1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DC_H_BASE_
13 #define _WX_DC_H_BASE_
15 // ----------------------------------------------------------------------------
16 // headers which we must include here
17 // ----------------------------------------------------------------------------
19 #include "wx/object.h" // the base class
21 #include "wx/intl.h" // for wxLayoutDirection
22 #include "wx/cursor.h" // we have member variables of these classes
23 #include "wx/font.h" // so we can't do without them
24 #include "wx/colour.h"
25 #include "wx/bitmap.h" // for wxNullBitmap
28 #include "wx/palette.h"
29 #include "wx/dynarray.h"
32 #include "wx/cmndata.h"
34 #define wxUSE_NEW_DC 1
36 class WXDLLIMPEXP_FWD_CORE wxDC
;
37 class WXDLLIMPEXP_FWD_CORE wxClientDC
;
38 class WXDLLIMPEXP_FWD_CORE wxPaintDC
;
39 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
40 class WXDLLIMPEXP_FWD_CORE wxScreenDC
;
41 class WXDLLIMPEXP_FWD_CORE wxMemoryDC
;
42 class WXDLLIMPEXP_FWD_CORE wxPrinterDC
;
43 class WXDLLIMPEXP_FWD_CORE wxPrintData
;
46 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
107 // Mapping modes (same values as used by Windows, don't change)
122 //-----------------------------------------------------------------------------
123 // wxDrawObject helper class
124 //-----------------------------------------------------------------------------
126 class WXDLLIMPEXP_CORE wxDrawObject
131 : m_isBBoxValid(false)
132 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
135 virtual ~wxDrawObject() { }
137 virtual void Draw(wxDC
&) const { }
139 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
143 if ( x
< m_minX
) m_minX
= x
;
144 if ( y
< m_minY
) m_minY
= y
;
145 if ( x
> m_maxX
) m_maxX
= x
;
146 if ( y
> m_maxY
) m_maxY
= y
;
150 m_isBBoxValid
= true;
159 void ResetBoundingBox()
161 m_isBBoxValid
= false;
163 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
166 // Get the final bounding box of the PostScript or Metafile picture.
168 wxCoord
MinX() const { return m_minX
; }
169 wxCoord
MaxX() const { return m_maxX
; }
170 wxCoord
MinY() const { return m_minY
; }
171 wxCoord
MaxY() const { return m_maxY
; }
173 //to define the type of object for derived objects
174 virtual int GetType()=0;
177 //for boundingbox calculation
178 bool m_isBBoxValid
:1;
179 //for boundingbox calculation
180 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
184 //-----------------------------------------------------------------------------
186 //-----------------------------------------------------------------------------
188 class WXDLLIMPEXP_FWD_CORE wxDCImpl
;
190 class WXDLLIMPEXP_CORE wxDCFactory
194 virtual ~wxDCFactory() {}
196 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
) = 0;
197 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
) = 0;
198 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
) = 0;
199 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
) = 0;
200 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
) = 0;
201 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
) = 0;
202 virtual wxDCImpl
* CreateScreenDC( wxScreenDC
*owner
) = 0;
203 #if wxUSE_PRINTING_ARCHITECTURE
204 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
) = 0;
207 static void Set(wxDCFactory
*factory
);
208 static wxDCFactory
*Get();
211 static wxDCFactory
*m_factory
;
214 //-----------------------------------------------------------------------------
216 //-----------------------------------------------------------------------------
218 class WXDLLIMPEXP_CORE wxNativeDCFactory
: public wxDCFactory
221 wxNativeDCFactory() {}
223 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
);
224 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
);
225 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
);
226 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
);
227 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
);
228 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
);
229 virtual wxDCImpl
* CreateScreenDC( wxScreenDC
*owner
);
230 #if wxUSE_PRINTING_ARCHITECTURE
231 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
);
235 //-----------------------------------------------------------------------------
237 //-----------------------------------------------------------------------------
239 class WXDLLIMPEXP_CORE wxDCImpl
: public wxObject
242 wxDCImpl( wxDC
*owner
);
245 wxDC
*GetOwner() const { return m_owner
; }
247 wxWindow
* GetWindow() const { return m_window
; }
249 virtual bool IsOk() const { return m_ok
; }
251 // query capabilities
253 virtual bool CanDrawBitmap() const = 0;
254 virtual bool CanGetTextExtent() const = 0;
257 virtual void* GetCairoContext() const
262 // query dimension, colour deps, resolution
264 virtual void DoGetSize(int *width
, int *height
) const = 0;
265 void GetSize(int *width
, int *height
) const
267 DoGetSize(width
, height
);
271 wxSize
GetSize() const
278 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
280 virtual int GetDepth() const = 0;
281 virtual wxSize
GetPPI() const = 0;
283 // Right-To-Left (RTL) modes
285 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
286 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
290 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
291 virtual void EndDoc() { }
293 virtual void StartPage() { }
294 virtual void EndPage() { }
296 // flushing the content of this dc immediately eg onto screen
297 virtual void Flush() { }
301 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
305 if ( x
< m_minX
) m_minX
= x
;
306 if ( y
< m_minY
) m_minY
= y
;
307 if ( x
> m_maxX
) m_maxX
= x
;
308 if ( y
> m_maxY
) m_maxY
= y
;
312 m_isBBoxValid
= true;
320 void ResetBoundingBox()
322 m_isBBoxValid
= false;
324 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
327 wxCoord
MinX() const { return m_minX
; }
328 wxCoord
MaxX() const { return m_maxX
; }
329 wxCoord
MinY() const { return m_minY
; }
330 wxCoord
MaxY() const { return m_maxY
; }
332 // setters and getters
334 virtual void SetFont(const wxFont
& font
) = 0;
335 virtual const wxFont
& GetFont() const { return m_font
; }
337 virtual void SetPen(const wxPen
& pen
) = 0;
338 virtual const wxPen
& GetPen() const { return m_pen
; }
340 virtual void SetBrush(const wxBrush
& brush
) = 0;
341 virtual const wxBrush
& GetBrush() const { return m_brush
; }
343 virtual void SetBackground(const wxBrush
& brush
) = 0;
344 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
346 virtual void SetBackgroundMode(int mode
) = 0;
347 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
349 virtual void SetTextForeground(const wxColour
& colour
)
350 { m_textForegroundColour
= colour
; }
351 virtual const wxColour
& GetTextForeground() const
352 { return m_textForegroundColour
; }
354 virtual void SetTextBackground(const wxColour
& colour
)
355 { m_textBackgroundColour
= colour
; }
356 virtual const wxColour
& GetTextBackground() const
357 { return m_textBackgroundColour
; }
360 virtual void SetPalette(const wxPalette
& palette
) = 0;
361 #endif // wxUSE_PALETTE
363 // inherit the DC attributes (font and colours) from the given window
365 // this is called automatically when a window, client or paint DC is
367 virtual void InheritAttributes(wxWindow
*win
);
372 virtual void SetLogicalFunction(wxRasterOperationMode function
) = 0;
373 virtual wxRasterOperationMode
GetLogicalFunction() const
374 { return m_logicalFunction
; }
378 virtual wxCoord
GetCharHeight() const = 0;
379 virtual wxCoord
GetCharWidth() const = 0;
380 virtual void DoGetTextExtent(const wxString
& string
,
381 wxCoord
*x
, wxCoord
*y
,
382 wxCoord
*descent
= NULL
,
383 wxCoord
*externalLeading
= NULL
,
384 const wxFont
*theFont
= NULL
) const = 0;
385 virtual void GetMultiLineTextExtent(const wxString
& string
,
388 wxCoord
*heightLine
= NULL
,
389 const wxFont
*font
= NULL
) const;
390 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
394 virtual void Clear() = 0;
398 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
399 wxCoord width
, wxCoord height
) = 0;
401 // NB: this function works with device coordinates, not the logical ones!
402 virtual void DoSetDeviceClippingRegion(const wxRegion
& region
) = 0;
404 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
405 wxCoord
*w
, wxCoord
*h
) const
412 *w
= m_clipX2
- m_clipX1
;
414 *h
= m_clipY2
- m_clipY1
;
417 virtual void DestroyClippingRegion() { ResetClipping(); }
420 // coordinates conversions and transforms
422 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
423 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
424 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
425 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
426 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
427 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
428 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
429 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
431 virtual void SetMapMode(wxMappingMode mode
);
432 virtual wxMappingMode
GetMapMode() const { return m_mappingMode
; }
434 virtual void SetUserScale(double x
, double y
);
435 virtual void GetUserScale(double *x
, double *y
) const
437 if ( x
) *x
= m_userScaleX
;
438 if ( y
) *y
= m_userScaleY
;
441 virtual void SetLogicalScale(double x
, double y
);
442 virtual void GetLogicalScale(double *x
, double *y
)
444 if ( x
) *x
= m_logicalScaleX
;
445 if ( y
) *y
= m_logicalScaleY
;
448 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
449 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
451 if ( x
) *x
= m_logicalOriginX
;
452 if ( y
) *y
= m_logicalOriginY
;
455 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
456 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
458 if ( x
) *x
= m_deviceOriginX
;
459 if ( y
) *y
= m_deviceOriginY
;
462 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
464 virtual void ComputeScaleAndOrigin();
466 // this needs to overidden if the axis is inverted
467 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
469 // ---------------------------------------------------------
470 // the actual drawing API
472 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
473 wxFloodFillStyle style
= wxFLOOD_SURFACE
) = 0;
475 virtual void DoGradientFillLinear(const wxRect
& rect
,
476 const wxColour
& initialColour
,
477 const wxColour
& destColour
,
478 wxDirection nDirection
= wxEAST
);
480 virtual void DoGradientFillConcentric(const wxRect
& rect
,
481 const wxColour
& initialColour
,
482 const wxColour
& destColour
,
483 const wxPoint
& circleCenter
);
485 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
487 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
488 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
490 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
491 wxCoord x2
, wxCoord y2
,
492 wxCoord xc
, wxCoord yc
) = 0;
493 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
494 wxCoord width
, wxCoord height
);
495 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
496 double sa
, double ea
) = 0;
498 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
499 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
500 wxCoord width
, wxCoord height
,
502 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
503 wxCoord width
, wxCoord height
) = 0;
505 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
507 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
508 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
509 bool useMask
= false) = 0;
511 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
512 virtual void DoDrawRotatedText(const wxString
& text
,
513 wxCoord x
, wxCoord y
, double angle
) = 0;
515 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
516 wxCoord width
, wxCoord height
,
518 wxCoord xsrc
, wxCoord ysrc
,
519 wxRasterOperationMode rop
= wxCOPY
,
520 bool useMask
= false,
521 wxCoord xsrcMask
= wxDefaultCoord
,
522 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
524 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
525 wxCoord dstWidth
, wxCoord dstHeight
,
527 wxCoord xsrc
, wxCoord ysrc
,
528 wxCoord srcWidth
, wxCoord srcHeight
,
529 wxRasterOperationMode rop
= wxCOPY
,
530 bool useMask
= false,
531 wxCoord xsrcMask
= wxDefaultCoord
,
532 wxCoord ysrcMask
= wxDefaultCoord
);
534 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
535 { return wxNullBitmap
; }
538 virtual void DoDrawLines(int n
, wxPoint points
[],
539 wxCoord xoffset
, wxCoord yoffset
) = 0;
540 virtual void DrawLines(const wxPointList
*list
,
541 wxCoord xoffset
, wxCoord yoffset
);
543 virtual void DoDrawPolygon(int n
, wxPoint points
[],
544 wxCoord xoffset
, wxCoord yoffset
,
545 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
) = 0;
546 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
547 wxCoord xoffset
, wxCoord yoffset
,
548 wxPolygonFillMode fillStyle
);
549 void DrawPolygon(const wxPointList
*list
,
550 wxCoord xoffset
, wxCoord yoffset
,
551 wxPolygonFillMode fillStyle
);
555 void DrawSpline(wxCoord x1
, wxCoord y1
,
556 wxCoord x2
, wxCoord y2
,
557 wxCoord x3
, wxCoord y3
);
558 void DrawSpline(int n
, wxPoint points
[]);
559 void DrawSpline(const wxPointList
*points
) { DoDrawSpline(points
); }
561 virtual void DoDrawSpline(const wxPointList
*points
);
564 // ---------------------------------------------------------
565 // wxMemoryDC Impl API
567 virtual void DoSelect(const wxBitmap
& WXUNUSED(bmp
))
570 virtual const wxBitmap
& GetSelectedBitmap() const
571 { return wxNullBitmap
; }
572 virtual wxBitmap
& GetSelectedBitmap()
573 { return wxNullBitmap
; }
575 // ---------------------------------------------------------
576 // wxPrinterDC Impl API
578 virtual wxRect
GetPaperRect() const
579 { int w
= 0; int h
= 0; DoGetSize( &w
, &h
); return wxRect(0,0,w
,h
); }
581 virtual int GetResolution() const
588 // unset clipping variables (after clipping region was destroyed)
593 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
597 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
598 /*! \param x Upper left corner of bounding box.
599 * \param y Upper left corner of bounding box.
600 * \param w Width of bounding box.
601 * \param h Height of bounding box.
602 * \param sa Starting angle of arc
603 * (counterclockwise, start at 3 o'clock, 360 is full circle).
604 * \param ea Ending angle of arc.
605 * \param angle Rotation angle, the Arc will be rotated after
606 * calculating begin and end.
608 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
609 wxCoord width
, wxCoord height
,
610 double sa
= 0, double ea
= 0, double angle
= 0 )
611 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
613 void DrawEllipticArcRot( const wxPoint
& pt
,
615 double sa
= 0, double ea
= 0, double angle
= 0 )
616 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
618 void DrawEllipticArcRot( const wxRect
& rect
,
619 double sa
= 0, double ea
= 0, double angle
= 0 )
620 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
622 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
623 wxCoord w
, wxCoord h
,
624 double sa
= 0, double ea
= 0, double angle
= 0 );
626 //! Rotates points around center.
627 /*! This is a quite straight method, it calculates in pixels
628 * and so it produces rounding errors.
629 * \param points The points inside will be rotated.
630 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
631 * \param center Center of rotation.
633 void Rotate( wxPointList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
635 // used by DrawEllipticArcRot
636 // Careful: wxList gets filled with points you have to delete later.
637 void CalculateEllipticPoints( wxPointList
* points
,
638 wxCoord xStart
, wxCoord yStart
,
639 wxCoord w
, wxCoord h
,
640 double sa
, double ea
);
641 #endif // __WXWINCE__
643 // returns adjustment factor for converting wxFont "point size"; in wx
644 // it is point size on screen and needs to be multiplied by this value
645 // for rendering on higher-resolution DCs such as printer ones
646 static float GetFontPointSizeAdjustment(float dpi
);
648 // window on which the DC draws or NULL
655 bool m_isInteractive
:1;
656 bool m_isBBoxValid
:1;
658 // coordinate system variables
660 wxCoord m_logicalOriginX
, m_logicalOriginY
;
661 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
663 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
664 // is not at 0,0. This was the case under
665 // Mac's GrafPorts (coordinate system
666 // used toplevel window's origin) and
667 // e.g. for Postscript, where the native
668 // origin in the bottom left corner.
669 double m_logicalScaleX
, m_logicalScaleY
;
670 double m_userScaleX
, m_userScaleY
;
671 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
673 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
675 // what is a mm on a screen you don't know the size of?
676 double m_mm_to_pix_x
,
679 // bounding and clipping boxes
680 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
681 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
683 wxRasterOperationMode m_logicalFunction
;
684 int m_backgroundMode
;
685 wxMappingMode m_mappingMode
;
689 wxBrush m_backgroundBrush
;
690 wxColour m_textForegroundColour
;
691 wxColour m_textBackgroundColour
;
696 bool m_hasCustomPalette
;
697 #endif // wxUSE_PALETTE
700 DECLARE_ABSTRACT_CLASS(wxDCImpl
)
704 class WXDLLIMPEXP_CORE wxDC
: public wxObject
707 virtual ~wxDC() { delete m_pimpl
; }
711 const wxDCImpl
*GetImpl() const
714 wxWindow
*GetWindow() const
715 { return m_pimpl
->GetWindow(); }
718 { return m_pimpl
&& m_pimpl
->IsOk(); }
720 // query capabilities
722 bool CanDrawBitmap() const
723 { return m_pimpl
->CanDrawBitmap(); }
724 bool CanGetTextExtent() const
725 { return m_pimpl
->CanGetTextExtent(); }
727 // query dimension, colour deps, resolution
729 void GetSize(int *width
, int *height
) const
730 { m_pimpl
->DoGetSize(width
, height
); }
731 wxSize
GetSize() const
732 { return m_pimpl
->GetSize(); }
734 void GetSizeMM(int* width
, int* height
) const
735 { m_pimpl
->DoGetSizeMM(width
, height
); }
736 wxSize
GetSizeMM() const
739 m_pimpl
->DoGetSizeMM(&w
, &h
);
744 { return m_pimpl
->GetDepth(); }
745 wxSize
GetPPI() const
746 { return m_pimpl
->GetPPI(); }
748 virtual int GetResolution() const
749 { return m_pimpl
->GetResolution(); }
751 // Right-To-Left (RTL) modes
753 void SetLayoutDirection(wxLayoutDirection dir
)
754 { m_pimpl
->SetLayoutDirection( dir
); }
755 wxLayoutDirection
GetLayoutDirection() const
756 { return m_pimpl
->GetLayoutDirection(); }
760 bool StartDoc(const wxString
& message
)
761 { return m_pimpl
->StartDoc(message
); }
763 { m_pimpl
->EndDoc(); }
766 { m_pimpl
->StartPage(); }
768 { m_pimpl
->EndPage(); }
772 void CalcBoundingBox(wxCoord x
, wxCoord y
)
773 { m_pimpl
->CalcBoundingBox(x
,y
); }
774 void ResetBoundingBox()
775 { m_pimpl
->ResetBoundingBox(); }
778 { return m_pimpl
->MinX(); }
780 { return m_pimpl
->MaxX(); }
782 { return m_pimpl
->MinY(); }
784 { return m_pimpl
->MaxY(); }
786 // setters and getters
788 void SetFont(const wxFont
& font
)
789 { m_pimpl
->SetFont( font
); }
790 const wxFont
& GetFont() const
791 { return m_pimpl
->GetFont(); }
793 void SetPen(const wxPen
& pen
)
794 { m_pimpl
->SetPen( pen
); }
795 const wxPen
& GetPen() const
796 { return m_pimpl
->GetPen(); }
798 void SetBrush(const wxBrush
& brush
)
799 { m_pimpl
->SetBrush( brush
); }
800 const wxBrush
& GetBrush() const
801 { return m_pimpl
->GetBrush(); }
803 void SetBackground(const wxBrush
& brush
)
804 { m_pimpl
->SetBackground( brush
); }
805 const wxBrush
& GetBackground() const
806 { return m_pimpl
->GetBackground(); }
808 void SetBackgroundMode(int mode
)
809 { m_pimpl
->SetBackgroundMode( mode
); }
810 int GetBackgroundMode() const
811 { return m_pimpl
->GetBackgroundMode(); }
813 void SetTextForeground(const wxColour
& colour
)
814 { m_pimpl
->SetTextForeground(colour
); }
815 const wxColour
& GetTextForeground() const
816 { return m_pimpl
->GetTextForeground(); }
818 void SetTextBackground(const wxColour
& colour
)
819 { m_pimpl
->SetTextBackground(colour
); }
820 const wxColour
& GetTextBackground() const
821 { return m_pimpl
->GetTextBackground(); }
824 void SetPalette(const wxPalette
& palette
)
825 { m_pimpl
->SetPalette(palette
); }
826 #endif // wxUSE_PALETTE
830 void SetLogicalFunction(wxRasterOperationMode function
)
831 { m_pimpl
->SetLogicalFunction(function
); }
832 wxRasterOperationMode
GetLogicalFunction() const
833 { return m_pimpl
->GetLogicalFunction(); }
837 wxCoord
GetCharHeight() const
838 { return m_pimpl
->GetCharHeight(); }
839 wxCoord
GetCharWidth() const
840 { return m_pimpl
->GetCharWidth(); }
842 void GetTextExtent(const wxString
& string
,
843 wxCoord
*x
, wxCoord
*y
,
844 wxCoord
*descent
= NULL
,
845 wxCoord
*externalLeading
= NULL
,
846 const wxFont
*theFont
= NULL
) const
847 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
849 wxSize
GetTextExtent(const wxString
& string
) const
852 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
856 void GetMultiLineTextExtent(const wxString
& string
,
859 wxCoord
*heightLine
= NULL
,
860 const wxFont
*font
= NULL
) const
861 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
863 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
866 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
870 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
871 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
876 { m_pimpl
->Clear(); }
880 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
881 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
882 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
883 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
884 void SetClippingRegion(const wxRect
& rect
)
885 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
887 // unlike the functions above, the coordinates of the region used in this
888 // one are in device coordinates, not the logical ones
889 void SetDeviceClippingRegion(const wxRegion
& region
)
890 { m_pimpl
->DoSetDeviceClippingRegion(region
); }
892 // this function is deprecated because its name is confusing: you may
893 // expect it to work with logical coordinates but, in fact, it does exactly
894 // the same thing as SetDeviceClippingRegion()
896 // please review the code using it and either replace it with calls to
897 // SetDeviceClippingRegion() or correct it if it was [wrongly] passing
898 // logical coordinates to this function
899 wxDEPRECATED_INLINE(void SetClippingRegion(const wxRegion
& region
),
900 SetDeviceClippingRegion(region
); )
902 void DestroyClippingRegion()
903 { m_pimpl
->DestroyClippingRegion(); }
905 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
906 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
907 void GetClippingBox(wxRect
& rect
) const
908 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
910 // coordinates conversions and transforms
912 wxCoord
DeviceToLogicalX(wxCoord x
) const
913 { return m_pimpl
->DeviceToLogicalX(x
); }
914 wxCoord
DeviceToLogicalY(wxCoord y
) const
915 { return m_pimpl
->DeviceToLogicalY(y
); }
916 wxCoord
DeviceToLogicalXRel(wxCoord x
) const
917 { return m_pimpl
->DeviceToLogicalXRel(x
); }
918 wxCoord
DeviceToLogicalYRel(wxCoord y
) const
919 { return m_pimpl
->DeviceToLogicalYRel(y
); }
920 wxCoord
LogicalToDeviceX(wxCoord x
) const
921 { return m_pimpl
->LogicalToDeviceX(x
); }
922 wxCoord
LogicalToDeviceY(wxCoord y
) const
923 { return m_pimpl
->LogicalToDeviceY(y
); }
924 wxCoord
LogicalToDeviceXRel(wxCoord x
) const
925 { return m_pimpl
->LogicalToDeviceXRel(x
); }
926 wxCoord
LogicalToDeviceYRel(wxCoord y
) const
927 { return m_pimpl
->LogicalToDeviceYRel(y
); }
929 void SetMapMode(wxMappingMode mode
)
930 { m_pimpl
->SetMapMode(mode
); }
931 wxMappingMode
GetMapMode() const
932 { return m_pimpl
->GetMapMode(); }
934 void SetUserScale(double x
, double y
)
935 { m_pimpl
->SetUserScale(x
,y
); }
936 void GetUserScale(double *x
, double *y
) const
937 { m_pimpl
->GetUserScale( x
, y
); }
939 void SetLogicalScale(double x
, double y
)
940 { m_pimpl
->SetLogicalScale( x
, y
); }
941 void GetLogicalScale(double *x
, double *y
)
942 { m_pimpl
->GetLogicalScale( x
, y
); }
944 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
945 { m_pimpl
->SetLogicalOrigin(x
,y
); }
946 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
947 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
948 wxPoint
GetLogicalOrigin() const
949 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
951 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
952 { m_pimpl
->SetDeviceOrigin( x
, y
); }
953 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
954 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
955 wxPoint
GetDeviceOrigin() const
956 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
958 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
959 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
962 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
963 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
966 // draw generic object
968 void DrawObject(wxDrawObject
* drawobject
)
970 drawobject
->Draw(*this);
971 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
972 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
975 // -----------------------------------------------
976 // the actual drawing API
978 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
979 wxFloodFillStyle style
= wxFLOOD_SURFACE
)
980 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
981 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
982 wxFloodFillStyle style
= wxFLOOD_SURFACE
)
983 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
985 // fill the area specified by rect with a radial gradient, starting from
986 // initialColour in the centre of the cercle and fading to destColour.
987 void GradientFillConcentric(const wxRect
& rect
,
988 const wxColour
& initialColour
,
989 const wxColour
& destColour
)
990 { m_pimpl
->DoGradientFillConcentric( rect
, initialColour
, destColour
,
991 wxPoint(rect
.GetWidth() / 2,
992 rect
.GetHeight() / 2)); }
994 void GradientFillConcentric(const wxRect
& rect
,
995 const wxColour
& initialColour
,
996 const wxColour
& destColour
,
997 const wxPoint
& circleCenter
)
998 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
1000 // fill the area specified by rect with a linear gradient
1001 void GradientFillLinear(const wxRect
& rect
,
1002 const wxColour
& initialColour
,
1003 const wxColour
& destColour
,
1004 wxDirection nDirection
= wxEAST
)
1005 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
1007 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
1008 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
1009 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
1010 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
1012 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1013 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
1014 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
1015 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
1017 void CrossHair(wxCoord x
, wxCoord y
)
1018 { m_pimpl
->DoCrossHair(x
, y
); }
1019 void CrossHair(const wxPoint
& pt
)
1020 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
1022 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
1023 wxCoord xc
, wxCoord yc
)
1024 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
1025 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
1026 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
1028 void DrawCheckMark(wxCoord x
, wxCoord y
,
1029 wxCoord width
, wxCoord height
)
1030 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
1031 void DrawCheckMark(const wxRect
& rect
)
1032 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1034 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1035 double sa
, double ea
)
1036 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
1037 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
1038 double sa
, double ea
)
1039 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
1041 void DrawPoint(wxCoord x
, wxCoord y
)
1042 { m_pimpl
->DoDrawPoint(x
, y
); }
1043 void DrawPoint(const wxPoint
& pt
)
1044 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
1046 void DrawLines(int n
, wxPoint points
[],
1047 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1048 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
1049 void DrawLines(const wxPointList
*list
,
1050 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1051 { m_pimpl
->DrawLines( list
, xoffset
, yoffset
); }
1052 #if WXWIN_COMPATIBILITY_2_8
1053 wxDEPRECATED( void DrawLines(const wxList
*list
,
1054 wxCoord xoffset
= 0, wxCoord yoffset
= 0) );
1055 #endif // WXWIN_COMPATIBILITY_2_8
1057 void DrawPolygon(int n
, wxPoint points
[],
1058 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1059 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
)
1060 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
1061 void DrawPolygon(const wxPointList
*list
,
1062 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1063 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
)
1064 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
1065 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1066 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1067 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
)
1068 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
1069 #if WXWIN_COMPATIBILITY_2_8
1070 wxDEPRECATED( void DrawPolygon(const wxList
*list
,
1071 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1072 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
) );
1073 #endif // WXWIN_COMPATIBILITY_2_8
1075 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1076 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
1077 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
1078 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1079 void DrawRectangle(const wxRect
& rect
)
1080 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1082 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
1084 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
1085 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
1087 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
1088 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
1089 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1091 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1092 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1093 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1094 { m_pimpl
->DoDrawEllipse(pt
.x
- radius
, pt
.y
- radius
, 2*radius
, 2*radius
); }
1096 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1097 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
1098 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1099 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1100 void DrawEllipse(const wxRect
& rect
)
1101 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1103 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1104 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
1105 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1106 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1108 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1109 bool useMask
= false)
1110 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
1111 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1112 bool useMask
= false)
1113 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1115 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1116 { m_pimpl
->DoDrawText(text
, x
, y
); }
1117 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1118 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
1120 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1121 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
1122 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1123 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1125 // this version puts both optional bitmap and the text into the given
1126 // rectangle and aligns is as specified by alignment parameter; it also
1127 // will emphasize the character with the given index if it is != -1 and
1128 // return the bounding rectangle if required
1129 void DrawLabel(const wxString
& text
,
1130 const wxBitmap
& image
,
1132 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1133 int indexAccel
= -1,
1134 wxRect
*rectBounding
= NULL
);
1136 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1137 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1138 int indexAccel
= -1)
1139 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1141 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1142 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1143 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1144 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1146 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
1147 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1149 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1150 wxDC
*source
, const wxPoint
& srcPt
,
1151 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1152 const wxPoint
& srcPtMask
= wxDefaultPosition
)
1154 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1155 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1158 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1159 wxCoord dstWidth
, wxCoord dstHeight
,
1161 wxCoord srcX
, wxCoord srcY
,
1162 wxCoord srcWidth
, wxCoord srcHeight
,
1163 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1164 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1166 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1167 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1169 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1170 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1171 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
1172 const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1174 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1175 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1178 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1180 return m_pimpl
->DoGetAsBitmap(subrect
);
1184 void DrawSpline(wxCoord x1
, wxCoord y1
,
1185 wxCoord x2
, wxCoord y2
,
1186 wxCoord x3
, wxCoord y3
)
1187 { m_pimpl
->DrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
1188 void DrawSpline(int n
, wxPoint points
[])
1189 { m_pimpl
->DrawSpline(n
,points
); }
1190 void DrawSpline(const wxPointList
*points
)
1191 { m_pimpl
->DrawSpline(points
); }
1192 #endif // wxUSE_SPLINES
1195 #if WXWIN_COMPATIBILITY_2_8
1196 // for compatibility with the old code when wxCoord was long everywhere
1197 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1199 long *descent
= NULL
,
1200 long *externalLeading
= NULL
,
1201 const wxFont
*theFont
= NULL
) const );
1202 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1203 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1204 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1206 #endif // WXWIN_COMPATIBILITY_2_8
1209 WXHDC
GetHDC() const;
1213 // ctor takes ownership of the pointer
1214 wxDC(wxDCImpl
*pimpl
) : m_pimpl(pimpl
) { }
1216 wxDCImpl
* const m_pimpl
;
1219 DECLARE_ABSTRACT_CLASS(wxDC
)
1220 DECLARE_NO_COPY_CLASS(wxDC
)
1223 // ----------------------------------------------------------------------------
1224 // helper class: you can use it to temporarily change the DC text colour and
1225 // restore it automatically when the object goes out of scope
1226 // ----------------------------------------------------------------------------
1228 class WXDLLIMPEXP_CORE wxDCTextColourChanger
1231 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1233 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1238 ~wxDCTextColourChanger()
1240 if ( m_colFgOld
.Ok() )
1241 m_dc
.SetTextForeground(m_colFgOld
);
1244 void Set(const wxColour
& col
)
1246 if ( !m_colFgOld
.Ok() )
1247 m_colFgOld
= m_dc
.GetTextForeground();
1248 m_dc
.SetTextForeground(col
);
1254 wxColour m_colFgOld
;
1256 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
1259 // ----------------------------------------------------------------------------
1260 // helper class: you can use it to temporarily change the DC pen and
1261 // restore it automatically when the object goes out of scope
1262 // ----------------------------------------------------------------------------
1264 class WXDLLIMPEXP_CORE wxDCPenChanger
1267 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1274 if ( m_penOld
.Ok() )
1275 m_dc
.SetPen(m_penOld
);
1283 DECLARE_NO_COPY_CLASS(wxDCPenChanger
)
1286 // ----------------------------------------------------------------------------
1287 // helper class: you can use it to temporarily change the DC brush and
1288 // restore it automatically when the object goes out of scope
1289 // ----------------------------------------------------------------------------
1291 class WXDLLIMPEXP_CORE wxDCBrushChanger
1294 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1296 m_dc
.SetBrush(brush
);
1301 if ( m_brushOld
.Ok() )
1302 m_dc
.SetBrush(m_brushOld
);
1310 DECLARE_NO_COPY_CLASS(wxDCBrushChanger
)
1313 // ----------------------------------------------------------------------------
1314 // another small helper class: sets the clipping region in its ctor and
1315 // destroys it in the dtor
1316 // ----------------------------------------------------------------------------
1318 class WXDLLIMPEXP_CORE wxDCClipper
1321 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1322 { dc
.SetClippingRegion(r
.GetBox()); }
1323 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1324 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1325 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1326 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1328 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1333 DECLARE_NO_COPY_CLASS(wxDCClipper
)
1336 // ----------------------------------------------------------------------------
1337 // helper class: you can use it to temporarily change the DC font and
1338 // restore it automatically when the object goes out of scope
1339 // ----------------------------------------------------------------------------
1341 class WXDLLIMPEXP_CORE wxDCFontChanger
1344 wxDCFontChanger(wxDC
& dc
, const wxFont
& font
) : m_dc(dc
), m_fontOld(dc
.GetFont())
1351 if ( m_fontOld
.Ok() )
1352 m_dc
.SetFont(m_fontOld
);
1360 DECLARE_NO_COPY_CLASS(wxDCFontChanger
)
1364 #endif // _WX_DC_H_BASE_