1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Vadim Zeitlin
7 // Copyright: (c) wxWidgets team
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_DC_H_BASE_
12 #define _WX_DC_H_BASE_
14 // ----------------------------------------------------------------------------
15 // headers which we must include here
16 // ----------------------------------------------------------------------------
18 #include "wx/object.h" // the base class
20 #include "wx/intl.h" // for wxLayoutDirection
21 #include "wx/cursor.h" // we have member variables of these classes
22 #include "wx/font.h" // so we can't do without them
23 #include "wx/colour.h"
24 #include "wx/bitmap.h" // for wxNullBitmap
27 #include "wx/palette.h"
28 #include "wx/dynarray.h"
31 #include "wx/region.h"
32 #include "wx/affinematrix2d.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 #if wxUSE_GRAPHICS_CONTEXT
46 class WXDLLIMPEXP_FWD_CORE wxGraphicsContext
;
50 enum wxRasterOperationMode
55 wxOR_REVERSE
, // src OR (NOT dst)
56 wxAND_REVERSE
, // src AND (NOT dst)
59 wxAND_INVERT
, // (NOT src) AND dst
61 wxNOR
, // (NOT src) AND (NOT dst)
62 wxEQUIV
, // (NOT src) XOR dst
63 wxSRC_INVERT
, // (NOT src)
64 wxOR_INVERT
, // (NOT src) OR dst
65 wxNAND
, // (NOT src) OR (NOT dst)
68 #if WXWIN_COMPATIBILITY_2_8
69 ,wxROP_BLACK
= wxCLEAR
,
70 wxBLIT_BLACKNESS
= wxCLEAR
,
72 wxBLIT_SRCINVERT
= wxXOR
,
74 wxBLIT_DSTINVERT
= wxINVERT
,
75 wxROP_MERGEPENNOT
= wxOR_REVERSE
,
76 wxBLIT_00DD0228
= wxOR_REVERSE
,
77 wxROP_MASKPENNOT
= wxAND_REVERSE
,
78 wxBLIT_SRCERASE
= wxAND_REVERSE
,
79 wxROP_COPYPEN
= wxCOPY
,
80 wxBLIT_SRCCOPY
= wxCOPY
,
81 wxROP_MASKPEN
= wxAND
,
82 wxBLIT_SRCAND
= wxAND
,
83 wxROP_MASKNOTPEN
= wxAND_INVERT
,
84 wxBLIT_00220326
= wxAND_INVERT
,
86 wxBLIT_00AA0029
= wxNO_OP
,
87 wxROP_NOTMERGEPEN
= wxNOR
,
88 wxBLIT_NOTSRCERASE
= wxNOR
,
89 wxROP_NOTXORPEN
= wxEQUIV
,
90 wxBLIT_00990066
= wxEQUIV
,
91 wxROP_NOTCOPYPEN
= wxSRC_INVERT
,
92 wxBLIT_NOTSCRCOPY
= wxSRC_INVERT
,
93 wxROP_MERGENOTPEN
= wxOR_INVERT
,
94 wxBLIT_MERGEPAINT
= wxOR_INVERT
,
95 wxROP_NOTMASKPEN
= wxNAND
,
96 wxBLIT_007700E6
= wxNAND
,
97 wxROP_MERGEPEN
= wxOR
,
98 wxBLIT_SRCPAINT
= wxOR
,
100 wxBLIT_WHITENESS
= wxSET
101 #endif //WXWIN_COMPATIBILITY_2_8
105 enum wxFloodFillStyle
121 // Description of text characteristics.
134 int height
, // Total character height.
135 ascent
, // Part of the height above the baseline.
136 descent
, // Part of the height below the baseline.
137 internalLeading
, // Intra-line spacing.
138 externalLeading
, // Inter-line spacing.
139 averageWidth
; // Average font width, a.k.a. "x-width".
142 #if WXWIN_COMPATIBILITY_2_8
144 //-----------------------------------------------------------------------------
145 // wxDrawObject helper class
146 //-----------------------------------------------------------------------------
148 class WXDLLIMPEXP_CORE wxDrawObject
151 wxDEPRECATED_CONSTRUCTOR(wxDrawObject
)()
152 : m_isBBoxValid(false)
153 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
156 virtual ~wxDrawObject() { }
158 virtual void Draw(wxDC
&) const { }
160 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
164 if ( x
< m_minX
) m_minX
= x
;
165 if ( y
< m_minY
) m_minY
= y
;
166 if ( x
> m_maxX
) m_maxX
= x
;
167 if ( y
> m_maxY
) m_maxY
= y
;
171 m_isBBoxValid
= true;
180 void ResetBoundingBox()
182 m_isBBoxValid
= false;
184 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
187 // Get the final bounding box of the PostScript or Metafile picture.
189 wxCoord
MinX() const { return m_minX
; }
190 wxCoord
MaxX() const { return m_maxX
; }
191 wxCoord
MinY() const { return m_minY
; }
192 wxCoord
MaxY() const { return m_maxY
; }
194 //to define the type of object for derived objects
195 virtual int GetType()=0;
198 //for boundingbox calculation
199 bool m_isBBoxValid
:1;
200 //for boundingbox calculation
201 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
204 #endif // WXWIN_COMPATIBILITY_2_8
207 //-----------------------------------------------------------------------------
209 //-----------------------------------------------------------------------------
211 class WXDLLIMPEXP_FWD_CORE wxDCImpl
;
213 class WXDLLIMPEXP_CORE wxDCFactory
217 virtual ~wxDCFactory() {}
219 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
) = 0;
220 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
) = 0;
221 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
) = 0;
222 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
) = 0;
223 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
) = 0;
224 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
) = 0;
225 virtual wxDCImpl
* CreateScreenDC( wxScreenDC
*owner
) = 0;
226 #if wxUSE_PRINTING_ARCHITECTURE
227 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
) = 0;
230 static void Set(wxDCFactory
*factory
);
231 static wxDCFactory
*Get();
234 static wxDCFactory
*m_factory
;
237 //-----------------------------------------------------------------------------
239 //-----------------------------------------------------------------------------
241 class WXDLLIMPEXP_CORE wxNativeDCFactory
: public wxDCFactory
244 wxNativeDCFactory() {}
246 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
);
247 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
);
248 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
);
249 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
);
250 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
);
251 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
);
252 virtual wxDCImpl
* CreateScreenDC( wxScreenDC
*owner
);
253 #if wxUSE_PRINTING_ARCHITECTURE
254 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
);
258 //-----------------------------------------------------------------------------
260 //-----------------------------------------------------------------------------
262 class WXDLLIMPEXP_CORE wxDCImpl
: public wxObject
265 wxDCImpl( wxDC
*owner
);
268 wxDC
*GetOwner() const { return m_owner
; }
270 wxWindow
* GetWindow() const { return m_window
; }
272 virtual bool IsOk() const { return m_ok
; }
274 // query capabilities
276 virtual bool CanDrawBitmap() const = 0;
277 virtual bool CanGetTextExtent() const = 0;
280 virtual void* GetCairoContext() const
285 virtual void* GetHandle() const { return NULL
; }
287 // query dimension, colour deps, resolution
289 virtual void DoGetSize(int *width
, int *height
) const = 0;
290 void GetSize(int *width
, int *height
) const
292 DoGetSize(width
, height
);
296 wxSize
GetSize() const
303 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
305 virtual int GetDepth() const = 0;
306 virtual wxSize
GetPPI() const = 0;
308 // Right-To-Left (RTL) modes
310 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
311 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
315 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
316 virtual void EndDoc() { }
318 virtual void StartPage() { }
319 virtual void EndPage() { }
321 // flushing the content of this dc immediately eg onto screen
322 virtual void Flush() { }
326 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
330 if ( x
< m_minX
) m_minX
= x
;
331 if ( y
< m_minY
) m_minY
= y
;
332 if ( x
> m_maxX
) m_maxX
= x
;
333 if ( y
> m_maxY
) m_maxY
= y
;
337 m_isBBoxValid
= true;
345 void ResetBoundingBox()
347 m_isBBoxValid
= false;
349 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
352 wxCoord
MinX() const { return m_minX
; }
353 wxCoord
MaxX() const { return m_maxX
; }
354 wxCoord
MinY() const { return m_minY
; }
355 wxCoord
MaxY() const { return m_maxY
; }
357 // setters and getters
359 virtual void SetFont(const wxFont
& font
) = 0;
360 virtual const wxFont
& GetFont() const { return m_font
; }
362 virtual void SetPen(const wxPen
& pen
) = 0;
363 virtual const wxPen
& GetPen() const { return m_pen
; }
365 virtual void SetBrush(const wxBrush
& brush
) = 0;
366 virtual const wxBrush
& GetBrush() const { return m_brush
; }
368 virtual void SetBackground(const wxBrush
& brush
) = 0;
369 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
371 virtual void SetBackgroundMode(int mode
) = 0;
372 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
374 virtual void SetTextForeground(const wxColour
& colour
)
375 { m_textForegroundColour
= colour
; }
376 virtual const wxColour
& GetTextForeground() const
377 { return m_textForegroundColour
; }
379 virtual void SetTextBackground(const wxColour
& colour
)
380 { m_textBackgroundColour
= colour
; }
381 virtual const wxColour
& GetTextBackground() const
382 { return m_textBackgroundColour
; }
385 virtual void SetPalette(const wxPalette
& palette
) = 0;
386 #endif // wxUSE_PALETTE
388 // inherit the DC attributes (font and colours) from the given window
390 // this is called automatically when a window, client or paint DC is
392 virtual void InheritAttributes(wxWindow
*win
);
397 virtual void SetLogicalFunction(wxRasterOperationMode function
) = 0;
398 virtual wxRasterOperationMode
GetLogicalFunction() const
399 { return m_logicalFunction
; }
403 virtual wxCoord
GetCharHeight() const = 0;
404 virtual wxCoord
GetCharWidth() const = 0;
406 // The derived classes should really override DoGetFontMetrics() to return
407 // the correct values in the future but for now provide a default
408 // implementation in terms of DoGetTextExtent() to avoid breaking the
409 // compilation of all other ports as wxMSW is the only one to implement it.
410 virtual void DoGetFontMetrics(int *height
,
413 int *internalLeading
,
414 int *externalLeading
,
415 int *averageWidth
) const;
417 virtual void DoGetTextExtent(const wxString
& string
,
418 wxCoord
*x
, wxCoord
*y
,
419 wxCoord
*descent
= NULL
,
420 wxCoord
*externalLeading
= NULL
,
421 const wxFont
*theFont
= NULL
) const = 0;
422 virtual void GetMultiLineTextExtent(const wxString
& string
,
425 wxCoord
*heightLine
= NULL
,
426 const wxFont
*font
= NULL
) const;
427 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
431 virtual void Clear() = 0;
435 // Note that this pure virtual method has an implementation that updates
436 // the values returned by DoGetClippingBox() and so can be called from the
437 // derived class overridden version if it makes sense (i.e. if the clipping
438 // box coordinates are not already updated in some other way).
439 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
440 wxCoord w
, wxCoord h
) = 0;
442 // NB: this function works with device coordinates, not the logical ones!
443 virtual void DoSetDeviceClippingRegion(const wxRegion
& region
) = 0;
445 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
446 wxCoord
*w
, wxCoord
*h
) const
453 *w
= m_clipX2
- m_clipX1
;
455 *h
= m_clipY2
- m_clipY1
;
458 virtual void DestroyClippingRegion() { ResetClipping(); }
461 // coordinates conversions and transforms
463 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
464 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
465 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
466 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
467 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
468 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
469 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
470 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
472 virtual void SetMapMode(wxMappingMode mode
);
473 virtual wxMappingMode
GetMapMode() const { return m_mappingMode
; }
475 virtual void SetUserScale(double x
, double y
);
476 virtual void GetUserScale(double *x
, double *y
) const
478 if ( x
) *x
= m_userScaleX
;
479 if ( y
) *y
= m_userScaleY
;
482 virtual void SetLogicalScale(double x
, double y
);
483 virtual void GetLogicalScale(double *x
, double *y
) const
485 if ( x
) *x
= m_logicalScaleX
;
486 if ( y
) *y
= m_logicalScaleY
;
489 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
490 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
492 if ( x
) *x
= m_logicalOriginX
;
493 if ( y
) *y
= m_logicalOriginY
;
496 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
497 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
499 if ( x
) *x
= m_deviceOriginX
;
500 if ( y
) *y
= m_deviceOriginY
;
503 #if wxUSE_DC_TRANSFORM_MATRIX
504 // Transform matrix support is not available in most ports right now
505 // (currently only wxMSW provides it) so do nothing in these methods by
507 virtual bool CanUseTransformMatrix() const
509 virtual bool SetTransformMatrix(const wxAffineMatrix2D
& WXUNUSED(matrix
))
511 virtual wxAffineMatrix2D
GetTransformMatrix() const
512 { return wxAffineMatrix2D(); }
513 virtual void ResetTransformMatrix()
515 #endif // wxUSE_DC_TRANSFORM_MATRIX
517 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
519 virtual void ComputeScaleAndOrigin();
521 // this needs to overidden if the axis is inverted
522 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
524 virtual double GetContentScaleFactor() const { return m_contentScaleFactor
; }
527 // Native Windows functions using the underlying HDC don't honour GDI+
528 // transformations which may be applied to it. Using this function we can
529 // transform the coordinates manually before passing them to such functions
530 // (as in e.g. wxRendererMSW code). It doesn't do anything if this is not a
532 virtual wxRect
MSWApplyGDIPlusTransform(const wxRect
& r
) const
539 // ---------------------------------------------------------
540 // the actual drawing API
542 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
543 wxFloodFillStyle style
= wxFLOOD_SURFACE
) = 0;
545 virtual void DoGradientFillLinear(const wxRect
& rect
,
546 const wxColour
& initialColour
,
547 const wxColour
& destColour
,
548 wxDirection nDirection
= wxEAST
);
550 virtual void DoGradientFillConcentric(const wxRect
& rect
,
551 const wxColour
& initialColour
,
552 const wxColour
& destColour
,
553 const wxPoint
& circleCenter
);
555 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
557 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
558 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
560 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
561 wxCoord x2
, wxCoord y2
,
562 wxCoord xc
, wxCoord yc
) = 0;
563 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
564 wxCoord width
, wxCoord height
);
565 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
566 double sa
, double ea
) = 0;
568 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
569 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
570 wxCoord width
, wxCoord height
,
572 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
573 wxCoord width
, wxCoord height
) = 0;
575 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
577 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
578 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
579 bool useMask
= false) = 0;
581 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
582 virtual void DoDrawRotatedText(const wxString
& text
,
583 wxCoord x
, wxCoord y
, double angle
) = 0;
585 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
586 wxCoord width
, wxCoord height
,
588 wxCoord xsrc
, wxCoord ysrc
,
589 wxRasterOperationMode rop
= wxCOPY
,
590 bool useMask
= false,
591 wxCoord xsrcMask
= wxDefaultCoord
,
592 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
594 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
595 wxCoord dstWidth
, wxCoord dstHeight
,
597 wxCoord xsrc
, wxCoord ysrc
,
598 wxCoord srcWidth
, wxCoord srcHeight
,
599 wxRasterOperationMode rop
= wxCOPY
,
600 bool useMask
= false,
601 wxCoord xsrcMask
= wxDefaultCoord
,
602 wxCoord ysrcMask
= wxDefaultCoord
);
604 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
605 { return wxNullBitmap
; }
608 virtual void DoDrawLines(int n
, const wxPoint points
[],
609 wxCoord xoffset
, wxCoord yoffset
) = 0;
610 virtual void DrawLines(const wxPointList
*list
,
611 wxCoord xoffset
, wxCoord yoffset
);
613 virtual void DoDrawPolygon(int n
, const wxPoint points
[],
614 wxCoord xoffset
, wxCoord yoffset
,
615 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
) = 0;
616 virtual void DoDrawPolyPolygon(int n
, const int count
[], const wxPoint points
[],
617 wxCoord xoffset
, wxCoord yoffset
,
618 wxPolygonFillMode fillStyle
);
619 void DrawPolygon(const wxPointList
*list
,
620 wxCoord xoffset
, wxCoord yoffset
,
621 wxPolygonFillMode fillStyle
);
625 void DrawSpline(wxCoord x1
, wxCoord y1
,
626 wxCoord x2
, wxCoord y2
,
627 wxCoord x3
, wxCoord y3
);
628 void DrawSpline(int n
, const wxPoint points
[]);
629 void DrawSpline(const wxPointList
*points
) { DoDrawSpline(points
); }
631 virtual void DoDrawSpline(const wxPointList
*points
);
634 // ---------------------------------------------------------
635 // wxMemoryDC Impl API
637 virtual void DoSelect(const wxBitmap
& WXUNUSED(bmp
))
640 virtual const wxBitmap
& GetSelectedBitmap() const
641 { return wxNullBitmap
; }
642 virtual wxBitmap
& GetSelectedBitmap()
643 { return wxNullBitmap
; }
645 // ---------------------------------------------------------
646 // wxPrinterDC Impl API
648 virtual wxRect
GetPaperRect() const
649 { int w
= 0; int h
= 0; DoGetSize( &w
, &h
); return wxRect(0,0,w
,h
); }
651 virtual int GetResolution() const
654 #if wxUSE_GRAPHICS_CONTEXT
655 virtual wxGraphicsContext
* GetGraphicsContext() const
657 virtual void SetGraphicsContext( wxGraphicsContext
* WXUNUSED(ctx
) )
665 // unset clipping variables (after clipping region was destroyed)
670 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
674 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
675 /*! \param x Upper left corner of bounding box.
676 * \param y Upper left corner of bounding box.
677 * \param w Width of bounding box.
678 * \param h Height of bounding box.
679 * \param sa Starting angle of arc
680 * (counterclockwise, start at 3 o'clock, 360 is full circle).
681 * \param ea Ending angle of arc.
682 * \param angle Rotation angle, the Arc will be rotated after
683 * calculating begin and end.
685 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
686 wxCoord width
, wxCoord height
,
687 double sa
= 0, double ea
= 0, double angle
= 0 )
688 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
690 void DrawEllipticArcRot( const wxPoint
& pt
,
692 double sa
= 0, double ea
= 0, double angle
= 0 )
693 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
695 void DrawEllipticArcRot( const wxRect
& rect
,
696 double sa
= 0, double ea
= 0, double angle
= 0 )
697 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
699 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
700 wxCoord w
, wxCoord h
,
701 double sa
= 0, double ea
= 0, double angle
= 0 );
703 //! Rotates points around center.
704 /*! This is a quite straight method, it calculates in pixels
705 * and so it produces rounding errors.
706 * \param points The points inside will be rotated.
707 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
708 * \param center Center of rotation.
710 void Rotate( wxPointList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
712 // used by DrawEllipticArcRot
713 // Careful: wxList gets filled with points you have to delete later.
714 void CalculateEllipticPoints( wxPointList
* points
,
715 wxCoord xStart
, wxCoord yStart
,
716 wxCoord w
, wxCoord h
,
717 double sa
, double ea
);
718 #endif // __WXWINCE__
720 // returns adjustment factor for converting wxFont "point size"; in wx
721 // it is point size on screen and needs to be multiplied by this value
722 // for rendering on higher-resolution DCs such as printer ones
723 static float GetFontPointSizeAdjustment(float dpi
);
725 // window on which the DC draws or NULL
732 bool m_isInteractive
:1;
733 bool m_isBBoxValid
:1;
735 // coordinate system variables
737 wxCoord m_logicalOriginX
, m_logicalOriginY
;
738 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
740 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
741 // is not at 0,0. This was the case under
742 // Mac's GrafPorts (coordinate system
743 // used toplevel window's origin) and
744 // e.g. for Postscript, where the native
745 // origin in the bottom left corner.
746 double m_logicalScaleX
, m_logicalScaleY
;
747 double m_userScaleX
, m_userScaleY
;
748 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
750 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
752 double m_contentScaleFactor
; // used by high resolution displays (retina)
754 // what is a mm on a screen you don't know the size of?
755 double m_mm_to_pix_x
,
758 // bounding and clipping boxes
759 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
760 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
762 wxRasterOperationMode m_logicalFunction
;
763 int m_backgroundMode
;
764 wxMappingMode m_mappingMode
;
768 wxBrush m_backgroundBrush
;
769 wxColour m_textForegroundColour
;
770 wxColour m_textBackgroundColour
;
775 bool m_hasCustomPalette
;
776 #endif // wxUSE_PALETTE
779 DECLARE_ABSTRACT_CLASS(wxDCImpl
)
783 class WXDLLIMPEXP_CORE wxDC
: public wxObject
786 // copy attributes (font, colours and writing direction) from another DC
787 void CopyAttributes(const wxDC
& dc
);
789 virtual ~wxDC() { delete m_pimpl
; }
793 const wxDCImpl
*GetImpl() const
796 wxWindow
*GetWindow() const
797 { return m_pimpl
->GetWindow(); }
799 void *GetHandle() const
800 { return m_pimpl
->GetHandle(); }
803 { return m_pimpl
&& m_pimpl
->IsOk(); }
805 // query capabilities
807 bool CanDrawBitmap() const
808 { return m_pimpl
->CanDrawBitmap(); }
809 bool CanGetTextExtent() const
810 { return m_pimpl
->CanGetTextExtent(); }
812 // query dimension, colour deps, resolution
814 void GetSize(int *width
, int *height
) const
815 { m_pimpl
->DoGetSize(width
, height
); }
816 wxSize
GetSize() const
817 { return m_pimpl
->GetSize(); }
819 void GetSizeMM(int* width
, int* height
) const
820 { m_pimpl
->DoGetSizeMM(width
, height
); }
821 wxSize
GetSizeMM() const
824 m_pimpl
->DoGetSizeMM(&w
, &h
);
829 { return m_pimpl
->GetDepth(); }
830 wxSize
GetPPI() const
831 { return m_pimpl
->GetPPI(); }
833 virtual int GetResolution() const
834 { return m_pimpl
->GetResolution(); }
836 double GetContentScaleFactor() const
837 { return m_pimpl
->GetContentScaleFactor(); }
839 // Right-To-Left (RTL) modes
841 void SetLayoutDirection(wxLayoutDirection dir
)
842 { m_pimpl
->SetLayoutDirection( dir
); }
843 wxLayoutDirection
GetLayoutDirection() const
844 { return m_pimpl
->GetLayoutDirection(); }
848 bool StartDoc(const wxString
& message
)
849 { return m_pimpl
->StartDoc(message
); }
851 { m_pimpl
->EndDoc(); }
854 { m_pimpl
->StartPage(); }
856 { m_pimpl
->EndPage(); }
860 void CalcBoundingBox(wxCoord x
, wxCoord y
)
861 { m_pimpl
->CalcBoundingBox(x
,y
); }
862 void ResetBoundingBox()
863 { m_pimpl
->ResetBoundingBox(); }
866 { return m_pimpl
->MinX(); }
868 { return m_pimpl
->MaxX(); }
870 { return m_pimpl
->MinY(); }
872 { return m_pimpl
->MaxY(); }
874 // setters and getters
876 void SetFont(const wxFont
& font
)
877 { m_pimpl
->SetFont( font
); }
878 const wxFont
& GetFont() const
879 { return m_pimpl
->GetFont(); }
881 void SetPen(const wxPen
& pen
)
882 { m_pimpl
->SetPen( pen
); }
883 const wxPen
& GetPen() const
884 { return m_pimpl
->GetPen(); }
886 void SetBrush(const wxBrush
& brush
)
887 { m_pimpl
->SetBrush( brush
); }
888 const wxBrush
& GetBrush() const
889 { return m_pimpl
->GetBrush(); }
891 void SetBackground(const wxBrush
& brush
)
892 { m_pimpl
->SetBackground( brush
); }
893 const wxBrush
& GetBackground() const
894 { return m_pimpl
->GetBackground(); }
896 void SetBackgroundMode(int mode
)
897 { m_pimpl
->SetBackgroundMode( mode
); }
898 int GetBackgroundMode() const
899 { return m_pimpl
->GetBackgroundMode(); }
901 void SetTextForeground(const wxColour
& colour
)
902 { m_pimpl
->SetTextForeground(colour
); }
903 const wxColour
& GetTextForeground() const
904 { return m_pimpl
->GetTextForeground(); }
906 void SetTextBackground(const wxColour
& colour
)
907 { m_pimpl
->SetTextBackground(colour
); }
908 const wxColour
& GetTextBackground() const
909 { return m_pimpl
->GetTextBackground(); }
912 void SetPalette(const wxPalette
& palette
)
913 { m_pimpl
->SetPalette(palette
); }
914 #endif // wxUSE_PALETTE
918 void SetLogicalFunction(wxRasterOperationMode function
)
919 { m_pimpl
->SetLogicalFunction(function
); }
920 wxRasterOperationMode
GetLogicalFunction() const
921 { return m_pimpl
->GetLogicalFunction(); }
925 wxCoord
GetCharHeight() const
926 { return m_pimpl
->GetCharHeight(); }
927 wxCoord
GetCharWidth() const
928 { return m_pimpl
->GetCharWidth(); }
930 wxFontMetrics
GetFontMetrics() const
933 m_pimpl
->DoGetFontMetrics(&fm
.height
, &fm
.ascent
, &fm
.descent
,
934 &fm
.internalLeading
, &fm
.externalLeading
,
939 void GetTextExtent(const wxString
& string
,
940 wxCoord
*x
, wxCoord
*y
,
941 wxCoord
*descent
= NULL
,
942 wxCoord
*externalLeading
= NULL
,
943 const wxFont
*theFont
= NULL
) const
944 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
946 wxSize
GetTextExtent(const wxString
& string
) const
949 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
953 void GetMultiLineTextExtent(const wxString
& string
,
956 wxCoord
*heightLine
= NULL
,
957 const wxFont
*font
= NULL
) const
958 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
960 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
963 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
967 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
968 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
973 { m_pimpl
->Clear(); }
977 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
978 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
979 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
980 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
981 void SetClippingRegion(const wxRect
& rect
)
982 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
984 // unlike the functions above, the coordinates of the region used in this
985 // one are in device coordinates, not the logical ones
986 void SetDeviceClippingRegion(const wxRegion
& region
)
987 { m_pimpl
->DoSetDeviceClippingRegion(region
); }
989 // this function is deprecated because its name is confusing: you may
990 // expect it to work with logical coordinates but, in fact, it does exactly
991 // the same thing as SetDeviceClippingRegion()
993 // please review the code using it and either replace it with calls to
994 // SetDeviceClippingRegion() or correct it if it was [wrongly] passing
995 // logical coordinates to this function
996 wxDEPRECATED_INLINE(void SetClippingRegion(const wxRegion
& region
),
997 SetDeviceClippingRegion(region
); )
999 void DestroyClippingRegion()
1000 { m_pimpl
->DestroyClippingRegion(); }
1002 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
1003 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
1004 void GetClippingBox(wxRect
& rect
) const
1005 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
1007 // coordinates conversions and transforms
1009 wxCoord
DeviceToLogicalX(wxCoord x
) const
1010 { return m_pimpl
->DeviceToLogicalX(x
); }
1011 wxCoord
DeviceToLogicalY(wxCoord y
) const
1012 { return m_pimpl
->DeviceToLogicalY(y
); }
1013 wxCoord
DeviceToLogicalXRel(wxCoord x
) const
1014 { return m_pimpl
->DeviceToLogicalXRel(x
); }
1015 wxCoord
DeviceToLogicalYRel(wxCoord y
) const
1016 { return m_pimpl
->DeviceToLogicalYRel(y
); }
1017 wxCoord
LogicalToDeviceX(wxCoord x
) const
1018 { return m_pimpl
->LogicalToDeviceX(x
); }
1019 wxCoord
LogicalToDeviceY(wxCoord y
) const
1020 { return m_pimpl
->LogicalToDeviceY(y
); }
1021 wxCoord
LogicalToDeviceXRel(wxCoord x
) const
1022 { return m_pimpl
->LogicalToDeviceXRel(x
); }
1023 wxCoord
LogicalToDeviceYRel(wxCoord y
) const
1024 { return m_pimpl
->LogicalToDeviceYRel(y
); }
1026 void SetMapMode(wxMappingMode mode
)
1027 { m_pimpl
->SetMapMode(mode
); }
1028 wxMappingMode
GetMapMode() const
1029 { return m_pimpl
->GetMapMode(); }
1031 void SetUserScale(double x
, double y
)
1032 { m_pimpl
->SetUserScale(x
,y
); }
1033 void GetUserScale(double *x
, double *y
) const
1034 { m_pimpl
->GetUserScale( x
, y
); }
1036 void SetLogicalScale(double x
, double y
)
1037 { m_pimpl
->SetLogicalScale( x
, y
); }
1038 void GetLogicalScale(double *x
, double *y
) const
1039 { m_pimpl
->GetLogicalScale( x
, y
); }
1041 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
1042 { m_pimpl
->SetLogicalOrigin(x
,y
); }
1043 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1044 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
1045 wxPoint
GetLogicalOrigin() const
1046 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
1048 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
1049 { m_pimpl
->SetDeviceOrigin( x
, y
); }
1050 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1051 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
1052 wxPoint
GetDeviceOrigin() const
1053 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
1055 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
1056 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
1058 #if wxUSE_DC_TRANSFORM_MATRIX
1059 bool CanUseTransformMatrix() const
1060 { return m_pimpl
->CanUseTransformMatrix(); }
1062 bool SetTransformMatrix(const wxAffineMatrix2D
&matrix
)
1063 { return m_pimpl
->SetTransformMatrix(matrix
); }
1065 wxAffineMatrix2D
GetTransformMatrix() const
1066 { return m_pimpl
->GetTransformMatrix(); }
1068 void ResetTransformMatrix()
1069 { m_pimpl
->ResetTransformMatrix(); }
1070 #endif // wxUSE_DC_TRANSFORM_MATRIX
1073 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
1074 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
1077 // -----------------------------------------------
1078 // the actual drawing API
1080 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1081 wxFloodFillStyle style
= wxFLOOD_SURFACE
)
1082 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
1083 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
1084 wxFloodFillStyle style
= wxFLOOD_SURFACE
)
1085 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
1087 // fill the area specified by rect with a radial gradient, starting from
1088 // initialColour in the centre of the cercle and fading to destColour.
1089 void GradientFillConcentric(const wxRect
& rect
,
1090 const wxColour
& initialColour
,
1091 const wxColour
& destColour
)
1092 { m_pimpl
->DoGradientFillConcentric( rect
, initialColour
, destColour
,
1093 wxPoint(rect
.GetWidth() / 2,
1094 rect
.GetHeight() / 2)); }
1096 void GradientFillConcentric(const wxRect
& rect
,
1097 const wxColour
& initialColour
,
1098 const wxColour
& destColour
,
1099 const wxPoint
& circleCenter
)
1100 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
1102 // fill the area specified by rect with a linear gradient
1103 void GradientFillLinear(const wxRect
& rect
,
1104 const wxColour
& initialColour
,
1105 const wxColour
& destColour
,
1106 wxDirection nDirection
= wxEAST
)
1107 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
1109 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
1110 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
1111 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
1112 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
1114 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1115 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
1116 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
1117 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
1119 void CrossHair(wxCoord x
, wxCoord y
)
1120 { m_pimpl
->DoCrossHair(x
, y
); }
1121 void CrossHair(const wxPoint
& pt
)
1122 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
1124 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
1125 wxCoord xc
, wxCoord yc
)
1126 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
1127 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
1128 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
1130 void DrawCheckMark(wxCoord x
, wxCoord y
,
1131 wxCoord width
, wxCoord height
)
1132 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
1133 void DrawCheckMark(const wxRect
& rect
)
1134 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1136 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1137 double sa
, double ea
)
1138 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
1139 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
1140 double sa
, double ea
)
1141 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
1143 void DrawPoint(wxCoord x
, wxCoord y
)
1144 { m_pimpl
->DoDrawPoint(x
, y
); }
1145 void DrawPoint(const wxPoint
& pt
)
1146 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
1148 void DrawLines(int n
, const wxPoint points
[],
1149 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1150 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
1151 void DrawLines(const wxPointList
*list
,
1152 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1153 { m_pimpl
->DrawLines( list
, xoffset
, yoffset
); }
1154 #if WXWIN_COMPATIBILITY_2_8
1155 wxDEPRECATED( void DrawLines(const wxList
*list
,
1156 wxCoord xoffset
= 0, wxCoord yoffset
= 0) );
1157 #endif // WXWIN_COMPATIBILITY_2_8
1159 void DrawPolygon(int n
, const wxPoint points
[],
1160 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1161 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
)
1162 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
1163 void DrawPolygon(const wxPointList
*list
,
1164 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1165 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
)
1166 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
1167 void DrawPolyPolygon(int n
, const int count
[], const wxPoint points
[],
1168 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1169 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
)
1170 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
1171 #if WXWIN_COMPATIBILITY_2_8
1172 wxDEPRECATED( void DrawPolygon(const wxList
*list
,
1173 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1174 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
) );
1175 #endif // WXWIN_COMPATIBILITY_2_8
1177 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1178 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
1179 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
1180 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1181 void DrawRectangle(const wxRect
& rect
)
1182 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1184 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
1186 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
1187 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
1189 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
1190 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
1191 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1193 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1194 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1195 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1196 { m_pimpl
->DoDrawEllipse(pt
.x
- radius
, pt
.y
- radius
, 2*radius
, 2*radius
); }
1198 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1199 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
1200 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1201 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1202 void DrawEllipse(const wxRect
& rect
)
1203 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1205 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1206 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
1207 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1208 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1210 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1211 bool useMask
= false)
1212 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
1213 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1214 bool useMask
= false)
1215 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1217 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1218 { m_pimpl
->DoDrawText(text
, x
, y
); }
1219 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1220 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
1222 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1223 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
1224 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1225 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1227 // this version puts both optional bitmap and the text into the given
1228 // rectangle and aligns is as specified by alignment parameter; it also
1229 // will emphasize the character with the given index if it is != -1 and
1230 // return the bounding rectangle if required
1231 void DrawLabel(const wxString
& text
,
1232 const wxBitmap
& image
,
1234 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1235 int indexAccel
= -1,
1236 wxRect
*rectBounding
= NULL
);
1238 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1239 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1240 int indexAccel
= -1)
1241 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1243 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1244 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1245 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1246 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1248 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
1249 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1251 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1252 wxDC
*source
, const wxPoint
& srcPt
,
1253 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1254 const wxPoint
& srcPtMask
= wxDefaultPosition
)
1256 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1257 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1260 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1261 wxCoord dstWidth
, wxCoord dstHeight
,
1263 wxCoord srcX
, wxCoord srcY
,
1264 wxCoord srcWidth
, wxCoord srcHeight
,
1265 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1266 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1268 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1269 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1271 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1272 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1273 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1274 const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1276 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1277 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1280 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1282 return m_pimpl
->DoGetAsBitmap(subrect
);
1286 void DrawSpline(wxCoord x1
, wxCoord y1
,
1287 wxCoord x2
, wxCoord y2
,
1288 wxCoord x3
, wxCoord y3
)
1289 { m_pimpl
->DrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
1290 void DrawSpline(int n
, const wxPoint points
[])
1291 { m_pimpl
->DrawSpline(n
,points
); }
1292 void DrawSpline(const wxPointList
*points
)
1293 { m_pimpl
->DrawSpline(points
); }
1294 #endif // wxUSE_SPLINES
1297 #if WXWIN_COMPATIBILITY_2_8
1298 // for compatibility with the old code when wxCoord was long everywhere
1299 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1301 long *descent
= NULL
,
1302 long *externalLeading
= NULL
,
1303 const wxFont
*theFont
= NULL
) const );
1304 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1305 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1306 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1308 wxDEPRECATED( void DrawObject(wxDrawObject
* drawobject
) );
1309 #endif // WXWIN_COMPATIBILITY_2_8
1312 // GetHDC() is the simplest way to retrieve an HDC From a wxDC but only
1313 // works if this wxDC is GDI-based and fails for GDI+ contexts (and
1314 // anything else without HDC, e.g. wxPostScriptDC)
1315 WXHDC
GetHDC() const;
1317 // don't use these methods manually, use GetTempHDC() instead
1318 virtual WXHDC
AcquireHDC() { return GetHDC(); }
1319 virtual void ReleaseHDC(WXHDC
WXUNUSED(hdc
)) { }
1321 // helper class holding the result of GetTempHDC() with std::auto_ptr<>-like
1322 // semantics, i.e. it is moved when copied
1328 m_hdc(dc
.AcquireHDC())
1332 TempHDC(const TempHDC
& thdc
)
1336 const_cast<TempHDC
&>(thdc
).m_hdc
= 0;
1342 m_dc
.ReleaseHDC(m_hdc
);
1345 WXHDC
GetHDC() const { return m_hdc
; }
1351 wxDECLARE_NO_ASSIGN_CLASS(TempHDC
);
1354 // GetTempHDC() also works for wxGCDC (but still not for wxPostScriptDC &c)
1355 TempHDC
GetTempHDC() { return TempHDC(*this); }
1358 #if wxUSE_GRAPHICS_CONTEXT
1359 virtual wxGraphicsContext
* GetGraphicsContext() const
1361 return m_pimpl
->GetGraphicsContext();
1363 virtual void SetGraphicsContext( wxGraphicsContext
* ctx
)
1365 m_pimpl
->SetGraphicsContext(ctx
);
1370 // ctor takes ownership of the pointer
1371 wxDC(wxDCImpl
*pimpl
) : m_pimpl(pimpl
) { }
1373 wxDCImpl
* const m_pimpl
;
1376 DECLARE_ABSTRACT_CLASS(wxDC
)
1377 wxDECLARE_NO_COPY_CLASS(wxDC
);
1380 // ----------------------------------------------------------------------------
1381 // helper class: you can use it to temporarily change the DC text colour and
1382 // restore it automatically when the object goes out of scope
1383 // ----------------------------------------------------------------------------
1385 class WXDLLIMPEXP_CORE wxDCTextColourChanger
1388 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1390 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1395 ~wxDCTextColourChanger()
1397 if ( m_colFgOld
.IsOk() )
1398 m_dc
.SetTextForeground(m_colFgOld
);
1401 void Set(const wxColour
& col
)
1403 if ( !m_colFgOld
.IsOk() )
1404 m_colFgOld
= m_dc
.GetTextForeground();
1405 m_dc
.SetTextForeground(col
);
1411 wxColour m_colFgOld
;
1413 wxDECLARE_NO_COPY_CLASS(wxDCTextColourChanger
);
1416 // ----------------------------------------------------------------------------
1417 // helper class: you can use it to temporarily change the DC pen and
1418 // restore it automatically when the object goes out of scope
1419 // ----------------------------------------------------------------------------
1421 class WXDLLIMPEXP_CORE wxDCPenChanger
1424 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1431 if ( m_penOld
.IsOk() )
1432 m_dc
.SetPen(m_penOld
);
1440 wxDECLARE_NO_COPY_CLASS(wxDCPenChanger
);
1443 // ----------------------------------------------------------------------------
1444 // helper class: you can use it to temporarily change the DC brush and
1445 // restore it automatically when the object goes out of scope
1446 // ----------------------------------------------------------------------------
1448 class WXDLLIMPEXP_CORE wxDCBrushChanger
1451 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1453 m_dc
.SetBrush(brush
);
1458 if ( m_brushOld
.IsOk() )
1459 m_dc
.SetBrush(m_brushOld
);
1467 wxDECLARE_NO_COPY_CLASS(wxDCBrushChanger
);
1470 // ----------------------------------------------------------------------------
1471 // another small helper class: sets the clipping region in its ctor and
1472 // destroys it in the dtor
1473 // ----------------------------------------------------------------------------
1475 class WXDLLIMPEXP_CORE wxDCClipper
1478 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1479 { dc
.SetClippingRegion(r
.GetBox()); }
1480 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1481 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1482 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1483 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1485 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1490 wxDECLARE_NO_COPY_CLASS(wxDCClipper
);
1493 // ----------------------------------------------------------------------------
1494 // helper class: you can use it to temporarily change the DC font and
1495 // restore it automatically when the object goes out of scope
1496 // ----------------------------------------------------------------------------
1498 class WXDLLIMPEXP_CORE wxDCFontChanger
1501 wxDCFontChanger(wxDC
& dc
)
1502 : m_dc(dc
), m_fontOld()
1506 wxDCFontChanger(wxDC
& dc
, const wxFont
& font
)
1507 : m_dc(dc
), m_fontOld(dc
.GetFont())
1512 void Set(const wxFont
& font
)
1514 if ( !m_fontOld
.IsOk() )
1515 m_fontOld
= m_dc
.GetFont();
1521 if ( m_fontOld
.IsOk() )
1522 m_dc
.SetFont(m_fontOld
);
1530 wxDECLARE_NO_COPY_CLASS(wxDCFontChanger
);
1534 #endif // _WX_DC_H_BASE_