+ private void addSearch() {
+ TLabel lblSearch = addLabel("Search: ", 0, 0);
+
+ TField search = new TField(this, 0, 0, 1, true) {
+ @Override
+ public void onKeypress(TKeypressEvent keypress) {
+ super.onKeypress(keypress);
+ TKeypress key = keypress.getKey();
+ if (key.isFnKey() && key.getKeyCode() == TKeypress.ENTER) {
+ TuiReaderMainWindow.this.filter = getText();
+ TuiReaderMainWindow.this.refreshStories();
+ }
+ }
+ };
+
+ TSizeConstraint.setSize(sizeConstraints, lblSearch, 5, 1, null, null);
+ TSizeConstraint.setSize(sizeConstraints, search, 15, 1, -5, null);
+ }
+
+ private void addList() {
+ list = addList(listItems, 0, 0, 10, 10, new TAction() {
+ @Override
+ public void DO() {
+ MetaData meta = getSelectedMeta();
+ if (meta != null) {
+ readStory(meta);
+ }
+ }
+ });
+
+ TSizeConstraint.setSize(sizeConstraints, list, 0, 7, 0, 0);
+ }
+
+ private void addSelect() {
+ // TODO: make a full list
+ final List<String> options = new ArrayList<String>();
+ options.add("(all opt)");
+ options.add("Sources");
+ options.add("Author");
+
+ // TODO
+ final List<String> sources = new ArrayList<String>();
+ sources.add("(show all)");
+ for (String source : reader.getLibrary().getSources()) {
+ sources.add(source);
+ }
+
+ TLabel lblSelect = addLabel("Select: ", 0, 0);
+
+ // TODO: why must be last so to be able to draw over the rest
+ // TODO: make it so we cannot add manual entries
+ // TODO: how to select the item via keyboard? why double-click via
+ // mouse?
+ // TODO: how to change the values size on resize?
+ // TODO: setWidth() does not impact the display width, only the control
+ // and the down arrow on the right
+ // TODO: width 1 +resize + click on down arrow = bad format exception
+ select = addComboBox(0, 0, 10, sources, 0,
+ Math.min(sources.size() + 1, getHeight() - 1 - 1),
+ new TAction() {
+ @Override
+ public void DO() {
+ // TODO: wut?
+ if (select.getText().equals("(show all)")) {
+ setSource(null);
+ } else {
+ setSource(select.getText());
+ }
+ refreshStories();
+ }
+ });
+
+ final TComboBox option = addComboBox(0, 0, 10, options, 0,
+ Math.min(sources.size() + 1, getHeight() - 1 - 1),
+ new TAction() {
+ @Override
+ public void DO() {
+ // TODO Not working:
+ sources.clear();
+ sources.add("(show all)");
+ for (String source : reader.getLibrary().getSources()) {
+ sources.add(source);
+ }
+ }
+ });
+
+ TSizeConstraint.setSize(sizeConstraints, lblSelect, 5, 3, null, null);
+ TSizeConstraint.setSize(sizeConstraints, option, 15, 3, -5, null);
+ TSizeConstraint.setSize(sizeConstraints, select, 15, 4, -5, null);
+ }
+
+ @Override
+ public void onResize(TResizeEvent resize) {
+ super.onResize(resize);
+ TSizeConstraint.resize(sizeConstraints);
+ }
+