1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxClientDC, wxPaintDC and wxWindowDC classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DCCLIENT_H_
13 #define _WX_DCCLIENT_H_
16 #pragma interface "dcclient.h"
21 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
25 class WXDLLEXPORT wxWindowDC
;
26 class WXDLLEXPORT wxWindow
;
28 // Under Windows, wxClientDC, wxPaintDC and wxWindowDC are implemented differently.
29 // On many platforms, however, they will be the same.
31 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
35 class WXDLLEXPORT wxWindowDC
: public wxDC
37 DECLARE_DYNAMIC_CLASS(wxWindowDC
)
42 wxWindowDC( wxWindow
*win
);
46 virtual void FloodFill( long x1
, long y1
, const wxColour
& col
, int style
=wxFLOOD_SURFACE
);
47 inline void FloodFill(const wxPoint
& pt
, const wxColour
& col
, int style
=wxFLOOD_SURFACE
)
49 FloodFill(pt
.x
, pt
.y
, col
, style
);
52 virtual bool GetPixel( long x1
, long y1
, wxColour
*col
) const;
53 inline bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
55 return GetPixel(pt
.x
, pt
.y
, col
);
58 virtual void DrawLine( long x1
, long y1
, long x2
, long y2
);
59 inline void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
61 DrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
);
64 virtual void CrossHair( long x
, long y
);
65 inline void CrossHair(const wxPoint
& pt
)
67 CrossHair(pt
.x
, pt
.y
);
70 virtual void DrawArc( long x1
, long y1
, long x2
, long y2
, long xc
, long yc
);
71 inline void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
73 DrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
);
76 virtual void DrawEllipticArc( long x
, long y
, long width
, long height
, double sa
, double ea
);
77 virtual void DrawEllipticArc (const wxPoint
& pt
, const wxSize
& sz
, double sa
, double ea
)
79 DrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
);
82 virtual void DrawPoint( long x
, long y
);
83 inline void DrawPoint( wxPoint
& point
)
84 { DrawPoint(point
.x
, point
.y
); }
86 virtual void DrawLines( int n
, wxPoint points
[], long xoffset
= 0, long yoffset
= 0 );
87 virtual void DrawLines( wxList
*points
, long xoffset
= 0, long yoffset
= 0 );
88 virtual void DrawPolygon( int n
, wxPoint points
[], long xoffset
= 0, long yoffset
= 0,
89 int fillStyle
=wxODDEVEN_RULE
);
90 virtual void DrawPolygon( wxList
*lines
, long xoffset
= 0, long yoffset
= 0,
91 int fillStyle
=wxODDEVEN_RULE
);
93 virtual void DrawRectangle( long x
, long y
, long width
, long height
);
94 inline void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
96 DrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
);
98 inline void DrawRectangle(const wxRect
& rect
)
100 DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
103 virtual void DrawRoundedRectangle( long x
, long y
, long width
, long height
, double radius
= 20.0 );
104 inline void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
, double radius
= 20.0)
106 DrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
);
108 inline void DrawRoundedRectangle(const wxRect
& rect
, double radius
= 20.0)
110 DrawRoundedRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
, radius
);
113 virtual void DrawEllipse( long x
, long y
, long width
, long height
);
114 inline void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
116 DrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
);
118 inline void DrawEllipse(const wxRect
& rect
)
120 DrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
123 virtual bool CanDrawBitmap(void) const;
125 virtual void DrawIcon( const wxIcon
&icon
, long x
, long y
);
126 inline void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
128 DrawIcon(icon
, pt
.x
, pt
.y
);
131 virtual bool Blit( long xdest
, long ydest
, long width
, long height
,
132 wxDC
*source
, long xsrc
, long ysrc
, int logical_func
= wxCOPY
, bool useMask
=FALSE
);
133 inline bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
134 wxDC
*source
, const wxPoint
& srcPt
, int rop
= wxCOPY
, bool useMask
= FALSE
)
136 return Blit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
, source
, srcPt
.x
, srcPt
.y
, rop
, useMask
);
139 virtual void DrawText( const wxString
&text
, long x
, long y
, bool use16
= FALSE
);
140 inline void DrawText(const wxString
& text
, const wxPoint
& pt
, bool use16bit
= FALSE
)
142 DrawText(text
, pt
.x
, pt
.y
, use16bit
);
145 virtual bool CanGetTextExtent(void) const;
146 virtual void GetTextExtent( const wxString
&string
, long *width
, long *height
,
147 long *descent
= NULL
, long *externalLeading
= NULL
,
148 wxFont
*theFont
= NULL
, bool use16
= FALSE
);
149 virtual long GetCharWidth(void);
150 virtual long GetCharHeight(void);
152 virtual void Clear(void);
153 virtual void Clear(const wxRect
& rect
);
155 virtual void SetFont( const wxFont
&font
);
156 virtual void SetPen( const wxPen
&pen
);
157 virtual void SetBrush( const wxBrush
&brush
);
158 virtual void SetBackground( const wxBrush
&brush
);
159 virtual void SetLogicalFunction( int function
);
160 virtual void SetTextForeground( const wxColour
&col
);
161 virtual void SetTextBackground( const wxColour
&col
);
162 virtual void SetBackgroundMode( int mode
);
163 virtual void SetPalette( const wxPalette
& palette
);
165 virtual void SetClippingRegion( long x
, long y
, long width
, long height
);
166 virtual void SetClippingRegion( const wxRegion
& region
);
167 virtual void DestroyClippingRegion(void);
169 virtual void DrawSpline( wxList
*points
);
170 virtual void DrawSpline( long x1
, long y1
, long x2
, long y2
, long x3
, long y3
)
171 { wxDC::DrawSpline(x1
, y1
, x2
, y2
, x3
, y3
); }
172 virtual void DrawSpline( int n
, wxPoint points
[] )
173 { wxDC::DrawSpline(n
, points
); }
176 void SetDCClipping (); // Helper function for setting clipping
178 inline WXGC
GetGC() const { return m_gc
; }
179 inline WXDisplay
* GetDisplay() const { return m_display
; }
180 inline bool GetAutoSetting() const { return m_autoSetting
; }
181 inline void SetAutoSetting(bool flag
) { m_autoSetting
= flag
; }
186 WXDisplay
* m_display
;
188 WXRegion m_currentRegion
; // Current clipping region (incl. paint clip region)
189 WXRegion m_userRegion
; // User-defined clipping region
190 WXPixmap m_pixmap
; // Pixmap for drawing on
192 // Not sure if we'll need all of these
193 int m_backgroundPixel
;
194 wxColour m_currentColour
;
195 // int m_currentBkMode;
196 int m_currentPenWidth
;
197 int m_currentPenJoin
;
198 int m_currentPenCap
;
199 int m_currentPenDashCount
;
200 char* m_currentPenDash
;
201 wxBitmap m_currentStipple
;
204 int m_autoSetting
; // See comment in dcclient.cpp
208 class WXDLLEXPORT wxPaintDC
: public wxWindowDC
210 DECLARE_DYNAMIC_CLASS(wxPaintDC
)
213 wxPaintDC(wxWindow
* win
);
217 class WXDLLEXPORT wxClientDC
: public wxWindowDC
219 DECLARE_DYNAMIC_CLASS(wxClientDC
)
222 wxClientDC(wxWindow
* win
): wxWindowDC(win
) {}