]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dc.h
using common code
[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() {}
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
2970ae54
RR
131
132 static void SetDCFactory( wxDCFactory *factory );
133 static wxDCFactory *GetFactory();
134private:
135 static wxDCFactory *m_factory;
136};
137
138//-----------------------------------------------------------------------------
139// wxNativeDCFactory
140//-----------------------------------------------------------------------------
141
ab171e95 142class WXDLLIMPEXP_CORE wxNativeDCFactory: public wxDCFactory
2970ae54
RR
143{
144public:
145 wxNativeDCFactory() {}
146
888dde65
RR
147 virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner );
148 virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner, wxWindow *window );
149 virtual wxDCImpl* CreateClientDC( wxClientDC *owner );
150 virtual wxDCImpl* CreateClientDC( wxClientDC *owner, wxWindow *window );
151 virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner );
152 virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner, wxWindow *window );
153 virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner );
154 virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap );
155 virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc );
156 virtual wxDCImpl* CreateScreenDC( wxScreenDC *owner );
6b4f4d47 157#if wxUSE_PRINTING_ARCHITECTURE
888dde65 158 virtual wxDCImpl* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data );
6b4f4d47 159#endif
2970ae54
RR
160};
161
2970ae54 162//-----------------------------------------------------------------------------
888dde65 163// wxDCImpl
2970ae54
RR
164//-----------------------------------------------------------------------------
165
888dde65 166class WXDLLIMPEXP_CORE wxDCImpl: public wxObject
2970ae54
RR
167{
168public:
888dde65
RR
169 wxDCImpl( wxDC *owner );
170 ~wxDCImpl();
2970ae54 171
ab171e95 172 wxDC *GetOwner() const { return m_owner; }
2970ae54 173
888dde65
RR
174 wxWindow* GetWindow() const { return m_window; }
175
2970ae54
RR
176 virtual bool IsOk() const { return m_ok; }
177
178 // query capabilities
179
180 virtual bool CanDrawBitmap() const = 0;
181 virtual bool CanGetTextExtent() const = 0;
182
183 // query dimension, colour deps, resolution
184
185 virtual void DoGetSize(int *width, int *height) const = 0;
186 virtual void DoGetSizeMM(int* width, int* height) const = 0;
187
188 virtual int GetDepth() const = 0;
189 virtual wxSize GetPPI() const = 0;
190
191 // Right-To-Left (RTL) modes
192
193 virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) { }
194 virtual wxLayoutDirection GetLayoutDirection() const { return wxLayout_Default; }
195
196 // page and document
197
198 virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; }
199 virtual void EndDoc() { }
200
201 virtual void StartPage() { }
202 virtual void EndPage() { }
203
cc18b1c7
SC
204 // flushing the content of this dc immediately eg onto screen
205 virtual void Flush() { }
206
2970ae54
RR
207 // bounding box
208
ca7db61e 209 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
2970ae54
RR
210 {
211 if ( m_isBBoxValid )
212 {
213 if ( x < m_minX ) m_minX = x;
214 if ( y < m_minY ) m_minY = y;
215 if ( x > m_maxX ) m_maxX = x;
216 if ( y > m_maxY ) m_maxY = y;
217 }
218 else
219 {
220 m_isBBoxValid = true;
221
222 m_minX = x;
223 m_minY = y;
224 m_maxX = x;
225 m_maxY = y;
226 }
227 }
ca7db61e 228 void ResetBoundingBox()
2970ae54
RR
229 {
230 m_isBBoxValid = false;
231
232 m_minX = m_maxX = m_minY = m_maxY = 0;
233 }
234
235 wxCoord MinX() const { return m_minX; }
236 wxCoord MaxX() const { return m_maxX; }
237 wxCoord MinY() const { return m_minY; }
238 wxCoord MaxY() const { return m_maxY; }
239
240 // setters and getters
241
242 virtual void SetFont(const wxFont& font) = 0;
243 virtual const wxFont& GetFont() const { return m_font; }
244
245 virtual void SetPen(const wxPen& pen) = 0;
246 virtual const wxPen& GetPen() const { return m_pen; }
247
248 virtual void SetBrush(const wxBrush& brush) = 0;
249 virtual const wxBrush& GetBrush() const { return m_brush; }
250
251 virtual void SetBackground(const wxBrush& brush) = 0;
252 virtual const wxBrush& GetBackground() const { return m_backgroundBrush; }
253
254 virtual void SetBackgroundMode(int mode) = 0;
255 virtual int GetBackgroundMode() const { return m_backgroundMode; }
256
257 virtual void SetTextForeground(const wxColour& colour)
258 { m_textForegroundColour = colour; }
259 virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; }
260
261 virtual void SetTextBackground(const wxColour& colour)
262 { m_textBackgroundColour = colour; }
263 virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
264
265#if wxUSE_PALETTE
266 virtual void SetPalette(const wxPalette& palette) = 0;
267#endif // wxUSE_PALETTE
268
269 // logical functions
270
271 virtual void SetLogicalFunction(int function) = 0;
272 virtual int GetLogicalFunction() const { return m_logicalFunction; }
273
274 // text measurement
275
276 virtual wxCoord GetCharHeight() const = 0;
277 virtual wxCoord GetCharWidth() const = 0;
278 virtual void DoGetTextExtent(const wxString& string,
279 wxCoord *x, wxCoord *y,
280 wxCoord *descent = NULL,
281 wxCoord *externalLeading = NULL,
282 const wxFont *theFont = NULL) const = 0;
283 virtual void GetMultiLineTextExtent(const wxString& string,
284 wxCoord *width,
285 wxCoord *height,
286 wxCoord *heightLine = NULL,
287 const wxFont *font = NULL) const;
288 virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
289
290 // clearing
291
292 virtual void Clear() = 0;
293
294 // clipping
295
296 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
297 wxCoord width, wxCoord height) = 0;
298 virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0;
299
300 virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
301 wxCoord *w, wxCoord *h) const
302 {
303 if ( x )
304 *x = m_clipX1;
305 if ( y )
306 *y = m_clipY1;
307 if ( w )
308 *w = m_clipX2 - m_clipX1;
309 if ( h )
310 *h = m_clipY2 - m_clipY1;
311 }
312
313 virtual void DestroyClippingRegion() { ResetClipping(); }
314
315
316 // coordinates conversions and transforms
317
318 virtual wxCoord DeviceToLogicalX(wxCoord x) const;
319 virtual wxCoord DeviceToLogicalY(wxCoord y) const;
320 virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
321 virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
322 virtual wxCoord LogicalToDeviceX(wxCoord x) const;
323 virtual wxCoord LogicalToDeviceY(wxCoord y) const;
324 virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
325 virtual wxCoord LogicalToDeviceYRel(wxCoord y) const;
326
327 virtual void SetMapMode(int mode);
328 virtual int GetMapMode() const { return m_mappingMode; }
329
330 virtual void SetUserScale(double x, double y);
331 virtual void GetUserScale(double *x, double *y) const
332 {
333 if ( x ) *x = m_userScaleX;
334 if ( y ) *y = m_userScaleY;
335 }
336
337 virtual void SetLogicalScale(double x, double y);
338 virtual void GetLogicalScale(double *x, double *y)
339 {
340 if ( x ) *x = m_logicalScaleX;
341 if ( y ) *y = m_logicalScaleY;
342 }
343
344 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
345 virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
346 {
347 if ( x ) *x = m_logicalOriginX;
348 if ( y ) *y = m_logicalOriginY;
349 }
350
351 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
352 virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
353 {
354 if ( x ) *x = m_deviceOriginX;
355 if ( y ) *y = m_deviceOriginY;
356 }
357
358 virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y );
359
360 virtual void ComputeScaleAndOrigin();
361
362 // this needs to overidden if the axis is inverted
363 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
364
365 // ---------------------------------------------------------
366 // the actual drawing API
367
368 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
369 int style = wxFLOOD_SURFACE) = 0;
370
371 virtual void DoGradientFillLinear(const wxRect& rect,
372 const wxColour& initialColour,
373 const wxColour& destColour,
374 wxDirection nDirection = wxEAST);
375
376 virtual void DoGradientFillConcentric(const wxRect& rect,
377 const wxColour& initialColour,
378 const wxColour& destColour,
379 const wxPoint& circleCenter);
380
381 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
382
383 virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
384 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
385
386 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
387 wxCoord x2, wxCoord y2,
388 wxCoord xc, wxCoord yc) = 0;
389 virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
390 wxCoord width, wxCoord height);
391 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
392 double sa, double ea) = 0;
393
394 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
395 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
396 wxCoord width, wxCoord height,
397 double radius) = 0;
398 virtual void DoDrawEllipse(wxCoord x, wxCoord y,
399 wxCoord width, wxCoord height) = 0;
400
401 virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
402
403 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
404 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
405 bool useMask = false) = 0;
406
407 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
408 virtual void DoDrawRotatedText(const wxString& text,
409 wxCoord x, wxCoord y, double angle) = 0;
410
411 virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
412 wxCoord width, wxCoord height,
413 wxDC *source,
414 wxCoord xsrc, wxCoord ysrc,
415 int rop = wxCOPY,
416 bool useMask = false,
417 wxCoord xsrcMask = wxDefaultCoord,
418 wxCoord ysrcMask = wxDefaultCoord) = 0;
419
420 virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest,
421 wxCoord dstWidth, wxCoord dstHeight,
422 wxDC *source,
423 wxCoord xsrc, wxCoord ysrc,
424 wxCoord srcWidth, wxCoord srcHeight,
425 int rop = wxCOPY,
426 bool useMask = false,
427 wxCoord xsrcMask = wxDefaultCoord,
428 wxCoord ysrcMask = wxDefaultCoord);
429
430 virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const
431 { return wxNullBitmap; }
432
433
434 virtual void DoDrawLines(int n, wxPoint points[],
4f37154e
RR
435 wxCoord xoffset, wxCoord yoffset ) = 0;
436 virtual void DrawLines(const wxPointList *list,
437 wxCoord xoffset, wxCoord yoffset );
438
2970ae54
RR
439 virtual void DoDrawPolygon(int n, wxPoint points[],
440 wxCoord xoffset, wxCoord yoffset,
441 int fillStyle = wxODDEVEN_RULE) = 0;
442 virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
443 wxCoord xoffset, wxCoord yoffset,
444 int fillStyle);
4f37154e
RR
445 void DrawPolygon(const wxPointList *list,
446 wxCoord xoffset, wxCoord yoffset,
447 int fillStyle );
2970ae54
RR
448
449
450#if wxUSE_SPLINES
ca7db61e
RR
451 virtual void DoDrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3);
452 virtual void DoDrawSpline(int n, wxPoint points[]);
b0d7707b 453 virtual void DoDrawSpline(const wxPointList *points);
2970ae54
RR
454#endif
455
4f37154e
RR
456 // ---------------------------------------------------------
457 // wxMemoryDC Impl API
458
459 virtual void DoSelect(const wxBitmap& WXUNUSED(bmp))
460 { }
461
462 virtual const wxBitmap& GetSelectedBitmap() const
463 { return wxNullBitmap; }
464 virtual wxBitmap& GetSelectedBitmap()
465 { return wxNullBitmap; }
466
467 // ---------------------------------------------------------
468 // wxPrinterDC Impl API
469
470 virtual wxRect GetPaperRect()
471 { int w = 0; int h = 0; DoGetSize( &w, &h ); return wxRect(0,0,w,h); }
472
473 virtual int GetResolution()
474 { return -1; }
475
2970ae54 476private:
888dde65 477 wxDC *m_owner;
2970ae54
RR
478
479protected:
480 // unset clipping variables (after clipping region was destroyed)
481 void ResetClipping()
482 {
483 m_clipping = false;
484
485 m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0;
486 }
487
888dde65
RR
488 // window on which the DC draws or NULL
489 wxWindow *m_window;
490
2970ae54
RR
491 // flags
492 bool m_colour:1;
493 bool m_ok:1;
494 bool m_clipping:1;
495 bool m_isInteractive:1;
496 bool m_isBBoxValid:1;
497
498 // coordinate system variables
499
500 wxCoord m_logicalOriginX, m_logicalOriginY;
501 wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user
502
503 wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner
504 // is not at 0,0. This was the case under
505 // Mac's GrafPorts (coordinate system
506 // used toplevel window's origin) and
507 // e.g. for Postscript, where the native
508 // origin in the bottom left corner.
509 double m_logicalScaleX, m_logicalScaleY;
510 double m_userScaleX, m_userScaleY;
511 double m_scaleX, m_scaleY; // calculated from logical scale and user scale
512
513 int m_signX, m_signY; // Used by SetAxisOrientation() to invert the axes
514
515 // what is a mm on a screen you don't know the size of?
516 double m_mm_to_pix_x,
517 m_mm_to_pix_y;
518
519 // bounding and clipping boxes
520 wxCoord m_minX, m_minY, m_maxX, m_maxY;
521 wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
522
523 int m_logicalFunction;
524 int m_backgroundMode;
525 int m_mappingMode;
526
527 wxPen m_pen;
528 wxBrush m_brush;
529 wxBrush m_backgroundBrush;
530 wxColour m_textForegroundColour;
531 wxColour m_textBackgroundColour;
532 wxFont m_font;
533
534#if wxUSE_PALETTE
535 wxPalette m_palette;
536 bool m_hasCustomPalette;
537#endif // wxUSE_PALETTE
538
539private:
888dde65 540 DECLARE_ABSTRACT_CLASS(wxDCImpl)
ca7db61e 541};
2970ae54
RR
542
543
888dde65 544class WXDLLIMPEXP_CORE wxDC: public wxObject
2970ae54
RR
545{
546public:
547 wxDC() { m_pimpl = NULL; }
888dde65 548 ~wxDC() { if (m_pimpl) 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
2970ae54
RR
558 bool IsOk() const
559 { return m_pimpl && m_pimpl->IsOk(); }
560
561 // query capabilities
562
563 bool CanDrawBitmap() const
564 { return m_pimpl->CanDrawBitmap(); }
565 bool CanGetTextExtent() const
566 { return m_pimpl->CanGetTextExtent(); }
567
568 // query dimension, colour deps, resolution
569
570 void GetSize(int *width, int *height) const
571 { m_pimpl->DoGetSize(width, height); }
572
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 }
588
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(); }
596
2970ae54
RR
597 // Right-To-Left (RTL) modes
598
599 void SetLayoutDirection(wxLayoutDirection dir)
600 { m_pimpl->SetLayoutDirection( dir ); }
601 wxLayoutDirection GetLayoutDirection() const
602 { return m_pimpl->GetLayoutDirection(); }
603
604 // page and document
605
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
617
618 void CalcBoundingBox(wxCoord x, wxCoord y)
619 { m_pimpl->CalcBoundingBox(x,y); }
620 void ResetBoundingBox()
621 { m_pimpl->ResetBoundingBox(); }
622
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(); }
631
632 // setters and getters
633
634 void SetFont(const wxFont& font)
635 { m_pimpl->SetFont( font ); }
636 const wxFont& GetFont() const
637 { return m_pimpl->GetFont(); }
638
639 void SetPen(const wxPen& pen)
640 { m_pimpl->SetPen( pen ); }
641 const wxPen& GetPen() const
642 { return m_pimpl->GetPen(); }
643
644 void SetBrush(const wxBrush& brush)
645 { m_pimpl->SetBrush( brush ); }
646 const wxBrush& GetBrush() const
647 { return m_pimpl->GetBrush(); }
648
649 void SetBackground(const wxBrush& brush)
650 { m_pimpl->SetBackground( brush ); }
651 const wxBrush& GetBackground() const
652 { return m_pimpl->GetBackground(); }
653
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(); }
663
664 void SetTextBackground(const wxColour& colour)
665 { m_pimpl->SetTextBackground(colour); }
666 const wxColour& GetTextBackground() const
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
673
674 // logical functions
675
676 void SetLogicalFunction(int function)
677 { m_pimpl->SetLogicalFunction(function); }
678 int GetLogicalFunction() const
679 { return m_pimpl->GetLogicalFunction(); }
680
681 // text measurement
682
683 wxCoord GetCharHeight() const
684 { return m_pimpl->GetCharHeight(); }
685 wxCoord GetCharWidth() const
686 { return m_pimpl->GetCharWidth(); }
687
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 }
701
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 ); }
708
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 }
715
716 bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
717 { return m_pimpl->DoGetPartialTextExtents(text, widths); }
718
719 // clearing
720
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); }
742
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); }
793
794 // mostly internal
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)
4f37154e
RR
884 { m_pimpl->DrawLines( list, xoffset, yoffset ); }
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
989 bool StretchBlit(wxCoord dstX, wxCoord dstY,
990 wxCoord dstWidth, wxCoord dstHeight,
991 wxDC *source,
992 wxCoord srcX, wxCoord srcY,
993 wxCoord srcWidth, wxCoord srcHeight,
994 int rop = wxCOPY, bool useMask = false,
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); }
b0d7707b 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:
888dde65 1039 wxDCImpl *m_pimpl;
aec43716 1040
ca7db61e 1041private:
888dde65 1042 DECLARE_ABSTRACT_CLASS(wxDC)
ca7db61e 1043};
aec43716 1044
1e6feb95
VZ
1045// ----------------------------------------------------------------------------
1046// helper class: you can use it to temporarily change the DC text colour and
1047// restore it automatically when the object goes out of scope
1048// ----------------------------------------------------------------------------
1049
1050class WXDLLEXPORT wxDCTextColourChanger
1051{
1052public:
ba161d7e 1053 wxDCTextColourChanger(wxDC& dc) : m_dc(dc), m_colFgOld() { }
1e6feb95 1054
1b97b23d
VS
1055 wxDCTextColourChanger(wxDC& dc, const wxColour& col) : m_dc(dc)
1056 {
1057 Set(col);
1058 }
1059
1e6feb95
VZ
1060 ~wxDCTextColourChanger()
1061 {
1062 if ( m_colFgOld.Ok() )
1063 m_dc.SetTextForeground(m_colFgOld);
1064 }
1065
1066 void Set(const wxColour& col)
1067 {
1068 if ( !m_colFgOld.Ok() )
1069 m_colFgOld = m_dc.GetTextForeground();
1070 m_dc.SetTextForeground(col);
1071 }
1072
1073private:
1074 wxDC& m_dc;
1075
1076 wxColour m_colFgOld;
fc7a2a60
VZ
1077
1078 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger)
1e6feb95
VZ
1079};
1080
4660e6ac
WS
1081// ----------------------------------------------------------------------------
1082// helper class: you can use it to temporarily change the DC pen and
1083// restore it automatically when the object goes out of scope
1084// ----------------------------------------------------------------------------
1085
1086class WXDLLEXPORT wxDCPenChanger
1087{
1088public:
0164f8eb
WS
1089 wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen())
1090 {
1091 m_dc.SetPen(pen);
1092 }
4660e6ac
WS
1093
1094 ~wxDCPenChanger()
1095 {
1096 if ( m_penOld.Ok() )
1097 m_dc.SetPen(m_penOld);
1098 }
1099
4660e6ac
WS
1100private:
1101 wxDC& m_dc;
1102
1103 wxPen m_penOld;
1104
1105 DECLARE_NO_COPY_CLASS(wxDCPenChanger)
1106};
1107
1108// ----------------------------------------------------------------------------
1109// helper class: you can use it to temporarily change the DC brush and
1110// restore it automatically when the object goes out of scope
1111// ----------------------------------------------------------------------------
1112
1113class WXDLLEXPORT wxDCBrushChanger
1114{
1115public:
0164f8eb
WS
1116 wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush())
1117 {
1118 m_dc.SetBrush(brush);
1119 }
4660e6ac
WS
1120
1121 ~wxDCBrushChanger()
1122 {
1123 if ( m_brushOld.Ok() )
1124 m_dc.SetBrush(m_brushOld);
1125 }
1126
4660e6ac
WS
1127private:
1128 wxDC& m_dc;
1129
1130 wxBrush m_brushOld;
1131
1132 DECLARE_NO_COPY_CLASS(wxDCBrushChanger)
1133};
1134
e26be42b
VZ
1135// ----------------------------------------------------------------------------
1136// another small helper class: sets the clipping region in its ctor and
1137// destroys it in the dtor
1138// ----------------------------------------------------------------------------
1139
1140class WXDLLEXPORT wxDCClipper
1141{
1142public:
fc298ea7
VZ
1143 wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc)
1144 { dc.SetClippingRegion(r); }
e26be42b
VZ
1145 wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc)
1146 { dc.SetClippingRegion(r.x, r.y, r.width, r.height); }
1147 wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc)
1148 { dc.SetClippingRegion(x, y, w, h); }
1149
1150 ~wxDCClipper() { m_dc.DestroyClippingRegion(); }
1151
1152private:
1153 wxDC& m_dc;
fc7a2a60
VZ
1154
1155 DECLARE_NO_COPY_CLASS(wxDCClipper)
e26be42b
VZ
1156};
1157
8b56b16a 1158#endif // _WX_DC_H_BASE_