1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DC_H_BASE_
13 #define _WX_DC_H_BASE_
15 // ----------------------------------------------------------------------------
16 // headers which we must include here
17 // ----------------------------------------------------------------------------
19 #include "wx/object.h" // the base class
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
28 #include "wx/palette.h"
29 #include "wx/dynarray.h"
32 #include "wx/cmndata.h"
34 #define wxUSE_NEW_DC 1
36 class WXDLLIMPEXP_FWD_CORE wxDC
;
37 class WXDLLIMPEXP_FWD_CORE wxClientDC
;
38 class WXDLLIMPEXP_FWD_CORE wxPaintDC
;
39 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
40 class WXDLLIMPEXP_FWD_CORE wxScreenDC
;
41 class WXDLLIMPEXP_FWD_CORE wxMemoryDC
;
42 class WXDLLIMPEXP_FWD_CORE wxPrinterDC
;
44 //-----------------------------------------------------------------------------
45 // wxDrawObject helper class
46 //-----------------------------------------------------------------------------
48 class WXDLLEXPORT wxDrawObject
53 : m_isBBoxValid(false)
54 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
57 virtual ~wxDrawObject() { }
59 virtual void Draw(wxDC
&) const { }
61 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
65 if ( x
< m_minX
) m_minX
= x
;
66 if ( y
< m_minY
) m_minY
= y
;
67 if ( x
> m_maxX
) m_maxX
= x
;
68 if ( y
> m_maxY
) m_maxY
= y
;
81 void ResetBoundingBox()
83 m_isBBoxValid
= false;
85 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
88 // Get the final bounding box of the PostScript or Metafile picture.
90 wxCoord
MinX() const { return m_minX
; }
91 wxCoord
MaxX() const { return m_maxX
; }
92 wxCoord
MinY() const { return m_minY
; }
93 wxCoord
MaxY() const { return m_maxY
; }
95 //to define the type of object for derived objects
96 virtual int GetType()=0;
99 //for boundingbox calculation
100 bool m_isBBoxValid
:1;
101 //for boundingbox calculation
102 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
106 //-----------------------------------------------------------------------------
108 //-----------------------------------------------------------------------------
110 class WXDLLIMPEXP_FWD_CORE wxDCImpl
;
112 class WXDLLIMPEXP_CORE wxDCFactory
116 virtual ~wxDCFactory() {}
118 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
) = 0;
119 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
) = 0;
120 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
) = 0;
121 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
) = 0;
122 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
) = 0;
123 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
) = 0;
124 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
) = 0;
125 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
) = 0;
126 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
) = 0;
127 virtual wxDCImpl
* CreateScreenDC( wxScreenDC
*owner
) = 0;
128 #if wxUSE_PRINTING_ARCHITECTURE
129 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
) = 0;
132 static void SetDCFactory( wxDCFactory
*factory
);
133 static wxDCFactory
*GetFactory();
135 static wxDCFactory
*m_factory
;
138 //-----------------------------------------------------------------------------
140 //-----------------------------------------------------------------------------
142 class WXDLLIMPEXP_CORE wxNativeDCFactory
: public wxDCFactory
145 wxNativeDCFactory() {}
147 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
);
148 virtual wxDCImpl
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
);
149 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
);
150 virtual wxDCImpl
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
);
151 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
);
152 virtual wxDCImpl
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
);
153 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
);
154 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
);
155 virtual wxDCImpl
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
);
156 virtual wxDCImpl
* CreateScreenDC( wxScreenDC
*owner
);
157 #if wxUSE_PRINTING_ARCHITECTURE
158 virtual wxDCImpl
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
);
162 //-----------------------------------------------------------------------------
164 //-----------------------------------------------------------------------------
166 class WXDLLIMPEXP_CORE wxDCImpl
: public wxObject
169 wxDCImpl( wxDC
*owner
);
172 wxDC
*GetOwner() const { return m_owner
; }
174 wxWindow
* GetWindow() const { return m_window
; }
176 virtual bool IsOk() const { return m_ok
; }
178 // query capabilities
180 virtual bool CanDrawBitmap() const = 0;
181 virtual bool CanGetTextExtent() const = 0;
183 // query dimension, colour deps, resolution
185 virtual void DoGetSize(int *width
, int *height
) const = 0;
186 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
188 virtual int GetDepth() const = 0;
189 virtual wxSize
GetPPI() const = 0;
191 // Right-To-Left (RTL) modes
193 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
194 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
198 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
199 virtual void EndDoc() { }
201 virtual void StartPage() { }
202 virtual void EndPage() { }
204 // flushing the content of this dc immediately eg onto screen
205 virtual void Flush() { }
209 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
213 if ( x
< m_minX
) m_minX
= x
;
214 if ( y
< m_minY
) m_minY
= y
;
215 if ( x
> m_maxX
) m_maxX
= x
;
216 if ( y
> m_maxY
) m_maxY
= y
;
220 m_isBBoxValid
= true;
228 void ResetBoundingBox()
230 m_isBBoxValid
= false;
232 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
235 wxCoord
MinX() const { return m_minX
; }
236 wxCoord
MaxX() const { return m_maxX
; }
237 wxCoord
MinY() const { return m_minY
; }
238 wxCoord
MaxY() const { return m_maxY
; }
240 // setters and getters
242 virtual void SetFont(const wxFont
& font
) = 0;
243 virtual const wxFont
& GetFont() const { return m_font
; }
245 virtual void SetPen(const wxPen
& pen
) = 0;
246 virtual const wxPen
& GetPen() const { return m_pen
; }
248 virtual void SetBrush(const wxBrush
& brush
) = 0;
249 virtual const wxBrush
& GetBrush() const { return m_brush
; }
251 virtual void SetBackground(const wxBrush
& brush
) = 0;
252 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
254 virtual void SetBackgroundMode(int mode
) = 0;
255 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
257 virtual void SetTextForeground(const wxColour
& colour
)
258 { m_textForegroundColour
= colour
; }
259 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
261 virtual void SetTextBackground(const wxColour
& colour
)
262 { m_textBackgroundColour
= colour
; }
263 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
266 virtual void SetPalette(const wxPalette
& palette
) = 0;
267 #endif // wxUSE_PALETTE
271 virtual void SetLogicalFunction(int function
) = 0;
272 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
276 virtual wxCoord
GetCharHeight() const = 0;
277 virtual wxCoord
GetCharWidth() const = 0;
278 virtual void DoGetTextExtent(const wxString
& string
,
279 wxCoord
*x
, wxCoord
*y
,
280 wxCoord
*descent
= NULL
,
281 wxCoord
*externalLeading
= NULL
,
282 const wxFont
*theFont
= NULL
) const = 0;
283 virtual void GetMultiLineTextExtent(const wxString
& string
,
286 wxCoord
*heightLine
= NULL
,
287 const wxFont
*font
= NULL
) const;
288 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
292 virtual void Clear() = 0;
296 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
297 wxCoord width
, wxCoord height
) = 0;
298 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
300 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
301 wxCoord
*w
, wxCoord
*h
) const
308 *w
= m_clipX2
- m_clipX1
;
310 *h
= m_clipY2
- m_clipY1
;
313 virtual void DestroyClippingRegion() { ResetClipping(); }
316 // coordinates conversions and transforms
318 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
319 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
320 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
321 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
322 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
323 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
324 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
325 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
327 virtual void SetMapMode(int mode
);
328 virtual int GetMapMode() const { return m_mappingMode
; }
330 virtual void SetUserScale(double x
, double y
);
331 virtual void GetUserScale(double *x
, double *y
) const
333 if ( x
) *x
= m_userScaleX
;
334 if ( y
) *y
= m_userScaleY
;
337 virtual void SetLogicalScale(double x
, double y
);
338 virtual void GetLogicalScale(double *x
, double *y
)
340 if ( x
) *x
= m_logicalScaleX
;
341 if ( y
) *y
= m_logicalScaleY
;
344 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
345 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
347 if ( x
) *x
= m_logicalOriginX
;
348 if ( y
) *y
= m_logicalOriginY
;
351 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
352 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
354 if ( x
) *x
= m_deviceOriginX
;
355 if ( y
) *y
= m_deviceOriginY
;
358 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
360 virtual void ComputeScaleAndOrigin();
362 // this needs to overidden if the axis is inverted
363 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
365 // ---------------------------------------------------------
366 // the actual drawing API
368 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
369 int style
= wxFLOOD_SURFACE
) = 0;
371 virtual void DoGradientFillLinear(const wxRect
& rect
,
372 const wxColour
& initialColour
,
373 const wxColour
& destColour
,
374 wxDirection nDirection
= wxEAST
);
376 virtual void DoGradientFillConcentric(const wxRect
& rect
,
377 const wxColour
& initialColour
,
378 const wxColour
& destColour
,
379 const wxPoint
& circleCenter
);
381 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
383 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
384 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
386 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
387 wxCoord x2
, wxCoord y2
,
388 wxCoord xc
, wxCoord yc
) = 0;
389 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
390 wxCoord width
, wxCoord height
);
391 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
392 double sa
, double ea
) = 0;
394 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
395 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
396 wxCoord width
, wxCoord height
,
398 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
399 wxCoord width
, wxCoord height
) = 0;
401 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
403 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
404 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
405 bool useMask
= false) = 0;
407 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
408 virtual void DoDrawRotatedText(const wxString
& text
,
409 wxCoord x
, wxCoord y
, double angle
) = 0;
411 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
412 wxCoord width
, wxCoord height
,
414 wxCoord xsrc
, wxCoord ysrc
,
416 bool useMask
= false,
417 wxCoord xsrcMask
= wxDefaultCoord
,
418 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
420 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
421 wxCoord dstWidth
, wxCoord dstHeight
,
423 wxCoord xsrc
, wxCoord ysrc
,
424 wxCoord srcWidth
, wxCoord srcHeight
,
426 bool useMask
= false,
427 wxCoord xsrcMask
= wxDefaultCoord
,
428 wxCoord ysrcMask
= wxDefaultCoord
);
430 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
431 { return wxNullBitmap
; }
434 virtual void DoDrawLines(int n
, wxPoint points
[],
435 wxCoord xoffset
, wxCoord yoffset
) = 0;
436 virtual void DrawLines(const wxPointList
*list
,
437 wxCoord xoffset
, wxCoord yoffset
);
439 virtual void DoDrawPolygon(int n
, wxPoint points
[],
440 wxCoord xoffset
, wxCoord yoffset
,
441 int fillStyle
= wxODDEVEN_RULE
) = 0;
442 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
443 wxCoord xoffset
, wxCoord yoffset
,
445 void DrawPolygon(const wxPointList
*list
,
446 wxCoord xoffset
, wxCoord yoffset
,
451 virtual void DoDrawSpline(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
, wxCoord x3
, wxCoord y3
);
452 virtual void DoDrawSpline(int n
, wxPoint points
[]);
453 virtual void DoDrawSpline(const wxPointList
*points
);
456 // ---------------------------------------------------------
457 // wxMemoryDC Impl API
459 virtual void DoSelect(const wxBitmap
& WXUNUSED(bmp
))
462 virtual const wxBitmap
& GetSelectedBitmap() const
463 { return wxNullBitmap
; }
464 virtual wxBitmap
& GetSelectedBitmap()
465 { return wxNullBitmap
; }
467 // ---------------------------------------------------------
468 // wxPrinterDC Impl API
470 virtual wxRect
GetPaperRect()
471 { int w
= 0; int h
= 0; DoGetSize( &w
, &h
); return wxRect(0,0,w
,h
); }
473 virtual int GetResolution()
480 // unset clipping variables (after clipping region was destroyed)
485 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
488 // window on which the DC draws or NULL
495 bool m_isInteractive
:1;
496 bool m_isBBoxValid
:1;
498 // coordinate system variables
500 wxCoord m_logicalOriginX
, m_logicalOriginY
;
501 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
503 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
504 // is not at 0,0. This was the case under
505 // Mac's GrafPorts (coordinate system
506 // used toplevel window's origin) and
507 // e.g. for Postscript, where the native
508 // origin in the bottom left corner.
509 double m_logicalScaleX
, m_logicalScaleY
;
510 double m_userScaleX
, m_userScaleY
;
511 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
513 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
515 // what is a mm on a screen you don't know the size of?
516 double m_mm_to_pix_x
,
519 // bounding and clipping boxes
520 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
521 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
523 int m_logicalFunction
;
524 int m_backgroundMode
;
529 wxBrush m_backgroundBrush
;
530 wxColour m_textForegroundColour
;
531 wxColour m_textBackgroundColour
;
536 bool m_hasCustomPalette
;
537 #endif // wxUSE_PALETTE
540 DECLARE_ABSTRACT_CLASS(wxDCImpl
)
544 class WXDLLIMPEXP_CORE wxDC
: public wxObject
547 wxDC() { m_pimpl
= NULL
; }
548 ~wxDC() { if (m_pimpl
) delete m_pimpl
; }
552 const wxDCImpl
*GetImpl() const
555 wxWindow
*GetWindow()
556 { return m_pimpl
->GetWindow(); }
559 { return m_pimpl
&& m_pimpl
->IsOk(); }
561 // query capabilities
563 bool CanDrawBitmap() const
564 { return m_pimpl
->CanDrawBitmap(); }
565 bool CanGetTextExtent() const
566 { return m_pimpl
->CanGetTextExtent(); }
568 // query dimension, colour deps, resolution
570 void GetSize(int *width
, int *height
) const
571 { m_pimpl
->DoGetSize(width
, height
); }
573 wxSize
GetSize() const
576 m_pimpl
->DoGetSize(&w
, &h
);
580 void GetSizeMM(int* width
, int* height
) const
581 { m_pimpl
->DoGetSizeMM(width
, height
); }
582 wxSize
GetSizeMM() const
585 m_pimpl
->DoGetSizeMM(&w
, &h
);
590 { return m_pimpl
->GetDepth(); }
591 wxSize
GetPPI() const
592 { return m_pimpl
->GetPPI(); }
594 virtual int GetResolution()
595 { return m_pimpl
->GetResolution(); }
597 // Right-To-Left (RTL) modes
599 void SetLayoutDirection(wxLayoutDirection dir
)
600 { m_pimpl
->SetLayoutDirection( dir
); }
601 wxLayoutDirection
GetLayoutDirection() const
602 { return m_pimpl
->GetLayoutDirection(); }
606 bool StartDoc(const wxString
& message
)
607 { return m_pimpl
->StartDoc(message
); }
609 { m_pimpl
->EndDoc(); }
612 { m_pimpl
->StartPage(); }
614 { m_pimpl
->EndPage(); }
618 void CalcBoundingBox(wxCoord x
, wxCoord y
)
619 { m_pimpl
->CalcBoundingBox(x
,y
); }
620 void ResetBoundingBox()
621 { m_pimpl
->ResetBoundingBox(); }
624 { return m_pimpl
->MinX(); }
626 { return m_pimpl
->MaxX(); }
628 { return m_pimpl
->MinY(); }
630 { return m_pimpl
->MaxY(); }
632 // setters and getters
634 void SetFont(const wxFont
& font
)
635 { m_pimpl
->SetFont( font
); }
636 const wxFont
& GetFont() const
637 { return m_pimpl
->GetFont(); }
639 void SetPen(const wxPen
& pen
)
640 { m_pimpl
->SetPen( pen
); }
641 const wxPen
& GetPen() const
642 { return m_pimpl
->GetPen(); }
644 void SetBrush(const wxBrush
& brush
)
645 { m_pimpl
->SetBrush( brush
); }
646 const wxBrush
& GetBrush() const
647 { return m_pimpl
->GetBrush(); }
649 void SetBackground(const wxBrush
& brush
)
650 { m_pimpl
->SetBackground( brush
); }
651 const wxBrush
& GetBackground() const
652 { return m_pimpl
->GetBackground(); }
654 void SetBackgroundMode(int mode
)
655 { m_pimpl
->SetBackgroundMode( mode
); }
656 int GetBackgroundMode() const
657 { return m_pimpl
->GetBackgroundMode(); }
659 void SetTextForeground(const wxColour
& colour
)
660 { m_pimpl
->SetTextForeground(colour
); }
661 const wxColour
& GetTextForeground() const
662 { return m_pimpl
->GetTextForeground(); }
664 void SetTextBackground(const wxColour
& colour
)
665 { m_pimpl
->SetTextBackground(colour
); }
666 const wxColour
& GetTextBackground() const
667 { return m_pimpl
->GetTextBackground(); }
670 void SetPalette(const wxPalette
& palette
)
671 { m_pimpl
->SetPalette(palette
); }
672 #endif // wxUSE_PALETTE
676 void SetLogicalFunction(int function
)
677 { m_pimpl
->SetLogicalFunction(function
); }
678 int GetLogicalFunction() const
679 { return m_pimpl
->GetLogicalFunction(); }
683 wxCoord
GetCharHeight() const
684 { return m_pimpl
->GetCharHeight(); }
685 wxCoord
GetCharWidth() const
686 { return m_pimpl
->GetCharWidth(); }
688 void GetTextExtent(const wxString
& string
,
689 wxCoord
*x
, wxCoord
*y
,
690 wxCoord
*descent
= NULL
,
691 wxCoord
*externalLeading
= NULL
,
692 const wxFont
*theFont
= NULL
) const
693 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
695 wxSize
GetTextExtent(const wxString
& string
) const
698 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
702 void GetMultiLineTextExtent(const wxString
& string
,
705 wxCoord
*heightLine
= NULL
,
706 const wxFont
*font
= NULL
) const
707 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
709 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
712 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
716 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
717 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
722 { m_pimpl
->Clear(); }
726 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
727 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
728 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
729 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
730 void SetClippingRegion(const wxRect
& rect
)
731 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
732 void SetClippingRegion(const wxRegion
& region
)
733 { m_pimpl
->DoSetClippingRegionAsRegion(region
); }
735 void DestroyClippingRegion()
736 { m_pimpl
->DestroyClippingRegion(); }
738 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
739 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
740 void GetClippingBox(wxRect
& rect
) const
741 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
743 // coordinates conversions and transforms
745 wxCoord
DeviceToLogicalX(wxCoord x
) const
746 { return m_pimpl
->DeviceToLogicalX(x
); }
747 wxCoord
DeviceToLogicalY(wxCoord y
) const
748 { return m_pimpl
->DeviceToLogicalY(y
); }
749 wxCoord
DeviceToLogicalXRel(wxCoord x
) const
750 { return m_pimpl
->DeviceToLogicalXRel(x
); }
751 wxCoord
DeviceToLogicalYRel(wxCoord y
) const
752 { return m_pimpl
->DeviceToLogicalYRel(y
); }
753 wxCoord
LogicalToDeviceX(wxCoord x
) const
754 { return m_pimpl
->LogicalToDeviceX(x
); }
755 wxCoord
LogicalToDeviceY(wxCoord y
) const
756 { return m_pimpl
->LogicalToDeviceY(y
); }
757 wxCoord
LogicalToDeviceXRel(wxCoord x
) const
758 { return m_pimpl
->LogicalToDeviceXRel(x
); }
759 wxCoord
LogicalToDeviceYRel(wxCoord y
) const
760 { return m_pimpl
->LogicalToDeviceYRel(y
); }
762 void SetMapMode(int mode
)
763 { m_pimpl
->SetMapMode(mode
); }
764 int GetMapMode() const
765 { return m_pimpl
->GetMapMode(); }
767 void SetUserScale(double x
, double y
)
768 { m_pimpl
->SetUserScale(x
,y
); }
769 void GetUserScale(double *x
, double *y
) const
770 { m_pimpl
->GetUserScale( x
, y
); }
772 void SetLogicalScale(double x
, double y
)
773 { m_pimpl
->SetLogicalScale( x
, y
); }
774 void GetLogicalScale(double *x
, double *y
)
775 { m_pimpl
->GetLogicalScale( x
, y
); }
777 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
778 { m_pimpl
->SetLogicalOrigin(x
,y
); }
779 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
780 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
781 wxPoint
GetLogicalOrigin() const
782 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
784 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
785 { m_pimpl
->SetDeviceOrigin( x
, y
); }
786 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
787 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
788 wxPoint
GetDeviceOrigin() const
789 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
791 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
792 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
795 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
796 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
799 // draw generic object
801 void DrawObject(wxDrawObject
* drawobject
)
803 drawobject
->Draw(*this);
804 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
805 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
808 // -----------------------------------------------
809 // the actual drawing API
811 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
812 int style
= wxFLOOD_SURFACE
)
813 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
814 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
815 int style
= wxFLOOD_SURFACE
)
816 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
818 // fill the area specified by rect with a radial gradient, starting from
819 // initialColour in the centre of the cercle and fading to destColour.
820 void GradientFillConcentric(const wxRect
& rect
,
821 const wxColour
& initialColour
,
822 const wxColour
& destColour
)
823 { m_pimpl
->DoGradientFillConcentric( rect
, initialColour
, destColour
,
824 wxPoint(rect
.GetWidth() / 2,
825 rect
.GetHeight() / 2)); }
827 void GradientFillConcentric(const wxRect
& rect
,
828 const wxColour
& initialColour
,
829 const wxColour
& destColour
,
830 const wxPoint
& circleCenter
)
831 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
833 // fill the area specified by rect with a linear gradient
834 void GradientFillLinear(const wxRect
& rect
,
835 const wxColour
& initialColour
,
836 const wxColour
& destColour
,
837 wxDirection nDirection
= wxEAST
)
838 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
840 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
841 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
842 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
843 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
845 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
846 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
847 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
848 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
850 void CrossHair(wxCoord x
, wxCoord y
)
851 { m_pimpl
->DoCrossHair(x
, y
); }
852 void CrossHair(const wxPoint
& pt
)
853 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
855 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
856 wxCoord xc
, wxCoord yc
)
857 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
858 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
859 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
861 void DrawCheckMark(wxCoord x
, wxCoord y
,
862 wxCoord width
, wxCoord height
)
863 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
864 void DrawCheckMark(const wxRect
& rect
)
865 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
867 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
868 double sa
, double ea
)
869 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
870 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
871 double sa
, double ea
)
872 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
874 void DrawPoint(wxCoord x
, wxCoord y
)
875 { m_pimpl
->DoDrawPoint(x
, y
); }
876 void DrawPoint(const wxPoint
& pt
)
877 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
879 void DrawLines(int n
, wxPoint points
[],
880 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
881 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
882 void DrawLines(const wxPointList
*list
,
883 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
884 { m_pimpl
->DrawLines( list
, xoffset
, yoffset
); }
885 #if WXWIN_COMPATIBILITY_2_8
886 wxDEPRECATED( void DrawLines(const wxList
*list
,
887 wxCoord xoffset
= 0, wxCoord yoffset
= 0) );
888 #endif // WXWIN_COMPATIBILITY_2_8
890 void DrawPolygon(int n
, wxPoint points
[],
891 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
892 int fillStyle
= wxODDEVEN_RULE
)
893 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
894 void DrawPolygon(const wxPointList
*list
,
895 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
896 int fillStyle
= wxODDEVEN_RULE
)
897 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
898 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
899 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
900 int fillStyle
= wxODDEVEN_RULE
)
901 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
902 #if WXWIN_COMPATIBILITY_2_8
903 wxDEPRECATED( void DrawPolygon(const wxList
*list
,
904 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
905 int fillStyle
= wxODDEVEN_RULE
) );
906 #endif // WXWIN_COMPATIBILITY_2_8
908 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
909 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
910 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
911 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
912 void DrawRectangle(const wxRect
& rect
)
913 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
915 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
917 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
918 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
920 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
921 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
922 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
924 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
925 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
926 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
927 { m_pimpl
->DoDrawEllipse(pt
.x
- radius
, pt
.y
- radius
, 2*radius
, 2*radius
); }
929 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
930 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
931 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
932 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
933 void DrawEllipse(const wxRect
& rect
)
934 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
936 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
937 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
938 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
939 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
941 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
942 bool useMask
= false)
943 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
944 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
945 bool useMask
= false)
946 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
948 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
949 { m_pimpl
->DoDrawText(text
, x
, y
); }
950 void DrawText(const wxString
& text
, const wxPoint
& pt
)
951 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
953 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
954 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
955 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
956 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
958 // this version puts both optional bitmap and the text into the given
959 // rectangle and aligns is as specified by alignment parameter; it also
960 // will emphasize the character with the given index if it is != -1 and
961 // return the bounding rectangle if required
962 void DrawLabel(const wxString
& text
,
963 const wxBitmap
& image
,
965 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
967 wxRect
*rectBounding
= NULL
);
969 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
970 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
972 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
974 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
975 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
976 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
978 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
979 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
981 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
982 wxDC
*source
, const wxPoint
& srcPt
,
983 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
985 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
986 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
989 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
990 wxCoord dstWidth
, wxCoord dstHeight
,
992 wxCoord srcX
, wxCoord srcY
,
993 wxCoord srcWidth
, wxCoord srcHeight
,
994 int rop
= wxCOPY
, bool useMask
= false,
995 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
997 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
998 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1000 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1001 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1002 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1004 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1005 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1008 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1010 return m_pimpl
->DoGetAsBitmap(subrect
);
1014 void DrawSpline(wxCoord x1
, wxCoord y1
,
1015 wxCoord x2
, wxCoord y2
,
1016 wxCoord x3
, wxCoord y3
)
1017 { m_pimpl
->DoDrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
1018 void DrawSpline(int n
, wxPoint points
[])
1019 { m_pimpl
->DoDrawSpline(n
,points
); }
1020 void DrawSpline(const wxPointList
*points
)
1021 { m_pimpl
->DoDrawSpline(points
); }
1022 #endif // wxUSE_SPLINES
1025 #if WXWIN_COMPATIBILITY_2_8
1026 // for compatibility with the old code when wxCoord was long everywhere
1027 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1029 long *descent
= NULL
,
1030 long *externalLeading
= NULL
,
1031 const wxFont
*theFont
= NULL
) const );
1032 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1033 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1034 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1035 #endif // WXWIN_COMPATIBILITY_2_8
1042 DECLARE_ABSTRACT_CLASS(wxDC
)
1045 // ----------------------------------------------------------------------------
1046 // helper class: you can use it to temporarily change the DC text colour and
1047 // restore it automatically when the object goes out of scope
1048 // ----------------------------------------------------------------------------
1050 class WXDLLEXPORT wxDCTextColourChanger
1053 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1055 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1060 ~wxDCTextColourChanger()
1062 if ( m_colFgOld
.Ok() )
1063 m_dc
.SetTextForeground(m_colFgOld
);
1066 void Set(const wxColour
& col
)
1068 if ( !m_colFgOld
.Ok() )
1069 m_colFgOld
= m_dc
.GetTextForeground();
1070 m_dc
.SetTextForeground(col
);
1076 wxColour m_colFgOld
;
1078 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
1081 // ----------------------------------------------------------------------------
1082 // helper class: you can use it to temporarily change the DC pen and
1083 // restore it automatically when the object goes out of scope
1084 // ----------------------------------------------------------------------------
1086 class WXDLLEXPORT wxDCPenChanger
1089 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1096 if ( m_penOld
.Ok() )
1097 m_dc
.SetPen(m_penOld
);
1105 DECLARE_NO_COPY_CLASS(wxDCPenChanger
)
1108 // ----------------------------------------------------------------------------
1109 // helper class: you can use it to temporarily change the DC brush and
1110 // restore it automatically when the object goes out of scope
1111 // ----------------------------------------------------------------------------
1113 class WXDLLEXPORT wxDCBrushChanger
1116 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1118 m_dc
.SetBrush(brush
);
1123 if ( m_brushOld
.Ok() )
1124 m_dc
.SetBrush(m_brushOld
);
1132 DECLARE_NO_COPY_CLASS(wxDCBrushChanger
)
1135 // ----------------------------------------------------------------------------
1136 // another small helper class: sets the clipping region in its ctor and
1137 // destroys it in the dtor
1138 // ----------------------------------------------------------------------------
1140 class WXDLLEXPORT wxDCClipper
1143 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1144 { dc
.SetClippingRegion(r
); }
1145 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1146 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1147 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1148 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1150 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1155 DECLARE_NO_COPY_CLASS(wxDCClipper
)
1158 #endif // _WX_DC_H_BASE_