Another approach - using fl_add_symbol():

I have a hack which wraps an image in a regular function, something like

void draw_my_icon(Fl_Color ){
      static Fl_Image * im1 = new Fl_PNG_Image(...);
      static im2 = (im1->copy())->deimage();
      Fl_Image * im = im1;
      if(fl_color() & 0xffffff00)  im = im2; // drawing inactive image - hack
      im->draw(0.5 + fl_transform_x(0, 1) - im->w() / 2, 0.5 + 
fl_transform_y(0, 1) - im->h() / 2);
}



Then you can do fl_add_symbol("my_icon", &draw_my_icon, 0);
and add your menu label like string with symbol using

   "@my_icon My label"


The disadvantage is that you need to define separate function for each image (I 
have a templated wrapper which simplifies that for me as the template generates
distinct functions with template parameter change)

It would be useful if fltk had this natively, eg using overloaded function

   fl_add_symbol(const char * name, Fl_Image * im);

This would be pretty easy to implement as the symbol table already has "int" 
flag field - so some bit could be used to identify if the pointer is function
pointer or image pointer and how the drawing should be called. Another option 
would be generalization of "Fl_Shared_Image" where the image names could be
directly used for the symbols (this would mean registering shared images in the 
hash table).

Any thoughts? maybe filling STR with similar a feature?

R.


On 16/03/2012 22:19, Jeff Ellis wrote:
> Is it possible to have both an image and a label in an Fl_Menu_Item? (E.g., 
> like popup menu's in most apps like, for example, MS-Outlook -- little icon 
> image on the left and menu label on the right.) I can't seem to figure out 
> how to do it.
> 
> I'm using FLTK 1.3.

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

Reply via email to