]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/dc.h
Applied patch [ 1255676 ] stc2wx/wx2stc not exported (Win32 Unicode DLL)
[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 8// Copyright: (c) David Webster
65571936 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"
0e320a79 16
fb46a9a6
DW
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)
0e320a79 60
fb46a9a6
DW
61// Relative
62#define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x)
63#define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y)
0e320a79 64
fb46a9a6 65#define YSCALE(y) (yorigin - (y))
0e320a79 66
fb46a9a6 67#define wx_round(a) (int)((a)+.5)
0e320a79 68
6835592c
DW
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
76class wxDCCacheEntry : public wxObject
77{
78public:
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
fb46a9a6 97class WXDLLEXPORT wxDC : public wxDCBase
54da4255 98{
fb46a9a6 99 DECLARE_DYNAMIC_CLASS(wxDC)
54da4255 100
fb46a9a6 101public:
d7e1a322 102 wxDC(void);
fb46a9a6
DW
103 ~wxDC();
104
105 // implement base class pure virtuals
106 // ----------------------------------
107
f6bcfd97
BP
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);
1408104d 159
fb46a9a6
DW
160 // implementation from now on
161 // --------------------------
54da4255 162
f6bcfd97
BP
163 virtual void SetRop(WXHDC hCdc);
164 virtual void SelectOldObjects(WXHDC hDc);
ce44c50e 165
f6bcfd97
BP
166 wxWindow* GetWindow(void) const { return m_pCanvas; }
167 void SetWindow(wxWindow* pWin) { m_pCanvas = pWin; }
ce44c50e 168
f6bcfd97
BP
169 WXHDC GetHDC(void) const { return m_hDC; }
170 void SetHDC( WXHDC hDc
171 ,bool bOwnsDC = FALSE
172 )
ce44c50e 173 {
f6bcfd97 174 m_hDC = hDc;
ce44c50e
DW
175 m_bOwnsDC = bOwnsDC;
176 }
177
d8fcb5e8
DW
178 HPS GetHPS(void) const { return m_hPS; }
179 void SetHPS(HPS hPS)
180 {
d8fcb5e8
DW
181 m_hPS = hPS;
182 }
f6bcfd97
BP
183 const wxBitmap& GetSelectedBitmap(void) const { return m_vSelectedBitmap; }
184 wxBitmap& GetSelectedBitmap(void) { return m_vSelectedBitmap; }
185
210a651b
DW
186 void UpdateClipBox();
187
6835592c
DW
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
1408104d 202protected:
1d0edc0f 203 virtual bool DoFloodFill( wxCoord vX
f6bcfd97
BP
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
6835592c
DW
293 ,wxCoord vXsrcMask = -1
294 ,wxCoord vYsrcMask = -1
f6bcfd97
BP
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 );
1408104d 303
f6bcfd97
BP
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 );
fb46a9a6 322
938aa9c4
DW
323#if wxUSE_PALETTE
324 void DoSelectPalette(bool bRealize = FALSE);
325 void InitializePalette(void);
326#endif // wxUSE_PALETTE
fb46a9a6 327
f6bcfd97
BP
328 //
329 // common part of DoDrawText() and DoDrawRotatedText()
330 //
331 void DrawAnyText( const wxString& rsText
332 ,wxCoord vX
333 ,wxCoord vY
334 );
fb46a9a6 335
f6bcfd97
BP
336 // OS2-specific member variables ?? do we even need this under OS/2?
337 int m_nWindowExtX;
338 int m_nWindowExtY;
1408104d 339
f6bcfd97
BP
340 //
341 // the window associated with this DC (may be NULL)
342 //
343 wxWindow* m_pCanvas;
344 wxBitmap m_vSelectedBitmap;
1408104d 345
d7e1a322
DW
346public:
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.
f6bcfd97 353 //
fb46a9a6 354 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
f6bcfd97
BP
355 //
356 bool m_bOwnsDC:1;
fb46a9a6 357
f6bcfd97 358 //
ac7fb818 359 // our HDC
f6bcfd97
BP
360 //
361 WXHDC m_hDC;
1408104d 362
f6bcfd97 363 //
1408104d
DW
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.
f6bcfd97
BP
367 //
368 WXHBITMAP m_hOldBitmap;
369 WXHPEN m_hOldPen;
370 WXHBRUSH m_hOldBrush;
371 WXHFONT m_hOldFont;
372 WXHPALETTE m_hOldPalette;
6835592c
DW
373
374#if wxUSE_DC_CACHEING
375 static wxList m_svBitmapCache;
376 static wxList m_svDCCache;
377#endif
378}; // end of CLASS wxDC
0e320a79
DW
379#endif
380 // _WX_DC_H_