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