]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/dc.h
changed license type
[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 class WXDLLEXPORT wxDC : public wxDCBase
71 {
72 DECLARE_DYNAMIC_CLASS(wxDC)
73
74 public:
75 wxDC();
76 ~wxDC();
77
78 // implement base class pure virtuals
79 // ----------------------------------
80
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);
132
133 // implementation from now on
134 // --------------------------
135
136 virtual void SetRop(WXHDC hCdc);
137 virtual void SelectOldObjects(WXHDC hDc);
138
139 wxWindow* GetWindow(void) const { return m_pCanvas; }
140 void SetWindow(wxWindow* pWin) { m_pCanvas = pWin; }
141
142 WXHDC GetHDC(void) const { return m_hDC; }
143 void SetHDC( WXHDC hDc
144 ,bool bOwnsDC = FALSE
145 )
146 {
147 m_hDC = hDc;
148 m_bOwnsDC = bOwnsDC;
149 }
150
151 const wxBitmap& GetSelectedBitmap(void) const { return m_vSelectedBitmap; }
152 wxBitmap& GetSelectedBitmap(void) { return m_vSelectedBitmap; }
153
154 protected:
155 virtual void DoFloodFill( wxCoord vX
156 ,wxCoord vY
157 ,const wxColour& rCol
158 ,int nStyle = wxFLOOD_SURFACE
159 );
160
161 virtual bool DoGetPixel( wxCoord vX
162 ,wxCoord vY
163 ,wxColour* pCol
164 ) const;
165
166 virtual void DoDrawPoint( wxCoord vX
167 ,wxCoord vY
168 );
169 virtual void DoDrawLine( wxCoord vX1
170 ,wxCoord vY1
171 ,wxCoord vX2
172 ,wxCoord vY2
173 );
174
175 virtual void DoDrawArc( wxCoord vX1
176 ,wxCoord vY1
177 ,wxCoord vX2
178 ,wxCoord vY2
179 ,wxCoord vXc
180 ,wxCoord vYc
181 );
182 virtual void DoDrawCheckMark( wxCoord vX
183 ,wxCoord vY
184 ,wxCoord vWidth
185 ,wxCoord vHeight
186 );
187 virtual void DoDrawEllipticArc( wxCoord vX
188 ,wxCoord vY
189 ,wxCoord vW
190 ,wxCoord vH
191 ,double dSa
192 ,double dEa
193 );
194
195 virtual void DoDrawRectangle( wxCoord vX
196 ,wxCoord vY
197 ,wxCoord vWidth
198 ,wxCoord vHeight
199 );
200 virtual void DoDrawRoundedRectangle( wxCoord vX
201 ,wxCoord vY
202 ,wxCoord vWidth
203 ,wxCoord vHeight
204 ,double dRadius
205 );
206 virtual void DoDrawEllipse( wxCoord vX
207 ,wxCoord vY
208 ,wxCoord vWidth
209 ,wxCoord vHeight
210 );
211
212 virtual void DoCrossHair( wxCoord vX
213 ,wxCoord vY
214 );
215
216 virtual void DoDrawIcon( const wxIcon& rIcon
217 ,wxCoord vX
218 ,wxCoord vY
219 );
220 virtual void DoDrawBitmap( const wxBitmap& rBmp
221 ,wxCoord vX
222 ,wxCoord vY
223 ,bool bUseMask = FALSE
224 );
225
226 virtual void DoDrawText( const wxString& rsText
227 ,wxCoord vX
228 ,wxCoord vY
229 );
230 virtual void DoDrawRotatedText( const wxString& rsText
231 ,wxCoord vX
232 ,wxCoord vY
233 ,double dAngle
234 );
235
236 virtual bool DoBlit( wxCoord vXdest
237 ,wxCoord vYdest
238 ,wxCoord vWidth
239 ,wxCoord vHeight
240 ,wxDC* pSource
241 ,wxCoord vXsrc
242 ,wxCoord vYsrc
243 ,int nRop = wxCOPY
244 ,bool bUseMask = FALSE
245 );
246
247 virtual void DoSetClippingRegionAsRegion(const wxRegion& rRegion);
248 virtual void DoSetClippingRegion( wxCoord vX
249 ,wxCoord vY
250 ,wxCoord vWidth
251 ,wxCoord vHeight
252 );
253 virtual void DoGetClippingRegion( wxCoord* pX
254 ,wxCoord* pY
255 ,wxCoord* pWidth
256 ,wxCoord* pHeight)
257 {
258 GetClippingBox( pX
259 ,pY
260 ,pWidth
261 ,pHeight
262 );
263 }
264
265 virtual void DoGetSize( int* pWidth
266 ,int* pHeight
267 ) const;
268 virtual void DoGetSizeMM( int* pWidth
269 ,int* pHeight
270 ) const;
271
272 virtual void DoDrawLines( int n
273 ,wxPoint vaPoints[]
274 ,wxCoord vXoffset
275 ,wxCoord yYoffset
276 );
277 virtual void DoDrawPolygon( int n
278 ,wxPoint vaPoints[]
279 ,wxCoord vXoffset
280 ,wxCoord vYoffset
281 ,int nFillStyle = wxODDEVEN_RULE
282 );
283
284 #if wxUSE_SPLINES
285 virtual void DoDrawSpline(wxList* pPoints);
286 #endif // wxUSE_SPLINES
287
288 //
289 // common part of DoDrawText() and DoDrawRotatedText()
290 //
291 void DrawAnyText( const wxString& rsText
292 ,wxCoord vX
293 ,wxCoord vY
294 );
295
296 // OS2-specific member variables ?? do we even need this under OS/2?
297 int m_nWindowExtX;
298 int m_nWindowExtY;
299
300 //
301 // the window associated with this DC (may be NULL)
302 //
303 wxWindow* m_pCanvas;
304 wxBitmap m_vSelectedBitmap;
305
306 //
307 // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
308 //
309 bool m_bOwnsDC:1;
310
311 //
312 // our HDC and its usage count: we only free it when the usage count drops
313 // to 0
314 //
315 WXHDC m_hDC;
316 int m_nDCCount;
317
318 //
319 // Store all old GDI objects when do a SelectObject, so we can select them
320 // back in (this unselecting user's objects) so we can safely delete the
321 // DC.
322 //
323 WXHBITMAP m_hOldBitmap;
324 WXHPEN m_hOldPen;
325 WXHBRUSH m_hOldBrush;
326 WXHFONT m_hOldFont;
327 WXHPALETTE m_hOldPalette;
328 };
329 #endif
330 // _WX_DC_H_