FL 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. These functions let you define new labeltypes, replace existing ones, or get at the actual function. 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 int (Fl_LabelFunction)(const Fl_Label*,int,int,int,int,uchar align);

An Fl_Label is a small structure imbedded in Fl_Object containing:
struct Fl_Label {
  const char* value;
  uchar type;
  uchar font;
  uchar size;
  uchar color;
  void draw(int,int,int,int, uchar align) const ;
};

The labeltype function takes a pointer to this structure and a a bounding box and alignment. The label should be drawn inside this bounding box, even though FL_ALIGN_INSIDE may not be on.

The function is never called if value is null. The function should return 1 if it draws something. If it returns 0 then the main code assummes nothing was done and calls the FL_NORMAL_LABEL code as a fallback (this is to be compatable with how Forms did symbols). See <FL/fl_draw.H> for the available drawing functions.

Fl_LabelFunction* Fl::get_labeltype(uchar);

Return the function for a labeltype.

uchar Fl::set_labeltype(uchar n, Fl_LabelFunction*);

Replace the function for labeltype n. Returns n.

uchar Fl::set_labeltype(uchar n, uchar from);

Copy one labeltype to another. Returns n.

uchar Fl::set_labeltype(Fl_LabelFunction*);

FL selects an unused labeltype, assigns the function to it, and returns it.

(back to contents)