1 /////////////////////////////////////////////////////////////////////////////
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "dc.h"
23 #include "wx/gdicmn.h"
25 class WXDLLEXPORT wxDC
: public wxObject
27 DECLARE_ABSTRACT_CLASS(wxDC
)
32 // Compatibility (obsolete)
33 inline void wxDC::BeginDrawing() {}
34 inline void wxDC::EndDrawing() {}
36 virtual void FloodFill(long x1
, long y1
, const wxColour
& col
, int style
=wxFLOOD_SURFACE
) ;
37 inline void FloodFill(const wxPoint
& pt
, const wxColour
& col
, int style
=wxFLOOD_SURFACE
)
39 FloodFill(pt
.x
, pt
.y
, col
, style
);
42 virtual bool GetPixel(long x1
, long y1
, wxColour
*col
) const ;
43 inline bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
45 return GetPixel(pt
.x
, pt
.y
, col
);
48 virtual void DrawLine(long x1
, long y1
, long x2
, long y2
);
49 inline void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
51 DrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
);
54 virtual void CrossHair(long x
, long y
) ;
55 virtual void CrossHair(const wxPoint
& pt
)
57 CrossHair(pt
.x
, pt
.y
);
60 virtual void DrawArc(long x1
,long y1
,long x2
,long y2
,double xc
, double yc
);
61 inline void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, double xc
, double yc
)
63 DrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, xc
, yc
);
66 virtual void DrawEllipticArc (long x
, long y
, long w
, long h
, double sa
, double ea
);
67 virtual void DrawEllipticArc (const wxPoint
& pt
, const wxSize
& sz
, double sa
, double ea
)
69 DrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
);
72 virtual void DrawPoint(long x
, long y
);
73 inline void DrawPoint(const wxPoint
& pt
)
75 DrawPoint(pt
.x
, pt
.y
);
78 virtual void DrawLines(int n
, wxPoint points
[], long xoffset
= 0, long yoffset
= 0);
80 virtual void DrawPolygon(int n
, wxPoint points
[], long xoffset
= 0, long yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
82 virtual void DrawRectangle(long x
, long y
, long width
, long height
);
83 inline void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
85 DrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
);
87 inline void DrawRectangle(const wxRect
& rect
)
89 DrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
92 virtual void DrawRoundedRectangle(long x
, long y
, long width
, long height
, double radius
= 20.0);
93 inline void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
, double radius
= 20.0)
95 DrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
);
97 inline void DrawRoundedRectangle(const wxRect
& rect
, double radius
= 20.0)
99 DrawRoundedRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
, radius
);
102 virtual void DrawEllipse(long x
, long y
, long width
, long height
);
103 inline void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
105 DrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
);
107 inline void DrawEllipse(const wxRect
& rect
)
109 DrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
112 virtual void DrawIcon(const wxIcon
& icon
, long x
, long y
);
113 inline void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
115 DrawIcon(icon
, pt
.x
, pt
.y
);
118 inline void DrawPoint(wxPoint
& point
) { DrawPoint(point
.x
, point
.y
); }
119 virtual void DrawLines(wxList
*list
, long xoffset
= 0, long yoffset
= 0);
120 virtual void DrawPolygon(wxList
*list
, long xoffset
= 0, long yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
122 virtual void DrawText(const wxString
& text
, long x
, long y
, bool use16bit
= FALSE
);
123 inline void DrawText(const wxString
& text
, const wxPoint
& pt
, bool use16bit
= FALSE
)
125 DrawText(text
, pt
.x
, pt
.y
, use16bit
);
128 virtual bool Blit(long xdest
, long ydest
, long width
, long height
,
129 wxDC
*source
, long xsrc
, long ysrc
, int rop
= wxCOPY
, bool useMask
= FALSE
);
130 inline bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
131 wxDC
*source
, const wxPoint
& srcPt
, int rop
= wxCOPY
, bool useMask
= FALSE
)
133 return Blit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
, source
, srcPt
.x
, srcPt
.y
, rop
, useMask
);
139 virtual void DrawSpline(long x1
, long y1
, long x2
, long y2
, long x3
, long y3
);
140 // Any number of control points - a list of pointers to wxPoints
141 virtual void DrawSpline(wxList
*points
);
142 virtual void DrawSpline(int n
, wxPoint points
[]);
144 virtual void Clear();
145 virtual void SetFont(const wxFont
& font
);
146 virtual void SetPen(const wxPen
& pen
);
147 virtual void SetBrush(const wxBrush
& brush
);
148 virtual void SetLogicalFunction(int function
);
149 virtual void SetBackground(const wxBrush
& brush
);
150 virtual void SetBackgroundMode(int mode
);
152 virtual void SetClippingRegion(long x
, long y
, long width
, long height
);
153 inline void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
155 SetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
);
157 inline void SetClippingRegion(const wxRect
& rect
)
159 SetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
162 virtual void SetPalette(const wxPalette
& palette
);
163 virtual void DestroyClippingRegion();
164 virtual long GetCharHeight() const;
165 virtual long GetCharWidth() const;
166 virtual void GetTextExtent(const wxString
& string
, long *x
, long *y
,
167 long *descent
= NULL
, long *externalLeading
= NULL
,
168 wxFont
*theFont
= NULL
, bool use16bit
= FALSE
) const;
170 // Size in device units
171 virtual void GetSize(int* width
, int* height
) const;
172 inline wxSize
GetSize() const { int w
, h
; GetSize(&w
, &h
); return wxSize(w
, h
); }
175 virtual void GetSizeMM(long* width
, long* height
) const ;
177 virtual bool StartDoc(const wxString
& message
);
178 virtual void EndDoc();
179 virtual void StartPage();
180 virtual void EndPage();
181 virtual void SetMapMode(int mode
);
182 virtual void SetUserScale(double x
, double y
);
183 virtual void SetSystemScale(double x
, double y
);
184 virtual void SetLogicalOrigin(long x
, long y
);
185 virtual void SetDeviceOrigin(long x
, long y
);
186 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
188 // This group of functions does actual conversion
189 // of the input, as you'd expect.
191 long DeviceToLogicalX(long x
) const;
192 long DeviceToLogicalY(long y
) const;
193 long DeviceToLogicalXRel(long x
) const;
194 long DeviceToLogicalYRel(long y
) const;
195 long LogicalToDeviceX(long x
) const;
196 long LogicalToDeviceY(long y
) const;
197 long LogicalToDeviceXRel(long x
) const;
198 long LogicalToDeviceYRel(long y
) const;
200 virtual bool CanDrawBitmap() const;
201 virtual bool CanGetTextExtent() const;
203 virtual void SetTextForeground(const wxColour
& colour
);
204 virtual void SetTextBackground(const wxColour
& colour
);
205 inline virtual bool Ok() const {return m_ok
;};
206 inline virtual int GetMapMode() const {return m_mappingMode
;};
208 inline virtual wxBrush
*GetBackground() const { return (wxBrush
*) &m_backgroundBrush
;}
209 inline virtual wxBrush
*GetBrush() const { return (wxBrush
*) &m_brush
;}
210 inline virtual wxFont
*GetFont() const { return (wxFont
*) &m_font
;}
211 inline virtual int GetLogicalFunction() const { return m_logicalFunction
;}
212 inline virtual wxPen
*GetPen() const { return (wxPen
*) &m_pen
;}
213 inline virtual wxColour
&GetTextBackground() const { return (wxColour
&) m_textBackgroundColour
;}
214 inline virtual wxColour
&GetTextForeground() const { return (wxColour
&) m_textForegroundColour
;}
216 virtual void SetLogicalScale(double x
, double y
);
217 virtual inline void GetUserScale(double* x
, double *y
) const { *x
= m_userScaleX
; *y
= m_userScaleY
; }
218 virtual void CalcBoundingBox(long x
, long y
);
219 // Get the final bounding box of the PostScript or Metafile picture.
220 virtual inline long MinX() const { return m_minX
; }
221 virtual inline long MaxX() const { return m_maxX
; }
222 virtual inline long MinY() const { return m_minY
; }
223 virtual inline long MaxY() const { return m_maxY
; }
225 // Sometimes we need to override optimization, e.g.
226 // if other software is drawing onto our surface and we
227 // can't be sure of who's done what.
228 virtual inline void SetOptimization(bool WXUNUSED(opt
)) { }
229 virtual inline bool GetOptimization() { return FALSE
; }
231 virtual void GetClippingBox(long *x
,long *y
,long *w
,long *h
) const ;
232 inline void GetClippingBox(wxRect
& rect
) const
235 GetClippingBox(&x
, &y
, &w
, &h
); rect
.x
= x
; rect
.y
= y
; rect
.width
= w
; rect
.height
= h
;
238 inline wxWindow
*GetWindow() const { return m_canvas
; }
239 inline void SetWindow(wxWindow
*win
) { m_canvas
= win
; }
245 bool m_isInteractive
;
247 // Coordinate system variables
248 long m_logicalOriginX
;
249 long m_logicalOriginY
;
251 long m_deviceOriginX
;
252 long m_deviceOriginY
;
254 double m_logicalScaleX
;
255 double m_logicalScaleY
;
260 int m_signX
; // Used by SetAxisOrientation() to
261 int m_signY
; // invert the axes
265 long m_minX
; // bounding box
270 int m_logicalFunction
;
271 int m_backgroundMode
;
275 wxBrush m_backgroundBrush
;
276 wxColour m_textForegroundColour
;
277 wxColour m_textBackgroundColour
;
284 double m_systemScaleX
;
285 double m_systemScaleY
;
288 wxBitmap m_selectedBitmap
;