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