]>
Commit | Line | Data |
---|---|---|
0e320a79 | 1 | ///////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: wx/os2/dc.h |
0e320a79 | 3 | // Purpose: wxDC class |
f0a56ab0 | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
f0a56ab0 | 6 | // Created: 08/26/99 |
f0a56ab0 | 7 | // Copyright: (c) David Webster |
65571936 | 8 | // Licence: wxWindows licence |
0e320a79 DW |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | #ifndef _WX_DC_H_ | |
12 | #define _WX_DC_H_ | |
13 | ||
fb46a9a6 | 14 | #include "wx/defs.h" |
2c24e7ad | 15 | #include "wx/dc.h" |
0e320a79 | 16 | |
fb46a9a6 DW |
17 | // --------------------------------------------------------------------------- |
18 | // macros | |
19 | // --------------------------------------------------------------------------- | |
20 | ||
21 | // Logical to device | |
22 | // Absolute | |
23 | #define XLOG2DEV(x) (x) | |
24 | #define YLOG2DEV(y) (y) | |
25 | ||
26 | // Relative | |
27 | #define XLOG2DEVREL(x) (x) | |
28 | #define YLOG2DEVREL(y) (y) | |
29 | ||
30 | // Device to logical | |
31 | // Absolute | |
32 | #define XDEV2LOG(x) (x) | |
33 | ||
34 | #define YDEV2LOG(y) (y) | |
35 | ||
36 | // Relative | |
37 | #define XDEV2LOGREL(x) (x) | |
38 | #define YDEV2LOGREL(y) (y) | |
39 | ||
40 | /* | |
41 | * Have the same macros as for XView but not for every operation: | |
42 | * just for calculating window/viewport extent (a better way of scaling). | |
43 | */ | |
44 | ||
45 | // Logical to device | |
46 | // Absolute | |
47 | #define MS_XLOG2DEV(x) LogicalToDevice(x) | |
48 | ||
49 | #define MS_YLOG2DEV(y) LogicalToDevice(y) | |
50 | ||
51 | // Relative | |
52 | #define MS_XLOG2DEVREL(x) LogicalToDeviceXRel(x) | |
53 | #define MS_YLOG2DEVREL(y) LogicalToDeviceYRel(y) | |
54 | ||
55 | // Device to logical | |
56 | // Absolute | |
57 | #define MS_XDEV2LOG(x) DeviceToLogicalX(x) | |
58 | ||
59 | #define MS_YDEV2LOG(y) DeviceToLogicalY(y) | |
0e320a79 | 60 | |
fb46a9a6 DW |
61 | // Relative |
62 | #define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x) | |
63 | #define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y) | |
0e320a79 | 64 | |
fb46a9a6 | 65 | #define YSCALE(y) (yorigin - (y)) |
0e320a79 | 66 | |
fb46a9a6 | 67 | #define wx_round(a) (int)((a)+.5) |
0e320a79 | 68 | |
6835592c DW |
69 | #if wxUSE_DC_CACHEING |
70 | /* | |
71 | * Cached blitting, maintaining a cache | |
72 | * of bitmaps required for transparent blitting | |
73 | * instead of constant creation/deletion | |
74 | */ | |
75 | ||
76 | class wxDCCacheEntry : public wxObject | |
77 | { | |
78 | public: | |
79 | wxDCCacheEntry( WXHBITMAP hBitmap | |
80 | ,int nWidth | |
81 | ,int nHeight | |
82 | ,int nDepth | |
83 | ); | |
84 | wxDCCacheEntry( HPS hPS | |
85 | ,int nDepth | |
86 | ); | |
d3c7fc99 | 87 | virtual ~wxDCCacheEntry(); |
6835592c DW |
88 | |
89 | WXHBITMAP m_hBitmap; | |
90 | HPS m_hPS; | |
91 | int m_nWidth; | |
92 | int m_nHeight; | |
93 | int m_nDepth; | |
94 | }; // end of CLASS wxDCCacheEntry | |
95 | #endif | |
96 | ||
2c24e7ad SN |
97 | // this is an ABC: use one of the derived classes to create a DC associated |
98 | // with a window, screen, printer and so on | |
53a2db12 | 99 | class WXDLLIMPEXP_CORE wxPMDCImpl : public wxDCImpl |
54da4255 | 100 | { |
fb46a9a6 | 101 | DECLARE_DYNAMIC_CLASS(wxDC) |
54da4255 | 102 | |
fb46a9a6 | 103 | public: |
2c24e7ad SN |
104 | wxPMDCImpl(wxDC *owner, WXHDC hDC); |
105 | virtual ~wxPMDCImpl(); | |
fb46a9a6 DW |
106 | |
107 | // implement base class pure virtuals | |
108 | // ---------------------------------- | |
109 | ||
a1d6411d | 110 | virtual void Clear(); |
f6bcfd97 BP |
111 | |
112 | virtual bool StartDoc(const wxString& rsMessage); | |
a1d6411d | 113 | virtual void EndDoc(); |
f6bcfd97 | 114 | |
a1d6411d SN |
115 | virtual void StartPage(); |
116 | virtual void EndPage(); | |
f6bcfd97 BP |
117 | |
118 | virtual void SetFont(const wxFont& rFont); | |
119 | virtual void SetPen(const wxPen& rPen); | |
120 | virtual void SetBrush(const wxBrush& rBrush); | |
121 | virtual void SetBackground(const wxBrush& rBrush); | |
122 | virtual void SetBackgroundMode(int nMode); | |
123 | virtual void SetPalette(const wxPalette& rPalette); | |
124 | ||
a1d6411d | 125 | virtual void DestroyClippingRegion(); |
f6bcfd97 | 126 | |
a1d6411d SN |
127 | virtual wxCoord GetCharHeight() const; |
128 | virtual wxCoord GetCharWidth() const; | |
2c24e7ad | 129 | |
a1d6411d SN |
130 | virtual bool CanDrawBitmap() const; |
131 | virtual bool CanGetTextExtent() const; | |
132 | virtual int GetDepth() const; | |
133 | virtual wxSize GetPPI() const; | |
f6bcfd97 | 134 | |
a1d6411d | 135 | virtual void SetMapMode(wxMappingMode nMode); |
f6bcfd97 BP |
136 | virtual void SetUserScale( double dX |
137 | ,double dY | |
138 | ); | |
f6bcfd97 BP |
139 | virtual void SetLogicalScale( double dX |
140 | ,double dY | |
141 | ); | |
142 | virtual void SetLogicalOrigin( wxCoord vX | |
143 | ,wxCoord vY | |
144 | ); | |
145 | virtual void SetDeviceOrigin( wxCoord vX | |
146 | ,wxCoord vY | |
147 | ); | |
148 | virtual void SetAxisOrientation( bool bXLeftRight | |
149 | ,bool bYBottomUp | |
150 | ); | |
89efaf2b | 151 | virtual void SetLogicalFunction(wxRasterOperationMode nFunction); |
1408104d | 152 | |
fb46a9a6 DW |
153 | // implementation from now on |
154 | // -------------------------- | |
54da4255 | 155 | |
f6bcfd97 BP |
156 | virtual void SetRop(WXHDC hCdc); |
157 | virtual void SelectOldObjects(WXHDC hDc); | |
ce44c50e | 158 | |
a1d6411d | 159 | wxWindow* GetWindow() const { return m_pCanvas; } |
f6bcfd97 | 160 | void SetWindow(wxWindow* pWin) { m_pCanvas = pWin; } |
ce44c50e | 161 | |
a1d6411d | 162 | WXHDC GetHDC() const { return m_hDC; } |
f6bcfd97 BP |
163 | void SetHDC( WXHDC hDc |
164 | ,bool bOwnsDC = FALSE | |
165 | ) | |
ce44c50e | 166 | { |
f6bcfd97 | 167 | m_hDC = hDc; |
ce44c50e DW |
168 | m_bOwnsDC = bOwnsDC; |
169 | } | |
170 | ||
a1d6411d | 171 | HPS GetHPS() const { return m_hPS; } |
d8fcb5e8 DW |
172 | void SetHPS(HPS hPS) |
173 | { | |
d8fcb5e8 DW |
174 | m_hPS = hPS; |
175 | } | |
a1d6411d SN |
176 | const wxBitmap& GetSelectedBitmap() const { return m_vSelectedBitmap; } |
177 | wxBitmap& GetSelectedBitmap() { return m_vSelectedBitmap; } | |
f6bcfd97 | 178 | |
210a651b DW |
179 | void UpdateClipBox(); |
180 | ||
6835592c DW |
181 | #if wxUSE_DC_CACHEING |
182 | static wxDCCacheEntry* FindBitmapInCache( HPS hPS | |
183 | ,int nWidth | |
184 | ,int nHeight | |
185 | ); | |
186 | static wxDCCacheEntry* FindDCInCache( wxDCCacheEntry* pNotThis | |
187 | ,HPS hPS | |
188 | ); | |
189 | ||
190 | static void AddToBitmapCache(wxDCCacheEntry* pEntry); | |
191 | static void AddToDCCache(wxDCCacheEntry* pEntry); | |
a1d6411d | 192 | static void ClearCache(); |
6835592c DW |
193 | #endif |
194 | ||
1408104d | 195 | protected: |
2c24e7ad SN |
196 | void Init() |
197 | { | |
2c6dbc21 VZ |
198 | m_pCanvas = NULL; |
199 | m_hOldBitmap = 0; | |
200 | m_hOldPen = 0; | |
201 | m_hOldBrush = 0; | |
202 | m_hOldFont = 0; | |
2c24e7ad SN |
203 | #if wxUSE_PALETTE |
204 | m_hOldPalette = 0; | |
205 | #endif // wxUSE_PALETTE | |
206 | ||
2c6dbc21 VZ |
207 | m_bOwnsDC = false; |
208 | m_hDC = 0; | |
209 | m_hOldPS = NULL; | |
210 | m_hPS = NULL; | |
211 | m_bIsPaintTime = false; // True at Paint Time | |
2c24e7ad | 212 | |
2c6dbc21 VZ |
213 | m_pen.SetColour(*wxBLACK); |
214 | m_brush.SetColour(*wxWHITE); | |
2c24e7ad SN |
215 | } |
216 | ||
217 | // create an uninitialized DC: this should be only used by the derived | |
218 | // classes | |
219 | wxPMDCImpl( wxDC *owner ) : wxDCImpl( owner ) { Init(); } | |
220 | ||
221 | public: | |
222 | virtual void DoGetTextExtent( const wxString& rsString | |
223 | ,wxCoord* pX | |
224 | ,wxCoord* pY | |
225 | ,wxCoord* pDescent = NULL | |
226 | ,wxCoord* pExternalLeading = NULL | |
227 | ,const wxFont* pTheFont = NULL | |
228 | ) const; | |
89efaf2b FM |
229 | virtual bool DoFloodFill( wxCoord vX |
230 | ,wxCoord vY | |
231 | ,const wxColour& rCol | |
232 | ,wxFloodFillStyle nStyle = wxFLOOD_SURFACE | |
f6bcfd97 BP |
233 | ); |
234 | ||
235 | virtual bool DoGetPixel( wxCoord vX | |
236 | ,wxCoord vY | |
237 | ,wxColour* pCol | |
238 | ) const; | |
239 | ||
240 | virtual void DoDrawPoint( wxCoord vX | |
241 | ,wxCoord vY | |
242 | ); | |
243 | virtual void DoDrawLine( wxCoord vX1 | |
244 | ,wxCoord vY1 | |
245 | ,wxCoord vX2 | |
246 | ,wxCoord vY2 | |
247 | ); | |
248 | ||
249 | virtual void DoDrawArc( wxCoord vX1 | |
250 | ,wxCoord vY1 | |
251 | ,wxCoord vX2 | |
252 | ,wxCoord vY2 | |
253 | ,wxCoord vXc | |
254 | ,wxCoord vYc | |
255 | ); | |
256 | virtual void DoDrawCheckMark( wxCoord vX | |
257 | ,wxCoord vY | |
258 | ,wxCoord vWidth | |
259 | ,wxCoord vHeight | |
260 | ); | |
261 | virtual void DoDrawEllipticArc( wxCoord vX | |
262 | ,wxCoord vY | |
263 | ,wxCoord vW | |
264 | ,wxCoord vH | |
265 | ,double dSa | |
266 | ,double dEa | |
267 | ); | |
268 | ||
269 | virtual void DoDrawRectangle( wxCoord vX | |
270 | ,wxCoord vY | |
271 | ,wxCoord vWidth | |
272 | ,wxCoord vHeight | |
273 | ); | |
274 | virtual void DoDrawRoundedRectangle( wxCoord vX | |
275 | ,wxCoord vY | |
276 | ,wxCoord vWidth | |
277 | ,wxCoord vHeight | |
278 | ,double dRadius | |
279 | ); | |
280 | virtual void DoDrawEllipse( wxCoord vX | |
281 | ,wxCoord vY | |
282 | ,wxCoord vWidth | |
283 | ,wxCoord vHeight | |
284 | ); | |
285 | ||
286 | virtual void DoCrossHair( wxCoord vX | |
287 | ,wxCoord vY | |
288 | ); | |
289 | ||
290 | virtual void DoDrawIcon( const wxIcon& rIcon | |
291 | ,wxCoord vX | |
292 | ,wxCoord vY | |
293 | ); | |
294 | virtual void DoDrawBitmap( const wxBitmap& rBmp | |
295 | ,wxCoord vX | |
296 | ,wxCoord vY | |
297 | ,bool bUseMask = FALSE | |
298 | ); | |
299 | ||
300 | virtual void DoDrawText( const wxString& rsText | |
301 | ,wxCoord vX | |
302 | ,wxCoord vY | |
303 | ); | |
304 | virtual void DoDrawRotatedText( const wxString& rsText | |
305 | ,wxCoord vX | |
306 | ,wxCoord vY | |
307 | ,double dAngle | |
308 | ); | |
309 | ||
310 | virtual bool DoBlit( wxCoord vXdest | |
311 | ,wxCoord vYdest | |
312 | ,wxCoord vWidth | |
313 | ,wxCoord vHeight | |
314 | ,wxDC* pSource | |
315 | ,wxCoord vXsrc | |
316 | ,wxCoord vYsrc | |
89efaf2b | 317 | ,wxRasterOperationMode nRop = wxCOPY |
f6bcfd97 | 318 | ,bool bUseMask = FALSE |
6835592c DW |
319 | ,wxCoord vXsrcMask = -1 |
320 | ,wxCoord vYsrcMask = -1 | |
f6bcfd97 BP |
321 | ); |
322 | ||
f6bcfd97 BP |
323 | virtual void DoSetClippingRegion( wxCoord vX |
324 | ,wxCoord vY | |
325 | ,wxCoord vWidth | |
326 | ,wxCoord vHeight | |
327 | ); | |
fdaad94e | 328 | virtual void DoSetDeviceClippingRegion(const wxRegion& rRegion); |
1408104d | 329 | |
f6bcfd97 BP |
330 | virtual void DoGetSize( int* pWidth |
331 | ,int* pHeight | |
332 | ) const; | |
333 | virtual void DoGetSizeMM( int* pWidth | |
334 | ,int* pHeight | |
335 | ) const; | |
336 | ||
337 | virtual void DoDrawLines( int n | |
4787c92d | 338 | ,const wxPoint vaPoints[] |
f6bcfd97 BP |
339 | ,wxCoord vXoffset |
340 | ,wxCoord yYoffset | |
341 | ); | |
342 | virtual void DoDrawPolygon( int n | |
4787c92d | 343 | ,const wxPoint vaPoints[] |
f6bcfd97 BP |
344 | ,wxCoord vXoffset |
345 | ,wxCoord vYoffset | |
89efaf2b | 346 | ,wxPolygonFillMode nFillStyle = wxODDEVEN_RULE |
f6bcfd97 | 347 | ); |
fb46a9a6 | 348 | |
938aa9c4 DW |
349 | #if wxUSE_PALETTE |
350 | void DoSelectPalette(bool bRealize = FALSE); | |
a1d6411d | 351 | void InitializePalette(); |
938aa9c4 | 352 | #endif // wxUSE_PALETTE |
fb46a9a6 | 353 | |
2c24e7ad | 354 | protected: |
f6bcfd97 BP |
355 | // |
356 | // common part of DoDrawText() and DoDrawRotatedText() | |
357 | // | |
358 | void DrawAnyText( const wxString& rsText | |
359 | ,wxCoord vX | |
360 | ,wxCoord vY | |
361 | ); | |
fb46a9a6 | 362 | |
f6bcfd97 BP |
363 | // OS2-specific member variables ?? do we even need this under OS/2? |
364 | int m_nWindowExtX; | |
365 | int m_nWindowExtY; | |
1408104d | 366 | |
f6bcfd97 BP |
367 | // |
368 | // the window associated with this DC (may be NULL) | |
369 | // | |
370 | wxWindow* m_pCanvas; | |
371 | wxBitmap m_vSelectedBitmap; | |
1408104d | 372 | |
d7e1a322 DW |
373 | public: |
374 | // PM specific stuff | |
375 | HPS m_hPS; | |
376 | HPS m_hOldPS; // old hPS, if any | |
377 | bool m_bIsPaintTime;// True at Paint Time | |
378 | ||
379 | RECTL m_vRclPaint; // Bounding rectangle at Paint time etc. | |
f6bcfd97 | 380 | // |
fb46a9a6 | 381 | // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it |
f6bcfd97 BP |
382 | // |
383 | bool m_bOwnsDC:1; | |
fb46a9a6 | 384 | |
f6bcfd97 | 385 | // |
ac7fb818 | 386 | // our HDC |
f6bcfd97 BP |
387 | // |
388 | WXHDC m_hDC; | |
1408104d | 389 | |
f6bcfd97 | 390 | // |
1408104d DW |
391 | // Store all old GDI objects when do a SelectObject, so we can select them |
392 | // back in (this unselecting user's objects) so we can safely delete the | |
393 | // DC. | |
f6bcfd97 BP |
394 | // |
395 | WXHBITMAP m_hOldBitmap; | |
396 | WXHPEN m_hOldPen; | |
397 | WXHBRUSH m_hOldBrush; | |
398 | WXHFONT m_hOldFont; | |
399 | WXHPALETTE m_hOldPalette; | |
6835592c DW |
400 | |
401 | #if wxUSE_DC_CACHEING | |
402 | static wxList m_svBitmapCache; | |
403 | static wxList m_svDCCache; | |
404 | #endif | |
405 | }; // end of CLASS wxDC | |
0e320a79 DW |
406 | #endif |
407 | // _WX_DC_H_ |