]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/brush.h
Cleanup of wxDataViewCtrl cell activation code.
[wxWidgets.git] / interface / wx / brush.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: brush.h
e54c96f1 3// Purpose: interface of wxBrush
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
8024723d
FM
9/**
10 The possible brush styles.
11*/
12enum wxBrushStyle
13{
1413ac04
FM
14 wxBRUSHSTYLE_INVALID = -1,
15
8024723d
FM
16 wxBRUSHSTYLE_SOLID = wxSOLID,
17 /**< Solid. */
18
19 wxBRUSHSTYLE_TRANSPARENT = wxTRANSPARENT,
20 /**< Transparent (no fill). */
21
22 wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE = wxSTIPPLE_MASK_OPAQUE,
939dafa6
FM
23 /**< Uses a bitmap as a stipple; the mask is used for blitting monochrome
24 using text foreground and background colors. */
8024723d
FM
25
26 wxBRUSHSTYLE_STIPPLE_MASK = wxSTIPPLE_MASK,
939dafa6
FM
27 /**< Uses a bitmap as a stipple; mask is used for masking areas in the
28 stipple bitmap. */
8024723d
FM
29
30 wxBRUSHSTYLE_STIPPLE = wxSTIPPLE,
31 /**< Uses a bitmap as a stipple. */
32
33 wxBRUSHSTYLE_BDIAGONAL_HATCH = wxBDIAGONAL_HATCH,
34 /**< Backward diagonal hatch. */
35
36 wxBRUSHSTYLE_CROSSDIAG_HATCH = wxCROSSDIAG_HATCH,
37 /**< Cross-diagonal hatch. */
38
39 wxBRUSHSTYLE_FDIAGONAL_HATCH = wxFDIAGONAL_HATCH,
40 /**< Forward diagonal hatch. */
41
42 wxBRUSHSTYLE_CROSS_HATCH = wxCROSS_HATCH,
43 /**< Cross hatch. */
44
45 wxBRUSHSTYLE_HORIZONTAL_HATCH = wxHORIZONTAL_HATCH,
46 /**< Horizontal hatch. */
47
48 wxBRUSHSTYLE_VERTICAL_HATCH = wxVERTICAL_HATCH,
49 /**< Vertical hatch. */
50
51 wxBRUSHSTYLE_FIRST_HATCH = wxFIRST_HATCH,
52 wxBRUSHSTYLE_LAST_HATCH = wxLAST_HATCH,
8024723d
FM
53};
54
55
56
23324ae1
FM
57/**
58 @class wxBrush
7c913512 59
23324ae1 60 A brush is a drawing tool for filling in areas. It is used for painting
8024723d
FM
61 the background of rectangles, ellipses, etc. It has a colour and a style.
62
63 On a monochrome display, wxWidgets shows all brushes as white unless the
64 colour is really black.
65
66 Do not initialize objects on the stack before the program commences, since
67 other required structures may not have been set up yet. Instead, define
68 global pointers to objects and create them in wxApp::OnInit or when required.
69
70 An application may wish to create brushes with different characteristics
71 dynamically, and there is the consequent danger that a large number of
72 duplicate brushes will be created. Therefore an application may wish to
73 get a pointer to a brush by using the global list of brushes ::wxTheBrushList,
74 and calling the member function wxBrushList::FindOrCreateBrush().
75
76 This class uses reference counting and copy-on-write internally so that
77 assignments between two instances of this class are very cheap.
78 You can therefore use actual objects instead of pointers without efficiency problems.
79 If an instance of this class is changed it will create its own data internally
80 so that other instances, which previously shared the data using the reference
81 counting, are not affected.
7c913512 82
23324ae1
FM
83 @library{wxcore}
84 @category{gdi}
7c913512 85
23324ae1 86 @stdobjects
d8184587
FM
87 @li ::wxNullBrush
88 @li ::wxBLACK_BRUSH
89 @li ::wxBLUE_BRUSH
90 @li ::wxCYAN_BRUSH
91 @li ::wxGREEN_BRUSH
86028025 92 @li ::wxYELLOW_BRUSH
d8184587
FM
93 @li ::wxGREY_BRUSH
94 @li ::wxLIGHT_GREY_BRUSH
95 @li ::wxMEDIUM_GREY_BRUSH
96 @li ::wxRED_BRUSH
97 @li ::wxTRANSPARENT_BRUSH
98 @li ::wxWHITE_BRUSH
7c913512 99
e54c96f1 100 @see wxBrushList, wxDC, wxDC::SetBrush
23324ae1
FM
101*/
102class wxBrush : public wxGDIObject
103{
104public:
23324ae1 105 /**
8024723d
FM
106 Default constructor.
107 The brush will be uninitialised, and wxBrush:IsOk() will return @false.
108 */
109 wxBrush();
110
111 /**
112 Constructs a brush from a colour object and @a style.
113
7c913512 114 @param colour
4cc4bfaf 115 Colour object.
8024723d
FM
116 @param style
117 One of the ::wxBrushStyle enumeration values.
118 */
1413ac04 119 wxBrush(const wxColour& colour, wxBrushStyle style = wxBRUSHSTYLE_SOLID);
8024723d
FM
120
121 /**
122 Constructs a stippled brush using a bitmap.
939dafa6 123 The brush style will be set to @c wxBRUSHSTYLE_STIPPLE.
23324ae1 124 */
7c913512 125 wxBrush(const wxBitmap& stippleBitmap);
8024723d
FM
126
127 /**
128 Copy constructor, uses @ref overview_refcount "reference counting".
129 */
7c913512 130 wxBrush(const wxBrush& brush);
23324ae1
FM
131
132 /**
133 Destructor.
8024723d
FM
134
135 See @ref overview_refcount_destruct for more info.
136
23324ae1 137 @remarks Although all remaining brushes are deleted when the application
8024723d
FM
138 exits, the application should try to clean up all brushes itself.
139 This is because wxWidgets cannot know if a pointer to the brush
140 object is stored in an application data structure, and there is
141 a risk of double deletion.
23324ae1 142 */
d2aa927a 143 virtual ~wxBrush();
23324ae1
FM
144
145 /**
146 Returns a reference to the brush colour.
8024723d 147
4cc4bfaf 148 @see SetColour()
23324ae1 149 */
231b9591 150 virtual wxColour GetColour() const;
23324ae1
FM
151
152 /**
939dafa6 153 Gets a pointer to the stipple bitmap. If the brush does not have a @c wxBRUSHSTYLE_STIPPLE
8024723d
FM
154 style, this bitmap may be non-@NULL but uninitialised (i.e. wxBitmap:IsOk() returns @false).
155
4cc4bfaf 156 @see SetStipple()
23324ae1 157 */
231b9591 158 virtual wxBitmap* GetStipple() const;
23324ae1
FM
159
160 /**
8024723d
FM
161 Returns the brush style, one of the ::wxBrushStyle values.
162
4cc4bfaf 163 @see SetStyle(), SetColour(), SetStipple()
23324ae1 164 */
1413ac04 165 virtual wxBrushStyle GetStyle() const;
23324ae1
FM
166
167 /**
168 Returns @true if the style of the brush is any of hatched fills.
8024723d 169
4cc4bfaf 170 @see GetStyle()
23324ae1 171 */
d2aa927a 172 virtual bool IsHatch() const;
23324ae1
FM
173
174 /**
e6777e65
VZ
175 Returns @true if the brush is initialised.
176
177 Notice that an uninitialized brush object can't be queried for any
178 brush properties and all calls to the accessor methods on it will
179 result in an assert failure.
23324ae1 180 */
0004982c 181 virtual bool IsOk() const;
23324ae1 182
e6777e65
VZ
183 /**
184 Returns @true if the brush is a valid non-transparent brush.
185
186 This method returns @true if the brush object is initialized and has a
187 non-transparent style. Notice that this should be used instead of
188 simply testing whether GetStyle() returns a style different from
189 wxBRUSHSTYLE_TRANSPARENT if the brush may be invalid as GetStyle()
190 would assert in this case.
191
192 @see IsTransparent()
193
194 @since 2.9.2.
195 */
196 bool IsNonTransparent() const;
197
198 /**
199 Returns @true if the brush is transparent.
200
201 A transparent brush is simply a brush with wxBRUSHSTYLE_TRANSPARENT
202 style.
203
d13b34d3 204 Notice that this function works even for non-initialized brushes (for
e6777e65
VZ
205 which it returns @false) unlike tests of the form <code>GetStyle() ==
206 wxBRUSHSTYLE_TRANSPARENT</code> which would assert if the brush is
207 invalid.
208
209 @see IsNonTransparent()
210
211 @since 2.9.2.
212 */
213 bool IsTransparent() const;
214
215
23324ae1
FM
216 //@{
217 /**
218 Sets the brush colour using red, green and blue values.
8024723d 219
4cc4bfaf 220 @see GetColour()
23324ae1 221 */
882678eb 222 virtual void SetColour(const wxColour& colour);
231b9591 223 virtual void SetColour(unsigned char red, unsigned char green, unsigned char blue);
23324ae1
FM
224 //@}
225
226 /**
227 Sets the stipple bitmap.
8024723d 228
7c913512 229 @param bitmap
4cc4bfaf 230 The bitmap to use for stippling.
8024723d 231
939dafa6 232 @remarks The style will be set to @c wxBRUSHSTYLE_STIPPLE, unless the bitmap
8024723d 233 has a mask associated to it, in which case the style will be set
939dafa6 234 to @c wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE.
8024723d 235
4cc4bfaf 236 @see wxBitmap
23324ae1 237 */
231b9591 238 virtual void SetStipple(const wxBitmap& bitmap);
23324ae1
FM
239
240 /**
241 Sets the brush style.
8024723d 242
7c913512 243 @param style
8024723d
FM
244 One of the ::wxBrushStyle values.
245
4cc4bfaf 246 @see GetStyle()
23324ae1 247 */
231b9591 248 virtual void SetStyle(wxBrushStyle style);
23324ae1
FM
249
250 /**
251 Inequality operator.
8024723d 252 See @ref overview_refcount_equality for more info.
23324ae1 253 */
1413ac04 254 bool operator !=(const wxBrush& brush) const;
23324ae1
FM
255
256 /**
257 Equality operator.
8024723d 258 See @ref overview_refcount_equality for more info.
23324ae1 259 */
1413ac04 260 bool operator ==(const wxBrush& brush) const;
23324ae1 261};
e54c96f1 262
e54c96f1 263/**
8024723d 264 An empty brush.
939dafa6 265 wxBrush::IsOk() always returns @false for this object.
e54c96f1
FM
266*/
267wxBrush wxNullBrush;
268
269/**
8024723d 270 Blue brush.
939dafa6
FM
271 Except for the color it has all standard attributes
272 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 273*/
8024723d 274wxBrush* wxBLUE_BRUSH;
e54c96f1
FM
275
276/**
8024723d 277 Green brush.
939dafa6
FM
278 Except for the color it has all standard attributes
279 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 280*/
8024723d 281wxBrush* wxGREEN_BRUSH;
e54c96f1 282
86028025
FM
283/**
284 Yellow brush.
285 Except for the color it has all standard attributes
286 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
287*/
288wxBrush* wxYELLOW_BRUSH;
289
e54c96f1 290/**
8024723d 291 White brush.
939dafa6
FM
292 Except for the color it has all standard attributes
293 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 294*/
8024723d 295wxBrush* wxWHITE_BRUSH;
e54c96f1
FM
296
297/**
8024723d 298 Black brush.
939dafa6
FM
299 Except for the color it has all standard attributes
300 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 301*/
8024723d 302wxBrush* wxBLACK_BRUSH;
e54c96f1
FM
303
304/**
8024723d 305 Grey brush.
939dafa6
FM
306 Except for the color it has all standard attributes
307 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 308*/
8024723d 309wxBrush* wxGREY_BRUSH;
e54c96f1
FM
310
311/**
8024723d 312 Medium grey brush.
939dafa6
FM
313 Except for the color it has all standard attributes
314 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 315*/
8024723d 316wxBrush* wxMEDIUM_GREY_BRUSH;
e54c96f1
FM
317
318/**
8024723d 319 Light grey brush.
939dafa6
FM
320 Except for the color it has all standard attributes
321 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 322*/
8024723d 323wxBrush* wxLIGHT_GREY_BRUSH;
e54c96f1
FM
324
325/**
8024723d 326 Transparent brush.
939dafa6
FM
327 Except for the color it has all standard attributes
328 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 329*/
8024723d 330wxBrush* wxTRANSPARENT_BRUSH;
e54c96f1
FM
331
332/**
8024723d 333 Cyan brush.
939dafa6
FM
334 Except for the color it has all standard attributes
335 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 336*/
8024723d 337wxBrush* wxCYAN_BRUSH;
e54c96f1
FM
338
339/**
8024723d 340 Red brush.
939dafa6
FM
341 Except for the color it has all standard attributes
342 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 343*/
8024723d
FM
344wxBrush* wxRED_BRUSH;
345
346
e54c96f1
FM
347
348/**
8024723d 349 @class wxBrushList
8024723d
FM
350
351 A brush list is a list containing all brushes which have been created.
352
1413ac04
FM
353 The application should not construct its own brush list: it should use the
354 object pointer ::wxTheBrushList.
355
8024723d
FM
356 @library{wxcore}
357 @category{gdi}
358
359 @see wxBrush
e54c96f1 360*/
8024723d
FM
361class wxBrushList : public wxList
362{
363public:
8024723d
FM
364 /**
365 Finds a brush with the specified attributes and returns it, else creates a new
366 brush, adds it to the brush list, and returns it.
e54c96f1 367
8024723d
FM
368 @param colour
369 Colour object.
370 @param style
371 Brush style. See ::wxBrushStyle for a list of styles.
372 */
373 wxBrush* FindOrCreateBrush(const wxColour& colour,
374 wxBrushStyle style = wxBRUSHSTYLE_SOLID);
375};
376
377/**
378 The global wxBrushList instance.
379*/
380wxBrushList* wxTheBrushList;