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