]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/dc.h
Glitches in wxDelegateRenderer
[wxWidgets.git] / include / wx / os2 / dc.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dc.h
3 // Purpose: wxDC class
4 // Author: David Webster
5 // Modified by:
6 // Created: 08/26/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_DC_H_
13 #define _WX_DC_H_
14
15 #include "wx/defs.h"
16 //#include "wx/dc.h"
17
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)
61
62 // Relative
63 #define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x)
64 #define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y)
65
66 #define YSCALE(y) (yorigin - (y))
67
68 #define wx_round(a) (int)((a)+.5)
69
70 #if wxUSE_DC_CACHEING
71 /*
72 * Cached blitting, maintaining a cache
73 * of bitmaps required for transparent blitting
74 * instead of constant creation/deletion
75 */
76
77 class wxDCCacheEntry : public wxObject
78 {
79 public:
80 wxDCCacheEntry( WXHBITMAP hBitmap
81 ,int nWidth
82 ,int nHeight
83 ,int nDepth
84 );
85 wxDCCacheEntry( HPS hPS
86 ,int nDepth
87 );
88 ~wxDCCacheEntry();
89
90 WXHBITMAP m_hBitmap;
91 HPS m_hPS;
92 int m_nWidth;
93 int m_nHeight;
94 int m_nDepth;
95 }; // end of CLASS wxDCCacheEntry
96 #endif
97
98 class WXDLLEXPORT wxDC : public wxDCBase
99 {
100 DECLARE_DYNAMIC_CLASS(wxDC)
101
102 public:
103 wxDC(void);
104 ~wxDC();
105
106 // implement base class pure virtuals
107 // ----------------------------------
108
109 virtual void Clear(void);
110
111 virtual bool StartDoc(const wxString& rsMessage);
112 virtual void EndDoc(void);
113
114 virtual void StartPage(void);
115 virtual void EndPage(void);
116
117 virtual void SetFont(const wxFont& rFont);
118 virtual void SetPen(const wxPen& rPen);
119 virtual void SetBrush(const wxBrush& rBrush);
120 virtual void SetBackground(const wxBrush& rBrush);
121 virtual void SetBackgroundMode(int nMode);
122 virtual void SetPalette(const wxPalette& rPalette);
123
124 virtual void DestroyClippingRegion(void);
125
126 virtual wxCoord GetCharHeight(void) const;
127 virtual wxCoord GetCharWidth(void) const;
128 virtual void DoGetTextExtent( const wxString& rsString
129 ,wxCoord* pX
130 ,wxCoord* pY
131 ,wxCoord* pDescent = NULL
132 ,wxCoord* pExternalLeading = NULL
133 ,wxFont* pTheFont = NULL
134 ) const;
135 virtual bool CanDrawBitmap(void) const;
136 virtual bool CanGetTextExtent(void) const;
137 virtual int GetDepth(void) const;
138 virtual wxSize GetPPI(void) const;
139
140 virtual void SetMapMode(int nMode);
141 virtual void SetUserScale( double dX
142 ,double dY
143 );
144 virtual void SetSystemScale( double dX
145 ,double dY
146 );
147 virtual void SetLogicalScale( double dX
148 ,double dY
149 );
150 virtual void SetLogicalOrigin( wxCoord vX
151 ,wxCoord vY
152 );
153 virtual void SetDeviceOrigin( wxCoord vX
154 ,wxCoord vY
155 );
156 virtual void SetAxisOrientation( bool bXLeftRight
157 ,bool bYBottomUp
158 );
159 virtual void SetLogicalFunction(int nFunction);
160
161 // implementation from now on
162 // --------------------------
163
164 virtual void SetRop(WXHDC hCdc);
165 virtual void SelectOldObjects(WXHDC hDc);
166
167 wxWindow* GetWindow(void) const { return m_pCanvas; }
168 void SetWindow(wxWindow* pWin) { m_pCanvas = pWin; }
169
170 WXHDC GetHDC(void) const { return m_hDC; }
171 void SetHDC( WXHDC hDc
172 ,bool bOwnsDC = FALSE
173 )
174 {
175 m_hDC = hDc;
176 m_bOwnsDC = bOwnsDC;
177 }
178
179 HPS GetHPS(void) const { return m_hPS; }
180 void SetHPS(HPS hPS)
181 {
182 HDC hDC = ::GpiQueryDevice(hPS);
183 m_hPS = hPS;
184 }
185 const wxBitmap& GetSelectedBitmap(void) const { return m_vSelectedBitmap; }
186 wxBitmap& GetSelectedBitmap(void) { return m_vSelectedBitmap; }
187
188 void UpdateClipBox();
189
190 #if wxUSE_DC_CACHEING
191 static wxDCCacheEntry* FindBitmapInCache( HPS hPS
192 ,int nWidth
193 ,int nHeight
194 );
195 static wxDCCacheEntry* FindDCInCache( wxDCCacheEntry* pNotThis
196 ,HPS hPS
197 );
198
199 static void AddToBitmapCache(wxDCCacheEntry* pEntry);
200 static void AddToDCCache(wxDCCacheEntry* pEntry);
201 static void ClearCache(void);
202 #endif
203
204 protected:
205 virtual bool DoFloodFill( wxCoord vX
206 ,wxCoord vY
207 ,const wxColour& rCol
208 ,int nStyle = wxFLOOD_SURFACE
209 );
210
211 virtual bool DoGetPixel( wxCoord vX
212 ,wxCoord vY
213 ,wxColour* pCol
214 ) const;
215
216 virtual void DoDrawPoint( wxCoord vX
217 ,wxCoord vY
218 );
219 virtual void DoDrawLine( wxCoord vX1
220 ,wxCoord vY1
221 ,wxCoord vX2
222 ,wxCoord vY2
223 );
224
225 virtual void DoDrawArc( wxCoord vX1
226 ,wxCoord vY1
227 ,wxCoord vX2
228 ,wxCoord vY2
229 ,wxCoord vXc
230 ,wxCoord vYc
231 );
232 virtual void DoDrawCheckMark( wxCoord vX
233 ,wxCoord vY
234 ,wxCoord vWidth
235 ,wxCoord vHeight
236 );
237 virtual void DoDrawEllipticArc( wxCoord vX
238 ,wxCoord vY
239 ,wxCoord vW
240 ,wxCoord vH
241 ,double dSa
242 ,double dEa
243 );
244
245 virtual void DoDrawRectangle( wxCoord vX
246 ,wxCoord vY
247 ,wxCoord vWidth
248 ,wxCoord vHeight
249 );
250 virtual void DoDrawRoundedRectangle( wxCoord vX
251 ,wxCoord vY
252 ,wxCoord vWidth
253 ,wxCoord vHeight
254 ,double dRadius
255 );
256 virtual void DoDrawEllipse( wxCoord vX
257 ,wxCoord vY
258 ,wxCoord vWidth
259 ,wxCoord vHeight
260 );
261
262 virtual void DoCrossHair( wxCoord vX
263 ,wxCoord vY
264 );
265
266 virtual void DoDrawIcon( const wxIcon& rIcon
267 ,wxCoord vX
268 ,wxCoord vY
269 );
270 virtual void DoDrawBitmap( const wxBitmap& rBmp
271 ,wxCoord vX
272 ,wxCoord vY
273 ,bool bUseMask = FALSE
274 );
275
276 virtual void DoDrawText( const wxString& rsText
277 ,wxCoord vX
278 ,wxCoord vY
279 );
280 virtual void DoDrawRotatedText( const wxString& rsText
281 ,wxCoord vX
282 ,wxCoord vY
283 ,double dAngle
284 );
285
286 virtual bool DoBlit( wxCoord vXdest
287 ,wxCoord vYdest
288 ,wxCoord vWidth
289 ,wxCoord vHeight
290 ,wxDC* pSource
291 ,wxCoord vXsrc
292 ,wxCoord vYsrc
293 ,int nRop = wxCOPY
294 ,bool bUseMask = FALSE
295 ,wxCoord vXsrcMask = -1
296 ,wxCoord vYsrcMask = -1
297 );
298
299 virtual void DoSetClippingRegionAsRegion(const wxRegion& rRegion);
300 virtual void DoSetClippingRegion( wxCoord vX
301 ,wxCoord vY
302 ,wxCoord vWidth
303 ,wxCoord vHeight
304 );
305 virtual void DoGetClippingRegion( wxCoord* pX
306 ,wxCoord* pY
307 ,wxCoord* pWidth
308 ,wxCoord* pHeight)
309 {
310 GetClippingBox( pX
311 ,pY
312 ,pWidth
313 ,pHeight
314 );
315 }
316
317 virtual void DoGetSize( int* pWidth
318 ,int* pHeight
319 ) const;
320 virtual void DoGetSizeMM( int* pWidth
321 ,int* pHeight
322 ) const;
323
324 virtual void DoDrawLines( int n
325 ,wxPoint vaPoints[]
326 ,wxCoord vXoffset
327 ,wxCoord yYoffset
328 );
329 virtual void DoDrawPolygon( int n
330 ,wxPoint vaPoints[]
331 ,wxCoord vXoffset
332 ,wxCoord vYoffset
333 ,int nFillStyle = wxODDEVEN_RULE
334 );
335
336 #if wxUSE_PALETTE
337 void DoSelectPalette(bool bRealize = FALSE);
338 void InitializePalette(void);
339 #endif // wxUSE_PALETTE
340
341 //
342 // common part of DoDrawText() and DoDrawRotatedText()
343 //
344 void DrawAnyText( const wxString& rsText
345 ,wxCoord vX
346 ,wxCoord vY
347 );
348
349 // OS2-specific member variables ?? do we even need this under OS/2?
350 int m_nWindowExtX;
351 int m_nWindowExtY;
352
353 //
354 // the window associated with this DC (may be NULL)
355 //
356 wxWindow* m_pCanvas;
357 wxBitmap m_vSelectedBitmap;
358
359 public:
360 // PM specific stuff
361 HPS m_hPS;
362 HPS m_hOldPS; // old hPS, if any
363 bool m_bIsPaintTime;// True at Paint Time
364
365 RECTL m_vRclPaint; // Bounding rectangle at Paint time etc.
366 //
367 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
368 //
369 bool m_bOwnsDC:1;
370
371 //
372 // our HDC
373 //
374 WXHDC m_hDC;
375
376 //
377 // Store all old GDI objects when do a SelectObject, so we can select them
378 // back in (this unselecting user's objects) so we can safely delete the
379 // DC.
380 //
381 WXHBITMAP m_hOldBitmap;
382 WXHPEN m_hOldPen;
383 WXHBRUSH m_hOldBrush;
384 WXHFONT m_hOldFont;
385 WXHPALETTE m_hOldPalette;
386
387 #if wxUSE_DC_CACHEING
388 static wxList m_svBitmapCache;
389 static wxList m_svDCCache;
390 #endif
391 }; // end of CLASS wxDC
392 #endif
393 // _WX_DC_H_