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
This commit is contained in:
parent
8b298e1b9b
commit
e85d7a8752
2
CHANGES
2
CHANGES
@ -1,5 +1,7 @@
|
||||
CHANGES IN FLTK 1.1.5rc2
|
||||
|
||||
- first Menu Item in a list would not go invisible
|
||||
(STR #406)
|
||||
- Documaentation fix (STR #412)
|
||||
- Documentation updates (STR #365, STR #399)
|
||||
- Fl_Text_Buffer::replace() now range checks its input
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Menu_Item.H,v 1.5.2.4.2.8 2004/04/11 04:38:54 easysw Exp $"
|
||||
// "$Id: Fl_Menu_Item.H,v 1.5.2.4.2.9 2004/06/07 19:22:45 matthiaswm Exp $"
|
||||
//
|
||||
// Menu item header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -64,6 +64,8 @@ struct FL_EXPORT Fl_Menu_Item {
|
||||
const Fl_Menu_Item *next(int=1) const;
|
||||
Fl_Menu_Item *next(int i=1) {
|
||||
return (Fl_Menu_Item*)(((const Fl_Menu_Item*)this)->next(i));}
|
||||
const Fl_Menu_Item *first() const { return next(0); }
|
||||
Fl_Menu_Item *first() { return next(0); }
|
||||
|
||||
// methods on menu items:
|
||||
const char* label() const {return text;}
|
||||
@ -159,5 +161,5 @@ enum { // back-compatability enum:
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Menu_Item.H,v 1.5.2.4.2.8 2004/04/11 04:38:54 easysw Exp $".
|
||||
// End of "$Id: Fl_Menu_Item.H,v 1.5.2.4.2.9 2004/06/07 19:22:45 matthiaswm Exp $".
|
||||
//
|
||||
|
@ -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 $".
|
||||
//
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Menu_Bar.cxx,v 1.7.2.6.2.4 2004/04/11 04:38:58 easysw Exp $"
|
||||
// "$Id: Fl_Menu_Bar.cxx,v 1.7.2.6.2.5 2004/06/07 19:23:12 matthiaswm Exp $"
|
||||
//
|
||||
// Menu bar widget for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -32,7 +32,7 @@ void Fl_Menu_Bar::draw() {
|
||||
if (!menu() || !menu()->text) return;
|
||||
const Fl_Menu_Item* m;
|
||||
int X = x()+6;
|
||||
for (m=menu(); m->text; m = m->next()) {
|
||||
for (m=menu()->first(); m->text; m = m->next()) {
|
||||
int W = m->measure(0,this) + 16;
|
||||
m->draw(X, y(), W, h(), this);
|
||||
X += W;
|
||||
@ -72,5 +72,5 @@ int Fl_Menu_Bar::handle(int event) {
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Menu_Bar.cxx,v 1.7.2.6.2.4 2004/04/11 04:38:58 easysw Exp $".
|
||||
// End of "$Id: Fl_Menu_Bar.cxx,v 1.7.2.6.2.5 2004/06/07 19:23:12 matthiaswm Exp $".
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user