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