]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/brush.tex
Overwrote(!!) with source files that compile and link with latest wxGTK.
[wxWidgets.git] / docs / latex / wx / brush.tex
1 \section{\class{wxBrush}}\label{wxbrush}
2
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
5 style.
6
7 \wxheading{Derived from}
8
9 \helpref{wxGDIObject}{wxgdiobject}\\
10 \helpref{wxObject}{wxobject}
11
12 \wxheading{Remarks}
13
14 On a monochrome display, wxWindows shows
15 all brushes as white unless the colour is really black.
16
17 Do not initialize objects on the stack before the program commences,
18 since other required structures may not have been set up yet. Instead,
19 define global pointers to objects and create them in \helpref{wxApp::OnInit}{wxapponinit} or
20 when required.
21
22 An application may wish to create brushes with different
23 characteristics dynamically, and there is the consequent danger that a
24 large number of duplicate brushes will be created. Therefore an
25 application may wish to get a pointer to a brush by using the global
26 list of brushes {\bf wxTheBrushList}, and calling the member function
27 \rtfsp{\bf FindOrCreateBrush}.
28
29 wxBrush uses a reference counting system, so assignments between brushes are very
30 cheap. You can therefore use actual wxBrush objects instead of pointers without
31 efficiency problems. Bear in mind, though, that changing a brush's properties may
32 affect another brush which has been involved in an assignment with the first brush,
33 because of the way internal brush data is shared.
34
35 TODO: an overview for wxBrush.
36
37 \wxheading{See also}
38
39 \helpref{wxBrushList}{wxbrushlist}, \helpref{wxDC}{wxdc}, \helpref{wxDC::SetBrush}{wxdcsetbrush}
40
41 \latexignore{\rtfignore{\wxheading{Members}}}
42
43 \membersection{wxBrush::wxBrush}
44
45 \func{}{wxBrush}{\void}
46
47 Default constructor. The brush will be uninitialised, and \helpref{wxBrush::Ok}{wxbrushok} will
48 return FALSE.
49
50 \func{}{wxBrush}{\param{const wxColour\&}{ colour}, \param{int}{ style}}
51
52 Constructs a brush from a colour object and style.
53
54 \func{}{wxBrush}{\param{const wxString\& }{colourName}, \param{int}{ style}}
55
56 Constructs a brush from a colour name and style.
57
58 \func{}{wxBrush}{\param{const wxBitmap\& }{stippleBitmap}}
59
60 Constructs a stippled brush using a bitmap.
61
62 \func{}{wxBrush}{\param{const wxBrush\&}{ brush}}
63
64 Copy constructor. This uses reference counting so is a cheap operation.
65
66 \func{}{wxBrush}{\param{const wxBrush*}{ brush}}
67
68 Copy constructor. This uses reference counting so is a cheap operation.
69
70 \wxheading{Parameters}
71
72 \docparam{colour}{Colour object.}
73
74 \docparam{colourName}{Colour name. The name will be looked up in the colour database.}
75
76 \docparam{style}{One of:
77
78 \begin{twocollist}\itemsep=0pt
79 \twocolitem{{\bf wxTRANSPARENT}}{Transparent (no fill).}
80 \twocolitem{{\bf wxSOLID}}{Solid.}
81 \twocolitem{{\bf wxBDIAGONAL\_HATCH}}{Backward diagonal hatch.}
82 \twocolitem{{\bf wxCROSSDIAG\_HATCH}}{Cross-diagonal hatch.}
83 \twocolitem{{\bf wxFDIAGONAL\_HATCH}}{Forward diagonal hatch.}
84 \twocolitem{{\bf wxCROSS\_HATCH}}{Cross hatch.}
85 \twocolitem{{\bf wxHORIZONTAL\_HATCH}}{Horizontal hatch.}
86 \twocolitem{{\bf wxVERTICAL\_HATCH}}{Vertical hatch.}
87 \end{twocollist}}
88
89 \docparam{brush}{Pointer or reference to a brush to copy.}
90
91 \docparam{stippleBitmap}{A bitmap to use for stippling.}
92
93 \wxheading{Remarks}
94
95 If a stipple brush is created, the brush style will be set to wxSTIPPLE.
96
97 \wxheading{See also}
98
99 \helpref{wxBrushList}{wxbrushlist}, \helpref{wxColour}{wxcolour}, \helpref{wxColourDatabase}{wxcolourdatabase}
100
101 \membersection{wxBrush::\destruct{wxBrush}}
102
103 \func{void}{\destruct{wxBrush}}{\void}
104
105 Destructor.
106
107 \wxheading{Remarks}
108
109 The destructor may not delete the underlying brush object of the native windowing
110 system, since wxBrush uses a reference counting system for efficiency.
111
112 Although all remaining brushes are deleted when the application exits,
113 the application should try to clean up all brushes itself. This is because
114 wxWindows cannot know if a pointer to the brush object is stored in an
115 application data structure, and there is a risk of double deletion.
116
117 \membersection{wxBrush::GetColour}\label{wxbrushgetcolour}
118
119 \constfunc{wxColour\&}{GetColour}{\void}
120
121 Returns a reference to the brush colour.
122
123 \wxheading{See also}
124
125 \helpref{wxBrush::SetColour}{wxbrushsetcolour}
126
127 \membersection{wxBrush::GetStipple}\label{wxbrushgetstipple}
128
129 \constfunc{wxBitmap *}{GetStipple}{\void}
130
131 Gets a pointer to the stipple bitmap. If the brush does not have a wxSTIPPLE style,
132 this bitmap may be non-NULL but uninitialised (\helpref{wxBitmap::Ok}{wxbitmapok} returns FALSE).
133
134 \wxheading{See also}
135
136 \helpref{wxBrush::SetStipple}{wxbrushsetstipple}
137
138 \membersection{wxBrush::GetStyle}\label{wxbrushgetstyle}
139
140 \constfunc{int}{GetStyle}{\void}
141
142 Returns the brush style, one of:
143
144 \begin{twocollist}\itemsep=0pt
145 \twocolitem{{\bf wxTRANSPARENT}}{Transparent (no fill).}
146 \twocolitem{{\bf wxSOLID}}{Solid.}
147 \twocolitem{{\bf wxBDIAGONAL\_HATCH}}{Backward diagonal hatch.}
148 \twocolitem{{\bf wxCROSSDIAG\_HATCH}}{Cross-diagonal hatch.}
149 \twocolitem{{\bf wxFDIAGONAL\_HATCH}}{Forward diagonal hatch.}
150 \twocolitem{{\bf wxCROSS\_HATCH}}{Cross hatch.}
151 \twocolitem{{\bf wxHORIZONTAL\_HATCH}}{Horizontal hatch.}
152 \twocolitem{{\bf wxVERTICAL\_HATCH}}{Vertical hatch.}
153 \twocolitem{{\bf wxSTIPPLE}}{Stippled using a bitmap.}
154 \end{twocollist}
155
156 \wxheading{See also}
157
158 \helpref{wxBrush::SetStyle}{wxbrushsetstyle}, \helpref{wxBrush::SetColour}{wxbrushsetcolour},\rtfsp
159 \helpref{wxBrush::SetStipple}{wxbrushsetstipple}
160
161 \membersection{wxBrush::Ok}\label{wxbrushok}
162
163 \constfunc{bool}{Ok}{\void}
164
165 Returns TRUE if the brush is initialised. It will return FALSE if the default
166 constructor has been used (for example, the brush is a member of a class, or
167 NULL has been assigned to it).
168
169 \membersection{wxBrush::SetColour}\label{wxbrushsetcolour}
170
171 \func{void}{SetColour}{\param{wxColour\& }{colour}}
172
173 Sets the brush colour using a reference to a colour object.
174
175 \func{void}{SetColour}{\param{const wxString\& }{colourName}}
176
177 Sets the brush colour using a colour name from the colour database.
178
179 \func{void}{SetColour}{\param{const unsigned char}{ red}, \param{const unsigned char}{ green}, \param{const unsigned char}{ blue}}
180
181 Sets the brush colour using red, green and blue values.
182
183 \wxheading{See also}
184
185 \helpref{wxBrush::GetColour}{wxbrushgetcolour}
186
187 \membersection{wxBrush::SetStipple}\label{wxbrushsetstipple}
188
189 \func{void}{SetStipple}{\param{const wxBitmap\&}{ bitmap}}
190
191 Sets the stipple bitmap.
192
193 \wxheading{Parameters}
194
195 \docparam{bitmap}{The bitmap to use for stippling.}
196
197 \wxheading{Remarks}
198
199 The style will be set to wxSTIPPLE.
200
201 Note that there is a big difference between stippling in X and Windows.
202 On X, the stipple is a mask between the wxBitmap and current colour.
203 On Windows, the current colour is ignored, and the bitmap colour is used.
204 However, for pre-defined modes like wxCROSS\_HATCH, the behaviour is the
205 same for both platforms.
206
207 \wxheading{See also}
208
209 \helpref{wxBitmap}{wxbitmap}
210
211 \membersection{wxBrush::SetStyle}\label{wxbrushsetstyle}
212
213 \func{void}{SetStyle}{\param{int}{ style}}
214
215 Sets the brush style.
216
217 \docparam{style}{One of:
218
219 \begin{twocollist}\itemsep=0pt
220 \twocolitem{{\bf wxTRANSPARENT}}{Transparent (no fill).}
221 \twocolitem{{\bf wxSOLID}}{Solid.}
222 \twocolitem{{\bf wxBDIAGONAL\_HATCH}}{Backward diagonal hatch.}
223 \twocolitem{{\bf wxCROSSDIAG\_HATCH}}{Cross-diagonal hatch.}
224 \twocolitem{{\bf wxFDIAGONAL\_HATCH}}{Forward diagonal hatch.}
225 \twocolitem{{\bf wxCROSS\_HATCH}}{Cross hatch.}
226 \twocolitem{{\bf wxHORIZONTAL\_HATCH}}{Horizontal hatch.}
227 \twocolitem{{\bf wxVERTICAL\_HATCH}}{Vertical hatch.}
228 \twocolitem{{\bf wxSTIPPLE}}{Stippled using a bitmap.}
229 \end{twocollist}}
230
231 \wxheading{See also}
232
233 \helpref{wxBrush::GetStyle}{wxbrushgetstyle}
234
235 \membersection{wxBrush::operator $=$}\label{wxbrushassignment}
236
237 \func{wxBrush\&}{operator $=$}{\param{const wxBrush\& }{brush}}
238
239 Assignment operator, using reference counting. Returns a reference
240 to `this'.
241
242 \membersection{wxBrush::operator $==$}\label{wxbrushequals}
243
244 \func{bool}{operator $==$}{\param{const wxBrush\& }{brush}}
245
246 Equality operator. Two brushes are equal if they contain pointers
247 to the same underlying brush data. It does not compare each attribute,
248 so two independently-created brushes using the same parameters will
249 fail the test.
250
251 \membersection{wxBrush::operator $!=$}\label{wxbrushnotequals}
252
253 \func{bool}{operator $!=$}{\param{const wxBrush\& }{brush}}
254
255 Inequality operator. Two brushes are not equal if they contain pointers
256 to different underlying brush data. It does not compare each attribute.
257
258 \section{\class{wxBrushList}}\label{wxbrushlist}
259
260 A brush list is a list containing all brushes which have been created.
261
262 \wxheading{Derived from}
263
264 \helpref{wxList}{wxlist}\\
265 \helpref{wxObject}{wxobject}
266
267 \wxheading{Remarks}
268
269 There is only one instance of this class: {\bf wxTheBrushList}. Use
270 this object to search for a previously created brush of the desired
271 type and create it if not already found. In some windowing systems,
272 the brush may be a scarce resource, so it can pay to reuse old
273 resources if possible. When an application finishes, all brushes will
274 be deleted and their resources freed, eliminating the possibility of
275 `memory leaks'. However, it is best not to rely on this automatic
276 cleanup because it can lead to double deletion in some circumstances.
277
278 There are two mechanisms in recent versions of wxWindows which make the
279 brush list less useful than it once was. Under Windows, scarce resources
280 are cleaned up internally if they are not being used. Also, a referencing
281 counting mechanism applied to all GDI objects means that some sharing
282 of underlying resources is possible. You don't have to keep track of pointers,
283 working out when it is safe delete a brush, because the referencing counting does
284 it for you. For example, you can set a brush in a device context, and then
285 immediately delete the brush you passed, because the brush is `copied'.
286
287 So you may find it easier to ignore the brush list, and instead create
288 and copy brushes as you see fit. If your Windows resource meter suggests
289 your application is using too many resources, you can resort to using
290 GDI lists to share objects explicitly.
291
292 The only compelling use for the brush list is for wxWindows to keep
293 track of brushes in order to clean them up on exit. It is also kept for
294 backward compatibility with earlier versions of wxWindows.
295
296 \wxheading{See also}
297
298 \helpref{wxBrush}{wxbrush}
299
300 \latexignore{\rtfignore{\wxheading{Members}}}
301
302 \membersection{wxBrushList::wxBrushList}\label{wxbrushlistconstr}
303
304 \func{void}{wxBrushList}{\void}
305
306 Constructor. The application should not construct its own brush list:
307 use the object pointer {\bf wxTheBrushList}.
308
309 \membersection{wxBrushList::AddBrush}\label{wxbrushlistaddbrush}
310
311 \func{void}{AddBrush}{\param{wxBrush *}{brush}}
312
313 Used internally by wxWindows to add a brush to the list.
314
315 \membersection{wxBrushList::FindOrCreateBrush}\label{wxbrushlistfindorcreatebrush}
316
317 \func{wxBrush *}{FindOrCreateBrush}{\param{const wxColour\& }{colour}, \param{int}{ style}}
318
319 Finds a brush with the specified attributes and returns it, else creates a new brush, adds it
320 to the brush list, and returns it.
321
322 \func{wxBrush *}{FindOrCreateBrush}{\param{const wxString\& }{colourName}, \param{int}{ style}}
323
324 Finds a brush with the specified attributes and returns it, else creates a new brush, adds it
325 to the brush list, and returns it.
326
327 Finds a brush of the given specification, or creates one and adds it to the list.
328
329 \wxheading{Parameters}
330
331 \docparam{colour}{Colour object.}
332
333 \docparam{colourName}{Colour name, which should be in the colour database.}
334
335 \docparam{style}{Brush style. See \helpref{wxBrush::SetStyle}{wxbrushsetstyle} for a list of styles.}
336
337 \membersection{wxBrushList::RemoveBrush}\label{wxbrushlistremovebrush}
338
339 \func{void}{RemoveBrush}{\param{wxBrush *}{brush}}
340
341 Used by wxWindows to remove a brush from the list.
342
343