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