]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/msw/dc.cpp
docs corrections and docs for Chris' wxImage::SaveFile(filename_only) patch
[wxWidgets.git] / src / msw / dc.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: dc.cpp
3// Purpose: wxDC class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ===========================================================================
13// declarations
14// ===========================================================================
15
16// ---------------------------------------------------------------------------
17// headers
18// ---------------------------------------------------------------------------
19
20#ifdef __GNUG__
21 #pragma implementation "dc.h"
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
28 #pragma hdrstop
29#endif
30
31#ifndef WX_PRECOMP
32 #include "wx/window.h"
33 #include "wx/dc.h"
34 #include "wx/utils.h"
35 #include "wx/dialog.h"
36 #include "wx/app.h"
37 #include "wx/bitmap.h"
38 #include "wx/dcmemory.h"
39 #include "wx/log.h"
40 #include "wx/icon.h"
41#endif
42
43#include "wx/sysopt.h"
44#include "wx/dcprint.h"
45#include "wx/module.h"
46
47#include <string.h>
48#include <math.h>
49
50#include "wx/msw/private.h" // needs to be before #include <commdlg.h>
51
52#if wxUSE_COMMON_DIALOGS && !defined(__WXMICROWIN__)
53 #include <commdlg.h>
54#endif
55
56#ifndef __WIN32__
57 #include <print.h>
58#endif
59
60IMPLEMENT_ABSTRACT_CLASS(wxDC, wxDCBase)
61
62// ---------------------------------------------------------------------------
63// constants
64// ---------------------------------------------------------------------------
65
66static const int VIEWPORT_EXTENT = 1000;
67
68static const int MM_POINTS = 9;
69static const int MM_METRIC = 10;
70
71// usually this is defined in math.h
72#ifndef M_PI
73 static const double M_PI = 3.14159265358979323846;
74#endif // M_PI
75
76// ROPs which don't have standard names (see "Ternary Raster Operations" in the
77// MSDN docs for how this and other numbers in wxDC::Blit() are obtained)
78#define DSTCOPY 0x00AA0029 // a.k.a. NOP operation
79
80// ----------------------------------------------------------------------------
81// macros for logical <-> device coords conversion
82// ----------------------------------------------------------------------------
83
84/*
85 We currently let Windows do all the translations itself so these macros are
86 not really needed (any more) but keep them to enhance readability of the
87 code by allowing to see where are the logical and where are the device
88 coordinates used.
89 */
90
91// logical to device
92#define XLOG2DEV(x) (x)
93#define YLOG2DEV(y) (y)
94
95// device to logical
96#define XDEV2LOG(x) (x)
97#define YDEV2LOG(y) (y)
98
99// ---------------------------------------------------------------------------
100// private functions
101// ---------------------------------------------------------------------------
102
103// convert degrees to radians
104static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; }
105
106// ----------------------------------------------------------------------------
107// private classes
108// ----------------------------------------------------------------------------
109
110// instead of duplicating the same code which sets and then restores text
111// colours in each wxDC method working with wxSTIPPLE_MASK_OPAQUE brushes,
112// encapsulate this in a small helper class
113
114// wxColourChanger: changes the text colours in the ctor if required and
115// restores them in the dtor
116class wxColourChanger
117{
118public:
119 wxColourChanger(wxDC& dc);
120 ~wxColourChanger();
121
122private:
123 wxDC& m_dc;
124
125 COLORREF m_colFgOld, m_colBgOld;
126
127 bool m_changed;
128};
129
130// ===========================================================================
131// implementation
132// ===========================================================================
133
134// ----------------------------------------------------------------------------
135// wxColourChanger
136// ----------------------------------------------------------------------------
137
138wxColourChanger::wxColourChanger(wxDC& dc) : m_dc(dc)
139{
140 const wxBrush& brush = dc.GetBrush();
141 if ( brush.Ok() && brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE )
142 {
143 HDC hdc = GetHdcOf(dc);
144 m_colFgOld = ::GetTextColor(hdc);
145 m_colBgOld = ::GetBkColor(hdc);
146
147 // note that Windows convention is opposite to wxWindows one, this is
148 // why text colour becomes the background one and vice versa
149 const wxColour& colFg = dc.GetTextForeground();
150 if ( colFg.Ok() )
151 {
152 ::SetBkColor(hdc, colFg.GetPixel());
153 }
154
155 const wxColour& colBg = dc.GetTextBackground();
156 if ( colBg.Ok() )
157 {
158 ::SetTextColor(hdc, colBg.GetPixel());
159 }
160
161 SetBkMode(hdc,
162 dc.GetBackgroundMode() == wxTRANSPARENT ? TRANSPARENT
163 : OPAQUE);
164
165 // flag which telsl us to undo changes in the dtor
166 m_changed = TRUE;
167 }
168 else
169 {
170 // nothing done, nothing to undo
171 m_changed = FALSE;
172 }
173}
174
175wxColourChanger::~wxColourChanger()
176{
177 if ( m_changed )
178 {
179 // restore the colours we changed
180 HDC hdc = GetHdcOf(m_dc);
181
182 ::SetBkMode(hdc, TRANSPARENT);
183 ::SetTextColor(hdc, m_colFgOld);
184 ::SetBkColor(hdc, m_colBgOld);
185 }
186}
187
188// ---------------------------------------------------------------------------
189// wxDC
190// ---------------------------------------------------------------------------
191
192// Default constructor
193wxDC::wxDC()
194{
195 m_canvas = NULL;
196
197 m_oldBitmap = 0;
198 m_oldPen = 0;
199 m_oldBrush = 0;
200 m_oldFont = 0;
201#if wxUSE_PALETTE
202 m_oldPalette = 0;
203#endif // wxUSE_PALETTE
204
205 m_bOwnsDC = FALSE;
206 m_hDC = 0;
207}
208
209wxDC::~wxDC()
210{
211 if ( m_hDC != 0 )
212 {
213 SelectOldObjects(m_hDC);
214
215 // if we own the HDC, we delete it, otherwise we just release it
216
217 if ( m_bOwnsDC )
218 {
219 ::DeleteDC(GetHdc());
220 }
221 else // we don't own our HDC
222 {
223 if (m_canvas)
224 {
225 ::ReleaseDC(GetHwndOf(m_canvas), GetHdc());
226 }
227 else
228 {
229 // Must have been a wxScreenDC
230 ::ReleaseDC((HWND) NULL, GetHdc());
231 }
232 }
233 }
234}
235
236// This will select current objects out of the DC,
237// which is what you have to do before deleting the
238// DC.
239void wxDC::SelectOldObjects(WXHDC dc)
240{
241 if (dc)
242 {
243 if (m_oldBitmap)
244 {
245 ::SelectObject((HDC) dc, (HBITMAP) m_oldBitmap);
246 if (m_selectedBitmap.Ok())
247 {
248 m_selectedBitmap.SetSelectedInto(NULL);
249 }
250 }
251 m_oldBitmap = 0;
252 if (m_oldPen)
253 {
254 ::SelectObject((HDC) dc, (HPEN) m_oldPen);
255 }
256 m_oldPen = 0;
257 if (m_oldBrush)
258 {
259 ::SelectObject((HDC) dc, (HBRUSH) m_oldBrush);
260 }
261 m_oldBrush = 0;
262 if (m_oldFont)
263 {
264 ::SelectObject((HDC) dc, (HFONT) m_oldFont);
265 }
266 m_oldFont = 0;
267
268#if wxUSE_PALETTE
269 if (m_oldPalette)
270 {
271 ::SelectPalette((HDC) dc, (HPALETTE) m_oldPalette, FALSE);
272 }
273 m_oldPalette = 0;
274#endif // wxUSE_PALETTE
275 }
276
277 m_brush = wxNullBrush;
278 m_pen = wxNullPen;
279#if wxUSE_PALETTE
280 m_palette = wxNullPalette;
281#endif // wxUSE_PALETTE
282 m_font = wxNullFont;
283 m_backgroundBrush = wxNullBrush;
284 m_selectedBitmap = wxNullBitmap;
285}
286
287// ---------------------------------------------------------------------------
288// clipping
289// ---------------------------------------------------------------------------
290
291void wxDC::UpdateClipBox()
292{
293#ifdef __WXMICROWIN__
294 if (!GetHDC()) return;
295#endif
296
297 RECT rect;
298 ::GetClipBox(GetHdc(), &rect);
299
300 m_clipX1 = (wxCoord) XDEV2LOG(rect.left);
301 m_clipY1 = (wxCoord) YDEV2LOG(rect.top);
302 m_clipX2 = (wxCoord) XDEV2LOG(rect.right);
303 m_clipY2 = (wxCoord) YDEV2LOG(rect.bottom);
304}
305
306// common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion()
307void wxDC::SetClippingHrgn(WXHRGN hrgn)
308{
309 wxCHECK_RET( hrgn, wxT("invalid clipping region") );
310
311#ifdef __WXMICROWIN__
312 if (!GetHdc()) return;
313#endif // __WXMICROWIN__
314
315 // note that we combine the new clipping region with the existing one: this
316 // is compatible with what the other ports do and is the documented
317 // behaviour now (starting with 2.3.3)
318#ifdef __WIN16__
319 RECT rectClip;
320 if ( !::GetClipBox(GetHdc(), &rectClip) )
321 return;
322
323 HRGN hrgnDest = ::CreateRectRgn(0, 0, 0, 0);
324 HRGN hrgnClipOld = ::CreateRectRgn(rectClip.left, rectClip.top,
325 rectClip.right, rectClip.bottom);
326
327 if ( ::CombineRgn(hrgnDest, hrgnClipOld, (HRGN)hrgn, RGN_AND) != ERROR )
328 {
329 ::SelectClipRgn(GetHdc(), hrgnDest);
330 }
331
332 ::DeleteObject(hrgnClipOld);
333 ::DeleteObject(hrgnDest);
334#else // Win32
335 if ( ::ExtSelectClipRgn(GetHdc(), (HRGN)hrgn, RGN_AND) == ERROR )
336 {
337 wxLogLastError(_T("ExtSelectClipRgn"));
338
339 return;
340 }
341#endif // Win16/32
342
343 m_clipping = TRUE;
344
345 UpdateClipBox();
346}
347
348void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
349{
350 // the region coords are always the device ones, so do the translation
351 // manually
352 //
353 // FIXME: possible +/-1 error here, to check!
354 HRGN hrgn = ::CreateRectRgn(LogicalToDeviceX(x),
355 LogicalToDeviceY(y),
356 LogicalToDeviceX(x + w),
357 LogicalToDeviceY(y + h));
358 if ( !hrgn )
359 {
360 wxLogLastError(_T("CreateRectRgn"));
361 }
362 else
363 {
364 SetClippingHrgn((WXHRGN)hrgn);
365
366 ::DeleteObject(hrgn);
367 }
368}
369
370void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
371{
372 SetClippingHrgn(region.GetHRGN());
373}
374
375void wxDC::DestroyClippingRegion()
376{
377#ifdef __WXMICROWIN__
378 if (!GetHDC()) return;
379#endif
380
381 if (m_clipping && m_hDC)
382 {
383 // TODO: this should restore the previous clipping region,
384 // so that OnPaint processing works correctly, and the update
385 // clipping region doesn't get destroyed after the first
386 // DestroyClippingRegion.
387 HRGN rgn = CreateRectRgn(0, 0, 32000, 32000);
388 ::SelectClipRgn(GetHdc(), rgn);
389 ::DeleteObject(rgn);
390 }
391
392 m_clipping = FALSE;
393}
394
395// ---------------------------------------------------------------------------
396// query capabilities
397// ---------------------------------------------------------------------------
398
399bool wxDC::CanDrawBitmap() const
400{
401 return TRUE;
402}
403
404bool wxDC::CanGetTextExtent() const
405{
406#ifdef __WXMICROWIN__
407 // TODO Extend MicroWindows' GetDeviceCaps function
408 return TRUE;
409#else
410 // What sort of display is it?
411 int technology = ::GetDeviceCaps(GetHdc(), TECHNOLOGY);
412
413 return (technology == DT_RASDISPLAY) || (technology == DT_RASPRINTER);
414#endif
415}
416
417int wxDC::GetDepth() const
418{
419#ifdef __WXMICROWIN__
420 if (!GetHDC()) return 16;
421#endif
422
423 return (int)::GetDeviceCaps(GetHdc(), BITSPIXEL);
424}
425
426// ---------------------------------------------------------------------------
427// drawing
428// ---------------------------------------------------------------------------
429
430void wxDC::Clear()
431{
432#ifdef __WXMICROWIN__
433 if (!GetHDC()) return;
434#endif
435
436 RECT rect;
437 if ( m_canvas )
438 {
439 GetClientRect((HWND) m_canvas->GetHWND(), &rect);
440 }
441 else
442 {
443 // No, I think we should simply ignore this if printing on e.g.
444 // a printer DC.
445 // wxCHECK_RET( m_selectedBitmap.Ok(), wxT("this DC can't be cleared") );
446 if (!m_selectedBitmap.Ok())
447 return;
448
449 rect.left = 0; rect.top = 0;
450 rect.right = m_selectedBitmap.GetWidth();
451 rect.bottom = m_selectedBitmap.GetHeight();
452 }
453
454 (void) ::SetMapMode(GetHdc(), MM_TEXT);
455
456 DWORD colour = ::GetBkColor(GetHdc());
457 HBRUSH brush = ::CreateSolidBrush(colour);
458 ::FillRect(GetHdc(), &rect, brush);
459 ::DeleteObject(brush);
460
461 int width = DeviceToLogicalXRel(VIEWPORT_EXTENT)*m_signX,
462 height = DeviceToLogicalYRel(VIEWPORT_EXTENT)*m_signY;
463
464 ::SetMapMode(GetHdc(), MM_ANISOTROPIC);
465 ::SetViewportExtEx(GetHdc(), VIEWPORT_EXTENT, VIEWPORT_EXTENT, NULL);
466 ::SetWindowExtEx(GetHdc(), width, height, NULL);
467 ::SetViewportOrgEx(GetHdc(), (int)m_deviceOriginX, (int)m_deviceOriginY, NULL);
468 ::SetWindowOrgEx(GetHdc(), (int)m_logicalOriginX, (int)m_logicalOriginY, NULL);
469}
470
471void wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
472{
473#ifdef __WXMICROWIN__
474 if (!GetHDC()) return;
475#endif
476
477 if ( !::ExtFloodFill(GetHdc(), XLOG2DEV(x), YLOG2DEV(y),
478 col.GetPixel(),
479 style == wxFLOOD_SURFACE ? FLOODFILLSURFACE
480 : FLOODFILLBORDER) )
481 {
482 // quoting from the MSDN docs:
483 //
484 // Following are some of the reasons this function might fail:
485 //
486 // * The filling could not be completed.
487 // * The specified point has the boundary color specified by the
488 // crColor parameter (if FLOODFILLBORDER was requested).
489 // * The specified point does not have the color specified by
490 // crColor (if FLOODFILLSURFACE was requested)
491 // * The point is outside the clipping region that is, it is not
492 // visible on the device.
493 //
494 wxLogLastError(wxT("ExtFloodFill"));
495 }
496
497 CalcBoundingBox(x, y);
498}
499
500bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
501{
502#ifdef __WXMICROWIN__
503 if (!GetHDC()) return FALSE;
504#endif
505
506 wxCHECK_MSG( col, FALSE, _T("NULL colour parameter in wxDC::GetPixel") );
507
508 // get the color of the pixel
509 COLORREF pixelcolor = ::GetPixel(GetHdc(), XLOG2DEV(x), YLOG2DEV(y));
510
511 wxRGBToColour(*col, pixelcolor);
512
513 return TRUE;
514}
515
516void wxDC::DoCrossHair(wxCoord x, wxCoord y)
517{
518#ifdef __WXMICROWIN__
519 if (!GetHDC()) return;
520#endif
521
522 wxCoord x1 = x-VIEWPORT_EXTENT;
523 wxCoord y1 = y-VIEWPORT_EXTENT;
524 wxCoord x2 = x+VIEWPORT_EXTENT;
525 wxCoord y2 = y+VIEWPORT_EXTENT;
526
527 (void)MoveToEx(GetHdc(), XLOG2DEV(x1), YLOG2DEV(y), NULL);
528 (void)LineTo(GetHdc(), XLOG2DEV(x2), YLOG2DEV(y));
529
530 (void)MoveToEx(GetHdc(), XLOG2DEV(x), YLOG2DEV(y1), NULL);
531 (void)LineTo(GetHdc(), XLOG2DEV(x), YLOG2DEV(y2));
532
533 CalcBoundingBox(x1, y1);
534 CalcBoundingBox(x2, y2);
535}
536
537void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
538{
539#ifdef __WXMICROWIN__
540 if (!GetHDC()) return;
541#endif
542
543 (void)MoveToEx(GetHdc(), XLOG2DEV(x1), YLOG2DEV(y1), NULL);
544 (void)LineTo(GetHdc(), XLOG2DEV(x2), YLOG2DEV(y2));
545
546 CalcBoundingBox(x1, y1);
547 CalcBoundingBox(x2, y2);
548}
549
550// Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
551// and ending at (x2, y2)
552void wxDC::DoDrawArc(wxCoord x1, wxCoord y1,
553 wxCoord x2, wxCoord y2,
554 wxCoord xc, wxCoord yc)
555{
556#ifdef __WXMICROWIN__
557 if (!GetHDC()) return;
558#endif
559
560 wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
561
562 double dx = xc - x1;
563 double dy = yc - y1;
564 double radius = (double)sqrt(dx*dx+dy*dy);
565 wxCoord r = (wxCoord)radius;
566
567 // treat the special case of full circle separately
568 if ( x1 == x2 && y1 == y2 )
569 {
570 DrawEllipse(xc - r, yc - r, 2*r, 2*r);
571 return;
572 }
573
574 wxCoord xx1 = XLOG2DEV(x1);
575 wxCoord yy1 = YLOG2DEV(y1);
576 wxCoord xx2 = XLOG2DEV(x2);
577 wxCoord yy2 = YLOG2DEV(y2);
578 wxCoord xxc = XLOG2DEV(xc);
579 wxCoord yyc = YLOG2DEV(yc);
580 wxCoord ray = (wxCoord) sqrt(double((xxc-xx1)*(xxc-xx1)+(yyc-yy1)*(yyc-yy1)));
581
582 wxCoord xxx1 = (wxCoord) (xxc-ray);
583 wxCoord yyy1 = (wxCoord) (yyc-ray);
584 wxCoord xxx2 = (wxCoord) (xxc+ray);
585 wxCoord yyy2 = (wxCoord) (yyc+ray);
586
587 if ( m_brush.Ok() && m_brush.GetStyle() != wxTRANSPARENT )
588 {
589 // Have to add 1 to bottom-right corner of rectangle
590 // to make semi-circles look right (crooked line otherwise).
591 // Unfortunately this is not a reliable method, depends
592 // on the size of shape.
593 // TODO: figure out why this happens!
594 Pie(GetHdc(),xxx1,yyy1,xxx2+1,yyy2+1, xx1,yy1,xx2,yy2);
595 }
596 else
597 {
598 Arc(GetHdc(),xxx1,yyy1,xxx2,yyy2, xx1,yy1,xx2,yy2);
599 }
600
601 CalcBoundingBox(xc - r, yc - r);
602 CalcBoundingBox(xc + r, yc + r);
603}
604
605void wxDC::DoDrawCheckMark(wxCoord x1, wxCoord y1,
606 wxCoord width, wxCoord height)
607{
608#ifdef __WXMICROWIN__
609 if (!GetHDC()) return;
610#endif
611
612 wxCoord x2 = x1 + width,
613 y2 = y1 + height;
614
615#if defined(__WIN32__) && !defined(__SC__) && !defined(__WXMICROWIN__)
616 RECT rect;
617 rect.left = x1;
618 rect.top = y1;
619 rect.right = x2;
620 rect.bottom = y2;
621
622 DrawFrameControl(GetHdc(), &rect, DFC_MENU, DFCS_MENUCHECK);
623#else // Win16
624 // In WIN16, draw a cross
625 HPEN blackPen = ::CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
626 HPEN whiteBrush = (HPEN)::GetStockObject(WHITE_BRUSH);
627 HPEN hPenOld = (HPEN)::SelectObject(GetHdc(), blackPen);
628 HPEN hBrushOld = (HPEN)::SelectObject(GetHdc(), whiteBrush);
629 ::SetROP2(GetHdc(), R2_COPYPEN);
630 Rectangle(GetHdc(), x1, y1, x2, y2);
631 MoveToEx(GetHdc(), x1, y1, NULL);
632 LineTo(GetHdc(), x2, y2);
633 MoveToEx(GetHdc(), x2, y1, NULL);
634 LineTo(GetHdc(), x1, y2);
635 ::SelectObject(GetHdc(), hPenOld);
636 ::SelectObject(GetHdc(), hBrushOld);
637 ::DeleteObject(blackPen);
638#endif // Win32/16
639
640 CalcBoundingBox(x1, y1);
641 CalcBoundingBox(x2, y2);
642}
643
644void wxDC::DoDrawPoint(wxCoord x, wxCoord y)
645{
646#ifdef __WXMICROWIN__
647 if (!GetHDC()) return;
648#endif
649
650 COLORREF color = 0x00ffffff;
651 if (m_pen.Ok())
652 {
653 color = m_pen.GetColour().GetPixel();
654 }
655
656 SetPixel(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), color);
657
658 CalcBoundingBox(x, y);
659}
660
661void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int fillStyle)
662{
663#ifdef __WXMICROWIN__
664 if (!GetHDC()) return;
665#endif
666
667 wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
668
669 // Do things less efficiently if we have offsets
670 if (xoffset != 0 || yoffset != 0)
671 {
672 POINT *cpoints = new POINT[n];
673 int i;
674 for (i = 0; i < n; i++)
675 {
676 cpoints[i].x = (int)(points[i].x + xoffset);
677 cpoints[i].y = (int)(points[i].y + yoffset);
678
679 CalcBoundingBox(cpoints[i].x, cpoints[i].y);
680 }
681 int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING);
682 (void)Polygon(GetHdc(), cpoints, n);
683 SetPolyFillMode(GetHdc(),prev);
684 delete[] cpoints;
685 }
686 else
687 {
688 int i;
689 for (i = 0; i < n; i++)
690 CalcBoundingBox(points[i].x, points[i].y);
691
692 int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING);
693 (void)Polygon(GetHdc(), (POINT*) points, n);
694 SetPolyFillMode(GetHdc(),prev);
695 }
696}
697
698void wxDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
699{
700#ifdef __WXMICROWIN__
701 if (!GetHDC()) return;
702#endif
703
704 // Do things less efficiently if we have offsets
705 if (xoffset != 0 || yoffset != 0)
706 {
707 POINT *cpoints = new POINT[n];
708 int i;
709 for (i = 0; i < n; i++)
710 {
711 cpoints[i].x = (int)(points[i].x + xoffset);
712 cpoints[i].y = (int)(points[i].y + yoffset);
713
714 CalcBoundingBox(cpoints[i].x, cpoints[i].y);
715 }
716 (void)Polyline(GetHdc(), cpoints, n);
717 delete[] cpoints;
718 }
719 else
720 {
721 int i;
722 for (i = 0; i < n; i++)
723 CalcBoundingBox(points[i].x, points[i].y);
724
725 (void)Polyline(GetHdc(), (POINT*) points, n);
726 }
727}
728
729void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
730{
731#ifdef __WXMICROWIN__
732 if (!GetHDC()) return;
733#endif
734
735 wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
736
737 wxCoord x2 = x + width;
738 wxCoord y2 = y + height;
739
740 if ((m_logicalFunction == wxCOPY) && (m_pen.GetStyle() == wxTRANSPARENT))
741 {
742 RECT rect;
743 rect.left = XLOG2DEV(x);
744 rect.top = YLOG2DEV(y);
745 rect.right = XLOG2DEV(x2);
746 rect.bottom = YLOG2DEV(y2);
747 (void)FillRect(GetHdc(), &rect, (HBRUSH)m_brush.GetResourceHandle() );
748 }
749 else
750 {
751 // Windows draws the filled rectangles without outline (i.e. drawn with a
752 // transparent pen) one pixel smaller in both directions and we want them
753 // to have the same size regardless of which pen is used - adjust
754
755