1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxBrush
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
9 The possible brush styles.
13 wxBRUSHSTYLE_INVALID
= -1,
15 wxBRUSHSTYLE_SOLID
= wxSOLID
,
18 wxBRUSHSTYLE_TRANSPARENT
= wxTRANSPARENT
,
19 /**< Transparent (no fill). */
21 wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE
= wxSTIPPLE_MASK_OPAQUE
,
22 /**< Uses a bitmap as a stipple; the mask is used for blitting monochrome
23 using text foreground and background colors. */
25 wxBRUSHSTYLE_STIPPLE_MASK
= wxSTIPPLE_MASK
,
26 /**< Uses a bitmap as a stipple; mask is used for masking areas in the
29 wxBRUSHSTYLE_STIPPLE
= wxSTIPPLE
,
30 /**< Uses a bitmap as a stipple. */
32 wxBRUSHSTYLE_BDIAGONAL_HATCH
,
33 /**< Backward diagonal hatch. */
35 wxBRUSHSTYLE_CROSSDIAG_HATCH
,
36 /**< Cross-diagonal hatch. */
38 wxBRUSHSTYLE_FDIAGONAL_HATCH
,
39 /**< Forward diagonal hatch. */
41 wxBRUSHSTYLE_CROSS_HATCH
,
44 wxBRUSHSTYLE_HORIZONTAL_HATCH
,
45 /**< Horizontal hatch. */
47 wxBRUSHSTYLE_VERTICAL_HATCH
,
48 /**< Vertical hatch. */
50 wxBRUSHSTYLE_FIRST_HATCH
,
51 /**< First of the hatch styles (inclusive). */
53 wxBRUSHSTYLE_LAST_HATCH
54 /**< Last of the hatch styles (inclusive). */
62 A brush is a drawing tool for filling in areas. It is used for painting
63 the background of rectangles, ellipses, etc. It has a colour and a style.
65 On a monochrome display, wxWidgets shows all brushes as white unless the
66 colour is really black.
68 Do not initialize objects on the stack before the program commences, since
69 other required structures may not have been set up yet. Instead, define
70 global pointers to objects and create them in wxApp::OnInit or when required.
72 An application may wish to create brushes with different characteristics
73 dynamically, and there is the consequent danger that a large number of
74 duplicate brushes will be created. Therefore an application may wish to
75 get a pointer to a brush by using the global list of brushes ::wxTheBrushList,
76 and calling the member function wxBrushList::FindOrCreateBrush().
78 This class uses reference counting and copy-on-write internally so that
79 assignments between two instances of this class are very cheap.
80 You can therefore use actual objects instead of pointers without efficiency problems.
81 If an instance of this class is changed it will create its own data internally
82 so that other instances, which previously shared the data using the reference
83 counting, are not affected.
96 @li ::wxLIGHT_GREY_BRUSH
97 @li ::wxMEDIUM_GREY_BRUSH
99 @li ::wxTRANSPARENT_BRUSH
102 @see wxBrushList, wxDC, wxDC::SetBrush
104 class wxBrush
: public wxGDIObject
109 The brush will be uninitialised, and wxBrush:IsOk() will return @false.
114 Constructs a brush from a colour object and @a style.
119 One of the ::wxBrushStyle enumeration values.
121 wxBrush(const wxColour
& colour
, wxBrushStyle style
= wxBRUSHSTYLE_SOLID
);
124 Constructs a stippled brush using a bitmap.
125 The brush style will be set to @c wxBRUSHSTYLE_STIPPLE.
127 wxBrush(const wxBitmap
& stippleBitmap
);
130 Copy constructor, uses @ref overview_refcount "reference counting".
132 wxBrush(const wxBrush
& brush
);
137 See @ref overview_refcount_destruct for more info.
139 @remarks Although all remaining brushes are deleted when the application
140 exits, the application should try to clean up all brushes itself.
141 This is because wxWidgets cannot know if a pointer to the brush
142 object is stored in an application data structure, and there is
143 a risk of double deletion.
148 Returns a reference to the brush colour.
152 virtual wxColour
GetColour() const;
155 Gets a pointer to the stipple bitmap. If the brush does not have a @c wxBRUSHSTYLE_STIPPLE
156 style, this bitmap may be non-@NULL but uninitialised (i.e. wxBitmap:IsOk() returns @false).
160 virtual wxBitmap
* GetStipple() const;
163 Returns the brush style, one of the ::wxBrushStyle values.
165 @see SetStyle(), SetColour(), SetStipple()
167 virtual wxBrushStyle
GetStyle() const;
170 Returns @true if the style of the brush is any of hatched fills.
174 virtual bool IsHatch() const;
177 Returns @true if the brush is initialised.
179 Notice that an uninitialized brush object can't be queried for any
180 brush properties and all calls to the accessor methods on it will
181 result in an assert failure.
183 virtual bool IsOk() const;
186 Returns @true if the brush is a valid non-transparent brush.
188 This method returns @true if the brush object is initialized and has a
189 non-transparent style. Notice that this should be used instead of
190 simply testing whether GetStyle() returns a style different from
191 wxBRUSHSTYLE_TRANSPARENT if the brush may be invalid as GetStyle()
192 would assert in this case.
198 bool IsNonTransparent() const;
201 Returns @true if the brush is transparent.
203 A transparent brush is simply a brush with wxBRUSHSTYLE_TRANSPARENT
206 Notice that this function works even for non-initialized brushes (for
207 which it returns @false) unlike tests of the form <code>GetStyle() ==
208 wxBRUSHSTYLE_TRANSPARENT</code> which would assert if the brush is
211 @see IsNonTransparent()
215 bool IsTransparent() const;
220 Sets the brush colour using red, green and blue values.
224 virtual void SetColour(const wxColour
& colour
);
225 virtual void SetColour(unsigned char red
, unsigned char green
, unsigned char blue
);
229 Sets the stipple bitmap.
232 The bitmap to use for stippling.
234 @remarks The style will be set to @c wxBRUSHSTYLE_STIPPLE, unless the bitmap
235 has a mask associated to it, in which case the style will be set
236 to @c wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE.
240 virtual void SetStipple(const wxBitmap
& bitmap
);
243 Sets the brush style.
246 One of the ::wxBrushStyle values.
250 virtual void SetStyle(wxBrushStyle style
);
254 See @ref overview_refcount_equality for more info.
256 bool operator !=(const wxBrush
& brush
) const;
260 See @ref overview_refcount_equality for more info.
262 bool operator ==(const wxBrush
& brush
) const;
267 wxBrush::IsOk() always returns @false for this object.
273 Except for the color it has all standard attributes
274 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
276 wxBrush
* wxBLUE_BRUSH
;
280 Except for the color it has all standard attributes
281 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
283 wxBrush
* wxGREEN_BRUSH
;
287 Except for the color it has all standard attributes
288 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
290 wxBrush
* wxYELLOW_BRUSH
;
294 Except for the color it has all standard attributes
295 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
297 wxBrush
* wxWHITE_BRUSH
;
301 Except for the color it has all standard attributes
302 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
304 wxBrush
* wxBLACK_BRUSH
;
308 Except for the color it has all standard attributes
309 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
311 wxBrush
* wxGREY_BRUSH
;
315 Except for the color it has all standard attributes
316 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
318 wxBrush
* wxMEDIUM_GREY_BRUSH
;
322 Except for the color it has all standard attributes
323 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
325 wxBrush
* wxLIGHT_GREY_BRUSH
;
329 Except for the color it has all standard attributes
330 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
332 wxBrush
* wxTRANSPARENT_BRUSH
;
336 Except for the color it has all standard attributes
337 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
339 wxBrush
* wxCYAN_BRUSH
;
343 Except for the color it has all standard attributes
344 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
346 wxBrush
* wxRED_BRUSH
;
353 A brush list is a list containing all brushes which have been created.
355 The application should not construct its own brush list: it should use the
356 object pointer ::wxTheBrushList.
367 Finds a brush with the specified attributes and returns it, else creates a new
368 brush, adds it to the brush list, and returns it.
373 Brush style. See ::wxBrushStyle for a list of styles.
375 wxBrush
* FindOrCreateBrush(const wxColour
& colour
,
376 wxBrushStyle style
= wxBRUSHSTYLE_SOLID
);
380 The global wxBrushList instance.
382 wxBrushList
* wxTheBrushList
;