Box Types

The type Fl_Boxtype stored and returned in Fl_Widget::box() is an enumeration defined in <Enumerations.H>:

FLTK Box Types

FL_NO_BOX means nothing is drawn at all, so whatever is already on the screen remains. The FL_..._FRAME types only draw their edges, leaving the interior unchanged. In the above diagram the blue color is the area that is not drawn by the box.

Making your own Boxtypes

Warning: This interface may change in future versions of fltk!

You can define your own boxtypes by making a small function that draws the box and adding it to the table of boxtypes.

The Drawing Function

The drawing function is passed the bounding box and background color for the widget:

void xyz_draw(int x, int y, int w, int h, Fl_Color c) {

A simple drawing function might fill a rectangle with the given color and then draw a black outline:

void xyz_draw(int x, int y, int w, int h, Fl_Color c) {
  fl_rectf(x, y, w, h);
  fl_rect(x, y, w, h);

Adding Your Box Type

The Fl::set_boxtype() method adds or replaces the specified box type:


Fl::set_boxtype(XYZ_BOX, xyz_draw, 1, 1, 2, 2);

The last 4 arguments to Fl::set_boxtype() are the offsets for the bounding box that should be subtracted when drawing the label inside the box.