]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/dc.h
removed tabs; minor cosmetic cleanup
[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 m_hPS = hPS;
183 }
184 const wxBitmap& GetSelectedBitmap(void) const { return m_vSelectedBitmap; }
185 wxBitmap& GetSelectedBitmap(void) { return m_vSelectedBitmap; }
186
187 void UpdateClipBox();
188
189 #if wxUSE_DC_CACHEING
190 static wxDCCacheEntry* FindBitmapInCache( HPS hPS
191 ,int nWidth
192 ,int nHeight
193 );
194 static wxDCCacheEntry* FindDCInCache( wxDCCacheEntry* pNotThis
195 ,HPS hPS
196 );
197
198 static void AddToBitmapCache(wxDCCacheEntry* pEntry);
199 static void AddToDCCache(wxDCCacheEntry* pEntry);
200 static void ClearCache(void);
201 #endif
202
203 protected:
204 virtual bool DoFloodFill( wxCoord vX
205 ,wxCoord vY
206 ,const wxColour& rCol
207 ,int nStyle = wxFLOOD_SURFACE
208 );
209
210 virtual bool DoGetPixel( wxCoord vX
211 ,wxCoord vY
212 ,wxColour* pCol
213 ) const;
214
215 virtual void DoDrawPoint( wxCoord vX
216 ,wxCoord vY
217 );
218 virtual void DoDrawLine( wxCoord vX1
219 ,wxCoord vY1
220 ,wxCoord vX2
221 ,wxCoord vY2
222 );
223
224 virtual void DoDrawArc( wxCoord vX1
225 ,wxCoord vY1
226 ,wxCoord vX2
227 ,wxCoord vY2
228 ,wxCoord vXc
229 ,wxCoord vYc
230 );
231 virtual void DoDrawCheckMark( wxCoord vX
232 ,wxCoord vY
233 ,wxCoord vWidth
234 ,wxCoord vHeight
235 );
236 virtual void DoDrawEllipticArc( wxCoord vX
237 ,wxCoord vY
238 ,wxCoord vW
239 ,wxCoord vH
240 ,double dSa
241 ,double dEa
242 );
243
244 virtual void DoDrawRectangle( wxCoord vX
245 ,wxCoord vY
246 ,wxCoord vWidth
247 ,wxCoord vHeight
248 );
249 virtual void DoDrawRoundedRectangle( wxCoord vX
250 ,wxCoord vY
251 ,wxCoord vWidth
252 ,wxCoord vHeight
253 ,double dRadius
254 );
255 virtual void DoDrawEllipse( wxCoord vX
256 ,wxCoord vY
257 ,wxCoord vWidth
258 ,wxCoord vHeight
259 );
260
261 virtual void DoCrossHair( wxCoord vX
262 ,wxCoord vY
263 );
264
265 virtual void DoDrawIcon( const wxIcon& rIcon
266 ,wxCoord vX
267 ,wxCoord vY
268 );
269 virtual void DoDrawBitmap( const wxBitmap& rBmp
270 ,wxCoord vX
271 ,wxCoord vY
272 ,bool bUseMask = FALSE
273 );
274
275 virtual void DoDrawText( const wxString& rsText
276 ,wxCoord vX
277 ,wxCoord vY
278 );
279 virtual void DoDrawRotatedText( const wxString& rsText
280 ,wxCoord vX
281 ,wxCoord vY
282 ,double dAngle
283 );
284
285 virtual bool DoBlit( wxCoord vXdest
286 ,wxCoord vYdest
287 ,wxCoord vWidth
288 ,wxCoord vHeight
289 ,wxDC* pSource
290 ,wxCoord vXsrc
291 ,wxCoord vYsrc
292 ,int nRop = wxCOPY
293 ,bool bUseMask = FALSE
294 ,wxCoord vXsrcMask = -1
295 ,wxCoord vYsrcMask = -1
296 );
297
298 virtual void DoSetClippingRegionAsRegion(const wxRegion& rRegion);
299 virtual void DoSetClippingRegion( wxCoord vX
300 ,wxCoord vY
301 ,wxCoord vWidth
302 ,wxCoord vHeight
303 );
304 virtual void DoGetClippingRegion( wxCoord* pX
305 ,wxCoord* pY
306 ,wxCoord* pWidth
307 ,wxCoord* pHeight)
308 {
309 GetClippingBox( pX
310 ,pY
311 ,pWidth
312 ,pHeight
313 );
314 }
315
316 virtual void DoGetSize( int* pWidth
317 ,int* pHeight
318 ) const;
319 virtual void DoGetSizeMM( int* pWidth
320 ,int* pHeight
321 ) const;
322
323 virtual void DoDrawLines( int n
324 ,wxPoint vaPoints[]
325 ,wxCoord vXoffset
326 ,wxCoord yYoffset
327 );
328 virtual void DoDrawPolygon( int n
329 ,wxPoint vaPoints[]
330 ,wxCoord vXoffset
331 ,wxCoord vYoffset
332 ,int nFillStyle = wxODDEVEN_RULE
333 );
334
335 #if wxUSE_PALETTE
336 void DoSelectPalette(bool bRealize = FALSE);
337 void InitializePalette(void);
338 #endif // wxUSE_PALETTE
339
340 //
341 // common part of DoDrawText() and DoDrawRotatedText()
342 //
343 void DrawAnyText( const wxString& rsText
344 ,wxCoord vX
345 ,wxCoord vY
346 );
347
348 // OS2-specific member variables ?? do we even need this under OS/2?
349 int m_nWindowExtX;
350 int m_nWindowExtY;
351
352 //
353 // the window associated with this DC (may be NULL)
354 //
355 wxWindow* m_pCanvas;
356 wxBitmap m_vSelectedBitmap;
357
358 public:
359 // PM specific stuff
360 HPS m_hPS;
361 HPS m_hOldPS; // old hPS, if any
362 bool m_bIsPaintTime;// True at Paint Time
363
364 RECTL m_vRclPaint; // Bounding rectangle at Paint time etc.
365 //
366 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
367 //
368 bool m_bOwnsDC:1;
369
370 //
371 // our HDC
372 //
373 WXHDC m_hDC;
374
375 //
376 // Store all old GDI objects when do a SelectObject, so we can select them
377 // back in (this unselecting user's objects) so we can safely delete the
378 // DC.
379 //
380 WXHBITMAP m_hOldBitmap;
381 WXHPEN m_hOldPen;
382 WXHBRUSH m_hOldBrush;
383 WXHFONT m_hOldFont;
384 WXHPALETTE m_hOldPalette;
385
386 #if wxUSE_DC_CACHEING
387 static wxList m_svBitmapCache;
388 static wxList m_svDCCache;
389 #endif
390 }; // end of CLASS wxDC
391 #endif
392 // _WX_DC_H_