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