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