]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/brush.h
Default to wxConvUTF8 (not wxConvAuto) in wxDataInputStream and wxDataOutputStream...
[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,
23 /**< @todo WHAT's THIS?? */
24
25 wxBRUSHSTYLE_STIPPLE_MASK = wxSTIPPLE_MASK,
26 /**< @todo WHAT's THIS?? */
27
28 wxBRUSHSTYLE_STIPPLE = wxSTIPPLE,
29 /**< Uses a bitmap as a stipple. */
30
31 wxBRUSHSTYLE_BDIAGONAL_HATCH = wxBDIAGONAL_HATCH,
32 /**< Backward diagonal hatch. */
33
34 wxBRUSHSTYLE_CROSSDIAG_HATCH = wxCROSSDIAG_HATCH,
35 /**< Cross-diagonal hatch. */
36
37 wxBRUSHSTYLE_FDIAGONAL_HATCH = wxFDIAGONAL_HATCH,
38 /**< Forward diagonal hatch. */
39
40 wxBRUSHSTYLE_CROSS_HATCH = wxCROSS_HATCH,
41 /**< Cross hatch. */
42
43 wxBRUSHSTYLE_HORIZONTAL_HATCH = wxHORIZONTAL_HATCH,
44 /**< Horizontal hatch. */
45
46 wxBRUSHSTYLE_VERTICAL_HATCH = wxVERTICAL_HATCH,
47 /**< Vertical hatch. */
48
49 wxBRUSHSTYLE_FIRST_HATCH = wxFIRST_HATCH,
50 wxBRUSHSTYLE_LAST_HATCH = wxLAST_HATCH,
8024723d
FM
51};
52
53
54
23324ae1
FM
55/**
56 @class wxBrush
7c913512 57
23324ae1 58 A brush is a drawing tool for filling in areas. It is used for painting
8024723d
FM
59 the background of rectangles, ellipses, etc. It has a colour and a style.
60
61 On a monochrome display, wxWidgets shows all brushes as white unless the
62 colour is really black.
63
64 Do not initialize objects on the stack before the program commences, since
65 other required structures may not have been set up yet. Instead, define
66 global pointers to objects and create them in wxApp::OnInit or when required.
67
68 An application may wish to create brushes with different characteristics
69 dynamically, and there is the consequent danger that a large number of
70 duplicate brushes will be created. Therefore an application may wish to
71 get a pointer to a brush by using the global list of brushes ::wxTheBrushList,
72 and calling the member function wxBrushList::FindOrCreateBrush().
73
74 This class uses reference counting and copy-on-write internally so that
75 assignments between two instances of this class are very cheap.
76 You can therefore use actual objects instead of pointers without efficiency problems.
77 If an instance of this class is changed it will create its own data internally
78 so that other instances, which previously shared the data using the reference
79 counting, are not affected.
7c913512 80
23324ae1
FM
81 @library{wxcore}
82 @category{gdi}
7c913512 83
23324ae1 84 @stdobjects
8024723d
FM
85 ::wxNullBrush, ::wxBLUE_BRUSH, ::wxGREEN_BRUSH, ::wxWHITE_BRUSH,
86 ::wxBLACK_BRUSH, ::wxGREY_BRUSH, ::wxMEDIUM_GREY_BRUSH, ::wxLIGHT_GREY_BRUSH,
87 ::wxTRANSPARENT_BRUSH, ::wxCYAN_BRUSH, ::wxRED_BRUSH
7c913512 88
e54c96f1 89 @see wxBrushList, wxDC, wxDC::SetBrush
23324ae1
FM
90*/
91class wxBrush : public wxGDIObject
92{
93public:
23324ae1 94 /**
8024723d
FM
95 Default constructor.
96 The brush will be uninitialised, and wxBrush:IsOk() will return @false.
97 */
98 wxBrush();
99
100 /**
101 Constructs a brush from a colour object and @a style.
102
7c913512 103 @param colour
4cc4bfaf 104 Colour object.
8024723d
FM
105 @param style
106 One of the ::wxBrushStyle enumeration values.
107 */
1413ac04 108 wxBrush(const wxColour& colour, wxBrushStyle style = wxBRUSHSTYLE_SOLID);
8024723d
FM
109
110 /**
111 Constructs a stippled brush using a bitmap.
112 The brush style will be set to wxBRUSHSTYLE_STIPPLE.
23324ae1 113 */
7c913512 114 wxBrush(const wxBitmap& stippleBitmap);
8024723d
FM
115
116 /**
117 Copy constructor, uses @ref overview_refcount "reference counting".
118 */
7c913512 119 wxBrush(const wxBrush& brush);
23324ae1
FM
120
121 /**
122 Destructor.
8024723d
FM
123
124 See @ref overview_refcount_destruct for more info.
125
23324ae1 126 @remarks Although all remaining brushes are deleted when the application
8024723d
FM
127 exits, the application should try to clean up all brushes itself.
128 This is because wxWidgets cannot know if a pointer to the brush
129 object is stored in an application data structure, and there is
130 a risk of double deletion.
23324ae1 131 */
d2aa927a 132 virtual ~wxBrush();
23324ae1
FM
133
134 /**
135 Returns a reference to the brush colour.
8024723d 136
4cc4bfaf 137 @see SetColour()
23324ae1 138 */
231b9591 139 virtual wxColour GetColour() const;
23324ae1
FM
140
141 /**
8024723d
FM
142 Gets a pointer to the stipple bitmap. If the brush does not have a wxBRUSHSTYLE_STIPPLE
143 style, this bitmap may be non-@NULL but uninitialised (i.e. wxBitmap:IsOk() returns @false).
144
4cc4bfaf 145 @see SetStipple()
23324ae1 146 */
231b9591 147 virtual wxBitmap* GetStipple() const;
23324ae1
FM
148
149 /**
8024723d
FM
150 Returns the brush style, one of the ::wxBrushStyle values.
151
4cc4bfaf 152 @see SetStyle(), SetColour(), SetStipple()
23324ae1 153 */
1413ac04 154 virtual wxBrushStyle GetStyle() const;
23324ae1
FM
155
156 /**
157 Returns @true if the style of the brush is any of hatched fills.
8024723d 158
4cc4bfaf 159 @see GetStyle()
23324ae1 160 */
d2aa927a 161 virtual bool IsHatch() const;
23324ae1
FM
162
163 /**
164 Returns @true if the brush is initialised. It will return @false if the default
165 constructor has been used (for example, the brush is a member of a class, or
166 @NULL has been assigned to it).
167 */
0004982c 168 virtual bool IsOk() const;
23324ae1
FM
169
170 //@{
171 /**
172 Sets the brush colour using red, green and blue values.
8024723d 173
4cc4bfaf 174 @see GetColour()
23324ae1 175 */
882678eb 176 virtual void SetColour(const wxColour& colour);
231b9591 177 virtual void SetColour(unsigned char red, unsigned char green, unsigned char blue);
23324ae1
FM
178 //@}
179
180 /**
181 Sets the stipple bitmap.
8024723d 182
7c913512 183 @param bitmap
4cc4bfaf 184 The bitmap to use for stippling.
8024723d
FM
185
186 @remarks The style will be set to wxBRUSHSTYLE_STIPPLE, unless the bitmap
187 has a mask associated to it, in which case the style will be set
188 to wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE.
189
4cc4bfaf 190 @see wxBitmap
23324ae1 191 */
231b9591 192 virtual void SetStipple(const wxBitmap& bitmap);
23324ae1
FM
193
194 /**
195 Sets the brush style.
8024723d 196
7c913512 197 @param style
8024723d
FM
198 One of the ::wxBrushStyle values.
199
4cc4bfaf 200 @see GetStyle()
23324ae1 201 */
231b9591 202 virtual void SetStyle(wxBrushStyle style);
23324ae1
FM
203
204 /**
205 Inequality operator.
8024723d 206 See @ref overview_refcount_equality for more info.
23324ae1 207 */
1413ac04 208 bool operator !=(const wxBrush& brush) const;
23324ae1
FM
209
210 /**
211 Equality operator.
8024723d 212 See @ref overview_refcount_equality for more info.
23324ae1 213 */
1413ac04 214 bool operator ==(const wxBrush& brush) const;
23324ae1 215};
e54c96f1 216
e54c96f1 217/**
8024723d 218 An empty brush.
e54c96f1
FM
219*/
220wxBrush wxNullBrush;
221
222/**
8024723d 223 Blue brush.
e54c96f1 224*/
8024723d 225wxBrush* wxBLUE_BRUSH;
e54c96f1
FM
226
227/**
8024723d 228 Green brush.
e54c96f1 229*/
8024723d 230wxBrush* wxGREEN_BRUSH;
e54c96f1
FM
231
232/**
8024723d 233 White brush.
e54c96f1 234*/
8024723d 235wxBrush* wxWHITE_BRUSH;
e54c96f1
FM
236
237/**
8024723d 238 Black brush.
e54c96f1 239*/
8024723d 240wxBrush* wxBLACK_BRUSH;
e54c96f1
FM
241
242/**
8024723d 243 Grey brush.
e54c96f1 244*/
8024723d 245wxBrush* wxGREY_BRUSH;
e54c96f1
FM
246
247/**
8024723d 248 Medium grey brush.
e54c96f1 249*/
8024723d 250wxBrush* wxMEDIUM_GREY_BRUSH;
e54c96f1
FM
251
252/**
8024723d 253 Light grey brush.
e54c96f1 254*/
8024723d 255wxBrush* wxLIGHT_GREY_BRUSH;
e54c96f1
FM
256
257/**
8024723d 258 Transparent brush.
e54c96f1 259*/
8024723d 260wxBrush* wxTRANSPARENT_BRUSH;
e54c96f1
FM
261
262/**
8024723d 263 Cyan brush.
e54c96f1 264*/
8024723d 265wxBrush* wxCYAN_BRUSH;
e54c96f1
FM
266
267/**
8024723d 268 Red brush.
e54c96f1 269*/
8024723d
FM
270wxBrush* wxRED_BRUSH;
271
272
e54c96f1
FM
273
274/**
8024723d 275 @class wxBrushList
8024723d
FM
276
277 A brush list is a list containing all brushes which have been created.
278
1413ac04
FM
279 The application should not construct its own brush list: it should use the
280 object pointer ::wxTheBrushList.
281
8024723d
FM
282 @library{wxcore}
283 @category{gdi}
284
285 @see wxBrush
e54c96f1 286*/
8024723d
FM
287class wxBrushList : public wxList
288{
289public:
8024723d
FM
290 /**
291 Finds a brush with the specified attributes and returns it, else creates a new
292 brush, adds it to the brush list, and returns it.
e54c96f1 293
8024723d
FM
294 @param colour
295 Colour object.
296 @param style
297 Brush style. See ::wxBrushStyle for a list of styles.
298 */
299 wxBrush* FindOrCreateBrush(const wxColour& colour,
300 wxBrushStyle style = wxBRUSHSTYLE_SOLID);
301};
302
303/**
304 The global wxBrushList instance.
305*/
306wxBrushList* wxTheBrushList;