1 \section{\class{wxBrush
}}\label{wxbrush
}
3 A brush is a drawing tool for filling in areas. It is used for painting
4 the background of rectangles, ellipses, etc. It has a colour and a
7 \wxheading{Derived from
}
9 \helpref{wxGDIObject
}{wxgdiobject
}\\
10 \helpref{wxObject
}{wxobject
}
12 \wxheading{Include files
}
16 \wxheading{Predefined objects
}
29 wxMEDIUM
\_GREY\_BRUSH\\
30 wxLIGHT
\_GREY\_BRUSH\\
31 wxTRANSPARENT
\_BRUSH\\
37 On a monochrome display, wxWindows shows
38 all brushes as white unless the colour is really black.
40 Do not initialize objects on the stack before the program commences,
41 since other required structures may not have been set up yet. Instead,
42 define global pointers to objects and create them in
\helpref{wxApp::OnInit
}{wxapponinit
} or
45 An application may wish to create brushes with different
46 characteristics dynamically, and there is the consequent danger that a
47 large number of duplicate brushes will be created. Therefore an
48 application may wish to get a pointer to a brush by using the global
49 list of brushes
{\bf wxTheBrushList
}, and calling the member function
50 \rtfsp{\bf FindOrCreateBrush
}.
52 wxBrush uses a reference counting system, so assignments between brushes are very
53 cheap. You can therefore use actual wxBrush objects instead of pointers without
54 efficiency problems. Once one wxBrush object changes its data it will create its
55 own brush data internally so that other brushes, which previously shared the
56 data using the reference counting, are not affected.
58 %TODO: an overview for wxBrush.
61 \helpref{wxBrushList
}{wxbrushlist
},
\helpref{wxDC
}{wxdc
},
\helpref{wxDC::SetBrush
}{wxdcsetbrush
}
63 \latexignore{\rtfignore{\wxheading{Members
}}}
65 \membersection{wxBrush::wxBrush
}
67 \func{}{wxBrush
}{\void}
69 Default constructor. The brush will be uninitialised, and
\helpref{wxBrush::Ok
}{wxbrushok
} will
72 \func{}{wxBrush
}{\param{const wxColour\&
}{ colour
},
\param{int
}{ style
}}
74 Constructs a brush from a colour object and style.
76 \func{}{wxBrush
}{\param{const wxString\&
}{colourName
},
\param{int
}{ style
}}
78 Constructs a brush from a colour name and style.
80 \func{}{wxBrush
}{\param{const wxBitmap\&
}{stippleBitmap
}}
82 Constructs a stippled brush using a bitmap.
84 \func{}{wxBrush
}{\param{const wxBrush\&
}{ brush
}}
86 Copy constructor. This uses reference counting so is a cheap operation.
88 \wxheading{Parameters
}
90 \docparam{colour
}{Colour object.
}
92 \docparam{colourName
}{Colour name. The name will be looked up in the colour database.
}
94 \docparam{style
}{One of:
96 \begin{twocollist
}\itemsep=
0pt
97 \twocolitem{{\bf wxTRANSPARENT
}}{Transparent (no fill).
}
98 \twocolitem{{\bf wxSOLID
}}{Solid.
}
99 \twocolitem{{\bf wxBDIAGONAL
\_HATCH}}{Backward diagonal hatch.
}
100 \twocolitem{{\bf wxCROSSDIAG
\_HATCH}}{Cross-diagonal hatch.
}
101 \twocolitem{{\bf wxFDIAGONAL
\_HATCH}}{Forward diagonal hatch.
}
102 \twocolitem{{\bf wxCROSS
\_HATCH}}{Cross hatch.
}
103 \twocolitem{{\bf wxHORIZONTAL
\_HATCH}}{Horizontal hatch.
}
104 \twocolitem{{\bf wxVERTICAL
\_HATCH}}{Vertical hatch.
}
107 \docparam{brush
}{Pointer or reference to a brush to copy.
}
109 \docparam{stippleBitmap
}{A bitmap to use for stippling.
}
113 If a stipple brush is created, the brush style will be set to wxSTIPPLE.
117 \helpref{wxBrushList
}{wxbrushlist
},
\helpref{wxColour
}{wxcolour
},
\helpref{wxColourDatabase
}{wxcolourdatabase
}
119 \membersection{wxBrush::
\destruct{wxBrush
}}
121 \func{void
}{\destruct{wxBrush
}}{\void}
127 The destructor may not delete the underlying brush object of the native windowing
128 system, since wxBrush uses a reference counting system for efficiency.
130 Although all remaining brushes are deleted when the application exits,
131 the application should try to clean up all brushes itself. This is because
132 wxWindows cannot know if a pointer to the brush object is stored in an
133 application data structure, and there is a risk of double deletion.
135 \membersection{wxBrush::GetColour
}\label{wxbrushgetcolour
}
137 \constfunc{wxColour\&
}{GetColour
}{\void}
139 Returns a reference to the brush colour.
143 \helpref{wxBrush::SetColour
}{wxbrushsetcolour
}
145 \membersection{wxBrush::GetStipple
}\label{wxbrushgetstipple
}
147 \constfunc{wxBitmap *
}{GetStipple
}{\void}
149 Gets a pointer to the stipple bitmap. If the brush does not have a wxSTIPPLE style,
150 this bitmap may be non-NULL but uninitialised (
\helpref{wxBitmap::Ok
}{wxbitmapok
} returns FALSE).
154 \helpref{wxBrush::SetStipple
}{wxbrushsetstipple
}
156 \membersection{wxBrush::GetStyle
}\label{wxbrushgetstyle
}
158 \constfunc{int
}{GetStyle
}{\void}
160 Returns the brush style, one of:
162 \begin{twocollist
}\itemsep=
0pt
163 \twocolitem{{\bf wxTRANSPARENT
}}{Transparent (no fill).
}
164 \twocolitem{{\bf wxSOLID
}}{Solid.
}
165 \twocolitem{{\bf wxBDIAGONAL
\_HATCH}}{Backward diagonal hatch.
}
166 \twocolitem{{\bf wxCROSSDIAG
\_HATCH}}{Cross-diagonal hatch.
}
167 \twocolitem{{\bf wxFDIAGONAL
\_HATCH}}{Forward diagonal hatch.
}
168 \twocolitem{{\bf wxCROSS
\_HATCH}}{Cross hatch.
}
169 \twocolitem{{\bf wxHORIZONTAL
\_HATCH}}{Horizontal hatch.
}
170 \twocolitem{{\bf wxVERTICAL
\_HATCH}}{Vertical hatch.
}
171 \twocolitem{{\bf wxSTIPPLE
}}{Stippled using a bitmap.
}
172 \twocolitem{{\bf wxSTIPPLE_MASK_OPAQUE
}}{Stippled using a bitmap's mask.
}
177 \helpref{wxBrush::SetStyle
}{wxbrushsetstyle
},
\helpref{wxBrush::SetColour
}{wxbrushsetcolour
},
\rtfsp
178 \helpref{wxBrush::SetStipple
}{wxbrushsetstipple
}
180 \membersection{wxBrush::Ok
}\label{wxbrushok
}
182 \constfunc{bool
}{Ok
}{\void}
184 Returns TRUE if the brush is initialised. It will return FALSE if the default
185 constructor has been used (for example, the brush is a member of a class, or
186 NULL has been assigned to it).
188 \membersection{wxBrush::SetColour
}\label{wxbrushsetcolour
}
190 \func{void
}{SetColour
}{\param{wxColour\&
}{colour
}}
192 Sets the brush colour using a reference to a colour object.
194 \func{void
}{SetColour
}{\param{const wxString\&
}{colourName
}}
196 Sets the brush colour using a colour name from the colour database.
198 \func{void
}{SetColour
}{\param{const unsigned char
}{ red
},
\param{const unsigned char
}{ green
},
\param{const unsigned char
}{ blue
}}
200 Sets the brush colour using red, green and blue values.
204 \helpref{wxBrush::GetColour
}{wxbrushgetcolour
}
206 \membersection{wxBrush::SetStipple
}\label{wxbrushsetstipple
}
208 \func{void
}{SetStipple
}{\param{const wxBitmap\&
}{ bitmap
}}
210 Sets the stipple bitmap.
212 \wxheading{Parameters
}
214 \docparam{bitmap
}{The bitmap to use for stippling.
}
218 The style will be set to wxSTIPPLE, unless the bitmap has a mask associated
219 to it, in which case the style will be set to wxSTIPPLE_MASK_OPAQUE.
221 If the wxSTIPPLE variant is used, the bitmap will be used to fill out the
222 area to be drawn. If the wxSTIPPLE_MASK_OPAQUE is used, the current
223 text foreground and text background determine what colours are used for
224 displaying and the bits in the mask (which is a mono-bitmap actually)
225 determine where to draw what.
227 Note that under Windows
95, only
8x8 pixel large stipple bitmaps are
228 supported, Windows
98 and NT as well as GTK support arbitrary bitmaps.
232 \helpref{wxBitmap
}{wxbitmap
}
234 \membersection{wxBrush::SetStyle
}\label{wxbrushsetstyle
}
236 \func{void
}{SetStyle
}{\param{int
}{ style
}}
238 Sets the brush style.
240 \docparam{style
}{One of:
242 \begin{twocollist
}\itemsep=
0pt
243 \twocolitem{{\bf wxTRANSPARENT
}}{Transparent (no fill).
}
244 \twocolitem{{\bf wxSOLID
}}{Solid.
}
245 \twocolitem{{\bf wxBDIAGONAL
\_HATCH}}{Backward diagonal hatch.
}
246 \twocolitem{{\bf wxCROSSDIAG
\_HATCH}}{Cross-diagonal hatch.
}
247 \twocolitem{{\bf wxFDIAGONAL
\_HATCH}}{Forward diagonal hatch.
}
248 \twocolitem{{\bf wxCROSS
\_HATCH}}{Cross hatch.
}
249 \twocolitem{{\bf wxHORIZONTAL
\_HATCH}}{Horizontal hatch.
}
250 \twocolitem{{\bf wxVERTICAL
\_HATCH}}{Vertical hatch.
}
251 \twocolitem{{\bf wxSTIPPLE
}}{Stippled using a bitmap.
}
252 \twocolitem{{\bf wxSTIPPLE_MASK_OPAQUE
}}{Stippled using a bitmap's mask.
}
257 \helpref{wxBrush::GetStyle
}{wxbrushgetstyle
}
259 \membersection{wxBrush::operator $=$
}\label{wxbrushassignment
}
261 \func{wxBrush\&
}{operator $=$
}{\param{const wxBrush\&
}{brush
}}
263 Assignment operator, using reference counting. Returns a reference
266 \membersection{wxBrush::operator $==$
}\label{wxbrushequals
}
268 \func{bool
}{operator $==$
}{\param{const wxBrush\&
}{brush
}}
270 Equality operator. Two brushes are equal if they contain pointers
271 to the same underlying brush data. It does not compare each attribute,
272 so two independently-created brushes using the same parameters will
275 \membersection{wxBrush::operator $!=$
}\label{wxbrushnotequals
}
277 \func{bool
}{operator $!=$
}{\param{const wxBrush\&
}{brush
}}
279 Inequality operator. Two brushes are not equal if they contain pointers
280 to different underlying brush data. It does not compare each attribute.
282 \section{\class{wxBrushList
}}\label{wxbrushlist
}
284 A brush list is a list containing all brushes which have been created.
286 \wxheading{Derived from
}
288 \helpref{wxList
}{wxlist
}\\
289 \helpref{wxObject
}{wxobject
}
291 \wxheading{Include files
}
297 There is only one instance of this class:
{\bf wxTheBrushList
}. Use
298 this object to search for a previously created brush of the desired
299 type and create it if not already found. In some windowing systems,
300 the brush may be a scarce resource, so it can pay to reuse old
301 resources if possible. When an application finishes, all brushes will
302 be deleted and their resources freed, eliminating the possibility of
303 `memory leaks'. However, it is best not to rely on this automatic
304 cleanup because it can lead to double deletion in some circumstances.
306 There are two mechanisms in recent versions of wxWindows which make the
307 brush list less useful than it once was. Under Windows, scarce resources
308 are cleaned up internally if they are not being used. Also, a referencing
309 counting mechanism applied to all GDI objects means that some sharing
310 of underlying resources is possible. You don't have to keep track of pointers,
311 working out when it is safe delete a brush, because the referencing counting does
312 it for you. For example, you can set a brush in a device context, and then
313 immediately delete the brush you passed, because the brush is `copied'.
315 So you may find it easier to ignore the brush list, and instead create
316 and copy brushes as you see fit. If your Windows resource meter suggests
317 your application is using too many resources, you can resort to using
318 GDI lists to share objects explicitly.
320 The only compelling use for the brush list is for wxWindows to keep
321 track of brushes in order to clean them up on exit. It is also kept for
322 backward compatibility with earlier versions of wxWindows.
326 \helpref{wxBrush
}{wxbrush
}
328 \latexignore{\rtfignore{\wxheading{Members
}}}
330 \membersection{wxBrushList::wxBrushList
}\label{wxbrushlistconstr
}
332 \func{void
}{wxBrushList
}{\void}
334 Constructor. The application should not construct its own brush list:
335 use the object pointer
{\bf wxTheBrushList
}.
337 \membersection{wxBrushList::AddBrush
}\label{wxbrushlistaddbrush
}
339 \func{void
}{AddBrush
}{\param{wxBrush *
}{brush
}}
341 Used internally by wxWindows to add a brush to the list.
343 \membersection{wxBrushList::FindOrCreateBrush
}\label{wxbrushlistfindorcreatebrush
}
345 \func{wxBrush *
}{FindOrCreateBrush
}{\param{const wxColour\&
}{colour
},
\param{int
}{ style
}}
347 Finds a brush with the specified attributes and returns it, else creates a new brush, adds it
348 to the brush list, and returns it.
350 \func{wxBrush *
}{FindOrCreateBrush
}{\param{const wxString\&
}{colourName
},
\param{int
}{ style
}}
352 Finds a brush with the specified attributes and returns it, else creates a new brush, adds it
353 to the brush list, and returns it.
355 Finds a brush of the given specification, or creates one and adds it to the list.
357 \wxheading{Parameters
}
359 \docparam{colour
}{Colour object.
}
361 \docparam{colourName
}{Colour name, which should be in the colour database.
}
363 \docparam{style
}{Brush style. See
\helpref{wxBrush::SetStyle
}{wxbrushsetstyle
} for a list of styles.
}
365 \membersection{wxBrushList::RemoveBrush
}\label{wxbrushlistremovebrush
}
367 \func{void
}{RemoveBrush
}{\param{wxBrush *
}{brush
}}
369 Used by wxWindows to remove a brush from the list.