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 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910
|
<HTML>
<head><title>wxDC</title></head>
<BODY BGCOLOR=#FFFFFF>
<A NAME="wxdc"></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="wx64.htm#wxdate"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx66.htm#wxddeclient"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>
<H2>wxDC</H2>
<P>
A wxDC is a <I>device context</I> onto which graphics and text can be drawn.
It is intended to represent a number of output devices in a generic way,
so a window can have a device context associated with it, and a printer also has a device context.
In this way, the same piece of code may write to a number of different devices,
if the device context is used as a parameter.<P>
Derived types of wxDC have documentation for specific features
only, so refer to this section for most device context information.<P>
<B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
<A HREF="wx158.htm#wxobject">wxObject</A><P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
<wx/dc.h><P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx294.htm#dcoverview">Overview</A><P>
<B><FONT COLOR="#FF0000">Members</FONT></B><P>
<A HREF="#topic191">wxDC::wxDC</A><BR>
<A HREF="#topic192">wxDC::~wxDC</A><BR>
<A HREF="#wxdcbegindrawing">wxDC::BeginDrawing</A><BR>
<A HREF="#wxdcblit">wxDC::Blit</A><BR>
<A HREF="#wxdcclear">wxDC::Clear</A><BR>
<A HREF="#wxdccrosshair">wxDC::CrossHair</A><BR>
<A HREF="#wxdcdestroyclippingregion">wxDC::DestroyClippingRegion</A><BR>
<A HREF="#wxdcdevicetologicalx">wxDC::DeviceToLogicalX</A><BR>
<A HREF="#wxdcdevicetologicalxrel">wxDC::DeviceToLogicalXRel</A><BR>
<A HREF="#wxdcdevicetologicaly">wxDC::DeviceToLogicalY</A><BR>
<A HREF="#wxdcdevicetologicalyrel">wxDC::DeviceToLogicalYRel</A><BR>
<A HREF="#wxdcdrawarc">wxDC::DrawArc</A><BR>
<A HREF="#wxdcdrawbitmap">wxDC::DrawBitmap</A><BR>
<A HREF="#wxdcdrawellipse">wxDC::DrawEllipse</A><BR>
<A HREF="#wxdcdrawellipticarc">wxDC::DrawEllipticArc</A><BR>
<A HREF="#wxdcdrawicon">wxDC::DrawIcon</A><BR>
<A HREF="#wxdcdrawline">wxDC::DrawLine</A><BR>
<A HREF="#wxdcdrawlines">wxDC::DrawLines</A><BR>
<A HREF="#wxdcdrawpolygon">wxDC::DrawPolygon</A><BR>
<A HREF="#wxdcdrawpoint">wxDC::DrawPoint</A><BR>
<A HREF="#wxdcdrawrectangle">wxDC::DrawRectangle</A><BR>
<A HREF="#wxdcdrawroundedrectangle">wxDC::DrawRoundedRectangle</A><BR>
<A HREF="#wxdcdrawspline">wxDC::DrawSpline</A><BR>
<A HREF="#wxdcdrawtext">wxDC::DrawText</A><BR>
<A HREF="#wxdcenddoc">wxDC::EndDoc</A><BR>
<A HREF="#wxdcenddrawing">wxDC::EndDrawing</A><BR>
<A HREF="#wxdcendpage">wxDC::EndPage</A><BR>
<A HREF="#wxdcfloodfill">wxDC::FloodFill</A><BR>
<A HREF="#wxdcgetbackground">wxDC::GetBackground</A><BR>
<A HREF="#wxdcgetbrush">wxDC::GetBrush</A><BR>
<A HREF="#wxdcgetcharheight">wxDC::GetCharHeight</A><BR>
<A HREF="#wxdcgetcharwidth">wxDC::GetCharWidth</A><BR>
<A HREF="#wxdcgetclippingbox">wxDC::GetClippingBox</A><BR>
<A HREF="#wxdcgetfont">wxDC::GetFont</A><BR>
<A HREF="#wxdcgetlogicalfunction">wxDC::GetLogicalFunction</A><BR>
<A HREF="#wxdcgetmapmode">wxDC::GetMapMode</A><BR>
<A HREF="#wxdcgetoptimization">wxDC::GetOptimization</A><BR>
<A HREF="#wxdcgetpen">wxDC::GetPen</A><BR>
<A HREF="#wxdcgetpixel">wxDC::GetPixel</A><BR>
<A HREF="#wxdcgetsize">wxDC::GetSize</A><BR>
<A HREF="#wxdcgettextbackground">wxDC::GetTextBackground</A><BR>
<A HREF="#wxdcgettextextent">wxDC::GetTextExtent</A><BR>
<A HREF="#wxdcgettextforeground">wxDC::GetTextForeground</A><BR>
<A HREF="#wxdclogicaltodevicex">wxDC::LogicalToDeviceX</A><BR>
<A HREF="#wxdclogicaltodevicexrel">wxDC::LogicalToDeviceXRel</A><BR>
<A HREF="#wxdclogicaltodevicey">wxDC::LogicalToDeviceY</A><BR>
<A HREF="#wxdclogicaltodeviceyrel">wxDC::LogicalToDeviceYRel</A><BR>
<A HREF="#wxdcmaxx">wxDC::MaxX</A><BR>
<A HREF="#wxdcmaxy">wxDC::MaxY</A><BR>
<A HREF="#wxdcminx">wxDC::MinX</A><BR>
<A HREF="#wxdcminy">wxDC::MinY</A><BR>
<A HREF="#wxdcok">wxDC::Ok</A><BR>
<A HREF="#wxdcsetdeviceorigin">wxDC::SetDeviceOrigin</A><BR>
<A HREF="#wxdcsetbackground">wxDC::SetBackground</A><BR>
<A HREF="#wxdcsetbackgroundmode">wxDC::SetBackgroundMode</A><BR>
<A HREF="#wxdcsetclippingregion">wxDC::SetClippingRegion</A><BR>
<A HREF="#wxdcsetpalette">wxDC::SetPalette</A><BR>
<A HREF="#wxdcsetbrush">wxDC::SetBrush</A><BR>
<A HREF="#wxdcsetfont">wxDC::SetFont</A><BR>
<A HREF="#wxdcsetlogicalfunction">wxDC::SetLogicalFunction</A><BR>
<A HREF="#wxdcsetmapmode">wxDC::SetMapMode</A><BR>
<A HREF="#wxsetoptimization">wxDC::SetOptimization</A><BR>
<A HREF="#wxdcsetpen">wxDC::SetPen</A><BR>
<A HREF="#wxdcsettextbackground">wxDC::SetTextBackground</A><BR>
<A HREF="#wxdcsettextforeground">wxDC::SetTextForeground</A><BR>
<A HREF="#wxdcsetuserscale">wxDC::SetUserScale</A><BR>
<A HREF="#wxdcstartdoc">wxDC::StartDoc</A><BR>
<A HREF="#wxdcstartpage">wxDC::StartPage</A><BR>
<P>
<HR>
<A NAME="topic191"></A>
<H3>wxDC::wxDC</H3>
<P>
<B></B> <B>wxDC</B>()<P>
Constructor.<P>
<HR>
<A NAME="topic192"></A>
<H3>wxDC::~wxDC</H3>
<P>
<B></B> <B>~wxDC</B>()<P>
Destructor.<P>
<HR>
<A NAME="wxdcbegindrawing"></A>
<H3>wxDC::BeginDrawing</H3>
<P>
<B>void</B> <B>BeginDrawing</B>()<P>
Allows optimization of drawing code under MS Windows. Enclose
drawing primitives between <B>BeginDrawing</B> and <B>EndDrawing</B>
calls.<P>
Drawing to a wxDialog panel device context outside of a
system-generated OnPaint event <I>requires</I> this pair of calls to
enclose drawing code. This is because a Windows dialog box does not have
a retained device context associated with it, and selections such as pen
and brush settings would be lost if the device context were obtained and
released for each drawing operation.<P>
<HR>
<A NAME="wxdcblit"></A>
<H3>wxDC::Blit</H3>
<P>
<B>bool</B> <B>Blit</B>(<B>long</B><I> xdest</I>, <B>long</B><I> ydest</I>, <B>long</B><I> width</I>, <B>long</B><I> height</I>,
<B>wxDC* </B><I>source</I>, <B>long</B><I> xsrc</I>, <B>long</B><I> ysrc</I>, <B>int</B><I> logicalFunc</I>,
<B>bool </B><I>useMask</I>)<P>
Copy from a source DC to this DC, specifying the destination
coordinates, size of area to copy, source DC, source coordinates, and
logical function.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>xdest</I><UL><UL>
Destination device context x position.</UL></UL>
<P>
<I>ydest</I><UL><UL>
Destination device context y position.</UL></UL>
<P>
<I>width</I><UL><UL>
Width of source area to be copied.</UL></UL>
<P>
<I>height</I><UL><UL>
Height of source area to be copied.</UL></UL>
<P>
<I>source</I><UL><UL>
Source device context.</UL></UL>
<P>
<I>xsrc</I><UL><UL>
Source device context x position.</UL></UL>
<P>
<I>ysrc</I><UL><UL>
Source device context y position.</UL></UL>
<P>
<I>logicalFunc</I><UL><UL>
Logical function to use: see <A HREF="wx65.htm#wxdcsetlogicalfunction">wxDC::SetLogicalFunction</A>.</UL></UL>
<P>
<I>useMask</I><UL><UL>
If TRUE, Blit does a transparent blit using the mask that is associated with the bitmap
selected into the source device context. The Windows implementation does the following:<P>
<OL>
<LI> Creates a temporary bitmap and copies the destination area into it.
<LI> Copies the source area into the temporary bitmap using the specified logical function.
<LI> Sets the masked area in the temporary bitmap to BLACK by ANDing the
mask bitmap with the temp bitmap with the foreground colour set to WHITE
and the bg colour set to BLACK.
<LI> Sets the unmasked area in the destination area to BLACK by ANDing the
mask bitmap with the destination area with the foreground colour set to BLACK
and the background colour set to WHITE.
<LI> ORs the temporary bitmap with the destination area.
<LI> Deletes the temporary bitmap.
</OL>
<P>
This sequence of operations ensures that the source's transparent area need not be black,
and logical functions are supported.
</UL></UL>
<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
There is partial support for Blit in wxPostScriptDC, under X.<P>
See <A HREF="wx137.htm#wxmemorydc">wxMemoryDC</A> for typical usage.<P>
wxheadingSee also<P>
<A HREF="wx137.htm#wxmemorydc">wxMemoryDC</A>, <A HREF="wx32.htm#wxbitmap">wxBitmap</A>, <A HREF="wx133.htm#wxmask">wxMask</A><P>
<HR>
<A NAME="wxdcclear"></A>
<H3>wxDC::Clear</H3>
<P>
<B>void</B> <B>Clear</B>()<P>
Clears the device context using the current background brush.<P>
<HR>
<A NAME="wxdccrosshair"></A>
<H3>wxDC::CrossHair</H3>
<P>
<B>void</B> <B>CrossHair</B>(<B>long</B><I> x</I>, <B>long</B><I> y</I>)<P>
Displays a cross hair using the current pen. This is a vertical
and horizontal line the height and width of the window, centred
on the given point.<P>
<HR>
<A NAME="wxdcdestroyclippingregion"></A>
<H3>wxDC::DestroyClippingRegion</H3>
<P>
<B>void</B> <B>DestroyClippingRegion</B>()<P>
Destroys the current clipping region so that none of the DC is clipped.
See also <A HREF="wx65.htm#wxdcsetclippingregion">wxDC::SetClippingRegion</A>.<P>
<HR>
<A NAME="wxdcdevicetologicalx"></A>
<H3>wxDC::DeviceToLogicalX</H3>
<P>
<B>long</B> <B>DeviceToLogicalX</B>(<B>long</B><I> x</I>)<P>
Convert device X coordinate to logical coordinate, using the current
mapping mode.<P>
<HR>
<A NAME="wxdcdevicetologicalxrel"></A>
<H3>wxDC::DeviceToLogicalXRel</H3>
<P>
<B>long</B> <B>DeviceToLogicalXRel</B>(<B>long</B><I> x</I>)<P>
Convert device X coordinate to relative logical coordinate, using the current
mapping mode. Use this function for converting a width, for example.<P>
<HR>
<A NAME="wxdcdevicetologicaly"></A>
<H3>wxDC::DeviceToLogicalY</H3>
<P>
<B>long</B> <B>DeviceToLogicalY</B>(<B>long</B><I> y</I>)<P>
Converts device Y coordinate to logical coordinate, using the current
mapping mode.<P>
<HR>
<A NAME="wxdcdevicetologicalyrel"></A>
<H3>wxDC::DeviceToLogicalYRel</H3>
<P>
<B>long</B> <B>DeviceToLogicalYRel</B>(<B>long</B><I> y</I>)<P>
Convert device Y coordinate to relative logical coordinate, using the current
mapping mode. Use this function for converting a height, for example.<P>
<HR>
<A NAME="wxdcdrawarc"></A>
<H3>wxDC::DrawArc</H3>
<P>
<B>void</B> <B>DrawArc</B>(<B>long</B><I> x1</I>, <B>long</B><I> y1</I>, <B>long</B><I> x2</I>, <B>long</B><I> y2</I>, <B>double</B><I> xc</I>, <B>double</B><I> yc</I>)<P>
Draws an arc of a circle, centred on (<I>xc, yc</I>), with starting point (<I>x1, y1</I>)
and ending at (<I>x2, y2</I>). The current pen is used for the outline
and the current brush for filling the shape.<P>
The arc is drawn in an anticlockwise direction from the start point to the end point.<P>
<HR>
<A NAME="wxdcdrawbitmap"></A>
<H3>wxDC::DrawBitmap</H3>
<P>
<B>void</B> <B>DrawBitmap</B>(<B>const wxBitmap&</B><I> bitmap</I>, <B>long</B><I> x</I>, <B>long</B><I> y</I>, <B>bool</B><I> transparent</I>)<P>
Draw a bitmap on the device context at the specified point. If <I>transparent</I> is TRUE and the bitmap has
a transparency mask, the bitmap will be drawn transparently.<P>
<HR>
<A NAME="wxdcdrawellipse"></A>
<H3>wxDC::DrawEllipse</H3>
<P>
<B>void</B> <B>DrawEllipse</B>(<B>long</B><I> x</I>, <B>long</B><I> y</I>, <B>long</B><I> width</I>, <B>long</B><I> height</I>)<P>
Draws an ellipse contained in the rectangle with the given top left corner, and with the
given size. The current pen is used for the outline and the current brush for
filling the shape.<P>
<HR>
<A NAME="wxdcdrawellipticarc"></A>
<H3>wxDC::DrawEllipticArc</H3>
<P>
<B>void</B> <B>DrawEllipticArc</B>(<B>long</B><I> x</I>, <B>long</B><I> y</I>, <B>long</B><I> width</I>, <B>long</B><I> height</I>,
<B>double</B><I> start</I>, <B>double</B><I> end</I>)<P>
Draws an arc of an ellipse. The current pen is used for drawing the arc and
the current brush is used for drawing the pie. This function is currently only available for
X window and PostScript device contexts.<P>
<I>x</I> and <I>y</I> specify the x and y coordinates of the upper-left corner of the rectangle that contains
the ellipse.<P>
<I>width</I> and <I>height</I> specify the width and height of the rectangle that contains
the ellipse.<P>
<I>start</I> and <I>end</I> specify the start and end of the arc relative to the three-o'clock
position from the center of the rectangle. Angles are specified
in degrees (360 is a complete circle). Positive values mean
counter-clockwise motion. If <I>start</I> is equal to <I>end</I>, a
complete ellipse will be drawn.<P>
<HR>
<A NAME="wxdcdrawicon"></A>
<H3>wxDC::DrawIcon</H3>
<P>
<B>void</B> <B>DrawIcon</B>(<B>const wxIcon&</B><I> icon</I>, <B>long</B><I> x</I>, <B>long</B><I> y</I>)<P>
Draw an icon on the display (does nothing if the device context is PostScript).
This can be the simplest way of drawing bitmaps on a window.<P>
<HR>
<A NAME="wxdcdrawline"></A>
<H3>wxDC::DrawLine</H3>
<P>
<B>void</B> <B>DrawLine</B>(<B>long</B><I> x1</I>, <B>long</B><I> y1</I>, <B>long</B><I> x2</I>, <B>long</B><I> y2</I>)<P>
Draws a line from the first point to the second. The current pen is used
for drawing the line.<P>
<HR>
<A NAME="wxdcdrawlines"></A>
<H3>wxDC::DrawLines</H3>
<P>
<B>void</B> <B>DrawLines</B>(<B>int</B><I> n</I>, <B>wxPoint</B><I> points[]</I>, <B>long</B><I> xoffset = 0</I>, <B>long</B><I> yoffset = 0</I>)<P>
<B>void</B> <B>DrawLines</B>(<B>wxList *</B><I>points</I>, <B>long</B><I> xoffset = 0</I>, <B>long</B><I> yoffset = 0</I>)<P>
Draws lines using an array of <I>points</I> of size <I>n</I>, or list of
pointers to points, adding the optional offset coordinate. The current
pen is used for drawing the lines. The programmer is responsible for
deleting the list of points.<P>
<B><FONT COLOR="#0000C8">wxPython note:</FONT></B><BR>
The wxPython version of this method accepts a Python list
of wxPoint objects.<P>
<HR>
<A NAME="wxdcdrawpolygon"></A>
<H3>wxDC::DrawPolygon</H3>
<P>
<B>void</B> <B>DrawPolygon</B>(<B>int</B><I> n</I>, <B>wxPoint</B><I> points[]</I>, <B>long</B><I> xoffset = 0</I>, <B>long</B><I> yoffset = 0</I>,<BR>
<B>int </B><I>fill_style = wxODDEVEN_RULE</I>)<P>
<B>void</B> <B>DrawPolygon</B>(<B>wxList *</B><I>points</I>, <B>long</B><I> xoffset = 0</I>, <B>long</B><I> yoffset = 0</I>,<BR>
<B>int </B><I>fill_style = wxODDEVEN_RULE</I>)<P>
Draws a filled polygon using an array of <I>points</I> of size <I>n</I>,
or list of pointers to points, adding the optional offset coordinate.<P>
The last argument specifies the fill rule: <B>wxODDEVEN_RULE</B> (the
default) or <B>wxWINDING_RULE</B>.<P>
The current pen is used for drawing the outline, and the current brush
for filling the shape. Using a transparent brush suppresses filling.
The programmer is responsible for deleting the list of points.<P>
Note that wxWindows automatically closes the first and last points.<P>
<B><FONT COLOR="#0000C8">wxPython note:</FONT></B><BR>
The wxPython version of this method accepts a Python list
of wxPoint objects.<P>
<HR>
<A NAME="wxdcdrawpoint"></A>
<H3>wxDC::DrawPoint</H3>
<P>
<B>void</B> <B>DrawPoint</B>(<B>long</B><I> x</I>, <B>long</B><I> y</I>)<P>
Draws a point using the current pen.<P>
<HR>
<A NAME="wxdcdrawrectangle"></A>
<H3>wxDC::DrawRectangle</H3>
<P>
<B>void</B> <B>DrawRectangle</B>(<B>long</B><I> x</I>, <B>long</B><I> y</I>, <B>long</B><I> width</I>, <B>long</B><I> height</I>)<P>
Draws a rectangle with the given top left corner, and with the given
size. The current pen is used for the outline and the current brush
for filling the shape.<P>
<HR>
<A NAME="wxdcdrawroundedrectangle"></A>
<H3>wxDC::DrawRoundedRectangle</H3>
<P>
<B>void</B> <B>DrawRoundedRectangle</B>(<B>long</B><I> x</I>, <B>long</B><I> y</I>, <B>long</B><I> width</I>, <B>long</B><I> height</I>, <B>double</B><I> radius = 20</I>)<P>
Draws a rectangle with the given top left corner, and with the given
size. The corners are quarter-circles using the given radius. The
current pen is used for the outline and the current brush for filling
the shape.<P>
If <I>radius</I> is positive, the value is assumed to be the
radius of the rounded corner. If <I>radius</I> is negative,
the absolute value is assumed to be the <I>proportion</I> of the smallest
dimension of the rectangle. This means that the corner can be
a sensible size relative to the size of the rectangle, and also avoids
the strange effects X produces when the corners are too big for
the rectangle.<P>
<HR>
<A NAME="wxdcdrawspline"></A>
<H3>wxDC::DrawSpline</H3>
<P>
<B>void</B> <B>DrawSpline</B>(<B>wxList *</B><I>points</I>)<P>
Draws a spline between all given control points, using the current
pen. Doesn't delete the wxList and contents. The spline is drawn
using a series of lines, using an algorithm taken from the X drawing
program 'XFIG'.<P>
<B>void</B> <B>DrawSpline</B>(<B>long</B><I> x1</I>, <B>long</B><I> y1</I>, <B>long</B><I> x2</I>, <B>long</B><I> y2</I>, <B>long</B><I> x3</I>, <B>long</B><I> y3</I>)<P>
Draws a three-point spline using the current pen.<P>
<B><FONT COLOR="#0000C8">wxPython note:</FONT></B><BR>
The wxPython version of this method accepts a Python list
of wxPoint objects.<P>
<HR>
<A NAME="wxdcdrawtext"></A>
<H3>wxDC::DrawText</H3>
<P>
<B>void</B> <B>DrawText</B>(<B>const wxString& </B><I>text</I>, <B>long</B><I> x</I>, <B>long</B><I> y</I>)<P>
Draws a text string at the specified point, using the current text font,
and the current text foreground and background colours.<P>
The coordinates refer to the top-left corner of the rectangle bounding
the string. See <A HREF="wx65.htm#wxdcgettextextent">wxDC::GetTextExtent</A> for how
to get the dimensions of a text string, which can be used to position the
text more precisely.<P>
<HR>
<A NAME="wxdcenddoc"></A>
<H3>wxDC::EndDoc</H3>
<P>
<B>void</B> <B>EndDoc</B>()<P>
Ends a document (only relevant when outputting to a printer).<P>
<HR>
<A NAME="wxdcenddrawing"></A>
<H3>wxDC::EndDrawing</H3>
<P>
<B>void</B> <B>EndDrawing</B>()<P>
Allows optimization of drawing code under MS Windows. Enclose
drawing primitives between <B>BeginDrawing</B> and <B>EndDrawing</B>
calls.<P>
<HR>
<A NAME="wxdcendpage"></A>
<H3>wxDC::EndPage</H3>
<P>
<B>void</B> <B>EndPage</B>()<P>
Ends a document page (only relevant when outputting to a printer).<P>
<HR>
<A NAME="wxdcfloodfill"></A>
<H3>wxDC::FloodFill</H3>
<P>
<B>void</B> <B>FloodFill</B>(<B>long</B><I> x</I>, <B>long</B><I> y</I>, <B>wxColour *</B><I>colour</I>, <B>int</B><I> style=wxFLOOD_SURFACE</I>)<P>
Flood fills the device context starting from the given point, in the given colour,
and using a style:<P>
<UL>
<LI> wxFLOOD_SURFACE: the flooding occurs until a colour other than the given colour is encountered.
<LI> wxFLOOD_BORDER: the area to be flooded is bounded by the given colour.
</UL>
<P>
<I>Note:</I> this function is available in MS Windows only.<P>
<HR>
<A NAME="wxdcgetbackground"></A>
<H3>wxDC::GetBackground</H3>
<P>
<B>wxBrush&</B> <B>GetBackground</B>()<P>
Gets the brush used for painting the background (see <A HREF="wx65.htm#wxdcsetbackground">wxDC::SetBackground</A>).<P>
<HR>
<A NAME="wxdcgetbrush"></A>
<H3>wxDC::GetBrush</H3>
<P>
<B>wxBrush&</B> <B>GetBrush</B>()<P>
Gets the current brush (see <A HREF="wx65.htm#wxdcsetbrush">wxDC::SetBrush</A>).<P>
<HR>
<A NAME="wxdcgetcharheight"></A>
<H3>wxDC::GetCharHeight</H3>
<P>
<B>long</B> <B>GetCharHeight</B>()<P>
Gets the character height of the currently set font.<P>
<HR>
<A NAME="wxdcgetcharwidth"></A>
<H3>wxDC::GetCharWidth</H3>
<P>
<B>long</B> <B>GetCharWidth</B>()<P>
Gets the average character width of the currently set font.<P>
<HR>
<A NAME="wxdcgetclippingbox"></A>
<H3>wxDC::GetClippingBox</H3>
<P>
<B>void</B> <B>GetClippingBox</B>(<B>long</B><I> *x</I>, <B>long</B><I> *y</I>, <B>long</B><I> *width</I>, <B>long</B><I> *height</I>)<P>
Gets the rectangle surrounding the current clipping region.<P>
<B><FONT COLOR="#0000C8">wxPython note:</FONT></B><BR>
No arguments are required and the four values defining the
rectangle are returned as a tuple.<P>
<HR>
<A NAME="wxdcgetfont"></A>
<H3>wxDC::GetFont</H3>
<P>
<B>wxFont&</B> <B>GetFont</B>()<P>
Gets the current font (see <A HREF="wx65.htm#wxdcsetfont">wxDC::SetFont</A>).<P>
<HR>
<A NAME="wxdcgetlogicalfunction"></A>
<H3>wxDC::GetLogicalFunction</H3>
<P>
<B>int</B> <B>GetLogicalFunction</B>()<P>
Gets the current logical function (see <A HREF="wx65.htm#wxdcsetlogicalfunction">wxDC::SetLogicalFunction</A>).<P>
<HR>
<A NAME="wxdcgetmapmode"></A>
<H3>wxDC::GetMapMode</H3>
<P>
<B>int</B> <B>GetMapMode</B>()<P>
Gets the <I>mapping mode</I> for the device context (see <A HREF="wx65.htm#wxdcsetmapmode">wxDC::SetMapMode</A>).<P>
<HR>
<A NAME="wxdcgetoptimization"></A>
<H3>wxDC::GetOptimization</H3>
<P>
<B>bool</B> <B>GetOptimization</B>()<P>
Returns TRUE if device context optimization is on.
See <A HREF="wx65.htm#wxsetoptimization">wxDC::SetOptimization</A> for details.<P>
<HR>
<A NAME="wxdcgetpen"></A>
<H3>wxDC::GetPen</H3>
<P>
<B>wxPen&</B> <B>GetPen</B>()<P>
Gets the current pen (see <A HREF="wx65.htm#wxdcsetpen">wxDC::SetPen</A>).<P>
<HR>
<A NAME="wxdcgetpixel"></A>
<H3>wxDC::GetPixel</H3>
<P>
<B>bool</B> <B>GetPixel</B>(<B>long</B><I> x</I>, <B>long</B><I> y</I>, <B>wxColour *</B><I>colour</I>)<P>
Sets <I>colour</I> to the colour at the specified location. Windows only; an X implementation
is being worked on. Not available for wxPostScriptDC or wxMetafileDC.<P>
<HR>
<A NAME="wxdcgetsize"></A>
<H3>wxDC::GetSize</H3>
<P>
<B>void</B> <B>GetSize</B>(<B>long *</B><I>width</I>, <B>long *</B><I>height</I>)<P>
For a PostScript device context, this gets the maximum size of graphics
drawn so far on the device context.<P>
For a Windows printer device context, this gets the horizontal and vertical
resolution. It can be used to scale graphics to fit the page when using
a Windows printer device context. For example, if <I>maxX</I> and <I>maxY</I>
represent the maximum horizontal and vertical 'pixel' values used in your
application, the following code will scale the graphic to fit on the
printer page:<P>
<PRE>
long w, h;
dc.GetSize(&w, &h);
double scaleX=(double)(maxX/w);
double scaleY=(double)(maxY/h);
dc.SetUserScale(min(scaleX,scaleY),min(scaleX,scaleY));
</PRE>
<B><FONT COLOR="#0000C8">wxPython note:</FONT></B><BR>
No arguments are required and the two values defining the
size are returned as a tuple.<P>
<HR>
<A NAME="wxdcgettextbackground"></A>
<H3>wxDC::GetTextBackground</H3>
<P>
<B>wxColour&</B> <B>GetTextBackground</B>()<P>
Gets the current text background colour (see <A HREF="wx65.htm#wxdcsettextbackground">wxDC::SetTextBackground</A>).<P>
<HR>
<A NAME="wxdcgettextextent"></A>
<H3>wxDC::GetTextExtent</H3>
<P>
<B>void</B> <B>GetTextExtent</B>(<B>const wxString& </B><I>string</I>, <B>long *</B><I>w</I>, <B>long *</B><I>h</I>,<BR>
<B>long *</B><I>descent = NULL</I>, <B>long *</B><I>externalLeading = NULL</I>, <B>wxFont *</B><I>font = NULL</I>)<P>
Gets the dimensions of the string using the currently selected font.
<I>string</I> is the text string to measure, <I>w</I> and <I>h</I> are
the total width and height respectively, <I>descent</I> is the
dimension from the baseline of the font to the bottom of the
descender, and <I>externalLeading</I> is any extra vertical space added
to the font by the font designer (usually is zero).<P>
The optional parameter <I>font</I> specifies an alternative
to the currently selected font: but note that this does not
yet work under Windows, so you need to set a font for
the device context first.<P>
See also <A HREF="wx100.htm#wxfont">wxFont</A>, <A HREF="wx65.htm#wxdcsetfont">wxDC::SetFont</A>.<P>
<B><FONT COLOR="#0000C8">wxPython note:</FONT></B><BR>
The following methods are implemented in wxPython:<P>
<UL><UL>
<TABLE>
<TR><TD VALIGN=TOP>
<B>GetTextExtent(string)</B>
</TD>
<TD VALIGN=TOP>
Returns a 2-tuple, (width, height)
</TD></TR>
<TR><TD VALIGN=TOP>
<B>GetFullTextExtent(string, font=NULL)</B>
</TD>
<TD VALIGN=TOP>
Returns a
4-tuple, (width, height, descent, externalLeading)
</TD></TR>
</TABLE>
</UL></UL>
<P>
<HR>
<A NAME="wxdcgettextforeground"></A>
<H3>wxDC::GetTextForeground</H3>
<P>
<B>wxColour&</B> <B>GetTextForeground</B>()<P>
Gets the current text foreground colour (see <A HREF="wx65.htm#wxdcsettextforeground">wxDC::SetTextForeground</A>).<P>
<HR>
<A NAME="wxdclogicaltodevicex"></A>
<H3>wxDC::LogicalToDeviceX</H3>
<P>
<B>long</B> <B>LogicalToDeviceX</B>(<B>long</B><I> x</I>)<P>
Converts logical X coordinate to device coordinate, using the current
mapping mode.<P>
<HR>
<A NAME="wxdclogicaltodevicexrel"></A>
<H3>wxDC::LogicalToDeviceXRel</H3>
<P>
<B>long</B> <B>LogicalToDeviceXRel</B>(<B>long</B><I> x</I>)<P>
Converts logical X coordinate to relative device coordinate, using the current
mapping mode. Use this for converting a width, for example.<P>
<HR>
<A NAME="wxdclogicaltodevicey"></A>
<H3>wxDC::LogicalToDeviceY</H3>
<P>
<B>long</B> <B>LogicalToDeviceY</B>(<B>long</B><I> y</I>)<P>
Converts logical Y coordinate to device coordinate, using the current
mapping mode.<P>
<HR>
<A NAME="wxdclogicaltodeviceyrel"></A>
<H3>wxDC::LogicalToDeviceYRel</H3>
<P>
<B>long</B> <B>LogicalToDeviceYRel</B>(<B>long</B><I> y</I>)<P>
Converts logical Y coordinate to relative device coordinate, using the current
mapping mode. Use this for converting a height, for example.<P>
<HR>
<A NAME="wxdcmaxx"></A>
<H3>wxDC::MaxX</H3>
<P>
<B>long</B> <B>MaxX</B>()<P>
Gets the maximum horizontal extent used in drawing commands so far.<P>
<HR>
<A NAME="wxdcmaxy"></A>
<H3>wxDC::MaxY</H3>
<P>
<B>long</B> <B>MaxY</B>()<P>
Gets the maximum vertical extent used in drawing commands so far.<P>
<HR>
<A NAME="wxdcminx"></A>
<H3>wxDC::MinX</H3>
<P>
<B>long</B> <B>MinX</B>()<P>
Gets the minimum horizontal extent used in drawing commands so far.<P>
<HR>
<A NAME="wxdcminy"></A>
<H3>wxDC::MinY</H3>
<P>
<B>long</B> <B>MinY</B>()<P>
Gets the minimum vertical extent used in drawing commands so far.<P>
<HR>
<A NAME="wxdcok"></A>
<H3>wxDC::Ok</H3>
<P>
<B>bool</B> <B>Ok</B>()<P>
Returns TRUE if the DC is ok to use.<P>
<HR>
<A NAME="wxdcsetdeviceorigin"></A>
<H3>wxDC::SetDeviceOrigin</H3>
<P>
<B>void</B> <B>SetDeviceOrigin</B>(<B>long</B><I> x</I>, <B>long</B><I> y</I>)<P>
Sets the device origin (i.e., the origin in pixels after scaling has been
applied).<P>
This function may be useful in Windows printing
operations for placing a graphic on a page.<P>
<HR>
<A NAME="wxdcsetbackground"></A>
<H3>wxDC::SetBackground</H3>
<P>
<B>void</B> <B>SetBackground</B>(<B>const wxBrush& </B><I>brush</I>)<P>
Sets the current background brush for the DC.<P>
<HR>
<A NAME="wxdcsetbackgroundmode"></A>
<H3>wxDC::SetBackgroundMode</H3>
<P>
<B>void</B> <B>SetBackgroundMode</B>(<B>int</B><I> mode</I>)<P>
<I>mode</I> may be one of wxSOLID and wxTRANSPARENT. This setting determines
whether text will be drawn with a background colour or not.<P>
<HR>
<A NAME="wxdcsetclippingregion"></A>
<H3>wxDC::SetClippingRegion</H3>
<P>
<B>void</B> <B>SetClippingRegion</B>(<B>long</B><I> x</I>, <B>long</B><I> y</I>, <B>long</B><I> width</I>, <B>long</B><I> height</I>)<P>
<B>void</B> <B>SetClippingRegion</B>(<B>const wxRegion&</B><I> region</I>)<P>
Sets the clipping region for the DC. The clipping region is an area
to which drawing is restricted. Possible uses for the clipping region are for clipping text
or for speeding up window redraws when only a known area of the screen is damaged.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx65.htm#wxdcdestroyclippingregion">wxDC::DestroyClippingRegion</A>, <A HREF="wx195.htm#wxregion">wxRegion</A><P>
<HR>
<A NAME="wxdcsetpalette"></A>
<H3>wxDC::SetPalette</H3>
<P>
<B>void</B> <B>SetPalette</B>(<B>const wxPalette& </B><I>palette</I>)<P>
If this is a window DC or memory DC, assigns the given palette to the window
or bitmap associated with the DC. If the argument is wxNullPalette, the current
palette is selected out of the device context, and the original palette
restored.<P>
See <A HREF="wx165.htm#wxpalette">wxPalette</A> for further details.<P>
<HR>
<A NAME="wxdcsetbrush"></A>
<H3>wxDC::SetBrush</H3>
<P>
<B>void</B> <B>SetBrush</B>(<B>const wxBrush& </B><I>brush</I>)<P>
Sets the current brush for the DC.<P>
If the argument is wxNullBrush, the current brush is selected out of the device
context, and the original brush restored, allowing the current brush to
be destroyed safely.<P>
See also <A HREF="wx36.htm#wxbrush">wxBrush</A>.<P>
<HR>
<A NAME="wxdcsetfont"></A>
<H3>wxDC::SetFont</H3>
<P>
<B>void</B> <B>SetFont</B>(<B>const wxFont& </B><I>font</I>)<P>
Sets the current font for the DC.<P>
If the argument is wxNullFont, the current font is selected out of the device
context, and the original font restored, allowing the current font to
be destroyed safely.<P>
See also <A HREF="wx100.htm#wxfont">wxFont</A>.<P>
<HR>
<A NAME="wxdcsetlogicalfunction"></A>
<H3>wxDC::SetLogicalFunction</H3>
<P>
<B>void</B> <B>SetLogicalFunction</B>(<B>int</B><I> function</I>)<P>
Sets the current logical function for the device context. This determines how
a source pixel (from a pen or brush colour, or source device context if
using <A HREF="wx65.htm#wxdcblit">wxDC::Blit</A>) combines with a destination pixel in the
current device context.<P>
The possible values
and their meaning in terms of source and destination pixel values are
as follows:<P>
<PRE>
wxAND src AND dst
wxAND_INVERT (NOT src) AND dst
wxAND_REVERSE src AND (NOT dst)
wxCLEAR 0
wxCOPY src
wxEQUIV (NOT src) XOR dst
wxINVERT NOT dst
wxNAND (NOT src) OR (NOT dst)
wxNOR (NOT src) AND (NOT dst)
wxNO_OP dst
wxOR src OR dst
wxOR_INVERT (NOT src) OR dst
wxOR_REVERSE src OR (NOT dst)
wxSET 1
wxSRC_INVERT NOT src
wxXOR src XOR dst
</PRE>
The default is wxCOPY, which simply draws with the current colour.
The others combine the current colour and the background using a
logical operation. wxXOR is commonly used for drawing rubber bands or
moving outlines, since drawing twice reverts to the original colour.<P>
<HR>
<A NAME="wxdcsetmapmode"></A>
<H3>wxDC::SetMapMode</H3>
<P>
<B>void</B> <B>SetMapMode</B>(<B>int</B><I> int</I>)<P>
The <I>mapping mode</I> of the device context defines the unit of
measurement used to convert logical units to device units. Note that
in X, text drawing isn't handled consistently with the mapping mode; a
font is always specified in point size. However, setting the <I>
user scale</I> (see <A HREF="wx65.htm#wxdcsetuserscale">wxDC::SetUserScale</A>) scales the text appropriately. In
Windows, scaleable TrueType fonts are always used; in X, results depend
on availability of fonts, but usually a reasonable match is found.<P>
Note that the coordinate origin should ideally be selectable, but for
now is always at the top left of the screen/printer.<P>
Drawing to a Windows printer device context under UNIX
uses the current mapping mode, but mapping mode is currently ignored for
PostScript output.<P>
The mapping mode can be one of the following:<P>
<TABLE>
<TR><TD VALIGN=TOP>
wxMM_TWIPS
</TD>
<TD VALIGN=TOP>
Each logical unit is 1/20 of a point, or 1/1440 of
an inch.
</TD></TR>
<TR><TD VALIGN=TOP>
wxMM_POINTS
</TD>
<TD VALIGN=TOP>
Each logical unit is a point, or 1/72 of an inch.
</TD></TR>
<TR><TD VALIGN=TOP>
wxMM_METRIC
</TD>
<TD VALIGN=TOP>
Each logical unit is 1 mm.
</TD></TR>
<TR><TD VALIGN=TOP>
wxMM_LOMETRIC
</TD>
<TD VALIGN=TOP>
Each logical unit is 1/10 of a mm.
</TD></TR>
<TR><TD VALIGN=TOP>
wxMM_TEXT
</TD>
<TD VALIGN=TOP>
Each logical unit is 1 pixel.
</TD></TR>
</TABLE>
<P>
<HR>
<A NAME="wxsetoptimization"></A>
<H3>wxDC::SetOptimization</H3>
<P>
<B>void</B> <B>SetOptimization</B>(<B>bool </B><I>optimize</I>)<P>
If <I>optimize</I> is TRUE (the default), this function sets optimization mode on.
This currently means that under X, the device context will not try to set a pen or brush
property if it is known to be set already. This approach can fall down
if non-wxWindows code is using the same device context or window, for example
when the window is a panel on which the windowing system draws panel items.
The wxWindows device context 'memory' will now be out of step with reality.<P>
Setting optimization off, drawing, then setting it back on again, is a trick
that must occasionally be employed.<P>
<HR>
<A NAME="wxdcsetpen"></A>
<H3>wxDC::SetPen</H3>
<P>
<B>void</B> <B>SetPen</B>(<B>const wxPen& </B><I>pen</I>)<P>
Sets the current pen for the DC.<P>
If the argument is wxNullPen, the current pen is selected out of the device
context, and the original pen restored.<P>
<HR>
<A NAME="wxdcsettextbackground"></A>
<H3>wxDC::SetTextBackground</H3>
<P>
<B>void</B> <B>SetTextBackground</B>(<B>const wxColour& </B><I>colour</I>)<P>
Sets the current text background colour for the DC.<P>
<HR>
<A NAME="wxdcsettextforeground"></A>
<H3>wxDC::SetTextForeground</H3>
<P>
<B>void</B> <B>SetTextForeground</B>(<B>const wxColour& </B><I>colour</I>)<P>
Sets the current text foreground colour for the DC.<P>
<HR>
<A NAME="wxdcsetuserscale"></A>
<H3>wxDC::SetUserScale</H3>
<P>
<B>void</B> <B>SetUserScale</B>(<B>double</B><I> xScale</I>, <B>double</B><I> yScale</I>)<P>
Sets the user scaling factor, useful for applications which require
'zooming'.<P>
<HR>
<A NAME="wxdcstartdoc"></A>
<H3>wxDC::StartDoc</H3>
<P>
<B>bool</B> <B>StartDoc</B>(<B>const wxString& </B><I>message</I>)<P>
Starts a document (only relevant when outputting to a printer).
Message is a message to show whilst printing.<P>
<HR>
<A NAME="wxdcstartpage"></A>
<H3>wxDC::StartPage</H3>
<P>
<B>bool</B> <B>StartPage</B>()<P>
Starts a document page (only relevant when outputting to a printer).<P>
</BODY></HTML>
|