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"
33 #include "wx/affinematrix2d.h"
35 #define wxUSE_NEW_DC 1
37 class WXDLLIMPEXP_FWD_CORE wxDC
;
38 class WXDLLIMPEXP_FWD_CORE wxClientDC
;
39 class WXDLLIMPEXP_FWD_CORE wxPaintDC
;
40 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
41 class WXDLLIMPEXP_FWD_CORE wxScreenDC
;
42 class WXDLLIMPEXP_FWD_CORE wxMemoryDC
;
43 class WXDLLIMPEXP_FWD_CORE wxPrinterDC
;
44 class WXDLLIMPEXP_FWD_CORE wxPrintData
;
46 #if wxUSE_GRAPHICS_CONTEXT
47 class WXDLLIMPEXP_FWD_CORE wxGraphicsContext
;
51 enum wxRasterOperationMode
56 wxOR_REVERSE
, // src OR (NOT dst)
57 wxAND_REVERSE
, // src AND (NOT dst)
60 wxAND_INVERT
, // (NOT src) AND dst
62 wxNOR
, // (NOT src) AND (NOT dst)
63 wxEQUIV
, // (NOT src) XOR dst
64 wxSRC_INVERT
, // (NOT src)
65 wxOR_INVERT
, // (NOT src) OR dst
66 wxNAND
, // (NOT src) OR (NOT dst)
69 #if WXWIN_COMPATIBILITY_2_8
70 ,wxROP_BLACK
= wxCLEAR
,
71 wxBLIT_BLACKNESS
= wxCLEAR
,
73 wxBLIT_SRCINVERT
= wxXOR
,
75 wxBLIT_DSTINVERT
= wxINVERT
,
76 wxROP_MERGEPENNOT
= wxOR_REVERSE
,
77 wxBLIT_00DD0228
= wxOR_REVERSE
,
78 wxROP_MASKPENNOT
= wxAND_REVERSE
,
79 wxBLIT_SRCERASE
= wxAND_REVERSE
,
80 wxROP_COPYPEN
= wxCOPY
,
81 wxBLIT_SRCCOPY
= wxCOPY
,
82 wxROP_MASKPEN
= wxAND
,
83 wxBLIT_SRCAND
= wxAND
,
84 wxROP_MASKNOTPEN
= wxAND_INVERT
,
85 wxBLIT_00220326
= wxAND_INVERT
,
87 wxBLIT_00AA0029
= wxNO_OP
,
88 wxROP_NOTMERGEPEN
= wxNOR
,
89 wxBLIT_NOTSRCERASE
= wxNOR
,
90 wxROP_NOTXORPEN
= wxEQUIV
,
91 wxBLIT_00990066
= wxEQUIV
,
92 wxROP_NOTCOPYPEN
= wxSRC_INVERT
,
93 wxBLIT_NOTSCRCOPY
= wxSRC_INVERT
,
94 wxROP_MERGENOTPEN
= wxOR_INVERT
,
95 wxBLIT_MERGEPAINT
= wxOR_INVERT
,
96 wxROP_NOTMASKPEN
= wxNAND
,
97 wxBLIT_007700E6
= wxNAND
,
98 wxROP_MERGEPEN
= wxOR
,
99 wxBLIT_SRCPAINT
= wxOR
,
101 wxBLIT_WHITENESS
= wxSET
102 #endif //WXWIN_COMPATIBILITY_2_8
106 enum wxFloodFillStyle
122 // Description of text characteristics.
135 int height
, // Total character height.
136 ascent
, // Part of the height above the baseline.
137 descent
, // Part of the height below the baseline.
138 internalLeading
, // Intra-line spacing.
139 externalLeading
, // Inter-line spacing.
140 averageWidth
; // Average font width, a.k.a. "x-width".
143 #if WXWIN_COMPATIBILITY_2_8
145 //-----------------------------------------------------------------------------
146 // wxDrawObject helper class
147 //-----------------------------------------------------------------------------
149 class WXDLLIMPEXP_CORE wxDrawObject
152 wxDEPRECATED_CONSTRUCTOR(wxDrawObject
)()
153 : m_isBBoxValid(false)
154 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
157 virtual ~wxDrawObject() { }
159 virtual void Draw(wxDC
&) const { }
161 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
165 if ( x
< m_minX
) m_minX
= x
;
166 if ( y
< m_minY
) m_minY
= y
;
167 if ( x
> m_maxX
) m_maxX
= x
;
168 if ( y
> m_maxY
) m_maxY
= y
;
172 m_isBBoxValid
= true;
181 void ResetBoundingBox()
183 m_isBBoxValid
= false;
185 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
188 // Get the final bounding box of the PostScript or Metafile picture.
190 wxCoord
MinX() const { return m_minX
; }
191 wxCoord
MaxX() const { return m_maxX
; }
192 wxCoord
MinY() const { return m_minY
; }
193 wxCoord
MaxY() const { return m_maxY
; }
195 //to define the type of object for derived objects
196 virtual int GetType()=0;
199 //for boundingbox calculation
200 bool m_isBBoxValid
:1;
201 //for boundingbox calculation
202 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
205 #endif // WXWIN_COMPATIBILITY_2_8
208 //-----------------------------------------------------------------------------
210 //-----------------------------------------------------------------------------
212 class WXDLLIMPEXP_FWD_CORE wxDCImpl
;
214 class WXDLLIMPEXP_CORE wxDCFactory
218 virtual ~wxDCFactory() {}
220 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
) = 0;
221 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
) = 0;
222 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
) = 0;
223 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
) = 0;
224 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
) = 0;
225 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
) = 0;
226 virtual wxDCImpl
* CreateScreenDC( wxScreenDC
*owner
) = 0;
227 #if wxUSE_PRINTING_ARCHITECTURE
228 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
) = 0;
231 static void Set(wxDCFactory
*factory
);
232 static wxDCFactory
*Get();
235 static wxDCFactory
*m_factory
;
238 //-----------------------------------------------------------------------------
240 //-----------------------------------------------------------------------------
242 class WXDLLIMPEXP_CORE wxNativeDCFactory
: public wxDCFactory
245 wxNativeDCFactory() {}
247 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
);
248 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
);
249 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
);
250 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
);
251 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
);
252 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
);
253 virtual wxDCImpl
* CreateScreenDC( wxScreenDC
*owner
);
254 #if wxUSE_PRINTING_ARCHITECTURE
255 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
);
259 //-----------------------------------------------------------------------------
261 //-----------------------------------------------------------------------------
263 class WXDLLIMPEXP_CORE wxDCImpl
: public wxObject
266 wxDCImpl( wxDC
*owner
);
269 wxDC
*GetOwner() const { return m_owner
; }
271 wxWindow
* GetWindow() const { return m_window
; }
273 virtual bool IsOk() const { return m_ok
; }
275 // query capabilities
277 virtual bool CanDrawBitmap() const = 0;
278 virtual bool CanGetTextExtent() const = 0;
281 virtual void* GetCairoContext() const
286 virtual void* GetHandle() const { return NULL
; }
288 // query dimension, colour deps, resolution
290 virtual void DoGetSize(int *width
, int *height
) const = 0;
291 void GetSize(int *width
, int *height
) const
293 DoGetSize(width
, height
);
297 wxSize
GetSize() const
304 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
306 virtual int GetDepth() const = 0;
307 virtual wxSize
GetPPI() const = 0;
309 // Right-To-Left (RTL) modes
311 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
312 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
316 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
317 virtual void EndDoc() { }
319 virtual void StartPage() { }
320 virtual void EndPage() { }
322 // flushing the content of this dc immediately eg onto screen
323 virtual void Flush() { }
327 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
331 if ( x
< m_minX
) m_minX
= x
;
332 if ( y
< m_minY
) m_minY
= y
;
333 if ( x
> m_maxX
) m_maxX
= x
;
334 if ( y
> m_maxY
) m_maxY
= y
;
338 m_isBBoxValid
= true;
346 void ResetBoundingBox()
348 m_isBBoxValid
= false;
350 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
353 wxCoord
MinX() const { return m_minX
; }
354 wxCoord
MaxX() const { return m_maxX
; }
355 wxCoord
MinY() const { return m_minY
; }
356 wxCoord
MaxY() const { return m_maxY
; }
358 // setters and getters
360 virtual void SetFont(const wxFont
& font
) = 0;
361 virtual const wxFont
& GetFont() const { return m_font
; }
363 virtual void SetPen(const wxPen
& pen
) = 0;
364 virtual const wxPen
& GetPen() const { return m_pen
; }
366 virtual void SetBrush(const wxBrush
& brush
) = 0;
367 virtual const wxBrush
& GetBrush() const { return m_brush
; }
369 virtual void SetBackground(const wxBrush
& brush
) = 0;
370 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
372 virtual void SetBackgroundMode(int mode
) = 0;
373 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
375 virtual void SetTextForeground(const wxColour
& colour
)
376 { m_textForegroundColour
= colour
; }
377 virtual const wxColour
& GetTextForeground() const
378 { return m_textForegroundColour
; }
380 virtual void SetTextBackground(const wxColour
& colour
)
381 { m_textBackgroundColour
= colour
; }
382 virtual const wxColour
& GetTextBackground() const
383 { return m_textBackgroundColour
; }
386 virtual void SetPalette(const wxPalette
& palette
) = 0;
387 #endif // wxUSE_PALETTE
389 // inherit the DC attributes (font and colours) from the given window
391 // this is called automatically when a window, client or paint DC is
393 virtual void InheritAttributes(wxWindow
*win
);
398 virtual void SetLogicalFunction(wxRasterOperationMode function
) = 0;
399 virtual wxRasterOperationMode
GetLogicalFunction() const
400 { return m_logicalFunction
; }
404 virtual wxCoord
GetCharHeight() const = 0;
405 virtual wxCoord
GetCharWidth() const = 0;
407 // The derived classes should really override DoGetFontMetrics() to return
408 // the correct values in the future but for now provide a default
409 // implementation in terms of DoGetTextExtent() to avoid breaking the
410 // compilation of all other ports as wxMSW is the only one to implement it.
411 virtual void DoGetFontMetrics(int *height
,
414 int *internalLeading
,
415 int *externalLeading
,
416 int *averageWidth
) const;
418 virtual void DoGetTextExtent(const wxString
& string
,
419 wxCoord
*x
, wxCoord
*y
,
420 wxCoord
*descent
= NULL
,
421 wxCoord
*externalLeading
= NULL
,
422 const wxFont
*theFont
= NULL
) const = 0;
423 virtual void GetMultiLineTextExtent(const wxString
& string
,
426 wxCoord
*heightLine
= NULL
,
427 const wxFont
*font
= NULL
) const;
428 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
432 virtual void Clear() = 0;
436 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
437 wxCoord width
, wxCoord height
) = 0;
439 // NB: this function works with device coordinates, not the logical ones!
440 virtual void DoSetDeviceClippingRegion(const wxRegion
& region
) = 0;
442 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
443 wxCoord
*w
, wxCoord
*h
) const
450 *w
= m_clipX2
- m_clipX1
;
452 *h
= m_clipY2
- m_clipY1
;
455 virtual void DestroyClippingRegion() { ResetClipping(); }
458 // coordinates conversions and transforms
460 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
461 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
462 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
463 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
464 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
465 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
466 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
467 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
469 virtual void SetMapMode(wxMappingMode mode
);
470 virtual wxMappingMode
GetMapMode() const { return m_mappingMode
; }
472 virtual void SetUserScale(double x
, double y
);
473 virtual void GetUserScale(double *x
, double *y
) const
475 if ( x
) *x
= m_userScaleX
;
476 if ( y
) *y
= m_userScaleY
;
479 virtual void SetLogicalScale(double x
, double y
);
480 virtual void GetLogicalScale(double *x
, double *y
) const
482 if ( x
) *x
= m_logicalScaleX
;
483 if ( y
) *y
= m_logicalScaleY
;
486 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
487 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
489 if ( x
) *x
= m_logicalOriginX
;
490 if ( y
) *y
= m_logicalOriginY
;
493 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
494 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
496 if ( x
) *x
= m_deviceOriginX
;
497 if ( y
) *y
= m_deviceOriginY
;
500 #if wxUSE_DC_TRANSFORM_MATRIX
501 // Transform matrix support is not available in most ports right now
502 // (currently only wxMSW provides it) so do nothing in these methods by
504 virtual bool CanUseTransformMatrix() const
506 virtual bool SetTransformMatrix(const wxAffineMatrix2D
& WXUNUSED(matrix
))
508 virtual wxAffineMatrix2D
GetTransformMatrix() const
509 { return wxAffineMatrix2D(); }
510 virtual void ResetTransformMatrix()
512 #endif // wxUSE_DC_TRANSFORM_MATRIX
514 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
516 virtual void ComputeScaleAndOrigin();
518 // this needs to overidden if the axis is inverted
519 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
522 // Native Windows functions using the underlying HDC don't honour GDI+
523 // transformations which may be applied to it. Using this function we can
524 // transform the coordinates manually before passing them to such functions
525 // (as in e.g. wxRendererMSW code). It doesn't do anything if this is not a
527 virtual wxRect
MSWApplyGDIPlusTransform(const wxRect
& r
) const
534 // ---------------------------------------------------------
535 // the actual drawing API
537 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
538 wxFloodFillStyle style
= wxFLOOD_SURFACE
) = 0;
540 virtual void DoGradientFillLinear(const wxRect
& rect
,
541 const wxColour
& initialColour
,
542 const wxColour
& destColour
,
543 wxDirection nDirection
= wxEAST
);
545 virtual void DoGradientFillConcentric(const wxRect
& rect
,
546 const wxColour
& initialColour
,
547 const wxColour
& destColour
,
548 const wxPoint
& circleCenter
);
550 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
552 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
553 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
555 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
556 wxCoord x2
, wxCoord y2
,
557 wxCoord xc
, wxCoord yc
) = 0;
558 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
559 wxCoord width
, wxCoord height
);
560 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
561 double sa
, double ea
) = 0;
563 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
564 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
565 wxCoord width
, wxCoord height
,
567 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
568 wxCoord width
, wxCoord height
) = 0;
570 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
572 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
573 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
574 bool useMask
= false) = 0;
576 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
577 virtual void DoDrawRotatedText(const wxString
& text
,
578 wxCoord x
, wxCoord y
, double angle
) = 0;
580 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
581 wxCoord width
, wxCoord height
,
583 wxCoord xsrc
, wxCoord ysrc
,
584 wxRasterOperationMode rop
= wxCOPY
,
585 bool useMask
= false,
586 wxCoord xsrcMask
= wxDefaultCoord
,
587 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
589 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
590 wxCoord dstWidth
, wxCoord dstHeight
,
592 wxCoord xsrc
, wxCoord ysrc
,
593 wxCoord srcWidth
, wxCoord srcHeight
,
594 wxRasterOperationMode rop
= wxCOPY
,
595 bool useMask
= false,
596 wxCoord xsrcMask
= wxDefaultCoord
,
597 wxCoord ysrcMask
= wxDefaultCoord
);
599 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
600 { return wxNullBitmap
; }
603 virtual void DoDrawLines(int n
, wxPoint points
[],
604 wxCoord xoffset
, wxCoord yoffset
) = 0;
605 virtual void DrawLines(const wxPointList
*list
,
606 wxCoord xoffset
, wxCoord yoffset
);
608 virtual void DoDrawPolygon(int n
, wxPoint points
[],
609 wxCoord xoffset
, wxCoord yoffset
,
610 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
) = 0;
611 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
612 wxCoord xoffset
, wxCoord yoffset
,
613 wxPolygonFillMode fillStyle
);
614 void DrawPolygon(const wxPointList
*list
,
615 wxCoord xoffset
, wxCoord yoffset
,
616 wxPolygonFillMode fillStyle
);
620 void DrawSpline(wxCoord x1
, wxCoord y1
,
621 wxCoord x2
, wxCoord y2
,
622 wxCoord x3
, wxCoord y3
);
623 void DrawSpline(int n
, wxPoint points
[]);
624 void DrawSpline(const wxPointList
*points
) { DoDrawSpline(points
); }
626 virtual void DoDrawSpline(const wxPointList
*points
);
629 // ---------------------------------------------------------
630 // wxMemoryDC Impl API
632 virtual void DoSelect(const wxBitmap
& WXUNUSED(bmp
))
635 virtual const wxBitmap
& GetSelectedBitmap() const
636 { return wxNullBitmap
; }
637 virtual wxBitmap
& GetSelectedBitmap()
638 { return wxNullBitmap
; }
640 // ---------------------------------------------------------
641 // wxPrinterDC Impl API
643 virtual wxRect
GetPaperRect() const
644 { int w
= 0; int h
= 0; DoGetSize( &w
, &h
); return wxRect(0,0,w
,h
); }
646 virtual int GetResolution() const
649 #if wxUSE_GRAPHICS_CONTEXT
650 virtual wxGraphicsContext
* GetGraphicsContext() const
652 virtual void SetGraphicsContext( wxGraphicsContext
* WXUNUSED(ctx
) )
660 // unset clipping variables (after clipping region was destroyed)
665 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
669 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
670 /*! \param x Upper left corner of bounding box.
671 * \param y Upper left corner of bounding box.
672 * \param w Width of bounding box.
673 * \param h Height of bounding box.
674 * \param sa Starting angle of arc
675 * (counterclockwise, start at 3 o'clock, 360 is full circle).
676 * \param ea Ending angle of arc.
677 * \param angle Rotation angle, the Arc will be rotated after
678 * calculating begin and end.
680 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
681 wxCoord width
, wxCoord height
,
682 double sa
= 0, double ea
= 0, double angle
= 0 )
683 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
685 void DrawEllipticArcRot( const wxPoint
& pt
,
687 double sa
= 0, double ea
= 0, double angle
= 0 )
688 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
690 void DrawEllipticArcRot( const wxRect
& rect
,
691 double sa
= 0, double ea
= 0, double angle
= 0 )
692 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
694 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
695 wxCoord w
, wxCoord h
,
696 double sa
= 0, double ea
= 0, double angle
= 0 );
698 //! Rotates points around center.
699 /*! This is a quite straight method, it calculates in pixels
700 * and so it produces rounding errors.
701 * \param points The points inside will be rotated.
702 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
703 * \param center Center of rotation.
705 void Rotate( wxPointList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
707 // used by DrawEllipticArcRot
708 // Careful: wxList gets filled with points you have to delete later.
709 void CalculateEllipticPoints( wxPointList
* points
,
710 wxCoord xStart
, wxCoord yStart
,
711 wxCoord w
, wxCoord h
,
712 double sa
, double ea
);
713 #endif // __WXWINCE__
715 // returns adjustment factor for converting wxFont "point size"; in wx
716 // it is point size on screen and needs to be multiplied by this value
717 // for rendering on higher-resolution DCs such as printer ones
718 static float GetFontPointSizeAdjustment(float dpi
);
720 // window on which the DC draws or NULL
727 bool m_isInteractive
:1;
728 bool m_isBBoxValid
:1;
730 // coordinate system variables
732 wxCoord m_logicalOriginX
, m_logicalOriginY
;
733 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
735 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
736 // is not at 0,0. This was the case under
737 // Mac's GrafPorts (coordinate system
738 // used toplevel window's origin) and
739 // e.g. for Postscript, where the native
740 // origin in the bottom left corner.
741 double m_logicalScaleX
, m_logicalScaleY
;
742 double m_userScaleX
, m_userScaleY
;
743 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
745 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
747 // what is a mm on a screen you don't know the size of?
748 double m_mm_to_pix_x
,
751 // bounding and clipping boxes
752 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
753 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
755 wxRasterOperationMode m_logicalFunction
;
756 int m_backgroundMode
;
757 wxMappingMode m_mappingMode
;
761 wxBrush m_backgroundBrush
;
762 wxColour m_textForegroundColour
;
763 wxColour m_textBackgroundColour
;
768 bool m_hasCustomPalette
;
769 #endif // wxUSE_PALETTE
772 DECLARE_ABSTRACT_CLASS(wxDCImpl
)
776 class WXDLLIMPEXP_CORE wxDC
: public wxObject
779 // copy attributes (font, colours and writing direction) from another DC
780 void CopyAttributes(const wxDC
& dc
);
782 virtual ~wxDC() { delete m_pimpl
; }
786 const wxDCImpl
*GetImpl() const
789 wxWindow
*GetWindow() const
790 { return m_pimpl
->GetWindow(); }
792 void *GetHandle() const
793 { return m_pimpl
->GetHandle(); }
796 { return m_pimpl
&& m_pimpl
->IsOk(); }
798 // query capabilities
800 bool CanDrawBitmap() const
801 { return m_pimpl
->CanDrawBitmap(); }
802 bool CanGetTextExtent() const
803 { return m_pimpl
->CanGetTextExtent(); }
805 // query dimension, colour deps, resolution
807 void GetSize(int *width
, int *height
) const
808 { m_pimpl
->DoGetSize(width
, height
); }
809 wxSize
GetSize() const
810 { return m_pimpl
->GetSize(); }
812 void GetSizeMM(int* width
, int* height
) const
813 { m_pimpl
->DoGetSizeMM(width
, height
); }
814 wxSize
GetSizeMM() const
817 m_pimpl
->DoGetSizeMM(&w
, &h
);
822 { return m_pimpl
->GetDepth(); }
823 wxSize
GetPPI() const
824 { return m_pimpl
->GetPPI(); }
826 virtual int GetResolution() const
827 { return m_pimpl
->GetResolution(); }
829 // Right-To-Left (RTL) modes
831 void SetLayoutDirection(wxLayoutDirection dir
)
832 { m_pimpl
->SetLayoutDirection( dir
); }
833 wxLayoutDirection
GetLayoutDirection() const
834 { return m_pimpl
->GetLayoutDirection(); }
838 bool StartDoc(const wxString
& message
)
839 { return m_pimpl
->StartDoc(message
); }
841 { m_pimpl
->EndDoc(); }
844 { m_pimpl
->StartPage(); }
846 { m_pimpl
->EndPage(); }
850 void CalcBoundingBox(wxCoord x
, wxCoord y
)
851 { m_pimpl
->CalcBoundingBox(x
,y
); }
852 void ResetBoundingBox()
853 { m_pimpl
->ResetBoundingBox(); }
856 { return m_pimpl
->MinX(); }
858 { return m_pimpl
->MaxX(); }
860 { return m_pimpl
->MinY(); }
862 { return m_pimpl
->MaxY(); }
864 // setters and getters
866 void SetFont(const wxFont
& font
)
867 { m_pimpl
->SetFont( font
); }
868 const wxFont
& GetFont() const
869 { return m_pimpl
->GetFont(); }
871 void SetPen(const wxPen
& pen
)
872 { m_pimpl
->SetPen( pen
); }
873 const wxPen
& GetPen() const
874 { return m_pimpl
->GetPen(); }
876 void SetBrush(const wxBrush
& brush
)
877 { m_pimpl
->SetBrush( brush
); }
878 const wxBrush
& GetBrush() const
879 { return m_pimpl
->GetBrush(); }
881 void SetBackground(const wxBrush
& brush
)
882 { m_pimpl
->SetBackground( brush
); }
883 const wxBrush
& GetBackground() const
884 { return m_pimpl
->GetBackground(); }
886 void SetBackgroundMode(int mode
)
887 { m_pimpl
->SetBackgroundMode( mode
); }
888 int GetBackgroundMode() const
889 { return m_pimpl
->GetBackgroundMode(); }
891 void SetTextForeground(const wxColour
& colour
)
892 { m_pimpl
->SetTextForeground(colour
); }
893 const wxColour
& GetTextForeground() const
894 { return m_pimpl
->GetTextForeground(); }
896 void SetTextBackground(const wxColour
& colour
)
897 { m_pimpl
->SetTextBackground(colour
); }
898 const wxColour
& GetTextBackground() const
899 { return m_pimpl
->GetTextBackground(); }
902 void SetPalette(const wxPalette
& palette
)
903 { m_pimpl
->SetPalette(palette
); }
904 #endif // wxUSE_PALETTE
908 void SetLogicalFunction(wxRasterOperationMode function
)
909 { m_pimpl
->SetLogicalFunction(function
); }
910 wxRasterOperationMode
GetLogicalFunction() const
911 { return m_pimpl
->GetLogicalFunction(); }
915 wxCoord
GetCharHeight() const
916 { return m_pimpl
->GetCharHeight(); }
917 wxCoord
GetCharWidth() const
918 { return m_pimpl
->GetCharWidth(); }
920 wxFontMetrics
GetFontMetrics() const
923 m_pimpl
->DoGetFontMetrics(&fm
.height
, &fm
.ascent
, &fm
.descent
,
924 &fm
.internalLeading
, &fm
.externalLeading
,
929 void GetTextExtent(const wxString
& string
,
930 wxCoord
*x
, wxCoord
*y
,
931 wxCoord
*descent
= NULL
,
932 wxCoord
*externalLeading
= NULL
,
933 const wxFont
*theFont
= NULL
) const
934 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
936 wxSize
GetTextExtent(const wxString
& string
) const
939 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
943 void GetMultiLineTextExtent(const wxString
& string
,
946 wxCoord
*heightLine
= NULL
,
947 const wxFont
*font
= NULL
) const
948 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
950 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
953 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
957 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
958 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
963 { m_pimpl
->Clear(); }
967 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
968 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
969 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
970 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
971 void SetClippingRegion(const wxRect
& rect
)
972 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
974 // unlike the functions above, the coordinates of the region used in this
975 // one are in device coordinates, not the logical ones
976 void SetDeviceClippingRegion(const wxRegion
& region
)
977 { m_pimpl
->DoSetDeviceClippingRegion(region
); }
979 // this function is deprecated because its name is confusing: you may
980 // expect it to work with logical coordinates but, in fact, it does exactly
981 // the same thing as SetDeviceClippingRegion()
983 // please review the code using it and either replace it with calls to
984 // SetDeviceClippingRegion() or correct it if it was [wrongly] passing
985 // logical coordinates to this function
986 wxDEPRECATED_INLINE(void SetClippingRegion(const wxRegion
& region
),
987 SetDeviceClippingRegion(region
); )
989 void DestroyClippingRegion()
990 { m_pimpl
->DestroyClippingRegion(); }
992 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
993 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
994 void GetClippingBox(wxRect
& rect
) const
995 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
997 // coordinates conversions and transforms
999 wxCoord
DeviceToLogicalX(wxCoord x
) const
1000 { return m_pimpl
->DeviceToLogicalX(x
); }
1001 wxCoord
DeviceToLogicalY(wxCoord y
) const
1002 { return m_pimpl
->DeviceToLogicalY(y
); }
1003 wxCoord
DeviceToLogicalXRel(wxCoord x
) const
1004 { return m_pimpl
->DeviceToLogicalXRel(x
); }
1005 wxCoord
DeviceToLogicalYRel(wxCoord y
) const
1006 { return m_pimpl
->DeviceToLogicalYRel(y
); }
1007 wxCoord
LogicalToDeviceX(wxCoord x
) const
1008 { return m_pimpl
->LogicalToDeviceX(x
); }
1009 wxCoord
LogicalToDeviceY(wxCoord y
) const
1010 { return m_pimpl
->LogicalToDeviceY(y
); }
1011 wxCoord
LogicalToDeviceXRel(wxCoord x
) const
1012 { return m_pimpl
->LogicalToDeviceXRel(x
); }
1013 wxCoord
LogicalToDeviceYRel(wxCoord y
) const
1014 { return m_pimpl
->LogicalToDeviceYRel(y
); }
1016 void SetMapMode(wxMappingMode mode
)
1017 { m_pimpl
->SetMapMode(mode
); }
1018 wxMappingMode
GetMapMode() const
1019 { return m_pimpl
->GetMapMode(); }
1021 void SetUserScale(double x
, double y
)
1022 { m_pimpl
->SetUserScale(x
,y
); }
1023 void GetUserScale(double *x
, double *y
) const
1024 { m_pimpl
->GetUserScale( x
, y
); }
1026 void SetLogicalScale(double x
, double y
)
1027 { m_pimpl
->SetLogicalScale( x
, y
); }
1028 void GetLogicalScale(double *x
, double *y
) const
1029 { m_pimpl
->GetLogicalScale( x
, y
); }
1031 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
1032 { m_pimpl
->SetLogicalOrigin(x
,y
); }
1033 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1034 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
1035 wxPoint
GetLogicalOrigin() const
1036 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
1038 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
1039 { m_pimpl
->SetDeviceOrigin( x
, y
); }
1040 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1041 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
1042 wxPoint
GetDeviceOrigin() const
1043 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
1045 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
1046 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
1048 #if wxUSE_DC_TRANSFORM_MATRIX
1049 bool CanUseTransformMatrix() const
1050 { return m_pimpl
->CanUseTransformMatrix(); }
1052 bool SetTransformMatrix(const wxAffineMatrix2D
&matrix
)
1053 { return m_pimpl
->SetTransformMatrix(matrix
); }
1055 wxAffineMatrix2D
GetTransformMatrix() const
1056 { return m_pimpl
->GetTransformMatrix(); }
1058 void ResetTransformMatrix()
1059 { m_pimpl
->ResetTransformMatrix(); }
1060 #endif // wxUSE_DC_TRANSFORM_MATRIX
1063 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
1064 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
1067 // -----------------------------------------------
1068 // the actual drawing API
1070 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1071 wxFloodFillStyle style
= wxFLOOD_SURFACE
)
1072 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
1073 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
1074 wxFloodFillStyle style
= wxFLOOD_SURFACE
)
1075 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
1077 // fill the area specified by rect with a radial gradient, starting from
1078 // initialColour in the centre of the cercle and fading to destColour.
1079 void GradientFillConcentric(const wxRect
& rect
,
1080 const wxColour
& initialColour
,
1081 const wxColour
& destColour
)
1082 { m_pimpl
->DoGradientFillConcentric( rect
, initialColour
, destColour
,
1083 wxPoint(rect
.GetWidth() / 2,
1084 rect
.GetHeight() / 2)); }
1086 void GradientFillConcentric(const wxRect
& rect
,
1087 const wxColour
& initialColour
,
1088 const wxColour
& destColour
,
1089 const wxPoint
& circleCenter
)
1090 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
1092 // fill the area specified by rect with a linear gradient
1093 void GradientFillLinear(const wxRect
& rect
,
1094 const wxColour
& initialColour
,
1095 const wxColour
& destColour
,
1096 wxDirection nDirection
= wxEAST
)
1097 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
1099 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
1100 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
1101 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
1102 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
1104 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1105 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
1106 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
1107 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
1109 void CrossHair(wxCoord x
, wxCoord y
)
1110 { m_pimpl
->DoCrossHair(x
, y
); }
1111 void CrossHair(const wxPoint
& pt
)
1112 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
1114 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
1115 wxCoord xc
, wxCoord yc
)
1116 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
1117 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
1118 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
1120 void DrawCheckMark(wxCoord x
, wxCoord y
,
1121 wxCoord width
, wxCoord height
)
1122 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
1123 void DrawCheckMark(const wxRect
& rect
)
1124 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1126 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1127 double sa
, double ea
)
1128 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
1129 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
1130 double sa
, double ea
)
1131 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
1133 void DrawPoint(wxCoord x
, wxCoord y
)
1134 { m_pimpl
->DoDrawPoint(x
, y
); }
1135 void DrawPoint(const wxPoint
& pt
)
1136 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
1138 void DrawLines(int n
, wxPoint points
[],
1139 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1140 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
1141 void DrawLines(const wxPointList
*list
,
1142 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1143 { m_pimpl
->DrawLines( list
, xoffset
, yoffset
); }
1144 #if WXWIN_COMPATIBILITY_2_8
1145 wxDEPRECATED( void DrawLines(const wxList
*list
,
1146 wxCoord xoffset
= 0, wxCoord yoffset
= 0) );
1147 #endif // WXWIN_COMPATIBILITY_2_8
1149 void DrawPolygon(int n
, wxPoint points
[],
1150 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1151 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
)
1152 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
1153 void DrawPolygon(const wxPointList
*list
,
1154 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1155 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
)
1156 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
1157 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1158 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1159 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
)
1160 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
1161 #if WXWIN_COMPATIBILITY_2_8
1162 wxDEPRECATED( void DrawPolygon(const wxList
*list
,
1163 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1164 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
) );
1165 #endif // WXWIN_COMPATIBILITY_2_8
1167 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1168 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
1169 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
1170 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1171 void DrawRectangle(const wxRect
& rect
)
1172 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1174 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
1176 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
1177 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
1179 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
1180 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
1181 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1183 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1184 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1185 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1186 { m_pimpl
->DoDrawEllipse(pt
.x
- radius
, pt
.y
- radius
, 2*radius
, 2*radius
); }
1188 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1189 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
1190 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1191 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1192 void DrawEllipse(const wxRect
& rect
)
1193 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1195 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1196 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
1197 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1198 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1200 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1201 bool useMask
= false)
1202 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
1203 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1204 bool useMask
= false)
1205 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1207 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1208 { m_pimpl
->DoDrawText(text
, x
, y
); }
1209 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1210 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
1212 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1213 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
1214 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1215 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1217 // this version puts both optional bitmap and the text into the given
1218 // rectangle and aligns is as specified by alignment parameter; it also
1219 // will emphasize the character with the given index if it is != -1 and
1220 // return the bounding rectangle if required
1221 void DrawLabel(const wxString
& text
,
1222 const wxBitmap
& image
,
1224 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1225 int indexAccel
= -1,
1226 wxRect
*rectBounding
= NULL
);
1228 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1229 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1230 int indexAccel
= -1)
1231 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1233 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1234 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1235 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1236 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1238 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
1239 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1241 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1242 wxDC
*source
, const wxPoint
& srcPt
,
1243 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1244 const wxPoint
& srcPtMask
= wxDefaultPosition
)
1246 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1247 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1250 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1251 wxCoord dstWidth
, wxCoord dstHeight
,
1253 wxCoord srcX
, wxCoord srcY
,
1254 wxCoord srcWidth
, wxCoord srcHeight
,
1255 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1256 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1258 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1259 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1261 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1262 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1263 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1264 const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1266 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1267 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1270 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1272 return m_pimpl
->DoGetAsBitmap(subrect
);
1276 void DrawSpline(wxCoord x1
, wxCoord y1
,
1277 wxCoord x2
, wxCoord y2
,
1278 wxCoord x3
, wxCoord y3
)
1279 { m_pimpl
->DrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
1280 void DrawSpline(int n
, wxPoint points
[])
1281 { m_pimpl
->DrawSpline(n
,points
); }
1282 void DrawSpline(const wxPointList
*points
)
1283 { m_pimpl
->DrawSpline(points
); }
1284 #endif // wxUSE_SPLINES
1287 #if WXWIN_COMPATIBILITY_2_8
1288 // for compatibility with the old code when wxCoord was long everywhere
1289 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1291 long *descent
= NULL
,
1292 long *externalLeading
= NULL
,
1293 const wxFont
*theFont
= NULL
) const );
1294 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1295 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1296 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1298 wxDEPRECATED( void DrawObject(wxDrawObject
* drawobject
) );
1299 #endif // WXWIN_COMPATIBILITY_2_8
1302 // GetHDC() is the simplest way to retrieve an HDC From a wxDC but only
1303 // works if this wxDC is GDI-based and fails for GDI+ contexts (and
1304 // anything else without HDC, e.g. wxPostScriptDC)
1305 WXHDC
GetHDC() const;
1307 // don't use these methods manually, use GetTempHDC() instead
1308 virtual WXHDC
AcquireHDC() { return GetHDC(); }
1309 virtual void ReleaseHDC(WXHDC
WXUNUSED(hdc
)) { }
1311 // helper class holding the result of GetTempHDC() with std::auto_ptr<>-like
1312 // semantics, i.e. it is moved when copied
1318 m_hdc(dc
.AcquireHDC())
1322 TempHDC(const TempHDC
& thdc
)
1326 const_cast<TempHDC
&>(thdc
).m_hdc
= 0;
1332 m_dc
.ReleaseHDC(m_hdc
);
1335 WXHDC
GetHDC() const { return m_hdc
; }
1341 wxDECLARE_NO_ASSIGN_CLASS(TempHDC
);
1344 // GetTempHDC() also works for wxGCDC (but still not for wxPostScriptDC &c)
1345 TempHDC
GetTempHDC() { return TempHDC(*this); }
1348 #if wxUSE_GRAPHICS_CONTEXT
1349 virtual wxGraphicsContext
* GetGraphicsContext() const
1351 return m_pimpl
->GetGraphicsContext();
1353 virtual void SetGraphicsContext( wxGraphicsContext
* ctx
)
1355 m_pimpl
->SetGraphicsContext(ctx
);
1360 // ctor takes ownership of the pointer
1361 wxDC(wxDCImpl
*pimpl
) : m_pimpl(pimpl
) { }
1363 wxDCImpl
* const m_pimpl
;
1366 DECLARE_ABSTRACT_CLASS(wxDC
)
1367 wxDECLARE_NO_COPY_CLASS(wxDC
);
1370 // ----------------------------------------------------------------------------
1371 // helper class: you can use it to temporarily change the DC text colour and
1372 // restore it automatically when the object goes out of scope
1373 // ----------------------------------------------------------------------------
1375 class WXDLLIMPEXP_CORE wxDCTextColourChanger
1378 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1380 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1385 ~wxDCTextColourChanger()
1387 if ( m_colFgOld
.IsOk() )
1388 m_dc
.SetTextForeground(m_colFgOld
);
1391 void Set(const wxColour
& col
)
1393 if ( !m_colFgOld
.IsOk() )
1394 m_colFgOld
= m_dc
.GetTextForeground();
1395 m_dc
.SetTextForeground(col
);
1401 wxColour m_colFgOld
;
1403 wxDECLARE_NO_COPY_CLASS(wxDCTextColourChanger
);
1406 // ----------------------------------------------------------------------------
1407 // helper class: you can use it to temporarily change the DC pen and
1408 // restore it automatically when the object goes out of scope
1409 // ----------------------------------------------------------------------------
1411 class WXDLLIMPEXP_CORE wxDCPenChanger
1414 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1421 if ( m_penOld
.IsOk() )
1422 m_dc
.SetPen(m_penOld
);
1430 wxDECLARE_NO_COPY_CLASS(wxDCPenChanger
);
1433 // ----------------------------------------------------------------------------
1434 // helper class: you can use it to temporarily change the DC brush and
1435 // restore it automatically when the object goes out of scope
1436 // ----------------------------------------------------------------------------
1438 class WXDLLIMPEXP_CORE wxDCBrushChanger
1441 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1443 m_dc
.SetBrush(brush
);
1448 if ( m_brushOld
.IsOk() )
1449 m_dc
.SetBrush(m_brushOld
);
1457 wxDECLARE_NO_COPY_CLASS(wxDCBrushChanger
);
1460 // ----------------------------------------------------------------------------
1461 // another small helper class: sets the clipping region in its ctor and
1462 // destroys it in the dtor
1463 // ----------------------------------------------------------------------------
1465 class WXDLLIMPEXP_CORE wxDCClipper
1468 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1469 { dc
.SetClippingRegion(r
.GetBox()); }
1470 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1471 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1472 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1473 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1475 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1480 wxDECLARE_NO_COPY_CLASS(wxDCClipper
);
1483 // ----------------------------------------------------------------------------
1484 // helper class: you can use it to temporarily change the DC font and
1485 // restore it automatically when the object goes out of scope
1486 // ----------------------------------------------------------------------------
1488 class WXDLLIMPEXP_CORE wxDCFontChanger
1491 wxDCFontChanger(wxDC
& dc
)
1492 : m_dc(dc
), m_fontOld()
1496 wxDCFontChanger(wxDC
& dc
, const wxFont
& font
)
1497 : m_dc(dc
), m_fontOld(dc
.GetFont())
1502 void Set(const wxFont
& font
)
1504 if ( !m_fontOld
.IsOk() )
1505 m_fontOld
= m_dc
.GetFont();
1511 if ( m_fontOld
.IsOk() )
1512 m_dc
.SetFont(m_fontOld
);
1520 wxDECLARE_NO_COPY_CLASS(wxDCFontChanger
);
1524 #endif // _WX_DC_H_BASE_