Wt  4.11.1
Public Types | Public Member Functions | List of all members
Wt::WBrush Class Reference

A value class that defines the style for filling a path. More...

#include <Wt/WBrush.h>

Inheritance diagram for Wt::WBrush:
[legend]

Public Types

typedef BrushStyle Style
 Typedef for enum Wt::BrushStyle.
 

Public Member Functions

 WBrush ()
 Creates a brush. More...
 
 WBrush (BrushStyle style)
 Creates a brush with the given style.
 
 WBrush (const WColor &color)
 Creates a solid brush of a given color. More...
 
 WBrush (StandardColor color)
 Creates a solid brush with a standard color. More...
 
 WBrush (const WGradient &gradient)
 Creates a gradient brush.
 
 ~WBrush ()=default
 Destructor.
 
 WBrush (const WBrush &other)
 Copy constructor.
 
bool operator== (const WBrush &other) const
 Comparison operator. More...
 
bool operator!= (const WBrush &other) const
 Comparison operator. More...
 
void setStyle (BrushStyle style)
 Sets the brush style. More...
 
BrushStyle style () const
 Returns the fill style. More...
 
void setColor (const WColor &color)
 Sets the brush color. More...
 
const WColorcolor () const
 Returns the brush color. More...
 
void setGradient (const WGradient &gradient)
 Sets the brush gradient. More...
 
const WGradientgradient () const
 Returns the brush gradient.
 
virtual std::string jsValue () const override
 Returns a JavaScript representation of the value of this object. More...
 
- Public Member Functions inherited from Wt::WJavaScriptExposableObject
bool isJavaScriptBound () const
 Returns whether this object is JavaScript bound. More...
 
std::string jsRef () const
 Returns a JavaScript reference to this object. More...
 

Detailed Description

A value class that defines the style for filling a path.

A brush defines the properties of how areas (the interior of shapes) are filled. A brush is defined either as a solid color or a gradient.

JavaScript exposability

A WBrush is JavaScript exposable. If a WBrush is JavaScript bound, it can be accessed in your custom JavaScript code through its handle's jsRef(). At the moment, only the color() property is exposed, e.g. a brush with the color WColor(10,20,30,255) will be represented in JavaScript as:

{
color: [10,20,30,255]
}
const WColor & color() const
Returns the brush color.
Definition: WBrush.h:132
Warning
A WBrush that is JavaScript exposed should be modified only through its handle. Any attempt at modifying it will cause an exception to be thrown.
See also
WPainter::setBrush(), WPen, WPaintedWidget::createJSBrush()

Constructor & Destructor Documentation

◆ WBrush() [1/3]

Wt::WBrush::WBrush ( )

Creates a brush.

Creates a brush with a BrushStyle::None fill style.

◆ WBrush() [2/3]

Wt::WBrush::WBrush ( const WColor color)

Creates a solid brush of a given color.

Creates a solid brush with the indicated color.

◆ WBrush() [3/3]

Wt::WBrush::WBrush ( StandardColor  color)

Creates a solid brush with a standard color.

Creates a solid brush with the indicated color.

Member Function Documentation

◆ color()

const WColor& Wt::WBrush::color ( ) const

Returns the brush color.

See also
color()

◆ jsValue()

std::string Wt::WBrush::jsValue ( ) const
overridevirtual

Returns a JavaScript representation of the value of this object.

Note
The value returned will reflect the current server side value of the object. If this object is JavaScript bound, this value may not reflect the actual client side value. If you need access to the client side value, use jsRef() intead.

Implements Wt::WJavaScriptExposableObject.

◆ operator!=()

bool Wt::WBrush::operator!= ( const WBrush other) const

Comparison operator.

Returns true if the brushes are different.

◆ operator==()

bool Wt::WBrush::operator== ( const WBrush other) const

Comparison operator.

Returns true if the brushes are exactly the same.

◆ setColor()

void Wt::WBrush::setColor ( const WColor color)

Sets the brush color.

If the current style is a gradient style, then it is reset to BrushStyle::Solid.

Exceptions
WExceptionif the brush is JavaScript bound
See also
color()

◆ setGradient()

void Wt::WBrush::setGradient ( const WGradient gradient)

Sets the brush gradient.

This also sets the style to BrushStyle::Gradient.

Exceptions
WExceptionif the brush is JavaScript bound

◆ setStyle()

void Wt::WBrush::setStyle ( BrushStyle  style)

Sets the brush style.

Exceptions
WExceptionif the brush is JavaScript bound
See also
style()

◆ style()

BrushStyle Wt::WBrush::style ( ) const

Returns the fill style.

See also
setStyle(BrushStyle)