Wt 3.1.10
Public Member Functions
Wt::WColor Class Reference

A class that specifies 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 WStringname () const
 Returns the CSS name.
bool operator== (const WColor &other) const
 Comparison operator.
bool operator!= (const WColor &other) const
 Comparison operator.

Detailed Description

A class that specifies 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 RGB components are parsed and will initialize the internal red, blue and green values to an appropriate value, other strings will initialize these values to -1.

The alpha component is only parsed if the string is in the rgba() format.

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 throws a WtException.

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 throws a WtException.

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 throws a WtException.

void Wt::WColor::setName ( const WString name)

Sets the CSS name.

The name may be any valid CSS color name, including names colors such as "aqua", or colors defined as RGB components.

In either case, the result of the methods red(), green() and blue() is undefined.

See also http://www.w3.org/TR/REC-CSS2/syndata.html#value-def-color

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

Generated on Mon Nov 14 2011 for the C++ Web Toolkit (Wt) by doxygen 1.7.4