]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/brush.tex
added wxLongLong::ToString()
[wxWidgets.git] / docs / latex / wx / brush.tex
CommitLineData
a660d684
KB
1\section{\class{wxBrush}}\label{wxbrush}
2
3A brush is a drawing tool for filling in areas. It is used for painting
4the background of rectangles, ellipses, etc. It has a colour and a
5style.
6
7\wxheading{Derived from}
8
9\helpref{wxGDIObject}{wxgdiobject}\\
10\helpref{wxObject}{wxobject}
11
954b8ae6
JS
12\wxheading{Include files}
13
14<wx/brush.h>
15
20e85460
JS
16\wxheading{Predefined objects}
17
18Objects:
19
20{\bf wxNullBrush}
21
22Pointers:
23
24{\bf wxBLUE\_BRUSH\\
25wxGREEN\_BRUSH\\
26wxWHITE\_BRUSH\\
27wxBLACK\_BRUSH\\
28wxGREY\_BRUSH\\
29wxMEDIUM\_GREY\_BRUSH\\
30wxLIGHT\_GREY\_BRUSH\\
31wxTRANSPARENT\_BRUSH\\
32wxCYAN\_BRUSH\\
33wxRED\_BRUSH}
34
a660d684
KB
35\wxheading{Remarks}
36
37On a monochrome display, wxWindows shows
38all brushes as white unless the colour is really black.
39
40Do not initialize objects on the stack before the program commences,
41since other required structures may not have been set up yet. Instead,
42define global pointers to objects and create them in \helpref{wxApp::OnInit}{wxapponinit} or
43when required.
44
45An application may wish to create brushes with different
46characteristics dynamically, and there is the consequent danger that a
47large number of duplicate brushes will be created. Therefore an
48application may wish to get a pointer to a brush by using the global
49list of brushes {\bf wxTheBrushList}, and calling the member function
50\rtfsp{\bf FindOrCreateBrush}.
51
52wxBrush uses a reference counting system, so assignments between brushes are very
53cheap. You can therefore use actual wxBrush objects instead of pointers without
12a44087
RR
54efficiency problems. Once one wxBrush object changes its data it will create its
55own brush data internally so that other brushes, which previously shared the
56data using the reference counting, are not affected.
a660d684 57
5b6aa0ff 58%TODO: an overview for wxBrush.
a660d684
KB
59\wxheading{See also}
60
61\helpref{wxBrushList}{wxbrushlist}, \helpref{wxDC}{wxdc}, \helpref{wxDC::SetBrush}{wxdcsetbrush}
62
63\latexignore{\rtfignore{\wxheading{Members}}}
64
65\membersection{wxBrush::wxBrush}
66
67\func{}{wxBrush}{\void}
68
69Default constructor. The brush will be uninitialised, and \helpref{wxBrush::Ok}{wxbrushok} will
70return FALSE.
71
eaaa6a06 72\func{}{wxBrush}{\param{const wxColour\&}{ colour}, \param{int}{ style}}
a660d684
KB
73
74Constructs a brush from a colour object and style.
75
eaaa6a06 76\func{}{wxBrush}{\param{const wxString\& }{colourName}, \param{int}{ style}}
a660d684
KB
77
78Constructs a brush from a colour name and style.
79
80\func{}{wxBrush}{\param{const wxBitmap\& }{stippleBitmap}}
81
82Constructs a stippled brush using a bitmap.
83
84\func{}{wxBrush}{\param{const wxBrush\&}{ brush}}
85
86Copy constructor. This uses reference counting so is a cheap operation.
87
a660d684
KB
88\wxheading{Parameters}
89
90\docparam{colour}{Colour object.}
91
92\docparam{colourName}{Colour name. The name will be looked up in the colour database.}
93
94\docparam{style}{One of:
95
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.}
105\end{twocollist}}
106
107\docparam{brush}{Pointer or reference to a brush to copy.}
108
109\docparam{stippleBitmap}{A bitmap to use for stippling.}
110
111\wxheading{Remarks}
112
113If a stipple brush is created, the brush style will be set to wxSTIPPLE.
114
115\wxheading{See also}
116
117\helpref{wxBrushList}{wxbrushlist}, \helpref{wxColour}{wxcolour}, \helpref{wxColourDatabase}{wxcolourdatabase}
118
119\membersection{wxBrush::\destruct{wxBrush}}
120
121\func{void}{\destruct{wxBrush}}{\void}
122
123Destructor.
124
125\wxheading{Remarks}
126
127The destructor may not delete the underlying brush object of the native windowing
128system, since wxBrush uses a reference counting system for efficiency.
129
130Although all remaining brushes are deleted when the application exits,
131the application should try to clean up all brushes itself. This is because
132wxWindows cannot know if a pointer to the brush object is stored in an
133application data structure, and there is a risk of double deletion.
134
135\membersection{wxBrush::GetColour}\label{wxbrushgetcolour}
136
137\constfunc{wxColour\&}{GetColour}{\void}
138
139Returns a reference to the brush colour.
140
141\wxheading{See also}
142
143\helpref{wxBrush::SetColour}{wxbrushsetcolour}
144
145\membersection{wxBrush::GetStipple}\label{wxbrushgetstipple}
146
147\constfunc{wxBitmap *}{GetStipple}{\void}
148
149Gets a pointer to the stipple bitmap. If the brush does not have a wxSTIPPLE style,
150this bitmap may be non-NULL but uninitialised (\helpref{wxBitmap::Ok}{wxbitmapok} returns FALSE).
151
152\wxheading{See also}
153
154\helpref{wxBrush::SetStipple}{wxbrushsetstipple}
155
156\membersection{wxBrush::GetStyle}\label{wxbrushgetstyle}
157
158\constfunc{int}{GetStyle}{\void}
159
160Returns the brush style, one of:
161
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.}
e7240349 172\twocolitem{{\bf wxSTIPPLE\_MASK\_OPAQUE}}{Stippled using a bitmap's mask.}
a660d684
KB
173\end{twocollist}
174
175\wxheading{See also}
176
177\helpref{wxBrush::SetStyle}{wxbrushsetstyle}, \helpref{wxBrush::SetColour}{wxbrushsetcolour},\rtfsp
178\helpref{wxBrush::SetStipple}{wxbrushsetstipple}
179
180\membersection{wxBrush::Ok}\label{wxbrushok}
181
182\constfunc{bool}{Ok}{\void}
183
184Returns TRUE if the brush is initialised. It will return FALSE if the default
185constructor has been used (for example, the brush is a member of a class, or
186NULL has been assigned to it).
187
188\membersection{wxBrush::SetColour}\label{wxbrushsetcolour}
189
190\func{void}{SetColour}{\param{wxColour\& }{colour}}
191
192Sets the brush colour using a reference to a colour object.
193
194\func{void}{SetColour}{\param{const wxString\& }{colourName}}
195
196Sets the brush colour using a colour name from the colour database.
197
198\func{void}{SetColour}{\param{const unsigned char}{ red}, \param{const unsigned char}{ green}, \param{const unsigned char}{ blue}}
199
200Sets the brush colour using red, green and blue values.
201
202\wxheading{See also}
203
204\helpref{wxBrush::GetColour}{wxbrushgetcolour}
205
206\membersection{wxBrush::SetStipple}\label{wxbrushsetstipple}
207
208\func{void}{SetStipple}{\param{const wxBitmap\&}{ bitmap}}
209
210Sets the stipple bitmap.
211
212\wxheading{Parameters}
213
214\docparam{bitmap}{The bitmap to use for stippling.}
215
216\wxheading{Remarks}
217
6e7b6cc6 218The style will be set to wxSTIPPLE, unless the bitmap has a mask associated
e7240349 219to it, in which case the style will be set to wxSTIPPLE\_MASK\_OPAQUE.
a660d684 220
6e7b6cc6 221If the wxSTIPPLE variant is used, the bitmap will be used to fill out the
e7240349 222area to be drawn. If the wxSTIPPLE\_MASK\_OPAQUE is used, the current
6e7b6cc6
RR
223text foreground and text background determine what colours are used for
224displaying and the bits in the mask (which is a mono-bitmap actually)
225determine where to draw what.
226
227Note that under Windows 95, only 8x8 pixel large stipple bitmaps are
228supported, Windows 98 and NT as well as GTK support arbitrary bitmaps.
a660d684
KB
229
230\wxheading{See also}
231
232\helpref{wxBitmap}{wxbitmap}
233
234\membersection{wxBrush::SetStyle}\label{wxbrushsetstyle}
235
eaaa6a06 236\func{void}{SetStyle}{\param{int}{ style}}
a660d684
KB
237
238Sets the brush style.
239
240\docparam{style}{One of:
241
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.}
e7240349 252\twocolitem{{\bf wxSTIPPLE\_MASK\_OPAQUE}}{Stippled using a bitmap's mask.}
a660d684
KB
253\end{twocollist}}
254
255\wxheading{See also}
256
257\helpref{wxBrush::GetStyle}{wxbrushgetstyle}
258
259\membersection{wxBrush::operator $=$}\label{wxbrushassignment}
260
261\func{wxBrush\&}{operator $=$}{\param{const wxBrush\& }{brush}}
262
263Assignment operator, using reference counting. Returns a reference
264to `this'.
265
266\membersection{wxBrush::operator $==$}\label{wxbrushequals}
267
268\func{bool}{operator $==$}{\param{const wxBrush\& }{brush}}
269
270Equality operator. Two brushes are equal if they contain pointers
271to the same underlying brush data. It does not compare each attribute,
272so two independently-created brushes using the same parameters will
273fail the test.
274
275\membersection{wxBrush::operator $!=$}\label{wxbrushnotequals}
276
277\func{bool}{operator $!=$}{\param{const wxBrush\& }{brush}}
278
279Inequality operator. Two brushes are not equal if they contain pointers
280to different underlying brush data. It does not compare each attribute.
281
282\section{\class{wxBrushList}}\label{wxbrushlist}
283
284A brush list is a list containing all brushes which have been created.
285
286\wxheading{Derived from}
287
288\helpref{wxList}{wxlist}\\
289\helpref{wxObject}{wxobject}
290
954b8ae6
JS
291\wxheading{Include files}
292
293<wx/gdicmn.h>
294
a660d684
KB
295\wxheading{Remarks}
296
297There is only one instance of this class: {\bf wxTheBrushList}. Use
298this object to search for a previously created brush of the desired
299type and create it if not already found. In some windowing systems,
300the brush may be a scarce resource, so it can pay to reuse old
301resources if possible. When an application finishes, all brushes will
302be deleted and their resources freed, eliminating the possibility of
303`memory leaks'. However, it is best not to rely on this automatic
304cleanup because it can lead to double deletion in some circumstances.
305
306There are two mechanisms in recent versions of wxWindows which make the
307brush list less useful than it once was. Under Windows, scarce resources
308are cleaned up internally if they are not being used. Also, a referencing
309counting mechanism applied to all GDI objects means that some sharing
310of underlying resources is possible. You don't have to keep track of pointers,
311working out when it is safe delete a brush, because the referencing counting does
312it for you. For example, you can set a brush in a device context, and then
313immediately delete the brush you passed, because the brush is `copied'.
314
315So you may find it easier to ignore the brush list, and instead create
316and copy brushes as you see fit. If your Windows resource meter suggests
317your application is using too many resources, you can resort to using
318GDI lists to share objects explicitly.
319
320The only compelling use for the brush list is for wxWindows to keep
321track of brushes in order to clean them up on exit. It is also kept for
322backward compatibility with earlier versions of wxWindows.
323
324\wxheading{See also}
325
326\helpref{wxBrush}{wxbrush}
327
328\latexignore{\rtfignore{\wxheading{Members}}}
329
330\membersection{wxBrushList::wxBrushList}\label{wxbrushlistconstr}
331
332\func{void}{wxBrushList}{\void}
333
334Constructor. The application should not construct its own brush list:
335use the object pointer {\bf wxTheBrushList}.
336
337\membersection{wxBrushList::AddBrush}\label{wxbrushlistaddbrush}
338
339\func{void}{AddBrush}{\param{wxBrush *}{brush}}
340
341Used internally by wxWindows to add a brush to the list.
342
343\membersection{wxBrushList::FindOrCreateBrush}\label{wxbrushlistfindorcreatebrush}
344
eaaa6a06 345\func{wxBrush *}{FindOrCreateBrush}{\param{const wxColour\& }{colour}, \param{int}{ style}}
a660d684
KB
346
347Finds a brush with the specified attributes and returns it, else creates a new brush, adds it
348to the brush list, and returns it.
349
eaaa6a06 350\func{wxBrush *}{FindOrCreateBrush}{\param{const wxString\& }{colourName}, \param{int}{ style}}
a660d684
KB
351
352Finds a brush with the specified attributes and returns it, else creates a new brush, adds it
353to the brush list, and returns it.
354
355Finds a brush of the given specification, or creates one and adds it to the list.
356
357\wxheading{Parameters}
358
359\docparam{colour}{Colour object.}
360
361\docparam{colourName}{Colour name, which should be in the colour database.}
362
363\docparam{style}{Brush style. See \helpref{wxBrush::SetStyle}{wxbrushsetstyle} for a list of styles.}
364
365\membersection{wxBrushList::RemoveBrush}\label{wxbrushlistremovebrush}
366
367\func{void}{RemoveBrush}{\param{wxBrush *}{brush}}
368
369Used by wxWindows to remove a brush from the list.
370
371