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
;
46 #if wxUSE_GRAPHICS_CONTEXT
47 class WXDLLIMPEXP_FWD_CORE wxGraphicsContext
;
50 //-----------------------------------------------------------------------------
51 // wxDrawObject helper class
52 //-----------------------------------------------------------------------------
54 class WXDLLIMPEXP_CORE wxDrawObject
59 : m_isBBoxValid(false)
60 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
63 virtual ~wxDrawObject() { }
65 virtual void Draw(wxDC
&) const { }
67 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
71 if ( x
< m_minX
) m_minX
= x
;
72 if ( y
< m_minY
) m_minY
= y
;
73 if ( x
> m_maxX
) m_maxX
= x
;
74 if ( y
> m_maxY
) m_maxY
= y
;
87 void ResetBoundingBox()
89 m_isBBoxValid
= false;
91 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
94 // Get the final bounding box of the PostScript or Metafile picture.
96 wxCoord
MinX() const { return m_minX
; }
97 wxCoord
MaxX() const { return m_maxX
; }
98 wxCoord
MinY() const { return m_minY
; }
99 wxCoord
MaxY() const { return m_maxY
; }
101 //to define the type of object for derived objects
102 virtual int GetType()=0;
105 //for boundingbox calculation
106 bool m_isBBoxValid
:1;
107 //for boundingbox calculation
108 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
112 //-----------------------------------------------------------------------------
114 //-----------------------------------------------------------------------------
116 class WXDLLIMPEXP_FWD_CORE wxDCImpl
;
118 class WXDLLIMPEXP_CORE wxDCFactory
122 virtual ~wxDCFactory() {}
124 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
) = 0;
125 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
) = 0;
126 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
) = 0;
127 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
) = 0;
128 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
) = 0;
129 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
) = 0;
130 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
) = 0;
131 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
) = 0;
132 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
) = 0;
133 virtual wxDCImpl
* CreateScreenDC( wxScreenDC
*owner
) = 0;
134 #if wxUSE_PRINTING_ARCHITECTURE
135 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
) = 0;
138 static void Set(wxDCFactory
*factory
);
139 static wxDCFactory
*Get();
142 static wxDCFactory
*m_factory
;
145 //-----------------------------------------------------------------------------
147 //-----------------------------------------------------------------------------
149 class WXDLLIMPEXP_CORE wxNativeDCFactory
: public wxDCFactory
152 wxNativeDCFactory() {}
154 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
);
155 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
);
156 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
);
157 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
);
158 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
);
159 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
);
160 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
);
161 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
);
162 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
);
163 virtual wxDCImpl
* CreateScreenDC( wxScreenDC
*owner
);
164 #if wxUSE_PRINTING_ARCHITECTURE
165 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
);
169 //-----------------------------------------------------------------------------
171 //-----------------------------------------------------------------------------
173 class WXDLLIMPEXP_CORE wxDCImpl
: public wxObject
176 wxDCImpl( wxDC
*owner
);
179 wxDC
*GetOwner() const { return m_owner
; }
181 wxWindow
* GetWindow() const { return m_window
; }
183 virtual bool IsOk() const { return m_ok
; }
185 // query capabilities
187 virtual bool CanDrawBitmap() const = 0;
188 virtual bool CanGetTextExtent() const = 0;
190 // get graphics context from
192 #if wxUSE_GRAPHICS_CONTEXT
193 virtual wxGraphicsContext
* CreateGraphicsContext()
199 // query dimension, colour deps, resolution
201 virtual void DoGetSize(int *width
, int *height
) const = 0;
202 void GetSize(int *width
, int *height
) const
204 DoGetSize(width
, height
);
208 wxSize
GetSize() const
215 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
217 virtual int GetDepth() const = 0;
218 virtual wxSize
GetPPI() const = 0;
220 // Right-To-Left (RTL) modes
222 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
223 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
227 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
228 virtual void EndDoc() { }
230 virtual void StartPage() { }
231 virtual void EndPage() { }
233 // flushing the content of this dc immediately eg onto screen
234 virtual void Flush() { }
238 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
242 if ( x
< m_minX
) m_minX
= x
;
243 if ( y
< m_minY
) m_minY
= y
;
244 if ( x
> m_maxX
) m_maxX
= x
;
245 if ( y
> m_maxY
) m_maxY
= y
;
249 m_isBBoxValid
= true;
257 void ResetBoundingBox()
259 m_isBBoxValid
= false;
261 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
264 wxCoord
MinX() const { return m_minX
; }
265 wxCoord
MaxX() const { return m_maxX
; }
266 wxCoord
MinY() const { return m_minY
; }
267 wxCoord
MaxY() const { return m_maxY
; }
269 // setters and getters
271 virtual void SetFont(const wxFont
& font
) = 0;
272 virtual const wxFont
& GetFont() const { return m_font
; }
274 virtual void SetPen(const wxPen
& pen
) = 0;
275 virtual const wxPen
& GetPen() const { return m_pen
; }
277 virtual void SetBrush(const wxBrush
& brush
) = 0;
278 virtual const wxBrush
& GetBrush() const { return m_brush
; }
280 virtual void SetBackground(const wxBrush
& brush
) = 0;
281 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
283 virtual void SetBackgroundMode(int mode
) = 0;
284 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
286 virtual void SetTextForeground(const wxColour
& colour
)
287 { m_textForegroundColour
= colour
; }
288 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
290 virtual void SetTextBackground(const wxColour
& colour
)
291 { m_textBackgroundColour
= colour
; }
292 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
295 virtual void SetPalette(const wxPalette
& palette
) = 0;
296 #endif // wxUSE_PALETTE
300 virtual void SetLogicalFunction(int function
) = 0;
301 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
305 virtual wxCoord
GetCharHeight() const = 0;
306 virtual wxCoord
GetCharWidth() const = 0;
307 virtual void DoGetTextExtent(const wxString
& string
,
308 wxCoord
*x
, wxCoord
*y
,
309 wxCoord
*descent
= NULL
,
310 wxCoord
*externalLeading
= NULL
,
311 const wxFont
*theFont
= NULL
) const = 0;
312 virtual void GetMultiLineTextExtent(const wxString
& string
,
315 wxCoord
*heightLine
= NULL
,
316 const wxFont
*font
= NULL
) const;
317 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
321 virtual void Clear() = 0;
325 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
326 wxCoord width
, wxCoord height
) = 0;
327 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
329 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
330 wxCoord
*w
, wxCoord
*h
) const
337 *w
= m_clipX2
- m_clipX1
;
339 *h
= m_clipY2
- m_clipY1
;
342 virtual void DestroyClippingRegion() { ResetClipping(); }
345 // coordinates conversions and transforms
347 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
348 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
349 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
350 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
351 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
352 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
353 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
354 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
356 virtual void SetMapMode(int mode
);
357 virtual int GetMapMode() const { return m_mappingMode
; }
359 virtual void SetUserScale(double x
, double y
);
360 virtual void GetUserScale(double *x
, double *y
) const
362 if ( x
) *x
= m_userScaleX
;
363 if ( y
) *y
= m_userScaleY
;
366 virtual void SetLogicalScale(double x
, double y
);
367 virtual void GetLogicalScale(double *x
, double *y
)
369 if ( x
) *x
= m_logicalScaleX
;
370 if ( y
) *y
= m_logicalScaleY
;
373 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
374 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
376 if ( x
) *x
= m_logicalOriginX
;
377 if ( y
) *y
= m_logicalOriginY
;
380 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
381 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
383 if ( x
) *x
= m_deviceOriginX
;
384 if ( y
) *y
= m_deviceOriginY
;
387 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
389 virtual void ComputeScaleAndOrigin();
391 // this needs to overidden if the axis is inverted
392 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
394 // ---------------------------------------------------------
395 // the actual drawing API
397 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
398 int style
= wxFLOOD_SURFACE
) = 0;
400 virtual void DoGradientFillLinear(const wxRect
& rect
,
401 const wxColour
& initialColour
,
402 const wxColour
& destColour
,
403 wxDirection nDirection
= wxEAST
);
405 virtual void DoGradientFillConcentric(const wxRect
& rect
,
406 const wxColour
& initialColour
,
407 const wxColour
& destColour
,
408 const wxPoint
& circleCenter
);
410 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
412 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
413 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
415 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
416 wxCoord x2
, wxCoord y2
,
417 wxCoord xc
, wxCoord yc
) = 0;
418 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
419 wxCoord width
, wxCoord height
);
420 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
421 double sa
, double ea
) = 0;
423 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
424 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
425 wxCoord width
, wxCoord height
,
427 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
428 wxCoord width
, wxCoord height
) = 0;
430 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
432 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
433 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
434 bool useMask
= false) = 0;
436 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
437 virtual void DoDrawRotatedText(const wxString
& text
,
438 wxCoord x
, wxCoord y
, double angle
) = 0;
440 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
441 wxCoord width
, wxCoord height
,
443 wxCoord xsrc
, wxCoord ysrc
,
445 bool useMask
= false,
446 wxCoord xsrcMask
= wxDefaultCoord
,
447 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
449 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
450 wxCoord dstWidth
, wxCoord dstHeight
,
452 wxCoord xsrc
, wxCoord ysrc
,
453 wxCoord srcWidth
, wxCoord srcHeight
,
455 bool useMask
= false,
456 wxCoord xsrcMask
= wxDefaultCoord
,
457 wxCoord ysrcMask
= wxDefaultCoord
);
459 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
460 { return wxNullBitmap
; }
463 virtual void DoDrawLines(int n
, wxPoint points
[],
464 wxCoord xoffset
, wxCoord yoffset
) = 0;
465 virtual void DrawLines(const wxPointList
*list
,
466 wxCoord xoffset
, wxCoord yoffset
);
468 virtual void DoDrawPolygon(int n
, wxPoint points
[],
469 wxCoord xoffset
, wxCoord yoffset
,
470 int fillStyle
= wxODDEVEN_RULE
) = 0;
471 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
472 wxCoord xoffset
, wxCoord yoffset
,
474 void DrawPolygon(const wxPointList
*list
,
475 wxCoord xoffset
, wxCoord yoffset
,
480 virtual void DoDrawSpline(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
, wxCoord x3
, wxCoord y3
);
481 virtual void DoDrawSpline(int n
, wxPoint points
[]);
482 virtual void DoDrawSpline(const wxPointList
*points
);
485 // ---------------------------------------------------------
486 // wxMemoryDC Impl API
488 virtual void DoSelect(const wxBitmap
& WXUNUSED(bmp
))
491 virtual const wxBitmap
& GetSelectedBitmap() const
492 { return wxNullBitmap
; }
493 virtual wxBitmap
& GetSelectedBitmap()
494 { return wxNullBitmap
; }
496 // ---------------------------------------------------------
497 // wxPrinterDC Impl API
499 virtual wxRect
GetPaperRect()
500 { int w
= 0; int h
= 0; DoGetSize( &w
, &h
); return wxRect(0,0,w
,h
); }
502 virtual int GetResolution()
509 // unset clipping variables (after clipping region was destroyed)
514 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
518 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
519 /*! \param x Upper left corner of bounding box.
520 * \param y Upper left corner of bounding box.
521 * \param w Width of bounding box.
522 * \param h Height of bounding box.
523 * \param sa Starting angle of arc
524 * (counterclockwise, start at 3 o'clock, 360 is full circle).
525 * \param ea Ending angle of arc.
526 * \param angle Rotation angle, the Arc will be rotated after
527 * calculating begin and end.
529 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
530 wxCoord width
, wxCoord height
,
531 double sa
= 0, double ea
= 0, double angle
= 0 )
532 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
534 void DrawEllipticArcRot( const wxPoint
& pt
,
536 double sa
= 0, double ea
= 0, double angle
= 0 )
537 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
539 void DrawEllipticArcRot( const wxRect
& rect
,
540 double sa
= 0, double ea
= 0, double angle
= 0 )
541 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
543 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
544 wxCoord w
, wxCoord h
,
545 double sa
= 0, double ea
= 0, double angle
= 0 );
547 //! Rotates points around center.
548 /*! This is a quite straight method, it calculates in pixels
549 * and so it produces rounding errors.
550 * \param points The points inside will be rotated.
551 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
552 * \param center Center of rotation.
554 void Rotate( wxPointList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
556 // used by DrawEllipticArcRot
557 // Careful: wxList gets filled with points you have to delete later.
558 void CalculateEllipticPoints( wxPointList
* points
,
559 wxCoord xStart
, wxCoord yStart
,
560 wxCoord w
, wxCoord h
,
561 double sa
, double ea
);
562 #endif // __WXWINCE__
565 // window on which the DC draws or NULL
572 bool m_isInteractive
:1;
573 bool m_isBBoxValid
:1;
575 // coordinate system variables
577 wxCoord m_logicalOriginX
, m_logicalOriginY
;
578 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
580 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
581 // is not at 0,0. This was the case under
582 // Mac's GrafPorts (coordinate system
583 // used toplevel window's origin) and
584 // e.g. for Postscript, where the native
585 // origin in the bottom left corner.
586 double m_logicalScaleX
, m_logicalScaleY
;
587 double m_userScaleX
, m_userScaleY
;
588 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
590 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
592 // what is a mm on a screen you don't know the size of?
593 double m_mm_to_pix_x
,
596 // bounding and clipping boxes
597 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
598 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
600 int m_logicalFunction
;
601 int m_backgroundMode
;
606 wxBrush m_backgroundBrush
;
607 wxColour m_textForegroundColour
;
608 wxColour m_textBackgroundColour
;
613 bool m_hasCustomPalette
;
614 #endif // wxUSE_PALETTE
617 DECLARE_ABSTRACT_CLASS(wxDCImpl
)
621 class WXDLLIMPEXP_CORE wxDC
: public wxObject
624 virtual ~wxDC() { delete m_pimpl
; }
628 const wxDCImpl
*GetImpl() const
631 wxWindow
*GetWindow() const
632 { return m_pimpl
->GetWindow(); }
635 { return m_pimpl
&& m_pimpl
->IsOk(); }
637 #if wxUSE_GRAPHICS_CONTEXT
638 wxGraphicsContext
* CreateGraphicsContext()
639 { return m_pimpl
->CreateGraphicsContext(); }
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
); }
808 void SetClippingRegion(const wxRegion
& region
)
809 { m_pimpl
->DoSetClippingRegionAsRegion(region
); }
811 void DestroyClippingRegion()
812 { m_pimpl
->DestroyClippingRegion(); }
814 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
815 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
816 void GetClippingBox(wxRect
& rect
) const
817 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
819 // coordinates conversions and transforms
821 wxCoord
DeviceToLogicalX(wxCoord x
) const
822 { return m_pimpl
->DeviceToLogicalX(x
); }
823 wxCoord
DeviceToLogicalY(wxCoord y
) const
824 { return m_pimpl
->DeviceToLogicalY(y
); }
825 wxCoord
DeviceToLogicalXRel(wxCoord x
) const
826 { return m_pimpl
->DeviceToLogicalXRel(x
); }
827 wxCoord
DeviceToLogicalYRel(wxCoord y
) const
828 { return m_pimpl
->DeviceToLogicalYRel(y
); }
829 wxCoord
LogicalToDeviceX(wxCoord x
) const
830 { return m_pimpl
->LogicalToDeviceX(x
); }
831 wxCoord
LogicalToDeviceY(wxCoord y
) const
832 { return m_pimpl
->LogicalToDeviceY(y
); }
833 wxCoord
LogicalToDeviceXRel(wxCoord x
) const
834 { return m_pimpl
->LogicalToDeviceXRel(x
); }
835 wxCoord
LogicalToDeviceYRel(wxCoord y
) const
836 { return m_pimpl
->LogicalToDeviceYRel(y
); }
838 void SetMapMode(int mode
)
839 { m_pimpl
->SetMapMode(mode
); }
840 int GetMapMode() const
841 { return m_pimpl
->GetMapMode(); }
843 void SetUserScale(double x
, double y
)
844 { m_pimpl
->SetUserScale(x
,y
); }
845 void GetUserScale(double *x
, double *y
) const
846 { m_pimpl
->GetUserScale( x
, y
); }
848 void SetLogicalScale(double x
, double y
)
849 { m_pimpl
->SetLogicalScale( x
, y
); }
850 void GetLogicalScale(double *x
, double *y
)
851 { m_pimpl
->GetLogicalScale( x
, y
); }
853 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
854 { m_pimpl
->SetLogicalOrigin(x
,y
); }
855 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
856 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
857 wxPoint
GetLogicalOrigin() const
858 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
860 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
861 { m_pimpl
->SetDeviceOrigin( x
, y
); }
862 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
863 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
864 wxPoint
GetDeviceOrigin() const
865 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
867 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
868 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
871 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
872 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
875 // draw generic object
877 void DrawObject(wxDrawObject
* drawobject
)
879 drawobject
->Draw(*this);
880 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
881 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
884 // -----------------------------------------------
885 // the actual drawing API
887 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
888 int style
= wxFLOOD_SURFACE
)
889 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
890 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
891 int style
= wxFLOOD_SURFACE
)
892 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
894 // fill the area specified by rect with a radial gradient, starting from
895 // initialColour in the centre of the cercle and fading to destColour.
896 void GradientFillConcentric(const wxRect
& rect
,
897 const wxColour
& initialColour
,
898 const wxColour
& destColour
)
899 { m_pimpl
->DoGradientFillConcentric( rect
, initialColour
, destColour
,
900 wxPoint(rect
.GetWidth() / 2,
901 rect
.GetHeight() / 2)); }
903 void GradientFillConcentric(const wxRect
& rect
,
904 const wxColour
& initialColour
,
905 const wxColour
& destColour
,
906 const wxPoint
& circleCenter
)
907 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
909 // fill the area specified by rect with a linear gradient
910 void GradientFillLinear(const wxRect
& rect
,
911 const wxColour
& initialColour
,
912 const wxColour
& destColour
,
913 wxDirection nDirection
= wxEAST
)
914 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
916 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
917 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
918 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
919 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
921 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
922 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
923 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
924 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
926 void CrossHair(wxCoord x
, wxCoord y
)
927 { m_pimpl
->DoCrossHair(x
, y
); }
928 void CrossHair(const wxPoint
& pt
)
929 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
931 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
932 wxCoord xc
, wxCoord yc
)
933 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
934 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
935 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
937 void DrawCheckMark(wxCoord x
, wxCoord y
,
938 wxCoord width
, wxCoord height
)
939 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
940 void DrawCheckMark(const wxRect
& rect
)
941 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
943 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
944 double sa
, double ea
)
945 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
946 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
947 double sa
, double ea
)
948 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
950 void DrawPoint(wxCoord x
, wxCoord y
)
951 { m_pimpl
->DoDrawPoint(x
, y
); }
952 void DrawPoint(const wxPoint
& pt
)
953 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
955 void DrawLines(int n
, wxPoint points
[],
956 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
957 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
958 void DrawLines(const wxPointList
*list
,
959 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
960 { m_pimpl
->DrawLines( list
, xoffset
, yoffset
); }
961 #if WXWIN_COMPATIBILITY_2_8
962 wxDEPRECATED( void DrawLines(const wxList
*list
,
963 wxCoord xoffset
= 0, wxCoord yoffset
= 0) );
964 #endif // WXWIN_COMPATIBILITY_2_8
966 void DrawPolygon(int n
, wxPoint points
[],
967 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
968 int fillStyle
= wxODDEVEN_RULE
)
969 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
970 void DrawPolygon(const wxPointList
*list
,
971 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
972 int fillStyle
= wxODDEVEN_RULE
)
973 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
974 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
975 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
976 int fillStyle
= wxODDEVEN_RULE
)
977 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
978 #if WXWIN_COMPATIBILITY_2_8
979 wxDEPRECATED( void DrawPolygon(const wxList
*list
,
980 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
981 int fillStyle
= wxODDEVEN_RULE
) );
982 #endif // WXWIN_COMPATIBILITY_2_8
984 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
985 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
986 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
987 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
988 void DrawRectangle(const wxRect
& rect
)
989 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
991 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
993 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
994 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
996 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
997 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
998 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1000 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1001 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1002 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1003 { m_pimpl
->DoDrawEllipse(pt
.x
- radius
, pt
.y
- radius
, 2*radius
, 2*radius
); }
1005 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1006 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
1007 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1008 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1009 void DrawEllipse(const wxRect
& rect
)
1010 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1012 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1013 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
1014 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1015 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1017 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1018 bool useMask
= false)
1019 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
1020 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1021 bool useMask
= false)
1022 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1024 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1025 { m_pimpl
->DoDrawText(text
, x
, y
); }
1026 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1027 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
1029 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1030 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
1031 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1032 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1034 // this version puts both optional bitmap and the text into the given
1035 // rectangle and aligns is as specified by alignment parameter; it also
1036 // will emphasize the character with the given index if it is != -1 and
1037 // return the bounding rectangle if required
1038 void DrawLabel(const wxString
& text
,
1039 const wxBitmap
& image
,
1041 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1042 int indexAccel
= -1,
1043 wxRect
*rectBounding
= NULL
);
1045 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1046 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1047 int indexAccel
= -1)
1048 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1050 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1051 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1052 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1054 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
1055 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1057 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1058 wxDC
*source
, const wxPoint
& srcPt
,
1059 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
1061 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1062 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1065 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1066 wxCoord dstWidth
, wxCoord dstHeight
,
1068 wxCoord srcX
, wxCoord srcY
,
1069 wxCoord srcWidth
, wxCoord srcHeight
,
1070 int rop
= wxCOPY
, bool useMask
= false,
1071 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1073 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1074 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1076 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1077 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1078 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1080 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1081 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1084 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1086 return m_pimpl
->DoGetAsBitmap(subrect
);
1090 void DrawSpline(wxCoord x1
, wxCoord y1
,
1091 wxCoord x2
, wxCoord y2
,
1092 wxCoord x3
, wxCoord y3
)
1093 { m_pimpl
->DoDrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
1094 void DrawSpline(int n
, wxPoint points
[])
1095 { m_pimpl
->DoDrawSpline(n
,points
); }
1096 void DrawSpline(const wxPointList
*points
)
1097 { m_pimpl
->DoDrawSpline(points
); }
1098 #endif // wxUSE_SPLINES
1101 #if WXWIN_COMPATIBILITY_2_8
1102 // for compatibility with the old code when wxCoord was long everywhere
1103 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1105 long *descent
= NULL
,
1106 long *externalLeading
= NULL
,
1107 const wxFont
*theFont
= NULL
) const );
1108 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1109 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1110 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1111 #endif // WXWIN_COMPATIBILITY_2_8
1115 // ctor takes ownership of the pointer
1116 wxDC(wxDCImpl
*pimpl
) : m_pimpl(pimpl
) { }
1118 wxDCImpl
* const m_pimpl
;
1121 DECLARE_ABSTRACT_CLASS(wxDC
)
1122 DECLARE_NO_COPY_CLASS(wxDC
)
1125 // ----------------------------------------------------------------------------
1126 // helper class: you can use it to temporarily change the DC text colour and
1127 // restore it automatically when the object goes out of scope
1128 // ----------------------------------------------------------------------------
1130 class WXDLLIMPEXP_CORE wxDCTextColourChanger
1133 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1135 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1140 ~wxDCTextColourChanger()
1142 if ( m_colFgOld
.Ok() )
1143 m_dc
.SetTextForeground(m_colFgOld
);
1146 void Set(const wxColour
& col
)
1148 if ( !m_colFgOld
.Ok() )
1149 m_colFgOld
= m_dc
.GetTextForeground();
1150 m_dc
.SetTextForeground(col
);
1156 wxColour m_colFgOld
;
1158 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
1161 // ----------------------------------------------------------------------------
1162 // helper class: you can use it to temporarily change the DC pen and
1163 // restore it automatically when the object goes out of scope
1164 // ----------------------------------------------------------------------------
1166 class WXDLLIMPEXP_CORE wxDCPenChanger
1169 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1176 if ( m_penOld
.Ok() )
1177 m_dc
.SetPen(m_penOld
);
1185 DECLARE_NO_COPY_CLASS(wxDCPenChanger
)
1188 // ----------------------------------------------------------------------------
1189 // helper class: you can use it to temporarily change the DC brush and
1190 // restore it automatically when the object goes out of scope
1191 // ----------------------------------------------------------------------------
1193 class WXDLLIMPEXP_CORE wxDCBrushChanger
1196 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1198 m_dc
.SetBrush(brush
);
1203 if ( m_brushOld
.Ok() )
1204 m_dc
.SetBrush(m_brushOld
);
1212 DECLARE_NO_COPY_CLASS(wxDCBrushChanger
)
1215 // ----------------------------------------------------------------------------
1216 // another small helper class: sets the clipping region in its ctor and
1217 // destroys it in the dtor
1218 // ----------------------------------------------------------------------------
1220 class WXDLLIMPEXP_CORE wxDCClipper
1223 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1224 { dc
.SetClippingRegion(r
); }
1225 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1226 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1227 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1228 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1230 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1235 DECLARE_NO_COPY_CLASS(wxDCClipper
)
1238 #endif // _WX_DC_H_BASE_