Hello,
I'm constructing a Open Recent submenu (under File). My app is fully
constructed using FLUID, so I cannot alter the menu array as is done in
fluid.cxx.
When I add my entry, the entry doesn't take on the label font and label size
as the menu proper. To work around this, I need to do a const_cast on
menu() and then set the labelfont and labelsize manually.
Normally, I try to avoid casting away const. AFAIK, when something is
labelled as const, the compiler _may_ do something with it which could
cause undefined behaviour.
Here is what I am doing: Is this safe or is there something about Fl_Menu_
that I'm missing?
char menu_entry[128];
char shortcut[2];
// construct the menu entry
snprintf(menu_entry, 128, "File/Open Recent/%s", value);
snprintf(shortcut, 6, "^%d", i);
int idx = menubar->add(menu_entry,
shortcut,
(Fl_Callback*)file_open, value);
// cast away the const so item can be modified
Fl_Menu_Item &item = const_cast<Fl_Menu_Item&>(menubar->menu()[idx]);
item.labelfont(menubar->labelfont());
item.labelsize(menubar->labelsize());
Thanks!
--
Alvin
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk