Wt: Wt::WColor Class Reference

Wt 3.3.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Hierarchy
- Class Members

Public Member Functions
Wt::WColor Class Reference
Style classes | Painting system

A value class that defines a color. More...

`#include <Wt/WColor>`

List of all members.

## 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 (GlobalColor 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.

## Detailed Description

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.

## Constructor & Destructor Documentation

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.

See also:
  setRgb(int, int, int, int)

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 rgba() format), will the CSS color be parsed into red, blue and green values. to an appropriate value. 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.

## Member Function Documentation

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.

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.

See also:
  WColor()

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.

See also:
  WColor(const WString&)

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.

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator