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 (not implemented in wx) 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() (not implemented in wx).
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.
Predefined objects (include wx.hrl):
wxWidgets docs: wxBrush
new() -> wxBrush()
new(Colour) -> wxBrush()
new(Brush) -> wxBrush()
Copy constructor, uses reference counting.
new(Colour, Options :: [Option]) -> wxBrush()
Constructs a brush from a colour object and style.
destroy(This :: wxBrush()) -> ok
See overview_refcount_destruct for more info.
Remark: 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.
getColour(This) -> wx:wx_colour4()
Returns a reference to the brush colour.
getStipple(This) -> wxBitmap:wxBitmap()
getStyle(This) -> wx:wx_enum()
isHatch(This) -> boolean()
Returns true if the style of the brush is any of hatched fills.
isOk(This) -> boolean()
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.
setColour(This, Colour) -> ok
Sets the brush colour using red, green and blue values.
setColour(This, Red, Green, Blue) -> ok
setStipple(This, Bitmap) -> ok
Sets the stipple bitmap.
Remark: 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.
setStyle(This, Style) -> ok
Sets the brush style.