1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DC_H_BASE_
13 #define _WX_DC_H_BASE_
15 // ----------------------------------------------------------------------------
16 // headers which we must include here
17 // ----------------------------------------------------------------------------
19 #include "wx/object.h" // the base class
21 #include "wx/intl.h" // for wxLayoutDirection
22 #include "wx/cursor.h" // we have member variables of these classes
23 #include "wx/font.h" // so we can't do without them
24 #include "wx/colour.h"
25 #include "wx/bitmap.h" // for wxNullBitmap
28 #include "wx/palette.h"
29 #include "wx/dynarray.h"
32 #include "wx/region.h"
34 #define wxUSE_NEW_DC 1
36 class WXDLLIMPEXP_FWD_CORE wxDC
;
37 class WXDLLIMPEXP_FWD_CORE wxClientDC
;
38 class WXDLLIMPEXP_FWD_CORE wxPaintDC
;
39 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
40 class WXDLLIMPEXP_FWD_CORE wxScreenDC
;
41 class WXDLLIMPEXP_FWD_CORE wxMemoryDC
;
42 class WXDLLIMPEXP_FWD_CORE wxPrinterDC
;
43 class WXDLLIMPEXP_FWD_CORE wxPrintData
;
46 enum wxRasterOperationMode
51 wxOR_REVERSE
, // src OR (NOT dst)
52 wxAND_REVERSE
, // src AND (NOT dst)
55 wxAND_INVERT
, // (NOT src) AND dst
57 wxNOR
, // (NOT src) AND (NOT dst)
58 wxEQUIV
, // (NOT src) XOR dst
59 wxSRC_INVERT
, // (NOT src)
60 wxOR_INVERT
, // (NOT src) OR dst
61 wxNAND
, // (NOT src) OR (NOT dst)
64 #if WXWIN_COMPATIBILITY_2_8
65 ,wxROP_BLACK
= wxCLEAR
,
66 wxBLIT_BLACKNESS
= wxCLEAR
,
68 wxBLIT_SRCINVERT
= wxXOR
,
70 wxBLIT_DSTINVERT
= wxINVERT
,
71 wxROP_MERGEPENNOT
= wxOR_REVERSE
,
72 wxBLIT_00DD0228
= wxOR_REVERSE
,
73 wxROP_MASKPENNOT
= wxAND_REVERSE
,
74 wxBLIT_SRCERASE
= wxAND_REVERSE
,
75 wxROP_COPYPEN
= wxCOPY
,
76 wxBLIT_SRCCOPY
= wxCOPY
,
77 wxROP_MASKPEN
= wxAND
,
78 wxBLIT_SRCAND
= wxAND
,
79 wxROP_MASKNOTPEN
= wxAND_INVERT
,
80 wxBLIT_00220326
= wxAND_INVERT
,
82 wxBLIT_00AA0029
= wxNO_OP
,
83 wxROP_NOTMERGEPEN
= wxNOR
,
84 wxBLIT_NOTSRCERASE
= wxNOR
,
85 wxROP_NOTXORPEN
= wxEQUIV
,
86 wxBLIT_00990066
= wxEQUIV
,
87 wxROP_NOTCOPYPEN
= wxSRC_INVERT
,
88 wxBLIT_NOTSCRCOPY
= wxSRC_INVERT
,
89 wxROP_MERGENOTPEN
= wxOR_INVERT
,
90 wxBLIT_MERGEPAINT
= wxOR_INVERT
,
91 wxROP_NOTMASKPEN
= wxNAND
,
92 wxBLIT_007700E6
= wxNAND
,
93 wxROP_MERGEPEN
= wxOR
,
94 wxBLIT_SRCPAINT
= wxOR
,
96 wxBLIT_WHITENESS
= wxSET
97 #endif //WXWIN_COMPATIBILITY_2_8
101 enum wxFloodFillStyle
117 // Description of text characteristics.
130 int height
, // Total character height.
131 ascent
, // Part of the height above the baseline.
132 descent
, // Part of the height below the baseline.
133 internalLeading
, // Intra-line spacing.
134 externalLeading
, // Inter-line spacing.
135 averageWidth
; // Average font width, a.k.a. "x-width".
138 #if WXWIN_COMPATIBILITY_2_8
140 //-----------------------------------------------------------------------------
141 // wxDrawObject helper class
142 //-----------------------------------------------------------------------------
144 class WXDLLIMPEXP_CORE wxDrawObject
147 wxDEPRECATED_CONSTRUCTOR(wxDrawObject
)()
148 : m_isBBoxValid(false)
149 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
152 virtual ~wxDrawObject() { }
154 virtual void Draw(wxDC
&) const { }
156 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
160 if ( x
< m_minX
) m_minX
= x
;
161 if ( y
< m_minY
) m_minY
= y
;
162 if ( x
> m_maxX
) m_maxX
= x
;
163 if ( y
> m_maxY
) m_maxY
= y
;
167 m_isBBoxValid
= true;
176 void ResetBoundingBox()
178 m_isBBoxValid
= false;
180 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
183 // Get the final bounding box of the PostScript or Metafile picture.
185 wxCoord
MinX() const { return m_minX
; }
186 wxCoord
MaxX() const { return m_maxX
; }
187 wxCoord
MinY() const { return m_minY
; }
188 wxCoord
MaxY() const { return m_maxY
; }
190 //to define the type of object for derived objects
191 virtual int GetType()=0;
194 //for boundingbox calculation
195 bool m_isBBoxValid
:1;
196 //for boundingbox calculation
197 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
200 #endif // WXWIN_COMPATIBILITY_2_8
203 //-----------------------------------------------------------------------------
205 //-----------------------------------------------------------------------------
207 class WXDLLIMPEXP_FWD_CORE wxDCImpl
;
209 class WXDLLIMPEXP_CORE wxDCFactory
213 virtual ~wxDCFactory() {}
215 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
) = 0;
216 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
) = 0;
217 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
) = 0;
218 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
) = 0;
219 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
) = 0;
220 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
) = 0;
221 virtual wxDCImpl
* CreateScreenDC( wxScreenDC
*owner
) = 0;
222 #if wxUSE_PRINTING_ARCHITECTURE
223 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
) = 0;
226 static void Set(wxDCFactory
*factory
);
227 static wxDCFactory
*Get();
230 static wxDCFactory
*m_factory
;
233 //-----------------------------------------------------------------------------
235 //-----------------------------------------------------------------------------
237 class WXDLLIMPEXP_CORE wxNativeDCFactory
: public wxDCFactory
240 wxNativeDCFactory() {}
242 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
);
243 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
);
244 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
);
245 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
);
246 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
);
247 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
);
248 virtual wxDCImpl
* CreateScreenDC( wxScreenDC
*owner
);
249 #if wxUSE_PRINTING_ARCHITECTURE
250 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
);
254 //-----------------------------------------------------------------------------
256 //-----------------------------------------------------------------------------
258 class WXDLLIMPEXP_CORE wxDCImpl
: public wxObject
261 wxDCImpl( wxDC
*owner
);
264 wxDC
*GetOwner() const { return m_owner
; }
266 wxWindow
* GetWindow() const { return m_window
; }
268 virtual bool IsOk() const { return m_ok
; }
270 // query capabilities
272 virtual bool CanDrawBitmap() const = 0;
273 virtual bool CanGetTextExtent() const = 0;
276 virtual void* GetCairoContext() const
281 // query dimension, colour deps, resolution
283 virtual void DoGetSize(int *width
, int *height
) const = 0;
284 void GetSize(int *width
, int *height
) const
286 DoGetSize(width
, height
);
290 wxSize
GetSize() const
297 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
299 virtual int GetDepth() const = 0;
300 virtual wxSize
GetPPI() const = 0;
302 // Right-To-Left (RTL) modes
304 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
305 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
309 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
310 virtual void EndDoc() { }
312 virtual void StartPage() { }
313 virtual void EndPage() { }
315 // flushing the content of this dc immediately eg onto screen
316 virtual void Flush() { }
320 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
324 if ( x
< m_minX
) m_minX
= x
;
325 if ( y
< m_minY
) m_minY
= y
;
326 if ( x
> m_maxX
) m_maxX
= x
;
327 if ( y
> m_maxY
) m_maxY
= y
;
331 m_isBBoxValid
= true;
339 void ResetBoundingBox()
341 m_isBBoxValid
= false;
343 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
346 wxCoord
MinX() const { return m_minX
; }
347 wxCoord
MaxX() const { return m_maxX
; }
348 wxCoord
MinY() const { return m_minY
; }
349 wxCoord
MaxY() const { return m_maxY
; }
351 // setters and getters
353 virtual void SetFont(const wxFont
& font
) = 0;
354 virtual const wxFont
& GetFont() const { return m_font
; }
356 virtual void SetPen(const wxPen
& pen
) = 0;
357 virtual const wxPen
& GetPen() const { return m_pen
; }
359 virtual void SetBrush(const wxBrush
& brush
) = 0;
360 virtual const wxBrush
& GetBrush() const { return m_brush
; }
362 virtual void SetBackground(const wxBrush
& brush
) = 0;
363 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
365 virtual void SetBackgroundMode(int mode
) = 0;
366 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
368 virtual void SetTextForeground(const wxColour
& colour
)
369 { m_textForegroundColour
= colour
; }
370 virtual const wxColour
& GetTextForeground() const
371 { return m_textForegroundColour
; }
373 virtual void SetTextBackground(const wxColour
& colour
)
374 { m_textBackgroundColour
= colour
; }
375 virtual const wxColour
& GetTextBackground() const
376 { return m_textBackgroundColour
; }
379 virtual void SetPalette(const wxPalette
& palette
) = 0;
380 #endif // wxUSE_PALETTE
382 // inherit the DC attributes (font and colours) from the given window
384 // this is called automatically when a window, client or paint DC is
386 virtual void InheritAttributes(wxWindow
*win
);
391 virtual void SetLogicalFunction(wxRasterOperationMode function
) = 0;
392 virtual wxRasterOperationMode
GetLogicalFunction() const
393 { return m_logicalFunction
; }
397 virtual wxCoord
GetCharHeight() const = 0;
398 virtual wxCoord
GetCharWidth() const = 0;
400 // The derived classes should really override DoGetFontMetrics() to return
401 // the correct values in the future but for now provide a default
402 // implementation in terms of DoGetTextExtent() to avoid breaking the
403 // compilation of all other ports as wxMSW is the only one to implement it.
404 virtual void DoGetFontMetrics(int *height
,
407 int *internalLeading
,
408 int *externalLeading
,
409 int *averageWidth
) const;
411 virtual void DoGetTextExtent(const wxString
& string
,
412 wxCoord
*x
, wxCoord
*y
,
413 wxCoord
*descent
= NULL
,
414 wxCoord
*externalLeading
= NULL
,
415 const wxFont
*theFont
= NULL
) const = 0;
416 virtual void GetMultiLineTextExtent(const wxString
& string
,
419 wxCoord
*heightLine
= NULL
,
420 const wxFont
*font
= NULL
) const;
421 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
425 virtual void Clear() = 0;
429 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
430 wxCoord width
, wxCoord height
) = 0;
432 // NB: this function works with device coordinates, not the logical ones!
433 virtual void DoSetDeviceClippingRegion(const wxRegion
& region
) = 0;
435 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
436 wxCoord
*w
, wxCoord
*h
) const
443 *w
= m_clipX2
- m_clipX1
;
445 *h
= m_clipY2
- m_clipY1
;
448 virtual void DestroyClippingRegion() { ResetClipping(); }
451 // coordinates conversions and transforms
453 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
454 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
455 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
456 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
457 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
458 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
459 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
460 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
462 virtual void SetMapMode(wxMappingMode mode
);
463 virtual wxMappingMode
GetMapMode() const { return m_mappingMode
; }
465 virtual void SetUserScale(double x
, double y
);
466 virtual void GetUserScale(double *x
, double *y
) const
468 if ( x
) *x
= m_userScaleX
;
469 if ( y
) *y
= m_userScaleY
;
472 virtual void SetLogicalScale(double x
, double y
);
473 virtual void GetLogicalScale(double *x
, double *y
)
475 if ( x
) *x
= m_logicalScaleX
;
476 if ( y
) *y
= m_logicalScaleY
;
479 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
480 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
482 if ( x
) *x
= m_logicalOriginX
;
483 if ( y
) *y
= m_logicalOriginY
;
486 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
487 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
489 if ( x
) *x
= m_deviceOriginX
;
490 if ( y
) *y
= m_deviceOriginY
;
493 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
495 virtual void ComputeScaleAndOrigin();
497 // this needs to overidden if the axis is inverted
498 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
500 // ---------------------------------------------------------
501 // the actual drawing API
503 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
504 wxFloodFillStyle style
= wxFLOOD_SURFACE
) = 0;
506 virtual void DoGradientFillLinear(const wxRect
& rect
,
507 const wxColour
& initialColour
,
508 const wxColour
& destColour
,
509 wxDirection nDirection
= wxEAST
);
511 virtual void DoGradientFillConcentric(const wxRect
& rect
,
512 const wxColour
& initialColour
,
513 const wxColour
& destColour
,
514 const wxPoint
& circleCenter
);
516 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
518 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
519 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
521 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
522 wxCoord x2
, wxCoord y2
,
523 wxCoord xc
, wxCoord yc
) = 0;
524 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
525 wxCoord width
, wxCoord height
);
526 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
527 double sa
, double ea
) = 0;
529 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
530 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
531 wxCoord width
, wxCoord height
,
533 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
534 wxCoord width
, wxCoord height
) = 0;
536 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
538 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
539 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
540 bool useMask
= false) = 0;
542 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
543 virtual void DoDrawRotatedText(const wxString
& text
,
544 wxCoord x
, wxCoord y
, double angle
) = 0;
546 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
547 wxCoord width
, wxCoord height
,
549 wxCoord xsrc
, wxCoord ysrc
,
550 wxRasterOperationMode rop
= wxCOPY
,
551 bool useMask
= false,
552 wxCoord xsrcMask
= wxDefaultCoord
,
553 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
555 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
556 wxCoord dstWidth
, wxCoord dstHeight
,
558 wxCoord xsrc
, wxCoord ysrc
,
559 wxCoord srcWidth
, wxCoord srcHeight
,
560 wxRasterOperationMode rop
= wxCOPY
,
561 bool useMask
= false,
562 wxCoord xsrcMask
= wxDefaultCoord
,
563 wxCoord ysrcMask
= wxDefaultCoord
);
565 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
566 { return wxNullBitmap
; }
569 virtual void DoDrawLines(int n
, wxPoint points
[],
570 wxCoord xoffset
, wxCoord yoffset
) = 0;
571 virtual void DrawLines(const wxPointList
*list
,
572 wxCoord xoffset
, wxCoord yoffset
);
574 virtual void DoDrawPolygon(int n
, wxPoint points
[],
575 wxCoord xoffset
, wxCoord yoffset
,
576 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
) = 0;
577 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
578 wxCoord xoffset
, wxCoord yoffset
,
579 wxPolygonFillMode fillStyle
);
580 void DrawPolygon(const wxPointList
*list
,
581 wxCoord xoffset
, wxCoord yoffset
,
582 wxPolygonFillMode fillStyle
);
586 void DrawSpline(wxCoord x1
, wxCoord y1
,
587 wxCoord x2
, wxCoord y2
,
588 wxCoord x3
, wxCoord y3
);
589 void DrawSpline(int n
, wxPoint points
[]);
590 void DrawSpline(const wxPointList
*points
) { DoDrawSpline(points
); }
592 virtual void DoDrawSpline(const wxPointList
*points
);
595 // ---------------------------------------------------------
596 // wxMemoryDC Impl API
598 virtual void DoSelect(const wxBitmap
& WXUNUSED(bmp
))
601 virtual const wxBitmap
& GetSelectedBitmap() const
602 { return wxNullBitmap
; }
603 virtual wxBitmap
& GetSelectedBitmap()
604 { return wxNullBitmap
; }
606 // ---------------------------------------------------------
607 // wxPrinterDC Impl API
609 virtual wxRect
GetPaperRect() const
610 { int w
= 0; int h
= 0; DoGetSize( &w
, &h
); return wxRect(0,0,w
,h
); }
612 virtual int GetResolution() const
619 // unset clipping variables (after clipping region was destroyed)
624 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
628 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
629 /*! \param x Upper left corner of bounding box.
630 * \param y Upper left corner of bounding box.
631 * \param w Width of bounding box.
632 * \param h Height of bounding box.
633 * \param sa Starting angle of arc
634 * (counterclockwise, start at 3 o'clock, 360 is full circle).
635 * \param ea Ending angle of arc.
636 * \param angle Rotation angle, the Arc will be rotated after
637 * calculating begin and end.
639 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
640 wxCoord width
, wxCoord height
,
641 double sa
= 0, double ea
= 0, double angle
= 0 )
642 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
644 void DrawEllipticArcRot( const wxPoint
& pt
,
646 double sa
= 0, double ea
= 0, double angle
= 0 )
647 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
649 void DrawEllipticArcRot( const wxRect
& rect
,
650 double sa
= 0, double ea
= 0, double angle
= 0 )
651 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
653 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
654 wxCoord w
, wxCoord h
,
655 double sa
= 0, double ea
= 0, double angle
= 0 );
657 //! Rotates points around center.
658 /*! This is a quite straight method, it calculates in pixels
659 * and so it produces rounding errors.
660 * \param points The points inside will be rotated.
661 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
662 * \param center Center of rotation.
664 void Rotate( wxPointList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
666 // used by DrawEllipticArcRot
667 // Careful: wxList gets filled with points you have to delete later.
668 void CalculateEllipticPoints( wxPointList
* points
,
669 wxCoord xStart
, wxCoord yStart
,
670 wxCoord w
, wxCoord h
,
671 double sa
, double ea
);
672 #endif // __WXWINCE__
674 // returns adjustment factor for converting wxFont "point size"; in wx
675 // it is point size on screen and needs to be multiplied by this value
676 // for rendering on higher-resolution DCs such as printer ones
677 static float GetFontPointSizeAdjustment(float dpi
);
679 // window on which the DC draws or NULL
686 bool m_isInteractive
:1;
687 bool m_isBBoxValid
:1;
689 // coordinate system variables
691 wxCoord m_logicalOriginX
, m_logicalOriginY
;
692 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
694 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
695 // is not at 0,0. This was the case under
696 // Mac's GrafPorts (coordinate system
697 // used toplevel window's origin) and
698 // e.g. for Postscript, where the native
699 // origin in the bottom left corner.
700 double m_logicalScaleX
, m_logicalScaleY
;
701 double m_userScaleX
, m_userScaleY
;
702 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
704 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
706 // what is a mm on a screen you don't know the size of?
707 double m_mm_to_pix_x
,
710 // bounding and clipping boxes
711 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
712 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
714 wxRasterOperationMode m_logicalFunction
;
715 int m_backgroundMode
;
716 wxMappingMode m_mappingMode
;
720 wxBrush m_backgroundBrush
;
721 wxColour m_textForegroundColour
;
722 wxColour m_textBackgroundColour
;
727 bool m_hasCustomPalette
;
728 #endif // wxUSE_PALETTE
731 DECLARE_ABSTRACT_CLASS(wxDCImpl
)
735 class WXDLLIMPEXP_CORE wxDC
: public wxObject
738 // copy attributes (font, colours and writing direction) from another DC
739 void CopyAttributes(const wxDC
& dc
);
741 virtual ~wxDC() { delete m_pimpl
; }
745 const wxDCImpl
*GetImpl() const
748 wxWindow
*GetWindow() const
749 { return m_pimpl
->GetWindow(); }
752 { return m_pimpl
&& m_pimpl
->IsOk(); }
754 // query capabilities
756 bool CanDrawBitmap() const
757 { return m_pimpl
->CanDrawBitmap(); }
758 bool CanGetTextExtent() const
759 { return m_pimpl
->CanGetTextExtent(); }
761 // query dimension, colour deps, resolution
763 void GetSize(int *width
, int *height
) const
764 { m_pimpl
->DoGetSize(width
, height
); }
765 wxSize
GetSize() const
766 { return m_pimpl
->GetSize(); }
768 void GetSizeMM(int* width
, int* height
) const
769 { m_pimpl
->DoGetSizeMM(width
, height
); }
770 wxSize
GetSizeMM() const
773 m_pimpl
->DoGetSizeMM(&w
, &h
);
778 { return m_pimpl
->GetDepth(); }
779 wxSize
GetPPI() const
780 { return m_pimpl
->GetPPI(); }
782 virtual int GetResolution() const
783 { return m_pimpl
->GetResolution(); }
785 // Right-To-Left (RTL) modes
787 void SetLayoutDirection(wxLayoutDirection dir
)
788 { m_pimpl
->SetLayoutDirection( dir
); }
789 wxLayoutDirection
GetLayoutDirection() const
790 { return m_pimpl
->GetLayoutDirection(); }
794 bool StartDoc(const wxString
& message
)
795 { return m_pimpl
->StartDoc(message
); }
797 { m_pimpl
->EndDoc(); }
800 { m_pimpl
->StartPage(); }
802 { m_pimpl
->EndPage(); }
806 void CalcBoundingBox(wxCoord x
, wxCoord y
)
807 { m_pimpl
->CalcBoundingBox(x
,y
); }
808 void ResetBoundingBox()
809 { m_pimpl
->ResetBoundingBox(); }
812 { return m_pimpl
->MinX(); }
814 { return m_pimpl
->MaxX(); }
816 { return m_pimpl
->MinY(); }
818 { return m_pimpl
->MaxY(); }
820 // setters and getters
822 void SetFont(const wxFont
& font
)
823 { m_pimpl
->SetFont( font
); }
824 const wxFont
& GetFont() const
825 { return m_pimpl
->GetFont(); }
827 void SetPen(const wxPen
& pen
)
828 { m_pimpl
->SetPen( pen
); }
829 const wxPen
& GetPen() const
830 { return m_pimpl
->GetPen(); }
832 void SetBrush(const wxBrush
& brush
)
833 { m_pimpl
->SetBrush( brush
); }
834 const wxBrush
& GetBrush() const
835 { return m_pimpl
->GetBrush(); }
837 void SetBackground(const wxBrush
& brush
)
838 { m_pimpl
->SetBackground( brush
); }
839 const wxBrush
& GetBackground() const
840 { return m_pimpl
->GetBackground(); }
842 void SetBackgroundMode(int mode
)
843 { m_pimpl
->SetBackgroundMode( mode
); }
844 int GetBackgroundMode() const
845 { return m_pimpl
->GetBackgroundMode(); }
847 void SetTextForeground(const wxColour
& colour
)
848 { m_pimpl
->SetTextForeground(colour
); }
849 const wxColour
& GetTextForeground() const
850 { return m_pimpl
->GetTextForeground(); }
852 void SetTextBackground(const wxColour
& colour
)
853 { m_pimpl
->SetTextBackground(colour
); }
854 const wxColour
& GetTextBackground() const
855 { return m_pimpl
->GetTextBackground(); }
858 void SetPalette(const wxPalette
& palette
)
859 { m_pimpl
->SetPalette(palette
); }
860 #endif // wxUSE_PALETTE
864 void SetLogicalFunction(wxRasterOperationMode function
)
865 { m_pimpl
->SetLogicalFunction(function
); }
866 wxRasterOperationMode
GetLogicalFunction() const
867 { return m_pimpl
->GetLogicalFunction(); }
871 wxCoord
GetCharHeight() const
872 { return m_pimpl
->GetCharHeight(); }
873 wxCoord
GetCharWidth() const
874 { return m_pimpl
->GetCharWidth(); }
876 wxFontMetrics
GetFontMetrics() const
879 m_pimpl
->DoGetFontMetrics(&fm
.height
, &fm
.ascent
, &fm
.descent
,
880 &fm
.internalLeading
, &fm
.externalLeading
,
885 void GetTextExtent(const wxString
& string
,
886 wxCoord
*x
, wxCoord
*y
,
887 wxCoord
*descent
= NULL
,
888 wxCoord
*externalLeading
= NULL
,
889 const wxFont
*theFont
= NULL
) const
890 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
892 wxSize
GetTextExtent(const wxString
& string
) const
895 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
899 void GetMultiLineTextExtent(const wxString
& string
,
902 wxCoord
*heightLine
= NULL
,
903 const wxFont
*font
= NULL
) const
904 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
906 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
909 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
913 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
914 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
919 { m_pimpl
->Clear(); }
923 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
924 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
925 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
926 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
927 void SetClippingRegion(const wxRect
& rect
)
928 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
930 // unlike the functions above, the coordinates of the region used in this
931 // one are in device coordinates, not the logical ones
932 void SetDeviceClippingRegion(const wxRegion
& region
)
933 { m_pimpl
->DoSetDeviceClippingRegion(region
); }
935 // this function is deprecated because its name is confusing: you may
936 // expect it to work with logical coordinates but, in fact, it does exactly
937 // the same thing as SetDeviceClippingRegion()
939 // please review the code using it and either replace it with calls to
940 // SetDeviceClippingRegion() or correct it if it was [wrongly] passing
941 // logical coordinates to this function
942 wxDEPRECATED_INLINE(void SetClippingRegion(const wxRegion
& region
),
943 SetDeviceClippingRegion(region
); )
945 void DestroyClippingRegion()
946 { m_pimpl
->DestroyClippingRegion(); }
948 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
949 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
950 void GetClippingBox(wxRect
& rect
) const
951 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
953 // coordinates conversions and transforms
955 wxCoord
DeviceToLogicalX(wxCoord x
) const
956 { return m_pimpl
->DeviceToLogicalX(x
); }
957 wxCoord
DeviceToLogicalY(wxCoord y
) const
958 { return m_pimpl
->DeviceToLogicalY(y
); }
959 wxCoord
DeviceToLogicalXRel(wxCoord x
) const
960 { return m_pimpl
->DeviceToLogicalXRel(x
); }
961 wxCoord
DeviceToLogicalYRel(wxCoord y
) const
962 { return m_pimpl
->DeviceToLogicalYRel(y
); }
963 wxCoord
LogicalToDeviceX(wxCoord x
) const
964 { return m_pimpl
->LogicalToDeviceX(x
); }
965 wxCoord
LogicalToDeviceY(wxCoord y
) const
966 { return m_pimpl
->LogicalToDeviceY(y
); }
967 wxCoord
LogicalToDeviceXRel(wxCoord x
) const
968 { return m_pimpl
->LogicalToDeviceXRel(x
); }
969 wxCoord
LogicalToDeviceYRel(wxCoord y
) const
970 { return m_pimpl
->LogicalToDeviceYRel(y
); }
972 void SetMapMode(wxMappingMode mode
)
973 { m_pimpl
->SetMapMode(mode
); }
974 wxMappingMode
GetMapMode() const
975 { return m_pimpl
->GetMapMode(); }
977 void SetUserScale(double x
, double y
)
978 { m_pimpl
->SetUserScale(x
,y
); }
979 void GetUserScale(double *x
, double *y
) const
980 { m_pimpl
->GetUserScale( x
, y
); }
982 void SetLogicalScale(double x
, double y
)
983 { m_pimpl
->SetLogicalScale( x
, y
); }
984 void GetLogicalScale(double *x
, double *y
)
985 { m_pimpl
->GetLogicalScale( x
, y
); }
987 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
988 { m_pimpl
->SetLogicalOrigin(x
,y
); }
989 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
990 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
991 wxPoint
GetLogicalOrigin() const
992 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
994 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
995 { m_pimpl
->SetDeviceOrigin( x
, y
); }
996 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
997 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
998 wxPoint
GetDeviceOrigin() const
999 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
1001 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
1002 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
1005 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
1006 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
1009 // -----------------------------------------------
1010 // the actual drawing API
1012 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1013 wxFloodFillStyle style
= wxFLOOD_SURFACE
)
1014 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
1015 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
1016 wxFloodFillStyle style
= wxFLOOD_SURFACE
)
1017 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
1019 // fill the area specified by rect with a radial gradient, starting from
1020 // initialColour in the centre of the cercle and fading to destColour.
1021 void GradientFillConcentric(const wxRect
& rect
,
1022 const wxColour
& initialColour
,
1023 const wxColour
& destColour
)
1024 { m_pimpl
->DoGradientFillConcentric( rect
, initialColour
, destColour
,
1025 wxPoint(rect
.GetWidth() / 2,
1026 rect
.GetHeight() / 2)); }
1028 void GradientFillConcentric(const wxRect
& rect
,
1029 const wxColour
& initialColour
,
1030 const wxColour
& destColour
,
1031 const wxPoint
& circleCenter
)
1032 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
1034 // fill the area specified by rect with a linear gradient
1035 void GradientFillLinear(const wxRect
& rect
,
1036 const wxColour
& initialColour
,
1037 const wxColour
& destColour
,
1038 wxDirection nDirection
= wxEAST
)
1039 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
1041 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
1042 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
1043 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
1044 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
1046 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1047 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
1048 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
1049 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
1051 void CrossHair(wxCoord x
, wxCoord y
)
1052 { m_pimpl
->DoCrossHair(x
, y
); }
1053 void CrossHair(const wxPoint
& pt
)
1054 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
1056 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
1057 wxCoord xc
, wxCoord yc
)
1058 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
1059 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
1060 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
1062 void DrawCheckMark(wxCoord x
, wxCoord y
,
1063 wxCoord width
, wxCoord height
)
1064 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
1065 void DrawCheckMark(const wxRect
& rect
)
1066 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1068 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1069 double sa
, double ea
)
1070 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
1071 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
1072 double sa
, double ea
)
1073 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
1075 void DrawPoint(wxCoord x
, wxCoord y
)
1076 { m_pimpl
->DoDrawPoint(x
, y
); }
1077 void DrawPoint(const wxPoint
& pt
)
1078 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
1080 void DrawLines(int n
, wxPoint points
[],
1081 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1082 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
1083 void DrawLines(const wxPointList
*list
,
1084 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1085 { m_pimpl
->DrawLines( list
, xoffset
, yoffset
); }
1086 #if WXWIN_COMPATIBILITY_2_8
1087 wxDEPRECATED( void DrawLines(const wxList
*list
,
1088 wxCoord xoffset
= 0, wxCoord yoffset
= 0) );
1089 #endif // WXWIN_COMPATIBILITY_2_8
1091 void DrawPolygon(int n
, wxPoint points
[],
1092 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1093 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
)
1094 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
1095 void DrawPolygon(const wxPointList
*list
,
1096 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1097 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
)
1098 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
1099 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1100 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1101 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
)
1102 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
1103 #if WXWIN_COMPATIBILITY_2_8
1104 wxDEPRECATED( void DrawPolygon(const wxList
*list
,
1105 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1106 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
) );
1107 #endif // WXWIN_COMPATIBILITY_2_8
1109 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1110 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
1111 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
1112 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1113 void DrawRectangle(const wxRect
& rect
)
1114 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1116 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
1118 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
1119 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
1121 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
1122 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
1123 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1125 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1126 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1127 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1128 { m_pimpl
->DoDrawEllipse(pt
.x
- radius
, pt
.y
- radius
, 2*radius
, 2*radius
); }
1130 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1131 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
1132 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1133 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1134 void DrawEllipse(const wxRect
& rect
)
1135 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1137 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1138 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
1139 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1140 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1142 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1143 bool useMask
= false)
1144 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
1145 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1146 bool useMask
= false)
1147 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1149 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1150 { m_pimpl
->DoDrawText(text
, x
, y
); }
1151 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1152 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
1154 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1155 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
1156 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1157 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1159 // this version puts both optional bitmap and the text into the given
1160 // rectangle and aligns is as specified by alignment parameter; it also
1161 // will emphasize the character with the given index if it is != -1 and
1162 // return the bounding rectangle if required
1163 void DrawLabel(const wxString
& text
,
1164 const wxBitmap
& image
,
1166 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1167 int indexAccel
= -1,
1168 wxRect
*rectBounding
= NULL
);
1170 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1171 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1172 int indexAccel
= -1)
1173 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1175 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1176 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1177 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1178 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1180 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
1181 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1183 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1184 wxDC
*source
, const wxPoint
& srcPt
,
1185 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1186 const wxPoint
& srcPtMask
= wxDefaultPosition
)
1188 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1189 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1192 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1193 wxCoord dstWidth
, wxCoord dstHeight
,
1195 wxCoord srcX
, wxCoord srcY
,
1196 wxCoord srcWidth
, wxCoord srcHeight
,
1197 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1198 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1200 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1201 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1203 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1204 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1205 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1206 const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1208 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1209 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1212 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1214 return m_pimpl
->DoGetAsBitmap(subrect
);
1218 void DrawSpline(wxCoord x1
, wxCoord y1
,
1219 wxCoord x2
, wxCoord y2
,
1220 wxCoord x3
, wxCoord y3
)
1221 { m_pimpl
->DrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
1222 void DrawSpline(int n
, wxPoint points
[])
1223 { m_pimpl
->DrawSpline(n
,points
); }
1224 void DrawSpline(const wxPointList
*points
)
1225 { m_pimpl
->DrawSpline(points
); }
1226 #endif // wxUSE_SPLINES
1229 #if WXWIN_COMPATIBILITY_2_8
1230 // for compatibility with the old code when wxCoord was long everywhere
1231 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1233 long *descent
= NULL
,
1234 long *externalLeading
= NULL
,
1235 const wxFont
*theFont
= NULL
) const );
1236 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1237 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1238 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1240 wxDEPRECATED( void DrawObject(wxDrawObject
* drawobject
) );
1241 #endif // WXWIN_COMPATIBILITY_2_8
1244 // GetHDC() is the simplest way to retrieve an HDC From a wxDC but only
1245 // works if this wxDC is GDI-based and fails for GDI+ contexts (and
1246 // anything else without HDC, e.g. wxPostScriptDC)
1247 WXHDC
GetHDC() const;
1249 // don't use these methods manually, use GetTempHDC() instead
1250 virtual WXHDC
AcquireHDC() { return GetHDC(); }
1251 virtual void ReleaseHDC(WXHDC
WXUNUSED(hdc
)) { }
1253 // helper class holding the result of GetTempHDC() with std::auto_ptr<>-like
1254 // semantics, i.e. it is moved when copied
1260 m_hdc(dc
.AcquireHDC())
1264 TempHDC(const TempHDC
& thdc
)
1268 const_cast<TempHDC
&>(thdc
).m_hdc
= 0;
1274 m_dc
.ReleaseHDC(m_hdc
);
1277 WXHDC
GetHDC() const { return m_hdc
; }
1283 wxDECLARE_NO_ASSIGN_CLASS(TempHDC
);
1286 // GetTempHDC() also works for wxGCDC (but still not for wxPostScriptDC &c)
1287 TempHDC
GetTempHDC() { return TempHDC(*this); }
1291 // ctor takes ownership of the pointer
1292 wxDC(wxDCImpl
*pimpl
) : m_pimpl(pimpl
) { }
1294 wxDCImpl
* const m_pimpl
;
1297 DECLARE_ABSTRACT_CLASS(wxDC
)
1298 wxDECLARE_NO_COPY_CLASS(wxDC
);
1301 // ----------------------------------------------------------------------------
1302 // helper class: you can use it to temporarily change the DC text colour and
1303 // restore it automatically when the object goes out of scope
1304 // ----------------------------------------------------------------------------
1306 class WXDLLIMPEXP_CORE wxDCTextColourChanger
1309 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1311 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1316 ~wxDCTextColourChanger()
1318 if ( m_colFgOld
.Ok() )
1319 m_dc
.SetTextForeground(m_colFgOld
);
1322 void Set(const wxColour
& col
)
1324 if ( !m_colFgOld
.Ok() )
1325 m_colFgOld
= m_dc
.GetTextForeground();
1326 m_dc
.SetTextForeground(col
);
1332 wxColour m_colFgOld
;
1334 wxDECLARE_NO_COPY_CLASS(wxDCTextColourChanger
);
1337 // ----------------------------------------------------------------------------
1338 // helper class: you can use it to temporarily change the DC pen and
1339 // restore it automatically when the object goes out of scope
1340 // ----------------------------------------------------------------------------
1342 class WXDLLIMPEXP_CORE wxDCPenChanger
1345 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1352 if ( m_penOld
.Ok() )
1353 m_dc
.SetPen(m_penOld
);
1361 wxDECLARE_NO_COPY_CLASS(wxDCPenChanger
);
1364 // ----------------------------------------------------------------------------
1365 // helper class: you can use it to temporarily change the DC brush and
1366 // restore it automatically when the object goes out of scope
1367 // ----------------------------------------------------------------------------
1369 class WXDLLIMPEXP_CORE wxDCBrushChanger
1372 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1374 m_dc
.SetBrush(brush
);
1379 if ( m_brushOld
.Ok() )
1380 m_dc
.SetBrush(m_brushOld
);
1388 wxDECLARE_NO_COPY_CLASS(wxDCBrushChanger
);
1391 // ----------------------------------------------------------------------------
1392 // another small helper class: sets the clipping region in its ctor and
1393 // destroys it in the dtor
1394 // ----------------------------------------------------------------------------
1396 class WXDLLIMPEXP_CORE wxDCClipper
1399 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1400 { dc
.SetClippingRegion(r
.GetBox()); }
1401 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1402 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1403 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1404 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1406 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1411 wxDECLARE_NO_COPY_CLASS(wxDCClipper
);
1414 // ----------------------------------------------------------------------------
1415 // helper class: you can use it to temporarily change the DC font and
1416 // restore it automatically when the object goes out of scope
1417 // ----------------------------------------------------------------------------
1419 class WXDLLIMPEXP_CORE wxDCFontChanger
1422 wxDCFontChanger(wxDC
& dc
)
1423 : m_dc(dc
), m_fontOld()
1427 wxDCFontChanger(wxDC
& dc
, const wxFont
& font
)
1428 : m_dc(dc
), m_fontOld(dc
.GetFont())
1433 void Set(const wxFont
& font
)
1435 if ( !m_fontOld
.Ok() )
1436 m_fontOld
= m_dc
.GetFont();
1442 if ( m_fontOld
.Ok() )
1443 m_dc
.SetFont(m_fontOld
);
1451 wxDECLARE_NO_COPY_CLASS(wxDCFontChanger
);
1455 #endif // _WX_DC_H_BASE_