Wt
3.3.8
|
A value class that defines a color. More...
#include <Wt/WColor>
Public Member Functions | |
WColor () | |
Creates a default color. More... | |
WColor (int red, int green, int blue, int alpha=255) | |
Creates a color with given red/green/blue/alpha components. More... | |
WColor (const WString &name) | |
Creates a color from a CSS name. More... | |
WColor (GlobalColor name) | |
Creates a predefined color. More... | |
void | setRgb (int red, int green, int blue, int alpha=255) |
Sets the red/green/blue/alpha components. More... | |
void | setName (const WString &name) |
Sets the CSS name. More... | |
bool | isDefault () const |
Returns if the color is the default color. More... | |
int | red () const |
Returns the red component. More... | |
int | green () const |
Returns the green component. More... | |
int | blue () const |
Returns the blue component. More... | |
int | alpha () const |
Returns the alpha component. More... | |
const WString & | name () const |
Returns the CSS name. More... | |
bool | operator== (const WColor &other) const |
Comparison operator. More... | |
bool | operator!= (const WColor &other) const |
Comparison operator. More... | |
const std::string | cssText (bool withAlpha=false) const |
Returns the color as a CSS property value. More... | |
A value class that defines a color.
A color corresponds to a CSS color. You can specify a color either using its red/green/blue components, or from a valid CSS name.
The color supports an alpha channel, which determines the degree of transparency. An alpha value of 0 is completely transparent (and thus invisible), while a value of 255 is completely opaque.
Wt::WColor::WColor | ( | ) |
Creates a default color.
The default color is depending on the context, another color (for example from a hierarchical parent in a widget tree), or a completely transparent color.
Wt::WColor::WColor | ( | int | red, |
int | green, | ||
int | blue, | ||
int | alpha = 255 |
||
) |
Creates a color with given red/green/blue/alpha components.
All four components must be specified with a value in the range (0 - 255). The alpha channel determines the degree of transparency. An alpha value of 0 is completely transparent (and thus invisible), while a value of 255 is completely opaque.
Wt::WColor::WColor | ( | const WString & | name | ) |
Creates a color from a CSS name.
The name
may be any valid CSS color name, including names colors such as "aqua", or colors defined as RGB components.
Only if the color is defined in terms of RGB components (using the #rgb, #rrggbb, rgb() or rgba() formats), will the CSS color be parsed into red, blue and green values. Otherwise, these values are not available, and the color can only be used in media that support CSS colors.
See also http://www.w3.org/TR/css3-color
Wt::WColor::WColor | ( | Wt::GlobalColor | name | ) |
Creates a predefined color.
Constructs one of the 16 predefined Wt colors constants.
int Wt::WColor::alpha | ( | ) | const |
Returns the alpha component.
Only available when the color was specified in terms of the RGB components using setRgb(int, int, int, int) or WColor(int, int, int, int).
int Wt::WColor::blue | ( | ) | const |
Returns the blue component.
Only available when the color was specified in terms of the RGB components using setRgb(int, int, int, int), WColor(int, int, int, int) or WColor(const WString& name) when the name was parsable.
If not available this method return 0.
const std::string Wt::WColor::cssText | ( | bool | withAlpha = false | ) | const |
Returns the color as a CSS property value.
This returns the color in rgb() or rgba() notation.
int Wt::WColor::green | ( | ) | const |
Returns the green component.
Only available when the color was specified in terms of the RGB components using setRgb(int, int, int, int), WColor(int, int, int, int) or WColor(const WString& name) when the name was parsable.
If not available this method return 0.
bool Wt::WColor::isDefault | ( | ) | const |
Returns if the color is the default color.
const WString& Wt::WColor::name | ( | ) | const |
Returns the CSS name.
Only available when it was set with setName(const WString&) or WColor(const WString& name).
bool Wt::WColor::operator!= | ( | const WColor & | other | ) | const |
Comparison operator.
Returns false if the two colors were not defined in exactly the same way. It may return return although they actually represent the same color.
bool Wt::WColor::operator== | ( | const WColor & | other | ) | const |
Comparison operator.
Returns true
if the two colors were defined in exactly the same way. It may return false
although they actually represent the same color.
int Wt::WColor::red | ( | ) | const |
Returns the red component.
Only available when the color was specified in terms of the RGB components using setRgb(int, int, int, int), WColor(int, int, int, int) or WColor(const WString& name) when the name was parsable .
If not available this method return 0.
void Wt::WColor::setName | ( | const WString & | name | ) |
Sets the CSS name.
void Wt::WColor::setRgb | ( | int | red, |
int | green, | ||
int | blue, | ||
int | alpha = 255 |
||
) |
Sets the red/green/blue/alpha components.
All four components must be specified with a value in the range (0 - 255). The alpha channel determines the degree of transparency. An alpha value of 0 is completely transparent (and thus invisible), while a value of 255 is completely opaque.