Fixed problem with empty submenus not getting the right offsets.
git-svn-id: file:///fltk/svn/fltk/trunk@211 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
8327071ab0
commit
e41c045fe5
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Menu_Type.cxx,v 1.8 1999/01/07 19:17:10 mike Exp $"
|
||||
// "$Id: Fl_Menu_Type.cxx,v 1.9 1999/01/13 15:51:51 mike Exp $"
|
||||
//
|
||||
// Menu item code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -135,16 +135,19 @@ void Fl_Menu_Item_Type::write_declare() {
|
||||
}
|
||||
}
|
||||
|
||||
// Search backwards to find the parent menu button and return it's name.
|
||||
// Also put in i the index into the button's menu item array belonging
|
||||
// to this menu item.
|
||||
const char* Fl_Menu_Item_Type::menu_name(int& i) {
|
||||
i = 0;
|
||||
Fl_Type* t = prev;
|
||||
while (t && t->is_menu_item()) {
|
||||
// be sure to count the {0} that ends a submenu:
|
||||
if (t->level > t->next->level ||
|
||||
if (t->level > t->next->level) i += (t->level - t->next->level);
|
||||
// detect empty submenu:
|
||||
t->level==t->next->level &&t->is_parent())
|
||||
else if (t->level == t->next->level && t->is_parent()) i++;
|
||||
t = t->prev;
|
||||
i++;
|
||||
t = t->prev; i++;
|
||||
}
|
||||
return unique_id(t, "menu", t->name(), t->label());
|
||||
}
|
||||
@ -267,22 +270,21 @@ void Fl_Menu_Item_Type::write_item() {
|
||||
}
|
||||
|
||||
void Fl_Menu_Item_Type::write_code1() {
|
||||
int i; const char* name = menu_name(i);
|
||||
if (!prev->is_menu_item()) {
|
||||
// for first menu item, declare the array
|
||||
int i; const char* n = menu_name(i);
|
||||
if (class_name())
|
||||
write_h(" static Fl_Menu_Item %s[];\n", n);
|
||||
write_h(" static Fl_Menu_Item %s[];\n", name);
|
||||
else
|
||||
write_h("extern Fl_Menu_Item %s[];\n", n);
|
||||
write_h("extern Fl_Menu_Item %s[];\n", name);
|
||||
}
|
||||
|
||||
const char *c = array_name(this);
|
||||
if (c) {
|
||||
int i; const char* n = menu_name(i);
|
||||
if (class_name())
|
||||
write_h(" static Fl_Menu_Item *%s;\n", c);
|
||||
else
|
||||
write_h("#define %s (%s+%d)\n", c, n, i);
|
||||
write_h("#define %s (%s+%d)\n", c, name, i);
|
||||
}
|
||||
|
||||
if (callback()) {
|
||||
@ -297,8 +299,7 @@ void Fl_Menu_Item_Type::write_code1() {
|
||||
|
||||
int init = 0;
|
||||
if (image) {
|
||||
int i; const char* n = menu_name(i);
|
||||
write_c(" {Fl_Menu_Item* o = &%s[%d];\n", n, i);
|
||||
write_c(" {Fl_Menu_Item* o = &%s[%d];\n", name, i);
|
||||
init = 1;
|
||||
image->write_code();
|
||||
}
|
||||
@ -306,8 +307,7 @@ void Fl_Menu_Item_Type::write_code1() {
|
||||
if (extra_code(n) && !isdeclare(extra_code(n))) {
|
||||
if (!init) {
|
||||
init = 1;
|
||||
int i; const char* n = menu_name(i);
|
||||
write_c("%s{ Fl_Menu_Item* o = &%s[%d];\n", indent(), n, i);
|
||||
write_c("%s{ Fl_Menu_Item* o = &%s[%d];\n", indent(), name, i);
|
||||
}
|
||||
write_c("%s %s\n", indent(), extra_code(n));
|
||||
}
|
||||
@ -529,5 +529,5 @@ void shortcut_in_cb(Shortcut_Button* i, void* v) {
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Menu_Type.cxx,v 1.8 1999/01/07 19:17:10 mike Exp $".
|
||||
// End of "$Id: Fl_Menu_Type.cxx,v 1.9 1999/01/13 15:51:51 mike Exp $".
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user