changeset 1835:a29b5eea6e99

fltkui
author corvid <corvid@lavabit.com>
date Sat, 15 Jan 2011 21:55:04 +0000
parents 5c6c8a1a3cb7
children 879c110ecb57
files dw/fltkui.cc dw/fltkui.hh test/dw_ui_test.cc
diffstat 3 files changed, 20 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/dw/fltkui.cc	Sat Jan 15 20:55:23 2011 +0000
+++ b/dw/fltkui.cc	Sat Jan 15 21:55:04 2011 +0000
@@ -30,7 +30,7 @@
 #include <FL/Fl_Input.H>
 #include <FL/Fl_Text_Editor.H>
 #include <FL/Fl_Check_Button.H>
-#include <FL/Fl_Radio_Button.H>
+#include <FL/Fl_Round_Button.H>
 #include <FL/Fl_Choice.H>
 #include <FL/Fl_Tree.H>
 
@@ -823,7 +823,7 @@
     */
 
    Fl_Button *button =
-      new Fl_Radio_Button (allocation->x, allocation->y, allocation->width,
+      new Fl_Round_Button (allocation->x, allocation->y, allocation->width,
                            allocation->ascent + allocation->descent);
 // button->clear_flag (SHORTCUT_LABEL);
    button->when (FL_WHEN_CHANGED);
@@ -977,8 +977,9 @@
    Fl_Tree *tree =
       new Fl_Tree (allocation->x, allocation->y, allocation->width,
                            allocation->ascent + allocation->descent);
-   if (mode == SELECTION_MULTIPLE)
-      tree->selectmode(FL_TREE_SELECT_MULTI);
+
+   tree->selectmode((mode == SELECTION_MULTIPLE) ? FL_TREE_SELECT_MULTI
+                                                 : FL_TREE_SELECT_SINGLE);
 // tree->clear_flag (SHORTCUT_LABEL);
    tree->callback(widgetCallback,this);
    tree->when(FL_WHEN_CHANGED);
@@ -1003,11 +1004,17 @@
    Fl_Tree_Item *item = ((Fl_Tree *)widget)->add(str);
    int index = itemsSelected.size ();
 
+   item->activate(enabled);
+
    itemsSelected.increase ();
    itemsSelected.set (index,selected);
 
-   item->select(selected);
-   item->activate(enabled);
+   if (selected) {
+      if (mode == SELECTION_MULTIPLE)
+         item->select(selected);
+      else
+         ((Fl_Tree *)widget)->select_only(item, 0);
+   }
 
    queueResize (true);
 }
--- a/dw/fltkui.hh	Sat Jan 15 20:55:23 2011 +0000
+++ b/dw/fltkui.hh	Sat Jan 15 21:55:04 2011 +0000
@@ -504,8 +504,7 @@
 protected:
    Fl_Widget *createNewWidget (core::Allocation *allocation);
 
-   //TODO we'll have to keep track
-   int getNumberOfItems () {return 0;};
+   int getNumberOfItems () {return itemsSelected.size();};
 
 private:
    static void widgetCallback (Fl_Widget *widget, void *data);
--- a/test/dw_ui_test.cc	Sat Jan 15 20:55:23 2011 +0000
+++ b/test/dw_ui_test.cc	Sat Jan 15 21:55:04 2011 +0000
@@ -202,17 +202,17 @@
       selres[i]->addItem("item 1", true, false);
 
 //    selres[i]->pushGroup("group 1", true);
-      selres[i]->addItem("item 1/1", true, false);
-      selres[i]->addItem("item 1/2", true, true);
-      selres[i]->addItem("item 1/3", false, false);
+      selres[i]->addItem("group 1/1", true, false);
+      selres[i]->addItem("group 1/2", true, true);
+      selres[i]->addItem("group 1/3", false, false);
 //    selres[i]->popGroup();
 
       selres[i]->addItem("item 2", true, i == 1);
 
 //    selres[i]->pushGroup("group 2", false);
-      selres[i]->addItem("item 2/1", true, false);
-      selres[i]->addItem("item 2/2", true, false);
-      selres[i]->addItem("item 2/3", false, false);
+      selres[i]->addItem("group 2/1", true, false);
+      selres[i]->addItem("group 2/2", true, false);
+      selres[i]->addItem("group 2/3", false, false);
 //    selres[i]->popGroup();
 
       selres[i]->addItem("item 3", false, false);