diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2004-06-07 19:23:12 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2004-06-07 19:23:12 +0000 |
| commit | e85d7a87523b157b92a7a4d20029f80c4dccbec5 (patch) | |
| tree | 03e36456ee997b771320934b1ff797616b96d13a /src/Fl_Menu.cxx | |
| parent | 8b298e1b9ba706f7fa3c281698c14ad55037da90 (diff) | |
The first menuitem in a menulist would not honor teh MENU_INVISIBLE flag.
I added the function Fl_Menu_Item::first() whi returns the first visible
menuitem, just like ::next() returns the next visible item, and added the
::first() call in the Menu code.
first() is an inline function that calls next(0). I updated next() to
correctly handle list where the current item is invisible.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3448 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Menu.cxx')
| -rw-r--r-- | src/Fl_Menu.cxx | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx index a39db6708..ce64cecec 100644 --- a/src/Fl_Menu.cxx +++ b/src/Fl_Menu.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Menu.cxx,v 1.18.2.12.2.30 2004/04/11 04:38:57 easysw Exp $" +// "$Id: Fl_Menu.cxx,v 1.18.2.12.2.31 2004/06/07 19:22:49 matthiaswm Exp $" // // Menu code for the Fast Light Tool Kit (FLTK). // @@ -53,6 +53,7 @@ const Fl_Menu_Item* Fl_Menu_Item::next(int n) const { if (n < 0) return 0; // this is so selected==-1 returns NULL const Fl_Menu_Item* m = this; int nest = 0; + if (!m->visible()) n++; while (n>0) { if (!m->text) { if (!nest) return m; @@ -239,6 +240,7 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp, set_modal(); clear_border(); menu = m; + m - m->first(); // find the first item that needs to be rendered drawn_selected = -1; if (button) { box(button->box()); @@ -379,7 +381,7 @@ void menuwindow::draw() { fl_draw_box(box(), 0, 0, w(), h(), color()); if (menu) { const Fl_Menu_Item* m; int j; - for (m=menu, j=0; m->text; j++, m = m->next()) drawentry(m, j, 0); + for (m=menu->first(), j=0; m->text; j++, m = m->next()) drawentry(m, j, 0); } } else { if (damage() & FL_DAMAGE_CHILD && selected!=drawn_selected) { // change selection @@ -403,7 +405,7 @@ int menuwindow::find_selected(int mx, int my) { if (my < 0 || my >= h()) return -1; if (!itemheight) { // menubar int xx = 3; int n = 0; - const Fl_Menu_Item* m = menu; + const Fl_Menu_Item* m = menu->first(); for (; ; m = m->next(), n++) { if (!m->text) return -1; xx += m->measure(0, button) + 16; @@ -421,7 +423,7 @@ int menuwindow::find_selected(int mx, int my) { int menuwindow::titlex(int n) { const Fl_Menu_Item* m; int xx = 3; - for (m=menu; n--; m = m->next()) xx += m->measure(0, button) + 16; + for (m=menu->first(); n--; m = m->next()) xx += m->measure(0, button) + 16; return xx; } @@ -754,7 +756,7 @@ Fl_Menu_Item::popup( // Search only the top level menu for a shortcut. Either &x in the // label or the shortcut fields are used: const Fl_Menu_Item* Fl_Menu_Item::find_shortcut(int* ip) const { - const Fl_Menu_Item* m = this; + const Fl_Menu_Item* m = first(); if (m) for (int ii = 0; m->text; m = m->next(), ii++) { if (m->activevisible()) { if (Fl::test_shortcut(m->shortcut_) @@ -770,7 +772,7 @@ const Fl_Menu_Item* Fl_Menu_Item::find_shortcut(int* ip) const { // Recursive search of all submenus for anything with this key as a // shortcut. Only uses the shortcut field, ignores &x in the labels: const Fl_Menu_Item* Fl_Menu_Item::test_shortcut() const { - const Fl_Menu_Item* m = this; + const Fl_Menu_Item* m = first(); const Fl_Menu_Item* ret = 0; if (m) for (; m->text; m = m->next()) { if (m->activevisible()) { @@ -789,5 +791,5 @@ const Fl_Menu_Item* Fl_Menu_Item::test_shortcut() const { } // -// End of "$Id: Fl_Menu.cxx,v 1.18.2.12.2.30 2004/04/11 04:38:57 easysw Exp $". +// End of "$Id: Fl_Menu.cxx,v 1.18.2.12.2.31 2004/06/07 19:22:49 matthiaswm Exp $". // |
