1 package be
.nikiroo
.fanfix
.reader
;
3 import java
.util
.ArrayList
;
7 import be
.nikiroo
.fanfix
.data
.MetaData
;
9 public class TuiReaderMainWindow
extends TWindow
{
11 private List
<MetaData
> listKeys
;
12 private List
<String
> listItems
;
13 private TuiReaderApplication reader
;
19 * the main application
21 * bitmask of MODAL, CENTERED, or RESIZABLE
23 public TuiReaderMainWindow(TuiReaderApplication reader
,
24 List
<MetaData
> stories
) {
25 // Construct a demo window. X and Y don't matter because it will be
26 // centered on screen.
27 super(reader
, "Library", 0, 0, 60, 18, CENTERED
| RESIZABLE
34 listKeys
= new ArrayList
<MetaData
>();
35 listItems
= new ArrayList
<String
>();
37 if (stories
!= null) {
38 for (MetaData meta
: stories
) {
40 listItems
.add(desc(meta
));
44 list
= addList(listItems
, 0, 0, getWidth(), getHeight(), new TAction() {
47 if (list
.getSelectedIndex() >= 0) {
48 enterOnStory(listKeys
.get(list
.getSelectedIndex()));
53 // TODO: add the current "type" or filter
54 statusBar
= newStatusBar("Library");
55 statusBar
.addShortcutKeypress(TKeypress
.kbF10
, TCommand
.cmExit
, "Exit");
58 addLabel("Label (1,1)", 1, 1);
59 addButton("&Button (35,1)", 35, 1, new TAction() {
63 addCheckbox(1, 2, "Checky (1,2)", false);
64 addProgressBar(1, 3, 30, 42);
65 TRadioGroup groupy
= addRadioGroup(1, 4, "Radio groupy");
66 groupy
.addRadioButton("Fanfan");
67 groupy
.addRadioButton("Tulipe");
68 addField(1, 10, 20, false, "text not fixed.");
69 addField(1, 11, 20, true, "text fixed.");
70 addText("20x4 Text in (12,20)", 1, 12, 20, 4);
72 TTreeView tree
= addTreeView(30, 5, 20, 5);
73 TTreeItem root
= new TTreeItem(tree
, "expended root", true);
74 tree
.setSelected(root
); // needed to allow arrow navigation without
75 // mouse-clicking before
77 root
.addChild("child");
78 root
.addChild("child 2").addChild("sub child");
83 private void enterOnStory(MetaData meta
) {
87 private String
desc(MetaData meta
) {
88 return String
.format("%5s: %s", meta
.getLuid(), meta
.getTitle());