]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/dc.h
compilation warning fixed
[wxWidgets.git] / include / wx / os2 / dc.h
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: dc.h
3// Purpose: wxDC class
f0a56ab0 4// Author: David Webster
0e320a79 5// Modified by:
f0a56ab0 6// Created: 08/26/99
0e320a79 7// RCS-ID: $Id$
f0a56ab0
DW
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_DC_H_
13#define _WX_DC_H_
14
fb46a9a6 15#include "wx/defs.h"
d7e1a322 16//#include "wx/dc.h"
0e320a79 17
fb46a9a6
DW
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)
0e320a79 61
fb46a9a6
DW
62// Relative
63#define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x)
64#define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y)
0e320a79 65
fb46a9a6 66#define YSCALE(y) (yorigin - (y))
0e320a79 67
fb46a9a6 68#define wx_round(a) (int)((a)+.5)
0e320a79 69
6835592c
DW
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
77class wxDCCacheEntry : public wxObject
78{
79public:
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
fb46a9a6 98class WXDLLEXPORT wxDC : public wxDCBase
54da4255 99{
fb46a9a6 100 DECLARE_DYNAMIC_CLASS(wxDC)
54da4255 101
fb46a9a6 102public:
d7e1a322 103 wxDC(void);
fb46a9a6
DW
104 ~wxDC();
105
106 // implement base class pure virtuals
107 // ----------------------------------
108
f6bcfd97
BP
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);
1408104d 160
fb46a9a6
DW
161 // implementation from now on
162 // --------------------------
54da4255 163
f6bcfd97
BP
164 virtual void SetRop(WXHDC hCdc);
165 virtual void SelectOldObjects(WXHDC hDc);
ce44c50e 166
f6bcfd97
BP
167 wxWindow* GetWindow(void) const { return m_pCanvas; }
168 void SetWindow(wxWindow* pWin) { m_pCanvas = pWin; }
ce44c50e 169
f6bcfd97
BP
170 WXHDC GetHDC(void) const { return m_hDC; }
171 void SetHDC( WXHDC hDc
172 ,bool bOwnsDC = FALSE
173 )
ce44c50e 174 {
f6bcfd97 175 m_hDC = hDc;
ce44c50e
DW
176 m_bOwnsDC = bOwnsDC;
177 }
178
d8fcb5e8
DW
179 HPS GetHPS(void) const { return m_hPS; }
180 void SetHPS(HPS hPS)
181 {
182 HDC hDC = ::GpiQueryDevice(hPS);
183 m_hPS = hPS;
184 }
f6bcfd97
BP
185 const wxBitmap& GetSelectedBitmap(void) const { return m_vSelectedBitmap; }
186 wxBitmap& GetSelectedBitmap(void) { return m_vSelectedBitmap; }
187
210a651b
DW
188 void UpdateClipBox();
189
6835592c
DW
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
1408104d 204protected:
f6bcfd97
BP
205 virtual void 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
6835592c
DW
295 ,wxCoord vXsrcMask = -1
296 ,wxCoord vYsrcMask = -1
f6bcfd97
BP
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)
fb46a9a6 309 {
f6bcfd97
BP
310 GetClippingBox( pX
311 ,pY
312 ,pWidth
313 ,pHeight
314 );
fb46a9a6 315 }
1408104d 316
f6bcfd97
BP
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 );
fb46a9a6 335
fb46a9a6 336
f6bcfd97
BP
337 //
338 // common part of DoDrawText() and DoDrawRotatedText()
339 //
340 void DrawAnyText( const wxString& rsText
341 ,wxCoord vX
342 ,wxCoord vY
343 );
fb46a9a6 344
f6bcfd97
BP
345 // OS2-specific member variables ?? do we even need this under OS/2?
346 int m_nWindowExtX;
347 int m_nWindowExtY;
1408104d 348
f6bcfd97
BP
349 //
350 // the window associated with this DC (may be NULL)
351 //
352 wxWindow* m_pCanvas;
353 wxBitmap m_vSelectedBitmap;
1408104d 354
d7e1a322
DW
355public:
356 // PM specific stuff
357 HPS m_hPS;
358 HPS m_hOldPS; // old hPS, if any
359 bool m_bIsPaintTime;// True at Paint Time
360
361 RECTL m_vRclPaint; // Bounding rectangle at Paint time etc.
f6bcfd97 362 //
fb46a9a6 363 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
f6bcfd97
BP
364 //
365 bool m_bOwnsDC:1;
fb46a9a6 366
f6bcfd97 367 //
ac7fb818 368 // our HDC
f6bcfd97
BP
369 //
370 WXHDC m_hDC;
1408104d 371
f6bcfd97 372 //
1408104d
DW
373 // Store all old GDI objects when do a SelectObject, so we can select them
374 // back in (this unselecting user's objects) so we can safely delete the
375 // DC.
f6bcfd97
BP
376 //
377 WXHBITMAP m_hOldBitmap;
378 WXHPEN m_hOldPen;
379 WXHBRUSH m_hOldBrush;
380 WXHFONT m_hOldFont;
381 WXHPALETTE m_hOldPalette;
6835592c
DW
382
383#if wxUSE_DC_CACHEING
384 static wxList m_svBitmapCache;
385 static wxList m_svDCCache;
386#endif
387}; // end of CLASS wxDC
0e320a79
DW
388#endif
389 // _WX_DC_H_