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/region.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 enum wxRasterOperationMode
51 wxOR_REVERSE
, // src OR (NOT dst)
52 wxAND_REVERSE
, // src AND (NOT dst)
55 wxAND_INVERT
, // (NOT src) AND dst
57 wxNOR
, // (NOT src) AND (NOT dst)
58 wxEQUIV
, // (NOT src) XOR dst
59 wxSRC_INVERT
, // (NOT src)
60 wxOR_INVERT
, // (NOT src) OR dst
61 wxNAND
, // (NOT src) OR (NOT dst)
64 #if WXWIN_COMPATIBILITY_2_8
65 ,wxROP_BLACK
= wxCLEAR
,
66 wxBLIT_BLACKNESS
= wxCLEAR
,
68 wxBLIT_SRCINVERT
= wxXOR
,
70 wxBLIT_DSTINVERT
= wxINVERT
,
71 wxROP_MERGEPENNOT
= wxOR_REVERSE
,
72 wxBLIT_00DD0228
= wxOR_REVERSE
,
73 wxROP_MASKPENNOT
= wxAND_REVERSE
,
74 wxBLIT_SRCERASE
= wxAND_REVERSE
,
75 wxROP_COPYPEN
= wxCOPY
,
76 wxBLIT_SRCCOPY
= wxCOPY
,
77 wxROP_MASKPEN
= wxAND
,
78 wxBLIT_SRCAND
= wxAND
,
79 wxROP_MASKNOTPEN
= wxAND_INVERT
,
80 wxBLIT_00220326
= wxAND_INVERT
,
82 wxBLIT_00AA0029
= wxNO_OP
,
83 wxROP_NOTMERGEPEN
= wxNOR
,
84 wxBLIT_NOTSRCERASE
= wxNOR
,
85 wxROP_NOTXORPEN
= wxEQUIV
,
86 wxBLIT_00990066
= wxEQUIV
,
87 wxROP_NOTCOPYPEN
= wxSRC_INVERT
,
88 wxBLIT_NOTSCRCOPY
= wxSRC_INVERT
,
89 wxROP_MERGENOTPEN
= wxOR_INVERT
,
90 wxBLIT_MERGEPAINT
= wxOR_INVERT
,
91 wxROP_NOTMASKPEN
= wxNAND
,
92 wxBLIT_007700E6
= wxNAND
,
93 wxROP_MERGEPEN
= wxOR
,
94 wxBLIT_SRCPAINT
= wxOR
,
96 wxBLIT_WHITENESS
= wxSET
97 #endif //WXWIN_COMPATIBILITY_2_8
101 enum wxFloodFillStyle
117 #if WXWIN_COMPATIBILITY_2_8
119 //-----------------------------------------------------------------------------
120 // wxDrawObject helper class
121 //-----------------------------------------------------------------------------
123 class WXDLLIMPEXP_CORE wxDrawObject
126 wxDEPRECATED_CONSTRUCTOR(wxDrawObject
)()
127 : m_isBBoxValid(false)
128 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
131 virtual ~wxDrawObject() { }
133 virtual void Draw(wxDC
&) const { }
135 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
139 if ( x
< m_minX
) m_minX
= x
;
140 if ( y
< m_minY
) m_minY
= y
;
141 if ( x
> m_maxX
) m_maxX
= x
;
142 if ( y
> m_maxY
) m_maxY
= y
;
146 m_isBBoxValid
= true;
155 void ResetBoundingBox()
157 m_isBBoxValid
= false;
159 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
162 // Get the final bounding box of the PostScript or Metafile picture.
164 wxCoord
MinX() const { return m_minX
; }
165 wxCoord
MaxX() const { return m_maxX
; }
166 wxCoord
MinY() const { return m_minY
; }
167 wxCoord
MaxY() const { return m_maxY
; }
169 //to define the type of object for derived objects
170 virtual int GetType()=0;
173 //for boundingbox calculation
174 bool m_isBBoxValid
:1;
175 //for boundingbox calculation
176 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
179 #endif // WXWIN_COMPATIBILITY_2_8
182 //-----------------------------------------------------------------------------
184 //-----------------------------------------------------------------------------
186 class WXDLLIMPEXP_FWD_CORE wxDCImpl
;
188 class WXDLLIMPEXP_CORE wxDCFactory
192 virtual ~wxDCFactory() {}
194 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
) = 0;
195 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
) = 0;
196 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
) = 0;
197 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
) = 0;
198 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
) = 0;
199 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
) = 0;
200 virtual wxDCImpl
* CreateScreenDC( wxScreenDC
*owner
) = 0;
201 #if wxUSE_PRINTING_ARCHITECTURE
202 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
) = 0;
205 static void Set(wxDCFactory
*factory
);
206 static wxDCFactory
*Get();
209 static wxDCFactory
*m_factory
;
212 //-----------------------------------------------------------------------------
214 //-----------------------------------------------------------------------------
216 class WXDLLIMPEXP_CORE wxNativeDCFactory
: public wxDCFactory
219 wxNativeDCFactory() {}
221 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
);
222 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
);
223 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
);
224 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
);
225 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
);
226 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
);
227 virtual wxDCImpl
* CreateScreenDC( wxScreenDC
*owner
);
228 #if wxUSE_PRINTING_ARCHITECTURE
229 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
);
233 //-----------------------------------------------------------------------------
235 //-----------------------------------------------------------------------------
237 class WXDLLIMPEXP_CORE wxDCImpl
: public wxObject
240 wxDCImpl( wxDC
*owner
);
243 wxDC
*GetOwner() const { return m_owner
; }
245 wxWindow
* GetWindow() const { return m_window
; }
247 virtual bool IsOk() const { return m_ok
; }
249 // query capabilities
251 virtual bool CanDrawBitmap() const = 0;
252 virtual bool CanGetTextExtent() const = 0;
255 virtual void* GetCairoContext() const
260 // query dimension, colour deps, resolution
262 virtual void DoGetSize(int *width
, int *height
) const = 0;
263 void GetSize(int *width
, int *height
) const
265 DoGetSize(width
, height
);
269 wxSize
GetSize() const
276 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
278 virtual int GetDepth() const = 0;
279 virtual wxSize
GetPPI() const = 0;
281 // Right-To-Left (RTL) modes
283 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
284 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
288 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
289 virtual void EndDoc() { }
291 virtual void StartPage() { }
292 virtual void EndPage() { }
294 // flushing the content of this dc immediately eg onto screen
295 virtual void Flush() { }
299 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
303 if ( x
< m_minX
) m_minX
= x
;
304 if ( y
< m_minY
) m_minY
= y
;
305 if ( x
> m_maxX
) m_maxX
= x
;
306 if ( y
> m_maxY
) m_maxY
= y
;
310 m_isBBoxValid
= true;
318 void ResetBoundingBox()
320 m_isBBoxValid
= false;
322 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
325 wxCoord
MinX() const { return m_minX
; }
326 wxCoord
MaxX() const { return m_maxX
; }
327 wxCoord
MinY() const { return m_minY
; }
328 wxCoord
MaxY() const { return m_maxY
; }
330 // setters and getters
332 virtual void SetFont(const wxFont
& font
) = 0;
333 virtual const wxFont
& GetFont() const { return m_font
; }
335 virtual void SetPen(const wxPen
& pen
) = 0;
336 virtual const wxPen
& GetPen() const { return m_pen
; }
338 virtual void SetBrush(const wxBrush
& brush
) = 0;
339 virtual const wxBrush
& GetBrush() const { return m_brush
; }
341 virtual void SetBackground(const wxBrush
& brush
) = 0;
342 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
344 virtual void SetBackgroundMode(int mode
) = 0;
345 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
347 virtual void SetTextForeground(const wxColour
& colour
)
348 { m_textForegroundColour
= colour
; }
349 virtual const wxColour
& GetTextForeground() const
350 { return m_textForegroundColour
; }
352 virtual void SetTextBackground(const wxColour
& colour
)
353 { m_textBackgroundColour
= colour
; }
354 virtual const wxColour
& GetTextBackground() const
355 { return m_textBackgroundColour
; }
358 virtual void SetPalette(const wxPalette
& palette
) = 0;
359 #endif // wxUSE_PALETTE
361 // inherit the DC attributes (font and colours) from the given window
363 // this is called automatically when a window, client or paint DC is
365 virtual void InheritAttributes(wxWindow
*win
);
370 virtual void SetLogicalFunction(wxRasterOperationMode function
) = 0;
371 virtual wxRasterOperationMode
GetLogicalFunction() const
372 { return m_logicalFunction
; }
376 virtual wxCoord
GetCharHeight() const = 0;
377 virtual wxCoord
GetCharWidth() const = 0;
378 virtual void DoGetTextExtent(const wxString
& string
,
379 wxCoord
*x
, wxCoord
*y
,
380 wxCoord
*descent
= NULL
,
381 wxCoord
*externalLeading
= NULL
,
382 const wxFont
*theFont
= NULL
) const = 0;
383 virtual void GetMultiLineTextExtent(const wxString
& string
,
386 wxCoord
*heightLine
= NULL
,
387 const wxFont
*font
= NULL
) const;
388 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
392 virtual void Clear() = 0;
396 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
397 wxCoord width
, wxCoord height
) = 0;
399 // NB: this function works with device coordinates, not the logical ones!
400 virtual void DoSetDeviceClippingRegion(const wxRegion
& region
) = 0;
402 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
403 wxCoord
*w
, wxCoord
*h
) const
410 *w
= m_clipX2
- m_clipX1
;
412 *h
= m_clipY2
- m_clipY1
;
415 virtual void DestroyClippingRegion() { ResetClipping(); }
418 // coordinates conversions and transforms
420 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
421 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
422 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
423 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
424 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
425 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
426 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
427 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
429 virtual void SetMapMode(wxMappingMode mode
);
430 virtual wxMappingMode
GetMapMode() const { return m_mappingMode
; }
432 virtual void SetUserScale(double x
, double y
);
433 virtual void GetUserScale(double *x
, double *y
) const
435 if ( x
) *x
= m_userScaleX
;
436 if ( y
) *y
= m_userScaleY
;
439 virtual void SetLogicalScale(double x
, double y
);
440 virtual void GetLogicalScale(double *x
, double *y
)
442 if ( x
) *x
= m_logicalScaleX
;
443 if ( y
) *y
= m_logicalScaleY
;
446 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
447 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
449 if ( x
) *x
= m_logicalOriginX
;
450 if ( y
) *y
= m_logicalOriginY
;
453 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
454 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
456 if ( x
) *x
= m_deviceOriginX
;
457 if ( y
) *y
= m_deviceOriginY
;
460 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
462 virtual void ComputeScaleAndOrigin();
464 // this needs to overidden if the axis is inverted
465 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
467 // ---------------------------------------------------------
468 // the actual drawing API
470 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
471 wxFloodFillStyle style
= wxFLOOD_SURFACE
) = 0;
473 virtual void DoGradientFillLinear(const wxRect
& rect
,
474 const wxColour
& initialColour
,
475 const wxColour
& destColour
,
476 wxDirection nDirection
= wxEAST
);
478 virtual void DoGradientFillConcentric(const wxRect
& rect
,
479 const wxColour
& initialColour
,
480 const wxColour
& destColour
,
481 const wxPoint
& circleCenter
);
483 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
485 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
486 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
488 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
489 wxCoord x2
, wxCoord y2
,
490 wxCoord xc
, wxCoord yc
) = 0;
491 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
492 wxCoord width
, wxCoord height
);
493 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
494 double sa
, double ea
) = 0;
496 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
497 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
498 wxCoord width
, wxCoord height
,
500 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
501 wxCoord width
, wxCoord height
) = 0;
503 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
505 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
506 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
507 bool useMask
= false) = 0;
509 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
510 virtual void DoDrawRotatedText(const wxString
& text
,
511 wxCoord x
, wxCoord y
, double angle
) = 0;
513 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
514 wxCoord width
, wxCoord height
,
516 wxCoord xsrc
, wxCoord ysrc
,
517 wxRasterOperationMode rop
= wxCOPY
,
518 bool useMask
= false,
519 wxCoord xsrcMask
= wxDefaultCoord
,
520 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
522 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
523 wxCoord dstWidth
, wxCoord dstHeight
,
525 wxCoord xsrc
, wxCoord ysrc
,
526 wxCoord srcWidth
, wxCoord srcHeight
,
527 wxRasterOperationMode rop
= wxCOPY
,
528 bool useMask
= false,
529 wxCoord xsrcMask
= wxDefaultCoord
,
530 wxCoord ysrcMask
= wxDefaultCoord
);
532 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
533 { return wxNullBitmap
; }
536 virtual void DoDrawLines(int n
, wxPoint points
[],
537 wxCoord xoffset
, wxCoord yoffset
) = 0;
538 virtual void DrawLines(const wxPointList
*list
,
539 wxCoord xoffset
, wxCoord yoffset
);
541 virtual void DoDrawPolygon(int n
, wxPoint points
[],
542 wxCoord xoffset
, wxCoord yoffset
,
543 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
) = 0;
544 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
545 wxCoord xoffset
, wxCoord yoffset
,
546 wxPolygonFillMode fillStyle
);
547 void DrawPolygon(const wxPointList
*list
,
548 wxCoord xoffset
, wxCoord yoffset
,
549 wxPolygonFillMode fillStyle
);
553 void DrawSpline(wxCoord x1
, wxCoord y1
,
554 wxCoord x2
, wxCoord y2
,
555 wxCoord x3
, wxCoord y3
);
556 void DrawSpline(int n
, wxPoint points
[]);
557 void DrawSpline(const wxPointList
*points
) { DoDrawSpline(points
); }
559 virtual void DoDrawSpline(const wxPointList
*points
);
562 // ---------------------------------------------------------
563 // wxMemoryDC Impl API
565 virtual void DoSelect(const wxBitmap
& WXUNUSED(bmp
))
568 virtual const wxBitmap
& GetSelectedBitmap() const
569 { return wxNullBitmap
; }
570 virtual wxBitmap
& GetSelectedBitmap()
571 { return wxNullBitmap
; }
573 // ---------------------------------------------------------
574 // wxPrinterDC Impl API
576 virtual wxRect
GetPaperRect() const
577 { int w
= 0; int h
= 0; DoGetSize( &w
, &h
); return wxRect(0,0,w
,h
); }
579 virtual int GetResolution() const
586 // unset clipping variables (after clipping region was destroyed)
591 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
595 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
596 /*! \param x Upper left corner of bounding box.
597 * \param y Upper left corner of bounding box.
598 * \param w Width of bounding box.
599 * \param h Height of bounding box.
600 * \param sa Starting angle of arc
601 * (counterclockwise, start at 3 o'clock, 360 is full circle).
602 * \param ea Ending angle of arc.
603 * \param angle Rotation angle, the Arc will be rotated after
604 * calculating begin and end.
606 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
607 wxCoord width
, wxCoord height
,
608 double sa
= 0, double ea
= 0, double angle
= 0 )
609 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
611 void DrawEllipticArcRot( const wxPoint
& pt
,
613 double sa
= 0, double ea
= 0, double angle
= 0 )
614 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
616 void DrawEllipticArcRot( const wxRect
& rect
,
617 double sa
= 0, double ea
= 0, double angle
= 0 )
618 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
620 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
621 wxCoord w
, wxCoord h
,
622 double sa
= 0, double ea
= 0, double angle
= 0 );
624 //! Rotates points around center.
625 /*! This is a quite straight method, it calculates in pixels
626 * and so it produces rounding errors.
627 * \param points The points inside will be rotated.
628 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
629 * \param center Center of rotation.
631 void Rotate( wxPointList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
633 // used by DrawEllipticArcRot
634 // Careful: wxList gets filled with points you have to delete later.
635 void CalculateEllipticPoints( wxPointList
* points
,
636 wxCoord xStart
, wxCoord yStart
,
637 wxCoord w
, wxCoord h
,
638 double sa
, double ea
);
639 #endif // __WXWINCE__
641 // returns adjustment factor for converting wxFont "point size"; in wx
642 // it is point size on screen and needs to be multiplied by this value
643 // for rendering on higher-resolution DCs such as printer ones
644 static float GetFontPointSizeAdjustment(float dpi
);
646 // window on which the DC draws or NULL
653 bool m_isInteractive
:1;
654 bool m_isBBoxValid
:1;
656 // coordinate system variables
658 wxCoord m_logicalOriginX
, m_logicalOriginY
;
659 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
661 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
662 // is not at 0,0. This was the case under
663 // Mac's GrafPorts (coordinate system
664 // used toplevel window's origin) and
665 // e.g. for Postscript, where the native
666 // origin in the bottom left corner.
667 double m_logicalScaleX
, m_logicalScaleY
;
668 double m_userScaleX
, m_userScaleY
;
669 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
671 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
673 // what is a mm on a screen you don't know the size of?
674 double m_mm_to_pix_x
,
677 // bounding and clipping boxes
678 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
679 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
681 wxRasterOperationMode m_logicalFunction
;
682 int m_backgroundMode
;
683 wxMappingMode m_mappingMode
;
687 wxBrush m_backgroundBrush
;
688 wxColour m_textForegroundColour
;
689 wxColour m_textBackgroundColour
;
694 bool m_hasCustomPalette
;
695 #endif // wxUSE_PALETTE
698 DECLARE_ABSTRACT_CLASS(wxDCImpl
)
702 class WXDLLIMPEXP_CORE wxDC
: public wxObject
705 // copy attributes (font, colours and writing direction) from another DC
706 void CopyAttributes(const wxDC
& dc
);
708 virtual ~wxDC() { delete m_pimpl
; }
712 const wxDCImpl
*GetImpl() const
715 wxWindow
*GetWindow() const
716 { return m_pimpl
->GetWindow(); }
719 { return m_pimpl
&& m_pimpl
->IsOk(); }
721 // query capabilities
723 bool CanDrawBitmap() const
724 { return m_pimpl
->CanDrawBitmap(); }
725 bool CanGetTextExtent() const
726 { return m_pimpl
->CanGetTextExtent(); }
728 // query dimension, colour deps, resolution
730 void GetSize(int *width
, int *height
) const
731 { m_pimpl
->DoGetSize(width
, height
); }
732 wxSize
GetSize() const
733 { return m_pimpl
->GetSize(); }
735 void GetSizeMM(int* width
, int* height
) const
736 { m_pimpl
->DoGetSizeMM(width
, height
); }
737 wxSize
GetSizeMM() const
740 m_pimpl
->DoGetSizeMM(&w
, &h
);
745 { return m_pimpl
->GetDepth(); }
746 wxSize
GetPPI() const
747 { return m_pimpl
->GetPPI(); }
749 virtual int GetResolution() const
750 { return m_pimpl
->GetResolution(); }
752 // Right-To-Left (RTL) modes
754 void SetLayoutDirection(wxLayoutDirection dir
)
755 { m_pimpl
->SetLayoutDirection( dir
); }
756 wxLayoutDirection
GetLayoutDirection() const
757 { return m_pimpl
->GetLayoutDirection(); }
761 bool StartDoc(const wxString
& message
)
762 { return m_pimpl
->StartDoc(message
); }
764 { m_pimpl
->EndDoc(); }
767 { m_pimpl
->StartPage(); }
769 { m_pimpl
->EndPage(); }
773 void CalcBoundingBox(wxCoord x
, wxCoord y
)
774 { m_pimpl
->CalcBoundingBox(x
,y
); }
775 void ResetBoundingBox()
776 { m_pimpl
->ResetBoundingBox(); }
779 { return m_pimpl
->MinX(); }
781 { return m_pimpl
->MaxX(); }
783 { return m_pimpl
->MinY(); }
785 { return m_pimpl
->MaxY(); }
787 // setters and getters
789 void SetFont(const wxFont
& font
)
790 { m_pimpl
->SetFont( font
); }
791 const wxFont
& GetFont() const
792 { return m_pimpl
->GetFont(); }
794 void SetPen(const wxPen
& pen
)
795 { m_pimpl
->SetPen( pen
); }
796 const wxPen
& GetPen() const
797 { return m_pimpl
->GetPen(); }
799 void SetBrush(const wxBrush
& brush
)
800 { m_pimpl
->SetBrush( brush
); }
801 const wxBrush
& GetBrush() const
802 { return m_pimpl
->GetBrush(); }
804 void SetBackground(const wxBrush
& brush
)
805 { m_pimpl
->SetBackground( brush
); }
806 const wxBrush
& GetBackground() const
807 { return m_pimpl
->GetBackground(); }
809 void SetBackgroundMode(int mode
)
810 { m_pimpl
->SetBackgroundMode( mode
); }
811 int GetBackgroundMode() const
812 { return m_pimpl
->GetBackgroundMode(); }
814 void SetTextForeground(const wxColour
& colour
)
815 { m_pimpl
->SetTextForeground(colour
); }
816 const wxColour
& GetTextForeground() const
817 { return m_pimpl
->GetTextForeground(); }
819 void SetTextBackground(const wxColour
& colour
)
820 { m_pimpl
->SetTextBackground(colour
); }
821 const wxColour
& GetTextBackground() const
822 { return m_pimpl
->GetTextBackground(); }
825 void SetPalette(const wxPalette
& palette
)
826 { m_pimpl
->SetPalette(palette
); }
827 #endif // wxUSE_PALETTE
831 void SetLogicalFunction(wxRasterOperationMode function
)
832 { m_pimpl
->SetLogicalFunction(function
); }
833 wxRasterOperationMode
GetLogicalFunction() const
834 { return m_pimpl
->GetLogicalFunction(); }
838 wxCoord
GetCharHeight() const
839 { return m_pimpl
->GetCharHeight(); }
840 wxCoord
GetCharWidth() const
841 { return m_pimpl
->GetCharWidth(); }
843 void GetTextExtent(const wxString
& string
,
844 wxCoord
*x
, wxCoord
*y
,
845 wxCoord
*descent
= NULL
,
846 wxCoord
*externalLeading
= NULL
,
847 const wxFont
*theFont
= NULL
) const
848 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
850 wxSize
GetTextExtent(const wxString
& string
) const
853 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
857 void GetMultiLineTextExtent(const wxString
& string
,
860 wxCoord
*heightLine
= NULL
,
861 const wxFont
*font
= NULL
) const
862 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
864 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
867 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
871 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
872 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
877 { m_pimpl
->Clear(); }
881 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
882 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
883 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
884 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
885 void SetClippingRegion(const wxRect
& rect
)
886 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
888 // unlike the functions above, the coordinates of the region used in this
889 // one are in device coordinates, not the logical ones
890 void SetDeviceClippingRegion(const wxRegion
& region
)
891 { m_pimpl
->DoSetDeviceClippingRegion(region
); }
893 // this function is deprecated because its name is confusing: you may
894 // expect it to work with logical coordinates but, in fact, it does exactly
895 // the same thing as SetDeviceClippingRegion()
897 // please review the code using it and either replace it with calls to
898 // SetDeviceClippingRegion() or correct it if it was [wrongly] passing
899 // logical coordinates to this function
900 wxDEPRECATED_INLINE(void SetClippingRegion(const wxRegion
& region
),
901 SetDeviceClippingRegion(region
); )
903 void DestroyClippingRegion()
904 { m_pimpl
->DestroyClippingRegion(); }
906 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
907 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
908 void GetClippingBox(wxRect
& rect
) const
909 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
911 // coordinates conversions and transforms
913 wxCoord
DeviceToLogicalX(wxCoord x
) const
914 { return m_pimpl
->DeviceToLogicalX(x
); }
915 wxCoord
DeviceToLogicalY(wxCoord y
) const
916 { return m_pimpl
->DeviceToLogicalY(y
); }
917 wxCoord
DeviceToLogicalXRel(wxCoord x
) const
918 { return m_pimpl
->DeviceToLogicalXRel(x
); }
919 wxCoord
DeviceToLogicalYRel(wxCoord y
) const
920 { return m_pimpl
->DeviceToLogicalYRel(y
); }
921 wxCoord
LogicalToDeviceX(wxCoord x
) const
922 { return m_pimpl
->LogicalToDeviceX(x
); }
923 wxCoord
LogicalToDeviceY(wxCoord y
) const
924 { return m_pimpl
->LogicalToDeviceY(y
); }
925 wxCoord
LogicalToDeviceXRel(wxCoord x
) const
926 { return m_pimpl
->LogicalToDeviceXRel(x
); }
927 wxCoord
LogicalToDeviceYRel(wxCoord y
) const
928 { return m_pimpl
->LogicalToDeviceYRel(y
); }
930 void SetMapMode(wxMappingMode mode
)
931 { m_pimpl
->SetMapMode(mode
); }
932 wxMappingMode
GetMapMode() const
933 { return m_pimpl
->GetMapMode(); }
935 void SetUserScale(double x
, double y
)
936 { m_pimpl
->SetUserScale(x
,y
); }
937 void GetUserScale(double *x
, double *y
) const
938 { m_pimpl
->GetUserScale( x
, y
); }
940 void SetLogicalScale(double x
, double y
)
941 { m_pimpl
->SetLogicalScale( x
, y
); }
942 void GetLogicalScale(double *x
, double *y
)
943 { m_pimpl
->GetLogicalScale( x
, y
); }
945 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
946 { m_pimpl
->SetLogicalOrigin(x
,y
); }
947 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
948 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
949 wxPoint
GetLogicalOrigin() const
950 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
952 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
953 { m_pimpl
->SetDeviceOrigin( x
, y
); }
954 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
955 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
956 wxPoint
GetDeviceOrigin() const
957 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
959 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
960 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
963 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
964 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
967 // -----------------------------------------------
968 // the actual drawing API
970 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
971 wxFloodFillStyle style
= wxFLOOD_SURFACE
)
972 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
973 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
974 wxFloodFillStyle style
= wxFLOOD_SURFACE
)
975 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
977 // fill the area specified by rect with a radial gradient, starting from
978 // initialColour in the centre of the cercle and fading to destColour.
979 void GradientFillConcentric(const wxRect
& rect
,
980 const wxColour
& initialColour
,
981 const wxColour
& destColour
)
982 { m_pimpl
->DoGradientFillConcentric( rect
, initialColour
, destColour
,
983 wxPoint(rect
.GetWidth() / 2,
984 rect
.GetHeight() / 2)); }
986 void GradientFillConcentric(const wxRect
& rect
,
987 const wxColour
& initialColour
,
988 const wxColour
& destColour
,
989 const wxPoint
& circleCenter
)
990 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
992 // fill the area specified by rect with a linear gradient
993 void GradientFillLinear(const wxRect
& rect
,
994 const wxColour
& initialColour
,
995 const wxColour
& destColour
,
996 wxDirection nDirection
= wxEAST
)
997 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
999 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
1000 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
1001 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
1002 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
1004 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1005 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
1006 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
1007 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
1009 void CrossHair(wxCoord x
, wxCoord y
)
1010 { m_pimpl
->DoCrossHair(x
, y
); }
1011 void CrossHair(const wxPoint
& pt
)
1012 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
1014 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
1015 wxCoord xc
, wxCoord yc
)
1016 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
1017 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
1018 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
1020 void DrawCheckMark(wxCoord x
, wxCoord y
,
1021 wxCoord width
, wxCoord height
)
1022 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
1023 void DrawCheckMark(const wxRect
& rect
)
1024 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1026 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1027 double sa
, double ea
)
1028 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
1029 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
1030 double sa
, double ea
)
1031 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
1033 void DrawPoint(wxCoord x
, wxCoord y
)
1034 { m_pimpl
->DoDrawPoint(x
, y
); }
1035 void DrawPoint(const wxPoint
& pt
)
1036 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
1038 void DrawLines(int n
, wxPoint points
[],
1039 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1040 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
1041 void DrawLines(const wxPointList
*list
,
1042 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1043 { m_pimpl
->DrawLines( list
, xoffset
, yoffset
); }
1044 #if WXWIN_COMPATIBILITY_2_8
1045 wxDEPRECATED( void DrawLines(const wxList
*list
,
1046 wxCoord xoffset
= 0, wxCoord yoffset
= 0) );
1047 #endif // WXWIN_COMPATIBILITY_2_8
1049 void DrawPolygon(int n
, wxPoint points
[],
1050 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1051 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
)
1052 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
1053 void DrawPolygon(const wxPointList
*list
,
1054 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1055 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
)
1056 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
1057 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1058 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1059 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
)
1060 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
1061 #if WXWIN_COMPATIBILITY_2_8
1062 wxDEPRECATED( void DrawPolygon(const wxList
*list
,
1063 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1064 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
) );
1065 #endif // WXWIN_COMPATIBILITY_2_8
1067 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1068 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
1069 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
1070 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1071 void DrawRectangle(const wxRect
& rect
)
1072 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1074 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
1076 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
1077 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
1079 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
1080 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
1081 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1083 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1084 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1085 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1086 { m_pimpl
->DoDrawEllipse(pt
.x
- radius
, pt
.y
- radius
, 2*radius
, 2*radius
); }
1088 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1089 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
1090 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1091 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1092 void DrawEllipse(const wxRect
& rect
)
1093 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1095 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1096 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
1097 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1098 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1100 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1101 bool useMask
= false)
1102 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
1103 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1104 bool useMask
= false)
1105 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1107 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1108 { m_pimpl
->DoDrawText(text
, x
, y
); }
1109 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1110 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
1112 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1113 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
1114 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1115 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1117 // this version puts both optional bitmap and the text into the given
1118 // rectangle and aligns is as specified by alignment parameter; it also
1119 // will emphasize the character with the given index if it is != -1 and
1120 // return the bounding rectangle if required
1121 void DrawLabel(const wxString
& text
,
1122 const wxBitmap
& image
,
1124 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1125 int indexAccel
= -1,
1126 wxRect
*rectBounding
= NULL
);
1128 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1129 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1130 int indexAccel
= -1)
1131 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1133 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1134 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1135 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1136 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1138 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
1139 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1141 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1142 wxDC
*source
, const wxPoint
& srcPt
,
1143 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1144 const wxPoint
& srcPtMask
= wxDefaultPosition
)
1146 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1147 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1150 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1151 wxCoord dstWidth
, wxCoord dstHeight
,
1153 wxCoord srcX
, wxCoord srcY
,
1154 wxCoord srcWidth
, wxCoord srcHeight
,
1155 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1156 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1158 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1159 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1161 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1162 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1163 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1164 const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1166 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1167 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1170 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1172 return m_pimpl
->DoGetAsBitmap(subrect
);
1176 void DrawSpline(wxCoord x1
, wxCoord y1
,
1177 wxCoord x2
, wxCoord y2
,
1178 wxCoord x3
, wxCoord y3
)
1179 { m_pimpl
->DrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
1180 void DrawSpline(int n
, wxPoint points
[])
1181 { m_pimpl
->DrawSpline(n
,points
); }
1182 void DrawSpline(const wxPointList
*points
)
1183 { m_pimpl
->DrawSpline(points
); }
1184 #endif // wxUSE_SPLINES
1187 #if WXWIN_COMPATIBILITY_2_8
1188 // for compatibility with the old code when wxCoord was long everywhere
1189 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1191 long *descent
= NULL
,
1192 long *externalLeading
= NULL
,
1193 const wxFont
*theFont
= NULL
) const );
1194 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1195 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1196 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1198 wxDEPRECATED( void DrawObject(wxDrawObject
* drawobject
) );
1199 #endif // WXWIN_COMPATIBILITY_2_8
1202 // GetHDC() is the simplest way to retrieve an HDC From a wxDC but only
1203 // works if this wxDC is GDI-based and fails for GDI+ contexts (and
1204 // anything else without HDC, e.g. wxPostScriptDC)
1205 WXHDC
GetHDC() const;
1207 // don't use these methods manually, use GetTempHDC() instead
1208 virtual WXHDC
AcquireHDC() { return GetHDC(); }
1209 virtual void ReleaseHDC(WXHDC
WXUNUSED(hdc
)) { }
1211 // helper class holding the result of GetTempHDC() with std::auto_ptr<>-like
1212 // semantics, i.e. it is moved when copied
1218 m_hdc(dc
.AcquireHDC())
1222 TempHDC(const TempHDC
& thdc
)
1226 const_cast<TempHDC
&>(thdc
).m_hdc
= 0;
1232 m_dc
.ReleaseHDC(m_hdc
);
1235 WXHDC
GetHDC() const { return m_hdc
; }
1241 wxDECLARE_NO_ASSIGN_CLASS(TempHDC
);
1244 // GetTempHDC() also works for wxGCDC (but still not for wxPostScriptDC &c)
1245 TempHDC
GetTempHDC() { return TempHDC(*this); }
1249 // ctor takes ownership of the pointer
1250 wxDC(wxDCImpl
*pimpl
) : m_pimpl(pimpl
) { }
1252 wxDCImpl
* const m_pimpl
;
1255 DECLARE_ABSTRACT_CLASS(wxDC
)
1256 wxDECLARE_NO_COPY_CLASS(wxDC
);
1259 // ----------------------------------------------------------------------------
1260 // helper class: you can use it to temporarily change the DC text colour and
1261 // restore it automatically when the object goes out of scope
1262 // ----------------------------------------------------------------------------
1264 class WXDLLIMPEXP_CORE wxDCTextColourChanger
1267 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1269 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1274 ~wxDCTextColourChanger()
1276 if ( m_colFgOld
.Ok() )
1277 m_dc
.SetTextForeground(m_colFgOld
);
1280 void Set(const wxColour
& col
)
1282 if ( !m_colFgOld
.Ok() )
1283 m_colFgOld
= m_dc
.GetTextForeground();
1284 m_dc
.SetTextForeground(col
);
1290 wxColour m_colFgOld
;
1292 wxDECLARE_NO_COPY_CLASS(wxDCTextColourChanger
);
1295 // ----------------------------------------------------------------------------
1296 // helper class: you can use it to temporarily change the DC pen and
1297 // restore it automatically when the object goes out of scope
1298 // ----------------------------------------------------------------------------
1300 class WXDLLIMPEXP_CORE wxDCPenChanger
1303 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1310 if ( m_penOld
.Ok() )
1311 m_dc
.SetPen(m_penOld
);
1319 wxDECLARE_NO_COPY_CLASS(wxDCPenChanger
);
1322 // ----------------------------------------------------------------------------
1323 // helper class: you can use it to temporarily change the DC brush and
1324 // restore it automatically when the object goes out of scope
1325 // ----------------------------------------------------------------------------
1327 class WXDLLIMPEXP_CORE wxDCBrushChanger
1330 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1332 m_dc
.SetBrush(brush
);
1337 if ( m_brushOld
.Ok() )
1338 m_dc
.SetBrush(m_brushOld
);
1346 wxDECLARE_NO_COPY_CLASS(wxDCBrushChanger
);
1349 // ----------------------------------------------------------------------------
1350 // another small helper class: sets the clipping region in its ctor and
1351 // destroys it in the dtor
1352 // ----------------------------------------------------------------------------
1354 class WXDLLIMPEXP_CORE wxDCClipper
1357 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1358 { dc
.SetClippingRegion(r
.GetBox()); }
1359 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1360 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1361 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1362 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1364 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1369 wxDECLARE_NO_COPY_CLASS(wxDCClipper
);
1372 // ----------------------------------------------------------------------------
1373 // helper class: you can use it to temporarily change the DC font and
1374 // restore it automatically when the object goes out of scope
1375 // ----------------------------------------------------------------------------
1377 class WXDLLIMPEXP_CORE wxDCFontChanger
1380 wxDCFontChanger(wxDC
& dc
)
1381 : m_dc(dc
), m_fontOld()
1385 wxDCFontChanger(wxDC
& dc
, const wxFont
& font
)
1386 : m_dc(dc
), m_fontOld(dc
.GetFont())
1391 void Set(const wxFont
& font
)
1393 if ( !m_fontOld
.Ok() )
1394 m_fontOld
= m_dc
.GetFont();
1400 if ( m_fontOld
.Ok() )
1401 m_dc
.SetFont(m_fontOld
);
1409 wxDECLARE_NO_COPY_CLASS(wxDCFontChanger
);
1413 #endif // _WX_DC_H_BASE_