cwidget 0.5.16
Public Member Functions

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
styleoperator+= (const style &other)
 Shorthand for apply_style.
bool operator== (const style &other) const
bool operator!= (const style &other) const
short get_fg () const
short get_bg () const
attr_t get_attrs () const
chtype apply_to (chtype ch) const
wchtype apply_to (wchtype ch) const

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

chtype cwidget::style::apply_to ( chtype  ch) const [inline]
Returns:
the given character with its attributes updated with ours.

References cwidget::config::mix_color().

wchtype cwidget::style::apply_to ( wchtype  ch) const [inline]
Returns:
the given character with its attributes updated with ours.

References cwidget::wchtype::attrs, cwidget::wchtype::ch, and cwidget::config::mix_color().

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

Flip the given attribute(s).

Referenced by apply_style(), cwidget::fragf(), and cwidget::style_attrs_flip().

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

Clear the given attribute(s).

Referenced by apply_style(), and cwidget::style_attrs_off().

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

Set the given attribute(s).

Referenced by apply_style(), and cwidget::style_attrs_on().

attr_t cwidget::style::get_attrs ( ) const [inline]
Returns:
the current attributes.

References cwidget::config::mix_color().

Referenced by cwidget::widgets::widget::apply_style(), and cwidget::widgets::widget::display().

short cwidget::style::get_bg ( ) const [inline]
Returns:
the background color.
short cwidget::style::get_fg ( ) const [inline]
Returns:
the foreground color.
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.

References apply_style().

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

Set the background color.

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

Referenced by apply_style(), and cwidget::style_bg().

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

Set the foreground color.

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

Referenced by apply_style(), and cwidget::style_fg().


The documentation for this class was generated from the following file: