Fltk Labeltypes

There are several built-in values for labeltype(). They are:

Only the first two are actual constants. The other symbols are macros so the code is not linked in if not used. To make bitmaps or pixmaps you use a method on the Fl_Bitmap or Fl_Pixmap object, see those pages for details.

Making your own Labeltypes

Labeltypes are actually indexes into a table of functions to draw them. The primary purpose of this is to let you reuse the label() pointer as a pointer to arbitrary data such as a bitmap or pixmap. You can also use this to draw the labels in ways inaccessible through the fl_font mechanisim, such as engraved, or with program-generated letters, or with GL display lists.

typedef void (Fl_Label_Draw_F)(const Fl_Label*, int,int,int,int, Fl_Align align);
typedef void (Fl_Label_Measure_F)(const Fl_Label*, int&, int&);

void Fl::set_labeltype(Fl_Labeltype n, Fl_Label_Draw_F*, Fl_Label_Measure_F*);

void Fl::set_labeltype(Fl_Labeltype n, Fl_Labeltype from);

Symbols

The FL_SYMBOL_LABEL labeltype uses the label() string to look up a small drawing procedure in a hash table. For historical reasons the string always starts with '@', if it starts with something else (or the symbol is not found) the label is drawn normally:

The @ sign may be followed by the following optional "formatting" characters, in this order:

void Fl::enable_symbols();

widget->labeltype(FL_SYMBOL_LABEL);

int fl_draw_symbol(const char* n,int x,int y,int w,int h,Fl_Color c);

int fl_add_symbol(const char *, void (*f)(Fl_Color), int flags=1);

(back to contents)