On 03/03/12 14:19, Ian MacArthur wrote:
> On 3 Mar 2012, at 17:09, Greg Ercolano wrote:
>> On 03/03/12 08:34, yannick wrote:
>>> I want menu to look like this:
>>>
>>> +---------+
>>> |@ Foobar |
>>> |# bar    |
>>> |$ baz    |
>>> +---------+
>>>
>>> where @, #, and $ represents images. But when I set image it show only that 
>>> image, no text.
>>
>>      Don't know, someone else might be able to help with that.
> 
> I don't know either - I guess you'd want the equivalent of the FL_ALIGN 
> options to do FL_ALIGN_IMAGE_NEXT_TO_TEXT - that would show the image with 
> the label text to the right of the image.
> Only we can't actually do that, so far as I know. Seems like it would be a 
> nice thing to be able to do, for icons and labels in menus.
> Maybe you can fake up that effect using conventional buttons - they will 
> support images and text together just like that...?
> I wonder why we don't have that already, actually?

        I looked into this a little, it's a bit convoluted.

        item->image(img) really calls the seemingly backwards img->label(item);
        to do the actual work. So in other words, it tells the image to attach
        itself to the item:

void image(Fl_Image* a) {a->label(this);}

        But, Fl_Image::label(item) then does this:

void Fl_Image::label(Fl_Menu_Item* m) {
  Fl::set_labeltype(_FL_IMAGE_LABEL, labeltype, measure);
  m->label(_FL_IMAGE_LABEL, (const char*)this);
}

        ..which turns around *again* and tells the item that its label
        is an _FL_IMAGE_LABEL type, and to use the image as the 'text'!
        Fl_Menu_Item::label() is implemented as:

  void label(Fl_Labeltype a,const char* b) {labeltype_ = a; text = b;}

        This was surely not a design so much as a hack of some kind,
        comments say to make fluid work.

        I imagine that somewhere in Fl_Menu_Item::draw() this all gets
        sorted out, and the reason the text isn't shown is cause the text
        is the image pointer.

        This is probably a mess that needs some cleanup.

        Perhaps this was all done to avoid ABI issues, and perhaps now
        that we have an ABI workaround, this can be fixed properly as
        another ABI breaking feature..?

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

Reply via email to