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