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