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