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