1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
20 #include "wx/object.h"
21 #include "wx/gdicmn.h"
26 #include "wx/gdicmn.h"
28 //-----------------------------------------------------------------------------
30 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
39 #define MM_ISOTROPIC 1
40 #define MM_ANISOTROPIC 2
47 //-----------------------------------------------------------------------------
49 //-----------------------------------------------------------------------------
51 extern int wxPageNumber
;
53 //-----------------------------------------------------------------------------
55 //-----------------------------------------------------------------------------
57 class wxDC
: public wxObject
59 DECLARE_ABSTRACT_CLASS(wxDC
)
66 void BeginDrawing(void) {};
67 void EndDrawing(void) {};
69 virtual bool Ok(void) const { return m_ok
; };
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;
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
);
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
);
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;
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
[] );
96 virtual bool CanDrawBitmap(void) const = 0;
97 virtual void DrawIcon( const wxIcon
&icon
, long x
, long y
, bool useMask
=FALSE
);
98 void DrawBitmap( const wxBitmap
&bmp
, long x
, long y
, bool useMask
=FALSE
)
99 { DrawIcon( *((wxIcon
*)(&bmp
)), x
, y
, useMask
); }
100 virtual bool Blit( long xdest
, long ydest
, long width
, long height
,
101 wxDC
*source
, long xsrc
, long ysrc
, int logical_func
= wxCOPY
, bool useMask
=FALSE
) = 0;
103 virtual void DrawText( const wxString
&text
, long x
, long y
, bool use16
= FALSE
) = 0;
104 virtual bool CanGetTextExtent(void) const = 0;
105 virtual void GetTextExtent( const wxString
&string
, long *width
, long *height
,
106 long *descent
= NULL
, long *externalLeading
= NULL
,
107 wxFont
*theFont
= NULL
, bool use16
= FALSE
) = 0;
108 virtual long GetCharWidth(void) = 0;
109 virtual long GetCharHeight(void) = 0;
111 virtual void Clear(void) = 0;
113 virtual void SetFont( const wxFont
&font
) = 0;
114 virtual wxFont
*GetFont(void) { return &m_font
; };
116 virtual void SetPen( const wxPen
&pen
) = 0;
117 virtual wxPen
*GetPen(void) { return &m_pen
; };
119 virtual void SetBrush( const wxBrush
&brush
) = 0;
120 virtual wxBrush
*GetBrush(void) { return &m_brush
; };
122 virtual void SetLogicalFunction( int function
) = 0;
123 virtual int GetLogicalFunction(void) { return m_logicalFunction
; };
125 virtual void SetTextForeground( const wxColour
&col
);
126 virtual void SetTextBackground( const wxColour
&col
);
127 virtual wxColour
& GetTextBackground(void) const { return (wxColour
&)m_textBackgroundColour
; };
128 virtual wxColour
& GetTextForeground(void) const { return (wxColour
&)m_textForegroundColour
; };
130 virtual void SetBackgroundMode( int mode
) = 0;
131 virtual int GetBackgroundMode(void) { return m_backgroundMode
; };
133 virtual void SetPalette( const wxPalette
& palette
) = 0;
134 void SetColourMap( const wxPalette
& palette
) { SetPalette(palette
); };
136 // the first two must be overridden and called
137 virtual void SetClippingRegion( long x
, long y
, long width
, long height
);
138 virtual void DestroyClippingRegion(void);
139 virtual void GetClippingBox( long *x
, long *y
, long *width
, long *height
) const;
141 virtual inline long MinX(void) const { return m_minX
; }
142 virtual inline long MaxX(void) const { return m_maxX
; }
143 virtual inline long MinY(void) const { return m_minY
; }
144 virtual inline long MaxY(void) const { return m_maxY
; }
146 virtual void GetSize( int* width
, int* height
) const;
147 inline wxSize
GetSize(void) const { int w
, h
; GetSize(&w
, &h
); return wxSize(w
, h
); }
148 virtual void GetSizeMM( long* width
, long* height
) const;
150 virtual bool StartDoc( const wxString
& WXUNUSED(message
) ) { return TRUE
; };
151 virtual void EndDoc(void) {};
152 virtual void StartPage(void) {};
153 virtual void EndPage(void) {};
155 virtual void SetMapMode( int mode
);
156 virtual int GetMapMode(void) const { return m_mappingMode
; };
158 virtual void SetUserScale( double x
, double y
);
159 virtual void GetUserScale( double *x
, double *y
);
160 virtual void SetLogicalScale( double x
, double y
);
161 virtual void GetLogicalScale( double *x
, double *y
);
163 virtual void SetLogicalOrigin( long x
, long y
);
164 virtual void GetLogicalOrigin( long *x
, long *y
);
165 virtual void SetDeviceOrigin( long x
, long y
);
166 virtual void GetDeviceOrigin( long *x
, long *y
);
167 virtual void SetInternalDeviceOrigin( long x
, long y
);
168 virtual void GetInternalDeviceOrigin( long *x
, long *y
);
170 virtual void SetAxisOrientation( bool xLeftRight
, bool yBottomUp
);
172 virtual void SetOptimization( bool WXUNUSED(optimize
) ) {};
173 virtual bool GetOptimization(void) { return m_optimize
; };
175 virtual long DeviceToLogicalX(long x
) const;
176 virtual long DeviceToLogicalY(long y
) const;
177 virtual long DeviceToLogicalXRel(long x
) const;
178 virtual long DeviceToLogicalYRel(long y
) const;
179 virtual long LogicalToDeviceX(long x
) const;
180 virtual long LogicalToDeviceY(long y
) const;
181 virtual long LogicalToDeviceXRel(long x
) const;
182 virtual long LogicalToDeviceYRel(long y
) const;
186 void CalcBoundingBox( long x
, long y
);
187 void ComputeScaleAndOrigin(void);
189 long XDEV2LOG(long x
) const
191 long new_x
= x
- m_deviceOriginX
;
193 return (long)((double)(new_x
) / m_scaleX
+ 0.5) * m_signX
+ m_logicalOriginX
;
195 return (long)((double)(new_x
) / m_scaleX
- 0.5) * m_signX
+ m_logicalOriginX
;
197 long XDEV2LOGREL(long x
) const
200 return (long)((double)(x
) / m_scaleX
+ 0.5);
202 return (long)((double)(x
) / m_scaleX
- 0.5);
204 long YDEV2LOG(long y
) const
206 long new_y
= y
- m_deviceOriginY
;
208 return (long)((double)(new_y
) / m_scaleY
+ 0.5) * m_signY
+ m_logicalOriginY
;
210 return (long)((double)(new_y
) / m_scaleY
- 0.5) * m_signY
+ m_logicalOriginY
;
212 long YDEV2LOGREL(long y
) const
215 return (long)((double)(y
) / m_scaleY
+ 0.5);
217 return (long)((double)(y
) / m_scaleY
- 0.5);
219 long XLOG2DEV(long x
) const
221 long new_x
= x
- m_logicalOriginX
;
223 return (long)((double)(new_x
) * m_scaleX
+ 0.5) * m_signX
+ m_deviceOriginX
;
225 return (long)((double)(new_x
) * m_scaleX
- 0.5) * m_signX
+ m_deviceOriginX
;
227 long XLOG2DEVREL(long x
) const
230 return (long)((double)(x
) * m_scaleX
+ 0.5);
232 return (long)((double)(x
) * m_scaleX
- 0.5);
234 long YLOG2DEV(long y
) const
236 long new_y
= y
- m_logicalOriginY
;
238 return (long)((double)(new_y
) * m_scaleY
+ 0.5) * m_signY
+ m_deviceOriginY
;
240 return (long)((double)(new_y
) * m_scaleY
- 0.5) * m_signY
+ m_deviceOriginY
;
242 long YLOG2DEVREL(long y
) const
245 return (long)((double)(y
) * m_scaleY
+ 0.5);
247 return (long)((double)(y
) * m_scaleY
- 0.5);
250 virtual void DrawOpenSpline( wxList
*points
) = 0;
257 // not sure, what these mean
258 bool m_clipping
; // Is clipping on right now ?
259 bool m_isInteractive
; // Is GetPixel possible ?
260 bool m_autoSetting
; // wxMSW only ?
261 bool m_dontDelete
; // wxMSW only ?
262 bool m_optimize
; // wxMSW only ?
263 wxString m_filename
; // Not sure where this belongs.
267 wxBrush m_backgroundBrush
;
268 wxColour m_textForegroundColour
;
269 wxColour m_textBackgroundColour
;
272 int m_logicalFunction
;
273 int m_backgroundMode
;
274 int m_textAlignment
; // gone in wxWin 2.0 ?
278 // not sure what for, but what is a mm on a screen you don't know the size of?
279 double m_mm_to_pix_x
,m_mm_to_pix_y
;
281 long m_internalDeviceOriginX
,m_internalDeviceOriginY
; // If un-scrolled is non-zero or
282 // d.o. changes with scrolling.
283 // Set using SetInternalDeviceOrigin().
285 long m_externalDeviceOriginX
,m_externalDeviceOriginY
; // To be set by external classes
286 // such as wxScrolledWindow
287 // using SetDeviceOrigin()
289 long m_deviceOriginX
,m_deviceOriginY
; // Sum of the two above.
291 long m_logicalOriginX
,m_logicalOriginY
; // User defined.
293 double m_scaleX
,m_scaleY
;
294 double m_logicalScaleX
,m_logicalScaleY
;
295 double m_userScaleX
,m_userScaleY
;
296 long m_signX
,m_signY
;
298 bool m_needComputeScaleX
,m_needComputeScaleY
; // not yet used
300 float m_scaleFactor
; // wxPSDC wants to have this. Will disappear.
302 long m_clipX1
,m_clipY1
,m_clipX2
,m_clipY2
;
303 long m_minX
,m_maxX
,m_minY
,m_maxY
;