]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/brush.h
pass wxIntPtr, not wxUIntPtr, to wxListCtrl::SortItems() callback as it's more compat...
[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$
6// Licence: wxWindows license
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
92 @li ::wxGREY_BRUSH
93 @li ::wxLIGHT_GREY_BRUSH
94 @li ::wxMEDIUM_GREY_BRUSH
95 @li ::wxRED_BRUSH
96 @li ::wxTRANSPARENT_BRUSH
97 @li ::wxWHITE_BRUSH
7c913512 98
e54c96f1 99 @see wxBrushList, wxDC, wxDC::SetBrush
23324ae1
FM
100*/
101class wxBrush : public wxGDIObject
102{
103public:
23324ae1 104 /**
8024723d
FM
105 Default constructor.
106 The brush will be uninitialised, and wxBrush:IsOk() will return @false.
107 */
108 wxBrush();
109
110 /**
111 Constructs a brush from a colour object and @a style.
112
7c913512 113 @param colour
4cc4bfaf 114 Colour object.
8024723d
FM
115 @param style
116 One of the ::wxBrushStyle enumeration values.
117 */
1413ac04 118 wxBrush(const wxColour& colour, wxBrushStyle style = wxBRUSHSTYLE_SOLID);
8024723d
FM
119
120 /**
121 Constructs a stippled brush using a bitmap.
939dafa6 122 The brush style will be set to @c wxBRUSHSTYLE_STIPPLE.
23324ae1 123 */
7c913512 124 wxBrush(const wxBitmap& stippleBitmap);
8024723d
FM
125
126 /**
127 Copy constructor, uses @ref overview_refcount "reference counting".
128 */
7c913512 129 wxBrush(const wxBrush& brush);
23324ae1
FM
130
131 /**
132 Destructor.
8024723d
FM
133
134 See @ref overview_refcount_destruct for more info.
135
23324ae1 136 @remarks Although all remaining brushes are deleted when the application
8024723d
FM
137 exits, the application should try to clean up all brushes itself.
138 This is because wxWidgets cannot know if a pointer to the brush
139 object is stored in an application data structure, and there is
140 a risk of double deletion.
23324ae1 141 */
d2aa927a 142 virtual ~wxBrush();
23324ae1
FM
143
144 /**
145 Returns a reference to the brush colour.
8024723d 146
4cc4bfaf 147 @see SetColour()
23324ae1 148 */
231b9591 149 virtual wxColour GetColour() const;
23324ae1
FM
150
151 /**
939dafa6 152 Gets a pointer to the stipple bitmap. If the brush does not have a @c wxBRUSHSTYLE_STIPPLE
8024723d
FM
153 style, this bitmap may be non-@NULL but uninitialised (i.e. wxBitmap:IsOk() returns @false).
154
4cc4bfaf 155 @see SetStipple()
23324ae1 156 */
231b9591 157 virtual wxBitmap* GetStipple() const;
23324ae1
FM
158
159 /**
8024723d
FM
160 Returns the brush style, one of the ::wxBrushStyle values.
161
4cc4bfaf 162 @see SetStyle(), SetColour(), SetStipple()
23324ae1 163 */
1413ac04 164 virtual wxBrushStyle GetStyle() const;
23324ae1
FM
165
166 /**
167 Returns @true if the style of the brush is any of hatched fills.
8024723d 168
4cc4bfaf 169 @see GetStyle()
23324ae1 170 */
d2aa927a 171 virtual bool IsHatch() const;
23324ae1
FM
172
173 /**
174 Returns @true if the brush is initialised. It will return @false if the default
175 constructor has been used (for example, the brush is a member of a class, or
176 @NULL has been assigned to it).
177 */
0004982c 178 virtual bool IsOk() const;
23324ae1
FM
179
180 //@{
181 /**
182 Sets the brush colour using red, green and blue values.
8024723d 183
4cc4bfaf 184 @see GetColour()
23324ae1 185 */
882678eb 186 virtual void SetColour(const wxColour& colour);
231b9591 187 virtual void SetColour(unsigned char red, unsigned char green, unsigned char blue);
23324ae1
FM
188 //@}
189
190 /**
191 Sets the stipple bitmap.
8024723d 192
7c913512 193 @param bitmap
4cc4bfaf 194 The bitmap to use for stippling.
8024723d 195
939dafa6 196 @remarks The style will be set to @c wxBRUSHSTYLE_STIPPLE, unless the bitmap
8024723d 197 has a mask associated to it, in which case the style will be set
939dafa6 198 to @c wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE.
8024723d 199
4cc4bfaf 200 @see wxBitmap
23324ae1 201 */
231b9591 202 virtual void SetStipple(const wxBitmap& bitmap);
23324ae1
FM
203
204 /**
205 Sets the brush style.
8024723d 206
7c913512 207 @param style
8024723d
FM
208 One of the ::wxBrushStyle values.
209
4cc4bfaf 210 @see GetStyle()
23324ae1 211 */
231b9591 212 virtual void SetStyle(wxBrushStyle style);
23324ae1
FM
213
214 /**
215 Inequality operator.
8024723d 216 See @ref overview_refcount_equality for more info.
23324ae1 217 */
1413ac04 218 bool operator !=(const wxBrush& brush) const;
23324ae1
FM
219
220 /**
221 Equality operator.
8024723d 222 See @ref overview_refcount_equality for more info.
23324ae1 223 */
1413ac04 224 bool operator ==(const wxBrush& brush) const;
23324ae1 225};
e54c96f1 226
e54c96f1 227/**
8024723d 228 An empty brush.
939dafa6 229 wxBrush::IsOk() always returns @false for this object.
e54c96f1
FM
230*/
231wxBrush wxNullBrush;
232
233/**
8024723d 234 Blue brush.
939dafa6
FM
235 Except for the color it has all standard attributes
236 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 237*/
8024723d 238wxBrush* wxBLUE_BRUSH;
e54c96f1
FM
239
240/**
8024723d 241 Green brush.
939dafa6
FM
242 Except for the color it has all standard attributes
243 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 244*/
8024723d 245wxBrush* wxGREEN_BRUSH;
e54c96f1
FM
246
247/**
8024723d 248 White brush.
939dafa6
FM
249 Except for the color it has all standard attributes
250 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 251*/
8024723d 252wxBrush* wxWHITE_BRUSH;
e54c96f1
FM
253
254/**
8024723d 255 Black brush.
939dafa6
FM
256 Except for the color it has all standard attributes
257 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 258*/
8024723d 259wxBrush* wxBLACK_BRUSH;
e54c96f1
FM
260
261/**
8024723d 262 Grey brush.
939dafa6
FM
263 Except for the color it has all standard attributes
264 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 265*/
8024723d 266wxBrush* wxGREY_BRUSH;
e54c96f1
FM
267
268/**
8024723d 269 Medium grey brush.
939dafa6
FM
270 Except for the color it has all standard attributes
271 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 272*/
8024723d 273wxBrush* wxMEDIUM_GREY_BRUSH;
e54c96f1
FM
274
275/**
8024723d 276 Light grey brush.
939dafa6
FM
277 Except for the color it has all standard attributes
278 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 279*/
8024723d 280wxBrush* wxLIGHT_GREY_BRUSH;
e54c96f1
FM
281
282/**
8024723d 283 Transparent brush.
939dafa6
FM
284 Except for the color it has all standard attributes
285 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 286*/
8024723d 287wxBrush* wxTRANSPARENT_BRUSH;
e54c96f1
FM
288
289/**
8024723d 290 Cyan brush.
939dafa6
FM
291 Except for the color it has all standard attributes
292 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 293*/
8024723d 294wxBrush* wxCYAN_BRUSH;
e54c96f1
FM
295
296/**
8024723d 297 Red brush.
939dafa6
FM
298 Except for the color it has all standard attributes
299 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
e54c96f1 300*/
8024723d
FM
301wxBrush* wxRED_BRUSH;
302
303
e54c96f1
FM
304
305/**
8024723d 306 @class wxBrushList
8024723d
FM
307
308 A brush list is a list containing all brushes which have been created.
309
1413ac04
FM
310 The application should not construct its own brush list: it should use the
311 object pointer ::wxTheBrushList.
312
8024723d
FM
313 @library{wxcore}
314 @category{gdi}
315
316 @see wxBrush
e54c96f1 317*/
8024723d
FM
318class wxBrushList : public wxList
319{
320public:
8024723d
FM
321 /**
322 Finds a brush with the specified attributes and returns it, else creates a new
323 brush, adds it to the brush list, and returns it.
e54c96f1 324
8024723d
FM
325 @param colour
326 Colour object.
327 @param style
328 Brush style. See ::wxBrushStyle for a list of styles.
329 */
330 wxBrush* FindOrCreateBrush(const wxColour& colour,
331 wxBrushStyle style = wxBRUSHSTYLE_SOLID);
332};
333
334/**
335 The global wxBrushList instance.
336*/
337wxBrushList* wxTheBrushList;