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