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