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