wxBrushList

A brush list is a list containing all brushes which have been created.

Derived from

wxList
wxObject

Include files

<wx/gdicmn.h>

Remarks

There is only one instance of this class: wxTheBrushList. Use this object to search for a previously created brush of the desired type and create it if not already found. In some windowing systems, the brush may be a scarce resource, so it can pay to reuse old resources if possible. When an application finishes, all brushes will be deleted and their resources freed, eliminating the possibility of `memory leaks'. However, it is best not to rely on this automatic cleanup because it can lead to double deletion in some circumstances.

There are two mechanisms in recent versions of wxWidgets which make the brush list less useful than it once was. Under Windows, scarce resources are cleaned up internally if they are not being used. Also, a reference counting mechanism applied to all GDI objects means that some sharing of underlying resources is possible. You don't have to keep track of pointers, working out when it is safe delete a brush, because the reference counting does it for you. For example, you can set a brush in a device context, and then immediately delete the brush you passed, because the brush is `copied'.

So you may find it easier to ignore the brush list, and instead create and copy brushes as you see fit. If your Windows resource meter suggests your application is using too many resources, you can resort to using GDI lists to share objects explicitly.

The only compelling use for the brush list is for wxWidgets to keep track of brushes in order to clean them up on exit. It is also kept for backward compatibility with earlier versions of wxWidgets.

See also

wxBrush



wxBrushList::wxBrushList



void wxBrushList(void)

Constructor. The application should not construct its own brush list: use the object pointer wxTheBrushList.



wxBrushList::AddBrush



void AddBrush(wxBrush * brush)

Used internally by wxWidgets to add a brush to the list.



wxBrushList::FindOrCreateBrush



wxBrush * FindOrCreateBrush(const wxColour& colour, int style = wxSOLID)

Finds a brush with the specified attributes and returns it, else creates a new brush, adds it to the brush list, and returns it.

Parameters

colour
Colour object.

style
Brush style. See wxBrush::SetStyle for a list of styles.



wxBrushList::RemoveBrush



void RemoveBrush(wxBrush * brush)

Used by wxWidgets to remove a brush from the list.

ymasuda 平成17年11月19日