Wt
4.11.0
|
A value class that defines a color. More...
#include <Wt/WColor.h>
Public Member Functions | |
WColor () | |
Creates a default color. | |
WColor (int red, int green, int blue, int alpha=255) | |
Creates a color with given red/green/blue/alpha components. | |
WColor (const WString &name) | |
Creates a color from a CSS name. | |
WColor (StandardColor name) | |
Creates a predefined color. | |
void | setRgb (int red, int green, int blue, int alpha=255) |
Sets the red/green/blue/alpha components. | |
void | setName (const WString &name) |
Sets the CSS name. | |
bool | isDefault () const |
Returns if the color is the default color. | |
int | red () const |
Returns the red component. | |
int | green () const |
Returns the green component. | |
int | blue () const |
Returns the blue component. | |
int | alpha () const |
Returns the alpha component. | |
const WString & | name () const |
Returns the CSS name. | |
bool | operator== (const WColor &other) const |
Comparison operator. | |
bool | operator!= (const WColor &other) const |
Comparison operator. | |
const std::string | cssText (bool withAlpha=true) const |
Returns the color as a CSS property value. | |
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.
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.
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 | ( | StandardColor | 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.
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.
Returns the CSS name.
Only available when it was set with setName(const WString&) or WColor(const WString& name).
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.
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.
Sets the CSS name.
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.