cwidget
0.5.17
|
A "style" is a setting to be applied to a display element (widget, text, etc). More...
#include <style.h>
Public Member Functions | |
style () | |
Initialize an "empty" style. More... | |
void | set_fg (short _fg) |
Set the foreground color. More... | |
void | set_bg (short _bg) |
Set the background color. More... | |
void | attrs_on (attr_t attrs) |
Set the given attribute(s). More... | |
void | attrs_off (attr_t attrs) |
Clear the given attribute(s). More... | |
void | attrs_flip (attr_t attrs) |
Flip the given attribute(s). More... | |
void | apply_style (const style &other) |
Update this style by applying the settings in the other style. | |
style | operator+ (const style &other) const |
style & | operator+= (const style &other) |
Shorthand for apply_style. More... | |
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 |
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.
|
inline |
Initialize an "empty" style.
|
inline |
References cwidget::config::mix_color().
Referenced by cwidget::chstring::apply_style(), and cwidget::wchstring::apply_style().
References cwidget::wchtype::attrs, cwidget::wchtype::ch, and cwidget::config::mix_color().
|
inline |
Flip the given attribute(s).
Referenced by apply_style(), cwidget::fragf(), and cwidget::style_attrs_flip().
|
inline |
Clear the given attribute(s).
Referenced by apply_style(), and cwidget::style_attrs_off().
|
inline |
Set the given attribute(s).
Referenced by apply_style(), and cwidget::style_attrs_on().
|
inline |
References cwidget::config::mix_color().
Referenced by cwidget::chstring::apply_style(), cwidget::widgets::widget::apply_style(), cwidget::clipbox(), cwidget::widgets::widget::display(), cwidget::dropbox(), cwidget::flowbox(), and cwidget::chstring::operator=().
|
inline |
|
inline |
Shorthand for apply_style.
References apply_style().
|
inline |
Set the background color.
There is no change if the new background color is "empty".
Referenced by apply_style(), and cwidget::style_bg().
|
inline |
Set the foreground color.
There is no change if the new foreground color is "empty".
Referenced by apply_style(), and cwidget::style_fg().