]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/brush.h
move TestTextInputStream() function in CppUnit's TextStreamTestCase class
[wxWidgets.git] / interface / wx / brush.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: brush.h
3 // Purpose: interface of wxBrush
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 The possible brush styles.
11 */
12 enum wxBrushStyle
13 {
14 wxBRUSHSTYLE_INVALID = -1,
15
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 /**< Uses a bitmap as a stipple; the mask is used for blitting monochrome
24 using text foreground and background colors. */
25
26 wxBRUSHSTYLE_STIPPLE_MASK = wxSTIPPLE_MASK,
27 /**< Uses a bitmap as a stipple; mask is used for masking areas in the
28 stipple bitmap. */
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,
53 };
54
55
56
57 /**
58 @class wxBrush
59
60 A brush is a drawing tool for filling in areas. It is used for painting
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.
82
83 @library{wxcore}
84 @category{gdi}
85
86 @stdobjects
87 @li ::wxNullBrush
88 @li ::wxBLACK_BRUSH
89 @li ::wxBLUE_BRUSH
90 @li ::wxCYAN_BRUSH
91 @li ::wxGREEN_BRUSH
92 @li ::wxYELLOW_BRUSH
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
99
100 @see wxBrushList, wxDC, wxDC::SetBrush
101 */
102 class wxBrush : public wxGDIObject
103 {
104 public:
105 /**
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
114 @param colour
115 Colour object.
116 @param style
117 One of the ::wxBrushStyle enumeration values.
118 */
119 wxBrush(const wxColour& colour, wxBrushStyle style = wxBRUSHSTYLE_SOLID);
120
121 /**
122 Constructs a stippled brush using a bitmap.
123 The brush style will be set to @c wxBRUSHSTYLE_STIPPLE.
124 */
125 wxBrush(const wxBitmap& stippleBitmap);
126
127 /**
128 Copy constructor, uses @ref overview_refcount "reference counting".
129 */
130 wxBrush(const wxBrush& brush);
131
132 /**
133 Destructor.
134
135 See @ref overview_refcount_destruct for more info.
136
137 @remarks Although all remaining brushes are deleted when the application
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.
142 */
143 virtual ~wxBrush();
144
145 /**
146 Returns a reference to the brush colour.
147
148 @see SetColour()
149 */
150 virtual wxColour GetColour() const;
151
152 /**
153 Gets a pointer to the stipple bitmap. If the brush does not have a @c wxBRUSHSTYLE_STIPPLE
154 style, this bitmap may be non-@NULL but uninitialised (i.e. wxBitmap:IsOk() returns @false).
155
156 @see SetStipple()
157 */
158 virtual wxBitmap* GetStipple() const;
159
160 /**
161 Returns the brush style, one of the ::wxBrushStyle values.
162
163 @see SetStyle(), SetColour(), SetStipple()
164 */
165 virtual wxBrushStyle GetStyle() const;
166
167 /**
168 Returns @true if the style of the brush is any of hatched fills.
169
170 @see GetStyle()
171 */
172 virtual bool IsHatch() const;
173
174 /**
175 Returns @true if the brush is initialised. It will return @false if the default
176 constructor has been used (for example, the brush is a member of a class, or
177 @NULL has been assigned to it).
178 */
179 virtual bool IsOk() const;
180
181 //@{
182 /**
183 Sets the brush colour using red, green and blue values.
184
185 @see GetColour()
186 */
187 virtual void SetColour(const wxColour& colour);
188 virtual void SetColour(unsigned char red, unsigned char green, unsigned char blue);
189 //@}
190
191 /**
192 Sets the stipple bitmap.
193
194 @param bitmap
195 The bitmap to use for stippling.
196
197 @remarks The style will be set to @c wxBRUSHSTYLE_STIPPLE, unless the bitmap
198 has a mask associated to it, in which case the style will be set
199 to @c wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE.
200
201 @see wxBitmap
202 */
203 virtual void SetStipple(const wxBitmap& bitmap);
204
205 /**
206 Sets the brush style.
207
208 @param style
209 One of the ::wxBrushStyle values.
210
211 @see GetStyle()
212 */
213 virtual void SetStyle(wxBrushStyle style);
214
215 /**
216 Inequality operator.
217 See @ref overview_refcount_equality for more info.
218 */
219 bool operator !=(const wxBrush& brush) const;
220
221 /**
222 Equality operator.
223 See @ref overview_refcount_equality for more info.
224 */
225 bool operator ==(const wxBrush& brush) const;
226 };
227
228 /**
229 An empty brush.
230 wxBrush::IsOk() always returns @false for this object.
231 */
232 wxBrush wxNullBrush;
233
234 /**
235 Blue brush.
236 Except for the color it has all standard attributes
237 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
238 */
239 wxBrush* wxBLUE_BRUSH;
240
241 /**
242 Green brush.
243 Except for the color it has all standard attributes
244 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
245 */
246 wxBrush* wxGREEN_BRUSH;
247
248 /**
249 Yellow brush.
250 Except for the color it has all standard attributes
251 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
252 */
253 wxBrush* wxYELLOW_BRUSH;
254
255 /**
256 White brush.
257 Except for the color it has all standard attributes
258 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
259 */
260 wxBrush* wxWHITE_BRUSH;
261
262 /**
263 Black brush.
264 Except for the color it has all standard attributes
265 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
266 */
267 wxBrush* wxBLACK_BRUSH;
268
269 /**
270 Grey brush.
271 Except for the color it has all standard attributes
272 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
273 */
274 wxBrush* wxGREY_BRUSH;
275
276 /**
277 Medium grey brush.
278 Except for the color it has all standard attributes
279 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
280 */
281 wxBrush* wxMEDIUM_GREY_BRUSH;
282
283 /**
284 Light grey brush.
285 Except for the color it has all standard attributes
286 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
287 */
288 wxBrush* wxLIGHT_GREY_BRUSH;
289
290 /**
291 Transparent brush.
292 Except for the color it has all standard attributes
293 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
294 */
295 wxBrush* wxTRANSPARENT_BRUSH;
296
297 /**
298 Cyan brush.
299 Except for the color it has all standard attributes
300 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
301 */
302 wxBrush* wxCYAN_BRUSH;
303
304 /**
305 Red brush.
306 Except for the color it has all standard attributes
307 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
308 */
309 wxBrush* wxRED_BRUSH;
310
311
312
313 /**
314 @class wxBrushList
315
316 A brush list is a list containing all brushes which have been created.
317
318 The application should not construct its own brush list: it should use the
319 object pointer ::wxTheBrushList.
320
321 @library{wxcore}
322 @category{gdi}
323
324 @see wxBrush
325 */
326 class wxBrushList : public wxList
327 {
328 public:
329 /**
330 Finds a brush with the specified attributes and returns it, else creates a new
331 brush, adds it to the brush list, and returns it.
332
333 @param colour
334 Colour object.
335 @param style
336 Brush style. See ::wxBrushStyle for a list of styles.
337 */
338 wxBrush* FindOrCreateBrush(const wxColour& colour,
339 wxBrushStyle style = wxBRUSHSTYLE_SOLID);
340 };
341
342 /**
343 The global wxBrushList instance.
344 */
345 wxBrushList* wxTheBrushList;