FLTK 1.5.0
|
Allows a mixed text and/or graphics label to be applied to an Fl_Menu_Item or Fl_Widget. More...
#include <Fl_Multi_Label.H>
Public Member Functions | |
void | label (Fl_Menu_Item *) |
Associate an Fl_Multi_Label with an Fl_Menu_Item. More... | |
void | label (Fl_Widget *) |
Associate an Fl_Multi_Label with an Fl_Widget. More... | |
Public Attributes | |
const char * | labela |
Holds the "leftmost" of the two elements in the composite label. More... | |
const char * | labelb |
Holds the "rightmost" of the two elements in the composite label. More... | |
uchar | typea |
Holds the "type" of labela. More... | |
uchar | typeb |
Holds the "type" of labelb. More... | |
Allows a mixed text and/or graphics label to be applied to an Fl_Menu_Item or Fl_Widget.
Most regular FLTK widgets now support the ability to associate both images and text with a label but some special cases, notably the non-widget Fl_Menu_Item objects, do not. Fl_Multi_Label may be used to create menu items that have an icon and text, which would not normally be possible for an Fl_Menu_Item. For example, Fl_Multi_Label is used in the New->Code submenu in fluid, and others.
Each Fl_Multi_Label holds two elements, labela
and labelb
; each may hold either a text label (const char*) or an image (Fl_Image*). When displayed, labela
is drawn first and labelb
is drawn immediately to its right.
More complex labels can be constructed by setting labelb as another Fl_Multi_Label and thus chaining up a series of label elements.
When assigning a label element to one of labela
or labelb
, they should be explicitly cast to (const char*) if they are not of that type already.
Example Use: Fl_Menu_Bar
void Fl_Multi_Label::label | ( | Fl_Menu_Item * | o | ) |
Associate an Fl_Multi_Label with an Fl_Menu_Item.
This uses Fl_Menu_Item::label(Fl_Labeltype a, const char *b) internally to set the label and the label type of the menu item, i.e. it stores a pointer to the Fl_Multi_Label object (this). An existing label (pointer) will be overwritten.
This sets the type of the menu item's label to _FL_MULTI_LABEL - note the leading underscore ('_').
There is no way to use a method like Fl_Widget::copy_label() that transfers ownership of the Fl_Multi_Label and its linked objects (images, text, and chained Fl_Multi_Label's) to the menu item.
The Fl_Multi_Label and all linked images, text labels, or chained Fl_Multi_Label objects must exist during the lifetime of the menu and will not be released when the menu item is destroyed.
void Fl_Multi_Label::label | ( | Fl_Widget * | o | ) |
Associate an Fl_Multi_Label with an Fl_Widget.
This method uses Fl_Widget::label(Fl_Labeltype, const char *) internally to set the label of the widget, i.e. it stores a pointer to the Fl_Multi_Label object (this). An existing label that has been set using Fl_Widget::copy_label() will be released prior to the assignment of the new label.
This sets the type of the widget's label to _FL_MULTI_LABEL - note the leading underscore ('_').
There is no way to use a method like Fl_Widget::copy_label() that transfers ownership of the Fl_Multi_Label and its linked objects (images, text, and chained Fl_Multi_Label's) to the widget.
The Fl_Multi_Label and all linked images, text labels, or chained Fl_Multi_Label objects must exist during the lifetime of the widget and will not be released when the widget is destroyed.
const char* Fl_Multi_Label::labela |
Holds the "leftmost" of the two elements in the composite label.
Typically this would be assigned either a text string (const char*), a (Fl_Image*) or a (Fl_Multi_Label*).
const char* Fl_Multi_Label::labelb |
Holds the "rightmost" of the two elements in the composite label.
Typically this would be assigned either a text string (const char*), a (Fl_Image*) or a (Fl_Multi_Label*).
uchar Fl_Multi_Label::typea |
Holds the "type" of labela.
Typically this is set to FL_NORMAL_LABEL for a text label, FL_IMAGE_LABEL for an image (based on Fl_image) or FL_MULTI_LABEL if "chaining" multiple Fl_Multi_Label elements together.
uchar Fl_Multi_Label::typeb |
Holds the "type" of labelb.
Typically this is set to FL_NORMAL_LABEL for a text label, FL_IMAGE_LABEL for an image (based on Fl_image) or FL_MULTI_LABEL if "chaining" multiple Fl_Multi_Label elements together.