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"
33 // 1 if using the reorganized DC code
34 #define wxUSE_NEW_DC 0
38 class WXDLLIMPEXP_FWD_CORE wxDC
;
39 class WXDLLIMPEXP_FWD_CORE wxClientDC
;
40 class WXDLLIMPEXP_FWD_CORE wxPaintDC
;
41 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
42 class WXDLLIMPEXP_FWD_CORE wxScreenDC
;
43 class WXDLLIMPEXP_FWD_CORE wxMemoryDC
;
45 class WXDLLIMPEXP_FWD_CORE wxDCBase
;
48 class WXDLLEXPORT wxDrawObject
53 : m_isBBoxValid(false)
54 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
57 virtual ~wxDrawObject() { }
60 virtual void Draw(wxDC
&) const { }
62 virtual void Draw(wxDCBase
&) const { }
65 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
69 if ( x
< m_minX
) m_minX
= x
;
70 if ( y
< m_minY
) m_minY
= y
;
71 if ( x
> m_maxX
) m_maxX
= x
;
72 if ( y
> m_maxY
) m_maxY
= y
;
85 void ResetBoundingBox()
87 m_isBBoxValid
= false;
89 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
92 // Get the final bounding box of the PostScript or Metafile picture.
94 wxCoord
MinX() const { return m_minX
; }
95 wxCoord
MaxX() const { return m_maxX
; }
96 wxCoord
MinY() const { return m_minY
; }
97 wxCoord
MaxY() const { return m_maxY
; }
99 //to define the type of object for derived objects
100 virtual int GetType()=0;
103 //for boundingbox calculation
104 bool m_isBBoxValid
:1;
105 //for boundingbox calculation
106 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
112 //-----------------------------------------------------------------------------
114 //-----------------------------------------------------------------------------
116 class WXDLLIMPEXP_FWD_CORE wxImplDC
;
118 class WXDLLIMPEXP_CORE wxDCFactory
122 virtual ~wxDCFactory() {}
124 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
) = 0;
125 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
) = 0;
126 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
) = 0;
127 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
) = 0;
128 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
) = 0;
129 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
) = 0;
130 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
) = 0;
131 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
) = 0;
132 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
) = 0;
133 virtual wxImplDC
* CreateScreenDC( wxScreenDC
*owner
) = 0;
135 static void SetDCFactory( wxDCFactory
*factory
);
136 static wxDCFactory
*GetFactory();
138 static wxDCFactory
*m_factory
;
141 //-----------------------------------------------------------------------------
143 //-----------------------------------------------------------------------------
145 class WXDLLIMPEXP_CORE wxNativeDCFactory
: public wxDCFactory
148 wxNativeDCFactory() {}
150 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
);
151 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
);
152 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
);
153 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
);
154 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
);
155 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
);
156 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
);
157 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
);
158 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
);
159 virtual wxImplDC
* CreateScreenDC( wxScreenDC
*owner
);
162 //-----------------------------------------------------------------------------
164 //-----------------------------------------------------------------------------
166 class WXDLLIMPEXP_CORE wxImplDC
: public wxObject
169 wxImplDC( wxDC
*owner
);
172 wxDC
*GetOwner() const { return m_owner
; }
174 virtual bool IsOk() const { return m_ok
; }
176 // query capabilities
178 virtual bool CanDrawBitmap() const = 0;
179 virtual bool CanGetTextExtent() const = 0;
181 // query dimension, colour deps, resolution
183 virtual void DoGetSize(int *width
, int *height
) const = 0;
184 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
186 virtual int GetDepth() const = 0;
187 virtual wxSize
GetPPI() const = 0;
189 // Right-To-Left (RTL) modes
191 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
192 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
196 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
197 virtual void EndDoc() { }
199 virtual void StartPage() { }
200 virtual void EndPage() { }
202 // flushing the content of this dc immediately eg onto screen
203 virtual void Flush() { }
207 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
211 if ( x
< m_minX
) m_minX
= x
;
212 if ( y
< m_minY
) m_minY
= y
;
213 if ( x
> m_maxX
) m_maxX
= x
;
214 if ( y
> m_maxY
) m_maxY
= y
;
218 m_isBBoxValid
= true;
226 void ResetBoundingBox()
228 m_isBBoxValid
= false;
230 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
233 wxCoord
MinX() const { return m_minX
; }
234 wxCoord
MaxX() const { return m_maxX
; }
235 wxCoord
MinY() const { return m_minY
; }
236 wxCoord
MaxY() const { return m_maxY
; }
238 // setters and getters
240 virtual void SetFont(const wxFont
& font
) = 0;
241 virtual const wxFont
& GetFont() const { return m_font
; }
243 virtual void SetPen(const wxPen
& pen
) = 0;
244 virtual const wxPen
& GetPen() const { return m_pen
; }
246 virtual void SetBrush(const wxBrush
& brush
) = 0;
247 virtual const wxBrush
& GetBrush() const { return m_brush
; }
249 virtual void SetBackground(const wxBrush
& brush
) = 0;
250 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
252 virtual void SetBackgroundMode(int mode
) = 0;
253 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
255 virtual void SetTextForeground(const wxColour
& colour
)
256 { m_textForegroundColour
= colour
; }
257 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
259 virtual void SetTextBackground(const wxColour
& colour
)
260 { m_textBackgroundColour
= colour
; }
261 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
264 virtual void SetPalette(const wxPalette
& palette
) = 0;
265 #endif // wxUSE_PALETTE
269 virtual void SetLogicalFunction(int function
) = 0;
270 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
274 virtual wxCoord
GetCharHeight() const = 0;
275 virtual wxCoord
GetCharWidth() const = 0;
276 virtual void DoGetTextExtent(const wxString
& string
,
277 wxCoord
*x
, wxCoord
*y
,
278 wxCoord
*descent
= NULL
,
279 wxCoord
*externalLeading
= NULL
,
280 const wxFont
*theFont
= NULL
) const = 0;
281 virtual void GetMultiLineTextExtent(const wxString
& string
,
284 wxCoord
*heightLine
= NULL
,
285 const wxFont
*font
= NULL
) const;
286 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
290 virtual void Clear() = 0;
294 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
295 wxCoord width
, wxCoord height
) = 0;
296 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
298 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
299 wxCoord
*w
, wxCoord
*h
) const
306 *w
= m_clipX2
- m_clipX1
;
308 *h
= m_clipY2
- m_clipY1
;
311 virtual void DestroyClippingRegion() { ResetClipping(); }
314 // coordinates conversions and transforms
316 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
317 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
318 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
319 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
320 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
321 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
322 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
323 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
325 virtual void SetMapMode(int mode
);
326 virtual int GetMapMode() const { return m_mappingMode
; }
328 virtual void SetUserScale(double x
, double y
);
329 virtual void GetUserScale(double *x
, double *y
) const
331 if ( x
) *x
= m_userScaleX
;
332 if ( y
) *y
= m_userScaleY
;
335 virtual void SetLogicalScale(double x
, double y
);
336 virtual void GetLogicalScale(double *x
, double *y
)
338 if ( x
) *x
= m_logicalScaleX
;
339 if ( y
) *y
= m_logicalScaleY
;
342 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
343 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
345 if ( x
) *x
= m_logicalOriginX
;
346 if ( y
) *y
= m_logicalOriginY
;
349 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
350 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
352 if ( x
) *x
= m_deviceOriginX
;
353 if ( y
) *y
= m_deviceOriginY
;
356 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
358 virtual void ComputeScaleAndOrigin();
360 // this needs to overidden if the axis is inverted
361 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
363 // ---------------------------------------------------------
364 // the actual drawing API
366 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
367 int style
= wxFLOOD_SURFACE
) = 0;
369 virtual void DoGradientFillLinear(const wxRect
& rect
,
370 const wxColour
& initialColour
,
371 const wxColour
& destColour
,
372 wxDirection nDirection
= wxEAST
);
374 virtual void DoGradientFillConcentric(const wxRect
& rect
,
375 const wxColour
& initialColour
,
376 const wxColour
& destColour
,
377 const wxPoint
& circleCenter
);
379 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
381 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
382 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
384 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
385 wxCoord x2
, wxCoord y2
,
386 wxCoord xc
, wxCoord yc
) = 0;
387 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
388 wxCoord width
, wxCoord height
);
389 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
390 double sa
, double ea
) = 0;
392 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
393 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
394 wxCoord width
, wxCoord height
,
396 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
397 wxCoord width
, wxCoord height
) = 0;
399 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
401 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
402 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
403 bool useMask
= false) = 0;
405 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
406 virtual void DoDrawRotatedText(const wxString
& text
,
407 wxCoord x
, wxCoord y
, double angle
) = 0;
409 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
410 wxCoord width
, wxCoord height
,
412 wxCoord xsrc
, wxCoord ysrc
,
414 bool useMask
= false,
415 wxCoord xsrcMask
= wxDefaultCoord
,
416 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
418 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
419 wxCoord dstWidth
, wxCoord dstHeight
,
421 wxCoord xsrc
, wxCoord ysrc
,
422 wxCoord srcWidth
, wxCoord srcHeight
,
424 bool useMask
= false,
425 wxCoord xsrcMask
= wxDefaultCoord
,
426 wxCoord ysrcMask
= wxDefaultCoord
);
428 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
429 { return wxNullBitmap
; }
432 virtual void DoDrawLines(int n
, wxPoint points
[],
433 wxCoord xoffset
, wxCoord yoffset
) = 0;
434 virtual void DoDrawPolygon(int n
, wxPoint points
[],
435 wxCoord xoffset
, wxCoord yoffset
,
436 int fillStyle
= wxODDEVEN_RULE
) = 0;
437 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
438 wxCoord xoffset
, wxCoord yoffset
,
444 virtual void DoDrawSpline(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
, wxCoord x3
, wxCoord y3
);
445 virtual void DoDrawSpline(int n
, wxPoint points
[]);
446 virtual void DoDrawSpline(const wxPointList
*points
);
453 // unset clipping variables (after clipping region was destroyed)
458 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
465 bool m_isInteractive
:1;
466 bool m_isBBoxValid
:1;
468 // coordinate system variables
470 wxCoord m_logicalOriginX
, m_logicalOriginY
;
471 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
473 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
474 // is not at 0,0. This was the case under
475 // Mac's GrafPorts (coordinate system
476 // used toplevel window's origin) and
477 // e.g. for Postscript, where the native
478 // origin in the bottom left corner.
479 double m_logicalScaleX
, m_logicalScaleY
;
480 double m_userScaleX
, m_userScaleY
;
481 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
483 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
485 // what is a mm on a screen you don't know the size of?
486 double m_mm_to_pix_x
,
489 // bounding and clipping boxes
490 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
491 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
493 int m_logicalFunction
;
494 int m_backgroundMode
;
499 wxBrush m_backgroundBrush
;
500 wxColour m_textForegroundColour
;
501 wxColour m_textBackgroundColour
;
506 bool m_hasCustomPalette
;
507 #endif // wxUSE_PALETTE
510 DECLARE_ABSTRACT_CLASS(wxImplDC
)
514 class wxDC
: public wxObject
517 wxDC() { m_pimpl
= NULL
; }
521 const wxImplDC
*GetImpl() const
526 { return m_pimpl
&& m_pimpl
->IsOk(); }
528 // query capabilities
530 bool CanDrawBitmap() const
531 { return m_pimpl
->CanDrawBitmap(); }
532 bool CanGetTextExtent() const
533 { return m_pimpl
->CanGetTextExtent(); }
535 // query dimension, colour deps, resolution
537 void GetSize(int *width
, int *height
) const
538 { m_pimpl
->DoGetSize(width
, height
); }
540 wxSize
GetSize() const
543 m_pimpl
->DoGetSize(&w
, &h
);
547 void GetSizeMM(int* width
, int* height
) const
548 { m_pimpl
->DoGetSizeMM(width
, height
); }
549 wxSize
GetSizeMM() const
552 m_pimpl
->DoGetSizeMM(&w
, &h
);
557 { return m_pimpl
->GetDepth(); }
558 wxSize
GetPPI() const
559 { return m_pimpl
->GetPPI(); }
561 // Right-To-Left (RTL) modes
563 void SetLayoutDirection(wxLayoutDirection dir
)
564 { m_pimpl
->SetLayoutDirection( dir
); }
565 wxLayoutDirection
GetLayoutDirection() const
566 { return m_pimpl
->GetLayoutDirection(); }
570 bool StartDoc(const wxString
& message
)
571 { return m_pimpl
->StartDoc(message
); }
573 { m_pimpl
->EndDoc(); }
576 { m_pimpl
->StartPage(); }
578 { m_pimpl
->EndPage(); }
582 void CalcBoundingBox(wxCoord x
, wxCoord y
)
583 { m_pimpl
->CalcBoundingBox(x
,y
); }
584 void ResetBoundingBox()
585 { m_pimpl
->ResetBoundingBox(); }
588 { return m_pimpl
->MinX(); }
590 { return m_pimpl
->MaxX(); }
592 { return m_pimpl
->MinY(); }
594 { return m_pimpl
->MaxY(); }
596 // setters and getters
598 void SetFont(const wxFont
& font
)
599 { m_pimpl
->SetFont( font
); }
600 const wxFont
& GetFont() const
601 { return m_pimpl
->GetFont(); }
603 void SetPen(const wxPen
& pen
)
604 { m_pimpl
->SetPen( pen
); }
605 const wxPen
& GetPen() const
606 { return m_pimpl
->GetPen(); }
608 void SetBrush(const wxBrush
& brush
)
609 { m_pimpl
->SetBrush( brush
); }
610 const wxBrush
& GetBrush() const
611 { return m_pimpl
->GetBrush(); }
613 void SetBackground(const wxBrush
& brush
)
614 { m_pimpl
->SetBackground( brush
); }
615 const wxBrush
& GetBackground() const
616 { return m_pimpl
->GetBackground(); }
618 void SetBackgroundMode(int mode
)
619 { m_pimpl
->SetBackgroundMode( mode
); }
620 int GetBackgroundMode() const
621 { return m_pimpl
->GetBackgroundMode(); }
623 void SetTextForeground(const wxColour
& colour
)
624 { m_pimpl
->SetTextForeground(colour
); }
625 const wxColour
& GetTextForeground() const
626 { return m_pimpl
->GetTextForeground(); }
628 void SetTextBackground(const wxColour
& colour
)
629 { m_pimpl
->SetTextBackground(colour
); }
630 const wxColour
& GetTextBackground() const
631 { return m_pimpl
->GetTextBackground(); }
634 void SetPalette(const wxPalette
& palette
)
635 { m_pimpl
->SetPalette(palette
); }
636 #endif // wxUSE_PALETTE
640 void SetLogicalFunction(int function
)
641 { m_pimpl
->SetLogicalFunction(function
); }
642 int GetLogicalFunction() const
643 { return m_pimpl
->GetLogicalFunction(); }
647 wxCoord
GetCharHeight() const
648 { return m_pimpl
->GetCharHeight(); }
649 wxCoord
GetCharWidth() const
650 { return m_pimpl
->GetCharWidth(); }
652 void GetTextExtent(const wxString
& string
,
653 wxCoord
*x
, wxCoord
*y
,
654 wxCoord
*descent
= NULL
,
655 wxCoord
*externalLeading
= NULL
,
656 const wxFont
*theFont
= NULL
) const
657 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
659 wxSize
GetTextExtent(const wxString
& string
) const
662 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
666 void GetMultiLineTextExtent(const wxString
& string
,
669 wxCoord
*heightLine
= NULL
,
670 const wxFont
*font
= NULL
) const
671 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
673 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
676 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
680 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
681 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
686 { m_pimpl
->Clear(); }
690 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
691 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
692 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
693 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
694 void SetClippingRegion(const wxRect
& rect
)
695 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
696 void SetClippingRegion(const wxRegion
& region
)
697 { m_pimpl
->DoSetClippingRegionAsRegion(region
); }
699 void DestroyClippingRegion()
700 { m_pimpl
->DestroyClippingRegion(); }
702 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
703 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
704 void GetClippingBox(wxRect
& rect
) const
705 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
707 // coordinates conversions and transforms
709 wxCoord
DeviceToLogicalX(wxCoord x
) const
710 { return m_pimpl
->DeviceToLogicalX(x
); }
711 wxCoord
DeviceToLogicalY(wxCoord y
) const
712 { return m_pimpl
->DeviceToLogicalY(y
); }
713 wxCoord
DeviceToLogicalXRel(wxCoord x
) const
714 { return m_pimpl
->DeviceToLogicalXRel(x
); }
715 wxCoord
DeviceToLogicalYRel(wxCoord y
) const
716 { return m_pimpl
->DeviceToLogicalYRel(y
); }
717 wxCoord
LogicalToDeviceX(wxCoord x
) const
718 { return m_pimpl
->LogicalToDeviceX(x
); }
719 wxCoord
LogicalToDeviceY(wxCoord y
) const
720 { return m_pimpl
->LogicalToDeviceY(y
); }
721 wxCoord
LogicalToDeviceXRel(wxCoord x
) const
722 { return m_pimpl
->LogicalToDeviceXRel(x
); }
723 wxCoord
LogicalToDeviceYRel(wxCoord y
) const
724 { return m_pimpl
->LogicalToDeviceYRel(y
); }
726 void SetMapMode(int mode
)
727 { m_pimpl
->SetMapMode(mode
); }
728 int GetMapMode() const
729 { return m_pimpl
->GetMapMode(); }
731 void SetUserScale(double x
, double y
)
732 { m_pimpl
->SetUserScale(x
,y
); }
733 void GetUserScale(double *x
, double *y
) const
734 { m_pimpl
->GetUserScale( x
, y
); }
736 void SetLogicalScale(double x
, double y
)
737 { m_pimpl
->SetLogicalScale( x
, y
); }
738 void GetLogicalScale(double *x
, double *y
)
739 { m_pimpl
->GetLogicalScale( x
, y
); }
741 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
742 { m_pimpl
->SetLogicalOrigin(x
,y
); }
743 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
744 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
745 wxPoint
GetLogicalOrigin() const
746 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
748 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
749 { m_pimpl
->SetDeviceOrigin( x
, y
); }
750 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
751 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
752 wxPoint
GetDeviceOrigin() const
753 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
755 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
756 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
759 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
760 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
763 // draw generic object
765 void DrawObject(wxDrawObject
* drawobject
)
767 drawobject
->Draw(*this);
768 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
769 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
772 // -----------------------------------------------
773 // the actual drawing API
775 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
776 int style
= wxFLOOD_SURFACE
)
777 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
778 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
779 int style
= wxFLOOD_SURFACE
)
780 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
782 // fill the area specified by rect with a radial gradient, starting from
783 // initialColour in the centre of the cercle and fading to destColour.
784 void GradientFillConcentric(const wxRect
& rect
,
785 const wxColour
& initialColour
,
786 const wxColour
& destColour
)
787 { m_pimpl
->DoGradientFillConcentric( rect
, initialColour
, destColour
,
788 wxPoint(rect
.GetWidth() / 2,
789 rect
.GetHeight() / 2)); }
791 void GradientFillConcentric(const wxRect
& rect
,
792 const wxColour
& initialColour
,
793 const wxColour
& destColour
,
794 const wxPoint
& circleCenter
)
795 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
797 // fill the area specified by rect with a linear gradient
798 void GradientFillLinear(const wxRect
& rect
,
799 const wxColour
& initialColour
,
800 const wxColour
& destColour
,
801 wxDirection nDirection
= wxEAST
)
802 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
804 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
805 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
806 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
807 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
809 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
810 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
811 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
812 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
814 void CrossHair(wxCoord x
, wxCoord y
)
815 { m_pimpl
->DoCrossHair(x
, y
); }
816 void CrossHair(const wxPoint
& pt
)
817 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
819 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
820 wxCoord xc
, wxCoord yc
)
821 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
822 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
823 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
825 void DrawCheckMark(wxCoord x
, wxCoord y
,
826 wxCoord width
, wxCoord height
)
827 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
828 void DrawCheckMark(const wxRect
& rect
)
829 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
831 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
832 double sa
, double ea
)
833 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
834 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
835 double sa
, double ea
)
836 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
838 void DrawPoint(wxCoord x
, wxCoord y
)
839 { m_pimpl
->DoDrawPoint(x
, y
); }
840 void DrawPoint(const wxPoint
& pt
)
841 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
843 void DrawLines(int n
, wxPoint points
[],
844 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
845 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
848 // needs to be removed
849 void DrawLines(const wxPointList
*list
,
850 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
853 void DrawPolygon(int n
, wxPoint points
[],
854 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
855 int fillStyle
= wxODDEVEN_RULE
)
856 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
859 // needs to be removed
860 void DrawPolygon(const wxPointList
*list
,
861 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
862 int fillStyle
= wxODDEVEN_RULE
)
863 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
866 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
867 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
868 int fillStyle
= wxODDEVEN_RULE
)
869 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
871 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
872 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
873 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
874 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
875 void DrawRectangle(const wxRect
& rect
)
876 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
878 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
880 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
881 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
883 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
884 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
885 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
887 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
888 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
889 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
890 { m_pimpl
->DoDrawEllipse(pt
.x
- radius
, pt
.y
- radius
, 2*radius
, 2*radius
); }
892 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
893 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
894 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
895 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
896 void DrawEllipse(const wxRect
& rect
)
897 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
899 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
900 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
901 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
902 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
904 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
905 bool useMask
= false)
906 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
907 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
908 bool useMask
= false)
909 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
911 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
912 { m_pimpl
->DoDrawText(text
, x
, y
); }
913 void DrawText(const wxString
& text
, const wxPoint
& pt
)
914 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
916 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
917 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
918 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
919 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
921 // this version puts both optional bitmap and the text into the given
922 // rectangle and aligns is as specified by alignment parameter; it also
923 // will emphasize the character with the given index if it is != -1 and
924 // return the bounding rectangle if required
925 void DrawLabel(const wxString
& text
,
926 const wxBitmap
& image
,
928 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
930 wxRect
*rectBounding
= NULL
);
932 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
933 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
935 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
937 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
938 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
939 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
941 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
942 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
944 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
945 wxDC
*source
, const wxPoint
& srcPt
,
946 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
948 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
949 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
952 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
953 wxCoord dstWidth
, wxCoord dstHeight
,
955 wxCoord srcX
, wxCoord srcY
,
956 wxCoord srcWidth
, wxCoord srcHeight
,
957 int rop
= wxCOPY
, bool useMask
= false,
958 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
960 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
961 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
963 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
964 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
965 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
967 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
968 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
971 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
973 return m_pimpl
->DoGetAsBitmap(subrect
);
977 void DrawSpline(wxCoord x1
, wxCoord y1
,
978 wxCoord x2
, wxCoord y2
,
979 wxCoord x3
, wxCoord y3
)
980 { m_pimpl
->DoDrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
981 void DrawSpline(int n
, wxPoint points
[])
982 { m_pimpl
->DoDrawSpline(n
,points
); }
983 void DrawSpline(const wxPointList
*points
)
984 { m_pimpl
->DoDrawSpline(points
); }
985 #endif // wxUSE_SPLINES
988 #if WXWIN_COMPATIBILITY_2_8
989 // for compatibility with the old code when wxCoord was long everywhere
990 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
992 long *descent
= NULL
,
993 long *externalLeading
= NULL
,
994 const wxFont
*theFont
= NULL
) const );
995 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
996 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
997 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
998 #endif // WXWIN_COMPATIBILITY_2_8
1005 DECLARE_ABSTRACT_CLASS(wxImplDC
)
1009 //-----------------------------------------------------------------------------
1011 //-----------------------------------------------------------------------------
1013 class WXDLLIMPEXP_CORE wxWindowDC
: public wxDC
1017 wxWindowDC( wxWindow
*win
);
1020 DECLARE_DYNAMIC_CLASS(wxWindowDC
)
1023 //-----------------------------------------------------------------------------
1025 //-----------------------------------------------------------------------------
1027 class WXDLLIMPEXP_CORE wxClientDC
: public wxDC
1031 wxClientDC( wxWindow
*win
);
1034 DECLARE_DYNAMIC_CLASS(wxClientDC
)
1037 //-----------------------------------------------------------------------------
1039 //-----------------------------------------------------------------------------
1041 class WXDLLIMPEXP_CORE wxPaintDC
: public wxDC
1045 wxPaintDC( wxWindow
*win
);
1048 DECLARE_DYNAMIC_CLASS(wxPaintDC
)
1051 #else // wxUSE_NEW_DC
1054 class WXDLLIMPEXP_FWD_CORE wxDC
;
1056 // ---------------------------------------------------------------------------
1058 // ---------------------------------------------------------------------------
1060 // ---------------------------------------------------------------------------
1061 // wxDC is the device context - object on which any drawing is done
1062 // ---------------------------------------------------------------------------
1064 class WXDLLEXPORT wxDCBase
: public wxObject
1068 virtual ~wxDCBase();
1070 // graphic primitives
1071 // ------------------
1073 virtual void DrawObject(wxDrawObject
* drawobject
)
1075 drawobject
->Draw(*this);
1076 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
1077 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
1080 wxDC
*GetOwner() const { return (wxDC
*) this; }
1082 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1083 int style
= wxFLOOD_SURFACE
)
1084 { return DoFloodFill(x
, y
, col
, style
); }
1085 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
1086 int style
= wxFLOOD_SURFACE
)
1087 { return DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
1089 // fill the area specified by rect with a radial gradient, starting from
1090 // initialColour in the centre of the cercle and fading to destColour.
1091 void GradientFillConcentric(const wxRect
& rect
,
1092 const wxColour
& initialColour
,
1093 const wxColour
& destColour
)
1094 { GradientFillConcentric(rect
, initialColour
, destColour
,
1095 wxPoint(rect
.GetWidth() / 2,
1096 rect
.GetHeight() / 2)); }
1098 void GradientFillConcentric(const wxRect
& rect
,
1099 const wxColour
& initialColour
,
1100 const wxColour
& destColour
,
1101 const wxPoint
& circleCenter
)
1102 { DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
1104 // fill the area specified by rect with a linear gradient
1105 void GradientFillLinear(const wxRect
& rect
,
1106 const wxColour
& initialColour
,
1107 const wxColour
& destColour
,
1108 wxDirection nDirection
= wxEAST
)
1109 { DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
1111 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
1112 { return DoGetPixel(x
, y
, col
); }
1113 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
1114 { return DoGetPixel(pt
.x
, pt
.y
, col
); }
1116 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1117 { DoDrawLine(x1
, y1
, x2
, y2
); }
1118 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
1119 { DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
1121 void CrossHair(wxCoord x
, wxCoord y
)
1122 { DoCrossHair(x
, y
); }
1123 void CrossHair(const wxPoint
& pt
)
1124 { DoCrossHair(pt
.x
, pt
.y
); }
1126 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
1127 wxCoord xc
, wxCoord yc
)
1128 { DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
1129 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
1130 { DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
1132 void DrawCheckMark(wxCoord x
, wxCoord y
,
1133 wxCoord width
, wxCoord height
)
1134 { DoDrawCheckMark(x
, y
, width
, height
); }
1135 void DrawCheckMark(const wxRect
& rect
)
1136 { DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1138 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1139 double sa
, double ea
)
1140 { DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
1141 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
1142 double sa
, double ea
)
1143 { DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
1145 void DrawPoint(wxCoord x
, wxCoord y
)
1146 { DoDrawPoint(x
, y
); }
1147 void DrawPoint(const wxPoint
& pt
)
1148 { DoDrawPoint(pt
.x
, pt
.y
); }
1150 void DrawLines(int n
, wxPoint points
[],
1151 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1152 { DoDrawLines(n
, points
, xoffset
, yoffset
); }
1153 void DrawLines(const wxPointList
*list
,
1154 wxCoord xoffset
= 0, wxCoord yoffset
= 0);
1156 #if WXWIN_COMPATIBILITY_2_8
1157 wxDEPRECATED( void DrawLines(const wxList
*list
,
1158 wxCoord xoffset
= 0, wxCoord yoffset
= 0) );
1159 #endif // WXWIN_COMPATIBILITY_2_8
1162 void DrawPolygon(int n
, wxPoint points
[],
1163 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1164 int fillStyle
= wxODDEVEN_RULE
)
1165 { DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
1167 void DrawPolygon(const wxPointList
*list
,
1168 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1169 int fillStyle
= wxODDEVEN_RULE
);
1171 #if WXWIN_COMPATIBILITY_2_8
1172 wxDEPRECATED( void DrawPolygon(const wxList
*list
,
1173 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1174 int fillStyle
= wxODDEVEN_RULE
) );
1175 #endif // WXWIN_COMPATIBILITY_2_8
1177 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1178 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1179 int fillStyle
= wxODDEVEN_RULE
)
1180 { DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
1182 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1183 { DoDrawRectangle(x
, y
, width
, height
); }
1184 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
1185 { DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1186 void DrawRectangle(const wxRect
& rect
)
1187 { DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1189 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
1191 { DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
1192 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
1194 { DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
1195 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
1196 { DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1198 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1199 { DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1200 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1201 { DrawCircle(pt
.x
, pt
.y
, radius
); }
1203 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1204 { DoDrawEllipse(x
, y
, width
, height
); }
1205 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1206 { DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1207 void DrawEllipse(const wxRect
& rect
)
1208 { DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1210 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1211 { DoDrawIcon(icon
, x
, y
); }
1212 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1213 { DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1215 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1216 bool useMask
= false)
1217 { DoDrawBitmap(bmp
, x
, y
, useMask
); }
1218 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1219 bool useMask
= false)
1220 { DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1222 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1223 { DoDrawText(text
, x
, y
); }
1224 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1225 { DoDrawText(text
, pt
.x
, pt
.y
); }
1227 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1228 { DoDrawRotatedText(text
, x
, y
, angle
); }
1229 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1230 { DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1232 // this version puts both optional bitmap and the text into the given
1233 // rectangle and aligns is as specified by alignment parameter; it also
1234 // will emphasize the character with the given index if it is != -1 and
1235 // return the bounding rectangle if required
1236 virtual void DrawLabel(const wxString
& text
,
1237 const wxBitmap
& image
,
1239 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1240 int indexAccel
= -1,
1241 wxRect
*rectBounding
= NULL
);
1243 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1244 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1245 int indexAccel
= -1)
1246 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1248 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1249 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1250 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1252 return DoBlit(xdest
, ydest
, width
, height
,
1253 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1255 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1256 wxDC
*source
, const wxPoint
& srcPt
,
1257 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
1259 return DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1260 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1263 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1264 wxCoord dstWidth
, wxCoord dstHeight
,
1266 wxCoord srcX
, wxCoord srcY
,
1267 wxCoord srcWidth
, wxCoord srcHeight
,
1268 int rop
= wxCOPY
, bool useMask
= false,
1269 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1271 return DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1272 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1274 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1275 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1276 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1278 return DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1279 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1282 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1284 return DoGetAsBitmap(subrect
);
1288 void DrawSpline(wxCoord x1
, wxCoord y1
,
1289 wxCoord x2
, wxCoord y2
,
1290 wxCoord x3
, wxCoord y3
);
1291 void DrawSpline(int n
, wxPoint points
[]);
1293 void DrawSpline(const wxPointList
*points
) { DoDrawSpline(points
); }
1295 #if WXWIN_COMPATIBILITY_2_8
1296 wxDEPRECATED( void DrawSpline(const wxList
*points
) );
1297 #endif // WXWIN_COMPATIBILITY_2_8
1299 #endif // wxUSE_SPLINES
1301 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
1303 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
1304 /*! \param x Upper left corner of bounding box.
1305 * \param y Upper left corner of bounding box.
1306 * \param w Width of bounding box.
1307 * \param h Height of bounding box.
1308 * \param sa Starting angle of arc
1309 * (counterclockwise, start at 3 o'clock, 360 is full circle).
1310 * \param ea Ending angle of arc.
1311 * \param angle Rotation angle, the Arc will be rotated after
1312 * calculating begin and end.
1314 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
1315 wxCoord width
, wxCoord height
,
1316 double sa
= 0, double ea
= 0, double angle
= 0 )
1317 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
1319 void DrawEllipticArcRot( const wxPoint
& pt
,
1321 double sa
= 0, double ea
= 0, double angle
= 0 )
1322 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
1324 void DrawEllipticArcRot( const wxRect
& rect
,
1325 double sa
= 0, double ea
= 0, double angle
= 0 )
1326 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
1328 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
1329 wxCoord w
, wxCoord h
,
1330 double sa
= 0, double ea
= 0, double angle
= 0 );
1332 //! Rotates points around center.
1333 /*! This is a quite straight method, it calculates in pixels
1334 * and so it produces rounding errors.
1335 * \param points The points inside will be rotated.
1336 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
1337 * \param center Center of rotation.
1339 void Rotate( wxPointList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
1341 // used by DrawEllipticArcRot
1342 // Careful: wxList gets filled with points you have to delete later.
1343 void CalculateEllipticPoints( wxPointList
* points
,
1344 wxCoord xStart
, wxCoord yStart
,
1345 wxCoord w
, wxCoord h
,
1346 double sa
, double ea
);
1349 // global DC operations
1350 // --------------------
1352 virtual void Clear() = 0;
1354 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
1355 virtual void EndDoc() { }
1357 virtual void StartPage() { }
1358 virtual void EndPage() { }
1360 #if WXWIN_COMPATIBILITY_2_6
1361 wxDEPRECATED( void BeginDrawing() );
1362 wxDEPRECATED( void EndDrawing() );
1363 #endif // WXWIN_COMPATIBILITY_2_6
1366 // set objects to use for drawing
1367 // ------------------------------
1369 virtual void SetFont(const wxFont
& font
) = 0;
1370 virtual void SetPen(const wxPen
& pen
) = 0;
1371 virtual void SetBrush(const wxBrush
& brush
) = 0;
1372 virtual void SetBackground(const wxBrush
& brush
) = 0;
1373 virtual void SetBackgroundMode(int mode
) = 0;
1375 virtual void SetPalette(const wxPalette
& palette
) = 0;
1376 #endif // wxUSE_PALETTE
1381 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1382 { DoSetClippingRegion(x
, y
, width
, height
); }
1383 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
1384 { DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1385 void SetClippingRegion(const wxRect
& rect
)
1386 { DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1387 void SetClippingRegion(const wxRegion
& region
)
1388 { DoSetClippingRegionAsRegion(region
); }
1390 virtual void DestroyClippingRegion() { ResetClipping(); }
1392 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
1393 { DoGetClippingBox(x
, y
, w
, h
); }
1394 void GetClippingBox(wxRect
& rect
) const
1396 DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
);
1402 virtual wxCoord
GetCharHeight() const = 0;
1403 virtual wxCoord
GetCharWidth() const = 0;
1405 // only works for single line strings
1406 void GetTextExtent(const wxString
& string
,
1407 wxCoord
*x
, wxCoord
*y
,
1408 wxCoord
*descent
= NULL
,
1409 wxCoord
*externalLeading
= NULL
,
1410 const wxFont
*theFont
= NULL
) const
1411 { DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
1413 wxSize
GetTextExtent(const wxString
& string
) const
1416 DoGetTextExtent(string
, &w
, &h
);
1417 return wxSize(w
, h
);
1420 // works for single as well as multi-line strings
1421 virtual void GetMultiLineTextExtent(const wxString
& string
,
1424 wxCoord
*heightLine
= NULL
,
1425 const wxFont
*font
= NULL
) const;
1427 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
1430 GetMultiLineTextExtent(string
, &w
, &h
);
1431 return wxSize(w
, h
);
1434 // Measure cumulative width of text after each character
1435 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1436 { return DoGetPartialTextExtents(text
, widths
); }
1439 // size and resolution
1440 // -------------------
1443 void GetSize(int *width
, int *height
) const
1444 { DoGetSize(width
, height
); }
1445 wxSize
GetSize() const
1450 return wxSize(w
, h
);
1454 void GetSizeMM(int* width
, int* height
) const
1455 { DoGetSizeMM(width
, height
); }
1456 wxSize
GetSizeMM() const
1459 DoGetSizeMM(&w
, &h
);
1461 return wxSize(w
, h
);
1464 // query DC capabilities
1465 // ---------------------
1467 virtual bool CanDrawBitmap() const = 0;
1468 virtual bool CanGetTextExtent() const = 0;
1471 virtual int GetDepth() const = 0;
1473 // Resolution in Pixels per inch
1474 virtual wxSize
GetPPI() const = 0;
1476 virtual bool Ok() const { return IsOk(); }
1477 virtual bool IsOk() const { return m_ok
; }
1479 // accessors and setters
1480 // ---------------------
1482 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
1483 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
1484 virtual const wxBrush
& GetBrush() const { return m_brush
; }
1485 virtual const wxFont
& GetFont() const { return m_font
; }
1486 virtual const wxPen
& GetPen() const { return m_pen
; }
1488 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
1489 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
1490 virtual void SetTextForeground(const wxColour
& colour
)
1491 { m_textForegroundColour
= colour
; }
1492 virtual void SetTextBackground(const wxColour
& colour
)
1493 { m_textBackgroundColour
= colour
; }
1496 // coordinates conversions and transforms
1497 // --------------------------------------
1499 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
1500 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
1501 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
1502 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
1503 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
1504 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
1505 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
1506 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
1508 virtual void SetMapMode(int mode
);
1509 virtual int GetMapMode() const { return m_mappingMode
; }
1511 virtual void SetUserScale(double x
, double y
);
1512 virtual void GetUserScale(double *x
, double *y
) const
1514 if ( x
) *x
= m_userScaleX
;
1515 if ( y
) *y
= m_userScaleY
;
1518 virtual void SetLogicalScale(double x
, double y
);
1519 virtual void GetLogicalScale(double *x
, double *y
)
1521 if ( x
) *x
= m_logicalScaleX
;
1522 if ( y
) *y
= m_logicalScaleY
;
1525 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
1526 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1527 { DoGetLogicalOrigin(x
, y
); }
1528 wxPoint
GetLogicalOrigin() const
1529 { wxCoord x
, y
; DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
1531 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
1532 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1533 { DoGetDeviceOrigin(x
, y
); }
1534 wxPoint
GetDeviceOrigin() const
1535 { wxCoord x
, y
; DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
1537 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
1539 virtual void ComputeScaleAndOrigin();
1541 // this needs to overidden if the axis is inverted (such
1542 // as when using Postscript, where 0,0 is the lower left
1543 // corner, not the upper left).
1544 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
1546 // logical functions
1547 // ---------------------------
1549 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
1550 virtual void SetLogicalFunction(int function
) = 0;
1555 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
1557 if ( m_isBBoxValid
)
1559 if ( x
< m_minX
) m_minX
= x
;
1560 if ( y
< m_minY
) m_minY
= y
;
1561 if ( x
> m_maxX
) m_maxX
= x
;
1562 if ( y
> m_maxY
) m_maxY
= y
;
1566 m_isBBoxValid
= true;
1575 void ResetBoundingBox()
1577 m_isBBoxValid
= false;
1579 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
1582 // Get the final bounding box of the PostScript or Metafile picture.
1583 wxCoord
MinX() const { return m_minX
; }
1584 wxCoord
MaxX() const { return m_maxX
; }
1585 wxCoord
MinY() const { return m_minY
; }
1586 wxCoord
MaxY() const { return m_maxY
; }
1588 // misc old functions
1589 // ------------------
1591 #if WXWIN_COMPATIBILITY_2_8
1592 // for compatibility with the old code when wxCoord was long everywhere
1593 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1595 long *descent
= NULL
,
1596 long *externalLeading
= NULL
,
1597 const wxFont
*theFont
= NULL
) const );
1598 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1599 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1600 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1601 #endif // WXWIN_COMPATIBILITY_2_8
1603 // RTL related functions
1604 // ---------------------
1606 // get or change the layout direction (LTR or RTL) for this dc,
1607 // wxLayout_Default is returned if layout direction is not supported
1608 virtual wxLayoutDirection
GetLayoutDirection() const
1609 { return wxLayout_Default
; }
1610 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
))
1614 // the pure virtual functions which should be implemented by wxDC
1615 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1616 int style
= wxFLOOD_SURFACE
) = 0;
1618 virtual void DoGradientFillLinear(const wxRect
& rect
,
1619 const wxColour
& initialColour
,
1620 const wxColour
& destColour
,
1621 wxDirection nDirection
= wxEAST
);
1623 virtual void DoGradientFillConcentric(const wxRect
& rect
,
1624 const wxColour
& initialColour
,
1625 const wxColour
& destColour
,
1626 const wxPoint
& circleCenter
);
1628 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
1630 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
1631 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
1633 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
1634 wxCoord x2
, wxCoord y2
,
1635 wxCoord xc
, wxCoord yc
) = 0;
1636 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
1637 wxCoord width
, wxCoord height
);
1638 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1639 double sa
, double ea
) = 0;
1641 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
1642 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1643 wxCoord width
, wxCoord height
,
1645 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
1646 wxCoord width
, wxCoord height
) = 0;
1648 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
1650 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
1651 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1652 bool useMask
= false) = 0;
1654 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
1655 virtual void DoDrawRotatedText(const wxString
& text
,
1656 wxCoord x
, wxCoord y
, double angle
) = 0;
1658 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
1659 wxCoord width
, wxCoord height
,
1661 wxCoord xsrc
, wxCoord ysrc
,
1663 bool useMask
= false,
1664 wxCoord xsrcMask
= wxDefaultCoord
,
1665 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
1667 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
1668 wxCoord dstWidth
, wxCoord dstHeight
,
1670 wxCoord xsrc
, wxCoord ysrc
,
1671 wxCoord srcWidth
, wxCoord srcHeight
,
1673 bool useMask
= false,
1674 wxCoord xsrcMask
= wxDefaultCoord
,
1675 wxCoord ysrcMask
= wxDefaultCoord
);
1677 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
1678 { return wxNullBitmap
; }
1680 virtual void DoGetSize(int *width
, int *height
) const = 0;
1681 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
1683 virtual void DoDrawLines(int n
, wxPoint points
[],
1684 wxCoord xoffset
, wxCoord yoffset
) = 0;
1685 virtual void DoDrawPolygon(int n
, wxPoint points
[],
1686 wxCoord xoffset
, wxCoord yoffset
,
1687 int fillStyle
= wxODDEVEN_RULE
) = 0;
1688 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1689 wxCoord xoffset
, wxCoord yoffset
,
1692 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
1693 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
1694 wxCoord width
, wxCoord height
) = 0;
1696 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
1697 wxCoord
*w
, wxCoord
*h
) const
1704 *w
= m_clipX2
- m_clipX1
;
1706 *h
= m_clipY2
- m_clipY1
;
1709 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1711 if ( x
) *x
= m_logicalOriginX
;
1712 if ( y
) *y
= m_logicalOriginY
;
1715 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1717 if ( x
) *x
= m_deviceOriginX
;
1718 if ( y
) *y
= m_deviceOriginY
;
1721 virtual void DoGetTextExtent(const wxString
& string
,
1722 wxCoord
*x
, wxCoord
*y
,
1723 wxCoord
*descent
= NULL
,
1724 wxCoord
*externalLeading
= NULL
,
1725 const wxFont
*theFont
= NULL
) const = 0;
1727 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
1730 virtual void DoDrawSpline(const wxPointList
*points
);
1734 // unset clipping variables (after clipping region was destroyed)
1735 void ResetClipping()
1739 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
1746 bool m_isInteractive
:1;
1747 bool m_isBBoxValid
:1;
1749 // coordinate system variables
1751 // TODO short descriptions of what exactly they are would be nice...
1753 wxCoord m_logicalOriginX
, m_logicalOriginY
;
1754 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
1756 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
1757 // is not at 0,0. This was the case under
1758 // Mac's GrafPorts (coordinate system
1759 // used toplevel window's origin) and
1760 // e.g. for Postscript, where the native
1761 // origin in the bottom left corner.
1762 double m_logicalScaleX
, m_logicalScaleY
;
1763 double m_userScaleX
, m_userScaleY
;
1764 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
1766 // Used by SetAxisOrientation() to invert the axes
1767 int m_signX
, m_signY
;
1769 // what is a mm on a screen you don't know the size of?
1770 double m_mm_to_pix_x
,
1773 // bounding and clipping boxes
1774 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
1775 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
1777 int m_logicalFunction
;
1778 int m_backgroundMode
;
1784 wxBrush m_backgroundBrush
;
1785 wxColour m_textForegroundColour
;
1786 wxColour m_textBackgroundColour
;
1790 wxPalette m_palette
;
1791 bool m_hasCustomPalette
;
1792 #endif // wxUSE_PALETTE
1795 DECLARE_NO_COPY_CLASS(wxDCBase
)
1796 DECLARE_ABSTRACT_CLASS(wxDCBase
)
1799 #endif // wxUSE_NEW_DC
1801 // ----------------------------------------------------------------------------
1802 // now include the declaration of wxDC class
1803 // ----------------------------------------------------------------------------
1805 #if defined(__WXPALMOS__)
1806 #include "wx/palmos/dc.h"
1807 #elif defined(__WXMSW__)
1808 #include "wx/msw/dc.h"
1809 #elif defined(__WXMOTIF__)
1810 #include "wx/motif/dc.h"
1811 #elif defined(__WXGTK20__)
1812 #include "wx/gtk/dc.h"
1813 #elif defined(__WXGTK__)
1814 #include "wx/gtk1/dc.h"
1815 #elif defined(__WXX11__)
1816 #include "wx/x11/dc.h"
1817 #elif defined(__WXMGL__)
1818 #include "wx/mgl/dc.h"
1819 #elif defined(__WXDFB__)
1820 #include "wx/dfb/dc.h"
1821 #elif defined(__WXMAC__)
1822 #include "wx/mac/dc.h"
1823 #elif defined(__WXCOCOA__)
1824 #include "wx/cocoa/dc.h"
1825 #elif defined(__WXPM__)
1826 #include "wx/os2/dc.h"
1829 #if wxUSE_GRAPHICS_CONTEXT
1830 #include "wx/dcgraph.h"
1833 // ----------------------------------------------------------------------------
1834 // helper class: you can use it to temporarily change the DC text colour and
1835 // restore it automatically when the object goes out of scope
1836 // ----------------------------------------------------------------------------
1838 class WXDLLEXPORT wxDCTextColourChanger
1841 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1843 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1848 ~wxDCTextColourChanger()
1850 if ( m_colFgOld
.Ok() )
1851 m_dc
.SetTextForeground(m_colFgOld
);
1854 void Set(const wxColour
& col
)
1856 if ( !m_colFgOld
.Ok() )
1857 m_colFgOld
= m_dc
.GetTextForeground();
1858 m_dc
.SetTextForeground(col
);
1864 wxColour m_colFgOld
;
1866 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
1869 // ----------------------------------------------------------------------------
1870 // helper class: you can use it to temporarily change the DC pen and
1871 // restore it automatically when the object goes out of scope
1872 // ----------------------------------------------------------------------------
1874 class WXDLLEXPORT wxDCPenChanger
1877 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1884 if ( m_penOld
.Ok() )
1885 m_dc
.SetPen(m_penOld
);
1893 DECLARE_NO_COPY_CLASS(wxDCPenChanger
)
1896 // ----------------------------------------------------------------------------
1897 // helper class: you can use it to temporarily change the DC brush and
1898 // restore it automatically when the object goes out of scope
1899 // ----------------------------------------------------------------------------
1901 class WXDLLEXPORT wxDCBrushChanger
1904 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1906 m_dc
.SetBrush(brush
);
1911 if ( m_brushOld
.Ok() )
1912 m_dc
.SetBrush(m_brushOld
);
1920 DECLARE_NO_COPY_CLASS(wxDCBrushChanger
)
1923 // ----------------------------------------------------------------------------
1924 // another small helper class: sets the clipping region in its ctor and
1925 // destroys it in the dtor
1926 // ----------------------------------------------------------------------------
1928 class WXDLLEXPORT wxDCClipper
1931 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1932 { dc
.SetClippingRegion(r
); }
1933 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1934 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1935 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1936 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1938 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1943 DECLARE_NO_COPY_CLASS(wxDCClipper
)
1946 #endif // _WX_DC_H_BASE_