Mercurial > dillo_port1.3
changeset 1889:e86b79bd57c9
push/popGroup is back. Implemented for FltkOptionMenu
author | corvid <corvid@lavabit.com> |
---|---|
date | Sat, 29 Jan 2011 05:29:09 +0000 |
parents | c18a1d2c2557 |
children | 6b9486c3be92 |
files | dw/fltkui.cc dw/fltkui.hh dw/ui.hh |
diffstat | 3 files changed, 40 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/dw/fltkui.cc Sat Jan 29 04:48:59 2011 +0000 +++ b/dw/fltkui.cc Sat Jan 29 05:29:09 2011 +0000 @@ -948,8 +948,7 @@ ((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 @@ 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 @@ 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); }
--- a/dw/fltkui.hh Sat Jan 29 04:48:59 2011 +0000 +++ b/dw/fltkui.hh Sat Jan 29 05:29:09 2011 +0000 @@ -467,6 +467,8 @@ 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 @@ 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 @@ ~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 @@ ~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);
--- a/dw/ui.hh Sat Jan 29 04:48:59 2011 +0000 +++ b/dw/ui.hh Sat Jan 29 05:29:09 2011 +0000 @@ -421,6 +421,8 @@ { 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;