Making Your Own Boxtypes
You can define your own boxtypes by making a small function that draws the box and adding it to the table of boxtypes.
Adding Your Box Type
#define XYZ_BOX FL_FREE_BOXTYPE
Fl::set_boxtype(XYZ_BOX, xyz_draw, 1, 1, 2, 2);
The Drawing Function
void xyz_draw(int x, int y, int w, int h, Fl_Color c) {
fl_color(c);
fl_rectf(x, y, w, h);
fl_color(FL_BLACK);
fl_rect(x, y, w, h);
}
Making Your Own Label Types
Adding Your Label Type
#define XYZ_LABEL FL_FREE_LABELTYPE
Fl::set_labeltype(XYZ_LABEL, xyz_draw, xyz_measure);
The label type number n can be any integer value starting at the constant FL_FREE_LABELTYPE. Once
you have added the label type you can use the labeltype() method to select your label type.
Label Type Functions
void xyz_draw(const Fl_Label *label, int x, int y, int w, int h, Fl_Align align
) {
...
}
void xyz_measure(const Fl_Label *label, int &w, int &h) {
...
}
Making your own symbols
int fl_add_symbol(const char *name, void (*drawit)(Fl_Color), int scalable)
name is the name of the symbol without the "@"; scalable must be set to 1 if the symbol is generated using scalable vector drawing functions.To create a new symbol, you implement a drawing function void drawit(Fl_Color c) which typically uses the functions described in Drawing Complex Shapes to generate a vector shape inside a two-bytwo units sized box around the origin.
int fl_draw_symbol(const char *name,int x,int y,int w,int h,Fl_Color col)
This function draws a named symbol fitting the given rectangle.
A widgets can only have one callback at a time, even though you can change the trigger condition at any time.
If you want set multi callback, you must override the parent widget's handle() method. This method is called when event happened, then it decide what to do. Detail see: int Fl_Button::handle(int event)