1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxBrush
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 The possible brush styles.
14 wxBRUSHSTYLE_INVALID
= -1,
16 wxBRUSHSTYLE_SOLID
= wxSOLID
,
19 wxBRUSHSTYLE_TRANSPARENT
= wxTRANSPARENT
,
20 /**< Transparent (no fill). */
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. */
26 wxBRUSHSTYLE_STIPPLE_MASK
= wxSTIPPLE_MASK
,
27 /**< Uses a bitmap as a stipple; mask is used for masking areas in the
30 wxBRUSHSTYLE_STIPPLE
= wxSTIPPLE
,
31 /**< Uses a bitmap as a stipple. */
33 wxBRUSHSTYLE_BDIAGONAL_HATCH
= wxBDIAGONAL_HATCH
,
34 /**< Backward diagonal hatch. */
36 wxBRUSHSTYLE_CROSSDIAG_HATCH
= wxCROSSDIAG_HATCH
,
37 /**< Cross-diagonal hatch. */
39 wxBRUSHSTYLE_FDIAGONAL_HATCH
= wxFDIAGONAL_HATCH
,
40 /**< Forward diagonal hatch. */
42 wxBRUSHSTYLE_CROSS_HATCH
= wxCROSS_HATCH
,
45 wxBRUSHSTYLE_HORIZONTAL_HATCH
= wxHORIZONTAL_HATCH
,
46 /**< Horizontal hatch. */
48 wxBRUSHSTYLE_VERTICAL_HATCH
= wxVERTICAL_HATCH
,
49 /**< Vertical hatch. */
51 wxBRUSHSTYLE_FIRST_HATCH
= wxFIRST_HATCH
,
52 wxBRUSHSTYLE_LAST_HATCH
= wxLAST_HATCH
,
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.
63 On a monochrome display, wxWidgets shows all brushes as white unless the
64 colour is really black.
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.
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().
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.
93 @li ::wxLIGHT_GREY_BRUSH
94 @li ::wxMEDIUM_GREY_BRUSH
96 @li ::wxTRANSPARENT_BRUSH
99 @see wxBrushList, wxDC, wxDC::SetBrush
101 class wxBrush
: public wxGDIObject
106 The brush will be uninitialised, and wxBrush:IsOk() will return @false.
111 Constructs a brush from a colour object and @a style.
116 One of the ::wxBrushStyle enumeration values.
118 wxBrush(const wxColour
& colour
, wxBrushStyle style
= wxBRUSHSTYLE_SOLID
);
121 Constructs a stippled brush using a bitmap.
122 The brush style will be set to @c wxBRUSHSTYLE_STIPPLE.
124 wxBrush(const wxBitmap
& stippleBitmap
);
127 Copy constructor, uses @ref overview_refcount "reference counting".
129 wxBrush(const wxBrush
& brush
);
134 See @ref overview_refcount_destruct for more info.
136 @remarks Although all remaining brushes are deleted when the application
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.
145 Returns a reference to the brush colour.
149 virtual wxColour
GetColour() const;
152 Gets a pointer to the stipple bitmap. If the brush does not have a @c wxBRUSHSTYLE_STIPPLE
153 style, this bitmap may be non-@NULL but uninitialised (i.e. wxBitmap:IsOk() returns @false).
157 virtual wxBitmap
* GetStipple() const;
160 Returns the brush style, one of the ::wxBrushStyle values.
162 @see SetStyle(), SetColour(), SetStipple()
164 virtual wxBrushStyle
GetStyle() const;
167 Returns @true if the style of the brush is any of hatched fills.
171 virtual bool IsHatch() const;
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).
178 virtual bool IsOk() const;
182 Sets the brush colour using red, green and blue values.
186 virtual void SetColour(const wxColour
& colour
);
187 virtual void SetColour(unsigned char red
, unsigned char green
, unsigned char blue
);
191 Sets the stipple bitmap.
194 The bitmap to use for stippling.
196 @remarks The style will be set to @c wxBRUSHSTYLE_STIPPLE, unless the bitmap
197 has a mask associated to it, in which case the style will be set
198 to @c wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE.
202 virtual void SetStipple(const wxBitmap
& bitmap
);
205 Sets the brush style.
208 One of the ::wxBrushStyle values.
212 virtual void SetStyle(wxBrushStyle style
);
216 See @ref overview_refcount_equality for more info.
218 bool operator !=(const wxBrush
& brush
) const;
222 See @ref overview_refcount_equality for more info.
224 bool operator ==(const wxBrush
& brush
) const;
229 wxBrush::IsOk() always returns @false for this object.
235 Except for the color it has all standard attributes
236 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
238 wxBrush
* wxBLUE_BRUSH
;
242 Except for the color it has all standard attributes
243 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
245 wxBrush
* wxGREEN_BRUSH
;
249 Except for the color it has all standard attributes
250 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
252 wxBrush
* wxWHITE_BRUSH
;
256 Except for the color it has all standard attributes
257 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
259 wxBrush
* wxBLACK_BRUSH
;
263 Except for the color it has all standard attributes
264 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
266 wxBrush
* wxGREY_BRUSH
;
270 Except for the color it has all standard attributes
271 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
273 wxBrush
* wxMEDIUM_GREY_BRUSH
;
277 Except for the color it has all standard attributes
278 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
280 wxBrush
* wxLIGHT_GREY_BRUSH
;
284 Except for the color it has all standard attributes
285 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
287 wxBrush
* wxTRANSPARENT_BRUSH
;
291 Except for the color it has all standard attributes
292 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
294 wxBrush
* wxCYAN_BRUSH
;
298 Except for the color it has all standard attributes
299 (@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
301 wxBrush
* wxRED_BRUSH
;
308 A brush list is a list containing all brushes which have been created.
310 The application should not construct its own brush list: it should use the
311 object pointer ::wxTheBrushList.
318 class wxBrushList
: public wxList
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.
328 Brush style. See ::wxBrushStyle for a list of styles.
330 wxBrush
* FindOrCreateBrush(const wxColour
& colour
,
331 wxBrushStyle style
= wxBRUSHSTYLE_SOLID
);
335 The global wxBrushList instance.
337 wxBrushList
* wxTheBrushList
;