Hello,

I build a menu dymamically by add()ing the items and want to change 
some attributes. What is the proper way to do that?  Background: The
Fl_Menu_::menu() function returns a pointer to the array of Fl_Menu_Items
as a *const* pointer. The set-functions of class Fl_Menu_Item however
require non-constantness. Currently I cast simply away the 'const' as in
the following example:

void add_red_item ( Fl_Menu_* colors )
{
    int pos = colors->add ("Red", 0, 0);

    Fl_Menu_Item* array = const_cast<Fl_Menu_Item*>( colors->menu() );

    //  Change color of added item to Red
    array[ pos ].labelcolor (FL_RED);
}

Is there a more proper way without the cast? (Fltk 1)

Thanks,
Hartmut
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to