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