1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488
|
<HTML>
<head><title>wxBrush</title></head>
<BODY BGCOLOR=#FFFFFF>
<A NAME="wxbrush"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx22.htm#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx35.htm#wxbitmapdataobject"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx37.htm#wxbrushlist"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>
<H2>wxBrush</H2>
<P>
A brush is a drawing tool for filling in areas. It is used for painting
the background of rectangles, ellipses, etc. It has a colour and a
style.<P>
<B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
<A HREF="wx107.htm#wxgdiobject">wxGDIObject</A><BR>
<A HREF="wx158.htm#wxobject">wxObject</A><P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
<wx/brush.h><P>
<B><FONT COLOR="#FF0000">Predefined objects</FONT></B><P>
Objects:<P>
<B>wxNullBrush</B><P>
Pointers:<P>
<B>wxBLUE_BRUSH<BR>
wxGREEN_BRUSH<BR>
wxWHITE_BRUSH<BR>
wxBLACK_BRUSH<BR>
wxGREY_BRUSH<BR>
wxMEDIUM_GREY_BRUSH<BR>
wxLIGHT_GREY_BRUSH<BR>
wxTRANSPARENT_BRUSH<BR>
wxCYAN_BRUSH<BR>
wxRED_BRUSH</B><P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
On a monochrome display, wxWindows shows
all brushes as white unless the colour is really black.<P>
Do not initialize objects on the stack before the program commences,
since other required structures may not have been set up yet. Instead,
define global pointers to objects and create them in <A HREF="wx26.htm#wxapponinit">wxApp::OnInit</A> or
when required.<P>
An application may wish to create brushes with different
characteristics dynamically, and there is the consequent danger that a
large number of duplicate brushes will be created. Therefore an
application may wish to get a pointer to a brush by using the global
list of brushes <B>wxTheBrushList</B>, and calling the member function
<B>FindOrCreateBrush</B>.<P>
wxBrush uses a reference counting system, so assignments between brushes are very
cheap. You can therefore use actual wxBrush objects instead of pointers without
efficiency problems. Once one wxBrush object changes its data it will create its
own brush data internally so that other brushes, which previously shared the
data using the reference counting, are not affected.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx37.htm#wxbrushlist">wxBrushList</A>, <A HREF="wx65.htm#wxdc">wxDC</A>, <A HREF="wx65.htm#wxdcsetbrush">wxDC::SetBrush</A><P>
<B><FONT COLOR="#FF0000">Members</FONT></B><P>
<A HREF="#topic72">wxBrush::wxBrush</A><BR>
<A HREF="#topic73">wxBrush::~wxBrush</A><BR>
<A HREF="#wxbrushgetcolour">wxBrush::GetColour</A><BR>
<A HREF="#wxbrushgetstipple">wxBrush::GetStipple</A><BR>
<A HREF="#wxbrushgetstyle">wxBrush::GetStyle</A><BR>
<A HREF="#wxbrushok">wxBrush::Ok</A><BR>
<A HREF="#wxbrushsetcolour">wxBrush::SetColour</A><BR>
<A HREF="#wxbrushsetstipple">wxBrush::SetStipple</A><BR>
<A HREF="#wxbrushsetstyle">wxBrush::SetStyle</A><BR>
<A HREF="#wxbrushassignment">wxBrush::operator =</A><BR>
<A HREF="#wxbrushequals">wxBrush::operator ==</A><BR>
<A HREF="#wxbrushnotequals">wxBrush::operator !=</A><BR>
<P>
<HR>
<A NAME="topic72"></A>
<H3>wxBrush::wxBrush</H3>
<P>
<B></B> <B>wxBrush</B>()<P>
Default constructor. The brush will be uninitialised, and <A HREF="wx36.htm#wxbrushok">wxBrush::Ok</A> will
return FALSE.<P>
<B></B> <B>wxBrush</B>(<B>const wxColour&</B><I> colour</I>, <B>int</B><I> style</I>)<P>
Constructs a brush from a colour object and style.<P>
<B></B> <B>wxBrush</B>(<B>const wxString& </B><I>colourName</I>, <B>int</B><I> style</I>)<P>
Constructs a brush from a colour name and style.<P>
<B></B> <B>wxBrush</B>(<B>const wxBitmap& </B><I>stippleBitmap</I>)<P>
Constructs a stippled brush using a bitmap.<P>
<B></B> <B>wxBrush</B>(<B>const wxBrush&</B><I> brush</I>)<P>
Copy constructor. This uses reference counting so is a cheap operation.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>colour</I><UL><UL>
Colour object.</UL></UL>
<P>
<I>colourName</I><UL><UL>
Colour name. The name will be looked up in the colour database.</UL></UL>
<P>
<I>style</I><UL><UL>
One of:<P>
<TABLE>
<TR><TD VALIGN=TOP>
<B>wxTRANSPARENT</B>
</TD>
<TD VALIGN=TOP>
Transparent (no fill).
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxSOLID</B>
</TD>
<TD VALIGN=TOP>
Solid.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxBDIAGONAL_HATCH</B>
</TD>
<TD VALIGN=TOP>
Backward diagonal hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxCROSSDIAG_HATCH</B>
</TD>
<TD VALIGN=TOP>
Cross-diagonal hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxFDIAGONAL_HATCH</B>
</TD>
<TD VALIGN=TOP>
Forward diagonal hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxCROSS_HATCH</B>
</TD>
<TD VALIGN=TOP>
Cross hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxHORIZONTAL_HATCH</B>
</TD>
<TD VALIGN=TOP>
Horizontal hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxVERTICAL_HATCH</B>
</TD>
<TD VALIGN=TOP>
Vertical hatch.
</TD></TR>
</TABLE>
</UL></UL>
<P>
<I>brush</I><UL><UL>
Pointer or reference to a brush to copy.</UL></UL>
<P>
<I>stippleBitmap</I><UL><UL>
A bitmap to use for stippling.</UL></UL>
<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
If a stipple brush is created, the brush style will be set to wxSTIPPLE.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx37.htm#wxbrushlist">wxBrushList</A>, <A HREF="wx46.htm#wxcolour">wxColour</A>, <A HREF="wx48.htm#wxcolourdatabase">wxColourDatabase</A><P>
<HR>
<A NAME="topic73"></A>
<H3>wxBrush::~wxBrush</H3>
<P>
<B>void</B> <B>~wxBrush</B>()<P>
Destructor.<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
The destructor may not delete the underlying brush object of the native windowing
system, since wxBrush uses a reference counting system for efficiency.<P>
Although all remaining brushes are deleted when the application exits,
the application should try to clean up all brushes itself. This is because
wxWindows cannot know if a pointer to the brush object is stored in an
application data structure, and there is a risk of double deletion.<P>
<HR>
<A NAME="wxbrushgetcolour"></A>
<H3>wxBrush::GetColour</H3>
<P>
<B>wxColour&</B> <B>GetColour</B>() <B>const</B><P>
Returns a reference to the brush colour.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx36.htm#wxbrushsetcolour">wxBrush::SetColour</A><P>
<HR>
<A NAME="wxbrushgetstipple"></A>
<H3>wxBrush::GetStipple</H3>
<P>
<B>wxBitmap *</B> <B>GetStipple</B>() <B>const</B><P>
Gets a pointer to the stipple bitmap. If the brush does not have a wxSTIPPLE style,
this bitmap may be non-NULL but uninitialised (<A HREF="wx32.htm#wxbitmapok">wxBitmap::Ok</A> returns FALSE).<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx36.htm#wxbrushsetstipple">wxBrush::SetStipple</A><P>
<HR>
<A NAME="wxbrushgetstyle"></A>
<H3>wxBrush::GetStyle</H3>
<P>
<B>int</B> <B>GetStyle</B>() <B>const</B><P>
Returns the brush style, one of:<P>
<TABLE>
<TR><TD VALIGN=TOP>
<B>wxTRANSPARENT</B>
</TD>
<TD VALIGN=TOP>
Transparent (no fill).
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxSOLID</B>
</TD>
<TD VALIGN=TOP>
Solid.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxBDIAGONAL_HATCH</B>
</TD>
<TD VALIGN=TOP>
Backward diagonal hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxCROSSDIAG_HATCH</B>
</TD>
<TD VALIGN=TOP>
Cross-diagonal hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxFDIAGONAL_HATCH</B>
</TD>
<TD VALIGN=TOP>
Forward diagonal hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxCROSS_HATCH</B>
</TD>
<TD VALIGN=TOP>
Cross hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxHORIZONTAL_HATCH</B>
</TD>
<TD VALIGN=TOP>
Horizontal hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxVERTICAL_HATCH</B>
</TD>
<TD VALIGN=TOP>
Vertical hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxSTIPPLE</B>
</TD>
<TD VALIGN=TOP>
Stippled using a bitmap.
</TD></TR>
</TABLE>
<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx36.htm#wxbrushsetstyle">wxBrush::SetStyle</A>, <A HREF="wx36.htm#wxbrushsetcolour">wxBrush::SetColour</A>,
<A HREF="wx36.htm#wxbrushsetstipple">wxBrush::SetStipple</A><P>
<HR>
<A NAME="wxbrushok"></A>
<H3>wxBrush::Ok</H3>
<P>
<B>bool</B> <B>Ok</B>() <B>const</B><P>
Returns TRUE if the brush is initialised. It will return FALSE if the default
constructor has been used (for example, the brush is a member of a class, or
NULL has been assigned to it).<P>
<HR>
<A NAME="wxbrushsetcolour"></A>
<H3>wxBrush::SetColour</H3>
<P>
<B>void</B> <B>SetColour</B>(<B>wxColour& </B><I>colour</I>)<P>
Sets the brush colour using a reference to a colour object.<P>
<B>void</B> <B>SetColour</B>(<B>const wxString& </B><I>colourName</I>)<P>
Sets the brush colour using a colour name from the colour database.<P>
<B>void</B> <B>SetColour</B>(<B>const unsigned char</B><I> red</I>, <B>const unsigned char</B><I> green</I>, <B>const unsigned char</B><I> blue</I>)<P>
Sets the brush colour using red, green and blue values.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx36.htm#wxbrushgetcolour">wxBrush::GetColour</A><P>
<HR>
<A NAME="wxbrushsetstipple"></A>
<H3>wxBrush::SetStipple</H3>
<P>
<B>void</B> <B>SetStipple</B>(<B>const wxBitmap&</B><I> bitmap</I>)<P>
Sets the stipple bitmap.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>bitmap</I><UL><UL>
The bitmap to use for stippling.</UL></UL>
<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
The style will be set to wxSTIPPLE.<P>
Note that there is a big difference between stippling in X and Windows.
On X, the stipple is a mask between the wxBitmap and current colour.
On Windows, the current colour is ignored, and the bitmap colour is used.
However, for pre-defined modes like wxCROSS_HATCH, the behaviour is the
same for both platforms.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx32.htm#wxbitmap">wxBitmap</A><P>
<HR>
<A NAME="wxbrushsetstyle"></A>
<H3>wxBrush::SetStyle</H3>
<P>
<B>void</B> <B>SetStyle</B>(<B>int</B><I> style</I>)<P>
Sets the brush style.<P>
<I>style</I><UL><UL>
One of:<P>
<TABLE>
<TR><TD VALIGN=TOP>
<B>wxTRANSPARENT</B>
</TD>
<TD VALIGN=TOP>
Transparent (no fill).
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxSOLID</B>
</TD>
<TD VALIGN=TOP>
Solid.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxBDIAGONAL_HATCH</B>
</TD>
<TD VALIGN=TOP>
Backward diagonal hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxCROSSDIAG_HATCH</B>
</TD>
<TD VALIGN=TOP>
Cross-diagonal hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxFDIAGONAL_HATCH</B>
</TD>
<TD VALIGN=TOP>
Forward diagonal hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxCROSS_HATCH</B>
</TD>
<TD VALIGN=TOP>
Cross hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxHORIZONTAL_HATCH</B>
</TD>
<TD VALIGN=TOP>
Horizontal hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxVERTICAL_HATCH</B>
</TD>
<TD VALIGN=TOP>
Vertical hatch.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxSTIPPLE</B>
</TD>
<TD VALIGN=TOP>
Stippled using a bitmap.
</TD></TR>
</TABLE>
</UL></UL>
<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx36.htm#wxbrushgetstyle">wxBrush::GetStyle</A><P>
<HR>
<A NAME="wxbrushassignment"></A>
<H3>wxBrush::operator =</H3>
<P>
<B>wxBrush&</B> <B>operator =</B>(<B>const wxBrush& </B><I>brush</I>)<P>
Assignment operator, using reference counting. Returns a reference
to 'this'.<P>
<HR>
<A NAME="wxbrushequals"></A>
<H3>wxBrush::operator ==</H3>
<P>
<B>bool</B> <B>operator ==</B>(<B>const wxBrush& </B><I>brush</I>)<P>
Equality operator. Two brushes are equal if they contain pointers
to the same underlying brush data. It does not compare each attribute,
so two independently-created brushes using the same parameters will
fail the test.<P>
<HR>
<A NAME="wxbrushnotequals"></A>
<H3>wxBrush::operator !=</H3>
<P>
<B>bool</B> <B>operator !=</B>(<B>const wxBrush& </B><I>brush</I>)<P>
Inequality operator. Two brushes are not equal if they contain pointers
to different underlying brush data. It does not compare each attribute.<P>
</BODY></HTML>
|