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