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