Style Class Reference

Inherited by NamedStyle.

List of all members.

Public Member Functions

Boxbox () const
Boxbuttonbox () const
Boxfocusbox () const
Symbolglyph () const
Fontlabelfont () const
Fonttextfont () const
LabelType * labeltype () const
Color color () const
Color textcolor () const
Color selection_color () const
Color selection_textcolor () const
Color buttoncolor () const
Color labelcolor () const
Color highlight_color () const
Color highlight_textcolor () const
float labelsize () const
float textsize () const
float leading () const
unsigned char scrollbar_align () const
unsigned char scrollbar_width () const
bool hide_underscore () const
bool draw_boxes_inactive () const
int wheel_scroll_lines () const
void box (Box *v)
void buttonbox (Box *v)
void focusbox (Box *v)
void glyph (Symbol *v)
void labelfont (Font *v)
void textfont (Font *v)
void labeltype (LabelType *v)
void color (Color v)
void textcolor (Color v)
void selection_color (Color v)
void selection_textcolor (Color v)
void buttoncolor (Color v)
void labelcolor (Color v)
void highlight_color (Color v)
void highlight_textcolor (Color v)
void labelsize (float v)
void textsize (float v)
void leading (float v)
void scrollbar_align (unsigned char v)
void scrollbar_width (unsigned char v)
void hide_underscore (bool v)
void draw_boxes_inactive (bool v)
void wheel_scroll_lines (int v)
 Style ()
bool dynamic () const

Static Public Member Functions

Stylefind (const char *name)

Public Attributes

const Styleparent_
Boxbox_
Boxbuttonbox_
Boxfocusbox_
Symbolglyph_
Fontlabelfont_
Fonttextfont_
LabelType * labeltype_
Color color_
Color textcolor_
Color selection_color_
Color selection_textcolor_
Color buttoncolor_
Color labelcolor_
Color highlight_color_
Color highlight_textcolor_
float labelsize_
float textsize_
float leading_
unsigned char scrollbar_align_
unsigned char scrollbar_width_
bool dynamic_

Static Public Attributes

bool hide_underscore_
bool draw_boxes_inactive_
int wheel_scroll_lines_


Detailed Description

Each widget has a pointer to an instance of Style. Usually many widgets share pointers to the same one. Styles are linked into a hierarchy tree by the parent_ pointers.

When you look up a value from a style (such as when box() is called) 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 returned. Thus changing a parent style can make global changes as long as widgets do not have local values set.

When you "set" a style (such as by calling box(UP_BOX)) then the local member variable is set. Notice that by setting a zero value you will indicate that it should return the parent value.

The method Widget::box(BOX) will create a dynamic() 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. Thus changes to a single widget do not affect other widgets, but the majority of widgets all share a Style structure.

Occasionally it is useful to see if a field has been set. To do this you can directly access the local member variables using names like box_.


Constructor & Destructor Documentation

Style::Style  ) 
 

The constructor clears the style to entirely zeros, including the parent_ pointer. You probably want to set the parent to Widget::default_style in order to inherit the global settings.


Member Function Documentation

Box * Style::box  )  const
 

The type of box to draw around the outer edge of the widget (for the majority of widgets, some classes ignore this or use it to draw only text fields inside the widget). The default is DOWN_BOX.

Box * Style::buttonbox  )  const
 

The type of box to draw buttons internal the widget (notice that Button uses box, however). The default is UP_BOX.

Color Style::buttoncolor  )  const
 

Color used when drawing buttons. Default is GRAY75.

Color Style::color  )  const
 

Color of the widgets. The default is WHITE. You may think most widgets are gray, but this is because Group and Window have their own Style with this set to GRAY75, and also because many parts of widgets are drawn with the buttoncolor().

If you want to change the overall color of all the gray parts of the interface you want to call set_background(color) instead, as this will set the entry for GRAY75 and also set the "gray ramp" so that the edges of buttons are the same color.

bool Style::draw_boxes_inactive  )  const [inline]
 

If false then most of the built-in box types draw the same even if INACTIVE_R is passed to them. This repliates Windows appearance. If true (the default) then the boxes themselves gray out.

bool Style::dynamic  )  const [inline]
 

True if this Style is unique to the Widget that owns it, and is not shared with other Widgets.

Box * Style::focusbox  )  const
 

Widgets draw this box atop the buttonbox() after they draw any labels or other graphics. If you have working alpha compositing this can add a translucent or highlighted overlay over the buttons.

This is called focusbox() because by default it is used to draw the Windows-style dotted focus lines. The default box draws this dotted line if FOCUESED is true, and draws nothing if false.

Symbol * Style::glyph  )  const
 

A small image that some Widgets use to draw part of themselves. For instance the CheckButton class has this set to a Symbol that draws the white box and the checkmark if VALUE is true.

Im most cases the drawflags() are examined to decide between differnt symbols. The default value draws empty squares and arrow buttons if ALIGN flags are on, see Widget::default_glpyh.

bool Style::hide_underscore  )  const [inline]
 

If false, draw &x in labels as an underscore. If true (the default) then the underscores are not drawn. In this case you should limit your &x hotkeys to menubar items, as underscores in buttons are not visible. The menubar will show them when Alt is held down.

Color Style::highlight_color  )  const
 

The color to draw the widget when the mouse is over it (for scrollbars and sliders this is used to color the buttons). Depending on the widget this will either recolor the buttons that are normally colored with buttoncolor(), or will recolor the main area that is normally colored with color().

The default value is zero, which indicates that highlighting is disabled.

Color Style::highlight_textcolor  )  const
 

Color used to draw the labels or text when the background is drawn in the highlight_color. The default of zero indicates that fltk will choose a contrasting color (either the same as the original color or white or black). I recommend you use the default if possible.

Color Style::labelcolor  )  const
 

Color used to draw labels. Default is BLACK.

Font * Style::labelfont  )  const
 

The font used to draw the label. Default is HELVETICA.

float Style::labelsize  )  const
 

Size of labelfont(). Default is 12.

LabelType * Style::labeltype  )  const
 

How to draw the label. This provides things like inset, shadow, and the symbols. NORMAL_LABEL.

float Style::leading  )  const
 

Extra spacing added between text lines or other things that are stacked vertically. The default is 2. The function drawtext() will use the value from Widget::default_style, but text editors and browsers and menus and similar widgets will use the local value.

unsigned char Style::scrollbar_align  )  const
 

Where to place scrollbars around a Browser or other scrolling widget. The default is ALIGN_RIGHT|ALIGN_BOTTOM.

unsigned char Style::scrollbar_width  )  const
 

How wide the scrollbars are around a Browser or other scrolling widget. The default is 15.

Color Style::selection_color  )  const
 

Color drawn behind selected text in inputs, or selected browser or menu items, or lit light buttons. The default is WINDOWS_BLUE.

Color Style::selection_textcolor  )  const
 

The color to draw text atop the selection_color. The default of zero indicates that fltk will choose a contrasting color (either the same as the original color or white or black). I recommend you use the default if possible.

Color Style::textcolor  )  const
 

Color to draw text inside the widget. Default is black. This is also used by many widgets to control the color when they draw the glyph(), thus it can control the color of checkmarks in CheckButton.

Font * Style::textfont  )  const
 

Font to use to draw information inside the widget, such as the text in a text editor or menu or browser. Default is HELVETICA.

float Style::textsize  )  const
 

Size of textfont(). This is also used by many Widgets to control the size they draw the glyph(). Default is 12.

int Style::wheel_scroll_lines  )  const [inline]
 

How many lines to move for one click of a mouse wheel. The default is 3.


The documentation for this class was generated from the following files:
Sun Jan 7 00:55:18 2007. FLTK ©2006 Bill Spitzak and others.
Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.