]>
Commit | Line | Data |
---|---|---|
006162a9 | 1 | ///////////////////////////////////////////////////////////////////////////// |
4660e6ac | 2 | // Name: wx/dc.h |
006162a9 VZ |
3 | // Purpose: wxDC class |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 05/25/99 | |
7 | // RCS-ID: $Id$ | |
77ffb593 | 8 | // Copyright: (c) wxWidgets team |
65571936 | 9 | // Licence: wxWindows licence |
006162a9 VZ |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
34138703 JS |
12 | #ifndef _WX_DC_H_BASE_ |
13 | #define _WX_DC_H_BASE_ | |
c801d85f | 14 | |
a23fd0e1 VZ |
15 | // ---------------------------------------------------------------------------- |
16 | // headers which we must include here | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | #include "wx/object.h" // the base class | |
20 | ||
0d80fb31 | 21 | #include "wx/intl.h" // for wxLayoutDirection |
a23fd0e1 VZ |
22 | #include "wx/cursor.h" // we have member variables of these classes |
23 | #include "wx/font.h" // so we can't do without them | |
24 | #include "wx/colour.h" | |
b494e2b0 | 25 | #include "wx/bitmap.h" // for wxNullBitmap |
a23fd0e1 VZ |
26 | #include "wx/brush.h" |
27 | #include "wx/pen.h" | |
28 | #include "wx/palette.h" | |
a23fd0e1 | 29 | #include "wx/list.h" // we use wxList in inline functions |
0919e93e | 30 | #include "wx/dynarray.h" |
19edb09c | 31 | #include "wx/math.h" |
02255e07 | 32 | #include "wx/image.h" |
a23fd0e1 | 33 | |
2970ae54 RR |
34 | // 1 if using the reorganized DC code |
35 | #define wxUSE_NEW_DC 0 | |
36 | ||
37 | ||
38 | #if wxUSE_NEW_DC | |
39 | ||
40 | //----------------------------------------------------------------------------- | |
41 | // wxDCFactory | |
42 | //----------------------------------------------------------------------------- | |
43 | ||
b5dbe15d | 44 | class WXDLLIMPEXP_FWD_CORE wxImplDC; |
2970ae54 RR |
45 | |
46 | class WXDLLIMPEXP_CORE wxDCFactory | |
47 | { | |
48 | public: | |
49 | wxDCFactory() {} | |
50 | virtual ~wxDCFactory() {} | |
51 | ||
52 | virtual wxImplDC* CreateWindowDC() = 0; | |
53 | virtual wxImplDC* CreateWindowDC( wxWindow *window ) = 0; | |
54 | virtual wxImplDC* CreateClientDC() = 0; | |
55 | virtual wxImplDC* CreateClientDC( wxWindow *window ) = 0; | |
56 | virtual wxImplDC* CreatePaintDC() = 0; | |
57 | virtual wxImplDC* CreatePaintDC( wxWindow *window ) = 0; | |
58 | virtual wxImplDC* CreateMemoryDC() = 0; | |
59 | virtual wxImplDC* CreateMemoryDC( wxBitmap &bitmap ) = 0; | |
60 | virtual wxImplDC* CreateMemoryDC( wxDC *dc ) = 0; | |
61 | ||
62 | static void SetDCFactory( wxDCFactory *factory ); | |
63 | static wxDCFactory *GetFactory(); | |
64 | private: | |
65 | static wxDCFactory *m_factory; | |
66 | }; | |
67 | ||
68 | //----------------------------------------------------------------------------- | |
69 | // wxNativeDCFactory | |
70 | //----------------------------------------------------------------------------- | |
71 | ||
72 | class WXDLLIMPEXP_CORE wxDCFactory | |
73 | { | |
74 | public: | |
75 | wxNativeDCFactory() {} | |
76 | ||
77 | virtual wxImplDC* CreateWindowDC(); | |
78 | virtual wxImplDC* CreateWindowDC( wxWindow *window ); | |
79 | virtual wxImplDC* CreateClientDC(); | |
80 | virtual wxImplDC* CreateClientDC( wxWindow *window ); | |
81 | virtual wxImplDC* CreatePaintDC(); | |
82 | virtual wxImplDC* CreatePaintDC( wxWindow *window ); | |
83 | virtual wxImplDC* CreateMemoryDC(); | |
84 | virtual wxImplDC* CreateMemoryDC( wxBitmap &bitmap ); | |
85 | virtual wxImplDC* CreateMemoryDC( wxDC *dc ); | |
86 | }; | |
87 | ||
88 | //----------------------------------------------------------------------------- | |
89 | // wxWindowDC | |
90 | //----------------------------------------------------------------------------- | |
91 | ||
92 | class WXDLLIMPEXP_CORE wxWindowDC : public wxDC | |
93 | { | |
94 | public: | |
95 | wxWindowDC(); | |
96 | wxWindowDC( wxWindow *win ); | |
97 | ||
98 | private: | |
99 | DECLARE_DYNAMIC_CLASS(wxWindowDC) | |
100 | }; | |
101 | ||
102 | //----------------------------------------------------------------------------- | |
103 | // wxClientDC | |
104 | //----------------------------------------------------------------------------- | |
105 | ||
106 | class WXDLLIMPEXP_CORE wxClientDC : public wxDC | |
107 | { | |
108 | public: | |
109 | wxClientDC(); | |
110 | wxClientDC( wxWindow *win ); | |
111 | ||
112 | private: | |
113 | DECLARE_DYNAMIC_CLASS(wxClientDC) | |
114 | }; | |
115 | ||
116 | //----------------------------------------------------------------------------- | |
117 | // wxMemoryDC | |
118 | //----------------------------------------------------------------------------- | |
119 | ||
120 | class WXDLLIMPEXP_CORE wxMemoryDC: public wxDC | |
121 | { | |
122 | public: | |
123 | wxMemoryDC(); | |
124 | wxMemoryDC( wxBitmap& bitmap ); | |
125 | wxMemoryDC( wxDC *dc ); | |
126 | ||
127 | private: | |
128 | DECLARE_DYNAMIC_CLASS(wxMemoryDC) | |
129 | }; | |
130 | ||
131 | //----------------------------------------------------------------------------- | |
132 | // wxPaintDC | |
133 | //----------------------------------------------------------------------------- | |
134 | ||
135 | class WXDLLIMPEXP_CORE wxPaintDC : public wxDC | |
136 | { | |
137 | public: | |
138 | wxPaintDC(); | |
139 | wxPaintDC( wxWindow *win ); | |
140 | ||
141 | private: | |
142 | DECLARE_DYNAMIC_CLASS(wxPaintDC) | |
143 | }; | |
144 | ||
145 | //----------------------------------------------------------------------------- | |
146 | // wxImplDC | |
147 | //----------------------------------------------------------------------------- | |
148 | ||
149 | class WXDLLIMPEXP_CORE wxImplDC: public wxObject | |
150 | { | |
151 | public: | |
152 | wxImplDC( wxDC *owner ); | |
153 | ~wxImplDC(); | |
154 | ||
155 | wxDC *GetOwner() { return m_owner; } | |
156 | ||
157 | virtual bool IsOk() const { return m_ok; } | |
158 | ||
159 | // query capabilities | |
160 | ||
161 | virtual bool CanDrawBitmap() const = 0; | |
162 | virtual bool CanGetTextExtent() const = 0; | |
163 | ||
164 | // query dimension, colour deps, resolution | |
165 | ||
166 | virtual void DoGetSize(int *width, int *height) const = 0; | |
167 | virtual void DoGetSizeMM(int* width, int* height) const = 0; | |
168 | ||
169 | virtual int GetDepth() const = 0; | |
170 | virtual wxSize GetPPI() const = 0; | |
171 | ||
172 | // Right-To-Left (RTL) modes | |
173 | ||
174 | virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) { } | |
175 | virtual wxLayoutDirection GetLayoutDirection() const { return wxLayout_Default; } | |
176 | ||
177 | // page and document | |
178 | ||
179 | virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; } | |
180 | virtual void EndDoc() { } | |
181 | ||
182 | virtual void StartPage() { } | |
183 | virtual void EndPage() { } | |
184 | ||
185 | // bounding box | |
186 | ||
187 | virtual void CalcBoundingBox(wxCoord x, wxCoord y); | |
188 | { | |
189 | if ( m_isBBoxValid ) | |
190 | { | |
191 | if ( x < m_minX ) m_minX = x; | |
192 | if ( y < m_minY ) m_minY = y; | |
193 | if ( x > m_maxX ) m_maxX = x; | |
194 | if ( y > m_maxY ) m_maxY = y; | |
195 | } | |
196 | else | |
197 | { | |
198 | m_isBBoxValid = true; | |
199 | ||
200 | m_minX = x; | |
201 | m_minY = y; | |
202 | m_maxX = x; | |
203 | m_maxY = y; | |
204 | } | |
205 | } | |
206 | void ResetBoundingBox(); | |
207 | { | |
208 | m_isBBoxValid = false; | |
209 | ||
210 | m_minX = m_maxX = m_minY = m_maxY = 0; | |
211 | } | |
212 | ||
213 | wxCoord MinX() const { return m_minX; } | |
214 | wxCoord MaxX() const { return m_maxX; } | |
215 | wxCoord MinY() const { return m_minY; } | |
216 | wxCoord MaxY() const { return m_maxY; } | |
217 | ||
218 | // setters and getters | |
219 | ||
220 | virtual void SetFont(const wxFont& font) = 0; | |
221 | virtual const wxFont& GetFont() const { return m_font; } | |
222 | ||
223 | virtual void SetPen(const wxPen& pen) = 0; | |
224 | virtual const wxPen& GetPen() const { return m_pen; } | |
225 | ||
226 | virtual void SetBrush(const wxBrush& brush) = 0; | |
227 | virtual const wxBrush& GetBrush() const { return m_brush; } | |
228 | ||
229 | virtual void SetBackground(const wxBrush& brush) = 0; | |
230 | virtual const wxBrush& GetBackground() const { return m_backgroundBrush; } | |
231 | ||
232 | virtual void SetBackgroundMode(int mode) = 0; | |
233 | virtual int GetBackgroundMode() const { return m_backgroundMode; } | |
234 | ||
235 | virtual void SetTextForeground(const wxColour& colour) | |
236 | { m_textForegroundColour = colour; } | |
237 | virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; } | |
238 | ||
239 | virtual void SetTextBackground(const wxColour& colour) | |
240 | { m_textBackgroundColour = colour; } | |
241 | virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; } | |
242 | ||
243 | #if wxUSE_PALETTE | |
244 | virtual void SetPalette(const wxPalette& palette) = 0; | |
245 | #endif // wxUSE_PALETTE | |
246 | ||
247 | // logical functions | |
248 | ||
249 | virtual void SetLogicalFunction(int function) = 0; | |
250 | virtual int GetLogicalFunction() const { return m_logicalFunction; } | |
251 | ||
252 | // text measurement | |
253 | ||
254 | virtual wxCoord GetCharHeight() const = 0; | |
255 | virtual wxCoord GetCharWidth() const = 0; | |
256 | virtual void DoGetTextExtent(const wxString& string, | |
257 | wxCoord *x, wxCoord *y, | |
258 | wxCoord *descent = NULL, | |
259 | wxCoord *externalLeading = NULL, | |
260 | const wxFont *theFont = NULL) const = 0; | |
261 | virtual void GetMultiLineTextExtent(const wxString& string, | |
262 | wxCoord *width, | |
263 | wxCoord *height, | |
264 | wxCoord *heightLine = NULL, | |
265 | const wxFont *font = NULL) const; | |
266 | virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const; | |
267 | ||
268 | // clearing | |
269 | ||
270 | virtual void Clear() = 0; | |
271 | ||
272 | // clipping | |
273 | ||
274 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, | |
275 | wxCoord width, wxCoord height) = 0; | |
276 | virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0; | |
277 | ||
278 | virtual void DoGetClippingBox(wxCoord *x, wxCoord *y, | |
279 | wxCoord *w, wxCoord *h) const | |
280 | { | |
281 | if ( x ) | |
282 | *x = m_clipX1; | |
283 | if ( y ) | |
284 | *y = m_clipY1; | |
285 | if ( w ) | |
286 | *w = m_clipX2 - m_clipX1; | |
287 | if ( h ) | |
288 | *h = m_clipY2 - m_clipY1; | |
289 | } | |
290 | ||
291 | virtual void DestroyClippingRegion() { ResetClipping(); } | |
292 | ||
293 | ||
294 | // coordinates conversions and transforms | |
295 | ||
296 | virtual wxCoord DeviceToLogicalX(wxCoord x) const; | |
297 | virtual wxCoord DeviceToLogicalY(wxCoord y) const; | |
298 | virtual wxCoord DeviceToLogicalXRel(wxCoord x) const; | |
299 | virtual wxCoord DeviceToLogicalYRel(wxCoord y) const; | |
300 | virtual wxCoord LogicalToDeviceX(wxCoord x) const; | |
301 | virtual wxCoord LogicalToDeviceY(wxCoord y) const; | |
302 | virtual wxCoord LogicalToDeviceXRel(wxCoord x) const; | |
303 | virtual wxCoord LogicalToDeviceYRel(wxCoord y) const; | |
304 | ||
305 | virtual void SetMapMode(int mode); | |
306 | virtual int GetMapMode() const { return m_mappingMode; } | |
307 | ||
308 | virtual void SetUserScale(double x, double y); | |
309 | virtual void GetUserScale(double *x, double *y) const | |
310 | { | |
311 | if ( x ) *x = m_userScaleX; | |
312 | if ( y ) *y = m_userScaleY; | |
313 | } | |
314 | ||
315 | virtual void SetLogicalScale(double x, double y); | |
316 | virtual void GetLogicalScale(double *x, double *y) | |
317 | { | |
318 | if ( x ) *x = m_logicalScaleX; | |
319 | if ( y ) *y = m_logicalScaleY; | |
320 | } | |
321 | ||
322 | virtual void SetLogicalOrigin(wxCoord x, wxCoord y); | |
323 | virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const | |
324 | { | |
325 | if ( x ) *x = m_logicalOriginX; | |
326 | if ( y ) *y = m_logicalOriginY; | |
327 | } | |
328 | ||
329 | virtual void SetDeviceOrigin(wxCoord x, wxCoord y); | |
330 | virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const | |
331 | { | |
332 | if ( x ) *x = m_deviceOriginX; | |
333 | if ( y ) *y = m_deviceOriginY; | |
334 | } | |
335 | ||
336 | virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y ); | |
337 | ||
338 | virtual void ComputeScaleAndOrigin(); | |
339 | ||
340 | // this needs to overidden if the axis is inverted | |
341 | virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
342 | ||
343 | // --------------------------------------------------------- | |
344 | // the actual drawing API | |
345 | ||
346 | virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, | |
347 | int style = wxFLOOD_SURFACE) = 0; | |
348 | ||
349 | virtual void DoGradientFillLinear(const wxRect& rect, | |
350 | const wxColour& initialColour, | |
351 | const wxColour& destColour, | |
352 | wxDirection nDirection = wxEAST); | |
353 | ||
354 | virtual void DoGradientFillConcentric(const wxRect& rect, | |
355 | const wxColour& initialColour, | |
356 | const wxColour& destColour, | |
357 | const wxPoint& circleCenter); | |
358 | ||
359 | virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0; | |
360 | ||
361 | virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0; | |
362 | virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0; | |
363 | ||
364 | virtual void DoDrawArc(wxCoord x1, wxCoord y1, | |
365 | wxCoord x2, wxCoord y2, | |
366 | wxCoord xc, wxCoord yc) = 0; | |
367 | virtual void DoDrawCheckMark(wxCoord x, wxCoord y, | |
368 | wxCoord width, wxCoord height); | |
369 | virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, | |
370 | double sa, double ea) = 0; | |
371 | ||
372 | virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0; | |
373 | virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, | |
374 | wxCoord width, wxCoord height, | |
375 | double radius) = 0; | |
376 | virtual void DoDrawEllipse(wxCoord x, wxCoord y, | |
377 | wxCoord width, wxCoord height) = 0; | |
378 | ||
379 | virtual void DoCrossHair(wxCoord x, wxCoord y) = 0; | |
380 | ||
381 | virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0; | |
382 | virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
383 | bool useMask = false) = 0; | |
384 | ||
385 | virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0; | |
386 | virtual void DoDrawRotatedText(const wxString& text, | |
387 | wxCoord x, wxCoord y, double angle) = 0; | |
388 | ||
389 | virtual bool DoBlit(wxCoord xdest, wxCoord ydest, | |
390 | wxCoord width, wxCoord height, | |
391 | wxDC *source, | |
392 | wxCoord xsrc, wxCoord ysrc, | |
393 | int rop = wxCOPY, | |
394 | bool useMask = false, | |
395 | wxCoord xsrcMask = wxDefaultCoord, | |
396 | wxCoord ysrcMask = wxDefaultCoord) = 0; | |
397 | ||
398 | virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest, | |
399 | wxCoord dstWidth, wxCoord dstHeight, | |
400 | wxDC *source, | |
401 | wxCoord xsrc, wxCoord ysrc, | |
402 | wxCoord srcWidth, wxCoord srcHeight, | |
403 | int rop = wxCOPY, | |
404 | bool useMask = false, | |
405 | wxCoord xsrcMask = wxDefaultCoord, | |
406 | wxCoord ysrcMask = wxDefaultCoord); | |
407 | ||
408 | virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const | |
409 | { return wxNullBitmap; } | |
410 | ||
411 | ||
412 | virtual void DoDrawLines(int n, wxPoint points[], | |
413 | wxCoord xoffset, wxCoord yoffset) = 0; | |
414 | virtual void DoDrawPolygon(int n, wxPoint points[], | |
415 | wxCoord xoffset, wxCoord yoffset, | |
416 | int fillStyle = wxODDEVEN_RULE) = 0; | |
417 | virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[], | |
418 | wxCoord xoffset, wxCoord yoffset, | |
419 | int fillStyle); | |
420 | ||
421 | ||
422 | ||
423 | #if wxUSE_SPLINES | |
424 | virtual void DoDrawSpline(wxList *points); | |
425 | #endif | |
426 | ||
427 | private: | |
428 | wxDC *m_owner; | |
429 | ||
430 | protected: | |
431 | // unset clipping variables (after clipping region was destroyed) | |
432 | void ResetClipping() | |
433 | { | |
434 | m_clipping = false; | |
435 | ||
436 | m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0; | |
437 | } | |
438 | ||
439 | // flags | |
440 | bool m_colour:1; | |
441 | bool m_ok:1; | |
442 | bool m_clipping:1; | |
443 | bool m_isInteractive:1; | |
444 | bool m_isBBoxValid:1; | |
445 | ||
446 | // coordinate system variables | |
447 | ||
448 | wxCoord m_logicalOriginX, m_logicalOriginY; | |
449 | wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user | |
450 | ||
451 | wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner | |
452 | // is not at 0,0. This was the case under | |
453 | // Mac's GrafPorts (coordinate system | |
454 | // used toplevel window's origin) and | |
455 | // e.g. for Postscript, where the native | |
456 | // origin in the bottom left corner. | |
457 | double m_logicalScaleX, m_logicalScaleY; | |
458 | double m_userScaleX, m_userScaleY; | |
459 | double m_scaleX, m_scaleY; // calculated from logical scale and user scale | |
460 | ||
461 | int m_signX, m_signY; // Used by SetAxisOrientation() to invert the axes | |
462 | ||
463 | // what is a mm on a screen you don't know the size of? | |
464 | double m_mm_to_pix_x, | |
465 | m_mm_to_pix_y; | |
466 | ||
467 | // bounding and clipping boxes | |
468 | wxCoord m_minX, m_minY, m_maxX, m_maxY; | |
469 | wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2; | |
470 | ||
471 | int m_logicalFunction; | |
472 | int m_backgroundMode; | |
473 | int m_mappingMode; | |
474 | ||
475 | wxPen m_pen; | |
476 | wxBrush m_brush; | |
477 | wxBrush m_backgroundBrush; | |
478 | wxColour m_textForegroundColour; | |
479 | wxColour m_textBackgroundColour; | |
480 | wxFont m_font; | |
481 | ||
482 | #if wxUSE_PALETTE | |
483 | wxPalette m_palette; | |
484 | bool m_hasCustomPalette; | |
485 | #endif // wxUSE_PALETTE | |
486 | ||
487 | private: | |
488 | DECLARE_ABSTRACT_CLASS(wxImplDC) | |
489 | } | |
490 | ||
491 | ||
492 | class wxDC: public wxObject | |
493 | { | |
494 | public: | |
495 | wxDC() { m_pimpl = NULL; } | |
496 | ||
497 | bool IsOk() const | |
498 | { return m_pimpl && m_pimpl->IsOk(); } | |
499 | ||
500 | // query capabilities | |
501 | ||
502 | bool CanDrawBitmap() const | |
503 | { return m_pimpl->CanDrawBitmap(); } | |
504 | bool CanGetTextExtent() const | |
505 | { return m_pimpl->CanGetTextExtent(); } | |
506 | ||
507 | // query dimension, colour deps, resolution | |
508 | ||
509 | void GetSize(int *width, int *height) const | |
510 | { m_pimpl->DoGetSize(width, height); } | |
511 | ||
512 | wxSize GetSize() const | |
513 | { | |
514 | int w, h; | |
515 | m_pimpl->DoGetSize(&w, &h); | |
516 | return wxSize(w, h); | |
517 | } | |
518 | ||
519 | void GetSizeMM(int* width, int* height) const | |
520 | { m_pimpl->DoGetSizeMM(width, height); } | |
521 | wxSize GetSizeMM() const | |
522 | { | |
523 | int w, h; | |
524 | m_pimpl->DoGetSizeMM(&w, &h); | |
525 | return wxSize(w, h); | |
526 | } | |
527 | ||
528 | int GetDepth() const | |
529 | { return m_pimpl->GetDepth(); } | |
530 | wxSize GetPPI() const | |
531 | { return m_pimpl->GetPPI(); } | |
532 | ||
533 | // Right-To-Left (RTL) modes | |
534 | ||
535 | void SetLayoutDirection(wxLayoutDirection dir) | |
536 | { m_pimpl->SetLayoutDirection( dir ); } | |
537 | wxLayoutDirection GetLayoutDirection() const | |
538 | { return m_pimpl->GetLayoutDirection(); } | |
539 | ||
540 | // page and document | |
541 | ||
542 | bool StartDoc(const wxString& message) | |
543 | { return m_pimpl->StartDoc(message); } | |
544 | void EndDoc() | |
545 | { m_pimpl->EndDoc(); } | |
546 | ||
547 | void StartPage() | |
548 | { m_pimpl->StartPage(); } | |
549 | void EndPage() | |
550 | { m_pimpl->EndPage(); } | |
551 | ||
552 | // bounding box | |
553 | ||
554 | void CalcBoundingBox(wxCoord x, wxCoord y) | |
555 | { m_pimpl->CalcBoundingBox(x,y); } | |
556 | void ResetBoundingBox() | |
557 | { m_pimpl->ResetBoundingBox(); } | |
558 | ||
559 | wxCoord MinX() const | |
560 | { return m_pimpl->MinX(); } | |
561 | wxCoord MaxX() const | |
562 | { return m_pimpl->MaxX(); } | |
563 | wxCoord MinY() const | |
564 | { return m_pimpl->MinY(); } | |
565 | wxCoord MaxY() const | |
566 | { return m_pimpl->MaxY(); } | |
567 | ||
568 | // setters and getters | |
569 | ||
570 | void SetFont(const wxFont& font) | |
571 | { m_pimpl->SetFont( font ); } | |
572 | const wxFont& GetFont() const | |
573 | { return m_pimpl->GetFont(); } | |
574 | ||
575 | void SetPen(const wxPen& pen) | |
576 | { m_pimpl->SetPen( pen ); } | |
577 | const wxPen& GetPen() const | |
578 | { return m_pimpl->GetPen(); } | |
579 | ||
580 | void SetBrush(const wxBrush& brush) | |
581 | { m_pimpl->SetBrush( brush ); } | |
582 | const wxBrush& GetBrush() const | |
583 | { return m_pimpl->GetBrush(); } | |
584 | ||
585 | void SetBackground(const wxBrush& brush) | |
586 | { m_pimpl->SetBackground( brush ); } | |
587 | const wxBrush& GetBackground() const | |
588 | { return m_pimpl->GetBackground(); } | |
589 | ||
590 | void SetBackgroundMode(int mode) | |
591 | { m_pimpl->SetBackground( mode ); } | |
592 | int GetBackgroundMode() const | |
593 | { return m_pimpl->GetBackground(); } | |
594 | ||
595 | void SetTextForeground(const wxColour& colour) | |
596 | { m_pimpl->SetTextForeground(colour); } | |
597 | const wxColour& GetTextForeground() const | |
598 | { return m_pimpl->GetTextForeground(); } | |
599 | ||
600 | void SetTextBackground(const wxColour& colour) | |
601 | { m_pimpl->SetTextBackground(colour); } | |
602 | const wxColour& GetTextBackground() const | |
603 | { return m_pimpl->GetTextBackground(); } | |
604 | ||
605 | #if wxUSE_PALETTE | |
606 | void SetPalette(const wxPalette& palette) | |
607 | { m_pimpl->SetPalette(palette); } | |
608 | #endif // wxUSE_PALETTE | |
609 | ||
610 | // logical functions | |
611 | ||
612 | void SetLogicalFunction(int function) | |
613 | { m_pimpl->SetLogicalFunction(function); } | |
614 | int GetLogicalFunction() const | |
615 | { return m_pimpl->GetLogicalFunction(); } | |
616 | ||
617 | // text measurement | |
618 | ||
619 | wxCoord GetCharHeight() const | |
620 | { return m_pimpl->GetCharHeight(); } | |
621 | wxCoord GetCharWidth() const | |
622 | { return m_pimpl->GetCharWidth(); } | |
623 | ||
624 | void GetTextExtent(const wxString& string, | |
625 | wxCoord *x, wxCoord *y, | |
626 | wxCoord *descent = NULL, | |
627 | wxCoord *externalLeading = NULL, | |
628 | const wxFont *theFont = NULL) const | |
629 | { m_pimpl->DoGetTextExtent(string, x, y, descent, externalLeading, theFont); } | |
630 | ||
631 | wxSize GetTextExtent(const wxString& string) const | |
632 | { | |
633 | wxCoord w, h; | |
634 | m_pimpl->DoGetTextExtent(string, &w, &h); | |
635 | return wxSize(w, h); | |
636 | } | |
637 | ||
638 | void GetMultiLineTextExtent(const wxString& string, | |
639 | wxCoord *width, | |
640 | wxCoord *height, | |
641 | wxCoord *heightLine = NULL, | |
642 | const wxFont *font = NULL) const | |
643 | { m_pimpl->GetMultiLineTextExtent( string, width, height, heightLine, font ); } | |
644 | ||
645 | wxSize GetMultiLineTextExtent(const wxString& string) const | |
646 | { | |
647 | wxCoord w, h; | |
648 | m_pimpl->GetMultiLineTextExtent(string, &w, &h); | |
649 | return wxSize(w, h); | |
650 | } | |
651 | ||
652 | bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const | |
653 | { return m_pimpl->DoGetPartialTextExtents(text, widths); } | |
654 | ||
655 | // clearing | |
656 | ||
657 | void Clear() | |
658 | { m_pimpl->Clear(); } | |
659 | ||
660 | // clipping | |
661 | ||
662 | void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) | |
663 | { m_pimpl->DoSetClippingRegion(x, y, width, height); } | |
664 | void SetClippingRegion(const wxPoint& pt, const wxSize& sz) | |
665 | { m_pimpl->DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); } | |
666 | void SetClippingRegion(const wxRect& rect) | |
667 | { m_pimpl->DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); } | |
668 | void SetClippingRegion(const wxRegion& region) | |
669 | { m_pimpl->DoSetClippingRegionAsRegion(region); } | |
670 | ||
671 | void DestroyClippingRegion() | |
672 | { m_pimpl->DestroyClippingRegion(); } | |
673 | ||
674 | void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const | |
675 | { m_pimpl->DoGetClippingBox(x, y, w, h); } | |
676 | void GetClippingBox(wxRect& rect) const | |
677 | { m_pimpl->DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height); } | |
678 | ||
679 | // coordinates conversions and transforms | |
680 | ||
681 | wxCoord DeviceToLogicalX(wxCoord x) const | |
682 | { return m_pimpl->DeviceToLogicalX(x); } | |
683 | wxCoord DeviceToLogicalY(wxCoord y) const; | |
684 | { return m_pimpl->DeviceToLogicalY(y); } | |
685 | wxCoord DeviceToLogicalXRel(wxCoord x) const; | |
686 | { return m_pimpl->DeviceToLogicalXRel(x); } | |
687 | wxCoord DeviceToLogicalYRel(wxCoord y) const; | |
688 | { return m_pimpl->DeviceToLogicalYRel(y); } | |
689 | wxCoord LogicalToDeviceX(wxCoord x) const; | |
690 | { return m_pimpl->LogicalToDeviceX(x); } | |
691 | wxCoord LogicalToDeviceY(wxCoord y) const; | |
692 | { return m_pimpl->LogicalToDeviceY(y); } | |
693 | wxCoord LogicalToDeviceXRel(wxCoord x) const; | |
694 | { return m_pimpl->LogicalToDeviceXRel(x); } | |
695 | wxCoord LogicalToDeviceYRel(wxCoord y) const; | |
696 | { return m_pimpl->LogicalToDeviceYRel(y); } | |
697 | ||
698 | void SetMapMode(int mode) | |
699 | { m_pimpl->SetMapMode(mode); } | |
700 | int GetMapMode() const | |
701 | { return m_pimpl->GetMapMode(); } | |
702 | ||
703 | void SetUserScale(double x, double y) | |
704 | { m_pimpl->SetUserScale(x,y); } | |
705 | void GetUserScale(double *x, double *y) const | |
706 | { m_pimpl->GetUserScale( x, y ); } | |
707 | ||
708 | void SetLogicalScale(double x, double y) | |
709 | { m_pimpl->SetLogicalScale( x, y ); } | |
710 | void GetLogicalScale(double *x, double *y) | |
711 | { m_pimpl->GetLogicalScale( x, y ); } | |
712 | ||
713 | void SetLogicalOrigin(wxCoord x, wxCoord y) | |
714 | { m_pimpl->SetLogicalOrigin(x,y); } | |
715 | void GetLogicalOrigin(wxCoord *x, wxCoord *y) const | |
716 | { m_pimpl->DoGetLogicalOrigin(x, y); } | |
717 | wxPoint GetLogicalOrigin() const | |
718 | { wxCoord x, y; m_pimpl->DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); } | |
719 | ||
720 | void SetDeviceOrigin(wxCoord x, wxCoord y) | |
721 | { m_pimpl->SetDeviceOrigin( x, y); } | |
722 | void GetDeviceOrigin(wxCoord *x, wxCoord *y) const | |
723 | { m_pimpl->DoGetDeviceOrigin(x, y); } | |
724 | wxPoint GetDeviceOrigin() const | |
725 | { wxCoord x, y; m_pimpl->DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); } | |
726 | ||
727 | void SetAxisOrientation(bool xLeftRight, bool yBottomUp) | |
728 | { m_pimpl->SetAxisOrientation(xLeftRight, yBottomUp); } | |
729 | ||
730 | // mostly internal | |
731 | void SetDeviceLocalOrigin( wxCoord x, wxCoord y ) | |
732 | { m_pimpl->SetDeviceLocalOrigin( x, y ); } | |
733 | ||
734 | ||
735 | // draw generic object | |
736 | ||
737 | void DrawObject(wxDrawObject* drawobject) | |
738 | { | |
739 | drawobject->Draw(*this); | |
740 | CalcBoundingBox(drawobject->MinX(),drawobject->MinY()); | |
741 | CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY()); | |
742 | } | |
743 | ||
744 | // ----------------------------------------------- | |
745 | // the actual drawing API | |
746 | ||
747 | bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, | |
748 | int style = wxFLOOD_SURFACE) | |
749 | { return m_pimpl->DoFloodFill(x, y, col, style); } | |
750 | bool FloodFill(const wxPoint& pt, const wxColour& col, | |
751 | int style = wxFLOOD_SURFACE) | |
752 | { return m_pimpl->DoFloodFill(pt.x, pt.y, col, style); } | |
753 | ||
754 | // fill the area specified by rect with a radial gradient, starting from | |
755 | // initialColour in the centre of the cercle and fading to destColour. | |
756 | void GradientFillConcentric(const wxRect& rect, | |
757 | const wxColour& initialColour, | |
758 | const wxColour& destColour) | |
759 | { m_pimpl->GradientFillConcentric(rect, initialColour, destColour, | |
760 | wxPoint(rect.GetWidth() / 2, | |
761 | rect.GetHeight() / 2)); } | |
762 | ||
763 | void GradientFillConcentric(const wxRect& rect, | |
764 | const wxColour& initialColour, | |
765 | const wxColour& destColour, | |
766 | const wxPoint& circleCenter) | |
767 | { m_pimpl->DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); } | |
768 | ||
769 | // fill the area specified by rect with a linear gradient | |
770 | void GradientFillLinear(const wxRect& rect, | |
771 | const wxColour& initialColour, | |
772 | const wxColour& destColour, | |
773 | wxDirection nDirection = wxEAST) | |
774 | { m_pimpl->DoGradientFillLinear(rect, initialColour, destColour, nDirection); } | |
775 | ||
776 | bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const | |
777 | { return m_pimpl->DoGetPixel(x, y, col); } | |
778 | bool GetPixel(const wxPoint& pt, wxColour *col) const | |
779 | { return m_pimpl->DoGetPixel(pt.x, pt.y, col); } | |
780 | ||
781 | void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) | |
782 | { m_pimpl->DoDrawLine(x1, y1, x2, y2); } | |
783 | void DrawLine(const wxPoint& pt1, const wxPoint& pt2) | |
784 | { m_pimpl->DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); } | |
785 | ||
786 | void CrossHair(wxCoord x, wxCoord y) | |
787 | { m_pimpl->DoCrossHair(x, y); } | |
788 | void CrossHair(const wxPoint& pt) | |
789 | { m_pimpl->DoCrossHair(pt.x, pt.y); } | |
790 | ||
791 | void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, | |
792 | wxCoord xc, wxCoord yc) | |
793 | { m_pimpl->DoDrawArc(x1, y1, x2, y2, xc, yc); } | |
794 | void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre) | |
795 | { m_pimpl->DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); } | |
796 | ||
797 | void DrawCheckMark(wxCoord x, wxCoord y, | |
798 | wxCoord width, wxCoord height) | |
799 | { m_pimpl->DoDrawCheckMark(x, y, width, height); } | |
800 | void DrawCheckMark(const wxRect& rect) | |
801 | { m_pimpl->DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); } | |
802 | ||
803 | void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, | |
804 | double sa, double ea) | |
805 | { m_pimpl->DoDrawEllipticArc(x, y, w, h, sa, ea); } | |
806 | void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, | |
807 | double sa, double ea) | |
808 | { m_pimpl->DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); } | |
809 | ||
810 | void DrawPoint(wxCoord x, wxCoord y) | |
811 | { m_pimpl->DoDrawPoint(x, y); } | |
812 | void DrawPoint(const wxPoint& pt) | |
813 | { m_pimpl->DoDrawPoint(pt.x, pt.y); } | |
814 | ||
815 | void DrawLines(int n, wxPoint points[], | |
816 | wxCoord xoffset = 0, wxCoord yoffset = 0) | |
817 | { m_pimpl->DoDrawLines(n, points, xoffset, yoffset); } | |
818 | void DrawLines(const wxList *list, | |
819 | wxCoord xoffset = 0, wxCoord yoffset = 0) | |
820 | { m_pimpl->DrawLines( list, xoffset, yoffset ); } | |
821 | ||
822 | void DrawPolygon(int n, wxPoint points[], | |
823 | wxCoord xoffset = 0, wxCoord yoffset = 0, | |
824 | int fillStyle = wxODDEVEN_RULE) | |
825 | { m_pimpl->DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); } | |
826 | ||
827 | void DrawPolygon(const wxList *list, | |
828 | wxCoord xoffset = 0, wxCoord yoffset = 0, | |
829 | int fillStyle = wxODDEVEN_RULE) | |
830 | { m_pimpl->DrawPolygon( list, xoffset, yoffset, fillStyle ); } | |
831 | ||
832 | void DrawPolyPolygon(int n, int count[], wxPoint points[], | |
833 | wxCoord xoffset = 0, wxCoord yoffset = 0, | |
834 | int fillStyle = wxODDEVEN_RULE) | |
835 | { m_pimpl->DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); } | |
836 | ||
837 | void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) | |
838 | { m_pimpl->DoDrawRectangle(x, y, width, height); } | |
839 | void DrawRectangle(const wxPoint& pt, const wxSize& sz) | |
840 | { m_pimpl->DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); } | |
841 | void DrawRectangle(const wxRect& rect) | |
842 | { m_pimpl->DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); } | |
843 | ||
844 | void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, | |
845 | double radius) | |
846 | { m_pimpl->DoDrawRoundedRectangle(x, y, width, height, radius); } | |
847 | void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, | |
848 | double radius) | |
849 | { m_pimpl->DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); } | |
850 | void DrawRoundedRectangle(const wxRect& r, double radius) | |
851 | { m_pimpl->DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); } | |
852 | ||
853 | void DrawCircle(wxCoord x, wxCoord y, wxCoord radius) | |
854 | { m_pimpl->DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); } | |
855 | void DrawCircle(const wxPoint& pt, wxCoord radius) | |
856 | { m_pimpl->DrawCircle(pt.x, pt.y, radius); } | |
857 | ||
858 | void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) | |
859 | { m_pimpl->DoDrawEllipse(x, y, width, height); } | |
860 | void DrawEllipse(const wxPoint& pt, const wxSize& sz) | |
861 | { m_pimpl->DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); } | |
862 | void DrawEllipse(const wxRect& rect) | |
863 | { m_pimpl->DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); } | |
864 | ||
865 | void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) | |
866 | { m_pimpl->DoDrawIcon(icon, x, y); } | |
867 | void DrawIcon(const wxIcon& icon, const wxPoint& pt) | |
868 | { m_pimpl->DoDrawIcon(icon, pt.x, pt.y); } | |
869 | ||
870 | void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
871 | bool useMask = false) | |
872 | { m_pimpl->DoDrawBitmap(bmp, x, y, useMask); } | |
873 | void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, | |
874 | bool useMask = false) | |
875 | { m_pimpl->DoDrawBitmap(bmp, pt.x, pt.y, useMask); } | |
876 | ||
02255e07 RR |
877 | virtual void DrawScaledBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, wxCoord w, wxCoord h, bool useMask = false, int quality = wxIMAGE_QUALITY_NORMAL) |
878 | { | |
879 | if (bmp.GetWidth() != w || bmp.GetHeight() != h) | |
880 | { | |
881 | if (quality != wxIMAGE_QUALITY_HIGH) | |
882 | quality = wxIMAGE_QUALITY_NORMAL; | |
883 | wxImage tmpImg = bmp.ConvertToImage(); | |
884 | tmpImg.Rescale( w, h, quality ); | |
885 | wxBitmap scaledBmp(tmpImg); | |
886 | m_pimpl->DoDrawBitmap(scaledBmp, x, y, useMask); | |
887 | } | |
888 | else | |
889 | m_pimpl->DoDrawBitmap(bmp, x, y, useMask); | |
890 | } | |
891 | virtual void DrawScaledBitmap(const wxBitmap &bmp, const wxPoint& pt, const wxSize& sz, bool useMask = false, int quality = wxIMAGE_QUALITY_NORMAL) | |
892 | { | |
893 | if (bmp.GetWidth() != sz.x || bmp.GetHeight() != sz.y) | |
894 | { | |
895 | if (quality != wxIMAGE_QUALITY_HIGH) | |
896 | quality = wxIMAGE_QUALITY_NORMAL; | |
897 | wxImage tmpImg = bmp.ConvertToImage(); | |
898 | tmpImg.Rescale( sz.x, sz.y, quality ); | |
899 | wxBitmap scaledBmp(tmpImg); | |
900 | m_pimpl->DoDrawBitmap(scaledBmp, pt.x, pt.y, useMask); | |
901 | } | |
902 | else | |
903 | m_pimpl->DoDrawBitmap(bmp, pt.x, pt.y, useMask); | |
904 | } | |
905 | virtual void DrawScaledBitmap(const wxBitmap &bmp, const wxRect& rect, bool useMask = false, int quality = wxIMAGE_QUALITY_NORMAL) | |
906 | { | |
907 | if (bmp.GetWidth() != rect.width || bmp.GetHeight() != rect.height) | |
908 | { | |
909 | if (quality != wxIMAGE_QUALITY_HIGH) | |
910 | quality = wxIMAGE_QUALITY_NORMAL; | |
911 | wxImage tmpImg = bmp.ConvertToImage(); | |
912 | tmpImg.Rescale( rect.width, rect.height, quality ); | |
913 | wxBitmap scaledBmp(tmpImg); | |
914 | m_pimpl->DoDrawBitmap(scaledBmp, rect.x, rect.y, useMask); | |
915 | } | |
916 | else | |
917 | m_pimpl->DoDrawBitmap(bmp, rect.x, rect.y, useMask); | |
918 | } | |
919 | ||
2970ae54 RR |
920 | void DrawText(const wxString& text, wxCoord x, wxCoord y) |
921 | { m_pimpl->DoDrawText(text, x, y); } | |
922 | void DrawText(const wxString& text, const wxPoint& pt) | |
923 | { m_pimpl->DoDrawText(text, pt.x, pt.y); } | |
924 | ||
925 | void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) | |
926 | { m_pimpl->DoDrawRotatedText(text, x, y, angle); } | |
927 | void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle) | |
928 | { m_pimpl->DoDrawRotatedText(text, pt.x, pt.y, angle); } | |
929 | ||
930 | // this version puts both optional bitmap and the text into the given | |
931 | // rectangle and aligns is as specified by alignment parameter; it also | |
932 | // will emphasize the character with the given index if it is != -1 and | |
933 | // return the bounding rectangle if required | |
934 | void DrawLabel(const wxString& text, | |
935 | const wxBitmap& image, | |
936 | const wxRect& rect, | |
937 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
938 | int indexAccel = -1, | |
939 | wxRect *rectBounding = NULL) | |
940 | { m_pimpl->DrawLabel( text, image, rect, alignment, indexAccel, rectBounding ); } | |
941 | ||
942 | void DrawLabel(const wxString& text, const wxRect& rect, | |
943 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
944 | int indexAccel = -1) | |
945 | { m_pimpl->DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); } | |
946 | ||
947 | bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, | |
948 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
949 | int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) | |
950 | { | |
951 | return m_pimpl->DoBlit(xdest, ydest, width, height, | |
952 | source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask); | |
953 | } | |
954 | bool Blit(const wxPoint& destPt, const wxSize& sz, | |
955 | wxDC *source, const wxPoint& srcPt, | |
956 | int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition) | |
957 | { | |
958 | return m_pimpl->DoBlit(destPt.x, destPt.y, sz.x, sz.y, | |
959 | source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y); | |
960 | } | |
961 | ||
962 | bool StretchBlit(wxCoord dstX, wxCoord dstY, | |
963 | wxCoord dstWidth, wxCoord dstHeight, | |
964 | wxDC *source, | |
965 | wxCoord srcX, wxCoord srcY, | |
966 | wxCoord srcWidth, wxCoord srcHeight, | |
967 | int rop = wxCOPY, bool useMask = false, | |
968 | wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord) | |
969 | { | |
970 | return m_pimpl->DoStretchBlit(dstX, dstY, dstWidth, dstHeight, | |
971 | source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY); | |
972 | } | |
973 | bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize, | |
974 | wxDC *source, const wxPoint& srcPt, const wxSize& srcSize, | |
975 | int rop = wxCOPY, bool useMask = false, const wxPoint& srcMaskPt = wxDefaultPosition) | |
976 | { | |
977 | return m_pimpl->DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y, | |
978 | source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y); | |
979 | } | |
980 | ||
981 | wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const | |
982 | { | |
983 | return m_pimpl->DoGetAsBitmap(subrect); | |
984 | } | |
985 | ||
986 | #if wxUSE_SPLINES | |
987 | // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?) | |
988 | void DrawSpline(wxCoord x1, wxCoord y1, | |
989 | wxCoord x2, wxCoord y2, | |
990 | wxCoord x3, wxCoord y3) | |
991 | { m_pimpl->DrawSpline(x1,y1,x2,y2,x3,y3); } | |
992 | void DrawSpline(int n, wxPoint points[]) | |
993 | { m_pimpl->DrawSpline(n,points); } | |
994 | ||
995 | void DrawSpline(wxList *points) | |
996 | { m_pimpl->DoDrawSpline(points); } | |
997 | #endif // wxUSE_SPLINES | |
998 | ||
999 | ||
1000 | #if WXWIN_COMPATIBILITY_2_8 | |
1001 | // for compatibility with the old code when wxCoord was long everywhere | |
1002 | wxDEPRECATED( void GetTextExtent(const wxString& string, | |
1003 | long *x, long *y, | |
1004 | long *descent = NULL, | |
1005 | long *externalLeading = NULL, | |
1006 | const wxFont *theFont = NULL) const ); | |
1007 | wxDEPRECATED( void GetLogicalOrigin(long *x, long *y) const ); | |
1008 | wxDEPRECATED( void GetDeviceOrigin(long *x, long *y) const ); | |
1009 | wxDEPRECATED( void GetClippingBox(long *x, long *y, long *w, long *h) const ); | |
1010 | #endif // WXWIN_COMPATIBILITY_2_8 | |
1011 | ||
1012 | ||
1013 | protected: | |
1014 | wxImplDC *m_pimpl; | |
1015 | ||
1016 | private: | |
1017 | DECLARE_ABSTRACT_CLASS(wxImplDC) | |
1018 | } | |
1019 | ||
1020 | ||
1021 | #else // wxUSE_NEW_DC | |
1022 | ||
1023 | ||
b5dbe15d VS |
1024 | class WXDLLIMPEXP_FWD_CORE wxDC; |
1025 | class WXDLLIMPEXP_FWD_CORE wxDCBase; | |
aec43716 KH |
1026 | |
1027 | class WXDLLEXPORT wxDrawObject | |
1028 | { | |
1029 | public: | |
1030 | ||
1031 | wxDrawObject() | |
68379eaf | 1032 | : m_isBBoxValid(false) |
ba161d7e GD |
1033 | , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0) |
1034 | { } | |
aec43716 KH |
1035 | |
1036 | virtual ~wxDrawObject() { } | |
1037 | ||
33ac7e6f | 1038 | virtual void Draw(wxDCBase&) const { } |
aec43716 KH |
1039 | |
1040 | virtual void CalcBoundingBox(wxCoord x, wxCoord y) | |
1041 | { | |
1042 | if ( m_isBBoxValid ) | |
1043 | { | |
1044 | if ( x < m_minX ) m_minX = x; | |
1045 | if ( y < m_minY ) m_minY = y; | |
1046 | if ( x > m_maxX ) m_maxX = x; | |
1047 | if ( y > m_maxY ) m_maxY = y; | |
1048 | } | |
1049 | else | |
1050 | { | |
68379eaf | 1051 | m_isBBoxValid = true; |
aec43716 KH |
1052 | |
1053 | m_minX = x; | |
1054 | m_minY = y; | |
1055 | m_maxX = x; | |
1056 | m_maxY = y; | |
1057 | } | |
1058 | } | |
1059 | ||
1060 | void ResetBoundingBox() | |
1061 | { | |
68379eaf | 1062 | m_isBBoxValid = false; |
aec43716 KH |
1063 | |
1064 | m_minX = m_maxX = m_minY = m_maxY = 0; | |
1065 | } | |
1066 | ||
1067 | // Get the final bounding box of the PostScript or Metafile picture. | |
1068 | ||
1069 | wxCoord MinX() const { return m_minX; } | |
1070 | wxCoord MaxX() const { return m_maxX; } | |
1071 | wxCoord MinY() const { return m_minY; } | |
1072 | wxCoord MaxY() const { return m_maxY; } | |
1073 | ||
1074 | //to define the type of object for derived objects | |
1075 | virtual int GetType()=0; | |
1076 | ||
1077 | protected: | |
1078 | //for boundingbox calculation | |
1079 | bool m_isBBoxValid:1; | |
1080 | //for boundingbox calculation | |
1081 | wxCoord m_minX, m_minY, m_maxX, m_maxY; | |
1082 | }; | |
1083 | ||
a23fd0e1 VZ |
1084 | // --------------------------------------------------------------------------- |
1085 | // global variables | |
1086 | // --------------------------------------------------------------------------- | |
1087 | ||
a23fd0e1 VZ |
1088 | // --------------------------------------------------------------------------- |
1089 | // wxDC is the device context - object on which any drawing is done | |
1090 | // --------------------------------------------------------------------------- | |
1091 | ||
1092 | class WXDLLEXPORT wxDCBase : public wxObject | |
1093 | { | |
a23fd0e1 | 1094 | public: |
04ab8b6d RR |
1095 | wxDCBase(); |
1096 | virtual ~wxDCBase(); | |
1097 | ||
a23fd0e1 VZ |
1098 | // graphic primitives |
1099 | // ------------------ | |
1100 | ||
aec43716 KH |
1101 | virtual void DrawObject(wxDrawObject* drawobject) |
1102 | { | |
1103 | drawobject->Draw(*this); | |
1104 | CalcBoundingBox(drawobject->MinX(),drawobject->MinY()); | |
1105 | CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY()); | |
1106 | } | |
1107 | ||
387ebd3e | 1108 | bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, |
72cdf4c9 | 1109 | int style = wxFLOOD_SURFACE) |
387ebd3e JS |
1110 | { return DoFloodFill(x, y, col, style); } |
1111 | bool FloodFill(const wxPoint& pt, const wxColour& col, | |
72cdf4c9 | 1112 | int style = wxFLOOD_SURFACE) |
387ebd3e | 1113 | { return DoFloodFill(pt.x, pt.y, col, style); } |
a23fd0e1 | 1114 | |
213ad8e7 VZ |
1115 | // fill the area specified by rect with a radial gradient, starting from |
1116 | // initialColour in the centre of the cercle and fading to destColour. | |
1117 | void GradientFillConcentric(const wxRect& rect, | |
4660e6ac | 1118 | const wxColour& initialColour, |
213ad8e7 VZ |
1119 | const wxColour& destColour) |
1120 | { GradientFillConcentric(rect, initialColour, destColour, | |
1121 | wxPoint(rect.GetWidth() / 2, | |
1122 | rect.GetHeight() / 2)); } | |
1123 | ||
1124 | void GradientFillConcentric(const wxRect& rect, | |
4660e6ac | 1125 | const wxColour& initialColour, |
213ad8e7 | 1126 | const wxColour& destColour, |
fb63a242 SC |
1127 | const wxPoint& circleCenter) |
1128 | { DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); } | |
213ad8e7 VZ |
1129 | |
1130 | // fill the area specified by rect with a linear gradient | |
1131 | void GradientFillLinear(const wxRect& rect, | |
4660e6ac | 1132 | const wxColour& initialColour, |
213ad8e7 VZ |
1133 | const wxColour& destColour, |
1134 | wxDirection nDirection = wxEAST) | |
1135 | { DoGradientFillLinear(rect, initialColour, destColour, nDirection); } | |
1136 | ||
72cdf4c9 | 1137 | bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const |
a23fd0e1 VZ |
1138 | { return DoGetPixel(x, y, col); } |
1139 | bool GetPixel(const wxPoint& pt, wxColour *col) const | |
1140 | { return DoGetPixel(pt.x, pt.y, col); } | |
1141 | ||
72cdf4c9 | 1142 | void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) |
a23fd0e1 VZ |
1143 | { DoDrawLine(x1, y1, x2, y2); } |
1144 | void DrawLine(const wxPoint& pt1, const wxPoint& pt2) | |
1145 | { DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); } | |
1146 | ||
72cdf4c9 | 1147 | void CrossHair(wxCoord x, wxCoord y) |
a23fd0e1 VZ |
1148 | { DoCrossHair(x, y); } |
1149 | void CrossHair(const wxPoint& pt) | |
1150 | { DoCrossHair(pt.x, pt.y); } | |
1151 | ||
72cdf4c9 VZ |
1152 | void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, |
1153 | wxCoord xc, wxCoord yc) | |
a23fd0e1 VZ |
1154 | { DoDrawArc(x1, y1, x2, y2, xc, yc); } |
1155 | void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre) | |
1156 | { DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); } | |
1157 | ||
cd9da200 VZ |
1158 | void DrawCheckMark(wxCoord x, wxCoord y, |
1159 | wxCoord width, wxCoord height) | |
1160 | { DoDrawCheckMark(x, y, width, height); } | |
1161 | void DrawCheckMark(const wxRect& rect) | |
1162 | { DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); } | |
1163 | ||
72cdf4c9 VZ |
1164 | void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, |
1165 | double sa, double ea) | |
7b90a8f2 | 1166 | { DoDrawEllipticArc(x, y, w, h, sa, ea); } |
a23fd0e1 VZ |
1167 | void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, |
1168 | double sa, double ea) | |
1169 | { DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); } | |
1170 | ||
72cdf4c9 | 1171 | void DrawPoint(wxCoord x, wxCoord y) |
a23fd0e1 VZ |
1172 | { DoDrawPoint(x, y); } |
1173 | void DrawPoint(const wxPoint& pt) | |
1174 | { DoDrawPoint(pt.x, pt.y); } | |
1175 | ||
72cdf4c9 VZ |
1176 | void DrawLines(int n, wxPoint points[], |
1177 | wxCoord xoffset = 0, wxCoord yoffset = 0) | |
a23fd0e1 | 1178 | { DoDrawLines(n, points, xoffset, yoffset); } |
72cdf4c9 VZ |
1179 | void DrawLines(const wxList *list, |
1180 | wxCoord xoffset = 0, wxCoord yoffset = 0); | |
a23fd0e1 VZ |
1181 | |
1182 | void DrawPolygon(int n, wxPoint points[], | |
72cdf4c9 | 1183 | wxCoord xoffset = 0, wxCoord yoffset = 0, |
a23fd0e1 VZ |
1184 | int fillStyle = wxODDEVEN_RULE) |
1185 | { DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); } | |
1186 | ||
1187 | void DrawPolygon(const wxList *list, | |
72cdf4c9 | 1188 | wxCoord xoffset = 0, wxCoord yoffset = 0, |
bd5dd957 | 1189 | int fillStyle = wxODDEVEN_RULE); |
a23fd0e1 | 1190 | |
793db755 | 1191 | void DrawPolyPolygon(int n, int count[], wxPoint points[], |
6e76b35d VZ |
1192 | wxCoord xoffset = 0, wxCoord yoffset = 0, |
1193 | int fillStyle = wxODDEVEN_RULE) | |
793db755 | 1194 | { DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); } |
6e76b35d | 1195 | |
72cdf4c9 | 1196 | void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) |
a23fd0e1 VZ |
1197 | { DoDrawRectangle(x, y, width, height); } |
1198 | void DrawRectangle(const wxPoint& pt, const wxSize& sz) | |
1199 | { DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); } | |
1200 | void DrawRectangle(const wxRect& rect) | |
1201 | { DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); } | |
1202 | ||
72cdf4c9 | 1203 | void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, |
a23fd0e1 VZ |
1204 | double radius) |
1205 | { DoDrawRoundedRectangle(x, y, width, height, radius); } | |
1206 | void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, | |
1207 | double radius) | |
1208 | { DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); } | |
1209 | void DrawRoundedRectangle(const wxRect& r, double radius) | |
1210 | { DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); } | |
1211 | ||
72cdf4c9 | 1212 | void DrawCircle(wxCoord x, wxCoord y, wxCoord radius) |
220af862 | 1213 | { DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); } |
0371e9a8 | 1214 | void DrawCircle(const wxPoint& pt, wxCoord radius) |
b95edd47 | 1215 | { DrawCircle(pt.x, pt.y, radius); } |
0371e9a8 | 1216 | |
72cdf4c9 | 1217 | void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) |
a23fd0e1 VZ |
1218 | { DoDrawEllipse(x, y, width, height); } |
1219 | void DrawEllipse(const wxPoint& pt, const wxSize& sz) | |
1220 | { DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); } | |
1221 | void DrawEllipse(const wxRect& rect) | |
1222 | { DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); } | |
1223 | ||
72cdf4c9 | 1224 | void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) |
a23fd0e1 VZ |
1225 | { DoDrawIcon(icon, x, y); } |
1226 | void DrawIcon(const wxIcon& icon, const wxPoint& pt) | |
1227 | { DoDrawIcon(icon, pt.x, pt.y); } | |
1228 | ||
72cdf4c9 | 1229 | void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, |
68379eaf | 1230 | bool useMask = false) |
a23fd0e1 VZ |
1231 | { DoDrawBitmap(bmp, x, y, useMask); } |
1232 | void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt, | |
68379eaf | 1233 | bool useMask = false) |
a23fd0e1 VZ |
1234 | { DoDrawBitmap(bmp, pt.x, pt.y, useMask); } |
1235 | ||
02255e07 RR |
1236 | virtual void DrawScaledBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, wxCoord w, wxCoord h, bool useMask = false, int quality = wxIMAGE_QUALITY_NORMAL) |
1237 | { | |
1238 | if (bmp.GetWidth() != w || bmp.GetHeight() != h) | |
1239 | { | |
1240 | if (quality != wxIMAGE_QUALITY_HIGH) | |
1241 | quality = wxIMAGE_QUALITY_NORMAL; | |
1242 | wxImage tmpImg = bmp.ConvertToImage(); | |
1243 | tmpImg.Rescale( w, h, quality ); | |
1244 | wxBitmap scaledBmp(tmpImg); | |
1245 | DoDrawBitmap(scaledBmp, x, y, useMask); | |
1246 | } | |
1247 | else | |
1248 | DoDrawBitmap(bmp, x, y, useMask); | |
1249 | } | |
1250 | virtual void DrawScaledBitmap(const wxBitmap &bmp, const wxPoint& pt, const wxSize& sz, bool useMask = false, int quality = wxIMAGE_QUALITY_NORMAL) | |
1251 | { | |
1252 | if (bmp.GetWidth() != sz.x || bmp.GetHeight() != sz.y) | |
1253 | { | |
1254 | if (quality != wxIMAGE_QUALITY_HIGH) | |
1255 | quality = wxIMAGE_QUALITY_NORMAL; | |
1256 | wxImage tmpImg = bmp.ConvertToImage(); | |
1257 | tmpImg.Rescale( sz.x, sz.y, quality ); | |
1258 | wxBitmap scaledBmp(tmpImg); | |
1259 | DoDrawBitmap(scaledBmp, pt.x, pt.y, useMask); | |
1260 | } | |
1261 | else | |
1262 | DoDrawBitmap(bmp, pt.x, pt.y, useMask); | |
1263 | } | |
1264 | virtual void DrawScaledBitmap(const wxBitmap &bmp, const wxRect& rect, bool useMask = false, int quality = wxIMAGE_QUALITY_NORMAL) | |
1265 | { | |
1266 | if (bmp.GetWidth() != rect.width || bmp.GetHeight() != rect.height) | |
1267 | { | |
1268 | if (quality != wxIMAGE_QUALITY_HIGH) | |
1269 | quality = wxIMAGE_QUALITY_NORMAL; | |
1270 | wxImage tmpImg = bmp.ConvertToImage(); | |
1271 | tmpImg.Rescale( rect.width, rect.height, quality ); | |
1272 | wxBitmap scaledBmp(tmpImg); | |
1273 | DoDrawBitmap(scaledBmp, rect.x, rect.y, useMask); | |
1274 | } | |
1275 | else | |
1276 | DoDrawBitmap(bmp, rect.x, rect.y, useMask); | |
1277 | } | |
1278 | ||
72cdf4c9 | 1279 | void DrawText(const wxString& text, wxCoord x, wxCoord y) |
a23fd0e1 VZ |
1280 | { DoDrawText(text, x, y); } |
1281 | void DrawText(const wxString& text, const wxPoint& pt) | |
1282 | { DoDrawText(text, pt.x, pt.y); } | |
1283 | ||
95724b1a VZ |
1284 | void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) |
1285 | { DoDrawRotatedText(text, x, y, angle); } | |
1286 | void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle) | |
1287 | { DoDrawRotatedText(text, pt.x, pt.y, angle); } | |
1288 | ||
1e6feb95 VZ |
1289 | // this version puts both optional bitmap and the text into the given |
1290 | // rectangle and aligns is as specified by alignment parameter; it also | |
1291 | // will emphasize the character with the given index if it is != -1 and | |
1292 | // return the bounding rectangle if required | |
1293 | virtual void DrawLabel(const wxString& text, | |
1294 | const wxBitmap& image, | |
1295 | const wxRect& rect, | |
1296 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
1297 | int indexAccel = -1, | |
1298 | wxRect *rectBounding = NULL); | |
1299 | ||
1300 | void DrawLabel(const wxString& text, const wxRect& rect, | |
1301 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
1302 | int indexAccel = -1) | |
1303 | { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); } | |
1304 | ||
72cdf4c9 VZ |
1305 | bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, |
1306 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
68379eaf | 1307 | int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) |
a23fd0e1 VZ |
1308 | { |
1309 | return DoBlit(xdest, ydest, width, height, | |
0cbff120 | 1310 | source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask); |
a23fd0e1 VZ |
1311 | } |
1312 | bool Blit(const wxPoint& destPt, const wxSize& sz, | |
1313 | wxDC *source, const wxPoint& srcPt, | |
68379eaf | 1314 | int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition) |
a23fd0e1 VZ |
1315 | { |
1316 | return DoBlit(destPt.x, destPt.y, sz.x, sz.y, | |
0cbff120 | 1317 | source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y); |
a23fd0e1 | 1318 | } |
e3b81044 VZ |
1319 | |
1320 | bool StretchBlit(wxCoord dstX, wxCoord dstY, | |
1321 | wxCoord dstWidth, wxCoord dstHeight, | |
1322 | wxDC *source, | |
1323 | wxCoord srcX, wxCoord srcY, | |
1324 | wxCoord srcWidth, wxCoord srcHeight, | |
1325 | int rop = wxCOPY, bool useMask = false, | |
1326 | wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord) | |
1327 | { | |
1328 | return DoStretchBlit(dstX, dstY, dstWidth, dstHeight, | |
1329 | source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY); | |
1330 | } | |
1331 | bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize, | |
1332 | wxDC *source, const wxPoint& srcPt, const wxSize& srcSize, | |
1333 | int rop = wxCOPY, bool useMask = false, const wxPoint& srcMaskPt = wxDefaultPosition) | |
1334 | { | |
1335 | return DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y, | |
1336 | source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y); | |
1337 | } | |
1338 | ||
c59abe03 | 1339 | wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const |
c64c9cd3 | 1340 | { |
c59abe03 | 1341 | return DoGetAsBitmap(subrect); |
c64c9cd3 | 1342 | } |
a23fd0e1 VZ |
1343 | |
1344 | #if wxUSE_SPLINES | |
72cdf4c9 VZ |
1345 | // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?) |
1346 | void DrawSpline(wxCoord x1, wxCoord y1, | |
1347 | wxCoord x2, wxCoord y2, | |
1348 | wxCoord x3, wxCoord y3); | |
bd5dd957 | 1349 | void DrawSpline(int n, wxPoint points[]); |
a23fd0e1 VZ |
1350 | |
1351 | void DrawSpline(wxList *points) { DoDrawSpline(points); } | |
1352 | #endif // wxUSE_SPLINES | |
1353 | ||
12bdd77c JS |
1354 | // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE |
1355 | #ifdef __WXWINCE__ | |
1356 | //! Generic method to draw ellipses, circles and arcs with current pen and brush. | |
1357 | /*! \param x Upper left corner of bounding box. | |
1358 | * \param y Upper left corner of bounding box. | |
1359 | * \param w Width of bounding box. | |
1360 | * \param h Height of bounding box. | |
d16b634f | 1361 | * \param sa Starting angle of arc |
12bdd77c JS |
1362 | * (counterclockwise, start at 3 o'clock, 360 is full circle). |
1363 | * \param ea Ending angle of arc. | |
d16b634f | 1364 | * \param angle Rotation angle, the Arc will be rotated after |
12bdd77c JS |
1365 | * calculating begin and end. |
1366 | */ | |
d16b634f VZ |
1367 | void DrawEllipticArcRot( wxCoord x, wxCoord y, |
1368 | wxCoord width, wxCoord height, | |
12bdd77c JS |
1369 | double sa = 0, double ea = 0, double angle = 0 ) |
1370 | { DoDrawEllipticArcRot( x, y, width, height, sa, ea, angle ); } | |
d16b634f VZ |
1371 | |
1372 | void DrawEllipticArcRot( const wxPoint& pt, | |
12bdd77c JS |
1373 | const wxSize& sz, |
1374 | double sa = 0, double ea = 0, double angle = 0 ) | |
1375 | { DoDrawEllipticArcRot( pt.x, pt.y, sz.x, sz.y, sa, ea, angle ); } | |
1376 | ||
1377 | void DrawEllipticArcRot( const wxRect& rect, | |
1378 | double sa = 0, double ea = 0, double angle = 0 ) | |
1379 | { DoDrawEllipticArcRot( rect.x, rect.y, rect.width, rect.height, sa, ea, angle ); } | |
1380 | ||
d16b634f VZ |
1381 | virtual void DoDrawEllipticArcRot( wxCoord x, wxCoord y, |
1382 | wxCoord w, wxCoord h, | |
12bdd77c | 1383 | double sa = 0, double ea = 0, double angle = 0 ); |
d16b634f | 1384 | |
12bdd77c JS |
1385 | //! Rotates points around center. |
1386 | /*! This is a quite straight method, it calculates in pixels | |
1387 | * and so it produces rounding errors. | |
1388 | * \param points The points inside will be rotated. | |
1389 | * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle). | |
1390 | * \param center Center of rotation. | |
d16b634f | 1391 | */ |
c47addef | 1392 | void Rotate( wxList* points, double angle, wxPoint center = wxPoint(0,0) ); |
12bdd77c JS |
1393 | |
1394 | // used by DrawEllipticArcRot | |
1395 | // Careful: wxList gets filled with points you have to delete later. | |
d16b634f VZ |
1396 | void CalculateEllipticPoints( wxList* points, |
1397 | wxCoord xStart, wxCoord yStart, | |
1398 | wxCoord w, wxCoord h, | |
12bdd77c JS |
1399 | double sa, double ea ); |
1400 | #endif | |
d16b634f | 1401 | |
a23fd0e1 VZ |
1402 | // global DC operations |
1403 | // -------------------- | |
1404 | ||
1405 | virtual void Clear() = 0; | |
1406 | ||
68379eaf | 1407 | virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; } |
af0bb3b1 | 1408 | virtual void EndDoc() { } |
a23fd0e1 | 1409 | |
af0bb3b1 VZ |
1410 | virtual void StartPage() { } |
1411 | virtual void EndPage() { } | |
a23fd0e1 | 1412 | |
2e992e06 VZ |
1413 | #if WXWIN_COMPATIBILITY_2_6 |
1414 | wxDEPRECATED( void BeginDrawing() ); | |
1415 | wxDEPRECATED( void EndDrawing() ); | |
1416 | #endif // WXWIN_COMPATIBILITY_2_6 | |
1417 | ||
1418 | ||
a23fd0e1 VZ |
1419 | // set objects to use for drawing |
1420 | // ------------------------------ | |
1421 | ||
1422 | virtual void SetFont(const wxFont& font) = 0; | |
1423 | virtual void SetPen(const wxPen& pen) = 0; | |
1424 | virtual void SetBrush(const wxBrush& brush) = 0; | |
1425 | virtual void SetBackground(const wxBrush& brush) = 0; | |
1426 | virtual void SetBackgroundMode(int mode) = 0; | |
d275c7eb | 1427 | #if wxUSE_PALETTE |
a23fd0e1 | 1428 | virtual void SetPalette(const wxPalette& palette) = 0; |
d275c7eb | 1429 | #endif // wxUSE_PALETTE |
a23fd0e1 VZ |
1430 | |
1431 | // clipping region | |
1432 | // --------------- | |
1433 | ||
72cdf4c9 | 1434 | void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) |
a23fd0e1 VZ |
1435 | { DoSetClippingRegion(x, y, width, height); } |
1436 | void SetClippingRegion(const wxPoint& pt, const wxSize& sz) | |
1437 | { DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); } | |
1438 | void SetClippingRegion(const wxRect& rect) | |
1439 | { DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); } | |
1440 | void SetClippingRegion(const wxRegion& region) | |
1441 | { DoSetClippingRegionAsRegion(region); } | |
1442 | ||
d16b634f | 1443 | virtual void DestroyClippingRegion() { ResetClipping(); } |
a23fd0e1 | 1444 | |
72cdf4c9 | 1445 | void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const |
a23fd0e1 VZ |
1446 | { DoGetClippingBox(x, y, w, h); } |
1447 | void GetClippingBox(wxRect& rect) const | |
8fb3a512 | 1448 | { |
ae500232 | 1449 | DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height); |
8fb3a512 | 1450 | } |
a23fd0e1 VZ |
1451 | |
1452 | // text extent | |
1453 | // ----------- | |
1454 | ||
72cdf4c9 VZ |
1455 | virtual wxCoord GetCharHeight() const = 0; |
1456 | virtual wxCoord GetCharWidth() const = 0; | |
cd9da200 | 1457 | |
1e6feb95 | 1458 | // only works for single line strings |
72cdf4c9 VZ |
1459 | void GetTextExtent(const wxString& string, |
1460 | wxCoord *x, wxCoord *y, | |
1461 | wxCoord *descent = NULL, | |
1462 | wxCoord *externalLeading = NULL, | |
c94f845b | 1463 | const wxFont *theFont = NULL) const |
72cdf4c9 | 1464 | { DoGetTextExtent(string, x, y, descent, externalLeading, theFont); } |
a23fd0e1 | 1465 | |
cc4f194e VZ |
1466 | wxSize GetTextExtent(const wxString& string) const |
1467 | { | |
1468 | wxCoord w, h; | |
1469 | DoGetTextExtent(string, &w, &h); | |
1470 | return wxSize(w, h); | |
1471 | } | |
1472 | ||
1e6feb95 | 1473 | // works for single as well as multi-line strings |
cc4f194e | 1474 | virtual void GetMultiLineTextExtent(const wxString& string, |
1e6feb95 VZ |
1475 | wxCoord *width, |
1476 | wxCoord *height, | |
1477 | wxCoord *heightLine = NULL, | |
c94f845b | 1478 | const wxFont *font = NULL) const; |
1e6feb95 | 1479 | |
cc4f194e VZ |
1480 | wxSize GetMultiLineTextExtent(const wxString& string) const |
1481 | { | |
1482 | wxCoord w, h; | |
1483 | GetMultiLineTextExtent(string, &w, &h); | |
1484 | return wxSize(w, h); | |
1485 | } | |
1486 | ||
0919e93e RD |
1487 | // Measure cumulative width of text after each character |
1488 | bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const | |
1489 | { return DoGetPartialTextExtents(text, widths); } | |
1490 | ||
d16b634f | 1491 | |
a23fd0e1 VZ |
1492 | // size and resolution |
1493 | // ------------------- | |
1494 | ||
1495 | // in device units | |
1496 | void GetSize(int *width, int *height) const | |
1497 | { DoGetSize(width, height); } | |
1498 | wxSize GetSize() const | |
1499 | { | |
1500 | int w, h; | |
1501 | DoGetSize(&w, &h); | |
1502 | ||
1503 | return wxSize(w, h); | |
1504 | } | |
1505 | ||
1506 | // in mm | |
1507 | void GetSizeMM(int* width, int* height) const | |
1508 | { DoGetSizeMM(width, height); } | |
1509 | wxSize GetSizeMM() const | |
1510 | { | |
1511 | int w, h; | |
1512 | DoGetSizeMM(&w, &h); | |
1513 | ||
1514 | return wxSize(w, h); | |
1515 | } | |
1516 | ||
a23fd0e1 VZ |
1517 | // query DC capabilities |
1518 | // --------------------- | |
1519 | ||
1520 | virtual bool CanDrawBitmap() const = 0; | |
1521 | virtual bool CanGetTextExtent() const = 0; | |
1522 | ||
1523 | // colour depth | |
1524 | virtual int GetDepth() const = 0; | |
1525 | ||
1526 | // Resolution in Pixels per inch | |
1527 | virtual wxSize GetPPI() const = 0; | |
1528 | ||
b7cacb43 VZ |
1529 | virtual bool Ok() const { return IsOk(); } |
1530 | virtual bool IsOk() const { return m_ok; } | |
a23fd0e1 | 1531 | |
2439f37a VZ |
1532 | // accessors and setters |
1533 | // --------------------- | |
a23fd0e1 | 1534 | |
2e992e06 VZ |
1535 | virtual int GetBackgroundMode() const { return m_backgroundMode; } |
1536 | virtual const wxBrush& GetBackground() const { return m_backgroundBrush; } | |
1537 | virtual const wxBrush& GetBrush() const { return m_brush; } | |
1538 | virtual const wxFont& GetFont() const { return m_font; } | |
1539 | virtual const wxPen& GetPen() const { return m_pen; } | |
a23fd0e1 | 1540 | |
2e992e06 VZ |
1541 | virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; } |
1542 | virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; } | |
a23fd0e1 VZ |
1543 | virtual void SetTextForeground(const wxColour& colour) |
1544 | { m_textForegroundColour = colour; } | |
1545 | virtual void SetTextBackground(const wxColour& colour) | |
1546 | { m_textBackgroundColour = colour; } | |
1547 | ||
04ab8b6d RR |
1548 | |
1549 | // coordinates conversions and transforms | |
1550 | // -------------------------------------- | |
1551 | ||
1552 | virtual wxCoord DeviceToLogicalX(wxCoord x) const; | |
1553 | virtual wxCoord DeviceToLogicalY(wxCoord y) const; | |
1554 | virtual wxCoord DeviceToLogicalXRel(wxCoord x) const; | |
1555 | virtual wxCoord DeviceToLogicalYRel(wxCoord y) const; | |
1556 | virtual wxCoord LogicalToDeviceX(wxCoord x) const; | |
1557 | virtual wxCoord LogicalToDeviceY(wxCoord y) const; | |
1558 | virtual wxCoord LogicalToDeviceXRel(wxCoord x) const; | |
1559 | virtual wxCoord LogicalToDeviceYRel(wxCoord y) const; | |
1560 | ||
1561 | virtual void SetMapMode(int mode); | |
2e992e06 | 1562 | virtual int GetMapMode() const { return m_mappingMode; } |
a23fd0e1 | 1563 | |
04ab8b6d | 1564 | virtual void SetUserScale(double x, double y); |
a23fd0e1 VZ |
1565 | virtual void GetUserScale(double *x, double *y) const |
1566 | { | |
1567 | if ( x ) *x = m_userScaleX; | |
1568 | if ( y ) *y = m_userScaleY; | |
1569 | } | |
a23fd0e1 | 1570 | |
04ab8b6d | 1571 | virtual void SetLogicalScale(double x, double y); |
a23fd0e1 VZ |
1572 | virtual void GetLogicalScale(double *x, double *y) |
1573 | { | |
1574 | if ( x ) *x = m_logicalScaleX; | |
1575 | if ( y ) *y = m_logicalScaleY; | |
1576 | } | |
a23fd0e1 | 1577 | |
04ab8b6d | 1578 | virtual void SetLogicalOrigin(wxCoord x, wxCoord y); |
72cdf4c9 | 1579 | void GetLogicalOrigin(wxCoord *x, wxCoord *y) const |
a23fd0e1 VZ |
1580 | { DoGetLogicalOrigin(x, y); } |
1581 | wxPoint GetLogicalOrigin() const | |
72cdf4c9 | 1582 | { wxCoord x, y; DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); } |
a23fd0e1 | 1583 | |
04ab8b6d | 1584 | virtual void SetDeviceOrigin(wxCoord x, wxCoord y); |
72cdf4c9 | 1585 | void GetDeviceOrigin(wxCoord *x, wxCoord *y) const |
a23fd0e1 VZ |
1586 | { DoGetDeviceOrigin(x, y); } |
1587 | wxPoint GetDeviceOrigin() const | |
72cdf4c9 | 1588 | { wxCoord x, y; DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); } |
04ab8b6d RR |
1589 | |
1590 | virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y ); | |
a23fd0e1 | 1591 | |
04ab8b6d | 1592 | virtual void ComputeScaleAndOrigin(); |
b1263dcf | 1593 | |
04ab8b6d RR |
1594 | // this needs to overidden if the axis is inverted (such |
1595 | // as when using Postscript, where 0,0 is the lower left | |
1596 | // corner, not the upper left). | |
1597 | virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
a23fd0e1 | 1598 | |
04ab8b6d RR |
1599 | // logical functions |
1600 | // --------------------------- | |
1601 | ||
2e992e06 | 1602 | virtual int GetLogicalFunction() const { return m_logicalFunction; } |
a23fd0e1 VZ |
1603 | virtual void SetLogicalFunction(int function) = 0; |
1604 | ||
a23fd0e1 VZ |
1605 | // bounding box |
1606 | // ------------ | |
1607 | ||
72cdf4c9 | 1608 | virtual void CalcBoundingBox(wxCoord x, wxCoord y) |
a23fd0e1 | 1609 | { |
f6bcfd97 BP |
1610 | if ( m_isBBoxValid ) |
1611 | { | |
1612 | if ( x < m_minX ) m_minX = x; | |
1613 | if ( y < m_minY ) m_minY = y; | |
1614 | if ( x > m_maxX ) m_maxX = x; | |
1615 | if ( y > m_maxY ) m_maxY = y; | |
1616 | } | |
1617 | else | |
1618 | { | |
68379eaf | 1619 | m_isBBoxValid = true; |
f6bcfd97 BP |
1620 | |
1621 | m_minX = x; | |
1622 | m_minY = y; | |
1623 | m_maxX = x; | |
1624 | m_maxY = y; | |
1625 | } | |
1626 | } | |
1627 | ||
1628 | void ResetBoundingBox() | |
1629 | { | |
68379eaf | 1630 | m_isBBoxValid = false; |
f6bcfd97 BP |
1631 | |
1632 | m_minX = m_maxX = m_minY = m_maxY = 0; | |
a23fd0e1 VZ |
1633 | } |
1634 | ||
1635 | // Get the final bounding box of the PostScript or Metafile picture. | |
72cdf4c9 VZ |
1636 | wxCoord MinX() const { return m_minX; } |
1637 | wxCoord MaxX() const { return m_maxX; } | |
1638 | wxCoord MinY() const { return m_minY; } | |
1639 | wxCoord MaxY() const { return m_maxY; } | |
a23fd0e1 VZ |
1640 | |
1641 | // misc old functions | |
1642 | // ------------------ | |
1643 | ||
ad973712 | 1644 | #if WXWIN_COMPATIBILITY_2_8 |
72cdf4c9 | 1645 | // for compatibility with the old code when wxCoord was long everywhere |
1f540d96 | 1646 | wxDEPRECATED( void GetTextExtent(const wxString& string, |
72cdf4c9 VZ |
1647 | long *x, long *y, |
1648 | long *descent = NULL, | |
1649 | long *externalLeading = NULL, | |
cfa87e81 RR |
1650 | const wxFont *theFont = NULL) const ); |
1651 | wxDEPRECATED( void GetLogicalOrigin(long *x, long *y) const ); | |
1652 | wxDEPRECATED( void GetDeviceOrigin(long *x, long *y) const ); | |
1653 | wxDEPRECATED( void GetClippingBox(long *x, long *y, long *w, long *h) const ); | |
ad973712 | 1654 | #endif // WXWIN_COMPATIBILITY_2_8 |
72cdf4c9 | 1655 | |
6ae7410f VZ |
1656 | // RTL related functions |
1657 | // --------------------- | |
1658 | ||
1659 | // get or change the layout direction (LTR or RTL) for this dc, | |
1660 | // wxLayout_Default is returned if layout direction is not supported | |
1661 | virtual wxLayoutDirection GetLayoutDirection() const | |
1662 | { return wxLayout_Default; } | |
1663 | virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir)) | |
1664 | { } | |
1665 | ||
a23fd0e1 VZ |
1666 | protected: |
1667 | // the pure virtual functions which should be implemented by wxDC | |
387ebd3e | 1668 | virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, |
a23fd0e1 VZ |
1669 | int style = wxFLOOD_SURFACE) = 0; |
1670 | ||
213ad8e7 VZ |
1671 | virtual void DoGradientFillLinear(const wxRect& rect, |
1672 | const wxColour& initialColour, | |
1673 | const wxColour& destColour, | |
1674 | wxDirection nDirection = wxEAST); | |
4660e6ac | 1675 | |
fb63a242 SC |
1676 | virtual void DoGradientFillConcentric(const wxRect& rect, |
1677 | const wxColour& initialColour, | |
1678 | const wxColour& destColour, | |
1679 | const wxPoint& circleCenter); | |
1680 | ||
72cdf4c9 | 1681 | virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0; |
a23fd0e1 | 1682 | |
72cdf4c9 VZ |
1683 | virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0; |
1684 | virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0; | |
a23fd0e1 | 1685 | |
72cdf4c9 VZ |
1686 | virtual void DoDrawArc(wxCoord x1, wxCoord y1, |
1687 | wxCoord x2, wxCoord y2, | |
1688 | wxCoord xc, wxCoord yc) = 0; | |
cd9da200 VZ |
1689 | virtual void DoDrawCheckMark(wxCoord x, wxCoord y, |
1690 | wxCoord width, wxCoord height); | |
72cdf4c9 | 1691 | virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, |
a23fd0e1 VZ |
1692 | double sa, double ea) = 0; |
1693 | ||
72cdf4c9 VZ |
1694 | virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0; |
1695 | virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, | |
1696 | wxCoord width, wxCoord height, | |
a23fd0e1 | 1697 | double radius) = 0; |
72cdf4c9 VZ |
1698 | virtual void DoDrawEllipse(wxCoord x, wxCoord y, |
1699 | wxCoord width, wxCoord height) = 0; | |
a23fd0e1 | 1700 | |
72cdf4c9 | 1701 | virtual void DoCrossHair(wxCoord x, wxCoord y) = 0; |
a23fd0e1 | 1702 | |
72cdf4c9 VZ |
1703 | virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0; |
1704 | virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
68379eaf | 1705 | bool useMask = false) = 0; |
a23fd0e1 | 1706 | |
72cdf4c9 | 1707 | virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0; |
95724b1a VZ |
1708 | virtual void DoDrawRotatedText(const wxString& text, |
1709 | wxCoord x, wxCoord y, double angle) = 0; | |
a23fd0e1 | 1710 | |
72cdf4c9 VZ |
1711 | virtual bool DoBlit(wxCoord xdest, wxCoord ydest, |
1712 | wxCoord width, wxCoord height, | |
e3b81044 VZ |
1713 | wxDC *source, |
1714 | wxCoord xsrc, wxCoord ysrc, | |
1715 | int rop = wxCOPY, | |
1716 | bool useMask = false, | |
1717 | wxCoord xsrcMask = wxDefaultCoord, | |
1718 | wxCoord ysrcMask = wxDefaultCoord) = 0; | |
1719 | ||
1720 | virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest, | |
1721 | wxCoord dstWidth, wxCoord dstHeight, | |
1722 | wxDC *source, | |
1723 | wxCoord xsrc, wxCoord ysrc, | |
1724 | wxCoord srcWidth, wxCoord srcHeight, | |
1725 | int rop = wxCOPY, | |
1726 | bool useMask = false, | |
1727 | wxCoord xsrcMask = wxDefaultCoord, | |
1728 | wxCoord ysrcMask = wxDefaultCoord); | |
1729 | ||
1730 | virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const | |
1731 | { return wxNullBitmap; } | |
c64c9cd3 | 1732 | |
a23fd0e1 VZ |
1733 | virtual void DoGetSize(int *width, int *height) const = 0; |
1734 | virtual void DoGetSizeMM(int* width, int* height) const = 0; | |
1735 | ||
1736 | virtual void DoDrawLines(int n, wxPoint points[], | |
72cdf4c9 | 1737 | wxCoord xoffset, wxCoord yoffset) = 0; |
a23fd0e1 | 1738 | virtual void DoDrawPolygon(int n, wxPoint points[], |
72cdf4c9 | 1739 | wxCoord xoffset, wxCoord yoffset, |
a23fd0e1 | 1740 | int fillStyle = wxODDEVEN_RULE) = 0; |
793db755 | 1741 | virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[], |
6e76b35d VZ |
1742 | wxCoord xoffset, wxCoord yoffset, |
1743 | int fillStyle); | |
a23fd0e1 VZ |
1744 | |
1745 | virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0; | |
72cdf4c9 VZ |
1746 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, |
1747 | wxCoord width, wxCoord height) = 0; | |
b0e0d661 | 1748 | |
72cdf4c9 VZ |
1749 | virtual void DoGetClippingBox(wxCoord *x, wxCoord *y, |
1750 | wxCoord *w, wxCoord *h) const | |
a23fd0e1 | 1751 | { |
d16b634f VZ |
1752 | if ( x ) |
1753 | *x = m_clipX1; | |
1754 | if ( y ) | |
1755 | *y = m_clipY1; | |
1756 | if ( w ) | |
1757 | *w = m_clipX2 - m_clipX1; | |
1758 | if ( h ) | |
1759 | *h = m_clipY2 - m_clipY1; | |
a23fd0e1 VZ |
1760 | } |
1761 | ||
72cdf4c9 | 1762 | virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const |
a23fd0e1 VZ |
1763 | { |
1764 | if ( x ) *x = m_logicalOriginX; | |
1765 | if ( y ) *y = m_logicalOriginY; | |
1766 | } | |
1767 | ||
72cdf4c9 | 1768 | virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const |
a23fd0e1 VZ |
1769 | { |
1770 | if ( x ) *x = m_deviceOriginX; | |
1771 | if ( y ) *y = m_deviceOriginY; | |
1772 | } | |
1773 | ||
72cdf4c9 VZ |
1774 | virtual void DoGetTextExtent(const wxString& string, |
1775 | wxCoord *x, wxCoord *y, | |
1776 | wxCoord *descent = NULL, | |
1777 | wxCoord *externalLeading = NULL, | |
c94f845b | 1778 | const wxFont *theFont = NULL) const = 0; |
d16b634f | 1779 | |
0919e93e | 1780 | virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const; |
d16b634f | 1781 | |
64698f9a | 1782 | #if wxUSE_SPLINES |
fe2e4366 | 1783 | virtual void DoDrawSpline(wxList *points); |
64698f9a | 1784 | #endif |
a23fd0e1 VZ |
1785 | |
1786 | protected: | |
d16b634f VZ |
1787 | // unset clipping variables (after clipping region was destroyed) |
1788 | void ResetClipping() | |
1789 | { | |
1790 | m_clipping = false; | |
1791 | ||
1792 | m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0; | |
1793 | } | |
1794 | ||
a23fd0e1 VZ |
1795 | // flags |
1796 | bool m_colour:1; | |
1797 | bool m_ok:1; | |
1798 | bool m_clipping:1; | |
1799 | bool m_isInteractive:1; | |
f6bcfd97 | 1800 | bool m_isBBoxValid:1; |
a23fd0e1 VZ |
1801 | |
1802 | // coordinate system variables | |
1803 | ||
1804 | // TODO short descriptions of what exactly they are would be nice... | |
1805 | ||
72cdf4c9 | 1806 | wxCoord m_logicalOriginX, m_logicalOriginY; |
04ab8b6d RR |
1807 | wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user |
1808 | ||
1809 | wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner | |
1810 | // is not at 0,0. This was the case under | |
1811 | // Mac's GrafPorts (coordinate system | |
1812 | // used toplevel window's origin) and | |
1813 | // e.g. for Postscript, where the native | |
1814 | // origin in the bottom left corner. | |
a23fd0e1 VZ |
1815 | double m_logicalScaleX, m_logicalScaleY; |
1816 | double m_userScaleX, m_userScaleY; | |
04ab8b6d | 1817 | double m_scaleX, m_scaleY; // calculated from logical scale and user scale |
a23fd0e1 VZ |
1818 | |
1819 | // Used by SetAxisOrientation() to invert the axes | |
1820 | int m_signX, m_signY; | |
1821 | ||
04ab8b6d RR |
1822 | // what is a mm on a screen you don't know the size of? |
1823 | double m_mm_to_pix_x, | |
1824 | m_mm_to_pix_y; | |
1825 | ||
a23fd0e1 | 1826 | // bounding and clipping boxes |
72cdf4c9 VZ |
1827 | wxCoord m_minX, m_minY, m_maxX, m_maxY; |
1828 | wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2; | |
a23fd0e1 VZ |
1829 | |
1830 | int m_logicalFunction; | |
1831 | int m_backgroundMode; | |
1832 | int m_mappingMode; | |
1833 | ||
1834 | // GDI objects | |
1835 | wxPen m_pen; | |
1836 | wxBrush m_brush; | |
1837 | wxBrush m_backgroundBrush; | |
1838 | wxColour m_textForegroundColour; | |
1839 | wxColour m_textBackgroundColour; | |
1840 | wxFont m_font; | |
d275c7eb VZ |
1841 | |
1842 | #if wxUSE_PALETTE | |
a23fd0e1 | 1843 | wxPalette m_palette; |
b95edd47 | 1844 | bool m_hasCustomPalette; |
d275c7eb | 1845 | #endif // wxUSE_PALETTE |
a23fd0e1 VZ |
1846 | |
1847 | private: | |
ac84e37d | 1848 | DECLARE_NO_COPY_CLASS(wxDCBase) |
cd9da200 | 1849 | DECLARE_ABSTRACT_CLASS(wxDCBase) |
a23fd0e1 VZ |
1850 | }; |
1851 | ||
2970ae54 RR |
1852 | #endif // wxUSE_NEW_DC |
1853 | ||
a23fd0e1 VZ |
1854 | // ---------------------------------------------------------------------------- |
1855 | // now include the declaration of wxDC class | |
1856 | // ---------------------------------------------------------------------------- | |
1857 | ||
4055ed82 | 1858 | #if defined(__WXPALMOS__) |
ffecfa5a JS |
1859 | #include "wx/palmos/dc.h" |
1860 | #elif defined(__WXMSW__) | |
a23fd0e1 | 1861 | #include "wx/msw/dc.h" |
2049ba38 | 1862 | #elif defined(__WXMOTIF__) |
a23fd0e1 | 1863 | #include "wx/motif/dc.h" |
1be7a35c | 1864 | #elif defined(__WXGTK20__) |
a23fd0e1 | 1865 | #include "wx/gtk/dc.h" |
1be7a35c MR |
1866 | #elif defined(__WXGTK__) |
1867 | #include "wx/gtk1/dc.h" | |
83df96d6 JS |
1868 | #elif defined(__WXX11__) |
1869 | #include "wx/x11/dc.h" | |
1e6feb95 VZ |
1870 | #elif defined(__WXMGL__) |
1871 | #include "wx/mgl/dc.h" | |
b3c86150 VS |
1872 | #elif defined(__WXDFB__) |
1873 | #include "wx/dfb/dc.h" | |
34138703 | 1874 | #elif defined(__WXMAC__) |
a23fd0e1 | 1875 | #include "wx/mac/dc.h" |
f4515f98 DE |
1876 | #elif defined(__WXCOCOA__) |
1877 | #include "wx/cocoa/dc.h" | |
1777b9bb DW |
1878 | #elif defined(__WXPM__) |
1879 | #include "wx/os2/dc.h" | |
c801d85f KB |
1880 | #endif |
1881 | ||
8acd14d1 SC |
1882 | #if wxUSE_GRAPHICS_CONTEXT |
1883 | #include "wx/dcgraph.h" | |
1884 | #endif | |
1885 | ||
1e6feb95 VZ |
1886 | // ---------------------------------------------------------------------------- |
1887 | // helper class: you can use it to temporarily change the DC text colour and | |
1888 | // restore it automatically when the object goes out of scope | |
1889 | // ---------------------------------------------------------------------------- | |
1890 | ||
1891 | class WXDLLEXPORT wxDCTextColourChanger | |
1892 | { | |
1893 | public: | |
ba161d7e | 1894 | wxDCTextColourChanger(wxDC& dc) : m_dc(dc), m_colFgOld() { } |
1e6feb95 | 1895 | |
1b97b23d VS |
1896 | wxDCTextColourChanger(wxDC& dc, const wxColour& col) : m_dc(dc) |
1897 | { | |
1898 | Set(col); | |
1899 | } | |
1900 | ||
1e6feb95 VZ |
1901 | ~wxDCTextColourChanger() |
1902 | { | |
1903 | if ( m_colFgOld.Ok() ) | |
1904 | m_dc.SetTextForeground(m_colFgOld); | |
1905 | } | |
1906 | ||
1907 | void Set(const wxColour& col) | |
1908 | { | |
1909 | if ( !m_colFgOld.Ok() ) | |
1910 | m_colFgOld = m_dc.GetTextForeground(); | |
1911 | m_dc.SetTextForeground(col); | |
1912 | } | |
1913 | ||
1914 | private: | |
1915 | wxDC& m_dc; | |
1916 | ||
1917 | wxColour m_colFgOld; | |
fc7a2a60 VZ |
1918 | |
1919 | DECLARE_NO_COPY_CLASS(wxDCTextColourChanger) | |
1e6feb95 VZ |
1920 | }; |
1921 | ||
4660e6ac WS |
1922 | // ---------------------------------------------------------------------------- |
1923 | // helper class: you can use it to temporarily change the DC pen and | |
1924 | // restore it automatically when the object goes out of scope | |
1925 | // ---------------------------------------------------------------------------- | |
1926 | ||
1927 | class WXDLLEXPORT wxDCPenChanger | |
1928 | { | |
1929 | public: | |
0164f8eb WS |
1930 | wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen()) |
1931 | { | |
1932 | m_dc.SetPen(pen); | |
1933 | } | |
4660e6ac WS |
1934 | |
1935 | ~wxDCPenChanger() | |
1936 | { | |
1937 | if ( m_penOld.Ok() ) | |
1938 | m_dc.SetPen(m_penOld); | |
1939 | } | |
1940 | ||
4660e6ac WS |
1941 | private: |
1942 | wxDC& m_dc; | |
1943 | ||
1944 | wxPen m_penOld; | |
1945 | ||
1946 | DECLARE_NO_COPY_CLASS(wxDCPenChanger) | |
1947 | }; | |
1948 | ||
1949 | // ---------------------------------------------------------------------------- | |
1950 | // helper class: you can use it to temporarily change the DC brush and | |
1951 | // restore it automatically when the object goes out of scope | |
1952 | // ---------------------------------------------------------------------------- | |
1953 | ||
1954 | class WXDLLEXPORT wxDCBrushChanger | |
1955 | { | |
1956 | public: | |
0164f8eb WS |
1957 | wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush()) |
1958 | { | |
1959 | m_dc.SetBrush(brush); | |
1960 | } | |
4660e6ac WS |
1961 | |
1962 | ~wxDCBrushChanger() | |
1963 | { | |
1964 | if ( m_brushOld.Ok() ) | |
1965 | m_dc.SetBrush(m_brushOld); | |
1966 | } | |
1967 | ||
4660e6ac WS |
1968 | private: |
1969 | wxDC& m_dc; | |
1970 | ||
1971 | wxBrush m_brushOld; | |
1972 | ||
1973 | DECLARE_NO_COPY_CLASS(wxDCBrushChanger) | |
1974 | }; | |
1975 | ||
e26be42b VZ |
1976 | // ---------------------------------------------------------------------------- |
1977 | // another small helper class: sets the clipping region in its ctor and | |
1978 | // destroys it in the dtor | |
1979 | // ---------------------------------------------------------------------------- | |
1980 | ||
1981 | class WXDLLEXPORT wxDCClipper | |
1982 | { | |
1983 | public: | |
fc298ea7 VZ |
1984 | wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc) |
1985 | { dc.SetClippingRegion(r); } | |
e26be42b VZ |
1986 | wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc) |
1987 | { dc.SetClippingRegion(r.x, r.y, r.width, r.height); } | |
1988 | wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc) | |
1989 | { dc.SetClippingRegion(x, y, w, h); } | |
1990 | ||
1991 | ~wxDCClipper() { m_dc.DestroyClippingRegion(); } | |
1992 | ||
1993 | private: | |
1994 | wxDC& m_dc; | |
fc7a2a60 VZ |
1995 | |
1996 | DECLARE_NO_COPY_CLASS(wxDCClipper) | |
e26be42b VZ |
1997 | }; |
1998 | ||
8b56b16a | 1999 | #endif // _WX_DC_H_BASE_ |