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
, wxWindow
*window
) = 0;
120 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
) = 0;
121 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
) = 0;
122 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
) = 0;
123 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
) = 0;
124 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
) = 0;
125 virtual wxDCImpl
* CreateScreenDC( wxScreenDC
*owner
) = 0;
126 #if wxUSE_PRINTING_ARCHITECTURE
127 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
) = 0;
130 static void Set(wxDCFactory
*factory
);
131 static wxDCFactory
*Get();
134 static wxDCFactory
*m_factory
;
137 //-----------------------------------------------------------------------------
139 //-----------------------------------------------------------------------------
141 class WXDLLIMPEXP_CORE wxNativeDCFactory
: public wxDCFactory
144 wxNativeDCFactory() {}
146 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
);
147 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
);
148 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
);
149 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
);
150 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
);
151 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
);
152 virtual wxDCImpl
* CreateScreenDC( wxScreenDC
*owner
);
153 #if wxUSE_PRINTING_ARCHITECTURE
154 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
);
158 //-----------------------------------------------------------------------------
160 //-----------------------------------------------------------------------------
162 class WXDLLIMPEXP_CORE wxDCImpl
: public wxObject
165 wxDCImpl( wxDC
*owner
);
168 wxDC
*GetOwner() const { return m_owner
; }
170 wxWindow
* GetWindow() const { return m_window
; }
172 virtual bool IsOk() const { return m_ok
; }
174 // query capabilities
176 virtual bool CanDrawBitmap() const = 0;
177 virtual bool CanGetTextExtent() const = 0;
180 virtual void* GetCairoContext() const
185 // query dimension, colour deps, resolution
187 virtual void DoGetSize(int *width
, int *height
) const = 0;
188 void GetSize(int *width
, int *height
) const
190 DoGetSize(width
, height
);
194 wxSize
GetSize() const
201 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
203 virtual int GetDepth() const = 0;
204 virtual wxSize
GetPPI() const = 0;
206 // Right-To-Left (RTL) modes
208 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
209 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
213 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
214 virtual void EndDoc() { }
216 virtual void StartPage() { }
217 virtual void EndPage() { }
219 // flushing the content of this dc immediately eg onto screen
220 virtual void Flush() { }
224 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
228 if ( x
< m_minX
) m_minX
= x
;
229 if ( y
< m_minY
) m_minY
= y
;
230 if ( x
> m_maxX
) m_maxX
= x
;
231 if ( y
> m_maxY
) m_maxY
= y
;
235 m_isBBoxValid
= true;
243 void ResetBoundingBox()
245 m_isBBoxValid
= false;
247 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
250 wxCoord
MinX() const { return m_minX
; }
251 wxCoord
MaxX() const { return m_maxX
; }
252 wxCoord
MinY() const { return m_minY
; }
253 wxCoord
MaxY() const { return m_maxY
; }
255 // setters and getters
257 virtual void SetFont(const wxFont
& font
) = 0;
258 virtual const wxFont
& GetFont() const { return m_font
; }
260 virtual void SetPen(const wxPen
& pen
) = 0;
261 virtual const wxPen
& GetPen() const { return m_pen
; }
263 virtual void SetBrush(const wxBrush
& brush
) = 0;
264 virtual const wxBrush
& GetBrush() const { return m_brush
; }
266 virtual void SetBackground(const wxBrush
& brush
) = 0;
267 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
269 virtual void SetBackgroundMode(int mode
) = 0;
270 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
272 virtual void SetTextForeground(const wxColour
& colour
)
273 { m_textForegroundColour
= colour
; }
274 virtual const wxColour
& GetTextForeground() const
275 { return m_textForegroundColour
; }
277 virtual void SetTextBackground(const wxColour
& colour
)
278 { m_textBackgroundColour
= colour
; }
279 virtual const wxColour
& GetTextBackground() const
280 { return m_textBackgroundColour
; }
283 virtual void SetPalette(const wxPalette
& palette
) = 0;
284 #endif // wxUSE_PALETTE
286 // inherit the DC attributes (font and colours) from the given window
288 // this is called automatically when a window, client or paint DC is
290 virtual void InheritAttributes(wxWindow
*win
);
295 virtual void SetLogicalFunction(int function
) = 0;
296 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
300 virtual wxCoord
GetCharHeight() const = 0;
301 virtual wxCoord
GetCharWidth() const = 0;
302 virtual void DoGetTextExtent(const wxString
& string
,
303 wxCoord
*x
, wxCoord
*y
,
304 wxCoord
*descent
= NULL
,
305 wxCoord
*externalLeading
= NULL
,
306 const wxFont
*theFont
= NULL
) const = 0;
307 virtual void GetMultiLineTextExtent(const wxString
& string
,
310 wxCoord
*heightLine
= NULL
,
311 const wxFont
*font
= NULL
) const;
312 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
316 virtual void Clear() = 0;
320 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
321 wxCoord width
, wxCoord height
) = 0;
323 // NB: this function works with device coordinates, not the logical ones!
324 virtual void DoSetDeviceClippingRegion(const wxRegion
& region
) = 0;
326 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
327 wxCoord
*w
, wxCoord
*h
) const
334 *w
= m_clipX2
- m_clipX1
;
336 *h
= m_clipY2
- m_clipY1
;
339 virtual void DestroyClippingRegion() { ResetClipping(); }
342 // coordinates conversions and transforms
344 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
345 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
346 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
347 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
348 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
349 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
350 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
351 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
353 virtual void SetMapMode(int mode
);
354 virtual int GetMapMode() const { return m_mappingMode
; }
356 virtual void SetUserScale(double x
, double y
);
357 virtual void GetUserScale(double *x
, double *y
) const
359 if ( x
) *x
= m_userScaleX
;
360 if ( y
) *y
= m_userScaleY
;
363 virtual void SetLogicalScale(double x
, double y
);
364 virtual void GetLogicalScale(double *x
, double *y
)
366 if ( x
) *x
= m_logicalScaleX
;
367 if ( y
) *y
= m_logicalScaleY
;
370 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
371 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
373 if ( x
) *x
= m_logicalOriginX
;
374 if ( y
) *y
= m_logicalOriginY
;
377 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
378 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
380 if ( x
) *x
= m_deviceOriginX
;
381 if ( y
) *y
= m_deviceOriginY
;
384 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
386 virtual void ComputeScaleAndOrigin();
388 // this needs to overidden if the axis is inverted
389 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
391 // ---------------------------------------------------------
392 // the actual drawing API
394 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
395 int style
= wxFLOOD_SURFACE
) = 0;
397 virtual void DoGradientFillLinear(const wxRect
& rect
,
398 const wxColour
& initialColour
,
399 const wxColour
& destColour
,
400 wxDirection nDirection
= wxEAST
);
402 virtual void DoGradientFillConcentric(const wxRect
& rect
,
403 const wxColour
& initialColour
,
404 const wxColour
& destColour
,
405 const wxPoint
& circleCenter
);
407 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
409 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
410 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
412 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
413 wxCoord x2
, wxCoord y2
,
414 wxCoord xc
, wxCoord yc
) = 0;
415 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
416 wxCoord width
, wxCoord height
);
417 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
418 double sa
, double ea
) = 0;
420 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
421 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
422 wxCoord width
, wxCoord height
,
424 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
425 wxCoord width
, wxCoord height
) = 0;
427 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
429 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
430 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
431 bool useMask
= false) = 0;
433 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
434 virtual void DoDrawRotatedText(const wxString
& text
,
435 wxCoord x
, wxCoord y
, double angle
) = 0;
437 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
438 wxCoord width
, wxCoord height
,
440 wxCoord xsrc
, wxCoord ysrc
,
442 bool useMask
= false,
443 wxCoord xsrcMask
= wxDefaultCoord
,
444 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
446 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
447 wxCoord dstWidth
, wxCoord dstHeight
,
449 wxCoord xsrc
, wxCoord ysrc
,
450 wxCoord srcWidth
, wxCoord srcHeight
,
452 bool useMask
= false,
453 wxCoord xsrcMask
= wxDefaultCoord
,
454 wxCoord ysrcMask
= wxDefaultCoord
);
456 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
457 { return wxNullBitmap
; }
460 virtual void DoDrawLines(int n
, wxPoint points
[],
461 wxCoord xoffset
, wxCoord yoffset
) = 0;
462 virtual void DrawLines(const wxPointList
*list
,
463 wxCoord xoffset
, wxCoord yoffset
);
465 virtual void DoDrawPolygon(int n
, wxPoint points
[],
466 wxCoord xoffset
, wxCoord yoffset
,
467 int fillStyle
= wxODDEVEN_RULE
) = 0;
468 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
469 wxCoord xoffset
, wxCoord yoffset
,
471 void DrawPolygon(const wxPointList
*list
,
472 wxCoord xoffset
, wxCoord yoffset
,
477 void DrawSpline(wxCoord x1
, wxCoord y1
,
478 wxCoord x2
, wxCoord y2
,
479 wxCoord x3
, wxCoord y3
);
480 void DrawSpline(int n
, wxPoint points
[]);
481 void DrawSpline(const wxPointList
*points
) { DoDrawSpline(points
); }
483 virtual void DoDrawSpline(const wxPointList
*points
);
486 // ---------------------------------------------------------
487 // wxMemoryDC Impl API
489 virtual void DoSelect(const wxBitmap
& WXUNUSED(bmp
))
492 virtual const wxBitmap
& GetSelectedBitmap() const
493 { return wxNullBitmap
; }
494 virtual wxBitmap
& GetSelectedBitmap()
495 { return wxNullBitmap
; }
497 // ---------------------------------------------------------
498 // wxPrinterDC Impl API
500 virtual wxRect
GetPaperRect()
501 { int w
= 0; int h
= 0; DoGetSize( &w
, &h
); return wxRect(0,0,w
,h
); }
503 virtual int GetResolution()
510 // unset clipping variables (after clipping region was destroyed)
515 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
519 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
520 /*! \param x Upper left corner of bounding box.
521 * \param y Upper left corner of bounding box.
522 * \param w Width of bounding box.
523 * \param h Height of bounding box.
524 * \param sa Starting angle of arc
525 * (counterclockwise, start at 3 o'clock, 360 is full circle).
526 * \param ea Ending angle of arc.
527 * \param angle Rotation angle, the Arc will be rotated after
528 * calculating begin and end.
530 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
531 wxCoord width
, wxCoord height
,
532 double sa
= 0, double ea
= 0, double angle
= 0 )
533 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
535 void DrawEllipticArcRot( const wxPoint
& pt
,
537 double sa
= 0, double ea
= 0, double angle
= 0 )
538 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
540 void DrawEllipticArcRot( const wxRect
& rect
,
541 double sa
= 0, double ea
= 0, double angle
= 0 )
542 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
544 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
545 wxCoord w
, wxCoord h
,
546 double sa
= 0, double ea
= 0, double angle
= 0 );
548 //! Rotates points around center.
549 /*! This is a quite straight method, it calculates in pixels
550 * and so it produces rounding errors.
551 * \param points The points inside will be rotated.
552 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
553 * \param center Center of rotation.
555 void Rotate( wxPointList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
557 // used by DrawEllipticArcRot
558 // Careful: wxList gets filled with points you have to delete later.
559 void CalculateEllipticPoints( wxPointList
* points
,
560 wxCoord xStart
, wxCoord yStart
,
561 wxCoord w
, wxCoord h
,
562 double sa
, double ea
);
563 #endif // __WXWINCE__
565 // returns adjustment factor for converting wxFont "point size"; in wx
566 // it is point size on screen and needs to be multiplied by this value
567 // for rendering on higher-resolution DCs such as printer ones
568 static float GetFontPointSizeAdjustment(float dpi
);
570 // window on which the DC draws or NULL
577 bool m_isInteractive
:1;
578 bool m_isBBoxValid
:1;
580 // coordinate system variables
582 wxCoord m_logicalOriginX
, m_logicalOriginY
;
583 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
585 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
586 // is not at 0,0. This was the case under
587 // Mac's GrafPorts (coordinate system
588 // used toplevel window's origin) and
589 // e.g. for Postscript, where the native
590 // origin in the bottom left corner.
591 double m_logicalScaleX
, m_logicalScaleY
;
592 double m_userScaleX
, m_userScaleY
;
593 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
595 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
597 // what is a mm on a screen you don't know the size of?
598 double m_mm_to_pix_x
,
601 // bounding and clipping boxes
602 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
603 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
605 int m_logicalFunction
;
606 int m_backgroundMode
;
611 wxBrush m_backgroundBrush
;
612 wxColour m_textForegroundColour
;
613 wxColour m_textBackgroundColour
;
618 bool m_hasCustomPalette
;
619 #endif // wxUSE_PALETTE
622 DECLARE_ABSTRACT_CLASS(wxDCImpl
)
626 class WXDLLIMPEXP_CORE wxDC
: public wxObject
629 virtual ~wxDC() { delete m_pimpl
; }
633 const wxDCImpl
*GetImpl() const
636 wxWindow
*GetWindow() const
637 { return m_pimpl
->GetWindow(); }
640 { return m_pimpl
&& m_pimpl
->IsOk(); }
642 // query capabilities
644 bool CanDrawBitmap() const
645 { return m_pimpl
->CanDrawBitmap(); }
646 bool CanGetTextExtent() const
647 { return m_pimpl
->CanGetTextExtent(); }
649 // query dimension, colour deps, resolution
651 void GetSize(int *width
, int *height
) const
652 { m_pimpl
->DoGetSize(width
, height
); }
653 wxSize
GetSize() const
654 { return m_pimpl
->GetSize(); }
656 void GetSizeMM(int* width
, int* height
) const
657 { m_pimpl
->DoGetSizeMM(width
, height
); }
658 wxSize
GetSizeMM() const
661 m_pimpl
->DoGetSizeMM(&w
, &h
);
666 { return m_pimpl
->GetDepth(); }
667 wxSize
GetPPI() const
668 { return m_pimpl
->GetPPI(); }
670 virtual int GetResolution()
671 { return m_pimpl
->GetResolution(); }
673 // Right-To-Left (RTL) modes
675 void SetLayoutDirection(wxLayoutDirection dir
)
676 { m_pimpl
->SetLayoutDirection( dir
); }
677 wxLayoutDirection
GetLayoutDirection() const
678 { return m_pimpl
->GetLayoutDirection(); }
682 bool StartDoc(const wxString
& message
)
683 { return m_pimpl
->StartDoc(message
); }
685 { m_pimpl
->EndDoc(); }
688 { m_pimpl
->StartPage(); }
690 { m_pimpl
->EndPage(); }
694 void CalcBoundingBox(wxCoord x
, wxCoord y
)
695 { m_pimpl
->CalcBoundingBox(x
,y
); }
696 void ResetBoundingBox()
697 { m_pimpl
->ResetBoundingBox(); }
700 { return m_pimpl
->MinX(); }
702 { return m_pimpl
->MaxX(); }
704 { return m_pimpl
->MinY(); }
706 { return m_pimpl
->MaxY(); }
708 // setters and getters
710 void SetFont(const wxFont
& font
)
711 { m_pimpl
->SetFont( font
); }
712 const wxFont
& GetFont() const
713 { return m_pimpl
->GetFont(); }
715 void SetPen(const wxPen
& pen
)
716 { m_pimpl
->SetPen( pen
); }
717 const wxPen
& GetPen() const
718 { return m_pimpl
->GetPen(); }
720 void SetBrush(const wxBrush
& brush
)
721 { m_pimpl
->SetBrush( brush
); }
722 const wxBrush
& GetBrush() const
723 { return m_pimpl
->GetBrush(); }
725 void SetBackground(const wxBrush
& brush
)
726 { m_pimpl
->SetBackground( brush
); }
727 const wxBrush
& GetBackground() const
728 { return m_pimpl
->GetBackground(); }
730 void SetBackgroundMode(int mode
)
731 { m_pimpl
->SetBackgroundMode( mode
); }
732 int GetBackgroundMode() const
733 { return m_pimpl
->GetBackgroundMode(); }
735 void SetTextForeground(const wxColour
& colour
)
736 { m_pimpl
->SetTextForeground(colour
); }
737 const wxColour
& GetTextForeground() const
738 { return m_pimpl
->GetTextForeground(); }
740 void SetTextBackground(const wxColour
& colour
)
741 { m_pimpl
->SetTextBackground(colour
); }
742 const wxColour
& GetTextBackground() const
743 { return m_pimpl
->GetTextBackground(); }
746 void SetPalette(const wxPalette
& palette
)
747 { m_pimpl
->SetPalette(palette
); }
748 #endif // wxUSE_PALETTE
752 void SetLogicalFunction(int function
)
753 { m_pimpl
->SetLogicalFunction(function
); }
754 int GetLogicalFunction() const
755 { return m_pimpl
->GetLogicalFunction(); }
759 wxCoord
GetCharHeight() const
760 { return m_pimpl
->GetCharHeight(); }
761 wxCoord
GetCharWidth() const
762 { return m_pimpl
->GetCharWidth(); }
764 void GetTextExtent(const wxString
& string
,
765 wxCoord
*x
, wxCoord
*y
,
766 wxCoord
*descent
= NULL
,
767 wxCoord
*externalLeading
= NULL
,
768 const wxFont
*theFont
= NULL
) const
769 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
771 wxSize
GetTextExtent(const wxString
& string
) const
774 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
778 void GetMultiLineTextExtent(const wxString
& string
,
781 wxCoord
*heightLine
= NULL
,
782 const wxFont
*font
= NULL
) const
783 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
785 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
788 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
792 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
793 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
798 { m_pimpl
->Clear(); }
802 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
803 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
804 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
805 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
806 void SetClippingRegion(const wxRect
& rect
)
807 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
809 // unlike the functions above, the coordinates of the region used in this
810 // one are in device coordinates, not the logical ones
811 void SetDeviceClippingRegion(const wxRegion
& region
)
812 { m_pimpl
->DoSetDeviceClippingRegion(region
); }
814 // this function is deprecated because its name is confusing: you may
815 // expect it to work with logical coordinates but, in fact, it does exactly
816 // the same thing as SetDeviceClippingRegion()
818 // please review the code using it and either replace it with calls to
819 // SetDeviceClippingRegion() or correct it if it was [wrongly] passing
820 // logical coordinates to this function
821 wxDEPRECATED_INLINE(void SetClippingRegion(const wxRegion
& region
),
822 SetDeviceClippingRegion(region
); )
824 void DestroyClippingRegion()
825 { m_pimpl
->DestroyClippingRegion(); }
827 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
828 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
829 void GetClippingBox(wxRect
& rect
) const
830 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
832 // coordinates conversions and transforms
834 wxCoord
DeviceToLogicalX(wxCoord x
) const
835 { return m_pimpl
->DeviceToLogicalX(x
); }
836 wxCoord
DeviceToLogicalY(wxCoord y
) const
837 { return m_pimpl
->DeviceToLogicalY(y
); }
838 wxCoord
DeviceToLogicalXRel(wxCoord x
) const
839 { return m_pimpl
->DeviceToLogicalXRel(x
); }
840 wxCoord
DeviceToLogicalYRel(wxCoord y
) const
841 { return m_pimpl
->DeviceToLogicalYRel(y
); }
842 wxCoord
LogicalToDeviceX(wxCoord x
) const
843 { return m_pimpl
->LogicalToDeviceX(x
); }
844 wxCoord
LogicalToDeviceY(wxCoord y
) const
845 { return m_pimpl
->LogicalToDeviceY(y
); }
846 wxCoord
LogicalToDeviceXRel(wxCoord x
) const
847 { return m_pimpl
->LogicalToDeviceXRel(x
); }
848 wxCoord
LogicalToDeviceYRel(wxCoord y
) const
849 { return m_pimpl
->LogicalToDeviceYRel(y
); }
851 void SetMapMode(int mode
)
852 { m_pimpl
->SetMapMode(mode
); }
853 int GetMapMode() const
854 { return m_pimpl
->GetMapMode(); }
856 void SetUserScale(double x
, double y
)
857 { m_pimpl
->SetUserScale(x
,y
); }
858 void GetUserScale(double *x
, double *y
) const
859 { m_pimpl
->GetUserScale( x
, y
); }
861 void SetLogicalScale(double x
, double y
)
862 { m_pimpl
->SetLogicalScale( x
, y
); }
863 void GetLogicalScale(double *x
, double *y
)
864 { m_pimpl
->GetLogicalScale( x
, y
); }
866 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
867 { m_pimpl
->SetLogicalOrigin(x
,y
); }
868 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
869 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
870 wxPoint
GetLogicalOrigin() const
871 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
873 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
874 { m_pimpl
->SetDeviceOrigin( x
, y
); }
875 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
876 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
877 wxPoint
GetDeviceOrigin() const
878 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
880 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
881 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
884 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
885 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
888 // draw generic object
890 void DrawObject(wxDrawObject
* drawobject
)
892 drawobject
->Draw(*this);
893 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
894 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
897 // -----------------------------------------------
898 // the actual drawing API
900 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
901 int style
= wxFLOOD_SURFACE
)
902 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
903 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
904 int style
= wxFLOOD_SURFACE
)
905 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
907 // fill the area specified by rect with a radial gradient, starting from
908 // initialColour in the centre of the cercle and fading to destColour.
909 void GradientFillConcentric(const wxRect
& rect
,
910 const wxColour
& initialColour
,
911 const wxColour
& destColour
)
912 { m_pimpl
->DoGradientFillConcentric( rect
, initialColour
, destColour
,
913 wxPoint(rect
.GetWidth() / 2,
914 rect
.GetHeight() / 2)); }
916 void GradientFillConcentric(const wxRect
& rect
,
917 const wxColour
& initialColour
,
918 const wxColour
& destColour
,
919 const wxPoint
& circleCenter
)
920 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
922 // fill the area specified by rect with a linear gradient
923 void GradientFillLinear(const wxRect
& rect
,
924 const wxColour
& initialColour
,
925 const wxColour
& destColour
,
926 wxDirection nDirection
= wxEAST
)
927 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
929 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
930 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
931 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
932 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
934 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
935 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
936 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
937 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
939 void CrossHair(wxCoord x
, wxCoord y
)
940 { m_pimpl
->DoCrossHair(x
, y
); }
941 void CrossHair(const wxPoint
& pt
)
942 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
944 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
945 wxCoord xc
, wxCoord yc
)
946 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
947 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
948 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
950 void DrawCheckMark(wxCoord x
, wxCoord y
,
951 wxCoord width
, wxCoord height
)
952 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
953 void DrawCheckMark(const wxRect
& rect
)
954 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
956 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
957 double sa
, double ea
)
958 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
959 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
960 double sa
, double ea
)
961 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
963 void DrawPoint(wxCoord x
, wxCoord y
)
964 { m_pimpl
->DoDrawPoint(x
, y
); }
965 void DrawPoint(const wxPoint
& pt
)
966 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
968 void DrawLines(int n
, wxPoint points
[],
969 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
970 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
971 void DrawLines(const wxPointList
*list
,
972 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
973 { m_pimpl
->DrawLines( list
, xoffset
, yoffset
); }
974 #if WXWIN_COMPATIBILITY_2_8
975 wxDEPRECATED( void DrawLines(const wxList
*list
,
976 wxCoord xoffset
= 0, wxCoord yoffset
= 0) );
977 #endif // WXWIN_COMPATIBILITY_2_8
979 void DrawPolygon(int n
, wxPoint points
[],
980 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
981 int fillStyle
= wxODDEVEN_RULE
)
982 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
983 void DrawPolygon(const wxPointList
*list
,
984 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
985 int fillStyle
= wxODDEVEN_RULE
)
986 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
987 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
988 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
989 int fillStyle
= wxODDEVEN_RULE
)
990 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
991 #if WXWIN_COMPATIBILITY_2_8
992 wxDEPRECATED( void DrawPolygon(const wxList
*list
,
993 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
994 int fillStyle
= wxODDEVEN_RULE
) );
995 #endif // WXWIN_COMPATIBILITY_2_8
997 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
998 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
999 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
1000 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1001 void DrawRectangle(const wxRect
& rect
)
1002 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1004 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
1006 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
1007 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
1009 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
1010 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
1011 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1013 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1014 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1015 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1016 { m_pimpl
->DoDrawEllipse(pt
.x
- radius
, pt
.y
- radius
, 2*radius
, 2*radius
); }
1018 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1019 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
1020 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1021 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1022 void DrawEllipse(const wxRect
& rect
)
1023 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1025 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1026 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
1027 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1028 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1030 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1031 bool useMask
= false)
1032 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
1033 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1034 bool useMask
= false)
1035 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1037 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1038 { m_pimpl
->DoDrawText(text
, x
, y
); }
1039 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1040 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
1042 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1043 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
1044 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1045 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1047 // this version puts both optional bitmap and the text into the given
1048 // rectangle and aligns is as specified by alignment parameter; it also
1049 // will emphasize the character with the given index if it is != -1 and
1050 // return the bounding rectangle if required
1051 void DrawLabel(const wxString
& text
,
1052 const wxBitmap
& image
,
1054 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1055 int indexAccel
= -1,
1056 wxRect
*rectBounding
= NULL
);
1058 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1059 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1060 int indexAccel
= -1)
1061 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1063 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1064 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1065 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1067 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
1068 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1070 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1071 wxDC
*source
, const wxPoint
& srcPt
,
1072 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
1074 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1075 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1078 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1079 wxCoord dstWidth
, wxCoord dstHeight
,
1081 wxCoord srcX
, wxCoord srcY
,
1082 wxCoord srcWidth
, wxCoord srcHeight
,
1083 int rop
= wxCOPY
, bool useMask
= false,
1084 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1086 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1087 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1089 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1090 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1091 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1093 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1094 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1097 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1099 return m_pimpl
->DoGetAsBitmap(subrect
);
1103 void DrawSpline(wxCoord x1
, wxCoord y1
,
1104 wxCoord x2
, wxCoord y2
,
1105 wxCoord x3
, wxCoord y3
)
1106 { m_pimpl
->DrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
1107 void DrawSpline(int n
, wxPoint points
[])
1108 { m_pimpl
->DrawSpline(n
,points
); }
1109 void DrawSpline(const wxPointList
*points
)
1110 { m_pimpl
->DrawSpline(points
); }
1111 #endif // wxUSE_SPLINES
1114 #if WXWIN_COMPATIBILITY_2_8
1115 // for compatibility with the old code when wxCoord was long everywhere
1116 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1118 long *descent
= NULL
,
1119 long *externalLeading
= NULL
,
1120 const wxFont
*theFont
= NULL
) const );
1121 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1122 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1123 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1125 #endif // WXWIN_COMPATIBILITY_2_8
1128 WXHDC
GetHDC() const;
1132 // ctor takes ownership of the pointer
1133 wxDC(wxDCImpl
*pimpl
) : m_pimpl(pimpl
) { }
1135 wxDCImpl
* const m_pimpl
;
1138 DECLARE_ABSTRACT_CLASS(wxDC
)
1139 DECLARE_NO_COPY_CLASS(wxDC
)
1142 // ----------------------------------------------------------------------------
1143 // helper class: you can use it to temporarily change the DC text colour and
1144 // restore it automatically when the object goes out of scope
1145 // ----------------------------------------------------------------------------
1147 class WXDLLIMPEXP_CORE wxDCTextColourChanger
1150 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1152 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1157 ~wxDCTextColourChanger()
1159 if ( m_colFgOld
.Ok() )
1160 m_dc
.SetTextForeground(m_colFgOld
);
1163 void Set(const wxColour
& col
)
1165 if ( !m_colFgOld
.Ok() )
1166 m_colFgOld
= m_dc
.GetTextForeground();
1167 m_dc
.SetTextForeground(col
);
1173 wxColour m_colFgOld
;
1175 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
1178 // ----------------------------------------------------------------------------
1179 // helper class: you can use it to temporarily change the DC pen and
1180 // restore it automatically when the object goes out of scope
1181 // ----------------------------------------------------------------------------
1183 class WXDLLIMPEXP_CORE wxDCPenChanger
1186 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1193 if ( m_penOld
.Ok() )
1194 m_dc
.SetPen(m_penOld
);
1202 DECLARE_NO_COPY_CLASS(wxDCPenChanger
)
1205 // ----------------------------------------------------------------------------
1206 // helper class: you can use it to temporarily change the DC brush and
1207 // restore it automatically when the object goes out of scope
1208 // ----------------------------------------------------------------------------
1210 class WXDLLIMPEXP_CORE wxDCBrushChanger
1213 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1215 m_dc
.SetBrush(brush
);
1220 if ( m_brushOld
.Ok() )
1221 m_dc
.SetBrush(m_brushOld
);
1229 DECLARE_NO_COPY_CLASS(wxDCBrushChanger
)
1232 // ----------------------------------------------------------------------------
1233 // another small helper class: sets the clipping region in its ctor and
1234 // destroys it in the dtor
1235 // ----------------------------------------------------------------------------
1237 class WXDLLIMPEXP_CORE wxDCClipper
1240 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1241 { dc
.SetClippingRegion(r
.GetBox()); }
1242 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1243 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1244 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1245 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1247 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1252 DECLARE_NO_COPY_CLASS(wxDCClipper
)
1255 #endif // _WX_DC_H_BASE_