wxWidgets: wxBrush Class Reference

| Version: 3.0.5

Public Member Functions | List of all members
wxBrush Class Reference
Class List by Category » Graphics Device Interface (GDI)

`#include </home/Hamish/wxwidgets/wxWidgets3.0-3.0.5.1-1.src/wxWidgets3.0-3.0.5.1-1.i686/src/wxWidgets-3.0.5.1/interface/wx/brush.h>`

Inheritance diagram for wxBrush:
[legend]

## Detailed Description

A brush is a drawing tool for filling in areas.

It is used for painting the background of rectangles, ellipses, etc. It has a colour and a style.

On a monochrome display, wxWidgets shows all brushes as white unless the colour is really black.

Do not initialize objects on the stack before the program commences, since other required structures may not have been set up yet. Instead, define global pointers to objects and create them in wxApp::OnInit or when required.

An application may wish to create brushes with different characteristics dynamically, and there is the consequent danger that a large number of duplicate brushes will be created. Therefore an application may wish to get a pointer to a brush by using the global list of brushes wxTheBrushList, and calling the member function wxBrushList::FindOrCreateBrush().

This class uses reference counting and copy-on-write internally so that assignments between two instances of this class are very cheap. You can therefore use actual objects instead of pointers without efficiency problems. If an instance of this class is changed it will create its own data internally so that other instances, which previously shared the data using the reference counting, are not affected.

##

Library: wxCore

<>< =''>:</>&;&;< =''>\ </></>

Predefined objects/pointers:

- wxNullBrush
- wxBLACK_BRUSH
- wxBLUE_BRUSH
- wxCYAN_BRUSH
- wxGREEN_BRUSH
- wxYELLOW_BRUSH
- wxGREY_BRUSH
- wxLIGHT_GREY_BRUSH
- wxMEDIUM_GREY_BRUSH
- wxRED_BRUSH
- wxTRANSPARENT_BRUSH
- wxWHITE_BRUSH

See also
  wxBrushList, wxDC, wxDC::SetBrush

## Public Member Functions
| wxBrush ()
| Default constructor. More...
| wxBrush (const wxColour &colour, wxBrushStyle style=wxBRUSHSTYLE_SOLID)
| Constructs a brush from a colour object and style. More...
| wxBrush (const wxBitmap &stippleBitmap)
| Constructs a stippled brush using a bitmap. More...
| wxBrush (const wxBrush &brush)
| Copy constructor, uses reference counting. More...
virtual | ~wxBrush ()
| Destructor. More...
virtual wxColour | GetColour () const
| Returns a reference to the brush colour. More...
virtual wxBitmap * | GetStipple () const
| Gets a pointer to the stipple bitmap. More...
virtual wxBrushStyle | GetStyle () const
| Returns the brush style, one of the wxBrushStyle values. More...
virtual bool | IsHatch () const
| Returns true if the style of the brush is any of hatched fills. More...
virtual bool | IsOk () const
| Returns true if the brush is initialised. More...
bool | IsNonTransparent () const
| Returns true if the brush is a valid non-transparent brush. More...
bool | IsTransparent () const
| Returns true if the brush is transparent. More...
virtual void | SetColour (const wxColour &colour)
| Sets the brush colour using red, green and blue values. More...
virtual void | SetColour (unsigned char red, unsigned char green, unsigned char blue)
virtual void | SetStipple (const wxBitmap &bitmap)
| Sets the stipple bitmap. More...
virtual void | SetStyle (wxBrushStyle style)
| Sets the brush style. More...
bool | operator!= (const wxBrush &brush) const
| Inequality operator. More...
bool | operator== (const wxBrush &brush) const
| Equality operator. More...
Public Member Functions inherited from wxGDIObject
| wxGDIObject ()
| Default constructor. More...
Public Member Functions inherited from wxObject
| wxObject ()
| Default ctor; initializes to NULL the internal reference data. More...
| wxObject (const wxObject &other)
| Copy ctor. More...
virtual | ~wxObject ()
| Destructor. More...
virtual wxClassInfo * | GetClassInfo () const
| This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar). More...
wxObjectRefData * | GetRefData () const
| Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. More...
bool | IsKindOf (const wxClassInfo *info) const
| Determines whether this class is a subclass of (or the same class as) the given class. More...
bool | IsSameAs (const wxObject &obj) const
| Returns true if this object has the same data pointer as obj. More...
void | Ref (const wxObject &clone)
| Makes this object refer to the data in clone. More...
void | SetRefData (wxObjectRefData *data)
| Sets the wxObject::m_refData pointer. More...
void | UnRef ()
| Decrements the reference count in the associated data, and if it is zero, deletes the data. More...
void | UnShare ()
| This is the same of AllocExclusive() but this method is public. More...
void | operator delete (void *buf)
| The delete operator is defined for debugging versions of the library only, when the identifier `WXDEBUG` is defined. More...
void * | operator new (size_t size, const wxString &filename=NULL, int lineNum=0)
| The new operator is defined for debugging versions of the library only, when the identifier `WXDEBUG` is defined. More...

## Additional Inherited Members
Protected Member Functions inherited from wxObject
void | AllocExclusive ()
| Ensure that this object's data is not shared with any other object. More...
virtual wxObjectRefData * | CreateRefData () const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. More...
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data. More...
Protected Attributes inherited from wxObject
wxObjectRefData * | m_refData
| Pointer to an object which is the object's reference-counted data. More...

## Constructor & Destructor Documentation

## ◆ wxBrush() [1/4]

wxBrush::wxBrush | ( |  | ) |

Default constructor.

The brush will be uninitialised, and wxBrush:IsOk() will return false.

## ◆ wxBrush() [2/4]

wxBrush::wxBrush | ( | const wxColour & | colour,
|  | wxBrushStyle | style = `wxBRUSHSTYLE_SOLID`
| ) |  |

Constructs a brush from a colour object and style.

Parameters

  colour | Colour object.
  style | One of the wxBrushStyle enumeration values.

## ◆ wxBrush() [3/4]

wxBrush::wxBrush | ( | const wxBitmap & | stippleBitmap | ) |

Constructs a stippled brush using a bitmap.

The brush style will be set to `wxBRUSHSTYLE_STIPPLE`.

## ◆ wxBrush() [4/4]

wxBrush::wxBrush | ( | const wxBrush & | brush | ) |

Copy constructor, uses reference counting.

## ◆ ~wxBrush()

virtual wxBrush::~wxBrush | ( |  | ) |
| virtual

Destructor.

See Object Destruction for more info.

Remarks
  Although all remaining brushes are deleted when the application exits, the application should try to clean up all brushes itself. This is because wxWidgets cannot know if a pointer to the brush object is stored in an application data structure, and there is a risk of double deletion.

## Member Function Documentation

## ◆ GetColour()

virtual wxColour wxBrush::GetColour | ( |  | ) | const
| virtual

Returns a reference to the brush colour.

See also
  SetColour()

## ◆ GetStipple()

virtual wxBitmap* wxBrush::GetStipple | ( |  | ) | const
| virtual

Gets a pointer to the stipple bitmap.

If the brush does not have a `wxBRUSHSTYLE_STIPPLE` style, this bitmap may be non-NULL but uninitialised (i.e. wxBitmap:IsOk() returns false).

See also
  SetStipple()

## ◆ GetStyle()

virtual wxBrushStyle wxBrush::GetStyle | ( |  | ) | const
| virtual

Returns the brush style, one of the wxBrushStyle values.

See also
  SetStyle(), SetColour(), SetStipple()

## ◆ IsHatch()

virtual bool wxBrush::IsHatch | ( |  | ) | const
| virtual

Returns true if the style of the brush is any of hatched fills.

See also
  GetStyle()

## ◆ IsNonTransparent()

bool wxBrush::IsNonTransparent | ( |  | ) | const

Returns true if the brush is a valid non-transparent brush.

This method returns true if the brush object is initialized and has a non-transparent style. Notice that this should be used instead of simply testing whether GetStyle() returns a style different from wxBRUSHSTYLE_TRANSPARENT if the brush may be invalid as GetStyle() would assert in this case.

See also
  IsTransparent()

Since
  2.9.2.

## ◆ IsOk()

virtual bool wxBrush::IsOk | ( |  | ) | const
| virtual

Returns true if the brush is initialised.

Notice that an uninitialized brush object can't be queried for any brush properties and all calls to the accessor methods on it will result in an assert failure.

## ◆ IsTransparent()

bool wxBrush::IsTransparent | ( |  | ) | const

Returns true if the brush is transparent.

A transparent brush is simply a brush with wxBRUSHSTYLE_TRANSPARENT style.

Notice that this function works even for non-initialized brushes (for which it returns false) unlike tests of the form `GetStyle() == wxBRUSHSTYLE_TRANSPARENT` which would assert if the brush is invalid.

See also
  IsNonTransparent()

Since
  2.9.2.

## ◆ operator!=()

bool wxBrush::operator!= | ( | const wxBrush & | brush | ) | const

Inequality operator.

See Object Comparison for more info.

## ◆ operator==()

bool wxBrush::operator== | ( | const wxBrush & | brush | ) | const

Equality operator.

See Object Comparison for more info.

## ◆ SetColour() [1/2]

virtual void wxBrush::SetColour | ( | const wxColour & | colour | ) |
| virtual

Sets the brush colour using red, green and blue values.

See also
  GetColour()

## ◆ SetColour() [2/2]

virtual void wxBrush::SetColour | ( | unsigned char | red,
|  | unsigned char | green,
|  | unsigned char | blue
| ) |  |
| virtual

## ◆ SetStipple()

virtual void wxBrush::SetStipple | ( | const wxBitmap & | bitmap | ) |
| virtual

Sets the stipple bitmap.

Parameters

  bitmap | The bitmap to use for stippling.

Remarks
  The style will be set to `wxBRUSHSTYLE_STIPPLE`, unless the bitmap has a mask associated to it, in which case the style will be set to `wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE`.

See also
  wxBitmap

## ◆ SetStyle()

virtual void wxBrush::SetStyle | ( | wxBrushStyle | style | ) |
| virtual

Sets the brush style.

Parameters

  style | One of the wxBrushStyle values.

See also
  GetStyle()