]> git.saurik.com Git - wxWidgets.git/blob - include/wx/stubs/dc.h
made pre-compiling the python files optional
[wxWidgets.git] / include / wx / stubs / dc.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dc.h
3 // Purpose: wxDC class
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_DC_H_
13 #define _WX_DC_H_
14
15 #ifdef __GNUG__
16 #pragma interface "dc.h"
17 #endif
18
19 #include "wx/pen.h"
20 #include "wx/brush.h"
21 #include "wx/icon.h"
22 #include "wx/font.h"
23 #include "wx/gdicmn.h"
24
25 //-----------------------------------------------------------------------------
26 // constants
27 //-----------------------------------------------------------------------------
28
29 #define MM_TEXT 0
30 #define MM_ISOTROPIC 1
31 #define MM_ANISOTROPIC 2
32 #define MM_LOMETRIC 3
33 #define MM_HIMETRIC 4
34 #define MM_TWIPS 5
35 #define MM_POINTS 6
36 #define MM_METRIC 7
37
38 //-----------------------------------------------------------------------------
39 // global variables
40 //-----------------------------------------------------------------------------
41
42 extern int wxPageNumber;
43
44 //-----------------------------------------------------------------------------
45 // wxDC
46 //-----------------------------------------------------------------------------
47
48 class WXDLLEXPORT wxDC: public wxObject
49 {
50 DECLARE_ABSTRACT_CLASS(wxDC)
51
52 public:
53
54 wxDC(void);
55 ~wxDC(void);
56
57 void BeginDrawing(void) {};
58 void EndDrawing(void) {};
59
60 virtual bool Ok(void) const { return m_ok; };
61
62 virtual void FloodFill( long x1, long y1, wxColour *col, int style=wxFLOOD_SURFACE ) = 0;
63 inline void FloodFill(const wxPoint& pt, const wxColour& col, int style=wxFLOOD_SURFACE)
64 {
65 FloodFill(pt.x, pt.y, col, style);
66 }
67 virtual bool GetPixel( long x1, long y1, wxColour *col ) const = 0;
68 inline bool GetPixel(const wxPoint& pt, wxColour *col) const
69 {
70 return GetPixel(pt.x, pt.y, col);
71 }
72
73 virtual void DrawLine( long x1, long y1, long x2, long y2 ) = 0;
74 inline void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
75 {
76 DrawLine(pt1.x, pt1.y, pt2.x, pt2.y);
77 }
78
79 virtual void CrossHair( long x, long y ) = 0;
80 inline void CrossHair(const wxPoint& pt)
81 {
82 CrossHair(pt.x, pt.y);
83 }
84
85 virtual void DrawArc( long x1, long y1, long x2, long y2, double xc, double yc ) = 0;
86 inline void DrawArc(const wxPoint& pt1, const wxPoint& pt2, double xc, double yc)
87 {
88 DrawArc(pt1.x, pt1.y, pt2.x, pt2.y, xc, yc);
89 }
90
91 virtual void DrawEllipticArc( long x, long y, long width, long height, double sa, double ea ) = 0;
92 virtual void DrawEllipticArc (const wxPoint& pt, const wxSize& sz, double sa, double ea)
93 {
94 DrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea);
95 }
96
97 virtual void DrawPoint( long x, long y ) = 0;
98 virtual void DrawPoint( wxPoint& point );
99
100 virtual void DrawLines( int n, wxPoint points[], long xoffset = 0, long yoffset = 0 ) = 0;
101 virtual void DrawLines( wxList *points, long xoffset = 0, long yoffset = 0 );
102 virtual void DrawPolygon( int n, wxPoint points[], long xoffset = 0, long yoffset = 0,
103 int fillStyle=wxODDEVEN_RULE ) = 0;
104 virtual void DrawPolygon( wxList *lines, long xoffset = 0, long yoffset = 0,
105 int fillStyle=wxODDEVEN_RULE );
106
107 virtual void DrawRectangle( long x, long y, long width, long height ) = 0;
108 inline void DrawRectangle(const wxPoint& pt, const wxSize& sz)
109 {
110 DrawRectangle(pt.x, pt.y, sz.x, sz.y);
111 }
112 inline void DrawRectangle(const wxRect& rect)
113 {
114 DrawRectangle(rect.x, rect.y, rect.width, rect.height);
115 }
116 virtual void DrawRoundedRectangle( long x, long y, long width, long height, double radius = 20.0 ) = 0;
117 inline void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, double radius = 20.0)
118 {
119 DrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius);
120 }
121 inline void DrawRoundedRectangle(const wxRect& rect, double radius = 20.0)
122 {
123 DrawRoundedRectangle(rect.x, rect.y, rect.width, rect.height, radius);
124 }
125
126 virtual void DrawEllipse( long x, long y, long width, long height ) = 0;
127 inline void DrawEllipse(const wxPoint& pt, const wxSize& sz)
128 {
129 DrawEllipse(pt.x, pt.y, sz.x, sz.y);
130 }
131 inline void DrawEllipse(const wxRect& rect)
132 {
133 DrawEllipse(rect.x, rect.y, rect.width, rect.height);
134 }
135
136 virtual void DrawIcon(const wxIcon& icon, long x, long y) = 0;
137
138 virtual void DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 );
139 virtual void DrawSpline( wxList *points );
140 virtual void DrawSpline( int n, wxPoint points[] );
141
142 virtual bool CanDrawBitmap(void) const = 0;
143
144 virtual void DrawIcon( const wxIcon &icon, long x, long y, bool useMask=FALSE );
145 inline void DrawIcon(const wxIcon& icon, const wxPoint& pt)
146 {
147 DrawIcon(icon, pt.x, pt.y);
148 }
149
150 // TODO DrawBitmap is not always the same as DrawIcon, especially if bitmaps and
151 // icons are implemented differently.
152 void DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask=FALSE )
153 { DrawIcon( *((wxIcon*)(&bmp)), x, y, useMask ); }
154
155 virtual bool Blit( long xdest, long ydest, long width, long height,
156 wxDC *source, long xsrc, long ysrc, int logical_func = wxCOPY, bool useMask=FALSE ) = 0;
157 inline bool Blit(const wxPoint& destPt, const wxSize& sz,
158 wxDC *source, const wxPoint& srcPt, int rop = wxCOPY, bool useMask = FALSE)
159 {
160 return Blit(destPt.x, destPt.y, sz.x, sz.y, source, srcPt.x, srcPt.y, rop, useMask);
161 }
162
163 virtual void DrawText( const wxString &text, long x, long y, bool use16 = FALSE ) = 0;
164 inline void DrawText(const wxString& text, const wxPoint& pt, bool use16bit = FALSE)
165 {
166 DrawText(text, pt.x, pt.y, use16bit);
167 }
168
169 virtual bool CanGetTextExtent(void) const = 0;
170 virtual void GetTextExtent( const wxString &string, long *width, long *height,
171 long *descent = NULL, long *externalLeading = NULL,
172 wxFont *theFont = NULL, bool use16 = FALSE ) = 0;
173 virtual long GetCharWidth(void) = 0;
174 virtual long GetCharHeight(void) = 0;
175
176 virtual void Clear(void) = 0;
177
178 virtual void SetFont( const wxFont &font ) = 0;
179 virtual wxFont *GetFont(void) const { return &m_font; };
180
181 virtual void SetPen( const wxPen &pen ) = 0;
182 virtual wxPen *GetPen(void) const { return &m_pen; };
183
184 virtual void SetBrush( const wxBrush &brush ) = 0;
185 virtual wxBrush *GetBrush(void) const { return &m_brush; };
186
187 virtual void SetBackground( const wxBrush &brush ) = 0;
188 virtual wxBrush *GetBackground(void) const { return &m_backgroundBrush; };
189
190 virtual void SetLogicalFunction( int function ) = 0;
191 virtual int GetLogicalFunction(void) const { return m_logicalFunction; };
192
193 virtual void SetTextForeground( const wxColour &col );
194 virtual void SetTextBackground( const wxColour &col );
195 virtual wxColour& GetTextBackground(void) const { return (wxColour&)m_textBackgroundColour; };
196 virtual wxColour& GetTextForeground(void) const { return (wxColour&)m_textForegroundColour; };
197
198 virtual void SetBackgroundMode( int mode ) = 0;
199 virtual int GetBackgroundMode(void) const { return m_backgroundMode; };
200
201 virtual void SetPalette( const wxPalette& palette ) = 0;
202 void SetColourMap( const wxPalette& palette ) { SetPalette(palette); };
203
204 // the first two must be overridden and called
205 virtual void SetClippingRegion( long x, long y, long width, long height );
206 virtual void DestroyClippingRegion(void);
207 virtual void GetClippingBox( long *x, long *y, long *width, long *height ) const;
208
209 virtual inline long MinX(void) const { return m_minX; }
210 virtual inline long MaxX(void) const { return m_maxX; }
211 virtual inline long MinY(void) const { return m_minY; }
212 virtual inline long MaxY(void) const { return m_maxY; }
213
214 virtual void GetSize( int* width, int* height ) const;
215 inline wxSize GetSize(void) const { int w, h; GetSize(&w, &h); return wxSize(w, h); }
216 virtual void GetSizeMM( long* width, long* height ) const;
217
218 virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; };
219 virtual void EndDoc(void) {};
220 virtual void StartPage(void) {};
221 virtual void EndPage(void) {};
222
223 virtual void SetMapMode( int mode );
224 virtual int GetMapMode(void) const { return m_mappingMode; };
225
226 virtual void SetUserScale( double x, double y );
227 virtual void GetUserScale( double *x, double *y );
228 virtual void SetLogicalScale( double x, double y );
229 virtual void GetLogicalScale( double *x, double *y );
230
231 virtual void SetLogicalOrigin( long x, long y );
232 virtual void GetLogicalOrigin( long *x, long *y );
233 virtual void SetDeviceOrigin( long x, long y );
234 virtual void GetDeviceOrigin( long *x, long *y );
235 virtual void SetInternalDeviceOrigin( long x, long y );
236 virtual void GetInternalDeviceOrigin( long *x, long *y );
237
238 virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
239
240 virtual void SetOptimization( bool WXUNUSED(optimize) ) {};
241 virtual bool GetOptimization(void) { return m_optimize; };
242
243 virtual long DeviceToLogicalX(long x) const;
244 virtual long DeviceToLogicalY(long y) const;
245 virtual long DeviceToLogicalXRel(long x) const;
246 virtual long DeviceToLogicalYRel(long y) const;
247 virtual long LogicalToDeviceX(long x) const;
248 virtual long LogicalToDeviceY(long y) const;
249 virtual long LogicalToDeviceXRel(long x) const;
250 virtual long LogicalToDeviceYRel(long y) const;
251
252 public:
253
254 void CalcBoundingBox( long x, long y );
255 void ComputeScaleAndOrigin(void);
256
257 long XDEV2LOG(long x) const
258 {
259 long new_x = x - m_deviceOriginX;
260 if (new_x > 0)
261 return (long)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
262 else
263 return (long)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
264 }
265 long XDEV2LOGREL(long x) const
266 {
267 if (x > 0)
268 return (long)((double)(x) / m_scaleX + 0.5);
269 else
270 return (long)((double)(x) / m_scaleX - 0.5);
271 }
272 long YDEV2LOG(long y) const
273 {
274 long new_y = y - m_deviceOriginY;
275 if (new_y > 0)
276 return (long)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
277 else
278 return (long)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
279 }
280 long YDEV2LOGREL(long y) const
281 {
282 if (y > 0)
283 return (long)((double)(y) / m_scaleY + 0.5);
284 else
285 return (long)((double)(y) / m_scaleY - 0.5);
286 }
287 long XLOG2DEV(long x) const
288 {
289 long new_x = x - m_logicalOriginX;
290 if (new_x > 0)
291 return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
292 else
293 return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
294 }
295 long XLOG2DEVREL(long x) const
296 {
297 if (x > 0)
298 return (long)((double)(x) * m_scaleX + 0.5);
299 else
300 return (long)((double)(x) * m_scaleX - 0.5);
301 }
302 long YLOG2DEV(long y) const
303 {
304 long new_y = y - m_logicalOriginY;
305 if (new_y > 0)
306 return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
307 else
308 return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
309 }
310 long YLOG2DEVREL(long y) const
311 {
312 if (y > 0)
313 return (long)((double)(y) * m_scaleY + 0.5);
314 else
315 return (long)((double)(y) * m_scaleY - 0.5);
316 }
317
318 virtual void DrawOpenSpline( wxList *points ) = 0;
319
320 public:
321
322 bool m_ok;
323 bool m_colour;
324
325 // not sure, what these mean
326 bool m_clipping; // Is clipping on right now ?
327 bool m_isInteractive; // Is GetPixel possible ?
328 bool m_autoSetting; // wxMSW only ?
329 bool m_dontDelete; // wxMSW only ?
330 bool m_optimize; // wxMSW only ?
331 wxString m_filename; // Not sure where this belongs.
332
333 wxPen m_pen;
334 wxBrush m_brush;
335 wxBrush m_backgroundBrush;
336 wxColour m_textForegroundColour;
337 wxColour m_textBackgroundColour;
338 wxFont m_font;
339
340 int m_logicalFunction;
341 int m_backgroundMode;
342 int m_textAlignment; // gone in wxWin 2.0 ?
343
344 int m_mappingMode;
345
346 // not sure what for, but what is a mm on a screen you don't know the size of?
347 double m_mm_to_pix_x,m_mm_to_pix_y;
348
349 long m_internalDeviceOriginX,m_internalDeviceOriginY; // If un-scrolled is non-zero or
350 // d.o. changes with scrolling.
351 // Set using SetInternalDeviceOrigin().
352
353 long m_externalDeviceOriginX,m_externalDeviceOriginY; // To be set by external classes
354 // such as wxScrolledWindow
355 // using SetDeviceOrigin()
356
357 long m_deviceOriginX,m_deviceOriginY; // Sum of the two above.
358
359 long m_logicalOriginX,m_logicalOriginY; // User defined.
360
361 double m_scaleX,m_scaleY;
362 double m_logicalScaleX,m_logicalScaleY;
363 double m_userScaleX,m_userScaleY;
364 long m_signX,m_signY;
365
366 bool m_needComputeScaleX,m_needComputeScaleY; // not yet used
367
368 float m_scaleFactor; // wxPSDC wants to have this. Will disappear.
369
370 long m_clipX1,m_clipY1,m_clipX2,m_clipY2;
371 long m_minX,m_maxX,m_minY,m_maxY;
372 };
373
374 #endif
375 // _WX_DC_H_