summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/fltkui.cc34
-rw-r--r--dw/fltkui.hh7
-rw-r--r--dw/ui.hh2
3 files changed, 40 insertions, 3 deletions
diff --git a/dw/fltkui.cc b/dw/fltkui.cc
index 1cc502c8..686429ca 100644
--- a/dw/fltkui.cc
+++ b/dw/fltkui.cc
@@ -948,8 +948,7 @@ void FltkOptionMenuResource::enlargeMenu ()
((Fl_Choice *)widget)->menu(menu);
}
-void FltkOptionMenuResource::addItem (const char *str,
- bool enabled, bool selected)
+Fl_Menu_Item *FltkOptionMenuResource::newItem()
{
Fl_Menu_Item *item;
@@ -957,6 +956,16 @@ void FltkOptionMenuResource::addItem (const char *str,
enlargeMenu();
item = menu + itemsUsed - 1;
+ itemsUsed++;
+
+ return item;
+}
+
+void FltkOptionMenuResource::addItem (const char *str,
+ bool enabled, bool selected)
+{
+ Fl_Menu_Item *item = newItem();
+
item->text = strdup(str);
if (enabled == false)
@@ -967,8 +976,27 @@ void FltkOptionMenuResource::addItem (const char *str,
if (selected)
((Fl_Choice *)widget)->value(item);
- itemsUsed++;
+ queueResize (true);
+}
+void FltkOptionMenuResource::pushGroup (const char *name, bool enabled)
+{
+ Fl_Menu_Item *item = newItem();
+
+ item->text = strdup(name);
+
+ if (enabled == false)
+ item->flags = FL_MENU_INACTIVE;
+
+ item->flags |= FL_SUBMENU;
+
+ queueResize (true);
+}
+
+void FltkOptionMenuResource::popGroup ()
+{
+ /* Item with NULL text field closes the submenu */
+ newItem();
queueResize (true);
}
diff --git a/dw/fltkui.hh b/dw/fltkui.hh
index 24875161..cc5f5bc0 100644
--- a/dw/fltkui.hh
+++ b/dw/fltkui.hh
@@ -467,6 +467,8 @@ protected:
lout::container::typed::Vector <Item> *items;
virtual bool setSelectedItems() { return false; }
virtual void addItem (const char *str, bool enabled, bool selected) = 0;
+ virtual void pushGroup (const char *name, bool enabled) = 0;
+ virtual void popGroup () = 0;
public:
FltkSelectionResource (FltkPlatform *platform);
~FltkSelectionResource ();
@@ -486,6 +488,7 @@ protected:
private:
static void widgetCallback (Fl_Widget *widget, void *data);
void enlargeMenu();
+ Fl_Menu_Item *newItem();
Fl_Menu_Item *menu;
int itemsAllocated, itemsUsed;
public:
@@ -493,6 +496,8 @@ public:
~FltkOptionMenuResource ();
void addItem (const char *str, bool enabled, bool selected);
+ void pushGroup (const char *name, bool enabled);
+ void popGroup ();
void sizeRequest (core::Requisition *requisition);
bool isSelected (int index);
@@ -519,6 +524,8 @@ public:
~FltkListResource ();
void addItem (const char *str, bool enabled, bool selected);
+ void pushGroup (const char *name, bool enabled) {};
+ void popGroup () {};
void sizeRequest (core::Requisition *requisition);
bool isSelected (int index);
diff --git a/dw/ui.hh b/dw/ui.hh
index 23c1c0a4..0873217f 100644
--- a/dw/ui.hh
+++ b/dw/ui.hh
@@ -421,6 +421,8 @@ class SelectionResource: public Resource
{
public:
virtual void addItem (const char *str, bool enabled, bool selected) = 0;
+ virtual void pushGroup (const char *name, bool enabled) = 0;
+ virtual void popGroup () = 0;
virtual int getNumberOfItems () = 0;
virtual bool isSelected (int index) = 0;