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