changeset 2037:18bad2dd4d3b

forms listResource item selection
author corvid <corvid@lavabit.com>
date Thu, 19 May 2011 18:15:16 +0000
parents 6a8f4de33240
children db2bd1610db1
files dw/fltkui.cc dw/fltkui.hh
diffstat 2 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/dw/fltkui.cc	Thu May 19 02:15:13 2011 +0000
+++ b/dw/fltkui.cc	Thu May 19 18:15:16 2011 +0000
@@ -1092,7 +1092,7 @@
    }
 }
 
-void *FltkListResource::newItem (const char *str, bool enabled)
+void *FltkListResource::newItem (const char *str, bool enabled, bool selected)
 {
    Fl_Tree *tree = (Fl_Tree *) widget;
    Fl_Tree_Item *parent = (Fl_Tree_Item *)currParent;
@@ -1103,6 +1103,7 @@
    item->activate(enabled);
    item->user_data((void *)index);
    itemsSelected.increase ();
+   itemsSelected.set (itemsSelected.size() - 1, selected);
 
    return item;
 }
@@ -1110,12 +1111,11 @@
 void FltkListResource::addItem (const char *str, bool enabled, bool selected)
 {
    Fl_Tree *tree = (Fl_Tree *) widget;
-   Fl_Tree_Item *item = (Fl_Tree_Item *) newItem(str, enabled);
+   Fl_Tree_Item *item = (Fl_Tree_Item *) newItem(str, enabled, selected);
 
    if (selected) {
       if (mode == SELECTION_MULTIPLE) {
          item->select(selected);
-         itemsSelected.set (itemsSelected.size() - 1, selected);
       } else {
          const bool do_callback = true;
          tree->select_only(item, do_callback);
@@ -1126,8 +1126,10 @@
 
 void FltkListResource::pushGroup (const char *name, bool enabled)
 {
+   bool selected = false;
+
    /* TODO: make it impossible to select a group */
-   currParent = (Fl_Tree_Item *) newItem(name, enabled);
+   currParent = (Fl_Tree_Item *) newItem(name, enabled, selected);
    queueResize (true);
 }
 
--- a/dw/fltkui.hh	Thu May 19 02:15:13 2011 +0000
+++ b/dw/fltkui.hh	Thu May 19 18:15:16 2011 +0000
@@ -490,7 +490,7 @@
 
 private:
    static void widgetCallback (Fl_Widget *widget, void *data);
-   void *newItem (const char *str, bool enabled);
+   void *newItem (const char *str, bool enabled, bool selected);
    void *currParent;
    lout::misc::SimpleVector <bool> itemsSelected;
    int showRows;