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