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.
The style may be one of:
On a monochrome display, the default behaviour is to show all brushes as white unless the colour is really black. If you wish the policy to be 'all non-white colours are black', as with pens, uncomment the piece of code documented in wxDC::SetBrush in wx_dc.cpp. Alternatively, set the Colour member of the device context to TRUE, and select appropriate colours.
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 FindOrCreateBrush. See wxBrushList and wxDC.
wxBrush::wxBrush
wxBrush::~wxBrush
wxBrush::GetColour
wxBrush::GetStipple
wxBrush::GetStyle
wxBrush::SetColour
wxBrush::SetStipple
wxBrush::SetStyle
void wxBrush(void)
void wxBrush(wxColour &colour, int style)
void wxBrush(char *colour_name, int style)
Constructs a brush: uninitialized, initialized with an RGB colour and a style, or initialized using a colour name and a style (see wxBrush::SetStyle). If the named colour form is used, an appropriate wxColour structure is found in the colour database.
void ~wxBrush(void)
Destructor, destroying the brush. Note that brushes should very rarely be deleted since windows may contain pointers to them. All brushes will be deleted when the application terminates.
If you have to delete a brush, then call wxDC::SetBrush with a NULL argument to ensure that the old brush is restored, and the current brush is selected out of the device context.
wxColour& GetColour(void)
Returns a reference to the brush colour.
wxBitmap * GetStipple(void)
Gets the stipple bitmap.
int GetStyle(void)
Returns the brush style, one of:
void SetColour(wxColour &colour)
void SetColour(char *colour_name)
void SetColour(int red, int green, int blue)
The brush's colour is changed to the given colour.
void SetStipple(wxBitmap *bitmap)
Sets the stipple bitmap.
Note that there is a big difference between stippling in X and Windows. On X, the stipple is a mask between the wxBitmap and current colour. On Windows, the current colour is ignored, and the bitmap colour is used. However, for pre-defined modes like wxCROSS_HATCH, the behaviour is the same for both platforms.
void SetStyle(int style)
Sets the brush style, one of: