]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dc.h | |
3 | // Purpose: wxDC class | |
f0a56ab0 | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
f0a56ab0 | 6 | // Created: 08/26/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
f0a56ab0 DW |
8 | // Copyright: (c) David Webster |
9 | // Licence: wxWindows licence | |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_DC_H_ | |
13 | #define _WX_DC_H_ | |
14 | ||
fb46a9a6 | 15 | #include "wx/defs.h" |
d7e1a322 | 16 | //#include "wx/dc.h" |
0e320a79 | 17 | |
fb46a9a6 DW |
18 | // --------------------------------------------------------------------------- |
19 | // macros | |
20 | // --------------------------------------------------------------------------- | |
21 | ||
22 | // Logical to device | |
23 | // Absolute | |
24 | #define XLOG2DEV(x) (x) | |
25 | #define YLOG2DEV(y) (y) | |
26 | ||
27 | // Relative | |
28 | #define XLOG2DEVREL(x) (x) | |
29 | #define YLOG2DEVREL(y) (y) | |
30 | ||
31 | // Device to logical | |
32 | // Absolute | |
33 | #define XDEV2LOG(x) (x) | |
34 | ||
35 | #define YDEV2LOG(y) (y) | |
36 | ||
37 | // Relative | |
38 | #define XDEV2LOGREL(x) (x) | |
39 | #define YDEV2LOGREL(y) (y) | |
40 | ||
41 | /* | |
42 | * Have the same macros as for XView but not for every operation: | |
43 | * just for calculating window/viewport extent (a better way of scaling). | |
44 | */ | |
45 | ||
46 | // Logical to device | |
47 | // Absolute | |
48 | #define MS_XLOG2DEV(x) LogicalToDevice(x) | |
49 | ||
50 | #define MS_YLOG2DEV(y) LogicalToDevice(y) | |
51 | ||
52 | // Relative | |
53 | #define MS_XLOG2DEVREL(x) LogicalToDeviceXRel(x) | |
54 | #define MS_YLOG2DEVREL(y) LogicalToDeviceYRel(y) | |
55 | ||
56 | // Device to logical | |
57 | // Absolute | |
58 | #define MS_XDEV2LOG(x) DeviceToLogicalX(x) | |
59 | ||
60 | #define MS_YDEV2LOG(y) DeviceToLogicalY(y) | |
0e320a79 | 61 | |
fb46a9a6 DW |
62 | // Relative |
63 | #define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x) | |
64 | #define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y) | |
0e320a79 | 65 | |
fb46a9a6 | 66 | #define YSCALE(y) (yorigin - (y)) |
0e320a79 | 67 | |
fb46a9a6 | 68 | #define wx_round(a) (int)((a)+.5) |
0e320a79 | 69 | |
fb46a9a6 | 70 | class WXDLLEXPORT wxDC : public wxDCBase |
54da4255 | 71 | { |
fb46a9a6 | 72 | DECLARE_DYNAMIC_CLASS(wxDC) |
54da4255 | 73 | |
fb46a9a6 | 74 | public: |
d7e1a322 | 75 | wxDC(void); |
fb46a9a6 DW |
76 | ~wxDC(); |
77 | ||
78 | // implement base class pure virtuals | |
79 | // ---------------------------------- | |
80 | ||
f6bcfd97 BP |
81 | virtual void Clear(void); |
82 | ||
83 | virtual bool StartDoc(const wxString& rsMessage); | |
84 | virtual void EndDoc(void); | |
85 | ||
86 | virtual void StartPage(void); | |
87 | virtual void EndPage(void); | |
88 | ||
89 | virtual void SetFont(const wxFont& rFont); | |
90 | virtual void SetPen(const wxPen& rPen); | |
91 | virtual void SetBrush(const wxBrush& rBrush); | |
92 | virtual void SetBackground(const wxBrush& rBrush); | |
93 | virtual void SetBackgroundMode(int nMode); | |
94 | virtual void SetPalette(const wxPalette& rPalette); | |
95 | ||
96 | virtual void DestroyClippingRegion(void); | |
97 | ||
98 | virtual wxCoord GetCharHeight(void) const; | |
99 | virtual wxCoord GetCharWidth(void) const; | |
100 | virtual void DoGetTextExtent( const wxString& rsString | |
101 | ,wxCoord* pX | |
102 | ,wxCoord* pY | |
103 | ,wxCoord* pDescent = NULL | |
104 | ,wxCoord* pExternalLeading = NULL | |
105 | ,wxFont* pTheFont = NULL | |
106 | ) const; | |
107 | virtual bool CanDrawBitmap(void) const; | |
108 | virtual bool CanGetTextExtent(void) const; | |
109 | virtual int GetDepth(void) const; | |
110 | virtual wxSize GetPPI(void) const; | |
111 | ||
112 | virtual void SetMapMode(int nMode); | |
113 | virtual void SetUserScale( double dX | |
114 | ,double dY | |
115 | ); | |
116 | virtual void SetSystemScale( double dX | |
117 | ,double dY | |
118 | ); | |
119 | virtual void SetLogicalScale( double dX | |
120 | ,double dY | |
121 | ); | |
122 | virtual void SetLogicalOrigin( wxCoord vX | |
123 | ,wxCoord vY | |
124 | ); | |
125 | virtual void SetDeviceOrigin( wxCoord vX | |
126 | ,wxCoord vY | |
127 | ); | |
128 | virtual void SetAxisOrientation( bool bXLeftRight | |
129 | ,bool bYBottomUp | |
130 | ); | |
131 | virtual void SetLogicalFunction(int nFunction); | |
1408104d | 132 | |
fb46a9a6 DW |
133 | // implementation from now on |
134 | // -------------------------- | |
54da4255 | 135 | |
f6bcfd97 BP |
136 | virtual void SetRop(WXHDC hCdc); |
137 | virtual void SelectOldObjects(WXHDC hDc); | |
ce44c50e | 138 | |
f6bcfd97 BP |
139 | wxWindow* GetWindow(void) const { return m_pCanvas; } |
140 | void SetWindow(wxWindow* pWin) { m_pCanvas = pWin; } | |
ce44c50e | 141 | |
f6bcfd97 BP |
142 | WXHDC GetHDC(void) const { return m_hDC; } |
143 | void SetHDC( WXHDC hDc | |
144 | ,bool bOwnsDC = FALSE | |
145 | ) | |
ce44c50e | 146 | { |
f6bcfd97 | 147 | m_hDC = hDc; |
ce44c50e DW |
148 | m_bOwnsDC = bOwnsDC; |
149 | } | |
150 | ||
f6bcfd97 BP |
151 | const wxBitmap& GetSelectedBitmap(void) const { return m_vSelectedBitmap; } |
152 | wxBitmap& GetSelectedBitmap(void) { return m_vSelectedBitmap; } | |
153 | ||
1408104d | 154 | protected: |
f6bcfd97 BP |
155 | virtual void DoFloodFill( wxCoord vX |
156 | ,wxCoord vY | |
157 | ,const wxColour& rCol | |
158 | ,int nStyle = wxFLOOD_SURFACE | |
159 | ); | |
160 | ||
161 | virtual bool DoGetPixel( wxCoord vX | |
162 | ,wxCoord vY | |
163 | ,wxColour* pCol | |
164 | ) const; | |
165 | ||
166 | virtual void DoDrawPoint( wxCoord vX | |
167 | ,wxCoord vY | |
168 | ); | |
169 | virtual void DoDrawLine( wxCoord vX1 | |
170 | ,wxCoord vY1 | |
171 | ,wxCoord vX2 | |
172 | ,wxCoord vY2 | |
173 | ); | |
174 | ||
175 | virtual void DoDrawArc( wxCoord vX1 | |
176 | ,wxCoord vY1 | |
177 | ,wxCoord vX2 | |
178 | ,wxCoord vY2 | |
179 | ,wxCoord vXc | |
180 | ,wxCoord vYc | |
181 | ); | |
182 | virtual void DoDrawCheckMark( wxCoord vX | |
183 | ,wxCoord vY | |
184 | ,wxCoord vWidth | |
185 | ,wxCoord vHeight | |
186 | ); | |
187 | virtual void DoDrawEllipticArc( wxCoord vX | |
188 | ,wxCoord vY | |
189 | ,wxCoord vW | |
190 | ,wxCoord vH | |
191 | ,double dSa | |
192 | ,double dEa | |
193 | ); | |
194 | ||
195 | virtual void DoDrawRectangle( wxCoord vX | |
196 | ,wxCoord vY | |
197 | ,wxCoord vWidth | |
198 | ,wxCoord vHeight | |
199 | ); | |
200 | virtual void DoDrawRoundedRectangle( wxCoord vX | |
201 | ,wxCoord vY | |
202 | ,wxCoord vWidth | |
203 | ,wxCoord vHeight | |
204 | ,double dRadius | |
205 | ); | |
206 | virtual void DoDrawEllipse( wxCoord vX | |
207 | ,wxCoord vY | |
208 | ,wxCoord vWidth | |
209 | ,wxCoord vHeight | |
210 | ); | |
211 | ||
212 | virtual void DoCrossHair( wxCoord vX | |
213 | ,wxCoord vY | |
214 | ); | |
215 | ||
216 | virtual void DoDrawIcon( const wxIcon& rIcon | |
217 | ,wxCoord vX | |
218 | ,wxCoord vY | |
219 | ); | |
220 | virtual void DoDrawBitmap( const wxBitmap& rBmp | |
221 | ,wxCoord vX | |
222 | ,wxCoord vY | |
223 | ,bool bUseMask = FALSE | |
224 | ); | |
225 | ||
226 | virtual void DoDrawText( const wxString& rsText | |
227 | ,wxCoord vX | |
228 | ,wxCoord vY | |
229 | ); | |
230 | virtual void DoDrawRotatedText( const wxString& rsText | |
231 | ,wxCoord vX | |
232 | ,wxCoord vY | |
233 | ,double dAngle | |
234 | ); | |
235 | ||
236 | virtual bool DoBlit( wxCoord vXdest | |
237 | ,wxCoord vYdest | |
238 | ,wxCoord vWidth | |
239 | ,wxCoord vHeight | |
240 | ,wxDC* pSource | |
241 | ,wxCoord vXsrc | |
242 | ,wxCoord vYsrc | |
243 | ,int nRop = wxCOPY | |
244 | ,bool bUseMask = FALSE | |
245 | ); | |
246 | ||
247 | virtual void DoSetClippingRegionAsRegion(const wxRegion& rRegion); | |
248 | virtual void DoSetClippingRegion( wxCoord vX | |
249 | ,wxCoord vY | |
250 | ,wxCoord vWidth | |
251 | ,wxCoord vHeight | |
252 | ); | |
253 | virtual void DoGetClippingRegion( wxCoord* pX | |
254 | ,wxCoord* pY | |
255 | ,wxCoord* pWidth | |
256 | ,wxCoord* pHeight) | |
fb46a9a6 | 257 | { |
f6bcfd97 BP |
258 | GetClippingBox( pX |
259 | ,pY | |
260 | ,pWidth | |
261 | ,pHeight | |
262 | ); | |
fb46a9a6 | 263 | } |
1408104d | 264 | |
f6bcfd97 BP |
265 | virtual void DoGetSize( int* pWidth |
266 | ,int* pHeight | |
267 | ) const; | |
268 | virtual void DoGetSizeMM( int* pWidth | |
269 | ,int* pHeight | |
270 | ) const; | |
271 | ||
272 | virtual void DoDrawLines( int n | |
273 | ,wxPoint vaPoints[] | |
274 | ,wxCoord vXoffset | |
275 | ,wxCoord yYoffset | |
276 | ); | |
277 | virtual void DoDrawPolygon( int n | |
278 | ,wxPoint vaPoints[] | |
279 | ,wxCoord vXoffset | |
280 | ,wxCoord vYoffset | |
281 | ,int nFillStyle = wxODDEVEN_RULE | |
282 | ); | |
fb46a9a6 DW |
283 | |
284 | #if wxUSE_SPLINES | |
f6bcfd97 | 285 | virtual void DoDrawSpline(wxList* pPoints); |
fb46a9a6 DW |
286 | #endif // wxUSE_SPLINES |
287 | ||
f6bcfd97 BP |
288 | // |
289 | // common part of DoDrawText() and DoDrawRotatedText() | |
290 | // | |
291 | void DrawAnyText( const wxString& rsText | |
292 | ,wxCoord vX | |
293 | ,wxCoord vY | |
294 | ); | |
fb46a9a6 | 295 | |
f6bcfd97 BP |
296 | // OS2-specific member variables ?? do we even need this under OS/2? |
297 | int m_nWindowExtX; | |
298 | int m_nWindowExtY; | |
1408104d | 299 | |
f6bcfd97 BP |
300 | // |
301 | // the window associated with this DC (may be NULL) | |
302 | // | |
303 | wxWindow* m_pCanvas; | |
304 | wxBitmap m_vSelectedBitmap; | |
1408104d | 305 | |
d7e1a322 DW |
306 | public: |
307 | // PM specific stuff | |
308 | HPS m_hPS; | |
309 | HPS m_hOldPS; // old hPS, if any | |
310 | bool m_bIsPaintTime;// True at Paint Time | |
311 | ||
312 | RECTL m_vRclPaint; // Bounding rectangle at Paint time etc. | |
f6bcfd97 | 313 | // |
fb46a9a6 | 314 | // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it |
f6bcfd97 BP |
315 | // |
316 | bool m_bOwnsDC:1; | |
fb46a9a6 | 317 | |
f6bcfd97 | 318 | // |
1408104d DW |
319 | // our HDC and its usage count: we only free it when the usage count drops |
320 | // to 0 | |
f6bcfd97 BP |
321 | // |
322 | WXHDC m_hDC; | |
323 | int m_nDCCount; | |
1408104d | 324 | |
f6bcfd97 | 325 | // |
1408104d DW |
326 | // Store all old GDI objects when do a SelectObject, so we can select them |
327 | // back in (this unselecting user's objects) so we can safely delete the | |
328 | // DC. | |
f6bcfd97 BP |
329 | // |
330 | WXHBITMAP m_hOldBitmap; | |
331 | WXHPEN m_hOldPen; | |
332 | WXHBRUSH m_hOldBrush; | |
333 | WXHFONT m_hOldFont; | |
334 | WXHPALETTE m_hOldPalette; | |
0e320a79 | 335 | }; |
0e320a79 DW |
336 | #endif |
337 | // _WX_DC_H_ |