1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DC_H_BASE_
13 #define _WX_DC_H_BASE_
15 // ----------------------------------------------------------------------------
16 // headers which we must include here
17 // ----------------------------------------------------------------------------
19 #include "wx/object.h" // the base class
21 #include "wx/intl.h" // for wxLayoutDirection
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"
25 #include "wx/bitmap.h" // for wxNullBitmap
28 #include "wx/palette.h"
29 #include "wx/dynarray.h"
32 #include "wx/cmndata.h"
34 #define wxUSE_NEW_DC 1
36 class WXDLLIMPEXP_FWD_CORE wxDC
;
37 class WXDLLIMPEXP_FWD_CORE wxClientDC
;
38 class WXDLLIMPEXP_FWD_CORE wxPaintDC
;
39 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
40 class WXDLLIMPEXP_FWD_CORE wxScreenDC
;
41 class WXDLLIMPEXP_FWD_CORE wxMemoryDC
;
42 class WXDLLIMPEXP_FWD_CORE wxPrinterDC
;
43 class WXDLLIMPEXP_FWD_CORE wxPrintData
;
45 //-----------------------------------------------------------------------------
46 // wxDrawObject helper class
47 //-----------------------------------------------------------------------------
49 class WXDLLIMPEXP_CORE wxDrawObject
54 : m_isBBoxValid(false)
55 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
58 virtual ~wxDrawObject() { }
60 virtual void Draw(wxDC
&) const { }
62 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
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
;
82 void ResetBoundingBox()
84 m_isBBoxValid
= false;
86 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
89 // Get the final bounding box of the PostScript or Metafile picture.
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
; }
96 //to define the type of object for derived objects
97 virtual int GetType()=0;
100 //for boundingbox calculation
101 bool m_isBBoxValid
:1;
102 //for boundingbox calculation
103 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
107 //-----------------------------------------------------------------------------
109 //-----------------------------------------------------------------------------
111 class WXDLLIMPEXP_FWD_CORE wxDCImpl
;
113 class WXDLLIMPEXP_CORE wxDCFactory
117 virtual ~wxDCFactory() {}
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;
129 #if wxUSE_PRINTING_ARCHITECTURE
130 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
) = 0;
133 static void Set(wxDCFactory
*factory
);
134 static wxDCFactory
*Get();
137 static wxDCFactory
*m_factory
;
140 //-----------------------------------------------------------------------------
142 //-----------------------------------------------------------------------------
144 class WXDLLIMPEXP_CORE wxNativeDCFactory
: public wxDCFactory
147 wxNativeDCFactory() {}
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
);
159 #if wxUSE_PRINTING_ARCHITECTURE
160 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
);
164 //-----------------------------------------------------------------------------
166 //-----------------------------------------------------------------------------
168 class WXDLLIMPEXP_CORE wxDCImpl
: public wxObject
171 wxDCImpl( wxDC
*owner
);
174 wxDC
*GetOwner() const { return m_owner
; }
176 wxWindow
* GetWindow() const { return m_window
; }
178 virtual bool IsOk() const { return m_ok
; }
180 // query capabilities
182 virtual bool CanDrawBitmap() const = 0;
183 virtual bool CanGetTextExtent() const = 0;
186 virtual void* GetCairoContext() const
191 // query dimension, colour deps, resolution
193 virtual void DoGetSize(int *width
, int *height
) const = 0;
194 void GetSize(int *width
, int *height
) const
196 DoGetSize(width
, height
);
200 wxSize
GetSize() const
207 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
209 virtual int GetDepth() const = 0;
210 virtual wxSize
GetPPI() const = 0;
212 // Right-To-Left (RTL) modes
214 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
215 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
219 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
220 virtual void EndDoc() { }
222 virtual void StartPage() { }
223 virtual void EndPage() { }
225 // flushing the content of this dc immediately eg onto screen
226 virtual void Flush() { }
230 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
234 if ( x
< m_minX
) m_minX
= x
;
235 if ( y
< m_minY
) m_minY
= y
;
236 if ( x
> m_maxX
) m_maxX
= x
;
237 if ( y
> m_maxY
) m_maxY
= y
;
241 m_isBBoxValid
= true;
249 void ResetBoundingBox()
251 m_isBBoxValid
= false;
253 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
256 wxCoord
MinX() const { return m_minX
; }
257 wxCoord
MaxX() const { return m_maxX
; }
258 wxCoord
MinY() const { return m_minY
; }
259 wxCoord
MaxY() const { return m_maxY
; }
261 // setters and getters
263 virtual void SetFont(const wxFont
& font
) = 0;
264 virtual const wxFont
& GetFont() const { return m_font
; }
266 virtual void SetPen(const wxPen
& pen
) = 0;
267 virtual const wxPen
& GetPen() const { return m_pen
; }
269 virtual void SetBrush(const wxBrush
& brush
) = 0;
270 virtual const wxBrush
& GetBrush() const { return m_brush
; }
272 virtual void SetBackground(const wxBrush
& brush
) = 0;
273 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
275 virtual void SetBackgroundMode(int mode
) = 0;
276 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
278 virtual void SetTextForeground(const wxColour
& colour
)
279 { m_textForegroundColour
= colour
; }
280 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
282 virtual void SetTextBackground(const wxColour
& colour
)
283 { m_textBackgroundColour
= colour
; }
284 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
287 virtual void SetPalette(const wxPalette
& palette
) = 0;
288 #endif // wxUSE_PALETTE
292 virtual void SetLogicalFunction(int function
) = 0;
293 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
297 virtual wxCoord
GetCharHeight() const = 0;
298 virtual wxCoord
GetCharWidth() const = 0;
299 virtual void DoGetTextExtent(const wxString
& string
,
300 wxCoord
*x
, wxCoord
*y
,
301 wxCoord
*descent
= NULL
,
302 wxCoord
*externalLeading
= NULL
,
303 const wxFont
*theFont
= NULL
) const = 0;
304 virtual void GetMultiLineTextExtent(const wxString
& string
,
307 wxCoord
*heightLine
= NULL
,
308 const wxFont
*font
= NULL
) const;
309 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
313 virtual void Clear() = 0;
317 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
318 wxCoord width
, wxCoord height
) = 0;
320 // NB: this function works with device coordinates, not the logical ones!
321 virtual void DoSetDeviceClippingRegion(const wxRegion
& region
) = 0;
323 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
324 wxCoord
*w
, wxCoord
*h
) const
331 *w
= m_clipX2
- m_clipX1
;
333 *h
= m_clipY2
- m_clipY1
;
336 virtual void DestroyClippingRegion() { ResetClipping(); }
339 // coordinates conversions and transforms
341 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
342 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
343 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
344 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
345 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
346 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
347 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
348 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
350 virtual void SetMapMode(int mode
);
351 virtual int GetMapMode() const { return m_mappingMode
; }
353 virtual void SetUserScale(double x
, double y
);
354 virtual void GetUserScale(double *x
, double *y
) const
356 if ( x
) *x
= m_userScaleX
;
357 if ( y
) *y
= m_userScaleY
;
360 virtual void SetLogicalScale(double x
, double y
);
361 virtual void GetLogicalScale(double *x
, double *y
)
363 if ( x
) *x
= m_logicalScaleX
;
364 if ( y
) *y
= m_logicalScaleY
;
367 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
368 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
370 if ( x
) *x
= m_logicalOriginX
;
371 if ( y
) *y
= m_logicalOriginY
;
374 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
375 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
377 if ( x
) *x
= m_deviceOriginX
;
378 if ( y
) *y
= m_deviceOriginY
;
381 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
383 virtual void ComputeScaleAndOrigin();
385 // this needs to overidden if the axis is inverted
386 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
388 // ---------------------------------------------------------
389 // the actual drawing API
391 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
392 int style
= wxFLOOD_SURFACE
) = 0;
394 virtual void DoGradientFillLinear(const wxRect
& rect
,
395 const wxColour
& initialColour
,
396 const wxColour
& destColour
,
397 wxDirection nDirection
= wxEAST
);
399 virtual void DoGradientFillConcentric(const wxRect
& rect
,
400 const wxColour
& initialColour
,
401 const wxColour
& destColour
,
402 const wxPoint
& circleCenter
);
404 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
406 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
407 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
409 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
410 wxCoord x2
, wxCoord y2
,
411 wxCoord xc
, wxCoord yc
) = 0;
412 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
413 wxCoord width
, wxCoord height
);
414 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
415 double sa
, double ea
) = 0;
417 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
418 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
419 wxCoord width
, wxCoord height
,
421 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
422 wxCoord width
, wxCoord height
) = 0;
424 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
426 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
427 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
428 bool useMask
= false) = 0;
430 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
431 virtual void DoDrawRotatedText(const wxString
& text
,
432 wxCoord x
, wxCoord y
, double angle
) = 0;
434 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
435 wxCoord width
, wxCoord height
,
437 wxCoord xsrc
, wxCoord ysrc
,
439 bool useMask
= false,
440 wxCoord xsrcMask
= wxDefaultCoord
,
441 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
443 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
444 wxCoord dstWidth
, wxCoord dstHeight
,
446 wxCoord xsrc
, wxCoord ysrc
,
447 wxCoord srcWidth
, wxCoord srcHeight
,
449 bool useMask
= false,
450 wxCoord xsrcMask
= wxDefaultCoord
,
451 wxCoord ysrcMask
= wxDefaultCoord
);
453 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
454 { return wxNullBitmap
; }
457 virtual void DoDrawLines(int n
, wxPoint points
[],
458 wxCoord xoffset
, wxCoord yoffset
) = 0;
459 virtual void DrawLines(const wxPointList
*list
,
460 wxCoord xoffset
, wxCoord yoffset
);
462 virtual void DoDrawPolygon(int n
, wxPoint points
[],
463 wxCoord xoffset
, wxCoord yoffset
,
464 int fillStyle
= wxODDEVEN_RULE
) = 0;
465 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
466 wxCoord xoffset
, wxCoord yoffset
,
468 void DrawPolygon(const wxPointList
*list
,
469 wxCoord xoffset
, wxCoord yoffset
,
474 void DrawSpline(wxCoord x1
, wxCoord y1
,
475 wxCoord x2
, wxCoord y2
,
476 wxCoord x3
, wxCoord y3
);
477 void DrawSpline(int n
, wxPoint points
[]);
478 void DrawSpline(const wxPointList
*points
) { DoDrawSpline(points
); }
480 virtual void DoDrawSpline(const wxPointList
*points
);
483 // ---------------------------------------------------------
484 // wxMemoryDC Impl API
486 virtual void DoSelect(const wxBitmap
& WXUNUSED(bmp
))
489 virtual const wxBitmap
& GetSelectedBitmap() const
490 { return wxNullBitmap
; }
491 virtual wxBitmap
& GetSelectedBitmap()
492 { return wxNullBitmap
; }
494 // ---------------------------------------------------------
495 // wxPrinterDC Impl API
497 virtual wxRect
GetPaperRect()
498 { int w
= 0; int h
= 0; DoGetSize( &w
, &h
); return wxRect(0,0,w
,h
); }
500 virtual int GetResolution()
507 // unset clipping variables (after clipping region was destroyed)
512 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
516 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
517 /*! \param x Upper left corner of bounding box.
518 * \param y Upper left corner of bounding box.
519 * \param w Width of bounding box.
520 * \param h Height of bounding box.
521 * \param sa Starting angle of arc
522 * (counterclockwise, start at 3 o'clock, 360 is full circle).
523 * \param ea Ending angle of arc.
524 * \param angle Rotation angle, the Arc will be rotated after
525 * calculating begin and end.
527 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
528 wxCoord width
, wxCoord height
,
529 double sa
= 0, double ea
= 0, double angle
= 0 )
530 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
532 void DrawEllipticArcRot( const wxPoint
& pt
,
534 double sa
= 0, double ea
= 0, double angle
= 0 )
535 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
537 void DrawEllipticArcRot( const wxRect
& rect
,
538 double sa
= 0, double ea
= 0, double angle
= 0 )
539 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
541 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
542 wxCoord w
, wxCoord h
,
543 double sa
= 0, double ea
= 0, double angle
= 0 );
545 //! Rotates points around center.
546 /*! This is a quite straight method, it calculates in pixels
547 * and so it produces rounding errors.
548 * \param points The points inside will be rotated.
549 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
550 * \param center Center of rotation.
552 void Rotate( wxPointList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
554 // used by DrawEllipticArcRot
555 // Careful: wxList gets filled with points you have to delete later.
556 void CalculateEllipticPoints( wxPointList
* points
,
557 wxCoord xStart
, wxCoord yStart
,
558 wxCoord w
, wxCoord h
,
559 double sa
, double ea
);
560 #endif // __WXWINCE__
563 // window on which the DC draws or NULL
570 bool m_isInteractive
:1;
571 bool m_isBBoxValid
:1;
573 // coordinate system variables
575 wxCoord m_logicalOriginX
, m_logicalOriginY
;
576 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
578 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
579 // is not at 0,0. This was the case under
580 // Mac's GrafPorts (coordinate system
581 // used toplevel window's origin) and
582 // e.g. for Postscript, where the native
583 // origin in the bottom left corner.
584 double m_logicalScaleX
, m_logicalScaleY
;
585 double m_userScaleX
, m_userScaleY
;
586 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
588 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
590 // what is a mm on a screen you don't know the size of?
591 double m_mm_to_pix_x
,
594 // bounding and clipping boxes
595 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
596 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
598 int m_logicalFunction
;
599 int m_backgroundMode
;
604 wxBrush m_backgroundBrush
;
605 wxColour m_textForegroundColour
;
606 wxColour m_textBackgroundColour
;
611 bool m_hasCustomPalette
;
612 #endif // wxUSE_PALETTE
615 DECLARE_ABSTRACT_CLASS(wxDCImpl
)
619 class WXDLLIMPEXP_CORE wxDC
: public wxObject
622 virtual ~wxDC() { delete m_pimpl
; }
626 const wxDCImpl
*GetImpl() const
629 wxWindow
*GetWindow() const
630 { return m_pimpl
->GetWindow(); }
633 { return m_pimpl
&& m_pimpl
->IsOk(); }
635 // query capabilities
637 bool CanDrawBitmap() const
638 { return m_pimpl
->CanDrawBitmap(); }
639 bool CanGetTextExtent() const
640 { return m_pimpl
->CanGetTextExtent(); }
642 // query dimension, colour deps, resolution
644 void GetSize(int *width
, int *height
) const
645 { m_pimpl
->DoGetSize(width
, height
); }
646 wxSize
GetSize() const
647 { return m_pimpl
->GetSize(); }
649 void GetSizeMM(int* width
, int* height
) const
650 { m_pimpl
->DoGetSizeMM(width
, height
); }
651 wxSize
GetSizeMM() const
654 m_pimpl
->DoGetSizeMM(&w
, &h
);
659 { return m_pimpl
->GetDepth(); }
660 wxSize
GetPPI() const
661 { return m_pimpl
->GetPPI(); }
663 virtual int GetResolution()
664 { return m_pimpl
->GetResolution(); }
666 // Right-To-Left (RTL) modes
668 void SetLayoutDirection(wxLayoutDirection dir
)
669 { m_pimpl
->SetLayoutDirection( dir
); }
670 wxLayoutDirection
GetLayoutDirection() const
671 { return m_pimpl
->GetLayoutDirection(); }
675 bool StartDoc(const wxString
& message
)
676 { return m_pimpl
->StartDoc(message
); }
678 { m_pimpl
->EndDoc(); }
681 { m_pimpl
->StartPage(); }
683 { m_pimpl
->EndPage(); }
687 void CalcBoundingBox(wxCoord x
, wxCoord y
)
688 { m_pimpl
->CalcBoundingBox(x
,y
); }
689 void ResetBoundingBox()
690 { m_pimpl
->ResetBoundingBox(); }
693 { return m_pimpl
->MinX(); }
695 { return m_pimpl
->MaxX(); }
697 { return m_pimpl
->MinY(); }
699 { return m_pimpl
->MaxY(); }
701 // setters and getters
703 void SetFont(const wxFont
& font
)
704 { m_pimpl
->SetFont( font
); }
705 const wxFont
& GetFont() const
706 { return m_pimpl
->GetFont(); }
708 void SetPen(const wxPen
& pen
)
709 { m_pimpl
->SetPen( pen
); }
710 const wxPen
& GetPen() const
711 { return m_pimpl
->GetPen(); }
713 void SetBrush(const wxBrush
& brush
)
714 { m_pimpl
->SetBrush( brush
); }
715 const wxBrush
& GetBrush() const
716 { return m_pimpl
->GetBrush(); }
718 void SetBackground(const wxBrush
& brush
)
719 { m_pimpl
->SetBackground( brush
); }
720 const wxBrush
& GetBackground() const
721 { return m_pimpl
->GetBackground(); }
723 void SetBackgroundMode(int mode
)
724 { m_pimpl
->SetBackgroundMode( mode
); }
725 int GetBackgroundMode() const
726 { return m_pimpl
->GetBackgroundMode(); }
728 void SetTextForeground(const wxColour
& colour
)
729 { m_pimpl
->SetTextForeground(colour
); }
730 const wxColour
& GetTextForeground() const
731 { return m_pimpl
->GetTextForeground(); }
733 void SetTextBackground(const wxColour
& colour
)
734 { m_pimpl
->SetTextBackground(colour
); }
735 const wxColour
& GetTextBackground() const
736 { return m_pimpl
->GetTextBackground(); }
739 void SetPalette(const wxPalette
& palette
)
740 { m_pimpl
->SetPalette(palette
); }
741 #endif // wxUSE_PALETTE
745 void SetLogicalFunction(int function
)
746 { m_pimpl
->SetLogicalFunction(function
); }
747 int GetLogicalFunction() const
748 { return m_pimpl
->GetLogicalFunction(); }
752 wxCoord
GetCharHeight() const
753 { return m_pimpl
->GetCharHeight(); }
754 wxCoord
GetCharWidth() const
755 { return m_pimpl
->GetCharWidth(); }
757 void GetTextExtent(const wxString
& string
,
758 wxCoord
*x
, wxCoord
*y
,
759 wxCoord
*descent
= NULL
,
760 wxCoord
*externalLeading
= NULL
,
761 const wxFont
*theFont
= NULL
) const
762 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
764 wxSize
GetTextExtent(const wxString
& string
) const
767 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
771 void GetMultiLineTextExtent(const wxString
& string
,
774 wxCoord
*heightLine
= NULL
,
775 const wxFont
*font
= NULL
) const
776 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
778 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
781 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
785 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
786 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
791 { m_pimpl
->Clear(); }
795 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
796 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
797 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
798 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
799 void SetClippingRegion(const wxRect
& rect
)
800 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
802 // unlike the functions above, the coordinates of the region used in this
803 // one are in device coordinates, not the logical ones
804 void SetDeviceClippingRegion(const wxRegion
& region
)
805 { m_pimpl
->DoSetDeviceClippingRegion(region
); }
807 // this function is deprecated because its name is confusing: you may
808 // expect it to work with logical coordinates but, in fact, it does exactly
809 // the same thing as SetDeviceClippingRegion()
811 // please review the code using it and either replace it with calls to
812 // SetDeviceClippingRegion() or correct it if it was [wrongly] passing
813 // logical coordinates to this function
814 wxDEPRECATED_INLINE(void SetClippingRegion(const wxRegion
& region
),
815 SetDeviceClippingRegion(region
); )
817 void DestroyClippingRegion()
818 { m_pimpl
->DestroyClippingRegion(); }
820 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
821 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
822 void GetClippingBox(wxRect
& rect
) const
823 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
825 // coordinates conversions and transforms
827 wxCoord
DeviceToLogicalX(wxCoord x
) const
828 { return m_pimpl
->DeviceToLogicalX(x
); }
829 wxCoord
DeviceToLogicalY(wxCoord y
) const
830 { return m_pimpl
->DeviceToLogicalY(y
); }
831 wxCoord
DeviceToLogicalXRel(wxCoord x
) const
832 { return m_pimpl
->DeviceToLogicalXRel(x
); }
833 wxCoord
DeviceToLogicalYRel(wxCoord y
) const
834 { return m_pimpl
->DeviceToLogicalYRel(y
); }
835 wxCoord
LogicalToDeviceX(wxCoord x
) const
836 { return m_pimpl
->LogicalToDeviceX(x
); }
837 wxCoord
LogicalToDeviceY(wxCoord y
) const
838 { return m_pimpl
->LogicalToDeviceY(y
); }
839 wxCoord
LogicalToDeviceXRel(wxCoord x
) const
840 { return m_pimpl
->LogicalToDeviceXRel(x
); }
841 wxCoord
LogicalToDeviceYRel(wxCoord y
) const
842 { return m_pimpl
->LogicalToDeviceYRel(y
); }
844 void SetMapMode(int mode
)
845 { m_pimpl
->SetMapMode(mode
); }
846 int GetMapMode() const
847 { return m_pimpl
->GetMapMode(); }
849 void SetUserScale(double x
, double y
)
850 { m_pimpl
->SetUserScale(x
,y
); }
851 void GetUserScale(double *x
, double *y
) const
852 { m_pimpl
->GetUserScale( x
, y
); }
854 void SetLogicalScale(double x
, double y
)
855 { m_pimpl
->SetLogicalScale( x
, y
); }
856 void GetLogicalScale(double *x
, double *y
)
857 { m_pimpl
->GetLogicalScale( x
, y
); }
859 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
860 { m_pimpl
->SetLogicalOrigin(x
,y
); }
861 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
862 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
863 wxPoint
GetLogicalOrigin() const
864 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
866 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
867 { m_pimpl
->SetDeviceOrigin( x
, y
); }
868 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
869 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
870 wxPoint
GetDeviceOrigin() const
871 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
873 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
874 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
877 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
878 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
881 // draw generic object
883 void DrawObject(wxDrawObject
* drawobject
)
885 drawobject
->Draw(*this);
886 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
887 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
890 // -----------------------------------------------
891 // the actual drawing API
893 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
894 int style
= wxFLOOD_SURFACE
)
895 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
896 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
897 int style
= wxFLOOD_SURFACE
)
898 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
900 // fill the area specified by rect with a radial gradient, starting from
901 // initialColour in the centre of the cercle and fading to destColour.
902 void GradientFillConcentric(const wxRect
& rect
,
903 const wxColour
& initialColour
,
904 const wxColour
& destColour
)
905 { m_pimpl
->DoGradientFillConcentric( rect
, initialColour
, destColour
,
906 wxPoint(rect
.GetWidth() / 2,
907 rect
.GetHeight() / 2)); }
909 void GradientFillConcentric(const wxRect
& rect
,
910 const wxColour
& initialColour
,
911 const wxColour
& destColour
,
912 const wxPoint
& circleCenter
)
913 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
915 // fill the area specified by rect with a linear gradient
916 void GradientFillLinear(const wxRect
& rect
,
917 const wxColour
& initialColour
,
918 const wxColour
& destColour
,
919 wxDirection nDirection
= wxEAST
)
920 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
922 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
923 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
924 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
925 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
927 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
928 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
929 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
930 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
932 void CrossHair(wxCoord x
, wxCoord y
)
933 { m_pimpl
->DoCrossHair(x
, y
); }
934 void CrossHair(const wxPoint
& pt
)
935 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
937 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
938 wxCoord xc
, wxCoord yc
)
939 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
940 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
941 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
943 void DrawCheckMark(wxCoord x
, wxCoord y
,
944 wxCoord width
, wxCoord height
)
945 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
946 void DrawCheckMark(const wxRect
& rect
)
947 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
949 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
950 double sa
, double ea
)
951 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
952 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
953 double sa
, double ea
)
954 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
956 void DrawPoint(wxCoord x
, wxCoord y
)
957 { m_pimpl
->DoDrawPoint(x
, y
); }
958 void DrawPoint(const wxPoint
& pt
)
959 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
961 void DrawLines(int n
, wxPoint points
[],
962 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
963 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
964 void DrawLines(const wxPointList
*list
,
965 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
966 { m_pimpl
->DrawLines( list
, xoffset
, yoffset
); }
967 #if WXWIN_COMPATIBILITY_2_8
968 wxDEPRECATED( void DrawLines(const wxList
*list
,
969 wxCoord xoffset
= 0, wxCoord yoffset
= 0) );
970 #endif // WXWIN_COMPATIBILITY_2_8
972 void DrawPolygon(int n
, wxPoint points
[],
973 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
974 int fillStyle
= wxODDEVEN_RULE
)
975 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
976 void DrawPolygon(const wxPointList
*list
,
977 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
978 int fillStyle
= wxODDEVEN_RULE
)
979 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
980 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
981 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
982 int fillStyle
= wxODDEVEN_RULE
)
983 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
984 #if WXWIN_COMPATIBILITY_2_8
985 wxDEPRECATED( void DrawPolygon(const wxList
*list
,
986 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
987 int fillStyle
= wxODDEVEN_RULE
) );
988 #endif // WXWIN_COMPATIBILITY_2_8
990 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
991 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
992 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
993 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
994 void DrawRectangle(const wxRect
& rect
)
995 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
997 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
999 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
1000 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
1002 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
1003 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
1004 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1006 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1007 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1008 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1009 { m_pimpl
->DoDrawEllipse(pt
.x
- radius
, pt
.y
- radius
, 2*radius
, 2*radius
); }
1011 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1012 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
1013 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1014 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1015 void DrawEllipse(const wxRect
& rect
)
1016 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1018 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1019 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
1020 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1021 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1023 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1024 bool useMask
= false)
1025 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
1026 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1027 bool useMask
= false)
1028 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1030 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1031 { m_pimpl
->DoDrawText(text
, x
, y
); }
1032 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1033 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
1035 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1036 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
1037 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1038 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1040 // this version puts both optional bitmap and the text into the given
1041 // rectangle and aligns is as specified by alignment parameter; it also
1042 // will emphasize the character with the given index if it is != -1 and
1043 // return the bounding rectangle if required
1044 void DrawLabel(const wxString
& text
,
1045 const wxBitmap
& image
,
1047 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1048 int indexAccel
= -1,
1049 wxRect
*rectBounding
= NULL
);
1051 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1052 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1053 int indexAccel
= -1)
1054 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1056 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1057 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1058 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1060 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
1061 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1063 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1064 wxDC
*source
, const wxPoint
& srcPt
,
1065 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
1067 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1068 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1071 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1072 wxCoord dstWidth
, wxCoord dstHeight
,
1074 wxCoord srcX
, wxCoord srcY
,
1075 wxCoord srcWidth
, wxCoord srcHeight
,
1076 int rop
= wxCOPY
, bool useMask
= false,
1077 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1079 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1080 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1082 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1083 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1084 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1086 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1087 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1090 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1092 return m_pimpl
->DoGetAsBitmap(subrect
);
1096 void DrawSpline(wxCoord x1
, wxCoord y1
,
1097 wxCoord x2
, wxCoord y2
,
1098 wxCoord x3
, wxCoord y3
)
1099 { m_pimpl
->DrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
1100 void DrawSpline(int n
, wxPoint points
[])
1101 { m_pimpl
->DrawSpline(n
,points
); }
1102 void DrawSpline(const wxPointList
*points
)
1103 { m_pimpl
->DrawSpline(points
); }
1104 #endif // wxUSE_SPLINES
1107 #if WXWIN_COMPATIBILITY_2_8
1108 // for compatibility with the old code when wxCoord was long everywhere
1109 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1111 long *descent
= NULL
,
1112 long *externalLeading
= NULL
,
1113 const wxFont
*theFont
= NULL
) const );
1114 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1115 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1116 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1117 #endif // WXWIN_COMPATIBILITY_2_8
1121 // ctor takes ownership of the pointer
1122 wxDC(wxDCImpl
*pimpl
) : m_pimpl(pimpl
) { }
1124 wxDCImpl
* const m_pimpl
;
1127 DECLARE_ABSTRACT_CLASS(wxDC
)
1128 DECLARE_NO_COPY_CLASS(wxDC
)
1131 // ----------------------------------------------------------------------------
1132 // helper class: you can use it to temporarily change the DC text colour and
1133 // restore it automatically when the object goes out of scope
1134 // ----------------------------------------------------------------------------
1136 class WXDLLIMPEXP_CORE wxDCTextColourChanger
1139 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1141 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1146 ~wxDCTextColourChanger()
1148 if ( m_colFgOld
.Ok() )
1149 m_dc
.SetTextForeground(m_colFgOld
);
1152 void Set(const wxColour
& col
)
1154 if ( !m_colFgOld
.Ok() )
1155 m_colFgOld
= m_dc
.GetTextForeground();
1156 m_dc
.SetTextForeground(col
);
1162 wxColour m_colFgOld
;
1164 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
1167 // ----------------------------------------------------------------------------
1168 // helper class: you can use it to temporarily change the DC pen and
1169 // restore it automatically when the object goes out of scope
1170 // ----------------------------------------------------------------------------
1172 class WXDLLIMPEXP_CORE wxDCPenChanger
1175 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1182 if ( m_penOld
.Ok() )
1183 m_dc
.SetPen(m_penOld
);
1191 DECLARE_NO_COPY_CLASS(wxDCPenChanger
)
1194 // ----------------------------------------------------------------------------
1195 // helper class: you can use it to temporarily change the DC brush and
1196 // restore it automatically when the object goes out of scope
1197 // ----------------------------------------------------------------------------
1199 class WXDLLIMPEXP_CORE wxDCBrushChanger
1202 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1204 m_dc
.SetBrush(brush
);
1209 if ( m_brushOld
.Ok() )
1210 m_dc
.SetBrush(m_brushOld
);
1218 DECLARE_NO_COPY_CLASS(wxDCBrushChanger
)
1221 // ----------------------------------------------------------------------------
1222 // another small helper class: sets the clipping region in its ctor and
1223 // destroys it in the dtor
1224 // ----------------------------------------------------------------------------
1226 class WXDLLIMPEXP_CORE wxDCClipper
1229 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1230 { dc
.SetClippingRegion(r
.GetBox()); }
1231 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1232 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1233 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1234 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1236 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1241 DECLARE_NO_COPY_CLASS(wxDCClipper
)
1244 #endif // _WX_DC_H_BASE_