First update patch for GTK+ print
[wxWidgets.git] / include / wx / dc.h
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/list.h" // we use wxList in inline functions
30 #include "wx/dynarray.h"
31 #include "wx/math.h"
32 #include "wx/image.h"
33
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
44 class WXDLLIMPEXP_FWD_CORE wxImplDC;
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
877 void DrawText(const wxString& text, wxCoord x, wxCoord y)
878 { m_pimpl->DoDrawText(text, x, y); }
879 void DrawText(const wxString& text, const wxPoint& pt)
880 { m_pimpl->DoDrawText(text, pt.x, pt.y); }
881
882 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
883 { m_pimpl->DoDrawRotatedText(text, x, y, angle); }
884 void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
885 { m_pimpl->DoDrawRotatedText(text, pt.x, pt.y, angle); }
886
887 // this version puts both optional bitmap and the text into the given
888 // rectangle and aligns is as specified by alignment parameter; it also
889 // will emphasize the character with the given index if it is != -1 and
890 // return the bounding rectangle if required
891 void DrawLabel(const wxString& text,
892 const wxBitmap& image,
893 const wxRect& rect,
894 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
895 int indexAccel = -1,
896 wxRect *rectBounding = NULL)
897 { m_pimpl->DrawLabel( text, image, rect, alignment, indexAccel, rectBounding ); }
898
899 void DrawLabel(const wxString& text, const wxRect& rect,
900 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
901 int indexAccel = -1)
902 { m_pimpl->DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
903
904 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
905 wxDC *source, wxCoord xsrc, wxCoord ysrc,
906 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord)
907 {
908 return m_pimpl->DoBlit(xdest, ydest, width, height,
909 source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
910 }
911 bool Blit(const wxPoint& destPt, const wxSize& sz,
912 wxDC *source, const wxPoint& srcPt,
913 int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition)
914 {
915 return m_pimpl->DoBlit(destPt.x, destPt.y, sz.x, sz.y,
916 source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
917 }
918
919 bool StretchBlit(wxCoord dstX, wxCoord dstY,
920 wxCoord dstWidth, wxCoord dstHeight,
921 wxDC *source,
922 wxCoord srcX, wxCoord srcY,
923 wxCoord srcWidth, wxCoord srcHeight,
924 int rop = wxCOPY, bool useMask = false,
925 wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord)
926 {
927 return m_pimpl->DoStretchBlit(dstX, dstY, dstWidth, dstHeight,
928 source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY);
929 }
930 bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize,
931 wxDC *source, const wxPoint& srcPt, const wxSize& srcSize,
932 int rop = wxCOPY, bool useMask = false, const wxPoint& srcMaskPt = wxDefaultPosition)
933 {
934 return m_pimpl->DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y,
935 source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y);
936 }
937
938 wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const
939 {
940 return m_pimpl->DoGetAsBitmap(subrect);
941 }
942
943 #if wxUSE_SPLINES
944 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
945 void DrawSpline(wxCoord x1, wxCoord y1,
946 wxCoord x2, wxCoord y2,
947 wxCoord x3, wxCoord y3)
948 { m_pimpl->DrawSpline(x1,y1,x2,y2,x3,y3); }
949 void DrawSpline(int n, wxPoint points[])
950 { m_pimpl->DrawSpline(n,points); }
951
952 void DrawSpline(wxList *points)
953 { m_pimpl->DoDrawSpline(points); }
954 #endif // wxUSE_SPLINES
955
956
957 #if WXWIN_COMPATIBILITY_2_8
958 // for compatibility with the old code when wxCoord was long everywhere
959 wxDEPRECATED( void GetTextExtent(const wxString& string,
960 long *x, long *y,
961 long *descent = NULL,
962 long *externalLeading = NULL,
963 const wxFont *theFont = NULL) const );
964 wxDEPRECATED( void GetLogicalOrigin(long *x, long *y) const );
965 wxDEPRECATED( void GetDeviceOrigin(long *x, long *y) const );
966 wxDEPRECATED( void GetClippingBox(long *x, long *y, long *w, long *h) const );
967 #endif // WXWIN_COMPATIBILITY_2_8
968
969
970 protected:
971 wxImplDC *m_pimpl;
972
973 private:
974 DECLARE_ABSTRACT_CLASS(wxImplDC)
975 }
976
977
978 #else // wxUSE_NEW_DC
979
980
981 class WXDLLIMPEXP_FWD_CORE wxDC;
982 class WXDLLIMPEXP_FWD_CORE wxDCBase;
983
984 class WXDLLEXPORT wxDrawObject
985 {
986 public:
987
988 wxDrawObject()
989 : m_isBBoxValid(false)
990 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
991 { }
992
993 virtual ~wxDrawObject() { }
994
995 virtual void Draw(wxDCBase&) const { }
996
997 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
998 {
999 if ( m_isBBoxValid )
1000 {
1001 if ( x < m_minX ) m_minX = x;
1002 if ( y < m_minY ) m_minY = y;
1003 if ( x > m_maxX ) m_maxX = x;
1004 if ( y > m_maxY ) m_maxY = y;
1005 }
1006 else
1007 {
1008 m_isBBoxValid = true;
1009
1010 m_minX = x;
1011 m_minY = y;
1012 m_maxX = x;
1013 m_maxY = y;
1014 }
1015 }
1016
1017 void ResetBoundingBox()
1018 {
1019 m_isBBoxValid = false;
1020
1021 m_minX = m_maxX = m_minY = m_maxY = 0;
1022 }
1023
1024 // Get the final bounding box of the PostScript or Metafile picture.
1025
1026 wxCoord MinX() const { return m_minX; }
1027 wxCoord MaxX() const { return m_maxX; }
1028 wxCoord MinY() const { return m_minY; }
1029 wxCoord MaxY() const { return m_maxY; }
1030
1031 //to define the type of object for derived objects
1032 virtual int GetType()=0;
1033
1034 protected:
1035 //for boundingbox calculation
1036 bool m_isBBoxValid:1;
1037 //for boundingbox calculation
1038 wxCoord m_minX, m_minY, m_maxX, m_maxY;
1039 };
1040
1041 // ---------------------------------------------------------------------------
1042 // global variables
1043 // ---------------------------------------------------------------------------
1044
1045 // ---------------------------------------------------------------------------
1046 // wxDC is the device context - object on which any drawing is done
1047 // ---------------------------------------------------------------------------
1048
1049 class WXDLLEXPORT wxDCBase : public wxObject
1050 {
1051 public:
1052 wxDCBase();
1053 virtual ~wxDCBase();
1054
1055 // graphic primitives
1056 // ------------------
1057
1058 virtual void DrawObject(wxDrawObject* drawobject)
1059 {
1060 drawobject->Draw(*this);
1061 CalcBoundingBox(drawobject->MinX(),drawobject->MinY());
1062 CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY());
1063 }
1064
1065 bool FloodFill(wxCoord x, wxCoord y, const wxColour& col,
1066 int style = wxFLOOD_SURFACE)
1067 { return DoFloodFill(x, y, col, style); }
1068 bool FloodFill(const wxPoint& pt, const wxColour& col,
1069 int style = wxFLOOD_SURFACE)
1070 { return DoFloodFill(pt.x, pt.y, col, style); }
1071
1072 // fill the area specified by rect with a radial gradient, starting from
1073 // initialColour in the centre of the cercle and fading to destColour.
1074 void GradientFillConcentric(const wxRect& rect,
1075 const wxColour& initialColour,
1076 const wxColour& destColour)
1077 { GradientFillConcentric(rect, initialColour, destColour,
1078 wxPoint(rect.GetWidth() / 2,
1079 rect.GetHeight() / 2)); }
1080
1081 void GradientFillConcentric(const wxRect& rect,
1082 const wxColour& initialColour,
1083 const wxColour& destColour,
1084 const wxPoint& circleCenter)
1085 { DoGradientFillConcentric(rect, initialColour, destColour, circleCenter); }
1086
1087 // fill the area specified by rect with a linear gradient
1088 void GradientFillLinear(const wxRect& rect,
1089 const wxColour& initialColour,
1090 const wxColour& destColour,
1091 wxDirection nDirection = wxEAST)
1092 { DoGradientFillLinear(rect, initialColour, destColour, nDirection); }
1093
1094 bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
1095 { return DoGetPixel(x, y, col); }
1096 bool GetPixel(const wxPoint& pt, wxColour *col) const
1097 { return DoGetPixel(pt.x, pt.y, col); }
1098
1099 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
1100 { DoDrawLine(x1, y1, x2, y2); }
1101 void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
1102 { DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); }
1103
1104 void CrossHair(wxCoord x, wxCoord y)
1105 { DoCrossHair(x, y); }
1106 void CrossHair(const wxPoint& pt)
1107 { DoCrossHair(pt.x, pt.y); }
1108
1109 void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
1110 wxCoord xc, wxCoord yc)
1111 { DoDrawArc(x1, y1, x2, y2, xc, yc); }
1112 void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
1113 { DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
1114
1115 void DrawCheckMark(wxCoord x, wxCoord y,
1116 wxCoord width, wxCoord height)
1117 { DoDrawCheckMark(x, y, width, height); }
1118 void DrawCheckMark(const wxRect& rect)
1119 { DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
1120
1121 void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
1122 double sa, double ea)
1123 { DoDrawEllipticArc(x, y, w, h, sa, ea); }
1124 void DrawEllipticArc(const wxPoint& pt, const wxSize& sz,
1125 double sa, double ea)
1126 { DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); }
1127
1128 void DrawPoint(wxCoord x, wxCoord y)
1129 { DoDrawPoint(x, y); }
1130 void DrawPoint(const wxPoint& pt)
1131 { DoDrawPoint(pt.x, pt.y); }
1132
1133 void DrawLines(int n, wxPoint points[],
1134 wxCoord xoffset = 0, wxCoord yoffset = 0)
1135 { DoDrawLines(n, points, xoffset, yoffset); }
1136 void DrawLines(const wxList *list,
1137 wxCoord xoffset = 0, wxCoord yoffset = 0);
1138
1139 void DrawPolygon(int n, wxPoint points[],
1140 wxCoord xoffset = 0, wxCoord yoffset = 0,
1141 int fillStyle = wxODDEVEN_RULE)
1142 { DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
1143
1144 void DrawPolygon(const wxList *list,
1145 wxCoord xoffset = 0, wxCoord yoffset = 0,
1146 int fillStyle = wxODDEVEN_RULE);
1147
1148 void DrawPolyPolygon(int n, int count[], wxPoint points[],
1149 wxCoord xoffset = 0, wxCoord yoffset = 0,
1150 int fillStyle = wxODDEVEN_RULE)
1151 { DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); }
1152
1153 void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
1154 { DoDrawRectangle(x, y, width, height); }
1155 void DrawRectangle(const wxPoint& pt, const wxSize& sz)
1156 { DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); }
1157 void DrawRectangle(const wxRect& rect)
1158 { DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); }
1159
1160 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
1161 double radius)
1162 { DoDrawRoundedRectangle(x, y, width, height, radius); }
1163 void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
1164 double radius)
1165 { DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); }
1166 void DrawRoundedRectangle(const wxRect& r, double radius)
1167 { DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); }
1168
1169 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius)
1170 { DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); }
1171 void DrawCircle(const wxPoint& pt, wxCoord radius)
1172 { DrawCircle(pt.x, pt.y, radius); }
1173
1174 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
1175 { DoDrawEllipse(x, y, width, height); }
1176 void DrawEllipse(const wxPoint& pt, const wxSize& sz)
1177 { DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); }
1178 void DrawEllipse(const wxRect& rect)
1179 { DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); }
1180
1181 void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
1182 { DoDrawIcon(icon, x, y); }
1183 void DrawIcon(const wxIcon& icon, const wxPoint& pt)
1184 { DoDrawIcon(icon, pt.x, pt.y); }
1185
1186 void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
1187 bool useMask = false)
1188 { DoDrawBitmap(bmp, x, y, useMask); }
1189 void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt,
1190 bool useMask = false)
1191 { DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
1192
1193 void DrawText(const wxString& text, wxCoord x, wxCoord y)
1194 { DoDrawText(text, x, y); }
1195 void DrawText(const wxString& text, const wxPoint& pt)
1196 { DoDrawText(text, pt.x, pt.y); }
1197
1198 void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
1199 { DoDrawRotatedText(text, x, y, angle); }
1200 void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
1201 { DoDrawRotatedText(text, pt.x, pt.y, angle); }
1202
1203 // this version puts both optional bitmap and the text into the given
1204 // rectangle and aligns is as specified by alignment parameter; it also
1205 // will emphasize the character with the given index if it is != -1 and
1206 // return the bounding rectangle if required
1207 virtual void DrawLabel(const wxString& text,
1208 const wxBitmap& image,
1209 const wxRect& rect,
1210 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
1211 int indexAccel = -1,
1212 wxRect *rectBounding = NULL);
1213
1214 void DrawLabel(const wxString& text, const wxRect& rect,
1215 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
1216 int indexAccel = -1)
1217 { DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
1218
1219 bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
1220 wxDC *source, wxCoord xsrc, wxCoord ysrc,
1221 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord)
1222 {
1223 return DoBlit(xdest, ydest, width, height,
1224 source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
1225 }
1226 bool Blit(const wxPoint& destPt, const wxSize& sz,
1227 wxDC *source, const wxPoint& srcPt,
1228 int rop = wxCOPY, bool useMask = false, const wxPoint& srcPtMask = wxDefaultPosition)
1229 {
1230 return DoBlit(destPt.x, destPt.y, sz.x, sz.y,
1231 source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
1232 }
1233
1234 bool StretchBlit(wxCoord dstX, wxCoord dstY,
1235 wxCoord dstWidth, wxCoord dstHeight,
1236 wxDC *source,
1237 wxCoord srcX, wxCoord srcY,
1238 wxCoord srcWidth, wxCoord srcHeight,
1239 int rop = wxCOPY, bool useMask = false,
1240 wxCoord srcMaskX = wxDefaultCoord, wxCoord srcMaskY = wxDefaultCoord)
1241 {
1242 return DoStretchBlit(dstX, dstY, dstWidth, dstHeight,
1243 source, srcX, srcY, srcWidth, srcHeight, rop, useMask, srcMaskX, srcMaskY);
1244 }
1245 bool StretchBlit(const wxPoint& dstPt, const wxSize& dstSize,
1246 wxDC *source, const wxPoint& srcPt, const wxSize& srcSize,
1247 int rop = wxCOPY, bool useMask = false, const wxPoint& srcMaskPt = wxDefaultPosition)
1248 {
1249 return DoStretchBlit(dstPt.x, dstPt.y, dstSize.x, dstSize.y,
1250 source, srcPt.x, srcPt.y, srcSize.x, srcSize.y, rop, useMask, srcMaskPt.x, srcMaskPt.y);
1251 }
1252
1253 wxBitmap GetAsBitmap(const wxRect *subrect = (const wxRect *) NULL) const
1254 {
1255 return DoGetAsBitmap(subrect);
1256 }
1257
1258 #if wxUSE_SPLINES
1259 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
1260 void DrawSpline(wxCoord x1, wxCoord y1,
1261 wxCoord x2, wxCoord y2,
1262 wxCoord x3, wxCoord y3);
1263 void DrawSpline(int n, wxPoint points[]);
1264
1265 void DrawSpline(wxList *points) { DoDrawSpline(points); }
1266 #endif // wxUSE_SPLINES
1267
1268 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
1269 #ifdef __WXWINCE__
1270 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
1271 /*! \param x Upper left corner of bounding box.
1272 * \param y Upper left corner of bounding box.
1273 * \param w Width of bounding box.
1274 * \param h Height of bounding box.
1275 * \param sa Starting angle of arc
1276 * (counterclockwise, start at 3 o'clock, 360 is full circle).
1277 * \param ea Ending angle of arc.
1278 * \param angle Rotation angle, the Arc will be rotated after
1279 * calculating begin and end.
1280 */
1281 void DrawEllipticArcRot( wxCoord x, wxCoord y,
1282 wxCoord width, wxCoord height,
1283 double sa = 0, double ea = 0, double angle = 0 )
1284 { DoDrawEllipticArcRot( x, y, width, height, sa, ea, angle ); }
1285
1286 void DrawEllipticArcRot( const wxPoint& pt,
1287 const wxSize& sz,
1288 double sa = 0, double ea = 0, double angle = 0 )
1289 { DoDrawEllipticArcRot( pt.x, pt.y, sz.x, sz.y, sa, ea, angle ); }
1290
1291 void DrawEllipticArcRot( const wxRect& rect,
1292 double sa = 0, double ea = 0, double angle = 0 )
1293 { DoDrawEllipticArcRot( rect.x, rect.y, rect.width, rect.height, sa, ea, angle ); }
1294
1295 virtual void DoDrawEllipticArcRot( wxCoord x, wxCoord y,
1296 wxCoord w, wxCoord h,
1297 double sa = 0, double ea = 0, double angle = 0 );
1298
1299 //! Rotates points around center.
1300 /*! This is a quite straight method, it calculates in pixels
1301 * and so it produces rounding errors.
1302 * \param points The points inside will be rotated.
1303 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
1304 * \param center Center of rotation.
1305 */
1306 void Rotate( wxList* points, double angle, wxPoint center = wxPoint(0,0) );
1307
1308 // used by DrawEllipticArcRot
1309 // Careful: wxList gets filled with points you have to delete later.
1310 void CalculateEllipticPoints( wxList* points,
1311 wxCoord xStart, wxCoord yStart,
1312 wxCoord w, wxCoord h,
1313 double sa, double ea );
1314 #endif
1315
1316 // global DC operations
1317 // --------------------
1318
1319 virtual void Clear() = 0;
1320
1321 virtual bool StartDoc(const wxString& WXUNUSED(message)) { return true; }
1322 virtual void EndDoc() { }
1323
1324 virtual void StartPage() { }
1325 virtual void EndPage() { }
1326
1327 #if WXWIN_COMPATIBILITY_2_6
1328 wxDEPRECATED( void BeginDrawing() );
1329 wxDEPRECATED( void EndDrawing() );
1330 #endif // WXWIN_COMPATIBILITY_2_6
1331
1332
1333 // set objects to use for drawing
1334 // ------------------------------
1335
1336 virtual void SetFont(const wxFont& font) = 0;
1337 virtual void SetPen(const wxPen& pen) = 0;
1338 virtual void SetBrush(const wxBrush& brush) = 0;
1339 virtual void SetBackground(const wxBrush& brush) = 0;
1340 virtual void SetBackgroundMode(int mode) = 0;
1341 #if wxUSE_PALETTE
1342 virtual void SetPalette(const wxPalette& palette) = 0;
1343 #endif // wxUSE_PALETTE
1344
1345 // clipping region
1346 // ---------------
1347
1348 void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
1349 { DoSetClippingRegion(x, y, width, height); }
1350 void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
1351 { DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
1352 void SetClippingRegion(const wxRect& rect)
1353 { DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
1354 void SetClippingRegion(const wxRegion& region)
1355 { DoSetClippingRegionAsRegion(region); }
1356
1357 virtual void DestroyClippingRegion() { ResetClipping(); }
1358
1359 void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
1360 { DoGetClippingBox(x, y, w, h); }
1361 void GetClippingBox(wxRect& rect) const
1362 {
1363 DoGetClippingBox(&rect.x, &rect.y, &rect.width, &rect.height);
1364 }
1365
1366 // text extent
1367 // -----------
1368
1369 virtual wxCoord GetCharHeight() const = 0;
1370 virtual wxCoord GetCharWidth() const = 0;
1371
1372 // only works for single line strings
1373 void GetTextExtent(const wxString& string,
1374 wxCoord *x, wxCoord *y,
1375 wxCoord *descent = NULL,
1376 wxCoord *externalLeading = NULL,
1377 const wxFont *theFont = NULL) const
1378 { DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
1379
1380 wxSize GetTextExtent(const wxString& string) const
1381 {
1382 wxCoord w, h;
1383 DoGetTextExtent(string, &w, &h);
1384 return wxSize(w, h);
1385 }
1386
1387 // works for single as well as multi-line strings
1388 virtual void GetMultiLineTextExtent(const wxString& string,
1389 wxCoord *width,
1390 wxCoord *height,
1391 wxCoord *heightLine = NULL,
1392 const wxFont *font = NULL) const;
1393
1394 wxSize GetMultiLineTextExtent(const wxString& string) const
1395 {
1396 wxCoord w, h;
1397 GetMultiLineTextExtent(string, &w, &h);
1398 return wxSize(w, h);
1399 }
1400
1401 // Measure cumulative width of text after each character
1402 bool GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
1403 { return DoGetPartialTextExtents(text, widths); }
1404
1405
1406 // size and resolution
1407 // -------------------
1408
1409 // in device units
1410 void GetSize(int *width, int *height) const
1411 { DoGetSize(width, height); }
1412 wxSize GetSize() const
1413 {
1414 int w, h;
1415 DoGetSize(&w, &h);
1416
1417 return wxSize(w, h);
1418 }
1419
1420 // in mm
1421 void GetSizeMM(int* width, int* height) const
1422 { DoGetSizeMM(width, height); }
1423 wxSize GetSizeMM() const
1424 {
1425 int w, h;
1426 DoGetSizeMM(&w, &h);
1427
1428 return wxSize(w, h);
1429 }
1430
1431 // query DC capabilities
1432 // ---------------------
1433
1434 virtual bool CanDrawBitmap() const = 0;
1435 virtual bool CanGetTextExtent() const = 0;
1436
1437 // colour depth
1438 virtual int GetDepth() const = 0;
1439
1440 // Resolution in Pixels per inch
1441 virtual wxSize GetPPI() const = 0;
1442
1443 virtual bool Ok() const { return IsOk(); }
1444 virtual bool IsOk() const { return m_ok; }
1445
1446 // accessors and setters
1447 // ---------------------
1448
1449 virtual int GetBackgroundMode() const { return m_backgroundMode; }
1450 virtual const wxBrush& GetBackground() const { return m_backgroundBrush; }
1451 virtual const wxBrush& GetBrush() const { return m_brush; }
1452 virtual const wxFont& GetFont() const { return m_font; }
1453 virtual const wxPen& GetPen() const { return m_pen; }
1454
1455 virtual const wxColour& GetTextForeground() const { return m_textForegroundColour; }
1456 virtual const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
1457 virtual void SetTextForeground(const wxColour& colour)
1458 { m_textForegroundColour = colour; }
1459 virtual void SetTextBackground(const wxColour& colour)
1460 { m_textBackgroundColour = colour; }
1461
1462
1463 // coordinates conversions and transforms
1464 // --------------------------------------
1465
1466 virtual wxCoord DeviceToLogicalX(wxCoord x) const;
1467 virtual wxCoord DeviceToLogicalY(wxCoord y) const;
1468 virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
1469 virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
1470 virtual wxCoord LogicalToDeviceX(wxCoord x) const;
1471 virtual wxCoord LogicalToDeviceY(wxCoord y) const;
1472 virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
1473 virtual wxCoord LogicalToDeviceYRel(wxCoord y) const;
1474
1475 virtual void SetMapMode(int mode);
1476 virtual int GetMapMode() const { return m_mappingMode; }
1477
1478 virtual void SetUserScale(double x, double y);
1479 virtual void GetUserScale(double *x, double *y) const
1480 {
1481 if ( x ) *x = m_userScaleX;
1482 if ( y ) *y = m_userScaleY;
1483 }
1484
1485 virtual void SetLogicalScale(double x, double y);
1486 virtual void GetLogicalScale(double *x, double *y)
1487 {
1488 if ( x ) *x = m_logicalScaleX;
1489 if ( y ) *y = m_logicalScaleY;
1490 }
1491
1492 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
1493 void GetLogicalOrigin(wxCoord *x, wxCoord *y) const
1494 { DoGetLogicalOrigin(x, y); }
1495 wxPoint GetLogicalOrigin() const
1496 { wxCoord x, y; DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); }
1497
1498 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
1499 void GetDeviceOrigin(wxCoord *x, wxCoord *y) const
1500 { DoGetDeviceOrigin(x, y); }
1501 wxPoint GetDeviceOrigin() const
1502 { wxCoord x, y; DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); }
1503
1504 virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y );
1505
1506 virtual void ComputeScaleAndOrigin();
1507
1508 // this needs to overidden if the axis is inverted (such
1509 // as when using Postscript, where 0,0 is the lower left
1510 // corner, not the upper left).
1511 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
1512
1513 // logical functions
1514 // ---------------------------
1515
1516 virtual int GetLogicalFunction() const { return m_logicalFunction; }
1517 virtual void SetLogicalFunction(int function) = 0;
1518
1519 // bounding box
1520 // ------------
1521
1522 virtual void CalcBoundingBox(wxCoord x, wxCoord y)
1523 {
1524 if ( m_isBBoxValid )
1525 {
1526 if ( x < m_minX ) m_minX = x;
1527 if ( y < m_minY ) m_minY = y;
1528 if ( x > m_maxX ) m_maxX = x;
1529 if ( y > m_maxY ) m_maxY = y;
1530 }
1531 else
1532 {
1533 m_isBBoxValid = true;
1534
1535 m_minX = x;
1536 m_minY = y;
1537 m_maxX = x;
1538 m_maxY = y;
1539 }
1540 }
1541
1542 void ResetBoundingBox()
1543 {
1544 m_isBBoxValid = false;
1545
1546 m_minX = m_maxX = m_minY = m_maxY = 0;
1547 }
1548
1549 // Get the final bounding box of the PostScript or Metafile picture.
1550 wxCoord MinX() const { return m_minX; }
1551 wxCoord MaxX() const { return m_maxX; }
1552 wxCoord MinY() const { return m_minY; }
1553 wxCoord MaxY() const { return m_maxY; }
1554
1555 // misc old functions
1556 // ------------------
1557
1558 #if WXWIN_COMPATIBILITY_2_8
1559 // for compatibility with the old code when wxCoord was long everywhere
1560 wxDEPRECATED( void GetTextExtent(const wxString& string,
1561 long *x, long *y,
1562 long *descent = NULL,
1563 long *externalLeading = NULL,
1564 const wxFont *theFont = NULL) const );
1565 wxDEPRECATED( void GetLogicalOrigin(long *x, long *y) const );
1566 wxDEPRECATED( void GetDeviceOrigin(long *x, long *y) const );
1567 wxDEPRECATED( void GetClippingBox(long *x, long *y, long *w, long *h) const );
1568 #endif // WXWIN_COMPATIBILITY_2_8
1569
1570 // RTL related functions
1571 // ---------------------
1572
1573 // get or change the layout direction (LTR or RTL) for this dc,
1574 // wxLayout_Default is returned if layout direction is not supported
1575 virtual wxLayoutDirection GetLayoutDirection() const
1576 { return wxLayout_Default; }
1577 virtual void SetLayoutDirection(wxLayoutDirection WXUNUSED(dir))
1578 { }
1579
1580 protected:
1581 // the pure virtual functions which should be implemented by wxDC
1582 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
1583 int style = wxFLOOD_SURFACE) = 0;
1584
1585 virtual void DoGradientFillLinear(const wxRect& rect,
1586 const wxColour& initialColour,
1587 const wxColour& destColour,
1588 wxDirection nDirection = wxEAST);
1589
1590 virtual void DoGradientFillConcentric(const wxRect& rect,
1591 const wxColour& initialColour,
1592 const wxColour& destColour,
1593 const wxPoint& circleCenter);
1594
1595 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
1596
1597 virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
1598 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
1599
1600 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
1601 wxCoord x2, wxCoord y2,
1602 wxCoord xc, wxCoord yc) = 0;
1603 virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
1604 wxCoord width, wxCoord height);
1605 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
1606 double sa, double ea) = 0;
1607
1608 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
1609 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
1610 wxCoord width, wxCoord height,
1611 double radius) = 0;
1612 virtual void DoDrawEllipse(wxCoord x, wxCoord y,
1613 wxCoord width, wxCoord height) = 0;
1614
1615 virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
1616
1617 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
1618 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
1619 bool useMask = false) = 0;
1620
1621 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
1622 virtual void DoDrawRotatedText(const wxString& text,
1623 wxCoord x, wxCoord y, double angle) = 0;
1624
1625 virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
1626 wxCoord width, wxCoord height,
1627 wxDC *source,
1628 wxCoord xsrc, wxCoord ysrc,
1629 int rop = wxCOPY,
1630 bool useMask = false,
1631 wxCoord xsrcMask = wxDefaultCoord,
1632 wxCoord ysrcMask = wxDefaultCoord) = 0;
1633
1634 virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest,
1635 wxCoord dstWidth, wxCoord dstHeight,
1636 wxDC *source,
1637 wxCoord xsrc, wxCoord ysrc,
1638 wxCoord srcWidth, wxCoord srcHeight,
1639 int rop = wxCOPY,
1640 bool useMask = false,
1641 wxCoord xsrcMask = wxDefaultCoord,
1642 wxCoord ysrcMask = wxDefaultCoord);
1643
1644 virtual wxBitmap DoGetAsBitmap(const wxRect *WXUNUSED(subrect)) const
1645 { return wxNullBitmap; }
1646
1647 virtual void DoGetSize(int *width, int *height) const = 0;
1648 virtual void DoGetSizeMM(int* width, int* height) const = 0;
1649
1650 virtual void DoDrawLines(int n, wxPoint points[],
1651 wxCoord xoffset, wxCoord yoffset) = 0;
1652 virtual void DoDrawPolygon(int n, wxPoint points[],
1653 wxCoord xoffset, wxCoord yoffset,
1654 int fillStyle = wxODDEVEN_RULE) = 0;
1655 virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
1656 wxCoord xoffset, wxCoord yoffset,
1657 int fillStyle);
1658
1659 virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0;
1660 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
1661 wxCoord width, wxCoord height) = 0;
1662
1663 virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
1664 wxCoord *w, wxCoord *h) const
1665 {
1666 if ( x )
1667 *x = m_clipX1;
1668 if ( y )
1669 *y = m_clipY1;
1670 if ( w )
1671 *w = m_clipX2 - m_clipX1;
1672 if ( h )
1673 *h = m_clipY2 - m_clipY1;
1674 }
1675
1676 virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
1677 {
1678 if ( x ) *x = m_logicalOriginX;
1679 if ( y ) *y = m_logicalOriginY;
1680 }
1681
1682 virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
1683 {
1684 if ( x ) *x = m_deviceOriginX;
1685 if ( y ) *y = m_deviceOriginY;
1686 }
1687
1688 virtual void DoGetTextExtent(const wxString& string,
1689 wxCoord *x, wxCoord *y,
1690 wxCoord *descent = NULL,
1691 wxCoord *externalLeading = NULL,
1692 const wxFont *theFont = NULL) const = 0;
1693
1694 virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
1695
1696 #if wxUSE_SPLINES
1697 virtual void DoDrawSpline(wxList *points);
1698 #endif
1699
1700 protected:
1701 // unset clipping variables (after clipping region was destroyed)
1702 void ResetClipping()
1703 {
1704 m_clipping = false;
1705
1706 m_clipX1 = m_clipX2 = m_clipY1 = m_clipY2 = 0;
1707 }
1708
1709 // flags
1710 bool m_colour:1;
1711 bool m_ok:1;
1712 bool m_clipping:1;
1713 bool m_isInteractive:1;
1714 bool m_isBBoxValid:1;
1715
1716 // coordinate system variables
1717
1718 // TODO short descriptions of what exactly they are would be nice...
1719
1720 wxCoord m_logicalOriginX, m_logicalOriginY;
1721 wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user
1722
1723 wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner
1724 // is not at 0,0. This was the case under
1725 // Mac's GrafPorts (coordinate system
1726 // used toplevel window's origin) and
1727 // e.g. for Postscript, where the native
1728 // origin in the bottom left corner.
1729 double m_logicalScaleX, m_logicalScaleY;
1730 double m_userScaleX, m_userScaleY;
1731 double m_scaleX, m_scaleY; // calculated from logical scale and user scale
1732
1733 // Used by SetAxisOrientation() to invert the axes
1734 int m_signX, m_signY;
1735
1736 // what is a mm on a screen you don't know the size of?
1737 double m_mm_to_pix_x,
1738 m_mm_to_pix_y;
1739
1740 // bounding and clipping boxes
1741 wxCoord m_minX, m_minY, m_maxX, m_maxY;
1742 wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
1743
1744 int m_logicalFunction;
1745 int m_backgroundMode;
1746 int m_mappingMode;
1747
1748 // GDI objects
1749 wxPen m_pen;
1750 wxBrush m_brush;
1751 wxBrush m_backgroundBrush;
1752 wxColour m_textForegroundColour;
1753 wxColour m_textBackgroundColour;
1754 wxFont m_font;
1755
1756 #if wxUSE_PALETTE
1757 wxPalette m_palette;
1758 bool m_hasCustomPalette;
1759 #endif // wxUSE_PALETTE
1760
1761 private:
1762 DECLARE_NO_COPY_CLASS(wxDCBase)
1763 DECLARE_ABSTRACT_CLASS(wxDCBase)
1764 };
1765
1766 #endif // wxUSE_NEW_DC
1767
1768 // ----------------------------------------------------------------------------
1769 // now include the declaration of wxDC class
1770 // ----------------------------------------------------------------------------
1771
1772 #if defined(__WXPALMOS__)
1773 #include "wx/palmos/dc.h"
1774 #elif defined(__WXMSW__)
1775 #include "wx/msw/dc.h"
1776 #elif defined(__WXMOTIF__)
1777 #include "wx/motif/dc.h"
1778 #elif defined(__WXGTK20__)
1779 #include "wx/gtk/dc.h"
1780 #elif defined(__WXGTK__)
1781 #include "wx/gtk1/dc.h"
1782 #elif defined(__WXX11__)
1783 #include "wx/x11/dc.h"
1784 #elif defined(__WXMGL__)
1785 #include "wx/mgl/dc.h"
1786 #elif defined(__WXDFB__)
1787 #include "wx/dfb/dc.h"
1788 #elif defined(__WXMAC__)
1789 #include "wx/mac/dc.h"
1790 #elif defined(__WXCOCOA__)
1791 #include "wx/cocoa/dc.h"
1792 #elif defined(__WXPM__)
1793 #include "wx/os2/dc.h"
1794 #endif
1795
1796 #if wxUSE_GRAPHICS_CONTEXT
1797 #include "wx/dcgraph.h"
1798 #endif
1799
1800 // ----------------------------------------------------------------------------
1801 // helper class: you can use it to temporarily change the DC text colour and
1802 // restore it automatically when the object goes out of scope
1803 // ----------------------------------------------------------------------------
1804
1805 class WXDLLEXPORT wxDCTextColourChanger
1806 {
1807 public:
1808 wxDCTextColourChanger(wxDC& dc) : m_dc(dc), m_colFgOld() { }
1809
1810 wxDCTextColourChanger(wxDC& dc, const wxColour& col) : m_dc(dc)
1811 {
1812 Set(col);
1813 }
1814
1815 ~wxDCTextColourChanger()
1816 {
1817 if ( m_colFgOld.Ok() )
1818 m_dc.SetTextForeground(m_colFgOld);
1819 }
1820
1821 void Set(const wxColour& col)
1822 {
1823 if ( !m_colFgOld.Ok() )
1824 m_colFgOld = m_dc.GetTextForeground();
1825 m_dc.SetTextForeground(col);
1826 }
1827
1828 private:
1829 wxDC& m_dc;
1830
1831 wxColour m_colFgOld;
1832
1833 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger)
1834 };
1835
1836 // ----------------------------------------------------------------------------
1837 // helper class: you can use it to temporarily change the DC pen and
1838 // restore it automatically when the object goes out of scope
1839 // ----------------------------------------------------------------------------
1840
1841 class WXDLLEXPORT wxDCPenChanger
1842 {
1843 public:
1844 wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen())
1845 {
1846 m_dc.SetPen(pen);
1847 }
1848
1849 ~wxDCPenChanger()
1850 {
1851 if ( m_penOld.Ok() )
1852 m_dc.SetPen(m_penOld);
1853 }
1854
1855 private:
1856 wxDC& m_dc;
1857
1858 wxPen m_penOld;
1859
1860 DECLARE_NO_COPY_CLASS(wxDCPenChanger)
1861 };
1862
1863 // ----------------------------------------------------------------------------
1864 // helper class: you can use it to temporarily change the DC brush and
1865 // restore it automatically when the object goes out of scope
1866 // ----------------------------------------------------------------------------
1867
1868 class WXDLLEXPORT wxDCBrushChanger
1869 {
1870 public:
1871 wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush())
1872 {
1873 m_dc.SetBrush(brush);
1874 }
1875
1876 ~wxDCBrushChanger()
1877 {
1878 if ( m_brushOld.Ok() )
1879 m_dc.SetBrush(m_brushOld);
1880 }
1881
1882 private:
1883 wxDC& m_dc;
1884
1885 wxBrush m_brushOld;
1886
1887 DECLARE_NO_COPY_CLASS(wxDCBrushChanger)
1888 };
1889
1890 // ----------------------------------------------------------------------------
1891 // another small helper class: sets the clipping region in its ctor and
1892 // destroys it in the dtor
1893 // ----------------------------------------------------------------------------
1894
1895 class WXDLLEXPORT wxDCClipper
1896 {
1897 public:
1898 wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc)
1899 { dc.SetClippingRegion(r); }
1900 wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc)
1901 { dc.SetClippingRegion(r.x, r.y, r.width, r.height); }
1902 wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc)
1903 { dc.SetClippingRegion(x, y, w, h); }
1904
1905 ~wxDCClipper() { m_dc.DestroyClippingRegion(); }
1906
1907 private:
1908 wxDC& m_dc;
1909
1910 DECLARE_NO_COPY_CLASS(wxDCClipper)
1911 };
1912
1913 #endif // _WX_DC_H_BASE_