aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/fltkui.cc19
-rw-r--r--dw/fltkui.hh3
-rw-r--r--test/dw_ui_test.cc12
3 files changed, 20 insertions, 14 deletions
diff --git a/dw/fltkui.cc b/dw/fltkui.cc
index b09b12ba..80000db4 100644
--- a/dw/fltkui.cc
+++ b/dw/fltkui.cc
@@ -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 *FltkRadioButtonResource::createNewButton (core::Allocation
*/
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_Widget *FltkListResource::createNewWidget (core::Allocation *allocation)
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 @@ void FltkListResource::addItem (const char *str, bool enabled, bool selected)
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);
}
diff --git a/dw/fltkui.hh b/dw/fltkui.hh
index 751c94e4..4d26bbd4 100644
--- a/dw/fltkui.hh
+++ b/dw/fltkui.hh
@@ -504,8 +504,7 @@ class FltkListResource:
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);
diff --git a/test/dw_ui_test.cc b/test/dw_ui_test.cc
index a94b7f3f..59173522 100644
--- a/test/dw_ui_test.cc
+++ b/test/dw_ui_test.cc
@@ -202,17 +202,17 @@ int main(int argc, char **argv)
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);