]>
Commit | Line | Data |
---|---|---|
006162a9 | 1 | ///////////////////////////////////////////////////////////////////////////// |
4660e6ac | 2 | // Name: wx/dc.h |
006162a9 VZ |
3 | // Purpose: wxDC class |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 05/25/99 | |
7 | // RCS-ID: $Id$ | |
77ffb593 | 8 | // Copyright: (c) wxWidgets team |
65571936 | 9 | // Licence: wxWindows licence |
006162a9 VZ |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
34138703 JS |
12 | #ifndef _WX_DC_H_BASE_ |
13 | #define _WX_DC_H_BASE_ | |
c801d85f | 14 | |
a23fd0e1 VZ |
15 | // ---------------------------------------------------------------------------- |
16 | // headers which we must include here | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | #include "wx/object.h" // the base class | |
20 | ||
0d80fb31 | 21 | #include "wx/intl.h" // for wxLayoutDirection |
a23fd0e1 VZ |
22 | #include "wx/cursor.h" // we have member variables of these classes |
23 | #include "wx/font.h" // so we can't do without them | |
24 | #include "wx/colour.h" | |
b494e2b0 | 25 | #include "wx/bitmap.h" // for wxNullBitmap |
a23fd0e1 VZ |
26 | #include "wx/brush.h" |
27 | #include "wx/pen.h" | |
28 | #include "wx/palette.h" | |
a23fd0e1 | 29 | #include "wx/list.h" // we use wxList in inline functions |
0919e93e | 30 | #include "wx/dynarray.h" |
19edb09c | 31 | #include "wx/math.h" |
a23fd0e1 | 32 | |
f4515f98 | 33 | class WXDLLEXPORT wxDC; |
aec43716 KH |
34 | class WXDLLEXPORT wxDCBase; |
35 | ||
36 | class WXDLLEXPORT wxDrawObject | |
37 | { | |
38 | public: | |
39 | ||
40 | wxDrawObject() | |
68379eaf | 41 | : m_isBBoxValid(false) |
ba161d7e GD |
42 | , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0) |
43 | { } | |
aec43716 KH |
44 | |
45 | virtual ~wxDrawObject() { } | |
46 | ||
33ac7e6f | 47 | virtual void Draw(wxDCBase&) const { } |
aec43716 KH |
48 | |
49 | virtual void CalcBoundingBox(wxCoord x, wxCoord y) | |
50 | { | |
51 | if ( m_isBBoxValid ) | |
52 | { | |
53 | if ( x < m_minX ) m_minX = x; | |
54 | if ( y < m_minY ) m_minY = y; | |
55 | if ( x > m_maxX ) m_maxX = x; | |
56 | if ( y > m_maxY ) m_maxY = y; | |
57 | } | |
58 | else | |
59 | { | |
68379eaf | 60 | m_isBBoxValid = true; |
aec43716 KH |
61 | |
62 | m_minX = x; | |
63 | m_minY = y; | |
64 | m_maxX = x; | |
65 | m_maxY = y; | |
66 | } | |
67 | } | |
68 | ||
69 | void ResetBoundingBox() | |
70 | { | |
68379eaf | 71 | m_isBBoxValid = false; |
aec43716 KH |
72 | |
73 | m_minX = m_maxX = m_minY = m_maxY = 0; | |
74 | } | |
75 | ||
76 | // Get the final bounding box of the PostScript or Metafile picture. | |
77 | ||
78 | wxCoord MinX() const { return m_minX; } | |
79 | wxCoord MaxX() const { return m_maxX; } | |
80 | wxCoord MinY() const { return m_minY; } | |
81 | wxCoord MaxY() const { return m_maxY; } | |
82 | ||
83 | //to define the type of object for derived objects | |
84 | virtual int GetType()=0; | |
85 | ||
86 | protected: | |
87 | //for boundingbox calculation | |
88 | bool m_isBBoxValid:1; | |
89 | //for boundingbox calculation | |
90 | wxCoord m_minX, m_minY, m_maxX, m_maxY; | |
91 | }; | |
92 | ||
a23fd0e1 VZ |
93 | // --------------------------------------------------------------------------- |
94 | // global variables | |
95 | // --------------------------------------------------------------------------- | |
96 | ||
a23fd0e1 VZ |
97 | // --------------------------------------------------------------------------- |
98 | // wxDC is the device context - object on which any drawing is done | |
99 | // --------------------------------------------------------------------------- | |
100 | ||
101 | class WXDLLEXPORT wxDCBase : public wxObject | |
102 | { | |
a23fd0e1 | 103 | public: |
04ab8b6d RR |
104 | wxDCBase(); |
105 | virtual ~wxDCBase(); | |
106 | ||
a23fd0e1 VZ |
107 | // graphic primitives |
108 | // ------------------ | |
109 | ||
aec43716 KH |
110 | virtual void DrawObject(wxDrawObject* drawobject) |
111 | { | |
112 | drawobject->Draw(*this); | |
113 | CalcBoundingBox(drawobject->MinX(),drawobject->MinY()); | |
114 | CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY()); | |
115 | } | |
116 | ||
387ebd3e | 117 | bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, |
72cdf4c9 | 118 | int style = wxFLOOD_SURFACE) |
387ebd3e JS |
119 | { return DoFloodFill(x, y, col, style); } |
120 | bool FloodFill(const wxPoint& pt, const wxColour& col, | |
72cdf4c9 | 121 | int style = wxFLOOD_SURFACE) |
387ebd3e | 122 | { return DoFloodFill(pt.x, pt.y, col, style); } |
a23fd0e1 | 123 | |
213ad8e7 VZ |
124 | // fill the area specified by rect with a radial gradient, starting from |
125 | // initialColour in the centre of the cercle and fading to destColour. | |
126 | void GradientFillConcentric(const wxRect& rect, | |
4660e6ac | 127 | const wxColour& initialColour, |
213ad8e7 VZ |
128 | const wxColour& destColour) |
129 | { GradientFillConcentric(rect, initialColour, destColour, | |
130 | wxPoint(rect.GetWidth() / 2, | |
131 | rect.GetHeight() / 2)); } | |
132 | ||
133 | void GradientFillConcentric(const wxRect& rect, | |
4660e6ac | 134 | const wxColour& initialColour, |
213ad8e7 | 135 | const wxColour& destColour, |
fb63a242 SC |
136 | const wxPoint& circleCenter) |
137 | { DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); } | |
213ad8e7 VZ |
138 | |
139 | // fill the area specified by rect with a linear gradient | |
140 | void GradientFillLinear(const wxRect& rect, | |
4660e6ac | 141 | const wxColour& initialColour, |
213ad8e7 VZ |
142 | const wxColour& destColour, |
143 | wxDirection nDirection = wxEAST) | |
144 | { DoGradientFillLinear(rect, initialColour, destColour, nDirection); } | |
145 | ||
72cdf4c9 | 146 | bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const |
a23fd0e1 VZ |
147 | { return DoGetPixel(x, y, col); } |
148 | bool GetPixel(const wxPoint& pt, wxColour *col) const | |
149 | { return DoGetPixel(pt.x, pt.y, col); } | |
150 | ||
72cdf4c9 | 151 | void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) |
a23fd0e1 VZ |
152 | { DoDrawLine(x1, y1, x2, y2); } |
153 | void DrawLine(const wxPoint& pt1, const wxPoint& pt2) | |
154 | { DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); } | |
155 | ||
72cdf4c9 | 156 | void CrossHair(wxCoord x, wxCoord y) |
a23fd0e1 VZ |
157 | { DoCrossHair(x, y); } |
158 | void CrossHair(const wxPoint& pt) | |
159 | { DoCrossHair(pt.x, pt.y); } | |
160 | ||
72cdf4c9 VZ |
161 | void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, |
162 | wxCoord xc, wxCoord yc) | |
a23fd0e1 VZ |
163 | { DoDrawArc(x1, y1, x2, y2, xc, yc); } |
164 | void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre) | |
165 | { DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); } | |
166 | ||
cd9da200 VZ |
167 | void DrawCheckMark(wxCoord x, wxCoord y, |
168 | wxCoord width, wxCoord height) | |
169 | { DoDrawCheckMark(x, y, width, height); } | |
170 | void DrawCheckMark(const wxRect& rect) | |
171 | { DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); } | |
172 | ||
72cdf4c9 VZ |
173 | void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, |
174 | double sa, double ea) | |
7b90a8f2 | 175 | { DoDrawEllipticArc(x, y, w, h, sa, ea); } |
a23fd0e1 VZ |
176 | void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, |
177 | double sa, double ea) | |
178 | { DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); } | |
179 | ||
72cdf4c9 | 180 | void DrawPoint(wxCoord x, wxCoord y) |
a23fd0e1 VZ |
181 | { DoDrawPoint(x, y); } |
182 | void DrawPoint(const wxPoint& pt) | |
183 | { DoDrawPoint(pt.x, pt.y); } | |
184 | ||
72cdf4c9 VZ |
185 | void DrawLines(int n, wxPoint points[], |
186 | wxCoord xoffset = 0, wxCoord yoffset = 0) | |
a23fd0e1 | 187 | { DoDrawLines(n, points, xoffset, yoffset); } |
72cdf4c9 VZ |
188 | void DrawLines(const wxList *list, |
189 | wxCoord xoffset = 0, wxCoord yoffset = 0); | |
a23fd0e1 VZ |
190 | |
191 | void DrawPolygon(int n, wxPoint points[], | |
72cdf4c9 | 192 | wxCoord xoffset = 0, wxCoord yoffset = 0, |
a23fd0e1 VZ |
193 | int fillStyle = wxODDEVEN_RULE) |
194 | { DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); } | |
195 | ||
196 | void DrawPolygon(const wxList *list, | |
72cdf4c9 | 197 | wxCoord xoffset = 0, wxCoord yoffset = 0, |
bd5dd957 | 198 | int fillStyle = wxODDEVEN_RULE); |
a23fd0e1 | 199 | |
793db755 | 200 | void DrawPolyPolygon(int n, int count[], wxPoint points[], |
6e76b35d VZ |
201 | wxCoord xoffset = 0, wxCoord yoffset = 0, |
202 | int fillStyle = wxODDEVEN_RULE) | |
793db755 | 203 | { DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); } |
6e76b35d | 204 | |
72cdf4c9 | 205 | void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) |
a23fd0e1 VZ |
206 | { DoDrawRectangle(x, y, width, height); } |
207 | void DrawRectangle(const wxPoint& pt, const wxSize& sz) | |
208 | { DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); } | |
209 | void DrawRectangle(const wxRect& rect) | |
210 | { DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); } | |
211 | ||
72cdf4c9 | 212 | void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, |
a23fd0e1 VZ |
213 | double radius) |
214 | { DoDrawRoundedRectangle(x, y, width, height, radius); } | |
215 | void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, | |
216 | double radius) | |
217 | { DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); } | |
218 | void DrawRoundedRectangle(const wxRect& r, double radius) | |
219 | { DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); } | |
220 | ||
72cdf4c9 | 221 | void DrawCircle(wxCoord x, wxCoord y, wxCoord radius) |
220af862 | 222 | { DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); } |
0371e9a8 | 223 | void DrawCircle(const wxPoint& pt, wxCoord radius) |
b95edd47 | 224 | { DrawCircle(pt.x, pt.y, radius); } |
0371e9a8 | 225 | |
72cdf4c9 | 226 | void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) |
a23fd0e1 VZ |
227 | { DoDrawEllipse(x, y, width, height); } |
228 | void DrawEllipse(const wxPoint& pt, const wxSize& sz) | |
229 | { DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); } | |
230 | void DrawEllipse(const wxRect& rect) | |
231 | { DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); } | |
232 | ||
72cdf4c9 | 233 | void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) |
a23fd0e1 VZ |
234 | { DoDrawIcon(icon, x, y); } |
235 | void DrawIcon(const wxIcon& icon, const wxPoint& pt) | |
236 | { DoDrawIcon(icon, pt.x, pt.y); } | |
237 | ||
72cdf4c9 | 238 | void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, |
68379eaf | 239 | bool useMask = false) |
a23fd0e1 VZ |
240 | { DoDrawBitmap(bmp, x, y, useMask); } |
241 | void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, | |
68379eaf | 242 | bool useMask = false) |
a23fd0e1 VZ |
243 | { DoDrawBitmap(bmp, pt.x, pt.y, useMask); } |
244 | ||
72cdf4c9 | 245 | void DrawText(const wxString& text, wxCoord x, wxCoord y) |
a23fd0e1 VZ |
246 | { DoDrawText(text, x, y); } |
247 | void DrawText(const wxString& text, const wxPoint& pt) | |
248 | { DoDrawText(text, pt.x, pt.y); } | |
249 | ||
95724b1a VZ |
250 | void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) |
251 | { DoDrawRotatedText(text, x, y, angle); } | |
252 | void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle) | |
253 | { DoDrawRotatedText(text, pt.x, pt.y, angle); } | |
254 | ||
1e6feb95 VZ |
255 | // this version puts both optional bitmap and the text into the given |
256 | // rectangle and aligns is as specified by alignment parameter; it also | |
257 | // will emphasize the character with the given index if it is != -1 and | |
258 | // return the bounding rectangle if required | |
259 | virtual void DrawLabel(const wxString& text, | |
260 | const wxBitmap& image, | |
261 | const wxRect& rect, | |
262 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
263 | int indexAccel = -1, | |
264 | wxRect *rectBounding = NULL); | |
265 | ||
266 | void DrawLabel(const wxString& text, const wxRect& rect, | |
267 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
268 | int indexAccel = -1) | |
269 | { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); } | |
270 | ||
72cdf4c9 VZ |
271 | bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, |
272 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
68379eaf | 273 | int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) |
a23fd0e1 VZ |
274 | { |
275 | return DoBlit(xdest, ydest, width, height, | |
0cbff120 | 276 | source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask); |
a23fd0e1 VZ |
277 | } |
278 | bool Blit(const wxPoint& destPt, const wxSize& sz, | |
279 | wxDC *source, const wxPoint& srcPt, | |
68379eaf | 280 | int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition) |
a23fd0e1 VZ |
281 | { |
282 | return DoBlit(destPt.x, destPt.y, sz.x, sz.y, | |
0cbff120 | 283 | source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y); |
a23fd0e1 | 284 | } |
e3b81044 VZ |
285 | |
286 | bool StretchBlit(wxCoord dstX, wxCoord dstY, | |
287 | wxCoord dstWidth, wxCoord dstHeight, | |
288 | wxDC *source, | |
289 | wxCoord srcX, wxCoord srcY, | |
290 | wxCoord srcWidth, wxCoord srcHeight, | |
291 | int rop = wxCOPY, bool useMask = false, | |
292 | wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord) | |
293 | { | |
294 | return DoStretchBlit(dstX, dstY, dstWidth, dstHeight, | |
295 | source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY); | |
296 | } | |
297 | bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize, | |
298 | wxDC *source, const wxPoint& srcPt, const wxSize& srcSize, | |
299 | int rop = wxCOPY, bool useMask = false, const wxPoint& srcMaskPt = wxDefaultPosition) | |
300 | { | |
301 | return DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y, | |
302 | source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y); | |
303 | } | |
304 | ||
c59abe03 | 305 | wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const |
c64c9cd3 | 306 | { |
c59abe03 | 307 | return DoGetAsBitmap(subrect); |
c64c9cd3 | 308 | } |
a23fd0e1 VZ |
309 | |
310 | #if wxUSE_SPLINES | |
72cdf4c9 VZ |
311 | // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?) |
312 | void DrawSpline(wxCoord x1, wxCoord y1, | |
313 | wxCoord x2, wxCoord y2, | |
314 | wxCoord x3, wxCoord y3); | |
bd5dd957 | 315 | void DrawSpline(int n, wxPoint points[]); |
a23fd0e1 VZ |
316 | |
317 | void DrawSpline(wxList *points) { DoDrawSpline(points); } | |
318 | #endif // wxUSE_SPLINES | |
319 | ||
12bdd77c JS |
320 | // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE |
321 | #ifdef __WXWINCE__ | |
322 | //! Generic method to draw ellipses, circles and arcs with current pen and brush. | |
323 | /*! \param x Upper left corner of bounding box. | |
324 | * \param y Upper left corner of bounding box. | |
325 | * \param w Width of bounding box. | |
326 | * \param h Height of bounding box. | |
d16b634f | 327 | * \param sa Starting angle of arc |
12bdd77c JS |
328 | * (counterclockwise, start at 3 o'clock, 360 is full circle). |
329 | * \param ea Ending angle of arc. | |
d16b634f | 330 | * \param angle Rotation angle, the Arc will be rotated after |
12bdd77c JS |
331 | * calculating begin and end. |
332 | */ | |
d16b634f VZ |
333 | void DrawEllipticArcRot( wxCoord x, wxCoord y, |
334 | wxCoord width, wxCoord height, | |
12bdd77c JS |
335 | double sa = 0, double ea = 0, double angle = 0 ) |
336 | { DoDrawEllipticArcRot( x, y, width, height, sa, ea, angle ); } | |
d16b634f VZ |
337 | |
338 | void DrawEllipticArcRot( const wxPoint& pt, | |
12bdd77c JS |
339 | const wxSize& sz, |
340 | double sa = 0, double ea = 0, double angle = 0 ) | |
341 | { DoDrawEllipticArcRot( pt.x, pt.y, sz.x, sz.y, sa, ea, angle ); } | |
342 | ||
343 | void DrawEllipticArcRot( const wxRect& rect, | |
344 | double sa = 0, double ea = 0, double angle = 0 ) | |
345 | { DoDrawEllipticArcRot( rect.x, rect.y, rect.width, rect.height, sa, ea, angle ); } | |
346 | ||
d16b634f VZ |
347 | virtual void DoDrawEllipticArcRot( wxCoord x, wxCoord y, |
348 | wxCoord w, wxCoord h, | |
12bdd77c | 349 | double sa = 0, double ea = 0, double angle = 0 ); |
d16b634f | 350 | |
12bdd77c JS |
351 | //! Rotates points around center. |
352 | /*! This is a quite straight method, it calculates in pixels | |
353 | * and so it produces rounding errors. | |
354 | * \param points The points inside will be rotated. | |
355 | * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle). | |
356 | * \param center Center of rotation. | |
d16b634f | 357 | */ |
c47addef | 358 | void Rotate( wxList* points, double angle, wxPoint center = wxPoint(0,0) ); |
12bdd77c JS |
359 | |
360 | // used by DrawEllipticArcRot | |
361 | // Careful: wxList gets filled with points you have to delete later. | |
d16b634f VZ |
362 | void CalculateEllipticPoints( wxList* points, |
363 | wxCoord xStart, wxCoord yStart, | |
364 | wxCoord w, wxCoord h, | |
12bdd77c JS |
365 | double sa, double ea ); |
366 | #endif | |
d16b634f | 367 | |
a23fd0e1 VZ |
368 | // global DC operations |
369 | // -------------------- | |
370 | ||
371 | virtual void Clear() = 0; | |
372 | ||
68379eaf | 373 | virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; } |
af0bb3b1 | 374 | virtual void EndDoc() { } |
a23fd0e1 | 375 | |
af0bb3b1 VZ |
376 | virtual void StartPage() { } |
377 | virtual void EndPage() { } | |
a23fd0e1 | 378 | |
2e992e06 VZ |
379 | #if WXWIN_COMPATIBILITY_2_6 |
380 | wxDEPRECATED( void BeginDrawing() ); | |
381 | wxDEPRECATED( void EndDrawing() ); | |
382 | #endif // WXWIN_COMPATIBILITY_2_6 | |
383 | ||
384 | ||
a23fd0e1 VZ |
385 | // set objects to use for drawing |
386 | // ------------------------------ | |
387 | ||
388 | virtual void SetFont(const wxFont& font) = 0; | |
389 | virtual void SetPen(const wxPen& pen) = 0; | |
390 | virtual void SetBrush(const wxBrush& brush) = 0; | |
391 | virtual void SetBackground(const wxBrush& brush) = 0; | |
392 | virtual void SetBackgroundMode(int mode) = 0; | |
d275c7eb | 393 | #if wxUSE_PALETTE |
a23fd0e1 | 394 | virtual void SetPalette(const wxPalette& palette) = 0; |
d275c7eb | 395 | #endif // wxUSE_PALETTE |
a23fd0e1 VZ |
396 | |
397 | // clipping region | |
398 | // --------------- | |
399 | ||
72cdf4c9 | 400 | void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) |
a23fd0e1 VZ |
401 | { DoSetClippingRegion(x, y, width, height); } |
402 | void SetClippingRegion(const wxPoint& pt, const wxSize& sz) | |
403 | { DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); } | |
404 | void SetClippingRegion(const wxRect& rect) | |
405 | { DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); } | |
406 | void SetClippingRegion(const wxRegion& region) | |
407 | { DoSetClippingRegionAsRegion(region); } | |
408 | ||
d16b634f | 409 | virtual void DestroyClippingRegion() { ResetClipping(); } |
a23fd0e1 | 410 | |
72cdf4c9 | 411 | void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const |
a23fd0e1 VZ |
412 | { DoGetClippingBox(x, y, w, h); } |
413 | void GetClippingBox(wxRect& rect) const | |
8fb3a512 | 414 | { |
ae500232 | 415 | DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height); |
8fb3a512 | 416 | } |
a23fd0e1 VZ |
417 | |
418 | // text extent | |
419 | // ----------- | |
420 | ||
72cdf4c9 VZ |
421 | virtual wxCoord GetCharHeight() const = 0; |
422 | virtual wxCoord GetCharWidth() const = 0; | |
cd9da200 | 423 | |
1e6feb95 | 424 | // only works for single line strings |
72cdf4c9 VZ |
425 | void GetTextExtent(const wxString& string, |
426 | wxCoord *x, wxCoord *y, | |
427 | wxCoord *descent = NULL, | |
428 | wxCoord *externalLeading = NULL, | |
c94f845b | 429 | const wxFont *theFont = NULL) const |
72cdf4c9 | 430 | { DoGetTextExtent(string, x, y, descent, externalLeading, theFont); } |
a23fd0e1 | 431 | |
cc4f194e VZ |
432 | wxSize GetTextExtent(const wxString& string) const |
433 | { | |
434 | wxCoord w, h; | |
435 | DoGetTextExtent(string, &w, &h); | |
436 | return wxSize(w, h); | |
437 | } | |
438 | ||
1e6feb95 | 439 | // works for single as well as multi-line strings |
cc4f194e | 440 | virtual void GetMultiLineTextExtent(const wxString& string, |
1e6feb95 VZ |
441 | wxCoord *width, |
442 | wxCoord *height, | |
443 | wxCoord *heightLine = NULL, | |
c94f845b | 444 | const wxFont *font = NULL) const; |
1e6feb95 | 445 | |
cc4f194e VZ |
446 | wxSize GetMultiLineTextExtent(const wxString& string) const |
447 | { | |
448 | wxCoord w, h; | |
449 | GetMultiLineTextExtent(string, &w, &h); | |
450 | return wxSize(w, h); | |
451 | } | |
452 | ||
0919e93e RD |
453 | // Measure cumulative width of text after each character |
454 | bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const | |
455 | { return DoGetPartialTextExtents(text, widths); } | |
456 | ||
d16b634f | 457 | |
a23fd0e1 VZ |
458 | // size and resolution |
459 | // ------------------- | |
460 | ||
461 | // in device units | |
462 | void GetSize(int *width, int *height) const | |
463 | { DoGetSize(width, height); } | |
464 | wxSize GetSize() const | |
465 | { | |
466 | int w, h; | |
467 | DoGetSize(&w, &h); | |
468 | ||
469 | return wxSize(w, h); | |
470 | } | |
471 | ||
472 | // in mm | |
473 | void GetSizeMM(int* width, int* height) const | |
474 | { DoGetSizeMM(width, height); } | |
475 | wxSize GetSizeMM() const | |
476 | { | |
477 | int w, h; | |
478 | DoGetSizeMM(&w, &h); | |
479 | ||
480 | return wxSize(w, h); | |
481 | } | |
482 | ||
a23fd0e1 VZ |
483 | // query DC capabilities |
484 | // --------------------- | |
485 | ||
486 | virtual bool CanDrawBitmap() const = 0; | |
487 | virtual bool CanGetTextExtent() const = 0; | |
488 | ||
489 | // colour depth | |
490 | virtual int GetDepth() const = 0; | |
491 | ||
492 | // Resolution in Pixels per inch | |
493 | virtual wxSize GetPPI() const = 0; | |
494 | ||
b7cacb43 VZ |
495 | virtual bool Ok() const { return IsOk(); } |
496 | virtual bool IsOk() const { return m_ok; } | |
a23fd0e1 | 497 | |
2439f37a VZ |
498 | // accessors and setters |
499 | // --------------------- | |
a23fd0e1 | 500 | |
2e992e06 VZ |
501 | virtual int GetBackgroundMode() const { return m_backgroundMode; } |
502 | virtual const wxBrush& GetBackground() const { return m_backgroundBrush; } | |
503 | virtual const wxBrush& GetBrush() const { return m_brush; } | |
504 | virtual const wxFont& GetFont() const { return m_font; } | |
505 | virtual const wxPen& GetPen() const { return m_pen; } | |
a23fd0e1 | 506 | |
2e992e06 VZ |
507 | virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; } |
508 | virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; } | |
a23fd0e1 VZ |
509 | virtual void SetTextForeground(const wxColour& colour) |
510 | { m_textForegroundColour = colour; } | |
511 | virtual void SetTextBackground(const wxColour& colour) | |
512 | { m_textBackgroundColour = colour; } | |
513 | ||
04ab8b6d RR |
514 | |
515 | // coordinates conversions and transforms | |
516 | // -------------------------------------- | |
517 | ||
518 | virtual wxCoord DeviceToLogicalX(wxCoord x) const; | |
519 | virtual wxCoord DeviceToLogicalY(wxCoord y) const; | |
520 | virtual wxCoord DeviceToLogicalXRel(wxCoord x) const; | |
521 | virtual wxCoord DeviceToLogicalYRel(wxCoord y) const; | |
522 | virtual wxCoord LogicalToDeviceX(wxCoord x) const; | |
523 | virtual wxCoord LogicalToDeviceY(wxCoord y) const; | |
524 | virtual wxCoord LogicalToDeviceXRel(wxCoord x) const; | |
525 | virtual wxCoord LogicalToDeviceYRel(wxCoord y) const; | |
526 | ||
527 | virtual void SetMapMode(int mode); | |
2e992e06 | 528 | virtual int GetMapMode() const { return m_mappingMode; } |
a23fd0e1 | 529 | |
04ab8b6d | 530 | virtual void SetUserScale(double x, double y); |
a23fd0e1 VZ |
531 | virtual void GetUserScale(double *x, double *y) const |
532 | { | |
533 | if ( x ) *x = m_userScaleX; | |
534 | if ( y ) *y = m_userScaleY; | |
535 | } | |
a23fd0e1 | 536 | |
04ab8b6d | 537 | virtual void SetLogicalScale(double x, double y); |
a23fd0e1 VZ |
538 | virtual void GetLogicalScale(double *x, double *y) |
539 | { | |
540 | if ( x ) *x = m_logicalScaleX; | |
541 | if ( y ) *y = m_logicalScaleY; | |
542 | } | |
a23fd0e1 | 543 | |
04ab8b6d | 544 | virtual void SetLogicalOrigin(wxCoord x, wxCoord y); |
72cdf4c9 | 545 | void GetLogicalOrigin(wxCoord *x, wxCoord *y) const |
a23fd0e1 VZ |
546 | { DoGetLogicalOrigin(x, y); } |
547 | wxPoint GetLogicalOrigin() const | |
72cdf4c9 | 548 | { wxCoord x, y; DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); } |
a23fd0e1 | 549 | |
04ab8b6d | 550 | virtual void SetDeviceOrigin(wxCoord x, wxCoord y); |
72cdf4c9 | 551 | void GetDeviceOrigin(wxCoord *x, wxCoord *y) const |
a23fd0e1 VZ |
552 | { DoGetDeviceOrigin(x, y); } |
553 | wxPoint GetDeviceOrigin() const | |
72cdf4c9 | 554 | { wxCoord x, y; DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); } |
04ab8b6d RR |
555 | |
556 | virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y ); | |
a23fd0e1 | 557 | |
04ab8b6d | 558 | virtual void ComputeScaleAndOrigin(); |
b1263dcf | 559 | |
04ab8b6d RR |
560 | // this needs to overidden if the axis is inverted (such |
561 | // as when using Postscript, where 0,0 is the lower left | |
562 | // corner, not the upper left). | |
563 | virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
a23fd0e1 | 564 | |
04ab8b6d RR |
565 | // logical functions |
566 | // --------------------------- | |
567 | ||
2e992e06 | 568 | virtual int GetLogicalFunction() const { return m_logicalFunction; } |
a23fd0e1 VZ |
569 | virtual void SetLogicalFunction(int function) = 0; |
570 | ||
a23fd0e1 VZ |
571 | // bounding box |
572 | // ------------ | |
573 | ||
72cdf4c9 | 574 | virtual void CalcBoundingBox(wxCoord x, wxCoord y) |
a23fd0e1 | 575 | { |
f6bcfd97 BP |
576 | if ( m_isBBoxValid ) |
577 | { | |
578 | if ( x < m_minX ) m_minX = x; | |
579 | if ( y < m_minY ) m_minY = y; | |
580 | if ( x > m_maxX ) m_maxX = x; | |
581 | if ( y > m_maxY ) m_maxY = y; | |
582 | } | |
583 | else | |
584 | { | |
68379eaf | 585 | m_isBBoxValid = true; |
f6bcfd97 BP |
586 | |
587 | m_minX = x; | |
588 | m_minY = y; | |
589 | m_maxX = x; | |
590 | m_maxY = y; | |
591 | } | |
592 | } | |
593 | ||
594 | void ResetBoundingBox() | |
595 | { | |
68379eaf | 596 | m_isBBoxValid = false; |
f6bcfd97 BP |
597 | |
598 | m_minX = m_maxX = m_minY = m_maxY = 0; | |
a23fd0e1 VZ |
599 | } |
600 | ||
601 | // Get the final bounding box of the PostScript or Metafile picture. | |
72cdf4c9 VZ |
602 | wxCoord MinX() const { return m_minX; } |
603 | wxCoord MaxX() const { return m_maxX; } | |
604 | wxCoord MinY() const { return m_minY; } | |
605 | wxCoord MaxY() const { return m_maxY; } | |
a23fd0e1 VZ |
606 | |
607 | // misc old functions | |
608 | // ------------------ | |
609 | ||
ad973712 | 610 | #if WXWIN_COMPATIBILITY_2_8 |
72cdf4c9 | 611 | // for compatibility with the old code when wxCoord was long everywhere |
72cdf4c9 VZ |
612 | void GetTextExtent(const wxString& string, |
613 | long *x, long *y, | |
614 | long *descent = NULL, | |
615 | long *externalLeading = NULL, | |
c94f845b | 616 | const wxFont *theFont = NULL) const |
72cdf4c9 VZ |
617 | { |
618 | wxCoord x2, y2, descent2, externalLeading2; | |
619 | DoGetTextExtent(string, &x2, &y2, | |
620 | &descent2, &externalLeading2, | |
621 | theFont); | |
622 | if ( x ) | |
623 | *x = x2; | |
624 | if ( y ) | |
625 | *y = y2; | |
626 | if ( descent ) | |
627 | *descent = descent2; | |
628 | if ( externalLeading ) | |
629 | *externalLeading = externalLeading2; | |
630 | } | |
631 | ||
632 | void GetLogicalOrigin(long *x, long *y) const | |
633 | { | |
634 | wxCoord x2, y2; | |
635 | DoGetLogicalOrigin(&x2, &y2); | |
636 | if ( x ) | |
637 | *x = x2; | |
638 | if ( y ) | |
639 | *y = y2; | |
640 | } | |
641 | ||
642 | void GetDeviceOrigin(long *x, long *y) const | |
643 | { | |
644 | wxCoord x2, y2; | |
645 | DoGetDeviceOrigin(&x2, &y2); | |
646 | if ( x ) | |
647 | *x = x2; | |
648 | if ( y ) | |
649 | *y = y2; | |
650 | } | |
1dd989e1 | 651 | void GetClippingBox(long *x, long *y, long *w, long *h) const |
cd9da200 VZ |
652 | { |
653 | wxCoord xx,yy,ww,hh; | |
654 | DoGetClippingBox(&xx, &yy, &ww, &hh); | |
655 | if (x) *x = xx; | |
656 | if (y) *y = yy; | |
657 | if (w) *w = ww; | |
658 | if (h) *h = hh; | |
1dd989e1 | 659 | } |
ad973712 | 660 | #endif // WXWIN_COMPATIBILITY_2_8 |
72cdf4c9 | 661 | |
6ae7410f VZ |
662 | // RTL related functions |
663 | // --------------------- | |
664 | ||
665 | // get or change the layout direction (LTR or RTL) for this dc, | |
666 | // wxLayout_Default is returned if layout direction is not supported | |
667 | virtual wxLayoutDirection GetLayoutDirection() const | |
668 | { return wxLayout_Default; } | |
669 | virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) | |
670 | { } | |
671 | ||
a23fd0e1 VZ |
672 | protected: |
673 | // the pure virtual functions which should be implemented by wxDC | |
387ebd3e | 674 | virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, |
a23fd0e1 VZ |
675 | int style = wxFLOOD_SURFACE) = 0; |
676 | ||
213ad8e7 VZ |
677 | virtual void DoGradientFillLinear(const wxRect& rect, |
678 | const wxColour& initialColour, | |
679 | const wxColour& destColour, | |
680 | wxDirection nDirection = wxEAST); | |
4660e6ac | 681 | |
fb63a242 SC |
682 | virtual void DoGradientFillConcentric(const wxRect& rect, |
683 | const wxColour& initialColour, | |
684 | const wxColour& destColour, | |
685 | const wxPoint& circleCenter); | |
686 | ||
72cdf4c9 | 687 | virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0; |
a23fd0e1 | 688 | |
72cdf4c9 VZ |
689 | virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0; |
690 | virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0; | |
a23fd0e1 | 691 | |
72cdf4c9 VZ |
692 | virtual void DoDrawArc(wxCoord x1, wxCoord y1, |
693 | wxCoord x2, wxCoord y2, | |
694 | wxCoord xc, wxCoord yc) = 0; | |
cd9da200 VZ |
695 | virtual void DoDrawCheckMark(wxCoord x, wxCoord y, |
696 | wxCoord width, wxCoord height); | |
72cdf4c9 | 697 | virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, |
a23fd0e1 VZ |
698 | double sa, double ea) = 0; |
699 | ||
72cdf4c9 VZ |
700 | virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0; |
701 | virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, | |
702 | wxCoord width, wxCoord height, | |
a23fd0e1 | 703 | double radius) = 0; |
72cdf4c9 VZ |
704 | virtual void DoDrawEllipse(wxCoord x, wxCoord y, |
705 | wxCoord width, wxCoord height) = 0; | |
a23fd0e1 | 706 | |
72cdf4c9 | 707 | virtual void DoCrossHair(wxCoord x, wxCoord y) = 0; |
a23fd0e1 | 708 | |
72cdf4c9 VZ |
709 | virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0; |
710 | virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
68379eaf | 711 | bool useMask = false) = 0; |
a23fd0e1 | 712 | |
72cdf4c9 | 713 | virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0; |
95724b1a VZ |
714 | virtual void DoDrawRotatedText(const wxString& text, |
715 | wxCoord x, wxCoord y, double angle) = 0; | |
a23fd0e1 | 716 | |
72cdf4c9 VZ |
717 | virtual bool DoBlit(wxCoord xdest, wxCoord ydest, |
718 | wxCoord width, wxCoord height, | |
e3b81044 VZ |
719 | wxDC *source, |
720 | wxCoord xsrc, wxCoord ysrc, | |
721 | int rop = wxCOPY, | |
722 | bool useMask = false, | |
723 | wxCoord xsrcMask = wxDefaultCoord, | |
724 | wxCoord ysrcMask = wxDefaultCoord) = 0; | |
725 | ||
726 | virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest, | |
727 | wxCoord dstWidth, wxCoord dstHeight, | |
728 | wxDC *source, | |
729 | wxCoord xsrc, wxCoord ysrc, | |
730 | wxCoord srcWidth, wxCoord srcHeight, | |
731 | int rop = wxCOPY, | |
732 | bool useMask = false, | |
733 | wxCoord xsrcMask = wxDefaultCoord, | |
734 | wxCoord ysrcMask = wxDefaultCoord); | |
735 | ||
736 | virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const | |
737 | { return wxNullBitmap; } | |
c64c9cd3 | 738 | |
a23fd0e1 VZ |
739 | virtual void DoGetSize(int *width, int *height) const = 0; |
740 | virtual void DoGetSizeMM(int* width, int* height) const = 0; | |
741 | ||
742 | virtual void DoDrawLines(int n, wxPoint points[], | |
72cdf4c9 | 743 | wxCoord xoffset, wxCoord yoffset) = 0; |
a23fd0e1 | 744 | virtual void DoDrawPolygon(int n, wxPoint points[], |
72cdf4c9 | 745 | wxCoord xoffset, wxCoord yoffset, |
a23fd0e1 | 746 | int fillStyle = wxODDEVEN_RULE) = 0; |
793db755 | 747 | virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[], |
6e76b35d VZ |
748 | wxCoord xoffset, wxCoord yoffset, |
749 | int fillStyle); | |
a23fd0e1 VZ |
750 | |
751 | virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0; | |
72cdf4c9 VZ |
752 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, |
753 | wxCoord width, wxCoord height) = 0; | |
b0e0d661 | 754 | |
72cdf4c9 VZ |
755 | virtual void DoGetClippingBox(wxCoord *x, wxCoord *y, |
756 | wxCoord *w, wxCoord *h) const | |
a23fd0e1 | 757 | { |
d16b634f VZ |
758 | if ( x ) |
759 | *x = m_clipX1; | |
760 | if ( y ) | |
761 | *y = m_clipY1; | |
762 | if ( w ) | |
763 | *w = m_clipX2 - m_clipX1; | |
764 | if ( h ) | |
765 | *h = m_clipY2 - m_clipY1; | |
a23fd0e1 VZ |
766 | } |
767 | ||
72cdf4c9 | 768 | virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const |
a23fd0e1 VZ |
769 | { |
770 | if ( x ) *x = m_logicalOriginX; | |
771 | if ( y ) *y = m_logicalOriginY; | |
772 | } | |
773 | ||
72cdf4c9 | 774 | virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const |
a23fd0e1 VZ |
775 | { |
776 | if ( x ) *x = m_deviceOriginX; | |
777 | if ( y ) *y = m_deviceOriginY; | |
778 | } | |
779 | ||
72cdf4c9 VZ |
780 | virtual void DoGetTextExtent(const wxString& string, |
781 | wxCoord *x, wxCoord *y, | |
782 | wxCoord *descent = NULL, | |
783 | wxCoord *externalLeading = NULL, | |
c94f845b | 784 | const wxFont *theFont = NULL) const = 0; |
d16b634f | 785 | |
0919e93e | 786 | virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const; |
d16b634f | 787 | |
64698f9a | 788 | #if wxUSE_SPLINES |
fe2e4366 | 789 | virtual void DoDrawSpline(wxList *points); |
64698f9a | 790 | #endif |
a23fd0e1 VZ |
791 | |
792 | protected: | |
d16b634f VZ |
793 | // unset clipping variables (after clipping region was destroyed) |
794 | void ResetClipping() | |
795 | { | |
796 | m_clipping = false; | |
797 | ||
798 | m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0; | |
799 | } | |
800 | ||
a23fd0e1 VZ |
801 | // flags |
802 | bool m_colour:1; | |
803 | bool m_ok:1; | |
804 | bool m_clipping:1; | |
805 | bool m_isInteractive:1; | |
f6bcfd97 | 806 | bool m_isBBoxValid:1; |
a23fd0e1 VZ |
807 | |
808 | // coordinate system variables | |
809 | ||
810 | // TODO short descriptions of what exactly they are would be nice... | |
811 | ||
72cdf4c9 | 812 | wxCoord m_logicalOriginX, m_logicalOriginY; |
04ab8b6d RR |
813 | wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user |
814 | ||
815 | wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner | |
816 | // is not at 0,0. This was the case under | |
817 | // Mac's GrafPorts (coordinate system | |
818 | // used toplevel window's origin) and | |
819 | // e.g. for Postscript, where the native | |
820 | // origin in the bottom left corner. | |
a23fd0e1 VZ |
821 | double m_logicalScaleX, m_logicalScaleY; |
822 | double m_userScaleX, m_userScaleY; | |
04ab8b6d | 823 | double m_scaleX, m_scaleY; // calculated from logical scale and user scale |
a23fd0e1 VZ |
824 | |
825 | // Used by SetAxisOrientation() to invert the axes | |
826 | int m_signX, m_signY; | |
827 | ||
04ab8b6d RR |
828 | // what is a mm on a screen you don't know the size of? |
829 | double m_mm_to_pix_x, | |
830 | m_mm_to_pix_y; | |
831 | ||
a23fd0e1 | 832 | // bounding and clipping boxes |
72cdf4c9 VZ |
833 | wxCoord m_minX, m_minY, m_maxX, m_maxY; |
834 | wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2; | |
a23fd0e1 VZ |
835 | |
836 | int m_logicalFunction; | |
837 | int m_backgroundMode; | |
838 | int m_mappingMode; | |
839 | ||
840 | // GDI objects | |
841 | wxPen m_pen; | |
842 | wxBrush m_brush; | |
843 | wxBrush m_backgroundBrush; | |
844 | wxColour m_textForegroundColour; | |
845 | wxColour m_textBackgroundColour; | |
846 | wxFont m_font; | |
d275c7eb VZ |
847 | |
848 | #if wxUSE_PALETTE | |
a23fd0e1 | 849 | wxPalette m_palette; |
b95edd47 | 850 | bool m_hasCustomPalette; |
d275c7eb | 851 | #endif // wxUSE_PALETTE |
a23fd0e1 VZ |
852 | |
853 | private: | |
ac84e37d | 854 | DECLARE_NO_COPY_CLASS(wxDCBase) |
cd9da200 | 855 | DECLARE_ABSTRACT_CLASS(wxDCBase) |
a23fd0e1 VZ |
856 | }; |
857 | ||
858 | // ---------------------------------------------------------------------------- | |
859 | // now include the declaration of wxDC class | |
860 | // ---------------------------------------------------------------------------- | |
861 | ||
4055ed82 | 862 | #if defined(__WXPALMOS__) |
ffecfa5a JS |
863 | #include "wx/palmos/dc.h" |
864 | #elif defined(__WXMSW__) | |
a23fd0e1 | 865 | #include "wx/msw/dc.h" |
2049ba38 | 866 | #elif defined(__WXMOTIF__) |
a23fd0e1 | 867 | #include "wx/motif/dc.h" |
1be7a35c | 868 | #elif defined(__WXGTK20__) |
a23fd0e1 | 869 | #include "wx/gtk/dc.h" |
1be7a35c MR |
870 | #elif defined(__WXGTK__) |
871 | #include "wx/gtk1/dc.h" | |
83df96d6 JS |
872 | #elif defined(__WXX11__) |
873 | #include "wx/x11/dc.h" | |
1e6feb95 VZ |
874 | #elif defined(__WXMGL__) |
875 | #include "wx/mgl/dc.h" | |
b3c86150 VS |
876 | #elif defined(__WXDFB__) |
877 | #include "wx/dfb/dc.h" | |
34138703 | 878 | #elif defined(__WXMAC__) |
a23fd0e1 | 879 | #include "wx/mac/dc.h" |
f4515f98 DE |
880 | #elif defined(__WXCOCOA__) |
881 | #include "wx/cocoa/dc.h" | |
1777b9bb DW |
882 | #elif defined(__WXPM__) |
883 | #include "wx/os2/dc.h" | |
c801d85f KB |
884 | #endif |
885 | ||
8acd14d1 SC |
886 | #if wxUSE_GRAPHICS_CONTEXT |
887 | #include "wx/dcgraph.h" | |
888 | #endif | |
889 | ||
1e6feb95 VZ |
890 | // ---------------------------------------------------------------------------- |
891 | // helper class: you can use it to temporarily change the DC text colour and | |
892 | // restore it automatically when the object goes out of scope | |
893 | // ---------------------------------------------------------------------------- | |
894 | ||
895 | class WXDLLEXPORT wxDCTextColourChanger | |
896 | { | |
897 | public: | |
ba161d7e | 898 | wxDCTextColourChanger(wxDC& dc) : m_dc(dc), m_colFgOld() { } |
1e6feb95 | 899 | |
1b97b23d VS |
900 | wxDCTextColourChanger(wxDC& dc, const wxColour& col) : m_dc(dc) |
901 | { | |
902 | Set(col); | |
903 | } | |
904 | ||
1e6feb95 VZ |
905 | ~wxDCTextColourChanger() |
906 | { | |
907 | if ( m_colFgOld.Ok() ) | |
908 | m_dc.SetTextForeground(m_colFgOld); | |
909 | } | |
910 | ||
911 | void Set(const wxColour& col) | |
912 | { | |
913 | if ( !m_colFgOld.Ok() ) | |
914 | m_colFgOld = m_dc.GetTextForeground(); | |
915 | m_dc.SetTextForeground(col); | |
916 | } | |
917 | ||
918 | private: | |
919 | wxDC& m_dc; | |
920 | ||
921 | wxColour m_colFgOld; | |
fc7a2a60 VZ |
922 | |
923 | DECLARE_NO_COPY_CLASS(wxDCTextColourChanger) | |
1e6feb95 VZ |
924 | }; |
925 | ||
4660e6ac WS |
926 | // ---------------------------------------------------------------------------- |
927 | // helper class: you can use it to temporarily change the DC pen and | |
928 | // restore it automatically when the object goes out of scope | |
929 | // ---------------------------------------------------------------------------- | |
930 | ||
931 | class WXDLLEXPORT wxDCPenChanger | |
932 | { | |
933 | public: | |
0164f8eb WS |
934 | wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen()) |
935 | { | |
936 | m_dc.SetPen(pen); | |
937 | } | |
4660e6ac WS |
938 | |
939 | ~wxDCPenChanger() | |
940 | { | |
941 | if ( m_penOld.Ok() ) | |
942 | m_dc.SetPen(m_penOld); | |
943 | } | |
944 | ||
4660e6ac WS |
945 | private: |
946 | wxDC& m_dc; | |
947 | ||
948 | wxPen m_penOld; | |
949 | ||
950 | DECLARE_NO_COPY_CLASS(wxDCPenChanger) | |
951 | }; | |
952 | ||
953 | // ---------------------------------------------------------------------------- | |
954 | // helper class: you can use it to temporarily change the DC brush and | |
955 | // restore it automatically when the object goes out of scope | |
956 | // ---------------------------------------------------------------------------- | |
957 | ||
958 | class WXDLLEXPORT wxDCBrushChanger | |
959 | { | |
960 | public: | |
0164f8eb WS |
961 | wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush()) |
962 | { | |
963 | m_dc.SetBrush(brush); | |
964 | } | |
4660e6ac WS |
965 | |
966 | ~wxDCBrushChanger() | |
967 | { | |
968 | if ( m_brushOld.Ok() ) | |
969 | m_dc.SetBrush(m_brushOld); | |
970 | } | |
971 | ||
4660e6ac WS |
972 | private: |
973 | wxDC& m_dc; | |
974 | ||
975 | wxBrush m_brushOld; | |
976 | ||
977 | DECLARE_NO_COPY_CLASS(wxDCBrushChanger) | |
978 | }; | |
979 | ||
e26be42b VZ |
980 | // ---------------------------------------------------------------------------- |
981 | // another small helper class: sets the clipping region in its ctor and | |
982 | // destroys it in the dtor | |
983 | // ---------------------------------------------------------------------------- | |
984 | ||
985 | class WXDLLEXPORT wxDCClipper | |
986 | { | |
987 | public: | |
fc298ea7 VZ |
988 | wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc) |
989 | { dc.SetClippingRegion(r); } | |
e26be42b VZ |
990 | wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc) |
991 | { dc.SetClippingRegion(r.x, r.y, r.width, r.height); } | |
992 | wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc) | |
993 | { dc.SetClippingRegion(x, y, w, h); } | |
994 | ||
995 | ~wxDCClipper() { m_dc.DestroyClippingRegion(); } | |
996 | ||
997 | private: | |
998 | wxDC& m_dc; | |
fc7a2a60 VZ |
999 | |
1000 | DECLARE_NO_COPY_CLASS(wxDCClipper) | |
e26be42b VZ |
1001 | }; |
1002 | ||
8b56b16a | 1003 | #endif // _WX_DC_H_BASE_ |