]> git.saurik.com Git - wxWidgets.git/blame - src/msw/dc.cpp
added automatic growing of in-place wxTextCtrls for generic wxListCtrl and wxTreeCtrl
[wxWidgets.git] / src / msw / dc.cpp
CommitLineData
2bda0e17
KB
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
fd3f686c 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
a23fd0e1
VZ
12// ===========================================================================
13// declarations
14// ===========================================================================
15
16// ---------------------------------------------------------------------------
17// headers
18// ---------------------------------------------------------------------------
19
2bda0e17 20#ifdef __GNUG__
a23fd0e1 21 #pragma implementation "dc.h"
2bda0e17
KB
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
a23fd0e1 28 #pragma hdrstop
2bda0e17
KB
29#endif
30
31#ifndef WX_PRECOMP
4286a5b5 32 #include "wx/window.h"
a23fd0e1
VZ
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"
0c589ad0 39 #include "wx/log.h"
4286a5b5 40 #include "wx/icon.h"
2bda0e17
KB
41#endif
42
43#include "wx/dcprint.h"
2bda0e17
KB
44
45#include <string.h>
46#include <math.h>
2bda0e17 47
a58a12e9
VZ
48#include "wx/msw/private.h" // needs to be before #include <commdlg.h>
49
47d67540 50#if wxUSE_COMMON_DIALOGS
a23fd0e1 51 #include <commdlg.h>
2bda0e17
KB
52#endif
53
54#ifndef __WIN32__
a23fd0e1 55 #include <print.h>
2bda0e17
KB
56#endif
57
a58a12e9 58IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
2bda0e17 59
a23fd0e1
VZ
60// ---------------------------------------------------------------------------
61// constants
62// ---------------------------------------------------------------------------
63
42e69d6b
VZ
64static const int VIEWPORT_EXTENT = 1000;
65
66static const int MM_POINTS = 9;
67static const int MM_METRIC = 10;
a23fd0e1 68
4314ec48
VZ
69// usually this is defined in math.h
70#ifndef M_PI
71 static const double M_PI = 3.14159265358979323846;
72#endif // M_PI
73
4aff28fc
VZ
74// ROPs which don't have standard names (see "Ternary Raster Operations" in the
75// MSDN docs for how this and other numbers in wxDC::Blit() are obtained)
76#define DSTCOPY 0x00AA0029 // a.k.a. NOP operation
77
4314ec48
VZ
78// ---------------------------------------------------------------------------
79// private functions
80// ---------------------------------------------------------------------------
81
82// convert degrees to radians
83static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; }
84
f6bcfd97
BP
85// ----------------------------------------------------------------------------
86// private classes
87// ----------------------------------------------------------------------------
88
89// instead of duplicating the same code which sets and then restores text
90// colours in each wxDC method working with wxSTIPPLE_MASK_OPAQUE brushes,
91// encapsulate this in a small helper class
92
93// wxColourChanger: changes the text colours in the ctor if required and
94// restores them in the dtor
95class wxColourChanger
96{
97public:
98 wxColourChanger(wxDC& dc);
99 ~wxColourChanger();
100
101private:
102 wxDC& m_dc;
103
104 COLORREF m_colFgOld, m_colBgOld;
105
106 bool m_changed;
107};
108
a23fd0e1
VZ
109// ===========================================================================
110// implementation
111// ===========================================================================
112
f6bcfd97
BP
113// ----------------------------------------------------------------------------
114// wxColourChanger
115// ----------------------------------------------------------------------------
116
117wxColourChanger::wxColourChanger(wxDC& dc) : m_dc(dc)
118{
119 if ( dc.GetBrush().GetStyle() == wxSTIPPLE_MASK_OPAQUE )
120 {
121 HDC hdc = GetHdcOf(dc);
122 m_colFgOld = ::GetTextColor(hdc);
123 m_colBgOld = ::GetBkColor(hdc);
124
125 // note that Windows convention is opposite to wxWindows one, this is
126 // why text colour becomes the background one and vice versa
127 const wxColour& colFg = dc.GetTextForeground();
128 if ( colFg.Ok() )
129 {
130 ::SetBkColor(hdc, colFg.GetPixel());
131 }
132
133 const wxColour& colBg = dc.GetTextBackground();
134 if ( colBg.Ok() )
135 {
136 ::SetTextColor(hdc, colBg.GetPixel());
137 }
138
139 SetBkMode(hdc,
140 dc.GetBackgroundMode() == wxTRANSPARENT ? TRANSPARENT
141 : OPAQUE);
142
143 // flag which telsl us to undo changes in the dtor
144 m_changed = TRUE;
145 }
146 else
147 {
148 // nothing done, nothing to undo
149 m_changed = FALSE;
150 }
151}
152
153wxColourChanger::~wxColourChanger()
154{
155 if ( m_changed )
156 {
157 // restore the colours we changed
158 HDC hdc = GetHdcOf(m_dc);
159
160 ::SetBkMode(hdc, TRANSPARENT);
161 ::SetTextColor(hdc, m_colFgOld);
162 ::SetBkColor(hdc, m_colBgOld);
163 }
164}
165
a23fd0e1
VZ
166// ---------------------------------------------------------------------------
167// wxDC
168// ---------------------------------------------------------------------------
2bda0e17
KB
169
170// Default constructor
a23fd0e1 171wxDC::wxDC()
2bda0e17 172{
7bcb11d3 173 m_canvas = NULL;
a23fd0e1 174
7bcb11d3
JS
175 m_oldBitmap = 0;
176 m_oldPen = 0;
177 m_oldBrush = 0;
178 m_oldFont = 0;
179 m_oldPalette = 0;
a23fd0e1 180
7bcb11d3
JS
181 m_bOwnsDC = FALSE;
182 m_hDC = 0;
a23fd0e1 183
7bcb11d3
JS
184 m_windowExtX = VIEWPORT_EXTENT;
185 m_windowExtY = VIEWPORT_EXTENT;
a23fd0e1 186
7bcb11d3 187 m_hDCCount = 0;
2bda0e17
KB
188}
189
190
a23fd0e1 191wxDC::~wxDC()
2bda0e17 192{
7bcb11d3
JS
193 if ( m_hDC != 0 ) {
194 SelectOldObjects(m_hDC);
195 if ( m_bOwnsDC ) {
196 if ( m_canvas == NULL )
a23fd0e1 197 ::DeleteDC(GetHdc());
7bcb11d3 198 else
a23fd0e1 199 ::ReleaseDC((HWND)m_canvas->GetHWND(), GetHdc());
7bcb11d3 200 }
2bda0e17 201 }
a23fd0e1 202
2bda0e17
KB
203}
204
205// This will select current objects out of the DC,
206// which is what you have to do before deleting the
207// DC.
208void wxDC::SelectOldObjects(WXHDC dc)
209{
7bcb11d3 210 if (dc)
2bda0e17 211 {
7bcb11d3
JS
212 if (m_oldBitmap)
213 {
214 ::SelectObject((HDC) dc, (HBITMAP) m_oldBitmap);
215 if (m_selectedBitmap.Ok())
216 {
217 m_selectedBitmap.SetSelectedInto(NULL);
218 }
219 }
a23fd0e1 220 m_oldBitmap = 0;
7bcb11d3
JS
221 if (m_oldPen)
222 {
223 ::SelectObject((HDC) dc, (HPEN) m_oldPen);
224 }
a23fd0e1 225 m_oldPen = 0;
7bcb11d3
JS
226 if (m_oldBrush)
227 {
228 ::SelectObject((HDC) dc, (HBRUSH) m_oldBrush);
229 }
a23fd0e1 230 m_oldBrush = 0;
7bcb11d3
JS
231 if (m_oldFont)
232 {
233 ::SelectObject((HDC) dc, (HFONT) m_oldFont);
234 }
a23fd0e1 235 m_oldFont = 0;
7bcb11d3
JS
236 if (m_oldPalette)
237 {
238 ::SelectPalette((HDC) dc, (HPALETTE) m_oldPalette, TRUE);
239 }
a23fd0e1 240 m_oldPalette = 0;
2bda0e17 241 }
a23fd0e1
VZ
242
243 m_brush = wxNullBrush;
7bcb11d3
JS
244 m_pen = wxNullPen;
245 m_palette = wxNullPalette;
246 m_font = wxNullFont;
247 m_backgroundBrush = wxNullBrush;
248 m_selectedBitmap = wxNullBitmap;
2bda0e17
KB
249}
250
a23fd0e1
VZ
251// ---------------------------------------------------------------------------
252// clipping
253// ---------------------------------------------------------------------------
254
f547e9bb
RL
255#define DO_SET_CLIPPING_BOX() \
256{ \
257 RECT rect; \
258 \
259 GetClipBox(GetHdc(), &rect); \
260 \
261 m_clipX1 = (wxCoord) XDEV2LOG(rect.left); \
262 m_clipY1 = (wxCoord) YDEV2LOG(rect.top); \
263 m_clipX2 = (wxCoord) XDEV2LOG(rect.right); \
264 m_clipY2 = (wxCoord) YDEV2LOG(rect.bottom); \
265}
266
72cdf4c9 267void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch)
2bda0e17 268{
7bcb11d3 269 m_clipping = TRUE;
f547e9bb
RL
270 IntersectClipRect(GetHdc(), XLOG2DEV(cx), YLOG2DEV(cy),
271 XLOG2DEV(cx + cw), YLOG2DEV(cy + ch));
272 DO_SET_CLIPPING_BOX()
2bda0e17
KB
273}
274
a23fd0e1 275void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
a724d789 276{
223d09f6 277 wxCHECK_RET( region.GetHRGN(), wxT("invalid clipping region") );
a23fd0e1 278
7bcb11d3 279 m_clipping = TRUE;
a23fd0e1 280
1e6d9499 281#ifdef __WIN16__
a23fd0e1 282 SelectClipRgn(GetHdc(), (HRGN) region.GetHRGN());
1e6d9499 283#else
a23fd0e1 284 ExtSelectClipRgn(GetHdc(), (HRGN) region.GetHRGN(), RGN_AND);
1e6d9499 285#endif
a724d789 286
f547e9bb 287 DO_SET_CLIPPING_BOX()
2bda0e17
KB
288}
289
a23fd0e1 290void wxDC::DestroyClippingRegion()
2bda0e17 291{
7bcb11d3
JS
292 if (m_clipping && m_hDC)
293 {
294 // TODO: this should restore the previous clipping region,
295 // so that OnPaint processing works correctly, and the update clipping region
296 // doesn't get destroyed after the first DestroyClippingRegion.
297 HRGN rgn = CreateRectRgn(0, 0, 32000, 32000);
a23fd0e1 298 SelectClipRgn(GetHdc(), rgn);
7bcb11d3
JS
299 DeleteObject(rgn);
300 }
301 m_clipping = FALSE;
2bda0e17
KB
302}
303
a23fd0e1
VZ
304// ---------------------------------------------------------------------------
305// query capabilities
306// ---------------------------------------------------------------------------
307
308bool wxDC::CanDrawBitmap() const
2bda0e17 309{
7bcb11d3 310 return TRUE;
2bda0e17
KB
311}
312
a23fd0e1 313bool wxDC::CanGetTextExtent() const
2bda0e17 314{
7bcb11d3 315 // What sort of display is it?
a23fd0e1
VZ
316 int technology = ::GetDeviceCaps(GetHdc(), TECHNOLOGY);
317
318 return (technology == DT_RASDISPLAY) || (technology == DT_RASPRINTER);
2bda0e17
KB
319}
320
a23fd0e1 321int wxDC::GetDepth() const
2bda0e17 322{
a23fd0e1 323 return (int)::GetDeviceCaps(GetHdc(), BITSPIXEL);
2bda0e17
KB
324}
325
a23fd0e1
VZ
326// ---------------------------------------------------------------------------
327// drawing
328// ---------------------------------------------------------------------------
329
330void wxDC::Clear()
2bda0e17 331{
7bcb11d3 332 RECT rect;
2506aab6
VZ
333 if ( m_canvas )
334 {
7bcb11d3 335 GetClientRect((HWND) m_canvas->GetHWND(), &rect);
2506aab6
VZ
336 }
337 else
7bcb11d3 338 {
eaeb6a3c
JS
339 // No, I think we should simply ignore this if printing on e.g.
340 // a printer DC.
341 // wxCHECK_RET( m_selectedBitmap.Ok(), wxT("this DC can't be cleared") );
342 if (!m_selectedBitmap.Ok())
343 return;
2506aab6 344
7bcb11d3
JS
345 rect.left = 0; rect.top = 0;
346 rect.right = m_selectedBitmap.GetWidth();
347 rect.bottom = m_selectedBitmap.GetHeight();
348 }
2506aab6 349
a23fd0e1
VZ
350 (void) ::SetMapMode(GetHdc(), MM_TEXT);
351
352 DWORD colour = GetBkColor(GetHdc());
7bcb11d3 353 HBRUSH brush = CreateSolidBrush(colour);
a23fd0e1 354 FillRect(GetHdc(), &rect, brush);
7bcb11d3 355 DeleteObject(brush);
a23fd0e1
VZ
356
357 ::SetMapMode(GetHdc(), MM_ANISOTROPIC);
358 ::SetViewportExtEx(GetHdc(), VIEWPORT_EXTENT, VIEWPORT_EXTENT, NULL);
359 ::SetWindowExtEx(GetHdc(), m_windowExtX, m_windowExtY, NULL);
360 ::SetViewportOrgEx(GetHdc(), (int)m_deviceOriginX, (int)m_deviceOriginY, NULL);
361 ::SetWindowOrgEx(GetHdc(), (int)m_logicalOriginX, (int)m_logicalOriginY, NULL);
362}
363
72cdf4c9 364void wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
a23fd0e1 365{
0bafad0c
VZ
366 if ( !::ExtFloodFill(GetHdc(), XLOG2DEV(x), YLOG2DEV(y),
367 col.GetPixel(),
368 style == wxFLOOD_SURFACE ? FLOODFILLSURFACE
369 : FLOODFILLBORDER) )
370 {
371 // quoting from the MSDN docs:
372 //
373 // Following are some of the reasons this function might fail:
374 //
375 // * The filling could not be completed.
376 // * The specified point has the boundary color specified by the
377 // crColor parameter (if FLOODFILLBORDER was requested).
378 // * The specified point does not have the color specified by
379 // crColor (if FLOODFILLSURFACE was requested)
380 // * The point is outside the clipping region that is, it is not
381 // visible on the device.
382 //
f6bcfd97 383 wxLogLastError(wxT("ExtFloodFill"));
0bafad0c 384 }
a23fd0e1 385
7bcb11d3 386 CalcBoundingBox(x, y);
2bda0e17
KB
387}
388
72cdf4c9 389bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
2bda0e17 390{
f6bcfd97
BP
391 wxCHECK_MSG( col, FALSE, _T("NULL colour parameter in wxDC::GetPixel") );
392
7bcb11d3 393 // get the color of the pixel
a23fd0e1 394 COLORREF pixelcolor = ::GetPixel(GetHdc(), XLOG2DEV(x), YLOG2DEV(y));
0bafad0c 395
f6bcfd97 396 wxRGBToColour(*col, pixelcolor);
dc1efb1d
JS
397
398 return TRUE;
2bda0e17
KB
399}
400
72cdf4c9 401void wxDC::DoCrossHair(wxCoord x, wxCoord y)
a23fd0e1 402{
72cdf4c9
VZ
403 wxCoord x1 = x-VIEWPORT_EXTENT;
404 wxCoord y1 = y-VIEWPORT_EXTENT;
405 wxCoord x2 = x+VIEWPORT_EXTENT;
406 wxCoord y2 = y+VIEWPORT_EXTENT;
a23fd0e1
VZ
407
408 (void)MoveToEx(GetHdc(), XLOG2DEV(x1), YLOG2DEV(y), NULL);
409 (void)LineTo(GetHdc(), XLOG2DEV(x2), YLOG2DEV(y));
410
411 (void)MoveToEx(GetHdc(), XLOG2DEV(x), YLOG2DEV(y1), NULL);
412 (void)LineTo(GetHdc(), XLOG2DEV(x), YLOG2DEV(y2));
413
7bcb11d3
JS
414 CalcBoundingBox(x1, y1);
415 CalcBoundingBox(x2, y2);
2bda0e17
KB
416}
417
72cdf4c9 418void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
2bda0e17 419{
a23fd0e1
VZ
420 (void)MoveToEx(GetHdc(), XLOG2DEV(x1), YLOG2DEV(y1), NULL);
421 (void)LineTo(GetHdc(), XLOG2DEV(x2), YLOG2DEV(y2));
422
058939fc
JS
423 // Normalization: Windows doesn't draw the last point of the line.
424 // But apparently neither does GTK+, so we take it out again.
425// (void)LineTo(GetHdc(), XLOG2DEV(x2) + 1, YLOG2DEV(y2));
a23fd0e1 426
7bcb11d3
JS
427 CalcBoundingBox(x1, y1);
428 CalcBoundingBox(x2, y2);
2bda0e17
KB
429}
430
f6bcfd97
BP
431// Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
432// and ending at (x2, y2)
433void wxDC::DoDrawArc(wxCoord x1, wxCoord y1,
434 wxCoord x2, wxCoord y2,
435 wxCoord xc, wxCoord yc)
2bda0e17 436{
f6bcfd97 437 wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
2d8a5cb1 438
f6bcfd97
BP
439 double dx = xc - x1;
440 double dy = yc - y1;
441 double radius = (double)sqrt(dx*dx+dy*dy);
442 wxCoord r = (wxCoord)radius;
2d8a5cb1 443
f6bcfd97
BP
444 // treat the special case of full circle separately
445 if ( x1 == x2 && y1 == y2 )
7bcb11d3 446 {
f6bcfd97 447 DrawEllipse(xc - r, yc - r, 2*r, 2*r);
a23fd0e1 448 return;
7bcb11d3 449 }
a23fd0e1 450
72cdf4c9
VZ
451 wxCoord xx1 = XLOG2DEV(x1);
452 wxCoord yy1 = YLOG2DEV(y1);
453 wxCoord xx2 = XLOG2DEV(x2);
454 wxCoord yy2 = YLOG2DEV(y2);
455 wxCoord xxc = XLOG2DEV(xc);
456 wxCoord yyc = YLOG2DEV(yc);
457 wxCoord ray = (wxCoord) sqrt(double((xxc-xx1)*(xxc-xx1)+(yyc-yy1)*(yyc-yy1)));
a23fd0e1 458
72cdf4c9
VZ
459 wxCoord xxx1 = (wxCoord) (xxc-ray);
460 wxCoord yyy1 = (wxCoord) (yyc-ray);
461 wxCoord xxx2 = (wxCoord) (xxc+ray);
462 wxCoord yyy2 = (wxCoord) (yyc+ray);
f6bcfd97
BP
463
464 if ( m_brush.Ok() && m_brush.GetStyle() != wxTRANSPARENT )
7bcb11d3
JS
465 {
466 // Have to add 1 to bottom-right corner of rectangle
467 // to make semi-circles look right (crooked line otherwise).
468 // Unfortunately this is not a reliable method, depends
469 // on the size of shape.
470 // TODO: figure out why this happens!
f6bcfd97 471 Pie(GetHdc(),xxx1,yyy1,xxx2+1,yyy2+1, xx1,yy1,xx2,yy2);
7bcb11d3
JS
472 }
473 else
2d8a5cb1 474 {
f6bcfd97 475 Arc(GetHdc(),xxx1,yyy1,xxx2,yyy2, xx1,yy1,xx2,yy2);
2d8a5cb1 476 }
f6bcfd97
BP
477
478 CalcBoundingBox(xc - r, yc - r);
479 CalcBoundingBox(xc + r, yc + r);
2bda0e17
KB
480}
481
cd9da200
VZ
482void wxDC::DoDrawCheckMark(wxCoord x1, wxCoord y1,
483 wxCoord width, wxCoord height)
484{
485 wxCoord x2 = x1 + width,
486 y2 = y1 + height;
487
488#if defined(__WIN32__) && !defined(__SC__)
489 RECT rect;
490 rect.left = x1;
491 rect.top = y1;
492 rect.right = x2;
493 rect.bottom = y2;
494
495 DrawFrameControl(GetHdc(), &rect, DFC_MENU, DFCS_MENUCHECK);
496#else // Win16
497 // In WIN16, draw a cross
498 HPEN blackPen = ::CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
499 HPEN whiteBrush = (HPEN)::GetStockObject(WHITE_BRUSH);
e06b9569
JS
500 HPEN hPenOld = (HPEN)::SelectObject(GetHdc(), blackPen);
501 HPEN hBrushOld = (HPEN)::SelectObject(GetHdc(), whiteBrush);
cd9da200
VZ
502 ::SetROP2(GetHdc(), R2_COPYPEN);
503 Rectangle(GetHdc(), x1, y1, x2, y2);
504 MoveTo(GetHdc(), x1, y1);
505 LineTo(GetHdc(), x2, y2);
506 MoveTo(GetHdc(), x2, y1);
507 LineTo(GetHdc(), x1, y2);
508 ::SelectObject(GetHdc(), hPenOld);
509 ::SelectObject(GetHdc(), hBrushOld);
510 ::DeleteObject(blackPen);
511#endif // Win32/16
512
513 CalcBoundingBox(x1, y1);
514 CalcBoundingBox(x2, y2);
515}
516
72cdf4c9 517void wxDC::DoDrawPoint(wxCoord x, wxCoord y)
2bda0e17 518{
7bcb11d3
JS
519 COLORREF color = 0x00ffffff;
520 if (m_pen.Ok())
521 {
a23fd0e1 522 color = m_pen.GetColour().GetPixel();
7bcb11d3 523 }
a23fd0e1
VZ
524
525 SetPixel(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), color);
526
7bcb11d3 527 CalcBoundingBox(x, y);
2bda0e17
KB
528}
529
72cdf4c9 530void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int fillStyle)
2bda0e17 531{
f6bcfd97 532 wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
de2d2cdc 533
7bcb11d3
JS
534 // Do things less efficiently if we have offsets
535 if (xoffset != 0 || yoffset != 0)
6a6c0a8b 536 {
7bcb11d3
JS
537 POINT *cpoints = new POINT[n];
538 int i;
539 for (i = 0; i < n; i++)
540 {
541 cpoints[i].x = (int)(points[i].x + xoffset);
542 cpoints[i].y = (int)(points[i].y + yoffset);
a23fd0e1 543
7bcb11d3
JS
544 CalcBoundingBox(cpoints[i].x, cpoints[i].y);
545 }
a23fd0e1
VZ
546 int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING);
547 (void)Polygon(GetHdc(), cpoints, n);
548 SetPolyFillMode(GetHdc(),prev);
7bcb11d3
JS
549 delete[] cpoints;
550 }
551 else
552 {
553 int i;
554 for (i = 0; i < n; i++)
555 CalcBoundingBox(points[i].x, points[i].y);
a23fd0e1
VZ
556
557 int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING);
558 (void)Polygon(GetHdc(), (POINT*) points, n);
559 SetPolyFillMode(GetHdc(),prev);
6a6c0a8b 560 }
2bda0e17
KB
561}
562
72cdf4c9 563void wxDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
2bda0e17 564{
7bcb11d3
JS
565 // Do things less efficiently if we have offsets
566 if (xoffset != 0 || yoffset != 0)
6a6c0a8b 567 {
7bcb11d3
JS
568 POINT *cpoints = new POINT[n];
569 int i;
570 for (i = 0; i < n; i++)
571 {
572 cpoints[i].x = (int)(points[i].x + xoffset);
573 cpoints[i].y = (int)(points[i].y + yoffset);
a23fd0e1 574
7bcb11d3
JS
575 CalcBoundingBox(cpoints[i].x, cpoints[i].y);
576 }
a23fd0e1 577 (void)Polyline(GetHdc(), cpoints, n);
7bcb11d3
JS
578 delete[] cpoints;
579 }
580 else
581 {
582 int i;
583 for (i = 0; i < n; i++)
584 CalcBoundingBox(points[i].x, points[i].y);
a23fd0e1
VZ
585
586 (void)Polyline(GetHdc(), (POINT*) points, n);
6a6c0a8b 587 }
2bda0e17
KB
588}
589
72cdf4c9 590void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
2bda0e17 591{
f6bcfd97 592 wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
de2d2cdc 593
72cdf4c9
VZ
594 wxCoord x2 = x + width;
595 wxCoord y2 = y + height;
a23fd0e1 596
5456b916 597 if ((m_logicalFunction == wxCOPY) && (m_pen.GetStyle() == wxTRANSPARENT))
0bafad0c 598 {
7299b1b2 599 RECT rect;
5456b916
RR
600 rect.left = XLOG2DEV(x);
601 rect.top = YLOG2DEV(y);
602 rect.right = XLOG2DEV(x2);
7299b1b2
RD
603 rect.bottom = YLOG2DEV(y2);
604 (void)FillRect(GetHdc(), &rect, (HBRUSH)m_brush.GetResourceHandle() );
5456b916
RR
605 }
606 else
607 {
608 // Windows draws the filled rectangles without outline (i.e. drawn with a
609 // transparent pen) one pixel smaller in both directions and we want them
f6bcfd97 610 // to have the same size regardless of which pen is used - adjust
5456b916
RR
611
612