cwidget::style Class Reference

A "style" is a setting to be applied to a display element (widget, text, etc). More...

#include <style.h>

List of all members.

Public Member Functions

 style ()
 Initialize an "empty" style.
void set_fg (short _fg)
 Set the foreground color.
void set_bg (short _bg)
 Set the background color.
void attrs_on (attr_t attrs)
 Set the given attribute(s).
void attrs_off (attr_t attrs)
 Clear the given attribute(s).
void attrs_flip (attr_t attrs)
 Flip the given attribute(s).
void apply_style (const style &other)
 Update this style by applying the settings in the other style.
style operator+ (const style &other) const
 
Returns:
a new style formed by composing this style with other.

styleoperator+= (const style &other)
 Shorthand for apply_style.
bool operator== (const style &other) const
bool operator!= (const style &other) const
short get_fg () const
 
Returns:
the foreground color.

short get_bg () const
 
Returns:
the background color.

attr_t get_attrs () const
 
Returns:
the current attributes.

chtype apply_to (chtype ch) const
 
Returns:
the given character with its attributes updated with ours.

wchtype apply_to (wchtype ch) const
 
Returns:
the given character with its attributes updated with ours.


Detailed Description

A "style" is a setting to be applied to a display element (widget, text, etc).

This means color (foreground and background) and attributes. A style may contain settings for any or all of these; settings which are unspecified are taken from the context in which the display element occurs. For instance, the "button highlighted" style might simply toggle the REVERSE flag.

The interface of styles is high-level: each style is viewed as a function that applies to the current text attributes; you can also extract the style's "current" state in order to merge it with a cchar (this is the style applied to the "null" or default style). However, as there are only a relatively limited number of things each style can change, the representation doesn't rely on virtual functions or even on keeping an array of operations to be applied; instead, it just keeps a summary of the operations it represents.


Constructor & Destructor Documentation

cwidget::style::style (  )  [inline]

Initialize an "empty" style.


Member Function Documentation

void cwidget::style::set_fg ( short  _fg  )  [inline]

Set the foreground color.

There is no change if the new foreground color is "empty".

void cwidget::style::set_bg ( short  _bg  )  [inline]

Set the background color.

There is no change if the new background color is "empty".

void cwidget::style::attrs_on ( attr_t  attrs  )  [inline]

Set the given attribute(s).

void cwidget::style::attrs_off ( attr_t  attrs  )  [inline]

Clear the given attribute(s).

void cwidget::style::attrs_flip ( attr_t  attrs  )  [inline]

Flip the given attribute(s).

style cwidget::style::operator+ ( const style other  )  const [inline]

Returns:
a new style formed by composing this style with other.

Note that this is a noncommutative operator!

style& cwidget::style::operator+= ( const style other  )  [inline]

Shorthand for apply_style.

short cwidget::style::get_fg (  )  const [inline]

Returns:
the foreground color.

short cwidget::style::get_bg (  )  const [inline]

Returns:
the background color.

attr_t cwidget::style::get_attrs (  )  const [inline]

Returns:
the current attributes.

chtype cwidget::style::apply_to ( chtype  ch  )  const [inline]

Returns:
the given character with its attributes updated with ours.

wchtype cwidget::style::apply_to ( wchtype  ch  )  const [inline]

Returns:
the given character with its attributes updated with ours.


The documentation for this class was generated from the following file:
Generated on Fri Feb 8 12:54:57 2008 for cwidget by  doxygen 1.5.4