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