Sorry for the late reply. I also had the idea of overriding the draw()
method. I coded it up late last night, but was too tired to e-mail it.
You'll find a working example for fluid below. I did this in 1.3.
# data file for the Fltk User Interface Designer (fluid)
version 1.0300
header_name {.h}
code_name {.cxx}
widget_class MyMenuBar {open
xywh {561 304 100 100} type Double
class Fl_Menu_Bar visible
} {
Function {end()} {open
} {}
Function {draw()} {open
} {
code {Fl_Menu_Item *view_menu = view_mnu;
printf("===== draw() =====\\n");
printf("view_menu: %p %s\\n", view_menu, view_menu ? view_menu-
>label() : "null");
view_menu++;
while (view_menu->label())
{
check_file(view_menu);
printf("\\t%p: %s", view_menu, view_menu->label());
if (!view_menu->visible()) printf(" (hidden)");
if (!view_menu->active()) printf(" (deactivated)");
printf("\\n");
view_menu++;
}
Fl_Menu_Bar::draw();} {}
}
Function {check_file(Fl_Menu_Item *mnu)} {open
} {
code {if (showall_chk->value())
{
mnu->activate();
mnu->show();
return;
}
if (0 == strcmp(mnu->label(), "file2.txt"))
mnu->deactivate();
if (0 == strcmp(mnu->label(), "file4.txt"))
mnu->hide();} {}
}
}
Function {make_window()} {open
} {
Fl_Window {} {open
xywh {430 281 515 320} type Double visible
} {
Fl_Menu_Bar main_mnu {
label MenuLabel open
xywh {0 0 515 25}
class MyMenuBar
} {
Submenu view_mnu {
label {&View} open
xywh {0 0 100 20}
} {
MenuItem {} {
label {file1.txt}
xywh {0 0 100 20} type Toggle
}
MenuItem {} {
label {file2.txt}
xywh {0 0 100 20} type Toggle
}
MenuItem {} {
label {file3.txt}
xywh {0 0 100 20} type Toggle
}
MenuItem {} {
label {file4.txt}
xywh {0 0 100 20} type Toggle
}
}
MenuItem showall_chk {
label {Show All Files}
callback {// Only necessary, if called from outside the menu.
//main_mnu->damage(FL_DAMAGE_ALL);
if (o->value())
showall2_chk->set();
else
showall2_chk->clear();}
xywh {0 0 100 20} type Toggle
}
}
Fl_Check_Button showall2_chk {
label {Show All Files}
callback {// Only necessary, if called from outside the menu.
main_mnu->damage(FL_DAMAGE_ALL);
if (o->value())
showall_chk->set();
else
showall_chk->clear();}
xywh {60 65 175 25} down_box DOWN_BOX
}
}
}
Function {} {} {
code {make_window()->show();} {}
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk