fltk::Style Class Reference

Inherited by fltk::NamedStyle.

List of all members.

Public Member Functions

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

Static Public Member Functions

static Stylefind (const char *name)

Public Attributes

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

Static Public Attributes

static bool draw_boxes_inactive_
static bool hide_underscore_
static 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 fltk::DOWN_BOX.

Box * Style::buttonbox (  )  const

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

Referenced by fltk::Button::draw(), and fltk::Item::set_style().

Symbol * Style::glyph (  )  const

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

Im most cases the fltk::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.

Font * Style::labelfont (  )  const

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

Referenced by fltk::drawstyle().

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 fltk::HELVETICA.

Referenced by fltk::drawstyle().

LabelType * Style::labeltype (  )  const

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

Color Style::color (  )  const

Color of the widgets. The default is fltk::WHITE. You may think most widgets are gray, but this is because Group and Window have their own Style with this set to fltk::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 fltk::set_background(color) instead, as this will set the entry for fltk::GRAY75 and also set the "gray ramp" so that the edges of buttons are the same color.

Referenced by fltk::drawstyle(), and fltk::Item::set_style().

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 fltk::CheckButton.

Referenced by fltk::drawstyle(), and fltk::Item::set_style().

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 fltk::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.

Referenced by fltk::Button::draw().

Color Style::buttoncolor (  )  const

Color used when drawing buttons. Default is fltk::GRAY75.

Referenced by fltk::drawstyle().

Color Style::labelcolor (  )  const

Color used to draw labels. Default is fltk::BLACK.

Referenced by fltk::drawstyle().

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.

Referenced by fltk::Button::draw(), fltk::drawstyle(), and fltk::Item::set_style().

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.

Referenced by fltk::drawstyle().

float Style::labelsize (  )  const

Size of labelfont(). Default is 12.

Referenced by fltk::drawstyle().

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.

Referenced by fltk::drawstyle().

float Style::leading (  )  const

Extra spacing added between text lines or other things that are stacked vertically. The default is 2. The function fltk::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 fltk::ALIGN_RIGHT|fltkALIGN_BOTTOM.

unsigned char Style::scrollbar_width (  )  const

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

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.

Referenced by fltk::Menu::draw_in().

bool Style::draw_boxes_inactive (  )  const [inline]

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

int Style::wheel_scroll_lines (  )  const [inline]

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

bool Style::dynamic (  )  const [inline]

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

Referenced by fltk::Widget::copy_style(), and fltk::Widget::~Widget().


Wed Jun 17 08:53:25 2009. FLTK ©2007 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.