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