]>
Commit | Line | Data |
---|---|---|
006162a9 | 1 | ///////////////////////////////////////////////////////////////////////////// |
4660e6ac | 2 | // Name: wx/dc.h |
006162a9 | 3 | // Purpose: wxDC class |
6d52ca53 | 4 | // Author: Vadim Zeitlin |
006162a9 VZ |
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 | 44 | |
89efaf2b FM |
45 | // Logical ops |
46 | enum wxRasterOperationMode | |
47 | { | |
48 | wxCLEAR, // 0 | |
49 | wxXOR, // src XOR dst | |
50 | wxINVERT, // NOT dst | |
51 | wxOR_REVERSE, // src OR (NOT dst) | |
52 | wxAND_REVERSE, // src AND (NOT dst) | |
53 | wxCOPY, // src | |
54 | wxAND, // src AND dst | |
55 | wxAND_INVERT, // (NOT src) AND dst | |
56 | wxNO_OP, // dst | |
57 | wxNOR, // (NOT src) AND (NOT dst) | |
58 | wxEQUIV, // (NOT src) XOR dst | |
59 | wxSRC_INVERT, // (NOT src) | |
60 | wxOR_INVERT, // (NOT src) OR dst | |
61 | wxNAND, // (NOT src) OR (NOT dst) | |
62 | wxOR, // src OR dst | |
63 | wxSET // 1 | |
79bd5e98 | 64 | #if WXWIN_COMPATIBILITY_2_8 |
89efaf2b FM |
65 | ,wxROP_BLACK = wxCLEAR, |
66 | wxBLIT_BLACKNESS = wxCLEAR, | |
67 | wxROP_XORPEN = wxXOR, | |
68 | wxBLIT_SRCINVERT = wxXOR, | |
69 | wxROP_NOT = wxINVERT, | |
70 | wxBLIT_DSTINVERT = wxINVERT, | |
71 | wxROP_MERGEPENNOT = wxOR_REVERSE, | |
72 | wxBLIT_00DD0228 = wxOR_REVERSE, | |
73 | wxROP_MASKPENNOT = wxAND_REVERSE, | |
74 | wxBLIT_SRCERASE = wxAND_REVERSE, | |
75 | wxROP_COPYPEN = wxCOPY, | |
76 | wxBLIT_SRCCOPY = wxCOPY, | |
77 | wxROP_MASKPEN = wxAND, | |
78 | wxBLIT_SRCAND = wxAND, | |
79 | wxROP_MASKNOTPEN = wxAND_INVERT, | |
80 | wxBLIT_00220326 = wxAND_INVERT, | |
81 | wxROP_NOP = wxNO_OP, | |
82 | wxBLIT_00AA0029 = wxNO_OP, | |
83 | wxROP_NOTMERGEPEN = wxNOR, | |
84 | wxBLIT_NOTSRCERASE = wxNOR, | |
85 | wxROP_NOTXORPEN = wxEQUIV, | |
86 | wxBLIT_00990066 = wxEQUIV, | |
87 | wxROP_NOTCOPYPEN = wxSRC_INVERT, | |
88 | wxBLIT_NOTSCRCOPY = wxSRC_INVERT, | |
89 | wxROP_MERGENOTPEN = wxOR_INVERT, | |
90 | wxBLIT_MERGEPAINT = wxOR_INVERT, | |
91 | wxROP_NOTMASKPEN = wxNAND, | |
92 | wxBLIT_007700E6 = wxNAND, | |
93 | wxROP_MERGEPEN = wxOR, | |
94 | wxBLIT_SRCPAINT = wxOR, | |
95 | wxROP_WHITE = wxSET, | |
96 | wxBLIT_WHITENESS = wxSET | |
97 | #endif //WXWIN_COMPATIBILITY_2_8 | |
98 | }; | |
99 | ||
100 | // Flood styles | |
101 | enum wxFloodFillStyle | |
102 | { | |
103 | wxFLOOD_SURFACE = 1, | |
104 | wxFLOOD_BORDER | |
105 | }; | |
106 | ||
107 | // Mapping modes (same values as used by Windows, don't change) | |
108 | enum wxMappingMode | |
109 | { | |
110 | wxMM_TEXT = 1, | |
111 | wxMM_LOMETRIC, | |
112 | wxMM_HIMETRIC, | |
113 | wxMM_LOENGLISH, | |
114 | wxMM_HIENGLISH, | |
115 | wxMM_TWIPS, | |
116 | wxMM_ISOTROPIC, | |
117 | wxMM_ANISOTROPIC, | |
118 | wxMM_POINTS, | |
119 | wxMM_METRIC | |
120 | }; | |
121 | ||
0a0e4984 VZ |
122 | #if WXWIN_COMPATIBILITY_2_8 |
123 | ||
888dde65 RR |
124 | //----------------------------------------------------------------------------- |
125 | // wxDrawObject helper class | |
126 | //----------------------------------------------------------------------------- | |
ca7db61e | 127 | |
713e9290 | 128 | class WXDLLIMPEXP_CORE wxDrawObject |
ca7db61e RR |
129 | { |
130 | public: | |
713e9290 | 131 | wxDEPRECATED_CONSTRUCTOR(wxDrawObject)() |
ca7db61e RR |
132 | : m_isBBoxValid(false) |
133 | , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0) | |
134 | { } | |
135 | ||
136 | virtual ~wxDrawObject() { } | |
137 | ||
ca7db61e | 138 | virtual void Draw(wxDC&) const { } |
ca7db61e RR |
139 | |
140 | virtual void CalcBoundingBox(wxCoord x, wxCoord y) | |
141 | { | |
142 | if ( m_isBBoxValid ) | |
143 | { | |
144 | if ( x < m_minX ) m_minX = x; | |
145 | if ( y < m_minY ) m_minY = y; | |
146 | if ( x > m_maxX ) m_maxX = x; | |
147 | if ( y > m_maxY ) m_maxY = y; | |
148 | } | |
149 | else | |
150 | { | |
151 | m_isBBoxValid = true; | |
152 | ||
153 | m_minX = x; | |
154 | m_minY = y; | |
155 | m_maxX = x; | |
156 | m_maxY = y; | |
157 | } | |
158 | } | |
159 | ||
160 | void ResetBoundingBox() | |
161 | { | |
162 | m_isBBoxValid = false; | |
163 | ||
164 | m_minX = m_maxX = m_minY = m_maxY = 0; | |
165 | } | |
166 | ||
167 | // Get the final bounding box of the PostScript or Metafile picture. | |
168 | ||
169 | wxCoord MinX() const { return m_minX; } | |
170 | wxCoord MaxX() const { return m_maxX; } | |
171 | wxCoord MinY() const { return m_minY; } | |
172 | wxCoord MaxY() const { return m_maxY; } | |
173 | ||
174 | //to define the type of object for derived objects | |
175 | virtual int GetType()=0; | |
176 | ||
177 | protected: | |
178 | //for boundingbox calculation | |
179 | bool m_isBBoxValid:1; | |
180 | //for boundingbox calculation | |
181 | wxCoord m_minX, m_minY, m_maxX, m_maxY; | |
182 | }; | |
183 | ||
0a0e4984 VZ |
184 | #endif // WXWIN_COMPATIBILITY_2_8 |
185 | ||
ca7db61e | 186 | |
2970ae54 RR |
187 | //----------------------------------------------------------------------------- |
188 | // wxDCFactory | |
189 | //----------------------------------------------------------------------------- | |
190 | ||
888dde65 | 191 | class WXDLLIMPEXP_FWD_CORE wxDCImpl; |
2970ae54 RR |
192 | |
193 | class WXDLLIMPEXP_CORE wxDCFactory | |
194 | { | |
195 | public: | |
196 | wxDCFactory() {} | |
197 | virtual ~wxDCFactory() {} | |
f0875501 | 198 | |
888dde65 | 199 | virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner, wxWindow *window ) = 0; |
888dde65 | 200 | virtual wxDCImpl* CreateClientDC( wxClientDC *owner, wxWindow *window ) = 0; |
888dde65 RR |
201 | virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner, wxWindow *window ) = 0; |
202 | virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner ) = 0; | |
203 | virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ) = 0; | |
204 | virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ) = 0; | |
205 | virtual wxDCImpl* CreateScreenDC( wxScreenDC *owner ) = 0; | |
6b4f4d47 | 206 | #if wxUSE_PRINTING_ARCHITECTURE |
888dde65 | 207 | virtual wxDCImpl* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ) = 0; |
6b4f4d47 | 208 | #endif |
f0875501 | 209 | |
f2498c4e | 210 | static void Set(wxDCFactory *factory); |
f0875501 VZ |
211 | static wxDCFactory *Get(); |
212 | ||
2970ae54 RR |
213 | private: |
214 | static wxDCFactory *m_factory; | |
215 | }; | |
216 | ||
217 | //----------------------------------------------------------------------------- | |
218 | // wxNativeDCFactory | |
219 | //----------------------------------------------------------------------------- | |
220 | ||
ab171e95 | 221 | class WXDLLIMPEXP_CORE wxNativeDCFactory: public wxDCFactory |
2970ae54 RR |
222 | { |
223 | public: | |
224 | wxNativeDCFactory() {} | |
f0875501 | 225 | |
888dde65 | 226 | virtual wxDCImpl* CreateWindowDC( wxWindowDC *owner, wxWindow *window ); |
888dde65 | 227 | virtual wxDCImpl* CreateClientDC( wxClientDC *owner, wxWindow *window ); |
888dde65 RR |
228 | virtual wxDCImpl* CreatePaintDC( wxPaintDC *owner, wxWindow *window ); |
229 | virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner ); | |
230 | virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ); | |
231 | virtual wxDCImpl* CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ); | |
232 | virtual wxDCImpl* CreateScreenDC( wxScreenDC *owner ); | |
6b4f4d47 | 233 | #if wxUSE_PRINTING_ARCHITECTURE |
888dde65 | 234 | virtual wxDCImpl* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data ); |
6b4f4d47 | 235 | #endif |
2970ae54 RR |
236 | }; |
237 | ||
2970ae54 | 238 | //----------------------------------------------------------------------------- |
888dde65 | 239 | // wxDCImpl |
2970ae54 RR |
240 | //----------------------------------------------------------------------------- |
241 | ||
888dde65 | 242 | class WXDLLIMPEXP_CORE wxDCImpl: public wxObject |
2970ae54 RR |
243 | { |
244 | public: | |
888dde65 | 245 | wxDCImpl( wxDC *owner ); |
edc51344 | 246 | virtual ~wxDCImpl(); |
f0875501 | 247 | |
ab171e95 | 248 | wxDC *GetOwner() const { return m_owner; } |
f0875501 | 249 | |
888dde65 | 250 | wxWindow* GetWindow() const { return m_window; } |
f0875501 | 251 | |
2970ae54 RR |
252 | virtual bool IsOk() const { return m_ok; } |
253 | ||
254 | // query capabilities | |
255 | ||
256 | virtual bool CanDrawBitmap() const = 0; | |
257 | virtual bool CanGetTextExtent() const = 0; | |
258 | ||
0b822969 RR |
259 | // get Cairo context |
260 | virtual void* GetCairoContext() const | |
2b44ffc0 RR |
261 | { |
262 | return NULL; | |
263 | } | |
2b44ffc0 | 264 | |
2970ae54 RR |
265 | // query dimension, colour deps, resolution |
266 | ||
267 | virtual void DoGetSize(int *width, int *height) const = 0; | |
4a624f6e VZ |
268 | void GetSize(int *width, int *height) const |
269 | { | |
243ef54b CE |
270 | DoGetSize(width, height); |
271 | return ; | |
4a624f6e VZ |
272 | } |
273 | ||
274 | wxSize GetSize() const | |
275 | { | |
276 | int w, h; | |
277 | DoGetSize(&w, &h); | |
278 | return wxSize(w, h); | |
279 | } | |
280 | ||
2970ae54 | 281 | virtual void DoGetSizeMM(int* width, int* height) const = 0; |
f0875501 | 282 | |
2970ae54 RR |
283 | virtual int GetDepth() const = 0; |
284 | virtual wxSize GetPPI() const = 0; | |
f0875501 | 285 | |
2970ae54 | 286 | // Right-To-Left (RTL) modes |
f0875501 | 287 | |
2970ae54 RR |
288 | virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) { } |
289 | virtual wxLayoutDirection GetLayoutDirection() const { return wxLayout_Default; } | |
f0875501 VZ |
290 | |
291 | // page and document | |
292 | ||
2970ae54 RR |
293 | virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; } |
294 | virtual void EndDoc() { } | |
295 | ||
296 | virtual void StartPage() { } | |
297 | virtual void EndPage() { } | |
298 | ||
cc18b1c7 SC |
299 | // flushing the content of this dc immediately eg onto screen |
300 | virtual void Flush() { } | |
301 | ||
2970ae54 RR |
302 | // bounding box |
303 | ||
ca7db61e | 304 | virtual void CalcBoundingBox(wxCoord x, wxCoord y) |
2970ae54 RR |
305 | { |
306 | if ( m_isBBoxValid ) | |
307 | { | |
308 | if ( x < m_minX ) m_minX = x; | |
309 | if ( y < m_minY ) m_minY = y; | |
310 | if ( x > m_maxX ) m_maxX = x; | |
311 | if ( y > m_maxY ) m_maxY = y; | |
312 | } | |
313 | else | |
314 | { | |
315 | m_isBBoxValid = true; | |
316 | ||
317 | m_minX = x; | |
318 | m_minY = y; | |
319 | m_maxX = x; | |
320 | m_maxY = y; | |
321 | } | |
322 | } | |
ca7db61e | 323 | void ResetBoundingBox() |
2970ae54 RR |
324 | { |
325 | m_isBBoxValid = false; | |
326 | ||
327 | m_minX = m_maxX = m_minY = m_maxY = 0; | |
328 | } | |
329 | ||
330 | wxCoord MinX() const { return m_minX; } | |
331 | wxCoord MaxX() const { return m_maxX; } | |
332 | wxCoord MinY() const { return m_minY; } | |
333 | wxCoord MaxY() const { return m_maxY; } | |
f0875501 | 334 | |
2970ae54 RR |
335 | // setters and getters |
336 | ||
337 | virtual void SetFont(const wxFont& font) = 0; | |
edc51344 | 338 | virtual const wxFont& GetFont() const { return m_font; } |
f0875501 | 339 | |
2970ae54 | 340 | virtual void SetPen(const wxPen& pen) = 0; |
edc51344 | 341 | virtual const wxPen& GetPen() const { return m_pen; } |
f0875501 | 342 | |
2970ae54 | 343 | virtual void SetBrush(const wxBrush& brush) = 0; |
edc51344 | 344 | virtual const wxBrush& GetBrush() const { return m_brush; } |
f0875501 | 345 | |
2970ae54 | 346 | virtual void SetBackground(const wxBrush& brush) = 0; |
edc51344 | 347 | virtual const wxBrush& GetBackground() const { return m_backgroundBrush; } |
f0875501 | 348 | |
2970ae54 RR |
349 | virtual void SetBackgroundMode(int mode) = 0; |
350 | virtual int GetBackgroundMode() const { return m_backgroundMode; } | |
351 | ||
352 | virtual void SetTextForeground(const wxColour& colour) | |
353 | { m_textForegroundColour = colour; } | |
edc51344 VZ |
354 | virtual const wxColour& GetTextForeground() const |
355 | { return m_textForegroundColour; } | |
f0875501 | 356 | |
2970ae54 RR |
357 | virtual void SetTextBackground(const wxColour& colour) |
358 | { m_textBackgroundColour = colour; } | |
edc51344 VZ |
359 | virtual const wxColour& GetTextBackground() const |
360 | { return m_textBackgroundColour; } | |
2970ae54 RR |
361 | |
362 | #if wxUSE_PALETTE | |
363 | virtual void SetPalette(const wxPalette& palette) = 0; | |
364 | #endif // wxUSE_PALETTE | |
365 | ||
edc51344 VZ |
366 | // inherit the DC attributes (font and colours) from the given window |
367 | // | |
368 | // this is called automatically when a window, client or paint DC is | |
369 | // created | |
370 | virtual void InheritAttributes(wxWindow *win); | |
371 | ||
372 | ||
2970ae54 | 373 | // logical functions |
f0875501 | 374 | |
89efaf2b FM |
375 | virtual void SetLogicalFunction(wxRasterOperationMode function) = 0; |
376 | virtual wxRasterOperationMode GetLogicalFunction() const | |
377 | { return m_logicalFunction; } | |
2970ae54 RR |
378 | |
379 | // text measurement | |
380 | ||
381 | virtual wxCoord GetCharHeight() const = 0; | |
382 | virtual wxCoord GetCharWidth() const = 0; | |
383 | virtual void DoGetTextExtent(const wxString& string, | |
384 | wxCoord *x, wxCoord *y, | |
385 | wxCoord *descent = NULL, | |
386 | wxCoord *externalLeading = NULL, | |
387 | const wxFont *theFont = NULL) const = 0; | |
388 | virtual void GetMultiLineTextExtent(const wxString& string, | |
389 | wxCoord *width, | |
390 | wxCoord *height, | |
391 | wxCoord *heightLine = NULL, | |
392 | const wxFont *font = NULL) const; | |
393 | virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const; | |
f0875501 | 394 | |
2970ae54 | 395 | // clearing |
f0875501 | 396 | |
2970ae54 RR |
397 | virtual void Clear() = 0; |
398 | ||
399 | // clipping | |
400 | ||
401 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, | |
402 | wxCoord width, wxCoord height) = 0; | |
fdaad94e VZ |
403 | |
404 | // NB: this function works with device coordinates, not the logical ones! | |
405 | virtual void DoSetDeviceClippingRegion(const wxRegion& region) = 0; | |
2970ae54 RR |
406 | |
407 | virtual void DoGetClippingBox(wxCoord *x, wxCoord *y, | |
408 | wxCoord *w, wxCoord *h) const | |
409 | { | |
410 | if ( x ) | |
411 | *x = m_clipX1; | |
412 | if ( y ) | |
413 | *y = m_clipY1; | |
414 | if ( w ) | |
415 | *w = m_clipX2 - m_clipX1; | |
416 | if ( h ) | |
417 | *h = m_clipY2 - m_clipY1; | |
418 | } | |
419 | ||
420 | virtual void DestroyClippingRegion() { ResetClipping(); } | |
421 | ||
422 | ||
423 | // coordinates conversions and transforms | |
424 | ||
425 | virtual wxCoord DeviceToLogicalX(wxCoord x) const; | |
426 | virtual wxCoord DeviceToLogicalY(wxCoord y) const; | |
427 | virtual wxCoord DeviceToLogicalXRel(wxCoord x) const; | |
428 | virtual wxCoord DeviceToLogicalYRel(wxCoord y) const; | |
429 | virtual wxCoord LogicalToDeviceX(wxCoord x) const; | |
430 | virtual wxCoord LogicalToDeviceY(wxCoord y) const; | |
431 | virtual wxCoord LogicalToDeviceXRel(wxCoord x) const; | |
432 | virtual wxCoord LogicalToDeviceYRel(wxCoord y) const; | |
433 | ||
89efaf2b FM |
434 | virtual void SetMapMode(wxMappingMode mode); |
435 | virtual wxMappingMode GetMapMode() const { return m_mappingMode; } | |
2970ae54 RR |
436 | |
437 | virtual void SetUserScale(double x, double y); | |
438 | virtual void GetUserScale(double *x, double *y) const | |
439 | { | |
440 | if ( x ) *x = m_userScaleX; | |
441 | if ( y ) *y = m_userScaleY; | |
442 | } | |
443 | ||
444 | virtual void SetLogicalScale(double x, double y); | |
445 | virtual void GetLogicalScale(double *x, double *y) | |
446 | { | |
447 | if ( x ) *x = m_logicalScaleX; | |
448 | if ( y ) *y = m_logicalScaleY; | |
449 | } | |
450 | ||
451 | virtual void SetLogicalOrigin(wxCoord x, wxCoord y); | |
452 | virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const | |
453 | { | |
454 | if ( x ) *x = m_logicalOriginX; | |
455 | if ( y ) *y = m_logicalOriginY; | |
456 | } | |
457 | ||
458 | virtual void SetDeviceOrigin(wxCoord x, wxCoord y); | |
459 | virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const | |
460 | { | |
461 | if ( x ) *x = m_deviceOriginX; | |
462 | if ( y ) *y = m_deviceOriginY; | |
463 | } | |
f0875501 | 464 | |
2970ae54 RR |
465 | virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y ); |
466 | ||
467 | virtual void ComputeScaleAndOrigin(); | |
468 | ||
469 | // this needs to overidden if the axis is inverted | |
470 | virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
471 | ||
472 | // --------------------------------------------------------- | |
473 | // the actual drawing API | |
474 | ||
475 | virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, | |
89efaf2b | 476 | wxFloodFillStyle style = wxFLOOD_SURFACE) = 0; |
2970ae54 RR |
477 | |
478 | virtual void DoGradientFillLinear(const wxRect& rect, | |
479 | const wxColour& initialColour, | |
480 | const wxColour& destColour, | |
481 | wxDirection nDirection = wxEAST); | |
482 | ||
483 | virtual void DoGradientFillConcentric(const wxRect& rect, | |
484 | const wxColour& initialColour, | |
485 | const wxColour& destColour, | |
486 | const wxPoint& circleCenter); | |
487 | ||
488 | virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0; | |
489 | ||
490 | virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0; | |
491 | virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0; | |
492 | ||
493 | virtual void DoDrawArc(wxCoord x1, wxCoord y1, | |
494 | wxCoord x2, wxCoord y2, | |
495 | wxCoord xc, wxCoord yc) = 0; | |
496 | virtual void DoDrawCheckMark(wxCoord x, wxCoord y, | |
497 | wxCoord width, wxCoord height); | |
498 | virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, | |
499 | double sa, double ea) = 0; | |
500 | ||
501 | virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0; | |
502 | virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, | |
503 | wxCoord width, wxCoord height, | |
504 | double radius) = 0; | |
505 | virtual void DoDrawEllipse(wxCoord x, wxCoord y, | |
506 | wxCoord width, wxCoord height) = 0; | |
507 | ||
508 | virtual void DoCrossHair(wxCoord x, wxCoord y) = 0; | |
509 | ||
510 | virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0; | |
511 | virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
512 | bool useMask = false) = 0; | |
513 | ||
514 | virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0; | |
515 | virtual void DoDrawRotatedText(const wxString& text, | |
516 | wxCoord x, wxCoord y, double angle) = 0; | |
517 | ||
518 | virtual bool DoBlit(wxCoord xdest, wxCoord ydest, | |
519 | wxCoord width, wxCoord height, | |
520 | wxDC *source, | |
521 | wxCoord xsrc, wxCoord ysrc, | |
89efaf2b | 522 | wxRasterOperationMode rop = wxCOPY, |
2970ae54 RR |
523 | bool useMask = false, |
524 | wxCoord xsrcMask = wxDefaultCoord, | |
525 | wxCoord ysrcMask = wxDefaultCoord) = 0; | |
526 | ||
527 | virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest, | |
528 | wxCoord dstWidth, wxCoord dstHeight, | |
529 | wxDC *source, | |
530 | wxCoord xsrc, wxCoord ysrc, | |
531 | wxCoord srcWidth, wxCoord srcHeight, | |
89efaf2b | 532 | wxRasterOperationMode rop = wxCOPY, |
2970ae54 RR |
533 | bool useMask = false, |
534 | wxCoord xsrcMask = wxDefaultCoord, | |
535 | wxCoord ysrcMask = wxDefaultCoord); | |
536 | ||
537 | virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const | |
538 | { return wxNullBitmap; } | |
539 | ||
540 | ||
541 | virtual void DoDrawLines(int n, wxPoint points[], | |
4f37154e RR |
542 | wxCoord xoffset, wxCoord yoffset ) = 0; |
543 | virtual void DrawLines(const wxPointList *list, | |
544 | wxCoord xoffset, wxCoord yoffset ); | |
f0875501 | 545 | |
2970ae54 | 546 | virtual void DoDrawPolygon(int n, wxPoint points[], |
89efaf2b FM |
547 | wxCoord xoffset, wxCoord yoffset, |
548 | wxPolygonFillMode fillStyle = wxODDEVEN_RULE) = 0; | |
2970ae54 RR |
549 | virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[], |
550 | wxCoord xoffset, wxCoord yoffset, | |
89efaf2b | 551 | wxPolygonFillMode fillStyle); |
4f37154e RR |
552 | void DrawPolygon(const wxPointList *list, |
553 | wxCoord xoffset, wxCoord yoffset, | |
89efaf2b | 554 | wxPolygonFillMode fillStyle ); |
2970ae54 RR |
555 | |
556 | ||
557 | #if wxUSE_SPLINES | |
7210c3a1 VZ |
558 | void DrawSpline(wxCoord x1, wxCoord y1, |
559 | wxCoord x2, wxCoord y2, | |
560 | wxCoord x3, wxCoord y3); | |
561 | void DrawSpline(int n, wxPoint points[]); | |
562 | void DrawSpline(const wxPointList *points) { DoDrawSpline(points); } | |
563 | ||
b0d7707b | 564 | virtual void DoDrawSpline(const wxPointList *points); |
2970ae54 | 565 | #endif |
f0875501 | 566 | |
4f37154e RR |
567 | // --------------------------------------------------------- |
568 | // wxMemoryDC Impl API | |
569 | ||
570 | virtual void DoSelect(const wxBitmap& WXUNUSED(bmp)) | |
571 | { } | |
f0875501 | 572 | |
4f37154e RR |
573 | virtual const wxBitmap& GetSelectedBitmap() const |
574 | { return wxNullBitmap; } | |
575 | virtual wxBitmap& GetSelectedBitmap() | |
576 | { return wxNullBitmap; } | |
f0875501 | 577 | |
4f37154e RR |
578 | // --------------------------------------------------------- |
579 | // wxPrinterDC Impl API | |
580 | ||
6d52ca53 | 581 | virtual wxRect GetPaperRect() const |
4f37154e | 582 | { int w = 0; int h = 0; DoGetSize( &w, &h ); return wxRect(0,0,w,h); } |
f0875501 | 583 | |
6d52ca53 | 584 | virtual int GetResolution() const |
4f37154e RR |
585 | { return -1; } |
586 | ||
2970ae54 | 587 | private: |
888dde65 | 588 | wxDC *m_owner; |
2970ae54 | 589 | |
f0875501 | 590 | protected: |
2970ae54 RR |
591 | // unset clipping variables (after clipping region was destroyed) |
592 | void ResetClipping() | |
593 | { | |
594 | m_clipping = false; | |
595 | ||
596 | m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0; | |
597 | } | |
598 | ||
2261baf7 VZ |
599 | #ifdef __WXWINCE__ |
600 | //! Generic method to draw ellipses, circles and arcs with current pen and brush. | |
601 | /*! \param x Upper left corner of bounding box. | |
602 | * \param y Upper left corner of bounding box. | |
603 | * \param w Width of bounding box. | |
604 | * \param h Height of bounding box. | |
605 | * \param sa Starting angle of arc | |
606 | * (counterclockwise, start at 3 o'clock, 360 is full circle). | |
607 | * \param ea Ending angle of arc. | |
608 | * \param angle Rotation angle, the Arc will be rotated after | |
609 | * calculating begin and end. | |
610 | */ | |
611 | void DrawEllipticArcRot( wxCoord x, wxCoord y, | |
612 | wxCoord width, wxCoord height, | |
613 | double sa = 0, double ea = 0, double angle = 0 ) | |
614 | { DoDrawEllipticArcRot( x, y, width, height, sa, ea, angle ); } | |
615 | ||
616 | void DrawEllipticArcRot( const wxPoint& pt, | |
617 | const wxSize& sz, | |
618 | double sa = 0, double ea = 0, double angle = 0 ) | |
619 | { DoDrawEllipticArcRot( pt.x, pt.y, sz.x, sz.y, sa, ea, angle ); } | |
620 | ||
621 | void DrawEllipticArcRot( const wxRect& rect, | |
622 | double sa = 0, double ea = 0, double angle = 0 ) | |
623 | { DoDrawEllipticArcRot( rect.x, rect.y, rect.width, rect.height, sa, ea, angle ); } | |
624 | ||
625 | virtual void DoDrawEllipticArcRot( wxCoord x, wxCoord y, | |
626 | wxCoord w, wxCoord h, | |
627 | double sa = 0, double ea = 0, double angle = 0 ); | |
628 | ||
629 | //! Rotates points around center. | |
630 | /*! This is a quite straight method, it calculates in pixels | |
631 | * and so it produces rounding errors. | |
632 | * \param points The points inside will be rotated. | |
633 | * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle). | |
634 | * \param center Center of rotation. | |
635 | */ | |
636 | void Rotate( wxPointList* points, double angle, wxPoint center = wxPoint(0,0) ); | |
637 | ||
638 | // used by DrawEllipticArcRot | |
639 | // Careful: wxList gets filled with points you have to delete later. | |
640 | void CalculateEllipticPoints( wxPointList* points, | |
641 | wxCoord xStart, wxCoord yStart, | |
642 | wxCoord w, wxCoord h, | |
643 | double sa, double ea ); | |
644 | #endif // __WXWINCE__ | |
645 | ||
12ca5586 VS |
646 | // returns adjustment factor for converting wxFont "point size"; in wx |
647 | // it is point size on screen and needs to be multiplied by this value | |
648 | // for rendering on higher-resolution DCs such as printer ones | |
649 | static float GetFontPointSizeAdjustment(float dpi); | |
2261baf7 | 650 | |
888dde65 RR |
651 | // window on which the DC draws or NULL |
652 | wxWindow *m_window; | |
f0875501 | 653 | |
2970ae54 RR |
654 | // flags |
655 | bool m_colour:1; | |
656 | bool m_ok:1; | |
657 | bool m_clipping:1; | |
658 | bool m_isInteractive:1; | |
659 | bool m_isBBoxValid:1; | |
660 | ||
661 | // coordinate system variables | |
662 | ||
663 | wxCoord m_logicalOriginX, m_logicalOriginY; | |
664 | wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user | |
f0875501 | 665 | |
2970ae54 RR |
666 | wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner |
667 | // is not at 0,0. This was the case under | |
668 | // Mac's GrafPorts (coordinate system | |
669 | // used toplevel window's origin) and | |
670 | // e.g. for Postscript, where the native | |
671 | // origin in the bottom left corner. | |
672 | double m_logicalScaleX, m_logicalScaleY; | |
673 | double m_userScaleX, m_userScaleY; | |
674 | double m_scaleX, m_scaleY; // calculated from logical scale and user scale | |
675 | ||
676 | int m_signX, m_signY; // Used by SetAxisOrientation() to invert the axes | |
f0875501 | 677 | |
2970ae54 RR |
678 | // what is a mm on a screen you don't know the size of? |
679 | double m_mm_to_pix_x, | |
680 | m_mm_to_pix_y; | |
f0875501 | 681 | |
2970ae54 RR |
682 | // bounding and clipping boxes |
683 | wxCoord m_minX, m_minY, m_maxX, m_maxY; | |
684 | wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2; | |
685 | ||
89efaf2b | 686 | wxRasterOperationMode m_logicalFunction; |
2970ae54 | 687 | int m_backgroundMode; |
89efaf2b | 688 | wxMappingMode m_mappingMode; |
2970ae54 RR |
689 | |
690 | wxPen m_pen; | |
691 | wxBrush m_brush; | |
692 | wxBrush m_backgroundBrush; | |
693 | wxColour m_textForegroundColour; | |
694 | wxColour m_textBackgroundColour; | |
695 | wxFont m_font; | |
696 | ||
697 | #if wxUSE_PALETTE | |
698 | wxPalette m_palette; | |
699 | bool m_hasCustomPalette; | |
700 | #endif // wxUSE_PALETTE | |
701 | ||
702 | private: | |
888dde65 | 703 | DECLARE_ABSTRACT_CLASS(wxDCImpl) |
ca7db61e | 704 | }; |
2970ae54 RR |
705 | |
706 | ||
f0875501 | 707 | class WXDLLIMPEXP_CORE wxDC : public wxObject |
2970ae54 RR |
708 | { |
709 | public: | |
f0875501 | 710 | virtual ~wxDC() { delete m_pimpl; } |
2970ae54 | 711 | |
888dde65 | 712 | wxDCImpl *GetImpl() |
ab171e95 | 713 | { return m_pimpl; } |
888dde65 | 714 | const wxDCImpl *GetImpl() const |
32043152 RR |
715 | { return m_pimpl; } |
716 | ||
1f991c9d | 717 | wxWindow *GetWindow() const |
888dde65 | 718 | { return m_pimpl->GetWindow(); } |
ab171e95 | 719 | |
f0875501 | 720 | bool IsOk() const |
2970ae54 RR |
721 | { return m_pimpl && m_pimpl->IsOk(); } |
722 | ||
723 | // query capabilities | |
724 | ||
f0875501 | 725 | bool CanDrawBitmap() const |
2970ae54 RR |
726 | { return m_pimpl->CanDrawBitmap(); } |
727 | bool CanGetTextExtent() const | |
728 | { return m_pimpl->CanGetTextExtent(); } | |
f0875501 | 729 | |
2970ae54 RR |
730 | // query dimension, colour deps, resolution |
731 | ||
732 | void GetSize(int *width, int *height) const | |
733 | { m_pimpl->DoGetSize(width, height); } | |
2970ae54 | 734 | wxSize GetSize() const |
4a624f6e | 735 | { return m_pimpl->GetSize(); } |
2970ae54 RR |
736 | |
737 | void GetSizeMM(int* width, int* height) const | |
738 | { m_pimpl->DoGetSizeMM(width, height); } | |
739 | wxSize GetSizeMM() const | |
740 | { | |
741 | int w, h; | |
742 | m_pimpl->DoGetSizeMM(&w, &h); | |
743 | return wxSize(w, h); | |
744 | } | |
f0875501 | 745 | |
2970ae54 RR |
746 | int GetDepth() const |
747 | { return m_pimpl->GetDepth(); } | |
748 | wxSize GetPPI() const | |
749 | { return m_pimpl->GetPPI(); } | |
750 | ||
6d52ca53 | 751 | virtual int GetResolution() const |
4f37154e | 752 | { return m_pimpl->GetResolution(); } |
f0875501 | 753 | |
2970ae54 | 754 | // Right-To-Left (RTL) modes |
f0875501 | 755 | |
2970ae54 RR |
756 | void SetLayoutDirection(wxLayoutDirection dir) |
757 | { m_pimpl->SetLayoutDirection( dir ); } | |
758 | wxLayoutDirection GetLayoutDirection() const | |
759 | { return m_pimpl->GetLayoutDirection(); } | |
f0875501 VZ |
760 | |
761 | // page and document | |
762 | ||
2970ae54 RR |
763 | bool StartDoc(const wxString& message) |
764 | { return m_pimpl->StartDoc(message); } | |
765 | void EndDoc() | |
766 | { m_pimpl->EndDoc(); } | |
767 | ||
768 | void StartPage() | |
769 | { m_pimpl->StartPage(); } | |
770 | void EndPage() | |
771 | { m_pimpl->EndPage(); } | |
772 | ||
773 | // bounding box | |
f0875501 | 774 | |
2970ae54 RR |
775 | void CalcBoundingBox(wxCoord x, wxCoord y) |
776 | { m_pimpl->CalcBoundingBox(x,y); } | |
777 | void ResetBoundingBox() | |
778 | { m_pimpl->ResetBoundingBox(); } | |
f0875501 | 779 | |
2970ae54 RR |
780 | wxCoord MinX() const |
781 | { return m_pimpl->MinX(); } | |
782 | wxCoord MaxX() const | |
783 | { return m_pimpl->MaxX(); } | |
784 | wxCoord MinY() const | |
785 | { return m_pimpl->MinY(); } | |
786 | wxCoord MaxY() const | |
787 | { return m_pimpl->MaxY(); } | |
f0875501 | 788 | |
2970ae54 RR |
789 | // setters and getters |
790 | ||
791 | void SetFont(const wxFont& font) | |
792 | { m_pimpl->SetFont( font ); } | |
f0875501 | 793 | const wxFont& GetFont() const |
2970ae54 | 794 | { return m_pimpl->GetFont(); } |
f0875501 | 795 | |
2970ae54 RR |
796 | void SetPen(const wxPen& pen) |
797 | { m_pimpl->SetPen( pen ); } | |
f0875501 | 798 | const wxPen& GetPen() const |
2970ae54 | 799 | { return m_pimpl->GetPen(); } |
f0875501 | 800 | |
2970ae54 RR |
801 | void SetBrush(const wxBrush& brush) |
802 | { m_pimpl->SetBrush( brush ); } | |
803 | const wxBrush& GetBrush() const | |
804 | { return m_pimpl->GetBrush(); } | |
f0875501 | 805 | |
2970ae54 RR |
806 | void SetBackground(const wxBrush& brush) |
807 | { m_pimpl->SetBackground( brush ); } | |
808 | const wxBrush& GetBackground() const | |
809 | { return m_pimpl->GetBackground(); } | |
f0875501 | 810 | |
2970ae54 | 811 | void SetBackgroundMode(int mode) |
ca7db61e | 812 | { m_pimpl->SetBackgroundMode( mode ); } |
2970ae54 | 813 | int GetBackgroundMode() const |
ca7db61e | 814 | { return m_pimpl->GetBackgroundMode(); } |
2970ae54 RR |
815 | |
816 | void SetTextForeground(const wxColour& colour) | |
817 | { m_pimpl->SetTextForeground(colour); } | |
818 | const wxColour& GetTextForeground() const | |
819 | { return m_pimpl->GetTextForeground(); } | |
f0875501 | 820 | |
2970ae54 RR |
821 | void SetTextBackground(const wxColour& colour) |
822 | { m_pimpl->SetTextBackground(colour); } | |
f0875501 | 823 | const wxColour& GetTextBackground() const |
2970ae54 RR |
824 | { return m_pimpl->GetTextBackground(); } |
825 | ||
826 | #if wxUSE_PALETTE | |
827 | void SetPalette(const wxPalette& palette) | |
828 | { m_pimpl->SetPalette(palette); } | |
829 | #endif // wxUSE_PALETTE | |
f0875501 | 830 | |
2970ae54 | 831 | // logical functions |
f0875501 | 832 | |
89efaf2b | 833 | void SetLogicalFunction(wxRasterOperationMode function) |
2970ae54 | 834 | { m_pimpl->SetLogicalFunction(function); } |
89efaf2b | 835 | wxRasterOperationMode GetLogicalFunction() const |
2970ae54 | 836 | { return m_pimpl->GetLogicalFunction(); } |
f0875501 | 837 | |
2970ae54 RR |
838 | // text measurement |
839 | ||
840 | wxCoord GetCharHeight() const | |
841 | { return m_pimpl->GetCharHeight(); } | |
842 | wxCoord GetCharWidth() const | |
843 | { return m_pimpl->GetCharWidth(); } | |
f0875501 | 844 | |
2970ae54 RR |
845 | void GetTextExtent(const wxString& string, |
846 | wxCoord *x, wxCoord *y, | |
847 | wxCoord *descent = NULL, | |
848 | wxCoord *externalLeading = NULL, | |
849 | const wxFont *theFont = NULL) const | |
850 | { m_pimpl->DoGetTextExtent(string, x, y, descent, externalLeading, theFont); } | |
851 | ||
852 | wxSize GetTextExtent(const wxString& string) const | |
853 | { | |
854 | wxCoord w, h; | |
855 | m_pimpl->DoGetTextExtent(string, &w, &h); | |
856 | return wxSize(w, h); | |
857 | } | |
f0875501 | 858 | |
2970ae54 RR |
859 | void GetMultiLineTextExtent(const wxString& string, |
860 | wxCoord *width, | |
861 | wxCoord *height, | |
862 | wxCoord *heightLine = NULL, | |
863 | const wxFont *font = NULL) const | |
864 | { m_pimpl->GetMultiLineTextExtent( string, width, height, heightLine, font ); } | |
f0875501 | 865 | |
2970ae54 RR |
866 | wxSize GetMultiLineTextExtent(const wxString& string) const |
867 | { | |
868 | wxCoord w, h; | |
869 | m_pimpl->GetMultiLineTextExtent(string, &w, &h); | |
870 | return wxSize(w, h); | |
871 | } | |
f0875501 | 872 | |
2970ae54 RR |
873 | bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const |
874 | { return m_pimpl->DoGetPartialTextExtents(text, widths); } | |
f0875501 | 875 | |
2970ae54 | 876 | // clearing |
f0875501 | 877 | |
2970ae54 RR |
878 | void Clear() |
879 | { m_pimpl->Clear(); } | |
880 | ||
881 | // clipping | |
882 | ||
883 | void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) | |
884 | { m_pimpl->DoSetClippingRegion(x, y, width, height); } | |
885 | void SetClippingRegion(const wxPoint& pt, const wxSize& sz) | |
886 | { m_pimpl->DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); } | |
887 | void SetClippingRegion(const wxRect& rect) | |
888 | { m_pimpl->DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); } | |
fdaad94e VZ |
889 | |
890 | // unlike the functions above, the coordinates of the region used in this | |
891 | // one are in device coordinates, not the logical ones | |
892 | void SetDeviceClippingRegion(const wxRegion& region) | |
893 | { m_pimpl->DoSetDeviceClippingRegion(region); } | |
894 | ||
895 | // this function is deprecated because its name is confusing: you may | |
896 | // expect it to work with logical coordinates but, in fact, it does exactly | |
897 | // the same thing as SetDeviceClippingRegion() | |
898 | // | |
899 | // please review the code using it and either replace it with calls to | |
900 | // SetDeviceClippingRegion() or correct it if it was [wrongly] passing | |
901 | // logical coordinates to this function | |
902 | wxDEPRECATED_INLINE(void SetClippingRegion(const wxRegion& region), | |
903 | SetDeviceClippingRegion(region); ) | |
2970ae54 RR |
904 | |
905 | void DestroyClippingRegion() | |
906 | { m_pimpl->DestroyClippingRegion(); } | |
907 | ||
908 | void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const | |
909 | { m_pimpl->DoGetClippingBox(x, y, w, h); } | |
910 | void GetClippingBox(wxRect& rect) const | |
911 | { m_pimpl->DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height); } | |
f0875501 | 912 | |
2970ae54 RR |
913 | // coordinates conversions and transforms |
914 | ||
915 | wxCoord DeviceToLogicalX(wxCoord x) const | |
916 | { return m_pimpl->DeviceToLogicalX(x); } | |
ca7db61e | 917 | wxCoord DeviceToLogicalY(wxCoord y) const |
2970ae54 | 918 | { return m_pimpl->DeviceToLogicalY(y); } |
ca7db61e | 919 | wxCoord DeviceToLogicalXRel(wxCoord x) const |
2970ae54 | 920 | { return m_pimpl->DeviceToLogicalXRel(x); } |
ca7db61e | 921 | wxCoord DeviceToLogicalYRel(wxCoord y) const |
2970ae54 | 922 | { return m_pimpl->DeviceToLogicalYRel(y); } |
ca7db61e | 923 | wxCoord LogicalToDeviceX(wxCoord x) const |
2970ae54 | 924 | { return m_pimpl->LogicalToDeviceX(x); } |
ca7db61e | 925 | wxCoord LogicalToDeviceY(wxCoord y) const |
2970ae54 | 926 | { return m_pimpl->LogicalToDeviceY(y); } |
ca7db61e | 927 | wxCoord LogicalToDeviceXRel(wxCoord x) const |
2970ae54 | 928 | { return m_pimpl->LogicalToDeviceXRel(x); } |
ca7db61e | 929 | wxCoord LogicalToDeviceYRel(wxCoord y) const |
2970ae54 RR |
930 | { return m_pimpl->LogicalToDeviceYRel(y); } |
931 | ||
89efaf2b | 932 | void SetMapMode(wxMappingMode mode) |
2970ae54 | 933 | { m_pimpl->SetMapMode(mode); } |
89efaf2b | 934 | wxMappingMode GetMapMode() const |
2970ae54 RR |
935 | { return m_pimpl->GetMapMode(); } |
936 | ||
937 | void SetUserScale(double x, double y) | |
938 | { m_pimpl->SetUserScale(x,y); } | |
939 | void GetUserScale(double *x, double *y) const | |
940 | { m_pimpl->GetUserScale( x, y ); } | |
941 | ||
942 | void SetLogicalScale(double x, double y) | |
943 | { m_pimpl->SetLogicalScale( x, y ); } | |
944 | void GetLogicalScale(double *x, double *y) | |
945 | { m_pimpl->GetLogicalScale( x, y ); } | |
946 | ||
947 | void SetLogicalOrigin(wxCoord x, wxCoord y) | |
948 | { m_pimpl->SetLogicalOrigin(x,y); } | |
949 | void GetLogicalOrigin(wxCoord *x, wxCoord *y) const | |
950 | { m_pimpl->DoGetLogicalOrigin(x, y); } | |
951 | wxPoint GetLogicalOrigin() const | |
952 | { wxCoord x, y; m_pimpl->DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); } | |
953 | ||
954 | void SetDeviceOrigin(wxCoord x, wxCoord y) | |
955 | { m_pimpl->SetDeviceOrigin( x, y); } | |
956 | void GetDeviceOrigin(wxCoord *x, wxCoord *y) const | |
957 | { m_pimpl->DoGetDeviceOrigin(x, y); } | |
958 | wxPoint GetDeviceOrigin() const | |
959 | { wxCoord x, y; m_pimpl->DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); } | |
960 | ||
961 | void SetAxisOrientation(bool xLeftRight, bool yBottomUp) | |
962 | { m_pimpl->SetAxisOrientation(xLeftRight, yBottomUp); } | |
f0875501 VZ |
963 | |
964 | // mostly internal | |
2970ae54 RR |
965 | void SetDeviceLocalOrigin( wxCoord x, wxCoord y ) |
966 | { m_pimpl->SetDeviceLocalOrigin( x, y ); } | |
967 | ||
968 | ||
2970ae54 RR |
969 | // ----------------------------------------------- |
970 | // the actual drawing API | |
971 | ||
972 | bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, | |
89efaf2b | 973 | wxFloodFillStyle style = wxFLOOD_SURFACE) |
2970ae54 RR |
974 | { return m_pimpl->DoFloodFill(x, y, col, style); } |
975 | bool FloodFill(const wxPoint& pt, const wxColour& col, | |
89efaf2b | 976 | wxFloodFillStyle style = wxFLOOD_SURFACE) |
2970ae54 RR |
977 | { return m_pimpl->DoFloodFill(pt.x, pt.y, col, style); } |
978 | ||
979 | // fill the area specified by rect with a radial gradient, starting from | |
980 | // initialColour in the centre of the cercle and fading to destColour. | |
981 | void GradientFillConcentric(const wxRect& rect, | |
982 | const wxColour& initialColour, | |
983 | const wxColour& destColour) | |
ca7db61e RR |
984 | { m_pimpl->DoGradientFillConcentric( rect, initialColour, destColour, |
985 | wxPoint(rect.GetWidth() / 2, | |
986 | rect.GetHeight() / 2)); } | |
2970ae54 RR |
987 | |
988 | void GradientFillConcentric(const wxRect& rect, | |
989 | const wxColour& initialColour, | |
990 | const wxColour& destColour, | |
991 | const wxPoint& circleCenter) | |
992 | { m_pimpl->DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); } | |
993 | ||
994 | // fill the area specified by rect with a linear gradient | |
995 | void GradientFillLinear(const wxRect& rect, | |
996 | const wxColour& initialColour, | |
997 | const wxColour& destColour, | |
998 | wxDirection nDirection = wxEAST) | |
999 | { m_pimpl->DoGradientFillLinear(rect, initialColour, destColour, nDirection); } | |
1000 | ||
1001 | bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const | |
1002 | { return m_pimpl->DoGetPixel(x, y, col); } | |
1003 | bool GetPixel(const wxPoint& pt, wxColour *col) const | |
1004 | { return m_pimpl->DoGetPixel(pt.x, pt.y, col); } | |
1005 | ||
1006 | void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) | |
1007 | { m_pimpl->DoDrawLine(x1, y1, x2, y2); } | |
1008 | void DrawLine(const wxPoint& pt1, const wxPoint& pt2) | |
1009 | { m_pimpl->DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); } | |
1010 | ||
1011 | void CrossHair(wxCoord x, wxCoord y) | |
1012 | { m_pimpl->DoCrossHair(x, y); } | |
1013 | void CrossHair(const wxPoint& pt) | |
1014 | { m_pimpl->DoCrossHair(pt.x, pt.y); } | |
1015 | ||
1016 | void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, | |
1017 | wxCoord xc, wxCoord yc) | |
1018 | { m_pimpl->DoDrawArc(x1, y1, x2, y2, xc, yc); } | |
1019 | void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre) | |
1020 | { m_pimpl->DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); } | |
1021 | ||
1022 | void DrawCheckMark(wxCoord x, wxCoord y, | |
1023 | wxCoord width, wxCoord height) | |
1024 | { m_pimpl->DoDrawCheckMark(x, y, width, height); } | |
1025 | void DrawCheckMark(const wxRect& rect) | |
1026 | { m_pimpl->DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); } | |
1027 | ||
1028 | void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, | |
1029 | double sa, double ea) | |
1030 | { m_pimpl->DoDrawEllipticArc(x, y, w, h, sa, ea); } | |
1031 | void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, | |
1032 | double sa, double ea) | |
1033 | { m_pimpl->DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); } | |
1034 | ||
1035 | void DrawPoint(wxCoord x, wxCoord y) | |
1036 | { m_pimpl->DoDrawPoint(x, y); } | |
1037 | void DrawPoint(const wxPoint& pt) | |
1038 | { m_pimpl->DoDrawPoint(pt.x, pt.y); } | |
1039 | ||
1040 | void DrawLines(int n, wxPoint points[], | |
1041 | wxCoord xoffset = 0, wxCoord yoffset = 0) | |
1042 | { m_pimpl->DoDrawLines(n, points, xoffset, yoffset); } | |
b0d7707b | 1043 | void DrawLines(const wxPointList *list, |
2970ae54 | 1044 | wxCoord xoffset = 0, wxCoord yoffset = 0) |
f0875501 | 1045 | { m_pimpl->DrawLines( list, xoffset, yoffset ); } |
4f37154e RR |
1046 | #if WXWIN_COMPATIBILITY_2_8 |
1047 | wxDEPRECATED( void DrawLines(const wxList *list, | |
1048 | wxCoord xoffset = 0, wxCoord yoffset = 0) ); | |
1049 | #endif // WXWIN_COMPATIBILITY_2_8 | |
2970ae54 RR |
1050 | |
1051 | void DrawPolygon(int n, wxPoint points[], | |
1052 | wxCoord xoffset = 0, wxCoord yoffset = 0, | |
89efaf2b | 1053 | wxPolygonFillMode fillStyle = wxODDEVEN_RULE) |
2970ae54 | 1054 | { m_pimpl->DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); } |
b0d7707b | 1055 | void DrawPolygon(const wxPointList *list, |
2970ae54 | 1056 | wxCoord xoffset = 0, wxCoord yoffset = 0, |
89efaf2b | 1057 | wxPolygonFillMode fillStyle = wxODDEVEN_RULE) |
2970ae54 | 1058 | { m_pimpl->DrawPolygon( list, xoffset, yoffset, fillStyle ); } |
2970ae54 RR |
1059 | void DrawPolyPolygon(int n, int count[], wxPoint points[], |
1060 | wxCoord xoffset = 0, wxCoord yoffset = 0, | |
89efaf2b | 1061 | wxPolygonFillMode fillStyle = wxODDEVEN_RULE) |
2970ae54 | 1062 | { m_pimpl->DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); } |
4f37154e RR |
1063 | #if WXWIN_COMPATIBILITY_2_8 |
1064 | wxDEPRECATED( void DrawPolygon(const wxList *list, | |
1065 | wxCoord xoffset = 0, wxCoord yoffset = 0, | |
89efaf2b | 1066 | wxPolygonFillMode fillStyle = wxODDEVEN_RULE) ); |
4f37154e | 1067 | #endif // WXWIN_COMPATIBILITY_2_8 |
2970ae54 RR |
1068 | |
1069 | void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) | |
1070 | { m_pimpl->DoDrawRectangle(x, y, width, height); } | |
1071 | void DrawRectangle(const wxPoint& pt, const wxSize& sz) | |
1072 | { m_pimpl->DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); } | |
1073 | void DrawRectangle(const wxRect& rect) | |
1074 | { m_pimpl->DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); } | |
1075 | ||
1076 | void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, | |
1077 | double radius) | |
1078 | { m_pimpl->DoDrawRoundedRectangle(x, y, width, height, radius); } | |
1079 | void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, | |
1080 | double radius) | |
1081 | { m_pimpl->DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); } | |
1082 | void DrawRoundedRectangle(const wxRect& r, double radius) | |
1083 | { m_pimpl->DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); } | |
1084 | ||
1085 | void DrawCircle(wxCoord x, wxCoord y, wxCoord radius) | |
1086 | { m_pimpl->DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); } | |
1087 | void DrawCircle(const wxPoint& pt, wxCoord radius) | |
ca7db61e | 1088 | { m_pimpl->DoDrawEllipse(pt.x - radius, pt.y - radius, 2*radius, 2*radius); } |
2970ae54 RR |
1089 | |
1090 | void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) | |
1091 | { m_pimpl->DoDrawEllipse(x, y, width, height); } | |
1092 | void DrawEllipse(const wxPoint& pt, const wxSize& sz) | |
1093 | { m_pimpl->DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); } | |
1094 | void DrawEllipse(const wxRect& rect) | |
1095 | { m_pimpl->DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); } | |
1096 | ||
1097 | void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) | |
1098 | { m_pimpl->DoDrawIcon(icon, x, y); } | |
1099 | void DrawIcon(const wxIcon& icon, const wxPoint& pt) | |
1100 | { m_pimpl->DoDrawIcon(icon, pt.x, pt.y); } | |
1101 | ||
1102 | void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
1103 | bool useMask = false) | |
1104 | { m_pimpl->DoDrawBitmap(bmp, x, y, useMask); } | |
1105 | void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, | |
1106 | bool useMask = false) | |
1107 | { m_pimpl->DoDrawBitmap(bmp, pt.x, pt.y, useMask); } | |
1108 | ||
1109 | void DrawText(const wxString& text, wxCoord x, wxCoord y) | |
1110 | { m_pimpl->DoDrawText(text, x, y); } | |
1111 | void DrawText(const wxString& text, const wxPoint& pt) | |
1112 | { m_pimpl->DoDrawText(text, pt.x, pt.y); } | |
1113 | ||
1114 | void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) | |
1115 | { m_pimpl->DoDrawRotatedText(text, x, y, angle); } | |
1116 | void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle) | |
1117 | { m_pimpl->DoDrawRotatedText(text, pt.x, pt.y, angle); } | |
1118 | ||
1119 | // this version puts both optional bitmap and the text into the given | |
1120 | // rectangle and aligns is as specified by alignment parameter; it also | |
1121 | // will emphasize the character with the given index if it is != -1 and | |
1122 | // return the bounding rectangle if required | |
1123 | void DrawLabel(const wxString& text, | |
1124 | const wxBitmap& image, | |
1125 | const wxRect& rect, | |
1126 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
1127 | int indexAccel = -1, | |
ca7db61e | 1128 | wxRect *rectBounding = NULL); |
2970ae54 RR |
1129 | |
1130 | void DrawLabel(const wxString& text, const wxRect& rect, | |
1131 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
1132 | int indexAccel = -1) | |
ca7db61e | 1133 | { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); } |
2970ae54 RR |
1134 | |
1135 | bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, | |
1136 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
89efaf2b FM |
1137 | wxRasterOperationMode rop = wxCOPY, bool useMask = false, |
1138 | wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) | |
2970ae54 RR |
1139 | { |
1140 | return m_pimpl->DoBlit(xdest, ydest, width, height, | |
1141 | source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask); | |
1142 | } | |
1143 | bool Blit(const wxPoint& destPt, const wxSize& sz, | |
1144 | wxDC *source, const wxPoint& srcPt, | |
89efaf2b FM |
1145 | wxRasterOperationMode rop = wxCOPY, bool useMask = false, |
1146 | const wxPoint& srcPtMask = wxDefaultPosition) | |
2970ae54 RR |
1147 | { |
1148 | return m_pimpl->DoBlit(destPt.x, destPt.y, sz.x, sz.y, | |
1149 | source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y); | |
1150 | } | |
1151 | ||
f0875501 | 1152 | bool StretchBlit(wxCoord dstX, wxCoord dstY, |
2970ae54 | 1153 | wxCoord dstWidth, wxCoord dstHeight, |
f0875501 | 1154 | wxDC *source, |
2970ae54 RR |
1155 | wxCoord srcX, wxCoord srcY, |
1156 | wxCoord srcWidth, wxCoord srcHeight, | |
89efaf2b | 1157 | wxRasterOperationMode rop = wxCOPY, bool useMask = false, |
2970ae54 RR |
1158 | wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord) |
1159 | { | |
1160 | return m_pimpl->DoStretchBlit(dstX, dstY, dstWidth, dstHeight, | |
1161 | source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY); | |
1162 | } | |
1163 | bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize, | |
1164 | wxDC *source, const wxPoint& srcPt, const wxSize& srcSize, | |
89efaf2b FM |
1165 | wxRasterOperationMode rop = wxCOPY, bool useMask = false, |
1166 | const wxPoint& srcMaskPt = wxDefaultPosition) | |
2970ae54 RR |
1167 | { |
1168 | return m_pimpl->DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y, | |
1169 | source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y); | |
1170 | } | |
1171 | ||
1172 | wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const | |
1173 | { | |
1174 | return m_pimpl->DoGetAsBitmap(subrect); | |
1175 | } | |
1176 | ||
1177 | #if wxUSE_SPLINES | |
2970ae54 RR |
1178 | void DrawSpline(wxCoord x1, wxCoord y1, |
1179 | wxCoord x2, wxCoord y2, | |
1180 | wxCoord x3, wxCoord y3) | |
7210c3a1 | 1181 | { m_pimpl->DrawSpline(x1,y1,x2,y2,x3,y3); } |
2970ae54 | 1182 | void DrawSpline(int n, wxPoint points[]) |
7210c3a1 | 1183 | { m_pimpl->DrawSpline(n,points); } |
f0875501 | 1184 | void DrawSpline(const wxPointList *points) |
7210c3a1 | 1185 | { m_pimpl->DrawSpline(points); } |
2970ae54 RR |
1186 | #endif // wxUSE_SPLINES |
1187 | ||
1188 | ||
1189 | #if WXWIN_COMPATIBILITY_2_8 | |
1190 | // for compatibility with the old code when wxCoord was long everywhere | |
1191 | wxDEPRECATED( void GetTextExtent(const wxString& string, | |
1192 | long *x, long *y, | |
1193 | long *descent = NULL, | |
1194 | long *externalLeading = NULL, | |
1195 | const wxFont *theFont = NULL) const ); | |
1196 | wxDEPRECATED( void GetLogicalOrigin(long *x, long *y) const ); | |
1197 | wxDEPRECATED( void GetDeviceOrigin(long *x, long *y) const ); | |
1198 | wxDEPRECATED( void GetClippingBox(long *x, long *y, long *w, long *h) const ); | |
f5725872 | 1199 | |
713e9290 | 1200 | wxDEPRECATED( void DrawObject(wxDrawObject* drawobject) ); |
2970ae54 RR |
1201 | #endif // WXWIN_COMPATIBILITY_2_8 |
1202 | ||
f5725872 VZ |
1203 | #ifdef __WXMSW__ |
1204 | WXHDC GetHDC() const; | |
1205 | #endif // __WXMSW__ | |
2970ae54 RR |
1206 | |
1207 | protected: | |
f0875501 VZ |
1208 | // ctor takes ownership of the pointer |
1209 | wxDC(wxDCImpl *pimpl) : m_pimpl(pimpl) { } | |
1210 | ||
1211 | wxDCImpl * const m_pimpl; | |
aec43716 | 1212 | |
ca7db61e | 1213 | private: |
888dde65 | 1214 | DECLARE_ABSTRACT_CLASS(wxDC) |
f0875501 | 1215 | DECLARE_NO_COPY_CLASS(wxDC) |
ca7db61e | 1216 | }; |
aec43716 | 1217 | |
1e6feb95 VZ |
1218 | // ---------------------------------------------------------------------------- |
1219 | // helper class: you can use it to temporarily change the DC text colour and | |
1220 | // restore it automatically when the object goes out of scope | |
1221 | // ---------------------------------------------------------------------------- | |
1222 | ||
53a2db12 | 1223 | class WXDLLIMPEXP_CORE wxDCTextColourChanger |
1e6feb95 VZ |
1224 | { |
1225 | public: | |
ba161d7e | 1226 | wxDCTextColourChanger(wxDC& dc) : m_dc(dc), m_colFgOld() { } |
1e6feb95 | 1227 | |
1b97b23d VS |
1228 | wxDCTextColourChanger(wxDC& dc, const wxColour& col) : m_dc(dc) |
1229 | { | |
1230 | Set(col); | |
1231 | } | |
1232 | ||
1e6feb95 VZ |
1233 | ~wxDCTextColourChanger() |
1234 | { | |
1235 | if ( m_colFgOld.Ok() ) | |
1236 | m_dc.SetTextForeground(m_colFgOld); | |
1237 | } | |
1238 | ||
1239 | void Set(const wxColour& col) | |
1240 | { | |
1241 | if ( !m_colFgOld.Ok() ) | |
1242 | m_colFgOld = m_dc.GetTextForeground(); | |
1243 | m_dc.SetTextForeground(col); | |
1244 | } | |
1245 | ||
1246 | private: | |
1247 | wxDC& m_dc; | |
1248 | ||
1249 | wxColour m_colFgOld; | |
fc7a2a60 VZ |
1250 | |
1251 | DECLARE_NO_COPY_CLASS(wxDCTextColourChanger) | |
1e6feb95 VZ |
1252 | }; |
1253 | ||
4660e6ac WS |
1254 | // ---------------------------------------------------------------------------- |
1255 | // helper class: you can use it to temporarily change the DC pen and | |
1256 | // restore it automatically when the object goes out of scope | |
1257 | // ---------------------------------------------------------------------------- | |
1258 | ||
53a2db12 | 1259 | class WXDLLIMPEXP_CORE wxDCPenChanger |
4660e6ac WS |
1260 | { |
1261 | public: | |
0164f8eb WS |
1262 | wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen()) |
1263 | { | |
1264 | m_dc.SetPen(pen); | |
1265 | } | |
4660e6ac WS |
1266 | |
1267 | ~wxDCPenChanger() | |
1268 | { | |
1269 | if ( m_penOld.Ok() ) | |
1270 | m_dc.SetPen(m_penOld); | |
1271 | } | |
1272 | ||
4660e6ac WS |
1273 | private: |
1274 | wxDC& m_dc; | |
1275 | ||
1276 | wxPen m_penOld; | |
1277 | ||
1278 | DECLARE_NO_COPY_CLASS(wxDCPenChanger) | |
1279 | }; | |
1280 | ||
1281 | // ---------------------------------------------------------------------------- | |
1282 | // helper class: you can use it to temporarily change the DC brush and | |
1283 | // restore it automatically when the object goes out of scope | |
1284 | // ---------------------------------------------------------------------------- | |
1285 | ||
53a2db12 | 1286 | class WXDLLIMPEXP_CORE wxDCBrushChanger |
4660e6ac WS |
1287 | { |
1288 | public: | |
0164f8eb WS |
1289 | wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush()) |
1290 | { | |
1291 | m_dc.SetBrush(brush); | |
1292 | } | |
4660e6ac WS |
1293 | |
1294 | ~wxDCBrushChanger() | |
1295 | { | |
1296 | if ( m_brushOld.Ok() ) | |
1297 | m_dc.SetBrush(m_brushOld); | |
1298 | } | |
1299 | ||
4660e6ac WS |
1300 | private: |
1301 | wxDC& m_dc; | |
1302 | ||
1303 | wxBrush m_brushOld; | |
1304 | ||
1305 | DECLARE_NO_COPY_CLASS(wxDCBrushChanger) | |
1306 | }; | |
1307 | ||
e26be42b VZ |
1308 | // ---------------------------------------------------------------------------- |
1309 | // another small helper class: sets the clipping region in its ctor and | |
1310 | // destroys it in the dtor | |
1311 | // ---------------------------------------------------------------------------- | |
1312 | ||
53a2db12 | 1313 | class WXDLLIMPEXP_CORE wxDCClipper |
e26be42b VZ |
1314 | { |
1315 | public: | |
fc298ea7 | 1316 | wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc) |
fdaad94e | 1317 | { dc.SetClippingRegion(r.GetBox()); } |
e26be42b VZ |
1318 | wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc) |
1319 | { dc.SetClippingRegion(r.x, r.y, r.width, r.height); } | |
1320 | wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc) | |
1321 | { dc.SetClippingRegion(x, y, w, h); } | |
1322 | ||
1323 | ~wxDCClipper() { m_dc.DestroyClippingRegion(); } | |
1324 | ||
1325 | private: | |
1326 | wxDC& m_dc; | |
fc7a2a60 VZ |
1327 | |
1328 | DECLARE_NO_COPY_CLASS(wxDCClipper) | |
e26be42b VZ |
1329 | }; |
1330 | ||
c48d6cdf FM |
1331 | // ---------------------------------------------------------------------------- |
1332 | // helper class: you can use it to temporarily change the DC font and | |
1333 | // restore it automatically when the object goes out of scope | |
1334 | // ---------------------------------------------------------------------------- | |
1335 | ||
1336 | class WXDLLIMPEXP_CORE wxDCFontChanger | |
1337 | { | |
1338 | public: | |
1339 | wxDCFontChanger(wxDC& dc, const wxFont& font) : m_dc(dc), m_fontOld(dc.GetFont()) | |
1340 | { | |
1341 | m_dc.SetFont(font); | |
1342 | } | |
1343 | ||
1344 | ~wxDCFontChanger() | |
1345 | { | |
1346 | if ( m_fontOld.Ok() ) | |
1347 | m_dc.SetFont(m_fontOld); | |
1348 | } | |
1349 | ||
1350 | private: | |
1351 | wxDC& m_dc; | |
1352 | ||
1353 | wxFont m_fontOld; | |
1354 | ||
1355 | DECLARE_NO_COPY_CLASS(wxDCFontChanger) | |
1356 | }; | |
1357 | ||
1358 | ||
8b56b16a | 1359 | #endif // _WX_DC_H_BASE_ |