]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/os2/dc.h | |
3 | // Purpose: wxDC class | |
4 | // Author: David Webster | |
5 | // Modified by: | |
6 | // Created: 08/26/99 | |
7 | // Copyright: (c) David Webster | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_DC_H_ | |
12 | #define _WX_DC_H_ | |
13 | ||
14 | #include "wx/defs.h" | |
15 | #include "wx/dc.h" | |
16 | ||
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) | |
60 | ||
61 | // Relative | |
62 | #define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x) | |
63 | #define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y) | |
64 | ||
65 | #define YSCALE(y) (yorigin - (y)) | |
66 | ||
67 | #define wx_round(a) (int)((a)+.5) | |
68 | ||
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 | ); | |
87 | virtual ~wxDCCacheEntry(); | |
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 | ||
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 | |
99 | class WXDLLIMPEXP_CORE wxPMDCImpl : public wxDCImpl | |
100 | { | |
101 | DECLARE_DYNAMIC_CLASS(wxDC) | |
102 | ||
103 | public: | |
104 | wxPMDCImpl(wxDC *owner, WXHDC hDC); | |
105 | virtual ~wxPMDCImpl(); | |
106 | ||
107 | // implement base class pure virtuals | |
108 | // ---------------------------------- | |
109 | ||
110 | virtual void Clear(); | |
111 | ||
112 | virtual bool StartDoc(const wxString& rsMessage); | |
113 | virtual void EndDoc(); | |
114 | ||
115 | virtual void StartPage(); | |
116 | virtual void EndPage(); | |
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 | ||
125 | virtual void DestroyClippingRegion(); | |
126 | ||
127 | virtual wxCoord GetCharHeight() const; | |
128 | virtual wxCoord GetCharWidth() const; | |
129 | ||
130 | virtual bool CanDrawBitmap() const; | |
131 | virtual bool CanGetTextExtent() const; | |
132 | virtual int GetDepth() const; | |
133 | virtual wxSize GetPPI() const; | |
134 | ||
135 | virtual void SetMapMode(wxMappingMode nMode); | |
136 | virtual void SetUserScale( double dX | |
137 | ,double dY | |
138 | ); | |
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 | ); | |
151 | virtual void SetLogicalFunction(wxRasterOperationMode nFunction); | |
152 | ||
153 | // implementation from now on | |
154 | // -------------------------- | |
155 | ||
156 | virtual void SetRop(WXHDC hCdc); | |
157 | virtual void SelectOldObjects(WXHDC hDc); | |
158 | ||
159 | wxWindow* GetWindow() const { return m_pCanvas; } | |
160 | void SetWindow(wxWindow* pWin) { m_pCanvas = pWin; } | |
161 | ||
162 | WXHDC GetHDC() const { return m_hDC; } | |
163 | void SetHDC( WXHDC hDc | |
164 | ,bool bOwnsDC = FALSE | |
165 | ) | |
166 | { | |
167 | m_hDC = hDc; | |
168 | m_bOwnsDC = bOwnsDC; | |
169 | } | |
170 | ||
171 | HPS GetHPS() const { return m_hPS; } | |
172 | void SetHPS(HPS hPS) | |
173 | { | |
174 | m_hPS = hPS; | |
175 | } | |
176 | const wxBitmap& GetSelectedBitmap() const { return m_vSelectedBitmap; } | |
177 | wxBitmap& GetSelectedBitmap() { return m_vSelectedBitmap; } | |
178 | ||
179 | void UpdateClipBox(); | |
180 | ||
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); | |
192 | static void ClearCache(); | |
193 | #endif | |
194 | ||
195 | protected: | |
196 | void Init() | |
197 | { | |
198 | m_pCanvas = NULL; | |
199 | m_hOldBitmap = 0; | |
200 | m_hOldPen = 0; | |
201 | m_hOldBrush = 0; | |
202 | m_hOldFont = 0; | |
203 | #if wxUSE_PALETTE | |
204 | m_hOldPalette = 0; | |
205 | #endif // wxUSE_PALETTE | |
206 | ||
207 | m_bOwnsDC = false; | |
208 | m_hDC = 0; | |
209 | m_hOldPS = NULL; | |
210 | m_hPS = NULL; | |
211 | m_bIsPaintTime = false; // True at Paint Time | |
212 | ||
213 | m_pen.SetColour(*wxBLACK); | |
214 | m_brush.SetColour(*wxWHITE); | |
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; | |
229 | virtual bool DoFloodFill( wxCoord vX | |
230 | ,wxCoord vY | |
231 | ,const wxColour& rCol | |
232 | ,wxFloodFillStyle nStyle = wxFLOOD_SURFACE | |
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 | |
317 | ,wxRasterOperationMode nRop = wxCOPY | |
318 | ,bool bUseMask = FALSE | |
319 | ,wxCoord vXsrcMask = -1 | |
320 | ,wxCoord vYsrcMask = -1 | |
321 | ); | |
322 | ||
323 | virtual void DoSetClippingRegion( wxCoord vX | |
324 | ,wxCoord vY | |
325 | ,wxCoord vWidth | |
326 | ,wxCoord vHeight | |
327 | ); | |
328 | virtual void DoSetDeviceClippingRegion(const wxRegion& rRegion); | |
329 | ||
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 | |
338 | ,const wxPoint vaPoints[] | |
339 | ,wxCoord vXoffset | |
340 | ,wxCoord yYoffset | |
341 | ); | |
342 | virtual void DoDrawPolygon( int n | |
343 | ,const wxPoint vaPoints[] | |
344 | ,wxCoord vXoffset | |
345 | ,wxCoord vYoffset | |
346 | ,wxPolygonFillMode nFillStyle = wxODDEVEN_RULE | |
347 | ); | |
348 | ||
349 | #if wxUSE_PALETTE | |
350 | void DoSelectPalette(bool bRealize = FALSE); | |
351 | void InitializePalette(); | |
352 | #endif // wxUSE_PALETTE | |
353 | ||
354 | protected: | |
355 | // | |
356 | // common part of DoDrawText() and DoDrawRotatedText() | |
357 | // | |
358 | void DrawAnyText( const wxString& rsText | |
359 | ,wxCoord vX | |
360 | ,wxCoord vY | |
361 | ); | |
362 | ||
363 | // OS2-specific member variables ?? do we even need this under OS/2? | |
364 | int m_nWindowExtX; | |
365 | int m_nWindowExtY; | |
366 | ||
367 | // | |
368 | // the window associated with this DC (may be NULL) | |
369 | // | |
370 | wxWindow* m_pCanvas; | |
371 | wxBitmap m_vSelectedBitmap; | |
372 | ||
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. | |
380 | // | |
381 | // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it | |
382 | // | |
383 | bool m_bOwnsDC:1; | |
384 | ||
385 | // | |
386 | // our HDC | |
387 | // | |
388 | WXHDC m_hDC; | |
389 | ||
390 | // | |
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. | |
394 | // | |
395 | WXHBITMAP m_hOldBitmap; | |
396 | WXHPEN m_hOldPen; | |
397 | WXHBRUSH m_hOldBrush; | |
398 | WXHFONT m_hOldFont; | |
399 | WXHPALETTE m_hOldPalette; | |
400 | ||
401 | #if wxUSE_DC_CACHEING | |
402 | static wxList m_svBitmapCache; | |
403 | static wxList m_svDCCache; | |
404 | #endif | |
405 | }; // end of CLASS wxDC | |
406 | #endif | |
407 | // _WX_DC_H_ |