]>
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" | |
0919e93e | 29 | #include "wx/dynarray.h" |
19edb09c | 30 | #include "wx/math.h" |
02255e07 | 31 | #include "wx/image.h" |
888dde65 | 32 | #include "wx/cmndata.h" |
a23fd0e1 | 33 | |
888dde65 | 34 | #define wxUSE_NEW_DC 1 |
2970ae54 | 35 | |
ca7db61e | 36 | class WXDLLIMPEXP_FWD_CORE wxDC; |
ab171e95 RR |
37 | class WXDLLIMPEXP_FWD_CORE wxClientDC; |
38 | class WXDLLIMPEXP_FWD_CORE wxPaintDC; | |
39 | class WXDLLIMPEXP_FWD_CORE wxWindowDC; | |
40 | class WXDLLIMPEXP_FWD_CORE wxScreenDC; | |
41 | class WXDLLIMPEXP_FWD_CORE wxMemoryDC; | |
c8ddadff | 42 | class WXDLLIMPEXP_FWD_CORE wxPrinterDC; |
477c48bf | 43 | class WXDLLIMPEXP_FWD_CORE wxPrintData; |
888dde65 RR |
44 | |
45 | //----------------------------------------------------------------------------- | |
46 | // wxDrawObject helper class | |
47 | //----------------------------------------------------------------------------- | |
ca7db61e RR |
48 | |
49 | class WXDLLEXPORT wxDrawObject | |
50 | { | |
51 | public: | |
52 | ||
53 | wxDrawObject() | |
54 | : m_isBBoxValid(false) | |
55 | , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0) | |
56 | { } | |
57 | ||
58 | virtual ~wxDrawObject() { } | |
59 | ||
ca7db61e | 60 | virtual void Draw(wxDC&) const { } |
ca7db61e RR |
61 | |
62 | virtual void CalcBoundingBox(wxCoord x, wxCoord y) | |
63 | { | |
64 | if ( m_isBBoxValid ) | |
65 | { | |
66 | if ( x < m_minX ) m_minX = x; | |
67 | if ( y < m_minY ) m_minY = y; | |
68 | if ( x > m_maxX ) m_maxX = x; | |
69 | if ( y > m_maxY ) m_maxY = y; | |
70 | } | |
71 | else | |
72 | { | |
73 | m_isBBoxValid = true; | |
74 | ||
75 | m_minX = x; | |
76 | m_minY = y; | |
77 | m_maxX = x; | |
78 | m_maxY = y; | |
79 | } | |
80 | } | |
81 | ||
82 | void ResetBoundingBox() | |
83 | { | |
84 | m_isBBoxValid = false; | |
85 | ||
86 | m_minX = m_maxX = m_minY = m_maxY = 0; | |
87 | } | |
88 | ||
89 | // Get the final bounding box of the PostScript or Metafile picture. | |
90 | ||
91 | wxCoord MinX() const { return m_minX; } | |
92 | wxCoord MaxX() const { return m_maxX; } | |
93 | wxCoord MinY() const { return m_minY; } | |
94 | wxCoord MaxY() const { return m_maxY; } | |
95 | ||
96 | //to define the type of object for derived objects | |
97 | virtual int GetType()=0; | |
98 | ||
99 | protected: | |
100 | //for boundingbox calculation | |
101 | bool m_isBBoxValid:1; | |
102 | //for boundingbox calculation | |
103 | wxCoord m_minX, m_minY, m_maxX, m_maxY; | |
104 | }; | |
105 | ||
106 | ||
2970ae54 RR |
107 | //----------------------------------------------------------------------------- |
108 | // wxDCFactory | |
109 | //----------------------------------------------------------------------------- | |
110 | ||
888dde65 | 111 | class WXDLLIMPEXP_FWD_CORE wxDCImpl; |
2970ae54 RR |
112 | |
113 | class WXDLLIMPEXP_CORE wxDCFactory | |
114 | { | |
115 | public: | |
116 | wxDCFactory() {} | |
117 | virtual ~wxDCFactory() {} | |
f0875501 | 118 | |
888dde65 RR |
119 | virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner ) = 0; |
120 | virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner, wxWindow *window ) = 0; | |
121 | virtual wxDCImpl* CreateClientDC( wxClientDC *owner ) = 0; | |
122 | virtual wxDCImpl* CreateClientDC( wxClientDC *owner, wxWindow *window ) = 0; | |
123 | virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner ) = 0; | |
124 | virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner, wxWindow *window ) = 0; | |
125 | virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner ) = 0; | |
126 | virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ) = 0; | |
127 | virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ) = 0; | |
128 | virtual wxDCImpl* CreateScreenDC( wxScreenDC *owner ) = 0; | |
6b4f4d47 | 129 | #if wxUSE_PRINTING_ARCHITECTURE |
888dde65 | 130 | virtual wxDCImpl* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ) = 0; |
6b4f4d47 | 131 | #endif |
f0875501 | 132 | |
f2498c4e | 133 | static void Set(wxDCFactory *factory); |
f0875501 VZ |
134 | static wxDCFactory *Get(); |
135 | ||
2970ae54 RR |
136 | private: |
137 | static wxDCFactory *m_factory; | |
138 | }; | |
139 | ||
140 | //----------------------------------------------------------------------------- | |
141 | // wxNativeDCFactory | |
142 | //----------------------------------------------------------------------------- | |
143 | ||
ab171e95 | 144 | class WXDLLIMPEXP_CORE wxNativeDCFactory: public wxDCFactory |
2970ae54 RR |
145 | { |
146 | public: | |
147 | wxNativeDCFactory() {} | |
f0875501 | 148 | |
888dde65 RR |
149 | virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner ); |
150 | virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner, wxWindow *window ); | |
151 | virtual wxDCImpl* CreateClientDC( wxClientDC *owner ); | |
152 | virtual wxDCImpl* CreateClientDC( wxClientDC *owner, wxWindow *window ); | |
153 | virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner ); | |
154 | virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner, wxWindow *window ); | |
155 | virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner ); | |
156 | virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ); | |
157 | virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ); | |
158 | virtual wxDCImpl* CreateScreenDC( wxScreenDC *owner ); | |
6b4f4d47 | 159 | #if wxUSE_PRINTING_ARCHITECTURE |
888dde65 | 160 | virtual wxDCImpl* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ); |
6b4f4d47 | 161 | #endif |
2970ae54 RR |
162 | }; |
163 | ||
2970ae54 | 164 | //----------------------------------------------------------------------------- |
888dde65 | 165 | // wxDCImpl |
2970ae54 RR |
166 | //----------------------------------------------------------------------------- |
167 | ||
888dde65 | 168 | class WXDLLIMPEXP_CORE wxDCImpl: public wxObject |
2970ae54 RR |
169 | { |
170 | public: | |
888dde65 RR |
171 | wxDCImpl( wxDC *owner ); |
172 | ~wxDCImpl(); | |
f0875501 | 173 | |
ab171e95 | 174 | wxDC *GetOwner() const { return m_owner; } |
f0875501 | 175 | |
888dde65 | 176 | wxWindow* GetWindow() const { return m_window; } |
f0875501 | 177 | |
2970ae54 RR |
178 | virtual bool IsOk() const { return m_ok; } |
179 | ||
180 | // query capabilities | |
181 | ||
182 | virtual bool CanDrawBitmap() const = 0; | |
183 | virtual bool CanGetTextExtent() const = 0; | |
184 | ||
185 | // query dimension, colour deps, resolution | |
186 | ||
187 | virtual void DoGetSize(int *width, int *height) const = 0; | |
4a624f6e VZ |
188 | void GetSize(int *width, int *height) const |
189 | { | |
190 | return DoGetSize(width, height); | |
191 | } | |
192 | ||
193 | wxSize GetSize() const | |
194 | { | |
195 | int w, h; | |
196 | DoGetSize(&w, &h); | |
197 | return wxSize(w, h); | |
198 | } | |
199 | ||
2970ae54 | 200 | virtual void DoGetSizeMM(int* width, int* height) const = 0; |
f0875501 | 201 | |
2970ae54 RR |
202 | virtual int GetDepth() const = 0; |
203 | virtual wxSize GetPPI() const = 0; | |
f0875501 | 204 | |
2970ae54 | 205 | // Right-To-Left (RTL) modes |
f0875501 | 206 | |
2970ae54 RR |
207 | virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) { } |
208 | virtual wxLayoutDirection GetLayoutDirection() const { return wxLayout_Default; } | |
f0875501 VZ |
209 | |
210 | // page and document | |
211 | ||
2970ae54 RR |
212 | virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; } |
213 | virtual void EndDoc() { } | |
214 | ||
215 | virtual void StartPage() { } | |
216 | virtual void EndPage() { } | |
217 | ||
cc18b1c7 SC |
218 | // flushing the content of this dc immediately eg onto screen |
219 | virtual void Flush() { } | |
220 | ||
2970ae54 RR |
221 | // bounding box |
222 | ||
ca7db61e | 223 | virtual void CalcBoundingBox(wxCoord x, wxCoord y) |
2970ae54 RR |
224 | { |
225 | if ( m_isBBoxValid ) | |
226 | { | |
227 | if ( x < m_minX ) m_minX = x; | |
228 | if ( y < m_minY ) m_minY = y; | |
229 | if ( x > m_maxX ) m_maxX = x; | |
230 | if ( y > m_maxY ) m_maxY = y; | |
231 | } | |
232 | else | |
233 | { | |
234 | m_isBBoxValid = true; | |
235 | ||
236 | m_minX = x; | |
237 | m_minY = y; | |
238 | m_maxX = x; | |
239 | m_maxY = y; | |
240 | } | |
241 | } | |
ca7db61e | 242 | void ResetBoundingBox() |
2970ae54 RR |
243 | { |
244 | m_isBBoxValid = false; | |
245 | ||
246 | m_minX = m_maxX = m_minY = m_maxY = 0; | |
247 | } | |
248 | ||
249 | wxCoord MinX() const { return m_minX; } | |
250 | wxCoord MaxX() const { return m_maxX; } | |
251 | wxCoord MinY() const { return m_minY; } | |
252 | wxCoord MaxY() const { return m_maxY; } | |
f0875501 | 253 | |
2970ae54 RR |
254 | // setters and getters |
255 | ||
256 | virtual void SetFont(const wxFont& font) = 0; | |
257 | virtual const wxFont& GetFont() const { return m_font; } | |
f0875501 | 258 | |
2970ae54 RR |
259 | virtual void SetPen(const wxPen& pen) = 0; |
260 | virtual const wxPen& GetPen() const { return m_pen; } | |
f0875501 | 261 | |
2970ae54 RR |
262 | virtual void SetBrush(const wxBrush& brush) = 0; |
263 | virtual const wxBrush& GetBrush() const { return m_brush; } | |
f0875501 | 264 | |
2970ae54 RR |
265 | virtual void SetBackground(const wxBrush& brush) = 0; |
266 | virtual const wxBrush& GetBackground() const { return m_backgroundBrush; } | |
f0875501 | 267 | |
2970ae54 RR |
268 | virtual void SetBackgroundMode(int mode) = 0; |
269 | virtual int GetBackgroundMode() const { return m_backgroundMode; } | |
270 | ||
271 | virtual void SetTextForeground(const wxColour& colour) | |
272 | { m_textForegroundColour = colour; } | |
273 | virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; } | |
f0875501 | 274 | |
2970ae54 RR |
275 | virtual void SetTextBackground(const wxColour& colour) |
276 | { m_textBackgroundColour = colour; } | |
277 | virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; } | |
278 | ||
279 | #if wxUSE_PALETTE | |
280 | virtual void SetPalette(const wxPalette& palette) = 0; | |
281 | #endif // wxUSE_PALETTE | |
282 | ||
283 | // logical functions | |
f0875501 | 284 | |
2970ae54 RR |
285 | virtual void SetLogicalFunction(int function) = 0; |
286 | virtual int GetLogicalFunction() const { return m_logicalFunction; } | |
287 | ||
288 | // text measurement | |
289 | ||
290 | virtual wxCoord GetCharHeight() const = 0; | |
291 | virtual wxCoord GetCharWidth() const = 0; | |
292 | virtual void DoGetTextExtent(const wxString& string, | |
293 | wxCoord *x, wxCoord *y, | |
294 | wxCoord *descent = NULL, | |
295 | wxCoord *externalLeading = NULL, | |
296 | const wxFont *theFont = NULL) const = 0; | |
297 | virtual void GetMultiLineTextExtent(const wxString& string, | |
298 | wxCoord *width, | |
299 | wxCoord *height, | |
300 | wxCoord *heightLine = NULL, | |
301 | const wxFont *font = NULL) const; | |
302 | virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const; | |
f0875501 | 303 | |
2970ae54 | 304 | // clearing |
f0875501 | 305 | |
2970ae54 RR |
306 | virtual void Clear() = 0; |
307 | ||
308 | // clipping | |
309 | ||
310 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, | |
311 | wxCoord width, wxCoord height) = 0; | |
312 | virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0; | |
313 | ||
314 | virtual void DoGetClippingBox(wxCoord *x, wxCoord *y, | |
315 | wxCoord *w, wxCoord *h) const | |
316 | { | |
317 | if ( x ) | |
318 | *x = m_clipX1; | |
319 | if ( y ) | |
320 | *y = m_clipY1; | |
321 | if ( w ) | |
322 | *w = m_clipX2 - m_clipX1; | |
323 | if ( h ) | |
324 | *h = m_clipY2 - m_clipY1; | |
325 | } | |
326 | ||
327 | virtual void DestroyClippingRegion() { ResetClipping(); } | |
328 | ||
329 | ||
330 | // coordinates conversions and transforms | |
331 | ||
332 | virtual wxCoord DeviceToLogicalX(wxCoord x) const; | |
333 | virtual wxCoord DeviceToLogicalY(wxCoord y) const; | |
334 | virtual wxCoord DeviceToLogicalXRel(wxCoord x) const; | |
335 | virtual wxCoord DeviceToLogicalYRel(wxCoord y) const; | |
336 | virtual wxCoord LogicalToDeviceX(wxCoord x) const; | |
337 | virtual wxCoord LogicalToDeviceY(wxCoord y) const; | |
338 | virtual wxCoord LogicalToDeviceXRel(wxCoord x) const; | |
339 | virtual wxCoord LogicalToDeviceYRel(wxCoord y) const; | |
340 | ||
341 | virtual void SetMapMode(int mode); | |
342 | virtual int GetMapMode() const { return m_mappingMode; } | |
343 | ||
344 | virtual void SetUserScale(double x, double y); | |
345 | virtual void GetUserScale(double *x, double *y) const | |
346 | { | |
347 | if ( x ) *x = m_userScaleX; | |
348 | if ( y ) *y = m_userScaleY; | |
349 | } | |
350 | ||
351 | virtual void SetLogicalScale(double x, double y); | |
352 | virtual void GetLogicalScale(double *x, double *y) | |
353 | { | |
354 | if ( x ) *x = m_logicalScaleX; | |
355 | if ( y ) *y = m_logicalScaleY; | |
356 | } | |
357 | ||
358 | virtual void SetLogicalOrigin(wxCoord x, wxCoord y); | |
359 | virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const | |
360 | { | |
361 | if ( x ) *x = m_logicalOriginX; | |
362 | if ( y ) *y = m_logicalOriginY; | |
363 | } | |
364 | ||
365 | virtual void SetDeviceOrigin(wxCoord x, wxCoord y); | |
366 | virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const | |
367 | { | |
368 | if ( x ) *x = m_deviceOriginX; | |
369 | if ( y ) *y = m_deviceOriginY; | |
370 | } | |
f0875501 | 371 | |
2970ae54 RR |
372 | virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y ); |
373 | ||
374 | virtual void ComputeScaleAndOrigin(); | |
375 | ||
376 | // this needs to overidden if the axis is inverted | |
377 | virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
378 | ||
379 | // --------------------------------------------------------- | |
380 | // the actual drawing API | |
381 | ||
382 | virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, | |
383 | int style = wxFLOOD_SURFACE) = 0; | |
384 | ||
385 | virtual void DoGradientFillLinear(const wxRect& rect, | |
386 | const wxColour& initialColour, | |
387 | const wxColour& destColour, | |
388 | wxDirection nDirection = wxEAST); | |
389 | ||
390 | virtual void DoGradientFillConcentric(const wxRect& rect, | |
391 | const wxColour& initialColour, | |
392 | const wxColour& destColour, | |
393 | const wxPoint& circleCenter); | |
394 | ||
395 | virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0; | |
396 | ||
397 | virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0; | |
398 | virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0; | |
399 | ||
400 | virtual void DoDrawArc(wxCoord x1, wxCoord y1, | |
401 | wxCoord x2, wxCoord y2, | |
402 | wxCoord xc, wxCoord yc) = 0; | |
403 | virtual void DoDrawCheckMark(wxCoord x, wxCoord y, | |
404 | wxCoord width, wxCoord height); | |
405 | virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, | |
406 | double sa, double ea) = 0; | |
407 | ||
408 | virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0; | |
409 | virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, | |
410 | wxCoord width, wxCoord height, | |
411 | double radius) = 0; | |
412 | virtual void DoDrawEllipse(wxCoord x, wxCoord y, | |
413 | wxCoord width, wxCoord height) = 0; | |
414 | ||
415 | virtual void DoCrossHair(wxCoord x, wxCoord y) = 0; | |
416 | ||
417 | virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0; | |
418 | virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
419 | bool useMask = false) = 0; | |
420 | ||
421 | virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0; | |
422 | virtual void DoDrawRotatedText(const wxString& text, | |
423 | wxCoord x, wxCoord y, double angle) = 0; | |
424 | ||
425 | virtual bool DoBlit(wxCoord xdest, wxCoord ydest, | |
426 | wxCoord width, wxCoord height, | |
427 | wxDC *source, | |
428 | wxCoord xsrc, wxCoord ysrc, | |
429 | int rop = wxCOPY, | |
430 | bool useMask = false, | |
431 | wxCoord xsrcMask = wxDefaultCoord, | |
432 | wxCoord ysrcMask = wxDefaultCoord) = 0; | |
433 | ||
434 | virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest, | |
435 | wxCoord dstWidth, wxCoord dstHeight, | |
436 | wxDC *source, | |
437 | wxCoord xsrc, wxCoord ysrc, | |
438 | wxCoord srcWidth, wxCoord srcHeight, | |
439 | int rop = wxCOPY, | |
440 | bool useMask = false, | |
441 | wxCoord xsrcMask = wxDefaultCoord, | |
442 | wxCoord ysrcMask = wxDefaultCoord); | |
443 | ||
444 | virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const | |
445 | { return wxNullBitmap; } | |
446 | ||
447 | ||
448 | virtual void DoDrawLines(int n, wxPoint points[], | |
4f37154e RR |
449 | wxCoord xoffset, wxCoord yoffset ) = 0; |
450 | virtual void DrawLines(const wxPointList *list, | |
451 | wxCoord xoffset, wxCoord yoffset ); | |
f0875501 | 452 | |
2970ae54 RR |
453 | virtual void DoDrawPolygon(int n, wxPoint points[], |
454 | wxCoord xoffset, wxCoord yoffset, | |
455 | int fillStyle = wxODDEVEN_RULE) = 0; | |
456 | virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[], | |
457 | wxCoord xoffset, wxCoord yoffset, | |
458 | int fillStyle); | |
4f37154e RR |
459 | void DrawPolygon(const wxPointList *list, |
460 | wxCoord xoffset, wxCoord yoffset, | |
461 | int fillStyle ); | |
2970ae54 RR |
462 | |
463 | ||
464 | #if wxUSE_SPLINES | |
ca7db61e RR |
465 | virtual void DoDrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3); |
466 | virtual void DoDrawSpline(int n, wxPoint points[]); | |
b0d7707b | 467 | virtual void DoDrawSpline(const wxPointList *points); |
2970ae54 | 468 | #endif |
f0875501 | 469 | |
4f37154e RR |
470 | // --------------------------------------------------------- |
471 | // wxMemoryDC Impl API | |
472 | ||
473 | virtual void DoSelect(const wxBitmap& WXUNUSED(bmp)) | |
474 | { } | |
f0875501 | 475 | |
4f37154e RR |
476 | virtual const wxBitmap& GetSelectedBitmap() const |
477 | { return wxNullBitmap; } | |
478 | virtual wxBitmap& GetSelectedBitmap() | |
479 | { return wxNullBitmap; } | |
f0875501 | 480 | |
4f37154e RR |
481 | // --------------------------------------------------------- |
482 | // wxPrinterDC Impl API | |
483 | ||
484 | virtual wxRect GetPaperRect() | |
485 | { int w = 0; int h = 0; DoGetSize( &w, &h ); return wxRect(0,0,w,h); } | |
f0875501 | 486 | |
4f37154e RR |
487 | virtual int GetResolution() |
488 | { return -1; } | |
489 | ||
2970ae54 | 490 | private: |
888dde65 | 491 | wxDC *m_owner; |
2970ae54 | 492 | |
f0875501 | 493 | protected: |
2970ae54 RR |
494 | // unset clipping variables (after clipping region was destroyed) |
495 | void ResetClipping() | |
496 | { | |
497 | m_clipping = false; | |
498 | ||
499 | m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0; | |
500 | } | |
501 | ||
888dde65 RR |
502 | // window on which the DC draws or NULL |
503 | wxWindow *m_window; | |
f0875501 | 504 | |
2970ae54 RR |
505 | // flags |
506 | bool m_colour:1; | |
507 | bool m_ok:1; | |
508 | bool m_clipping:1; | |
509 | bool m_isInteractive:1; | |
510 | bool m_isBBoxValid:1; | |
511 | ||
512 | // coordinate system variables | |
513 | ||
514 | wxCoord m_logicalOriginX, m_logicalOriginY; | |
515 | wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user | |
f0875501 | 516 | |
2970ae54 RR |
517 | wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner |
518 | // is not at 0,0. This was the case under | |
519 | // Mac's GrafPorts (coordinate system | |
520 | // used toplevel window's origin) and | |
521 | // e.g. for Postscript, where the native | |
522 | // origin in the bottom left corner. | |
523 | double m_logicalScaleX, m_logicalScaleY; | |
524 | double m_userScaleX, m_userScaleY; | |
525 | double m_scaleX, m_scaleY; // calculated from logical scale and user scale | |
526 | ||
527 | int m_signX, m_signY; // Used by SetAxisOrientation() to invert the axes | |
f0875501 | 528 | |
2970ae54 RR |
529 | // what is a mm on a screen you don't know the size of? |
530 | double m_mm_to_pix_x, | |
531 | m_mm_to_pix_y; | |
f0875501 | 532 | |
2970ae54 RR |
533 | // bounding and clipping boxes |
534 | wxCoord m_minX, m_minY, m_maxX, m_maxY; | |
535 | wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2; | |
536 | ||
537 | int m_logicalFunction; | |
538 | int m_backgroundMode; | |
539 | int m_mappingMode; | |
540 | ||
541 | wxPen m_pen; | |
542 | wxBrush m_brush; | |
543 | wxBrush m_backgroundBrush; | |
544 | wxColour m_textForegroundColour; | |
545 | wxColour m_textBackgroundColour; | |
546 | wxFont m_font; | |
547 | ||
548 | #if wxUSE_PALETTE | |
549 | wxPalette m_palette; | |
550 | bool m_hasCustomPalette; | |
551 | #endif // wxUSE_PALETTE | |
552 | ||
553 | private: | |
888dde65 | 554 | DECLARE_ABSTRACT_CLASS(wxDCImpl) |
ca7db61e | 555 | }; |
2970ae54 RR |
556 | |
557 | ||
f0875501 | 558 | class WXDLLIMPEXP_CORE wxDC : public wxObject |
2970ae54 RR |
559 | { |
560 | public: | |
f0875501 | 561 | virtual ~wxDC() { delete m_pimpl; } |
2970ae54 | 562 | |
888dde65 | 563 | wxDCImpl *GetImpl() |
ab171e95 | 564 | { return m_pimpl; } |
888dde65 | 565 | const wxDCImpl *GetImpl() const |
32043152 RR |
566 | { return m_pimpl; } |
567 | ||
888dde65 RR |
568 | wxWindow *GetWindow() |
569 | { return m_pimpl->GetWindow(); } | |
ab171e95 | 570 | |
f0875501 | 571 | bool IsOk() const |
2970ae54 RR |
572 | { return m_pimpl && m_pimpl->IsOk(); } |
573 | ||
574 | // query capabilities | |
575 | ||
f0875501 | 576 | bool CanDrawBitmap() const |
2970ae54 RR |
577 | { return m_pimpl->CanDrawBitmap(); } |
578 | bool CanGetTextExtent() const | |
579 | { return m_pimpl->CanGetTextExtent(); } | |
f0875501 | 580 | |
2970ae54 RR |
581 | // query dimension, colour deps, resolution |
582 | ||
583 | void GetSize(int *width, int *height) const | |
584 | { m_pimpl->DoGetSize(width, height); } | |
2970ae54 | 585 | wxSize GetSize() const |
4a624f6e | 586 | { return m_pimpl->GetSize(); } |
2970ae54 RR |
587 | |
588 | void GetSizeMM(int* width, int* height) const | |
589 | { m_pimpl->DoGetSizeMM(width, height); } | |
590 | wxSize GetSizeMM() const | |
591 | { | |
592 | int w, h; | |
593 | m_pimpl->DoGetSizeMM(&w, &h); | |
594 | return wxSize(w, h); | |
595 | } | |
f0875501 | 596 | |
2970ae54 RR |
597 | int GetDepth() const |
598 | { return m_pimpl->GetDepth(); } | |
599 | wxSize GetPPI() const | |
600 | { return m_pimpl->GetPPI(); } | |
601 | ||
4f37154e RR |
602 | virtual int GetResolution() |
603 | { return m_pimpl->GetResolution(); } | |
f0875501 | 604 | |
2970ae54 | 605 | // Right-To-Left (RTL) modes |
f0875501 | 606 | |
2970ae54 RR |
607 | void SetLayoutDirection(wxLayoutDirection dir) |
608 | { m_pimpl->SetLayoutDirection( dir ); } | |
609 | wxLayoutDirection GetLayoutDirection() const | |
610 | { return m_pimpl->GetLayoutDirection(); } | |
f0875501 VZ |
611 | |
612 | // page and document | |
613 | ||
2970ae54 RR |
614 | bool StartDoc(const wxString& message) |
615 | { return m_pimpl->StartDoc(message); } | |
616 | void EndDoc() | |
617 | { m_pimpl->EndDoc(); } | |
618 | ||
619 | void StartPage() | |
620 | { m_pimpl->StartPage(); } | |
621 | void EndPage() | |
622 | { m_pimpl->EndPage(); } | |
623 | ||
624 | // bounding box | |
f0875501 | 625 | |
2970ae54 RR |
626 | void CalcBoundingBox(wxCoord x, wxCoord y) |
627 | { m_pimpl->CalcBoundingBox(x,y); } | |
628 | void ResetBoundingBox() | |
629 | { m_pimpl->ResetBoundingBox(); } | |
f0875501 | 630 | |
2970ae54 RR |
631 | wxCoord MinX() const |
632 | { return m_pimpl->MinX(); } | |
633 | wxCoord MaxX() const | |
634 | { return m_pimpl->MaxX(); } | |
635 | wxCoord MinY() const | |
636 | { return m_pimpl->MinY(); } | |
637 | wxCoord MaxY() const | |
638 | { return m_pimpl->MaxY(); } | |
f0875501 | 639 | |
2970ae54 RR |
640 | // setters and getters |
641 | ||
642 | void SetFont(const wxFont& font) | |
643 | { m_pimpl->SetFont( font ); } | |
f0875501 | 644 | const wxFont& GetFont() const |
2970ae54 | 645 | { return m_pimpl->GetFont(); } |
f0875501 | 646 | |
2970ae54 RR |
647 | void SetPen(const wxPen& pen) |
648 | { m_pimpl->SetPen( pen ); } | |
f0875501 | 649 | const wxPen& GetPen() const |
2970ae54 | 650 | { return m_pimpl->GetPen(); } |
f0875501 | 651 | |
2970ae54 RR |
652 | void SetBrush(const wxBrush& brush) |
653 | { m_pimpl->SetBrush( brush ); } | |
654 | const wxBrush& GetBrush() const | |
655 | { return m_pimpl->GetBrush(); } | |
f0875501 | 656 | |
2970ae54 RR |
657 | void SetBackground(const wxBrush& brush) |
658 | { m_pimpl->SetBackground( brush ); } | |
659 | const wxBrush& GetBackground() const | |
660 | { return m_pimpl->GetBackground(); } | |
f0875501 | 661 | |
2970ae54 | 662 | void SetBackgroundMode(int mode) |
ca7db61e | 663 | { m_pimpl->SetBackgroundMode( mode ); } |
2970ae54 | 664 | int GetBackgroundMode() const |
ca7db61e | 665 | { return m_pimpl->GetBackgroundMode(); } |
2970ae54 RR |
666 | |
667 | void SetTextForeground(const wxColour& colour) | |
668 | { m_pimpl->SetTextForeground(colour); } | |
669 | const wxColour& GetTextForeground() const | |
670 | { return m_pimpl->GetTextForeground(); } | |
f0875501 | 671 | |
2970ae54 RR |
672 | void SetTextBackground(const wxColour& colour) |
673 | { m_pimpl->SetTextBackground(colour); } | |
f0875501 | 674 | const wxColour& GetTextBackground() const |
2970ae54 RR |
675 | { return m_pimpl->GetTextBackground(); } |
676 | ||
677 | #if wxUSE_PALETTE | |
678 | void SetPalette(const wxPalette& palette) | |
679 | { m_pimpl->SetPalette(palette); } | |
680 | #endif // wxUSE_PALETTE | |
f0875501 | 681 | |
2970ae54 | 682 | // logical functions |
f0875501 | 683 | |
2970ae54 RR |
684 | void SetLogicalFunction(int function) |
685 | { m_pimpl->SetLogicalFunction(function); } | |
686 | int GetLogicalFunction() const | |
687 | { return m_pimpl->GetLogicalFunction(); } | |
f0875501 | 688 | |
2970ae54 RR |
689 | // text measurement |
690 | ||
691 | wxCoord GetCharHeight() const | |
692 | { return m_pimpl->GetCharHeight(); } | |
693 | wxCoord GetCharWidth() const | |
694 | { return m_pimpl->GetCharWidth(); } | |
f0875501 | 695 | |
2970ae54 RR |
696 | void GetTextExtent(const wxString& string, |
697 | wxCoord *x, wxCoord *y, | |
698 | wxCoord *descent = NULL, | |
699 | wxCoord *externalLeading = NULL, | |
700 | const wxFont *theFont = NULL) const | |
701 | { m_pimpl->DoGetTextExtent(string, x, y, descent, externalLeading, theFont); } | |
702 | ||
703 | wxSize GetTextExtent(const wxString& string) const | |
704 | { | |
705 | wxCoord w, h; | |
706 | m_pimpl->DoGetTextExtent(string, &w, &h); | |
707 | return wxSize(w, h); | |
708 | } | |
f0875501 | 709 | |
2970ae54 RR |
710 | void GetMultiLineTextExtent(const wxString& string, |
711 | wxCoord *width, | |
712 | wxCoord *height, | |
713 | wxCoord *heightLine = NULL, | |
714 | const wxFont *font = NULL) const | |
715 | { m_pimpl->GetMultiLineTextExtent( string, width, height, heightLine, font ); } | |
f0875501 | 716 | |
2970ae54 RR |
717 | wxSize GetMultiLineTextExtent(const wxString& string) const |
718 | { | |
719 | wxCoord w, h; | |
720 | m_pimpl->GetMultiLineTextExtent(string, &w, &h); | |
721 | return wxSize(w, h); | |
722 | } | |
f0875501 | 723 | |
2970ae54 RR |
724 | bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const |
725 | { return m_pimpl->DoGetPartialTextExtents(text, widths); } | |
f0875501 | 726 | |
2970ae54 | 727 | // clearing |
f0875501 | 728 | |
2970ae54 RR |
729 | void Clear() |
730 | { m_pimpl->Clear(); } | |
731 | ||
732 | // clipping | |
733 | ||
734 | void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) | |
735 | { m_pimpl->DoSetClippingRegion(x, y, width, height); } | |
736 | void SetClippingRegion(const wxPoint& pt, const wxSize& sz) | |
737 | { m_pimpl->DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); } | |
738 | void SetClippingRegion(const wxRect& rect) | |
739 | { m_pimpl->DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); } | |
740 | void SetClippingRegion(const wxRegion& region) | |
741 | { m_pimpl->DoSetClippingRegionAsRegion(region); } | |
742 | ||
743 | void DestroyClippingRegion() | |
744 | { m_pimpl->DestroyClippingRegion(); } | |
745 | ||
746 | void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const | |
747 | { m_pimpl->DoGetClippingBox(x, y, w, h); } | |
748 | void GetClippingBox(wxRect& rect) const | |
749 | { m_pimpl->DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height); } | |
f0875501 | 750 | |
2970ae54 RR |
751 | // coordinates conversions and transforms |
752 | ||
753 | wxCoord DeviceToLogicalX(wxCoord x) const | |
754 | { return m_pimpl->DeviceToLogicalX(x); } | |
ca7db61e | 755 | wxCoord DeviceToLogicalY(wxCoord y) const |
2970ae54 | 756 | { return m_pimpl->DeviceToLogicalY(y); } |
ca7db61e | 757 | wxCoord DeviceToLogicalXRel(wxCoord x) const |
2970ae54 | 758 | { return m_pimpl->DeviceToLogicalXRel(x); } |
ca7db61e | 759 | wxCoord DeviceToLogicalYRel(wxCoord y) const |
2970ae54 | 760 | { return m_pimpl->DeviceToLogicalYRel(y); } |
ca7db61e | 761 | wxCoord LogicalToDeviceX(wxCoord x) const |
2970ae54 | 762 | { return m_pimpl->LogicalToDeviceX(x); } |
ca7db61e | 763 | wxCoord LogicalToDeviceY(wxCoord y) const |
2970ae54 | 764 | { return m_pimpl->LogicalToDeviceY(y); } |
ca7db61e | 765 | wxCoord LogicalToDeviceXRel(wxCoord x) const |
2970ae54 | 766 | { return m_pimpl->LogicalToDeviceXRel(x); } |
ca7db61e | 767 | wxCoord LogicalToDeviceYRel(wxCoord y) const |
2970ae54 RR |
768 | { return m_pimpl->LogicalToDeviceYRel(y); } |
769 | ||
770 | void SetMapMode(int mode) | |
771 | { m_pimpl->SetMapMode(mode); } | |
772 | int GetMapMode() const | |
773 | { return m_pimpl->GetMapMode(); } | |
774 | ||
775 | void SetUserScale(double x, double y) | |
776 | { m_pimpl->SetUserScale(x,y); } | |
777 | void GetUserScale(double *x, double *y) const | |
778 | { m_pimpl->GetUserScale( x, y ); } | |
779 | ||
780 | void SetLogicalScale(double x, double y) | |
781 | { m_pimpl->SetLogicalScale( x, y ); } | |
782 | void GetLogicalScale(double *x, double *y) | |
783 | { m_pimpl->GetLogicalScale( x, y ); } | |
784 | ||
785 | void SetLogicalOrigin(wxCoord x, wxCoord y) | |
786 | { m_pimpl->SetLogicalOrigin(x,y); } | |
787 | void GetLogicalOrigin(wxCoord *x, wxCoord *y) const | |
788 | { m_pimpl->DoGetLogicalOrigin(x, y); } | |
789 | wxPoint GetLogicalOrigin() const | |
790 | { wxCoord x, y; m_pimpl->DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); } | |
791 | ||
792 | void SetDeviceOrigin(wxCoord x, wxCoord y) | |
793 | { m_pimpl->SetDeviceOrigin( x, y); } | |
794 | void GetDeviceOrigin(wxCoord *x, wxCoord *y) const | |
795 | { m_pimpl->DoGetDeviceOrigin(x, y); } | |
796 | wxPoint GetDeviceOrigin() const | |
797 | { wxCoord x, y; m_pimpl->DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); } | |
798 | ||
799 | void SetAxisOrientation(bool xLeftRight, bool yBottomUp) | |
800 | { m_pimpl->SetAxisOrientation(xLeftRight, yBottomUp); } | |
f0875501 VZ |
801 | |
802 | // mostly internal | |
2970ae54 RR |
803 | void SetDeviceLocalOrigin( wxCoord x, wxCoord y ) |
804 | { m_pimpl->SetDeviceLocalOrigin( x, y ); } | |
805 | ||
806 | ||
807 | // draw generic object | |
808 | ||
809 | void DrawObject(wxDrawObject* drawobject) | |
810 | { | |
811 | drawobject->Draw(*this); | |
812 | CalcBoundingBox(drawobject->MinX(),drawobject->MinY()); | |
813 | CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY()); | |
814 | } | |
815 | ||
816 | // ----------------------------------------------- | |
817 | // the actual drawing API | |
818 | ||
819 | bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, | |
820 | int style = wxFLOOD_SURFACE) | |
821 | { return m_pimpl->DoFloodFill(x, y, col, style); } | |
822 | bool FloodFill(const wxPoint& pt, const wxColour& col, | |
823 | int style = wxFLOOD_SURFACE) | |
824 | { return m_pimpl->DoFloodFill(pt.x, pt.y, col, style); } | |
825 | ||
826 | // fill the area specified by rect with a radial gradient, starting from | |
827 | // initialColour in the centre of the cercle and fading to destColour. | |
828 | void GradientFillConcentric(const wxRect& rect, | |
829 | const wxColour& initialColour, | |
830 | const wxColour& destColour) | |
ca7db61e RR |
831 | { m_pimpl->DoGradientFillConcentric( rect, initialColour, destColour, |
832 | wxPoint(rect.GetWidth() / 2, | |
833 | rect.GetHeight() / 2)); } | |
2970ae54 RR |
834 | |
835 | void GradientFillConcentric(const wxRect& rect, | |
836 | const wxColour& initialColour, | |
837 | const wxColour& destColour, | |
838 | const wxPoint& circleCenter) | |
839 | { m_pimpl->DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); } | |
840 | ||
841 | // fill the area specified by rect with a linear gradient | |
842 | void GradientFillLinear(const wxRect& rect, | |
843 | const wxColour& initialColour, | |
844 | const wxColour& destColour, | |
845 | wxDirection nDirection = wxEAST) | |
846 | { m_pimpl->DoGradientFillLinear(rect, initialColour, destColour, nDirection); } | |
847 | ||
848 | bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const | |
849 | { return m_pimpl->DoGetPixel(x, y, col); } | |
850 | bool GetPixel(const wxPoint& pt, wxColour *col) const | |
851 | { return m_pimpl->DoGetPixel(pt.x, pt.y, col); } | |
852 | ||
853 | void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) | |
854 | { m_pimpl->DoDrawLine(x1, y1, x2, y2); } | |
855 | void DrawLine(const wxPoint& pt1, const wxPoint& pt2) | |
856 | { m_pimpl->DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); } | |
857 | ||
858 | void CrossHair(wxCoord x, wxCoord y) | |
859 | { m_pimpl->DoCrossHair(x, y); } | |
860 | void CrossHair(const wxPoint& pt) | |
861 | { m_pimpl->DoCrossHair(pt.x, pt.y); } | |
862 | ||
863 | void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, | |
864 | wxCoord xc, wxCoord yc) | |
865 | { m_pimpl->DoDrawArc(x1, y1, x2, y2, xc, yc); } | |
866 | void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre) | |
867 | { m_pimpl->DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); } | |
868 | ||
869 | void DrawCheckMark(wxCoord x, wxCoord y, | |
870 | wxCoord width, wxCoord height) | |
871 | { m_pimpl->DoDrawCheckMark(x, y, width, height); } | |
872 | void DrawCheckMark(const wxRect& rect) | |
873 | { m_pimpl->DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); } | |
874 | ||
875 | void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, | |
876 | double sa, double ea) | |
877 | { m_pimpl->DoDrawEllipticArc(x, y, w, h, sa, ea); } | |
878 | void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, | |
879 | double sa, double ea) | |
880 | { m_pimpl->DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); } | |
881 | ||
882 | void DrawPoint(wxCoord x, wxCoord y) | |
883 | { m_pimpl->DoDrawPoint(x, y); } | |
884 | void DrawPoint(const wxPoint& pt) | |
885 | { m_pimpl->DoDrawPoint(pt.x, pt.y); } | |
886 | ||
887 | void DrawLines(int n, wxPoint points[], | |
888 | wxCoord xoffset = 0, wxCoord yoffset = 0) | |
889 | { m_pimpl->DoDrawLines(n, points, xoffset, yoffset); } | |
b0d7707b | 890 | void DrawLines(const wxPointList *list, |
2970ae54 | 891 | wxCoord xoffset = 0, wxCoord yoffset = 0) |
f0875501 | 892 | { m_pimpl->DrawLines( list, xoffset, yoffset ); } |
4f37154e RR |
893 | #if WXWIN_COMPATIBILITY_2_8 |
894 | wxDEPRECATED( void DrawLines(const wxList *list, | |
895 | wxCoord xoffset = 0, wxCoord yoffset = 0) ); | |
896 | #endif // WXWIN_COMPATIBILITY_2_8 | |
2970ae54 RR |
897 | |
898 | void DrawPolygon(int n, wxPoint points[], | |
899 | wxCoord xoffset = 0, wxCoord yoffset = 0, | |
900 | int fillStyle = wxODDEVEN_RULE) | |
901 | { m_pimpl->DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); } | |
b0d7707b | 902 | void DrawPolygon(const wxPointList *list, |
2970ae54 RR |
903 | wxCoord xoffset = 0, wxCoord yoffset = 0, |
904 | int fillStyle = wxODDEVEN_RULE) | |
905 | { m_pimpl->DrawPolygon( list, xoffset, yoffset, fillStyle ); } | |
2970ae54 RR |
906 | void DrawPolyPolygon(int n, int count[], wxPoint points[], |
907 | wxCoord xoffset = 0, wxCoord yoffset = 0, | |
908 | int fillStyle = wxODDEVEN_RULE) | |
909 | { m_pimpl->DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); } | |
4f37154e RR |
910 | #if WXWIN_COMPATIBILITY_2_8 |
911 | wxDEPRECATED( void DrawPolygon(const wxList *list, | |
912 | wxCoord xoffset = 0, wxCoord yoffset = 0, | |
913 | int fillStyle = wxODDEVEN_RULE) ); | |
914 | #endif // WXWIN_COMPATIBILITY_2_8 | |
2970ae54 RR |
915 | |
916 | void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) | |
917 | { m_pimpl->DoDrawRectangle(x, y, width, height); } | |
918 | void DrawRectangle(const wxPoint& pt, const wxSize& sz) | |
919 | { m_pimpl->DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); } | |
920 | void DrawRectangle(const wxRect& rect) | |
921 | { m_pimpl->DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); } | |
922 | ||
923 | void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, | |
924 | double radius) | |
925 | { m_pimpl->DoDrawRoundedRectangle(x, y, width, height, radius); } | |
926 | void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, | |
927 | double radius) | |
928 | { m_pimpl->DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); } | |
929 | void DrawRoundedRectangle(const wxRect& r, double radius) | |
930 | { m_pimpl->DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); } | |
931 | ||
932 | void DrawCircle(wxCoord x, wxCoord y, wxCoord radius) | |
933 | { m_pimpl->DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); } | |
934 | void DrawCircle(const wxPoint& pt, wxCoord radius) | |
ca7db61e | 935 | { m_pimpl->DoDrawEllipse(pt.x - radius, pt.y - radius, 2*radius, 2*radius); } |
2970ae54 RR |
936 | |
937 | void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) | |
938 | { m_pimpl->DoDrawEllipse(x, y, width, height); } | |
939 | void DrawEllipse(const wxPoint& pt, const wxSize& sz) | |
940 | { m_pimpl->DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); } | |
941 | void DrawEllipse(const wxRect& rect) | |
942 | { m_pimpl->DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); } | |
943 | ||
944 | void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) | |
945 | { m_pimpl->DoDrawIcon(icon, x, y); } | |
946 | void DrawIcon(const wxIcon& icon, const wxPoint& pt) | |
947 | { m_pimpl->DoDrawIcon(icon, pt.x, pt.y); } | |
948 | ||
949 | void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
950 | bool useMask = false) | |
951 | { m_pimpl->DoDrawBitmap(bmp, x, y, useMask); } | |
952 | void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, | |
953 | bool useMask = false) | |
954 | { m_pimpl->DoDrawBitmap(bmp, pt.x, pt.y, useMask); } | |
955 | ||
956 | void DrawText(const wxString& text, wxCoord x, wxCoord y) | |
957 | { m_pimpl->DoDrawText(text, x, y); } | |
958 | void DrawText(const wxString& text, const wxPoint& pt) | |
959 | { m_pimpl->DoDrawText(text, pt.x, pt.y); } | |
960 | ||
961 | void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) | |
962 | { m_pimpl->DoDrawRotatedText(text, x, y, angle); } | |
963 | void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle) | |
964 | { m_pimpl->DoDrawRotatedText(text, pt.x, pt.y, angle); } | |
965 | ||
966 | // this version puts both optional bitmap and the text into the given | |
967 | // rectangle and aligns is as specified by alignment parameter; it also | |
968 | // will emphasize the character with the given index if it is != -1 and | |
969 | // return the bounding rectangle if required | |
970 | void DrawLabel(const wxString& text, | |
971 | const wxBitmap& image, | |
972 | const wxRect& rect, | |
973 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
974 | int indexAccel = -1, | |
ca7db61e | 975 | wxRect *rectBounding = NULL); |
2970ae54 RR |
976 | |
977 | void DrawLabel(const wxString& text, const wxRect& rect, | |
978 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
979 | int indexAccel = -1) | |
ca7db61e | 980 | { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); } |
2970ae54 RR |
981 | |
982 | bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, | |
983 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
984 | int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) | |
985 | { | |
986 | return m_pimpl->DoBlit(xdest, ydest, width, height, | |
987 | source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask); | |
988 | } | |
989 | bool Blit(const wxPoint& destPt, const wxSize& sz, | |
990 | wxDC *source, const wxPoint& srcPt, | |
991 | int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition) | |
992 | { | |
993 | return m_pimpl->DoBlit(destPt.x, destPt.y, sz.x, sz.y, | |
994 | source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y); | |
995 | } | |
996 | ||
f0875501 | 997 | bool StretchBlit(wxCoord dstX, wxCoord dstY, |
2970ae54 | 998 | wxCoord dstWidth, wxCoord dstHeight, |
f0875501 | 999 | wxDC *source, |
2970ae54 RR |
1000 | wxCoord srcX, wxCoord srcY, |
1001 | wxCoord srcWidth, wxCoord srcHeight, | |
f0875501 | 1002 | int rop = wxCOPY, bool useMask = false, |
2970ae54 RR |
1003 | wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord) |
1004 | { | |
1005 | return m_pimpl->DoStretchBlit(dstX, dstY, dstWidth, dstHeight, | |
1006 | source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY); | |
1007 | } | |
1008 | bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize, | |
1009 | wxDC *source, const wxPoint& srcPt, const wxSize& srcSize, | |
1010 | int rop = wxCOPY, bool useMask = false, const wxPoint& srcMaskPt = wxDefaultPosition) | |
1011 | { | |
1012 | return m_pimpl->DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y, | |
1013 | source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y); | |
1014 | } | |
1015 | ||
1016 | wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const | |
1017 | { | |
1018 | return m_pimpl->DoGetAsBitmap(subrect); | |
1019 | } | |
1020 | ||
1021 | #if wxUSE_SPLINES | |
2970ae54 RR |
1022 | void DrawSpline(wxCoord x1, wxCoord y1, |
1023 | wxCoord x2, wxCoord y2, | |
1024 | wxCoord x3, wxCoord y3) | |
ca7db61e | 1025 | { m_pimpl->DoDrawSpline(x1,y1,x2,y2,x3,y3); } |
2970ae54 | 1026 | void DrawSpline(int n, wxPoint points[]) |
ca7db61e | 1027 | { m_pimpl->DoDrawSpline(n,points); } |
f0875501 | 1028 | void DrawSpline(const wxPointList *points) |
2970ae54 RR |
1029 | { m_pimpl->DoDrawSpline(points); } |
1030 | #endif // wxUSE_SPLINES | |
1031 | ||
1032 | ||
1033 | #if WXWIN_COMPATIBILITY_2_8 | |
1034 | // for compatibility with the old code when wxCoord was long everywhere | |
1035 | wxDEPRECATED( void GetTextExtent(const wxString& string, | |
1036 | long *x, long *y, | |
1037 | long *descent = NULL, | |
1038 | long *externalLeading = NULL, | |
1039 | const wxFont *theFont = NULL) const ); | |
1040 | wxDEPRECATED( void GetLogicalOrigin(long *x, long *y) const ); | |
1041 | wxDEPRECATED( void GetDeviceOrigin(long *x, long *y) const ); | |
1042 | wxDEPRECATED( void GetClippingBox(long *x, long *y, long *w, long *h) const ); | |
1043 | #endif // WXWIN_COMPATIBILITY_2_8 | |
1044 | ||
1045 | ||
1046 | protected: | |
f0875501 VZ |
1047 | // ctor takes ownership of the pointer |
1048 | wxDC(wxDCImpl *pimpl) : m_pimpl(pimpl) { } | |
1049 | ||
1050 | wxDCImpl * const m_pimpl; | |
aec43716 | 1051 | |
ca7db61e | 1052 | private: |
888dde65 | 1053 | DECLARE_ABSTRACT_CLASS(wxDC) |
f0875501 | 1054 | DECLARE_NO_COPY_CLASS(wxDC) |
ca7db61e | 1055 | }; |
aec43716 | 1056 | |
1e6feb95 VZ |
1057 | // ---------------------------------------------------------------------------- |
1058 | // helper class: you can use it to temporarily change the DC text colour and | |
1059 | // restore it automatically when the object goes out of scope | |
1060 | // ---------------------------------------------------------------------------- | |
1061 | ||
1062 | class WXDLLEXPORT wxDCTextColourChanger | |
1063 | { | |
1064 | public: | |
ba161d7e | 1065 | wxDCTextColourChanger(wxDC& dc) : m_dc(dc), m_colFgOld() { } |
1e6feb95 | 1066 | |
1b97b23d VS |
1067 | wxDCTextColourChanger(wxDC& dc, const wxColour& col) : m_dc(dc) |
1068 | { | |
1069 | Set(col); | |
1070 | } | |
1071 | ||
1e6feb95 VZ |
1072 | ~wxDCTextColourChanger() |
1073 | { | |
1074 | if ( m_colFgOld.Ok() ) | |
1075 | m_dc.SetTextForeground(m_colFgOld); | |
1076 | } | |
1077 | ||
1078 | void Set(const wxColour& col) | |
1079 | { | |
1080 | if ( !m_colFgOld.Ok() ) | |
1081 | m_colFgOld = m_dc.GetTextForeground(); | |
1082 | m_dc.SetTextForeground(col); | |
1083 | } | |
1084 | ||
1085 | private: | |
1086 | wxDC& m_dc; | |
1087 | ||
1088 | wxColour m_colFgOld; | |
fc7a2a60 VZ |
1089 | |
1090 | DECLARE_NO_COPY_CLASS(wxDCTextColourChanger) | |
1e6feb95 VZ |
1091 | }; |
1092 | ||
4660e6ac WS |
1093 | // ---------------------------------------------------------------------------- |
1094 | // helper class: you can use it to temporarily change the DC pen and | |
1095 | // restore it automatically when the object goes out of scope | |
1096 | // ---------------------------------------------------------------------------- | |
1097 | ||
1098 | class WXDLLEXPORT wxDCPenChanger | |
1099 | { | |
1100 | public: | |
0164f8eb WS |
1101 | wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen()) |
1102 | { | |
1103 | m_dc.SetPen(pen); | |
1104 | } | |
4660e6ac WS |
1105 | |
1106 | ~wxDCPenChanger() | |
1107 | { | |
1108 | if ( m_penOld.Ok() ) | |
1109 | m_dc.SetPen(m_penOld); | |
1110 | } | |
1111 | ||
4660e6ac WS |
1112 | private: |
1113 | wxDC& m_dc; | |
1114 | ||
1115 | wxPen m_penOld; | |
1116 | ||
1117 | DECLARE_NO_COPY_CLASS(wxDCPenChanger) | |
1118 | }; | |
1119 | ||
1120 | // ---------------------------------------------------------------------------- | |
1121 | // helper class: you can use it to temporarily change the DC brush and | |
1122 | // restore it automatically when the object goes out of scope | |
1123 | // ---------------------------------------------------------------------------- | |
1124 | ||
1125 | class WXDLLEXPORT wxDCBrushChanger | |
1126 | { | |
1127 | public: | |
0164f8eb WS |
1128 | wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush()) |
1129 | { | |
1130 | m_dc.SetBrush(brush); | |
1131 | } | |
4660e6ac WS |
1132 | |
1133 | ~wxDCBrushChanger() | |
1134 | { | |
1135 | if ( m_brushOld.Ok() ) | |
1136 | m_dc.SetBrush(m_brushOld); | |
1137 | } | |
1138 | ||
4660e6ac WS |
1139 | private: |
1140 | wxDC& m_dc; | |
1141 | ||
1142 | wxBrush m_brushOld; | |
1143 | ||
1144 | DECLARE_NO_COPY_CLASS(wxDCBrushChanger) | |
1145 | }; | |
1146 | ||
e26be42b VZ |
1147 | // ---------------------------------------------------------------------------- |
1148 | // another small helper class: sets the clipping region in its ctor and | |
1149 | // destroys it in the dtor | |
1150 | // ---------------------------------------------------------------------------- | |
1151 | ||
1152 | class WXDLLEXPORT wxDCClipper | |
1153 | { | |
1154 | public: | |
fc298ea7 VZ |
1155 | wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc) |
1156 | { dc.SetClippingRegion(r); } | |
e26be42b VZ |
1157 | wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc) |
1158 | { dc.SetClippingRegion(r.x, r.y, r.width, r.height); } | |
1159 | wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc) | |
1160 | { dc.SetClippingRegion(x, y, w, h); } | |
1161 | ||
1162 | ~wxDCClipper() { m_dc.DestroyClippingRegion(); } | |
1163 | ||
1164 | private: | |
1165 | wxDC& m_dc; | |
fc7a2a60 VZ |
1166 | |
1167 | DECLARE_NO_COPY_CLASS(wxDCClipper) | |
e26be42b VZ |
1168 | }; |
1169 | ||
8b56b16a | 1170 | #endif // _WX_DC_H_BASE_ |