]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dc.h
Document wxDataViewListCtrl, minor corrections
[wxWidgets.git] / include / wx / dc.h
CommitLineData
006162a9 1/////////////////////////////////////////////////////////////////////////////
4660e6ac 2// Name: wx/dc.h
006162a9 3// Purpose: wxDC class
6d52ca53 4// Author: Vadim Zeitlin
006162a9
VZ
5// Modified by:
6// Created: 05/25/99
7// RCS-ID: $Id$
77ffb593 8// Copyright: (c) wxWidgets team
65571936 9// Licence: wxWindows licence
006162a9
VZ
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_DC_H_BASE_
13#define _WX_DC_H_BASE_
c801d85f 14
a23fd0e1
VZ
15// ----------------------------------------------------------------------------
16// headers which we must include here
17// ----------------------------------------------------------------------------
18
19#include "wx/object.h" // the base class
20
0d80fb31 21#include "wx/intl.h" // for wxLayoutDirection
a23fd0e1
VZ
22#include "wx/cursor.h" // we have member variables of these classes
23#include "wx/font.h" // so we can't do without them
24#include "wx/colour.h"
b494e2b0 25#include "wx/bitmap.h" // for wxNullBitmap
a23fd0e1
VZ
26#include "wx/brush.h"
27#include "wx/pen.h"
28#include "wx/palette.h"
0919e93e 29#include "wx/dynarray.h"
19edb09c 30#include "wx/math.h"
02255e07 31#include "wx/image.h"
888dde65 32#include "wx/cmndata.h"
a23fd0e1 33
888dde65 34#define wxUSE_NEW_DC 1
2970ae54 35
ca7db61e 36class WXDLLIMPEXP_FWD_CORE wxDC;
ab171e95
RR
37class WXDLLIMPEXP_FWD_CORE wxClientDC;
38class WXDLLIMPEXP_FWD_CORE wxPaintDC;
39class WXDLLIMPEXP_FWD_CORE wxWindowDC;
40class WXDLLIMPEXP_FWD_CORE wxScreenDC;
41class WXDLLIMPEXP_FWD_CORE wxMemoryDC;
c8ddadff 42class WXDLLIMPEXP_FWD_CORE wxPrinterDC;
477c48bf 43class WXDLLIMPEXP_FWD_CORE wxPrintData;
888dde65 44
89efaf2b
FM
45// Logical ops
46enum wxRasterOperationMode
47{
48 wxCLEAR, // 0
49 wxXOR, // src XOR dst
50 wxINVERT, // NOT dst
51 wxOR_REVERSE, // src OR (NOT dst)
52 wxAND_REVERSE, // src AND (NOT dst)
53 wxCOPY, // src
54 wxAND, // src AND dst
55 wxAND_INVERT, // (NOT src) AND dst
56 wxNO_OP, // dst
57 wxNOR, // (NOT src) AND (NOT dst)
58 wxEQUIV, // (NOT src) XOR dst
59 wxSRC_INVERT, // (NOT src)
60 wxOR_INVERT, // (NOT src) OR dst
61 wxNAND, // (NOT src) OR (NOT dst)
62 wxOR, // src OR dst
63 wxSET // 1
79bd5e98 64#if WXWIN_COMPATIBILITY_2_8
89efaf2b
FM
65 ,wxROP_BLACK = wxCLEAR,
66 wxBLIT_BLACKNESS = wxCLEAR,
67 wxROP_XORPEN = wxXOR,
68 wxBLIT_SRCINVERT = wxXOR,
69 wxROP_NOT = wxINVERT,
70 wxBLIT_DSTINVERT = wxINVERT,
71 wxROP_MERGEPENNOT = wxOR_REVERSE,
72 wxBLIT_00DD0228 = wxOR_REVERSE,
73 wxROP_MASKPENNOT = wxAND_REVERSE,
74 wxBLIT_SRCERASE = wxAND_REVERSE,
75 wxROP_COPYPEN = wxCOPY,
76 wxBLIT_SRCCOPY = wxCOPY,
77 wxROP_MASKPEN = wxAND,
78 wxBLIT_SRCAND = wxAND,
79 wxROP_MASKNOTPEN = wxAND_INVERT,
80 wxBLIT_00220326 = wxAND_INVERT,
81 wxROP_NOP = wxNO_OP,
82 wxBLIT_00AA0029 = wxNO_OP,
83 wxROP_NOTMERGEPEN = wxNOR,
84 wxBLIT_NOTSRCERASE = wxNOR,
85 wxROP_NOTXORPEN = wxEQUIV,
86 wxBLIT_00990066 = wxEQUIV,
87 wxROP_NOTCOPYPEN = wxSRC_INVERT,
88 wxBLIT_NOTSCRCOPY = wxSRC_INVERT,
89 wxROP_MERGENOTPEN = wxOR_INVERT,
90 wxBLIT_MERGEPAINT = wxOR_INVERT,
91 wxROP_NOTMASKPEN = wxNAND,
92 wxBLIT_007700E6 = wxNAND,
93 wxROP_MERGEPEN = wxOR,
94 wxBLIT_SRCPAINT = wxOR,
95 wxROP_WHITE = wxSET,
96 wxBLIT_WHITENESS = wxSET
97#endif //WXWIN_COMPATIBILITY_2_8
98};
99
100// Flood styles
101enum wxFloodFillStyle
102{
103 wxFLOOD_SURFACE = 1,
104 wxFLOOD_BORDER
105};
106
107// Mapping modes (same values as used by Windows, don't change)
108enum wxMappingMode
109{
110 wxMM_TEXT = 1,
111 wxMM_LOMETRIC,
112 wxMM_HIMETRIC,
113 wxMM_LOENGLISH,
114 wxMM_HIENGLISH,
115 wxMM_TWIPS,
116 wxMM_ISOTROPIC,
117 wxMM_ANISOTROPIC,
118 wxMM_POINTS,
119 wxMM_METRIC
120};
121
888dde65
RR
122//-----------------------------------------------------------------------------
123// wxDrawObject helper class
124//-----------------------------------------------------------------------------
ca7db61e 125
53a2db12 126class WXDLLIMPEXP_CORE wxDrawObject
ca7db61e
RR
127{
128public:
129
130 wxDrawObject()
131 : m_isBBoxValid(false)
132 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
133 { }
134
135 virtual ~wxDrawObject() { }
136
ca7db61e 137 virtual void Draw(wxDC&) const { }
ca7db61e
RR
138
139 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
140 {
141 if ( m_isBBoxValid )
142 {
143 if ( x < m_minX ) m_minX = x;
144 if ( y < m_minY ) m_minY = y;
145 if ( x > m_maxX ) m_maxX = x;
146 if ( y > m_maxY ) m_maxY = y;
147 }
148 else
149 {
150 m_isBBoxValid = true;
151
152 m_minX = x;
153 m_minY = y;
154 m_maxX = x;
155 m_maxY = y;
156 }
157 }
158
159 void ResetBoundingBox()
160 {
161 m_isBBoxValid = false;
162
163 m_minX = m_maxX = m_minY = m_maxY = 0;
164 }
165
166 // Get the final bounding box of the PostScript or Metafile picture.
167
168 wxCoord MinX() const { return m_minX; }
169 wxCoord MaxX() const { return m_maxX; }
170 wxCoord MinY() const { return m_minY; }
171 wxCoord MaxY() const { return m_maxY; }
172
173 //to define the type of object for derived objects
174 virtual int GetType()=0;
175
176protected:
177 //for boundingbox calculation
178 bool m_isBBoxValid:1;
179 //for boundingbox calculation
180 wxCoord m_minX, m_minY, m_maxX, m_maxY;
181};
182
183
2970ae54
RR
184//-----------------------------------------------------------------------------
185// wxDCFactory
186//-----------------------------------------------------------------------------
187
888dde65 188class WXDLLIMPEXP_FWD_CORE wxDCImpl;
2970ae54
RR
189
190class WXDLLIMPEXP_CORE wxDCFactory
191{
192public:
193 wxDCFactory() {}
194 virtual ~wxDCFactory() {}
f0875501 195
888dde65 196 virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner, wxWindow *window ) = 0;
888dde65 197 virtual wxDCImpl* CreateClientDC( wxClientDC *owner, wxWindow *window ) = 0;
888dde65
RR
198 virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner, wxWindow *window ) = 0;
199 virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner ) = 0;
200 virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ) = 0;
201 virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ) = 0;
202 virtual wxDCImpl* CreateScreenDC( wxScreenDC *owner ) = 0;
6b4f4d47 203#if wxUSE_PRINTING_ARCHITECTURE
888dde65 204 virtual wxDCImpl* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ) = 0;
6b4f4d47 205#endif
f0875501 206
f2498c4e 207 static void Set(wxDCFactory *factory);
f0875501
VZ
208 static wxDCFactory *Get();
209
2970ae54
RR
210private:
211 static wxDCFactory *m_factory;
212};
213
214//-----------------------------------------------------------------------------
215// wxNativeDCFactory
216//-----------------------------------------------------------------------------
217
ab171e95 218class WXDLLIMPEXP_CORE wxNativeDCFactory: public wxDCFactory
2970ae54
RR
219{
220public:
221 wxNativeDCFactory() {}
f0875501 222
888dde65 223 virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner, wxWindow *window );
888dde65 224 virtual wxDCImpl* CreateClientDC( wxClientDC *owner, wxWindow *window );
888dde65
RR
225 virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner, wxWindow *window );
226 virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner );
227 virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap );
228 virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc );
229 virtual wxDCImpl* CreateScreenDC( wxScreenDC *owner );
6b4f4d47 230#if wxUSE_PRINTING_ARCHITECTURE
888dde65 231 virtual wxDCImpl* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data );
6b4f4d47 232#endif
2970ae54
RR
233};
234
2970ae54 235//-----------------------------------------------------------------------------
888dde65 236// wxDCImpl
2970ae54
RR
237//-----------------------------------------------------------------------------
238
888dde65 239class WXDLLIMPEXP_CORE wxDCImpl: public wxObject
2970ae54
RR
240{
241public:
888dde65 242 wxDCImpl( wxDC *owner );
edc51344 243 virtual ~wxDCImpl();
f0875501 244
ab171e95 245 wxDC *GetOwner() const { return m_owner; }
f0875501 246
888dde65 247 wxWindow* GetWindow() const { return m_window; }
f0875501 248
2970ae54
RR
249 virtual bool IsOk() const { return m_ok; }
250
251 // query capabilities
252
253 virtual bool CanDrawBitmap() const = 0;
254 virtual bool CanGetTextExtent() const = 0;
255
0b822969
RR
256 // get Cairo context
257 virtual void* GetCairoContext() const
2b44ffc0
RR
258 {
259 return NULL;
260 }
2b44ffc0 261
2970ae54
RR
262 // query dimension, colour deps, resolution
263
264 virtual void DoGetSize(int *width, int *height) const = 0;
4a624f6e
VZ
265 void GetSize(int *width, int *height) const
266 {
243ef54b
CE
267 DoGetSize(width, height);
268 return ;
4a624f6e
VZ
269 }
270
271 wxSize GetSize() const
272 {
273 int w, h;
274 DoGetSize(&w, &h);
275 return wxSize(w, h);
276 }
277
2970ae54 278 virtual void DoGetSizeMM(int* width, int* height) const = 0;
f0875501 279
2970ae54
RR
280 virtual int GetDepth() const = 0;
281 virtual wxSize GetPPI() const = 0;
f0875501 282
2970ae54 283 // Right-To-Left (RTL) modes
f0875501 284
2970ae54
RR
285 virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) { }
286 virtual wxLayoutDirection GetLayoutDirection() const { return wxLayout_Default; }
f0875501
VZ
287
288 // page and document
289
2970ae54
RR
290 virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; }
291 virtual void EndDoc() { }
292
293 virtual void StartPage() { }
294 virtual void EndPage() { }
295
cc18b1c7
SC
296 // flushing the content of this dc immediately eg onto screen
297 virtual void Flush() { }
298
2970ae54
RR
299 // bounding box
300
ca7db61e 301 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
2970ae54
RR
302 {
303 if ( m_isBBoxValid )
304 {
305 if ( x < m_minX ) m_minX = x;
306 if ( y < m_minY ) m_minY = y;
307 if ( x > m_maxX ) m_maxX = x;
308 if ( y > m_maxY ) m_maxY = y;
309 }
310 else
311 {
312 m_isBBoxValid = true;
313
314 m_minX = x;
315 m_minY = y;
316 m_maxX = x;
317 m_maxY = y;
318 }
319 }
ca7db61e 320 void ResetBoundingBox()
2970ae54
RR
321 {
322 m_isBBoxValid = false;
323
324 m_minX = m_maxX = m_minY = m_maxY = 0;
325 }
326
327 wxCoord MinX() const { return m_minX; }
328 wxCoord MaxX() const { return m_maxX; }
329 wxCoord MinY() const { return m_minY; }
330 wxCoord MaxY() const { return m_maxY; }
f0875501 331
2970ae54
RR
332 // setters and getters
333
334 virtual void SetFont(const wxFont& font) = 0;
edc51344 335 virtual const wxFont& GetFont() const { return m_font; }
f0875501 336
2970ae54 337 virtual void SetPen(const wxPen& pen) = 0;
edc51344 338 virtual const wxPen& GetPen() const { return m_pen; }
f0875501 339
2970ae54 340 virtual void SetBrush(const wxBrush& brush) = 0;
edc51344 341 virtual const wxBrush& GetBrush() const { return m_brush; }
f0875501 342
2970ae54 343 virtual void SetBackground(const wxBrush& brush) = 0;
edc51344 344 virtual const wxBrush& GetBackground() const { return m_backgroundBrush; }
f0875501 345
2970ae54
RR
346 virtual void SetBackgroundMode(int mode) = 0;
347 virtual int GetBackgroundMode() const { return m_backgroundMode; }
348
349 virtual void SetTextForeground(const wxColour& colour)
350 { m_textForegroundColour = colour; }
edc51344
VZ
351 virtual const wxColour& GetTextForeground() const
352 { return m_textForegroundColour; }
f0875501 353
2970ae54
RR
354 virtual void SetTextBackground(const wxColour& colour)
355 { m_textBackgroundColour = colour; }
edc51344
VZ
356 virtual const wxColour& GetTextBackground() const
357 { return m_textBackgroundColour; }
2970ae54
RR
358
359#if wxUSE_PALETTE
360 virtual void SetPalette(const wxPalette& palette) = 0;
361#endif // wxUSE_PALETTE
362
edc51344
VZ
363 // inherit the DC attributes (font and colours) from the given window
364 //
365 // this is called automatically when a window, client or paint DC is
366 // created
367 virtual void InheritAttributes(wxWindow *win);
368
369
2970ae54 370 // logical functions
f0875501 371
89efaf2b
FM
372 virtual void SetLogicalFunction(wxRasterOperationMode function) = 0;
373 virtual wxRasterOperationMode GetLogicalFunction() const
374 { return m_logicalFunction; }
2970ae54
RR
375
376 // text measurement
377
378 virtual wxCoord GetCharHeight() const = 0;
379 virtual wxCoord GetCharWidth() const = 0;
380 virtual void DoGetTextExtent(const wxString& string,
381 wxCoord *x, wxCoord *y,
382 wxCoord *descent = NULL,
383 wxCoord *externalLeading = NULL,
384 const wxFont *theFont = NULL) const = 0;
385 virtual void GetMultiLineTextExtent(const wxString& string,
386 wxCoord *width,
387 wxCoord *height,
388 wxCoord *heightLine = NULL,
389 const wxFont *font = NULL) const;
390 virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
f0875501 391
2970ae54 392 // clearing
f0875501 393
2970ae54
RR
394 virtual void Clear() = 0;
395
396 // clipping
397
398 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
399 wxCoord width, wxCoord height) = 0;
fdaad94e
VZ
400
401 // NB: this function works with device coordinates, not the logical ones!
402 virtual void DoSetDeviceClippingRegion(const wxRegion& region) = 0;
2970ae54
RR
403
404 virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
405 wxCoord *w, wxCoord *h) const
406 {
407 if ( x )
408 *x = m_clipX1;
409 if ( y )
410 *y = m_clipY1;
411 if ( w )
412 *w = m_clipX2 - m_clipX1;
413 if ( h )
414 *h = m_clipY2 - m_clipY1;
415 }
416
417 virtual void DestroyClippingRegion() { ResetClipping(); }
418
419
420 // coordinates conversions and transforms
421
422 virtual wxCoord DeviceToLogicalX(wxCoord x) const;
423 virtual wxCoord DeviceToLogicalY(wxCoord y) const;
424 virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
425 virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
426 virtual wxCoord LogicalToDeviceX(wxCoord x) const;
427 virtual wxCoord LogicalToDeviceY(wxCoord y) const;
428 virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
429 virtual wxCoord LogicalToDeviceYRel(wxCoord y) const;
430
89efaf2b
FM
431 virtual void SetMapMode(wxMappingMode mode);
432 virtual wxMappingMode GetMapMode() const { return m_mappingMode; }
2970ae54
RR
433
434 virtual void SetUserScale(double x, double y);
435 virtual void GetUserScale(double *x, double *y) const
436 {
437 if ( x ) *x = m_userScaleX;
438 if ( y ) *y = m_userScaleY;
439 }
440
441 virtual void SetLogicalScale(double x, double y);
442 virtual void GetLogicalScale(double *x, double *y)
443 {
444 if ( x ) *x = m_logicalScaleX;
445 if ( y ) *y = m_logicalScaleY;
446 }
447
448 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
449 virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
450 {
451 if ( x ) *x = m_logicalOriginX;
452 if ( y ) *y = m_logicalOriginY;
453 }
454
455 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
456 virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
457 {
458 if ( x ) *x = m_deviceOriginX;
459 if ( y ) *y = m_deviceOriginY;
460 }
f0875501 461
2970ae54
RR
462 virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y );
463
464 virtual void ComputeScaleAndOrigin();
465
466 // this needs to overidden if the axis is inverted
467 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
468
469 // ---------------------------------------------------------
470 // the actual drawing API
471
472 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
89efaf2b 473 wxFloodFillStyle style = wxFLOOD_SURFACE) = 0;
2970ae54
RR
474
475 virtual void DoGradientFillLinear(const wxRect& rect,
476 const wxColour& initialColour,
477 const wxColour& destColour,
478 wxDirection nDirection = wxEAST);
479
480 virtual void DoGradientFillConcentric(const wxRect& rect,
481 const wxColour& initialColour,
482 const wxColour& destColour,
483 const wxPoint& circleCenter);
484
485 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
486
487 virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
488 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
489
490 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
491 wxCoord x2, wxCoord y2,
492 wxCoord xc, wxCoord yc) = 0;
493 virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
494 wxCoord width, wxCoord height);
495 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
496 double sa, double ea) = 0;
497
498 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
499 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
500 wxCoord width, wxCoord height,
501 double radius) = 0;
502 virtual void DoDrawEllipse(wxCoord x, wxCoord y,
503 wxCoord width, wxCoord height) = 0;
504
505 virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
506
507 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
508 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
509 bool useMask = false) = 0;
510
511 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
512 virtual void DoDrawRotatedText(const wxString& text,
513 wxCoord x, wxCoord y, double angle) = 0;
514
515 virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
516 wxCoord width, wxCoord height,
517 wxDC *source,
518 wxCoord xsrc, wxCoord ysrc,
89efaf2b 519 wxRasterOperationMode rop = wxCOPY,
2970ae54
RR
520 bool useMask = false,
521 wxCoord xsrcMask = wxDefaultCoord,
522 wxCoord ysrcMask = wxDefaultCoord) = 0;
523
524 virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest,
525 wxCoord dstWidth, wxCoord dstHeight,
526 wxDC *source,
527 wxCoord xsrc, wxCoord ysrc,
528 wxCoord srcWidth, wxCoord srcHeight,
89efaf2b 529 wxRasterOperationMode rop = wxCOPY,
2970ae54
RR
530 bool useMask = false,
531 wxCoord xsrcMask = wxDefaultCoord,
532 wxCoord ysrcMask = wxDefaultCoord);
533
534 virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const
535 { return wxNullBitmap; }
536
537
538 virtual void DoDrawLines(int n, wxPoint points[],
4f37154e
RR
539 wxCoord xoffset, wxCoord yoffset ) = 0;
540 virtual void DrawLines(const wxPointList *list,
541 wxCoord xoffset, wxCoord yoffset );
f0875501 542
2970ae54 543 virtual void DoDrawPolygon(int n, wxPoint points[],
89efaf2b
FM
544 wxCoord xoffset, wxCoord yoffset,
545 wxPolygonFillMode fillStyle = wxODDEVEN_RULE) = 0;
2970ae54
RR
546 virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
547 wxCoord xoffset, wxCoord yoffset,
89efaf2b 548 wxPolygonFillMode fillStyle);
4f37154e
RR
549 void DrawPolygon(const wxPointList *list,
550 wxCoord xoffset, wxCoord yoffset,
89efaf2b 551 wxPolygonFillMode fillStyle );
2970ae54
RR
552
553
554#if wxUSE_SPLINES
7210c3a1
VZ
555 void DrawSpline(wxCoord x1, wxCoord y1,
556 wxCoord x2, wxCoord y2,
557 wxCoord x3, wxCoord y3);
558 void DrawSpline(int n, wxPoint points[]);
559 void DrawSpline(const wxPointList *points) { DoDrawSpline(points); }
560
b0d7707b 561 virtual void DoDrawSpline(const wxPointList *points);
2970ae54 562#endif
f0875501 563
4f37154e
RR
564 // ---------------------------------------------------------
565 // wxMemoryDC Impl API
566
567 virtual void DoSelect(const wxBitmap& WXUNUSED(bmp))
568 { }
f0875501 569
4f37154e
RR
570 virtual const wxBitmap& GetSelectedBitmap() const
571 { return wxNullBitmap; }
572 virtual wxBitmap& GetSelectedBitmap()
573 { return wxNullBitmap; }
f0875501 574
4f37154e
RR
575 // ---------------------------------------------------------
576 // wxPrinterDC Impl API
577
6d52ca53 578 virtual wxRect GetPaperRect() const
4f37154e 579 { int w = 0; int h = 0; DoGetSize( &w, &h ); return wxRect(0,0,w,h); }
f0875501 580
6d52ca53 581 virtual int GetResolution() const
4f37154e
RR
582 { return -1; }
583
2970ae54 584private:
888dde65 585 wxDC *m_owner;
2970ae54 586
f0875501 587protected:
2970ae54
RR
588 // unset clipping variables (after clipping region was destroyed)
589 void ResetClipping()
590 {
591 m_clipping = false;
592
593 m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0;
594 }
595
2261baf7
VZ
596#ifdef __WXWINCE__
597 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
598 /*! \param x Upper left corner of bounding box.
599 * \param y Upper left corner of bounding box.
600 * \param w Width of bounding box.
601 * \param h Height of bounding box.
602 * \param sa Starting angle of arc
603 * (counterclockwise, start at 3 o'clock, 360 is full circle).
604 * \param ea Ending angle of arc.
605 * \param angle Rotation angle, the Arc will be rotated after
606 * calculating begin and end.
607 */
608 void DrawEllipticArcRot( wxCoord x, wxCoord y,
609 wxCoord width, wxCoord height,
610 double sa = 0, double ea = 0, double angle = 0 )
611 { DoDrawEllipticArcRot( x, y, width, height, sa, ea, angle ); }
612
613 void DrawEllipticArcRot( const wxPoint& pt,
614 const wxSize& sz,
615 double sa = 0, double ea = 0, double angle = 0 )
616 { DoDrawEllipticArcRot( pt.x, pt.y, sz.x, sz.y, sa, ea, angle ); }
617
618 void DrawEllipticArcRot( const wxRect& rect,
619 double sa = 0, double ea = 0, double angle = 0 )
620 { DoDrawEllipticArcRot( rect.x, rect.y, rect.width, rect.height, sa, ea, angle ); }
621
622 virtual void DoDrawEllipticArcRot( wxCoord x, wxCoord y,
623 wxCoord w, wxCoord h,
624 double sa = 0, double ea = 0, double angle = 0 );
625
626 //! Rotates points around center.
627 /*! This is a quite straight method, it calculates in pixels
628 * and so it produces rounding errors.
629 * \param points The points inside will be rotated.
630 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
631 * \param center Center of rotation.
632 */
633 void Rotate( wxPointList* points, double angle, wxPoint center = wxPoint(0,0) );
634
635 // used by DrawEllipticArcRot
636 // Careful: wxList gets filled with points you have to delete later.
637 void CalculateEllipticPoints( wxPointList* points,
638 wxCoord xStart, wxCoord yStart,
639 wxCoord w, wxCoord h,
640 double sa, double ea );
641#endif // __WXWINCE__
642
12ca5586
VS
643 // returns adjustment factor for converting wxFont "point size"; in wx
644 // it is point size on screen and needs to be multiplied by this value
645 // for rendering on higher-resolution DCs such as printer ones
646 static float GetFontPointSizeAdjustment(float dpi);
2261baf7 647
888dde65
RR
648 // window on which the DC draws or NULL
649 wxWindow *m_window;
f0875501 650
2970ae54
RR
651 // flags
652 bool m_colour:1;
653 bool m_ok:1;
654 bool m_clipping:1;
655 bool m_isInteractive:1;
656 bool m_isBBoxValid:1;
657
658 // coordinate system variables
659
660 wxCoord m_logicalOriginX, m_logicalOriginY;
661 wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user
f0875501 662
2970ae54
RR
663 wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner
664 // is not at 0,0. This was the case under
665 // Mac's GrafPorts (coordinate system
666 // used toplevel window's origin) and
667 // e.g. for Postscript, where the native
668 // origin in the bottom left corner.
669 double m_logicalScaleX, m_logicalScaleY;
670 double m_userScaleX, m_userScaleY;
671 double m_scaleX, m_scaleY; // calculated from logical scale and user scale
672
673 int m_signX, m_signY; // Used by SetAxisOrientation() to invert the axes
f0875501 674
2970ae54
RR
675 // what is a mm on a screen you don't know the size of?
676 double m_mm_to_pix_x,
677 m_mm_to_pix_y;
f0875501 678
2970ae54
RR
679 // bounding and clipping boxes
680 wxCoord m_minX, m_minY, m_maxX, m_maxY;
681 wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
682
89efaf2b 683 wxRasterOperationMode m_logicalFunction;
2970ae54 684 int m_backgroundMode;
89efaf2b 685 wxMappingMode m_mappingMode;
2970ae54
RR
686
687 wxPen m_pen;
688 wxBrush m_brush;
689 wxBrush m_backgroundBrush;
690 wxColour m_textForegroundColour;
691 wxColour m_textBackgroundColour;
692 wxFont m_font;
693
694#if wxUSE_PALETTE
695 wxPalette m_palette;
696 bool m_hasCustomPalette;
697#endif // wxUSE_PALETTE
698
699private:
888dde65 700 DECLARE_ABSTRACT_CLASS(wxDCImpl)
ca7db61e 701};
2970ae54
RR
702
703
f0875501 704class WXDLLIMPEXP_CORE wxDC : public wxObject
2970ae54
RR
705{
706public:
f0875501 707 virtual ~wxDC() { delete m_pimpl; }
2970ae54 708
888dde65 709 wxDCImpl *GetImpl()
ab171e95 710 { return m_pimpl; }
888dde65 711 const wxDCImpl *GetImpl() const
32043152
RR
712 { return m_pimpl; }
713
1f991c9d 714 wxWindow *GetWindow() const
888dde65 715 { return m_pimpl->GetWindow(); }
ab171e95 716
f0875501 717 bool IsOk() const
2970ae54
RR
718 { return m_pimpl && m_pimpl->IsOk(); }
719
720 // query capabilities
721
f0875501 722 bool CanDrawBitmap() const
2970ae54
RR
723 { return m_pimpl->CanDrawBitmap(); }
724 bool CanGetTextExtent() const
725 { return m_pimpl->CanGetTextExtent(); }
f0875501 726
2970ae54
RR
727 // query dimension, colour deps, resolution
728
729 void GetSize(int *width, int *height) const
730 { m_pimpl->DoGetSize(width, height); }
2970ae54 731 wxSize GetSize() const
4a624f6e 732 { return m_pimpl->GetSize(); }
2970ae54
RR
733
734 void GetSizeMM(int* width, int* height) const
735 { m_pimpl->DoGetSizeMM(width, height); }
736 wxSize GetSizeMM() const
737 {
738 int w, h;
739 m_pimpl->DoGetSizeMM(&w, &h);
740 return wxSize(w, h);
741 }
f0875501 742
2970ae54
RR
743 int GetDepth() const
744 { return m_pimpl->GetDepth(); }
745 wxSize GetPPI() const
746 { return m_pimpl->GetPPI(); }
747
6d52ca53 748 virtual int GetResolution() const
4f37154e 749 { return m_pimpl->GetResolution(); }
f0875501 750
2970ae54 751 // Right-To-Left (RTL) modes
f0875501 752
2970ae54
RR
753 void SetLayoutDirection(wxLayoutDirection dir)
754 { m_pimpl->SetLayoutDirection( dir ); }
755 wxLayoutDirection GetLayoutDirection() const
756 { return m_pimpl->GetLayoutDirection(); }
f0875501
VZ
757
758 // page and document
759
2970ae54
RR
760 bool StartDoc(const wxString& message)
761 { return m_pimpl->StartDoc(message); }
762 void EndDoc()
763 { m_pimpl->EndDoc(); }
764
765 void StartPage()
766 { m_pimpl->StartPage(); }
767 void EndPage()
768 { m_pimpl->EndPage(); }
769
770 // bounding box
f0875501 771
2970ae54
RR
772 void CalcBoundingBox(wxCoord x, wxCoord y)
773 { m_pimpl->CalcBoundingBox(x,y); }
774 void ResetBoundingBox()
775 { m_pimpl->ResetBoundingBox(); }
f0875501 776
2970ae54
RR
777 wxCoord MinX() const
778 { return m_pimpl->MinX(); }
779 wxCoord MaxX() const
780 { return m_pimpl->MaxX(); }
781 wxCoord MinY() const
782 { return m_pimpl->MinY(); }
783 wxCoord MaxY() const
784 { return m_pimpl->MaxY(); }
f0875501 785
2970ae54
RR
786 // setters and getters
787
788 void SetFont(const wxFont& font)
789 { m_pimpl->SetFont( font ); }
f0875501 790 const wxFont& GetFont() const
2970ae54 791 { return m_pimpl->GetFont(); }
f0875501 792
2970ae54
RR
793 void SetPen(const wxPen& pen)
794 { m_pimpl->SetPen( pen ); }
f0875501 795 const wxPen& GetPen() const
2970ae54 796 { return m_pimpl->GetPen(); }
f0875501 797
2970ae54
RR
798 void SetBrush(const wxBrush& brush)
799 { m_pimpl->SetBrush( brush ); }
800 const wxBrush& GetBrush() const
801 { return m_pimpl->GetBrush(); }
f0875501 802
2970ae54
RR
803 void SetBackground(const wxBrush& brush)
804 { m_pimpl->SetBackground( brush ); }
805 const wxBrush& GetBackground() const
806 { return m_pimpl->GetBackground(); }
f0875501 807
2970ae54 808 void SetBackgroundMode(int mode)
ca7db61e 809 { m_pimpl->SetBackgroundMode( mode ); }
2970ae54 810 int GetBackgroundMode() const
ca7db61e 811 { return m_pimpl->GetBackgroundMode(); }
2970ae54
RR
812
813 void SetTextForeground(const wxColour& colour)
814 { m_pimpl->SetTextForeground(colour); }
815 const wxColour& GetTextForeground() const
816 { return m_pimpl->GetTextForeground(); }
f0875501 817
2970ae54
RR
818 void SetTextBackground(const wxColour& colour)
819 { m_pimpl->SetTextBackground(colour); }
f0875501 820 const wxColour& GetTextBackground() const
2970ae54
RR
821 { return m_pimpl->GetTextBackground(); }
822
823#if wxUSE_PALETTE
824 void SetPalette(const wxPalette& palette)
825 { m_pimpl->SetPalette(palette); }
826#endif // wxUSE_PALETTE
f0875501 827
2970ae54 828 // logical functions
f0875501 829
89efaf2b 830 void SetLogicalFunction(wxRasterOperationMode function)
2970ae54 831 { m_pimpl->SetLogicalFunction(function); }
89efaf2b 832 wxRasterOperationMode GetLogicalFunction() const
2970ae54 833 { return m_pimpl->GetLogicalFunction(); }
f0875501 834
2970ae54
RR
835 // text measurement
836
837 wxCoord GetCharHeight() const
838 { return m_pimpl->GetCharHeight(); }
839 wxCoord GetCharWidth() const
840 { return m_pimpl->GetCharWidth(); }
f0875501 841
2970ae54
RR
842 void GetTextExtent(const wxString& string,
843 wxCoord *x, wxCoord *y,
844 wxCoord *descent = NULL,
845 wxCoord *externalLeading = NULL,
846 const wxFont *theFont = NULL) const
847 { m_pimpl->DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
848
849 wxSize GetTextExtent(const wxString& string) const
850 {
851 wxCoord w, h;
852 m_pimpl->DoGetTextExtent(string, &w, &h);
853 return wxSize(w, h);
854 }
f0875501 855
2970ae54
RR
856 void GetMultiLineTextExtent(const wxString& string,
857 wxCoord *width,
858 wxCoord *height,
859 wxCoord *heightLine = NULL,
860 const wxFont *font = NULL) const
861 { m_pimpl->GetMultiLineTextExtent( string, width, height, heightLine, font ); }
f0875501 862
2970ae54
RR
863 wxSize GetMultiLineTextExtent(const wxString& string) const
864 {
865 wxCoord w, h;
866 m_pimpl->GetMultiLineTextExtent(string, &w, &h);
867 return wxSize(w, h);
868 }
f0875501 869
2970ae54
RR
870 bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
871 { return m_pimpl->DoGetPartialTextExtents(text, widths); }
f0875501 872
2970ae54 873 // clearing
f0875501 874
2970ae54
RR
875 void Clear()
876 { m_pimpl->Clear(); }
877
878 // clipping
879
880 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
881 { m_pimpl->DoSetClippingRegion(x, y, width, height); }
882 void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
883 { m_pimpl->DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
884 void SetClippingRegion(const wxRect& rect)
885 { m_pimpl->DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
fdaad94e
VZ
886
887 // unlike the functions above, the coordinates of the region used in this
888 // one are in device coordinates, not the logical ones
889 void SetDeviceClippingRegion(const wxRegion& region)
890 { m_pimpl->DoSetDeviceClippingRegion(region); }
891
892 // this function is deprecated because its name is confusing: you may
893 // expect it to work with logical coordinates but, in fact, it does exactly
894 // the same thing as SetDeviceClippingRegion()
895 //
896 // please review the code using it and either replace it with calls to
897 // SetDeviceClippingRegion() or correct it if it was [wrongly] passing
898 // logical coordinates to this function
899 wxDEPRECATED_INLINE(void SetClippingRegion(const wxRegion& region),
900 SetDeviceClippingRegion(region); )
2970ae54
RR
901
902 void DestroyClippingRegion()
903 { m_pimpl->DestroyClippingRegion(); }
904
905 void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
906 { m_pimpl->DoGetClippingBox(x, y, w, h); }
907 void GetClippingBox(wxRect& rect) const
908 { m_pimpl->DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height); }
f0875501 909
2970ae54
RR
910 // coordinates conversions and transforms
911
912 wxCoord DeviceToLogicalX(wxCoord x) const
913 { return m_pimpl->DeviceToLogicalX(x); }
ca7db61e 914 wxCoord DeviceToLogicalY(wxCoord y) const
2970ae54 915 { return m_pimpl->DeviceToLogicalY(y); }
ca7db61e 916 wxCoord DeviceToLogicalXRel(wxCoord x) const
2970ae54 917 { return m_pimpl->DeviceToLogicalXRel(x); }
ca7db61e 918 wxCoord DeviceToLogicalYRel(wxCoord y) const
2970ae54 919 { return m_pimpl->DeviceToLogicalYRel(y); }
ca7db61e 920 wxCoord LogicalToDeviceX(wxCoord x) const
2970ae54 921 { return m_pimpl->LogicalToDeviceX(x); }
ca7db61e 922 wxCoord LogicalToDeviceY(wxCoord y) const
2970ae54 923 { return m_pimpl->LogicalToDeviceY(y); }
ca7db61e 924 wxCoord LogicalToDeviceXRel(wxCoord x) const
2970ae54 925 { return m_pimpl->LogicalToDeviceXRel(x); }
ca7db61e 926 wxCoord LogicalToDeviceYRel(wxCoord y) const
2970ae54
RR
927 { return m_pimpl->LogicalToDeviceYRel(y); }
928
89efaf2b 929 void SetMapMode(wxMappingMode mode)
2970ae54 930 { m_pimpl->SetMapMode(mode); }
89efaf2b 931 wxMappingMode GetMapMode() const
2970ae54
RR
932 { return m_pimpl->GetMapMode(); }
933
934 void SetUserScale(double x, double y)
935 { m_pimpl->SetUserScale(x,y); }
936 void GetUserScale(double *x, double *y) const
937 { m_pimpl->GetUserScale( x, y ); }
938
939 void SetLogicalScale(double x, double y)
940 { m_pimpl->SetLogicalScale( x, y ); }
941 void GetLogicalScale(double *x, double *y)
942 { m_pimpl->GetLogicalScale( x, y ); }
943
944 void SetLogicalOrigin(wxCoord x, wxCoord y)
945 { m_pimpl->SetLogicalOrigin(x,y); }
946 void GetLogicalOrigin(wxCoord *x, wxCoord *y) const
947 { m_pimpl->DoGetLogicalOrigin(x, y); }
948 wxPoint GetLogicalOrigin() const
949 { wxCoord x, y; m_pimpl->DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); }
950
951 void SetDeviceOrigin(wxCoord x, wxCoord y)
952 { m_pimpl->SetDeviceOrigin( x, y); }
953 void GetDeviceOrigin(wxCoord *x, wxCoord *y) const
954 { m_pimpl->DoGetDeviceOrigin(x, y); }
955 wxPoint GetDeviceOrigin() const
956 { wxCoord x, y; m_pimpl->DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); }
957
958 void SetAxisOrientation(bool xLeftRight, bool yBottomUp)
959 { m_pimpl->SetAxisOrientation(xLeftRight, yBottomUp); }
f0875501
VZ
960
961 // mostly internal
2970ae54
RR
962 void SetDeviceLocalOrigin( wxCoord x, wxCoord y )
963 { m_pimpl->SetDeviceLocalOrigin( x, y ); }
964
965
966 // draw generic object
967
968 void DrawObject(wxDrawObject* drawobject)
969 {
970 drawobject->Draw(*this);
971 CalcBoundingBox(drawobject->MinX(),drawobject->MinY());
972 CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY());
973 }
974
975 // -----------------------------------------------
976 // the actual drawing API
977
978 bool FloodFill(wxCoord x, wxCoord y, const wxColour& col,
89efaf2b 979 wxFloodFillStyle style = wxFLOOD_SURFACE)
2970ae54
RR
980 { return m_pimpl->DoFloodFill(x, y, col, style); }
981 bool FloodFill(const wxPoint& pt, const wxColour& col,
89efaf2b 982 wxFloodFillStyle style = wxFLOOD_SURFACE)
2970ae54
RR
983 { return m_pimpl->DoFloodFill(pt.x, pt.y, col, style); }
984
985 // fill the area specified by rect with a radial gradient, starting from
986 // initialColour in the centre of the cercle and fading to destColour.
987 void GradientFillConcentric(const wxRect& rect,
988 const wxColour& initialColour,
989 const wxColour& destColour)
ca7db61e
RR
990 { m_pimpl->DoGradientFillConcentric( rect, initialColour, destColour,
991 wxPoint(rect.GetWidth() / 2,
992 rect.GetHeight() / 2)); }
2970ae54
RR
993
994 void GradientFillConcentric(const wxRect& rect,
995 const wxColour& initialColour,
996 const wxColour& destColour,
997 const wxPoint& circleCenter)
998 { m_pimpl->DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); }
999
1000 // fill the area specified by rect with a linear gradient
1001 void GradientFillLinear(const wxRect& rect,
1002 const wxColour& initialColour,
1003 const wxColour& destColour,
1004 wxDirection nDirection = wxEAST)
1005 { m_pimpl->DoGradientFillLinear(rect, initialColour, destColour, nDirection); }
1006
1007 bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
1008 { return m_pimpl->DoGetPixel(x, y, col); }
1009 bool GetPixel(const wxPoint& pt, wxColour *col) const
1010 { return m_pimpl->DoGetPixel(pt.x, pt.y, col); }
1011
1012 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
1013 { m_pimpl->DoDrawLine(x1, y1, x2, y2); }
1014 void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
1015 { m_pimpl->DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); }
1016
1017 void CrossHair(wxCoord x, wxCoord y)
1018 { m_pimpl->DoCrossHair(x, y); }
1019 void CrossHair(const wxPoint& pt)
1020 { m_pimpl->DoCrossHair(pt.x, pt.y); }
1021
1022 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
1023 wxCoord xc, wxCoord yc)
1024 { m_pimpl->DoDrawArc(x1, y1, x2, y2, xc, yc); }
1025 void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
1026 { m_pimpl->DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
1027
1028 void DrawCheckMark(wxCoord x, wxCoord y,
1029 wxCoord width, wxCoord height)
1030 { m_pimpl->DoDrawCheckMark(x, y, width, height); }
1031 void DrawCheckMark(const wxRect& rect)
1032 { m_pimpl->DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
1033
1034 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
1035 double sa, double ea)
1036 { m_pimpl->DoDrawEllipticArc(x, y, w, h, sa, ea); }
1037 void DrawEllipticArc(const wxPoint& pt, const wxSize& sz,
1038 double sa, double ea)
1039 { m_pimpl->DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); }
1040
1041 void DrawPoint(wxCoord x, wxCoord y)
1042 { m_pimpl->DoDrawPoint(x, y); }
1043 void DrawPoint(const wxPoint& pt)
1044 { m_pimpl->DoDrawPoint(pt.x, pt.y); }
1045
1046 void DrawLines(int n, wxPoint points[],
1047 wxCoord xoffset = 0, wxCoord yoffset = 0)
1048 { m_pimpl->DoDrawLines(n, points, xoffset, yoffset); }
b0d7707b 1049 void DrawLines(const wxPointList *list,
2970ae54 1050 wxCoord xoffset = 0, wxCoord yoffset = 0)
f0875501 1051 { m_pimpl->DrawLines( list, xoffset, yoffset ); }
4f37154e
RR
1052#if WXWIN_COMPATIBILITY_2_8
1053 wxDEPRECATED( void DrawLines(const wxList *list,
1054 wxCoord xoffset = 0, wxCoord yoffset = 0) );
1055#endif // WXWIN_COMPATIBILITY_2_8
2970ae54
RR
1056
1057 void DrawPolygon(int n, wxPoint points[],
1058 wxCoord xoffset = 0, wxCoord yoffset = 0,
89efaf2b 1059 wxPolygonFillMode fillStyle = wxODDEVEN_RULE)
2970ae54 1060 { m_pimpl->DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
b0d7707b 1061 void DrawPolygon(const wxPointList *list,
2970ae54 1062 wxCoord xoffset = 0, wxCoord yoffset = 0,
89efaf2b 1063 wxPolygonFillMode fillStyle = wxODDEVEN_RULE)
2970ae54 1064 { m_pimpl->DrawPolygon( list, xoffset, yoffset, fillStyle ); }
2970ae54
RR
1065 void DrawPolyPolygon(int n, int count[], wxPoint points[],
1066 wxCoord xoffset = 0, wxCoord yoffset = 0,
89efaf2b 1067 wxPolygonFillMode fillStyle = wxODDEVEN_RULE)
2970ae54 1068 { m_pimpl->DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); }
4f37154e
RR
1069#if WXWIN_COMPATIBILITY_2_8
1070 wxDEPRECATED( void DrawPolygon(const wxList *list,
1071 wxCoord xoffset = 0, wxCoord yoffset = 0,
89efaf2b 1072 wxPolygonFillMode fillStyle = wxODDEVEN_RULE) );
4f37154e 1073#endif // WXWIN_COMPATIBILITY_2_8
2970ae54
RR
1074
1075 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
1076 { m_pimpl->DoDrawRectangle(x, y, width, height); }
1077 void DrawRectangle(const wxPoint& pt, const wxSize& sz)
1078 { m_pimpl->DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); }
1079 void DrawRectangle(const wxRect& rect)
1080 { m_pimpl->DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); }
1081
1082 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
1083 double radius)
1084 { m_pimpl->DoDrawRoundedRectangle(x, y, width, height, radius); }
1085 void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
1086 double radius)
1087 { m_pimpl->DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); }
1088 void DrawRoundedRectangle(const wxRect& r, double radius)
1089 { m_pimpl->DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); }
1090
1091 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius)
1092 { m_pimpl->DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); }
1093 void DrawCircle(const wxPoint& pt, wxCoord radius)
ca7db61e 1094 { m_pimpl->DoDrawEllipse(pt.x - radius, pt.y - radius, 2*radius, 2*radius); }
2970ae54
RR
1095
1096 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
1097 { m_pimpl->DoDrawEllipse(x, y, width, height); }
1098 void DrawEllipse(const wxPoint& pt, const wxSize& sz)
1099 { m_pimpl->DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); }
1100 void DrawEllipse(const wxRect& rect)
1101 { m_pimpl->DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); }
1102
1103 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
1104 { m_pimpl->DoDrawIcon(icon, x, y); }
1105 void DrawIcon(const wxIcon& icon, const wxPoint& pt)
1106 { m_pimpl->DoDrawIcon(icon, pt.x, pt.y); }
1107
1108 void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
1109 bool useMask = false)
1110 { m_pimpl->DoDrawBitmap(bmp, x, y, useMask); }
1111 void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt,
1112 bool useMask = false)
1113 { m_pimpl->DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
1114
1115 void DrawText(const wxString& text, wxCoord x, wxCoord y)
1116 { m_pimpl->DoDrawText(text, x, y); }
1117 void DrawText(const wxString& text, const wxPoint& pt)
1118 { m_pimpl->DoDrawText(text, pt.x, pt.y); }
1119
1120 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
1121 { m_pimpl->DoDrawRotatedText(text, x, y, angle); }
1122 void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
1123 { m_pimpl->DoDrawRotatedText(text, pt.x, pt.y, angle); }
1124
1125 // this version puts both optional bitmap and the text into the given
1126 // rectangle and aligns is as specified by alignment parameter; it also
1127 // will emphasize the character with the given index if it is != -1 and
1128 // return the bounding rectangle if required
1129 void DrawLabel(const wxString& text,
1130 const wxBitmap& image,
1131 const wxRect& rect,
1132 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
1133 int indexAccel = -1,
ca7db61e 1134 wxRect *rectBounding = NULL);
2970ae54
RR
1135
1136 void DrawLabel(const wxString& text, const wxRect& rect,
1137 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
1138 int indexAccel = -1)
ca7db61e 1139 { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
2970ae54
RR
1140
1141 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
1142 wxDC *source, wxCoord xsrc, wxCoord ysrc,
89efaf2b
FM
1143 wxRasterOperationMode rop = wxCOPY, bool useMask = false,
1144 wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord)
2970ae54
RR
1145 {
1146 return m_pimpl->DoBlit(xdest, ydest, width, height,
1147 source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
1148 }
1149 bool Blit(const wxPoint& destPt, const wxSize& sz,
1150 wxDC *source, const wxPoint& srcPt,
89efaf2b
FM
1151 wxRasterOperationMode rop = wxCOPY, bool useMask = false,
1152 const wxPoint& srcPtMask = wxDefaultPosition)
2970ae54
RR
1153 {
1154 return m_pimpl->DoBlit(destPt.x, destPt.y, sz.x, sz.y,
1155 source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
1156 }
1157
f0875501 1158 bool StretchBlit(wxCoord dstX, wxCoord dstY,
2970ae54 1159 wxCoord dstWidth, wxCoord dstHeight,
f0875501 1160 wxDC *source,
2970ae54
RR
1161 wxCoord srcX, wxCoord srcY,
1162 wxCoord srcWidth, wxCoord srcHeight,
89efaf2b 1163 wxRasterOperationMode rop = wxCOPY, bool useMask = false,
2970ae54
RR
1164 wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord)
1165 {
1166 return m_pimpl->DoStretchBlit(dstX, dstY, dstWidth, dstHeight,
1167 source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY);
1168 }
1169 bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize,
1170 wxDC *source, const wxPoint& srcPt, const wxSize& srcSize,
89efaf2b
FM
1171 wxRasterOperationMode rop = wxCOPY, bool useMask = false,
1172 const wxPoint& srcMaskPt = wxDefaultPosition)
2970ae54
RR
1173 {
1174 return m_pimpl->DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y,
1175 source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y);
1176 }
1177
1178 wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const
1179 {
1180 return m_pimpl->DoGetAsBitmap(subrect);
1181 }
1182
1183#if wxUSE_SPLINES
2970ae54
RR
1184 void DrawSpline(wxCoord x1, wxCoord y1,
1185 wxCoord x2, wxCoord y2,
1186 wxCoord x3, wxCoord y3)
7210c3a1 1187 { m_pimpl->DrawSpline(x1,y1,x2,y2,x3,y3); }
2970ae54 1188 void DrawSpline(int n, wxPoint points[])
7210c3a1 1189 { m_pimpl->DrawSpline(n,points); }
f0875501 1190 void DrawSpline(const wxPointList *points)
7210c3a1 1191 { m_pimpl->DrawSpline(points); }
2970ae54
RR
1192#endif // wxUSE_SPLINES
1193
1194
1195#if WXWIN_COMPATIBILITY_2_8
1196 // for compatibility with the old code when wxCoord was long everywhere
1197 wxDEPRECATED( void GetTextExtent(const wxString& string,
1198 long *x, long *y,
1199 long *descent = NULL,
1200 long *externalLeading = NULL,
1201 const wxFont *theFont = NULL) const );
1202 wxDEPRECATED( void GetLogicalOrigin(long *x, long *y) const );
1203 wxDEPRECATED( void GetDeviceOrigin(long *x, long *y) const );
1204 wxDEPRECATED( void GetClippingBox(long *x, long *y, long *w, long *h) const );
f5725872 1205
2970ae54
RR
1206#endif // WXWIN_COMPATIBILITY_2_8
1207
f5725872
VZ
1208#ifdef __WXMSW__
1209 WXHDC GetHDC() const;
1210#endif // __WXMSW__
2970ae54
RR
1211
1212protected:
f0875501
VZ
1213 // ctor takes ownership of the pointer
1214 wxDC(wxDCImpl *pimpl) : m_pimpl(pimpl) { }
1215
1216 wxDCImpl * const m_pimpl;
aec43716 1217
ca7db61e 1218private:
888dde65 1219 DECLARE_ABSTRACT_CLASS(wxDC)
f0875501 1220 DECLARE_NO_COPY_CLASS(wxDC)
ca7db61e 1221};
aec43716 1222
1e6feb95
VZ
1223// ----------------------------------------------------------------------------
1224// helper class: you can use it to temporarily change the DC text colour and
1225// restore it automatically when the object goes out of scope
1226// ----------------------------------------------------------------------------
1227
53a2db12 1228class WXDLLIMPEXP_CORE wxDCTextColourChanger
1e6feb95
VZ
1229{
1230public:
ba161d7e 1231 wxDCTextColourChanger(wxDC& dc) : m_dc(dc), m_colFgOld() { }
1e6feb95 1232
1b97b23d
VS
1233 wxDCTextColourChanger(wxDC& dc, const wxColour& col) : m_dc(dc)
1234 {
1235 Set(col);
1236 }
1237
1e6feb95
VZ
1238 ~wxDCTextColourChanger()
1239 {
1240 if ( m_colFgOld.Ok() )
1241 m_dc.SetTextForeground(m_colFgOld);
1242 }
1243
1244 void Set(const wxColour& col)
1245 {
1246 if ( !m_colFgOld.Ok() )
1247 m_colFgOld = m_dc.GetTextForeground();
1248 m_dc.SetTextForeground(col);
1249 }
1250
1251private:
1252 wxDC& m_dc;
1253
1254 wxColour m_colFgOld;
fc7a2a60
VZ
1255
1256 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger)
1e6feb95
VZ
1257};
1258
4660e6ac
WS
1259// ----------------------------------------------------------------------------
1260// helper class: you can use it to temporarily change the DC pen and
1261// restore it automatically when the object goes out of scope
1262// ----------------------------------------------------------------------------
1263
53a2db12 1264class WXDLLIMPEXP_CORE wxDCPenChanger
4660e6ac
WS
1265{
1266public:
0164f8eb
WS
1267 wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen())
1268 {
1269 m_dc.SetPen(pen);
1270 }
4660e6ac
WS
1271
1272 ~wxDCPenChanger()
1273 {
1274 if ( m_penOld.Ok() )
1275 m_dc.SetPen(m_penOld);
1276 }
1277
4660e6ac
WS
1278private:
1279 wxDC& m_dc;
1280
1281 wxPen m_penOld;
1282
1283 DECLARE_NO_COPY_CLASS(wxDCPenChanger)
1284};
1285
1286// ----------------------------------------------------------------------------
1287// helper class: you can use it to temporarily change the DC brush and
1288// restore it automatically when the object goes out of scope
1289// ----------------------------------------------------------------------------
1290
53a2db12 1291class WXDLLIMPEXP_CORE wxDCBrushChanger
4660e6ac
WS
1292{
1293public:
0164f8eb
WS
1294 wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush())
1295 {
1296 m_dc.SetBrush(brush);
1297 }
4660e6ac
WS
1298
1299 ~wxDCBrushChanger()
1300 {
1301 if ( m_brushOld.Ok() )
1302 m_dc.SetBrush(m_brushOld);
1303 }
1304
4660e6ac
WS
1305private:
1306 wxDC& m_dc;
1307
1308 wxBrush m_brushOld;
1309
1310 DECLARE_NO_COPY_CLASS(wxDCBrushChanger)
1311};
1312
e26be42b
VZ
1313// ----------------------------------------------------------------------------
1314// another small helper class: sets the clipping region in its ctor and
1315// destroys it in the dtor
1316// ----------------------------------------------------------------------------
1317
53a2db12 1318class WXDLLIMPEXP_CORE wxDCClipper
e26be42b
VZ
1319{
1320public:
fc298ea7 1321 wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc)
fdaad94e 1322 { dc.SetClippingRegion(r.GetBox()); }
e26be42b
VZ
1323 wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc)
1324 { dc.SetClippingRegion(r.x, r.y, r.width, r.height); }
1325 wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc)
1326 { dc.SetClippingRegion(x, y, w, h); }
1327
1328 ~wxDCClipper() { m_dc.DestroyClippingRegion(); }
1329
1330private:
1331 wxDC& m_dc;
fc7a2a60
VZ
1332
1333 DECLARE_NO_COPY_CLASS(wxDCClipper)
e26be42b
VZ
1334};
1335
c48d6cdf
FM
1336// ----------------------------------------------------------------------------
1337// helper class: you can use it to temporarily change the DC font and
1338// restore it automatically when the object goes out of scope
1339// ----------------------------------------------------------------------------
1340
1341class WXDLLIMPEXP_CORE wxDCFontChanger
1342{
1343public:
1344 wxDCFontChanger(wxDC& dc, const wxFont& font) : m_dc(dc), m_fontOld(dc.GetFont())
1345 {
1346 m_dc.SetFont(font);
1347 }
1348
1349 ~wxDCFontChanger()
1350 {
1351 if ( m_fontOld.Ok() )
1352 m_dc.SetFont(m_fontOld);
1353 }
1354
1355private:
1356 wxDC& m_dc;
1357
1358 wxFont m_fontOld;
1359
1360 DECLARE_NO_COPY_CLASS(wxDCFontChanger)
1361};
1362
1363
8b56b16a 1364#endif // _WX_DC_H_BASE_