Each widget has a pointer to an instance of Fl_Style. Usually many widgets share pointers to the same Fl_Style. All the Fl_Styles are linked into a hierarchy of parents & child styles, so that it is possible to change an item in a parent style and propagate all the changes to the children.
When a widget looks up a value from a style, it looks at that style and each parent up until it finds a non-zero value to return, or until there are no more parents, in which case zero is used. Thus changing a parent style can make global changes as long as widgets do not have local values set.
In normal usage "set" methods like Fl_Widget::box(n) will create a "unique" style for that widget, which is a child of the original style, and set the box in that style. This "unique" style is reused for any other changes to that widget and it is deleted when the widget is deleted.
FL_UP_BOX.
FL_DOWN_BOX.
FL_VALUE of the flags to
determine if the glyph is pushed in or turned on. If you write your
own function call the default of fl_glyph() for any symbols you don't
recognize. Currently defined glyphs:
FL_GLYPH_CHECK - draw a checkbox indicator
FL_GLYPH_RADIO - draw a radio button indicator
FL_GLYPH_UP - draw an up arrow at the top of a scrollbar
FL_GLYPH_DOWN - draw a down arrow at the botom of a scrollbar
FL_GLYPH_LEFT - draw a left arrow at the left of a scrollbar
FL_GLYPH_RIGHT - draw a right arrow at the right of a
scrollbar
FL_GLYPH_VSLIDER - draw a vertical slider/scrollbar handle
FL_GLYPH_HSLIDER - draw a horizontal slider/scrollbar handle
These glyphs all have values starting at 100 or more. Many widget subclasses define a private glyph function to draw parts of themselves, using local glyphs whose values start at 1. A "theme" may want to replace these functions, you should examine the fltk source code to find out what the codes for the glyphs are.
FL_HELVETICA.
label_font. Default is 12.
FL_HELVETICA.
text_font. Default is 12.
FL_NORMAL_LABEL.
box. Default is FL_GRAY.
If you wish to change the general color of fltk you probably want to
call fl_background(color)
instead, as this will set the entry for FL_GRAY and also
set the "gray ramp" so that the edges of buttons are the same color.
FL_NO_COLOR.
highlight_color. The
default of zero leaves the label_color unchanged.
text_box. Default is
FL_LIGHT2.
Check buttons, radio buttons, menu items, and light buttons use
this to color in the glyph that indicates check/radio state when the
button is turned on (text_background is used for the check
marks when they are off).
selection_color. The
default is FL_WHITE.
Fl_Named_Style(const char* name, void (*revert)(Fl_Style*), Fl_Style** pointer);name is the name you want themes to use to look up the style. If you don't care if the themes can see your widget class you can just use null for the name (you must still provide the pointer, as multiple themes have to be able make duplicates of your style with different "parent" pointers).
revert is a function that initializes the style to it's default value. The style is cleared to zero (meaning inherit from the default style) before revert is called. If revert is NULL then all-zeros is the default.
pointer is a pointer to the pointer to the style. This allows multiple themes to exist at once, because instead of the theme changing any already-used styles, it replaces the pointer with a new style. This can be used by programs that let the user design or test themes. If you don't plan to use your widget in such a program you can make a static instance of your style (rather than using new) and pass null as this pointer.
Here is an example of a class that wants the box to default to FL_ROUND_BOX:
static void revert(Fl_Style* s) {
s->box = FL_ROUND_BOX;
}
static Fl_Named_Style* style = new Fl_Named_Style("MyWidget", revert, &style);
MyWidget::MyWidget(int x, int y, int w, int h, const char *l)
: Fl_Widget(x,y,w,h,l)
{
style(::style);
}
You ususally only need to change a few styles to implement a theme. All widgets inherit from the default style anything that they don't set themselves.
Fl_Named_Style* Fl_Style::find(const char* name);To locate a style to modify by name, use this static Fl_Style method. By using this function for anything other than default_style it allows you to test if a style is actually linked into the program, so that you can make a theme plugin that changes any style.
Case is ignored and spaces and underscores are considered equivalent.
text_box is drawn around each item, and
selection_color is used to color the current one.
box is drawn
around each of them.
FL_GRAY is set the the rgb values of the
passed color. This is the best way to change the overall color of
your application, because it sets all the shaded borders.