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/list.h" // we use wxList in inline functions
30 #include "wx/dynarray.h"
33 // 1 if using the reorganized DC code
34 #define wxUSE_NEW_DC 0
39 //-----------------------------------------------------------------------------
41 //-----------------------------------------------------------------------------
43 class WXDLLIMPEXP_CORE wxImplDC
;
45 class WXDLLIMPEXP_CORE wxDCFactory
49 virtual ~wxDCFactory() {}
51 virtual wxImplDC
* CreateWindowDC() = 0;
52 virtual wxImplDC
* CreateWindowDC( wxWindow
*window
) = 0;
53 virtual wxImplDC
* CreateClientDC() = 0;
54 virtual wxImplDC
* CreateClientDC( wxWindow
*window
) = 0;
55 virtual wxImplDC
* CreatePaintDC() = 0;
56 virtual wxImplDC
* CreatePaintDC( wxWindow
*window
) = 0;
57 virtual wxImplDC
* CreateMemoryDC() = 0;
58 virtual wxImplDC
* CreateMemoryDC( wxBitmap
&bitmap
) = 0;
59 virtual wxImplDC
* CreateMemoryDC( wxDC
*dc
) = 0;
61 static void SetDCFactory( wxDCFactory
*factory
);
62 static wxDCFactory
*GetFactory();
64 static wxDCFactory
*m_factory
;
67 //-----------------------------------------------------------------------------
69 //-----------------------------------------------------------------------------
71 class WXDLLIMPEXP_CORE wxDCFactory
74 wxNativeDCFactory() {}
76 virtual wxImplDC
* CreateWindowDC();
77 virtual wxImplDC
* CreateWindowDC( wxWindow
*window
);
78 virtual wxImplDC
* CreateClientDC();
79 virtual wxImplDC
* CreateClientDC( wxWindow
*window
);
80 virtual wxImplDC
* CreatePaintDC();
81 virtual wxImplDC
* CreatePaintDC( wxWindow
*window
);
82 virtual wxImplDC
* CreateMemoryDC();
83 virtual wxImplDC
* CreateMemoryDC( wxBitmap
&bitmap
);
84 virtual wxImplDC
* CreateMemoryDC( wxDC
*dc
);
87 //-----------------------------------------------------------------------------
89 //-----------------------------------------------------------------------------
91 class WXDLLIMPEXP_CORE wxWindowDC
: public wxDC
95 wxWindowDC( wxWindow
*win
);
98 DECLARE_DYNAMIC_CLASS(wxWindowDC
)
101 //-----------------------------------------------------------------------------
103 //-----------------------------------------------------------------------------
105 class WXDLLIMPEXP_CORE wxClientDC
: public wxDC
109 wxClientDC( wxWindow
*win
);
112 DECLARE_DYNAMIC_CLASS(wxClientDC
)
115 //-----------------------------------------------------------------------------
117 //-----------------------------------------------------------------------------
119 class WXDLLIMPEXP_CORE wxMemoryDC
: public wxDC
123 wxMemoryDC( wxBitmap
& bitmap
);
124 wxMemoryDC( wxDC
*dc
);
127 DECLARE_DYNAMIC_CLASS(wxMemoryDC
)
130 //-----------------------------------------------------------------------------
132 //-----------------------------------------------------------------------------
134 class WXDLLIMPEXP_CORE wxPaintDC
: public wxDC
138 wxPaintDC( wxWindow
*win
);
141 DECLARE_DYNAMIC_CLASS(wxPaintDC
)
144 //-----------------------------------------------------------------------------
146 //-----------------------------------------------------------------------------
148 class WXDLLIMPEXP_CORE wxImplDC
: public wxObject
151 wxImplDC( wxDC
*owner
);
154 wxDC
*GetOwner() { return m_owner
; }
156 virtual bool IsOk() const { return m_ok
; }
158 // query capabilities
160 virtual bool CanDrawBitmap() const = 0;
161 virtual bool CanGetTextExtent() const = 0;
163 // query dimension, colour deps, resolution
165 virtual void DoGetSize(int *width
, int *height
) const = 0;
166 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
168 virtual int GetDepth() const = 0;
169 virtual wxSize
GetPPI() const = 0;
171 // Right-To-Left (RTL) modes
173 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
174 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
178 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
179 virtual void EndDoc() { }
181 virtual void StartPage() { }
182 virtual void EndPage() { }
186 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
);
190 if ( x
< m_minX
) m_minX
= x
;
191 if ( y
< m_minY
) m_minY
= y
;
192 if ( x
> m_maxX
) m_maxX
= x
;
193 if ( y
> m_maxY
) m_maxY
= y
;
197 m_isBBoxValid
= true;
205 void ResetBoundingBox();
207 m_isBBoxValid
= false;
209 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
212 wxCoord
MinX() const { return m_minX
; }
213 wxCoord
MaxX() const { return m_maxX
; }
214 wxCoord
MinY() const { return m_minY
; }
215 wxCoord
MaxY() const { return m_maxY
; }
217 // setters and getters
219 virtual void SetFont(const wxFont
& font
) = 0;
220 virtual const wxFont
& GetFont() const { return m_font
; }
222 virtual void SetPen(const wxPen
& pen
) = 0;
223 virtual const wxPen
& GetPen() const { return m_pen
; }
225 virtual void SetBrush(const wxBrush
& brush
) = 0;
226 virtual const wxBrush
& GetBrush() const { return m_brush
; }
228 virtual void SetBackground(const wxBrush
& brush
) = 0;
229 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
231 virtual void SetBackgroundMode(int mode
) = 0;
232 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
234 virtual void SetTextForeground(const wxColour
& colour
)
235 { m_textForegroundColour
= colour
; }
236 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
238 virtual void SetTextBackground(const wxColour
& colour
)
239 { m_textBackgroundColour
= colour
; }
240 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
243 virtual void SetPalette(const wxPalette
& palette
) = 0;
244 #endif // wxUSE_PALETTE
248 virtual void SetLogicalFunction(int function
) = 0;
249 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
253 virtual wxCoord
GetCharHeight() const = 0;
254 virtual wxCoord
GetCharWidth() const = 0;
255 virtual void DoGetTextExtent(const wxString
& string
,
256 wxCoord
*x
, wxCoord
*y
,
257 wxCoord
*descent
= NULL
,
258 wxCoord
*externalLeading
= NULL
,
259 const wxFont
*theFont
= NULL
) const = 0;
260 virtual void GetMultiLineTextExtent(const wxString
& string
,
263 wxCoord
*heightLine
= NULL
,
264 const wxFont
*font
= NULL
) const;
265 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
269 virtual void Clear() = 0;
273 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
274 wxCoord width
, wxCoord height
) = 0;
275 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
277 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
278 wxCoord
*w
, wxCoord
*h
) const
285 *w
= m_clipX2
- m_clipX1
;
287 *h
= m_clipY2
- m_clipY1
;
290 virtual void DestroyClippingRegion() { ResetClipping(); }
293 // coordinates conversions and transforms
295 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
296 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
297 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
298 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
299 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
300 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
301 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
302 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
304 virtual void SetMapMode(int mode
);
305 virtual int GetMapMode() const { return m_mappingMode
; }
307 virtual void SetUserScale(double x
, double y
);
308 virtual void GetUserScale(double *x
, double *y
) const
310 if ( x
) *x
= m_userScaleX
;
311 if ( y
) *y
= m_userScaleY
;
314 virtual void SetLogicalScale(double x
, double y
);
315 virtual void GetLogicalScale(double *x
, double *y
)
317 if ( x
) *x
= m_logicalScaleX
;
318 if ( y
) *y
= m_logicalScaleY
;
321 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
322 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
324 if ( x
) *x
= m_logicalOriginX
;
325 if ( y
) *y
= m_logicalOriginY
;
328 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
329 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
331 if ( x
) *x
= m_deviceOriginX
;
332 if ( y
) *y
= m_deviceOriginY
;
335 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
337 virtual void ComputeScaleAndOrigin();
339 // this needs to overidden if the axis is inverted
340 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
342 // ---------------------------------------------------------
343 // the actual drawing API
345 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
346 int style
= wxFLOOD_SURFACE
) = 0;
348 virtual void DoGradientFillLinear(const wxRect
& rect
,
349 const wxColour
& initialColour
,
350 const wxColour
& destColour
,
351 wxDirection nDirection
= wxEAST
);
353 virtual void DoGradientFillConcentric(const wxRect
& rect
,
354 const wxColour
& initialColour
,
355 const wxColour
& destColour
,
356 const wxPoint
& circleCenter
);
358 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
360 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
361 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
363 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
364 wxCoord x2
, wxCoord y2
,
365 wxCoord xc
, wxCoord yc
) = 0;
366 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
367 wxCoord width
, wxCoord height
);
368 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
369 double sa
, double ea
) = 0;
371 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
372 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
373 wxCoord width
, wxCoord height
,
375 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
376 wxCoord width
, wxCoord height
) = 0;
378 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
380 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
381 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
382 bool useMask
= false) = 0;
384 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
385 virtual void DoDrawRotatedText(const wxString
& text
,
386 wxCoord x
, wxCoord y
, double angle
) = 0;
388 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
389 wxCoord width
, wxCoord height
,
391 wxCoord xsrc
, wxCoord ysrc
,
393 bool useMask
= false,
394 wxCoord xsrcMask
= wxDefaultCoord
,
395 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
397 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
398 wxCoord dstWidth
, wxCoord dstHeight
,
400 wxCoord xsrc
, wxCoord ysrc
,
401 wxCoord srcWidth
, wxCoord srcHeight
,
403 bool useMask
= false,
404 wxCoord xsrcMask
= wxDefaultCoord
,
405 wxCoord ysrcMask
= wxDefaultCoord
);
407 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
408 { return wxNullBitmap
; }
411 virtual void DoDrawLines(int n
, wxPoint points
[],
412 wxCoord xoffset
, wxCoord yoffset
) = 0;
413 virtual void DoDrawPolygon(int n
, wxPoint points
[],
414 wxCoord xoffset
, wxCoord yoffset
,
415 int fillStyle
= wxODDEVEN_RULE
) = 0;
416 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
417 wxCoord xoffset
, wxCoord yoffset
,
423 virtual void DoDrawSpline(wxList
*points
);
430 // unset clipping variables (after clipping region was destroyed)
435 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
442 bool m_isInteractive
:1;
443 bool m_isBBoxValid
:1;
445 // coordinate system variables
447 wxCoord m_logicalOriginX
, m_logicalOriginY
;
448 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
450 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
451 // is not at 0,0. This was the case under
452 // Mac's GrafPorts (coordinate system
453 // used toplevel window's origin) and
454 // e.g. for Postscript, where the native
455 // origin in the bottom left corner.
456 double m_logicalScaleX
, m_logicalScaleY
;
457 double m_userScaleX
, m_userScaleY
;
458 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
460 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
462 // what is a mm on a screen you don't know the size of?
463 double m_mm_to_pix_x
,
466 // bounding and clipping boxes
467 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
468 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
470 int m_logicalFunction
;
471 int m_backgroundMode
;
476 wxBrush m_backgroundBrush
;
477 wxColour m_textForegroundColour
;
478 wxColour m_textBackgroundColour
;
483 bool m_hasCustomPalette
;
484 #endif // wxUSE_PALETTE
487 DECLARE_ABSTRACT_CLASS(wxImplDC
)
491 class wxDC
: public wxObject
494 wxDC() { m_pimpl
= NULL
; }
497 { return m_pimpl
&& m_pimpl
->IsOk(); }
499 // query capabilities
501 bool CanDrawBitmap() const
502 { return m_pimpl
->CanDrawBitmap(); }
503 bool CanGetTextExtent() const
504 { return m_pimpl
->CanGetTextExtent(); }
506 // query dimension, colour deps, resolution
508 void GetSize(int *width
, int *height
) const
509 { m_pimpl
->DoGetSize(width
, height
); }
511 wxSize
GetSize() const
514 m_pimpl
->DoGetSize(&w
, &h
);
518 void GetSizeMM(int* width
, int* height
) const
519 { m_pimpl
->DoGetSizeMM(width
, height
); }
520 wxSize
GetSizeMM() const
523 m_pimpl
->DoGetSizeMM(&w
, &h
);
528 { return m_pimpl
->GetDepth(); }
529 wxSize
GetPPI() const
530 { return m_pimpl
->GetPPI(); }
532 // Right-To-Left (RTL) modes
534 void SetLayoutDirection(wxLayoutDirection dir
)
535 { m_pimpl
->SetLayoutDirection( dir
); }
536 wxLayoutDirection
GetLayoutDirection() const
537 { return m_pimpl
->GetLayoutDirection(); }
541 bool StartDoc(const wxString
& message
)
542 { return m_pimpl
->StartDoc(message
); }
544 { m_pimpl
->EndDoc(); }
547 { m_pimpl
->StartPage(); }
549 { m_pimpl
->EndPage(); }
553 void CalcBoundingBox(wxCoord x
, wxCoord y
)
554 { m_pimpl
->CalcBoundingBox(x
,y
); }
555 void ResetBoundingBox()
556 { m_pimpl
->ResetBoundingBox(); }
559 { return m_pimpl
->MinX(); }
561 { return m_pimpl
->MaxX(); }
563 { return m_pimpl
->MinY(); }
565 { return m_pimpl
->MaxY(); }
567 // setters and getters
569 void SetFont(const wxFont
& font
)
570 { m_pimpl
->SetFont( font
); }
571 const wxFont
& GetFont() const
572 { return m_pimpl
->GetFont(); }
574 void SetPen(const wxPen
& pen
)
575 { m_pimpl
->SetPen( pen
); }
576 const wxPen
& GetPen() const
577 { return m_pimpl
->GetPen(); }
579 void SetBrush(const wxBrush
& brush
)
580 { m_pimpl
->SetBrush( brush
); }
581 const wxBrush
& GetBrush() const
582 { return m_pimpl
->GetBrush(); }
584 void SetBackground(const wxBrush
& brush
)
585 { m_pimpl
->SetBackground( brush
); }
586 const wxBrush
& GetBackground() const
587 { return m_pimpl
->GetBackground(); }
589 void SetBackgroundMode(int mode
)
590 { m_pimpl
->SetBackground( mode
); }
591 int GetBackgroundMode() const
592 { return m_pimpl
->GetBackground(); }
594 void SetTextForeground(const wxColour
& colour
)
595 { m_pimpl
->SetTextForeground(colour
); }
596 const wxColour
& GetTextForeground() const
597 { return m_pimpl
->GetTextForeground(); }
599 void SetTextBackground(const wxColour
& colour
)
600 { m_pimpl
->SetTextBackground(colour
); }
601 const wxColour
& GetTextBackground() const
602 { return m_pimpl
->GetTextBackground(); }
605 void SetPalette(const wxPalette
& palette
)
606 { m_pimpl
->SetPalette(palette
); }
607 #endif // wxUSE_PALETTE
611 void SetLogicalFunction(int function
)
612 { m_pimpl
->SetLogicalFunction(function
); }
613 int GetLogicalFunction() const
614 { return m_pimpl
->GetLogicalFunction(); }
618 wxCoord
GetCharHeight() const
619 { return m_pimpl
->GetCharHeight(); }
620 wxCoord
GetCharWidth() const
621 { return m_pimpl
->GetCharWidth(); }
623 void GetTextExtent(const wxString
& string
,
624 wxCoord
*x
, wxCoord
*y
,
625 wxCoord
*descent
= NULL
,
626 wxCoord
*externalLeading
= NULL
,
627 const wxFont
*theFont
= NULL
) const
628 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
630 wxSize
GetTextExtent(const wxString
& string
) const
633 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
637 void GetMultiLineTextExtent(const wxString
& string
,
640 wxCoord
*heightLine
= NULL
,
641 const wxFont
*font
= NULL
) const
642 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
644 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
647 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
651 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
652 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
657 { m_pimpl
->Clear(); }
661 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
662 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
663 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
664 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
665 void SetClippingRegion(const wxRect
& rect
)
666 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
667 void SetClippingRegion(const wxRegion
& region
)
668 { m_pimpl
->DoSetClippingRegionAsRegion(region
); }
670 void DestroyClippingRegion()
671 { m_pimpl
->DestroyClippingRegion(); }
673 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
674 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
675 void GetClippingBox(wxRect
& rect
) const
676 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
678 // coordinates conversions and transforms
680 wxCoord
DeviceToLogicalX(wxCoord x
) const
681 { return m_pimpl
->DeviceToLogicalX(x
); }
682 wxCoord
DeviceToLogicalY(wxCoord y
) const;
683 { return m_pimpl
->DeviceToLogicalY(y
); }
684 wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
685 { return m_pimpl
->DeviceToLogicalXRel(x
); }
686 wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
687 { return m_pimpl
->DeviceToLogicalYRel(y
); }
688 wxCoord
LogicalToDeviceX(wxCoord x
) const;
689 { return m_pimpl
->LogicalToDeviceX(x
); }
690 wxCoord
LogicalToDeviceY(wxCoord y
) const;
691 { return m_pimpl
->LogicalToDeviceY(y
); }
692 wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
693 { return m_pimpl
->LogicalToDeviceXRel(x
); }
694 wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
695 { return m_pimpl
->LogicalToDeviceYRel(y
); }
697 void SetMapMode(int mode
)
698 { m_pimpl
->SetMapMode(mode
); }
699 int GetMapMode() const
700 { return m_pimpl
->GetMapMode(); }
702 void SetUserScale(double x
, double y
)
703 { m_pimpl
->SetUserScale(x
,y
); }
704 void GetUserScale(double *x
, double *y
) const
705 { m_pimpl
->GetUserScale( x
, y
); }
707 void SetLogicalScale(double x
, double y
)
708 { m_pimpl
->SetLogicalScale( x
, y
); }
709 void GetLogicalScale(double *x
, double *y
)
710 { m_pimpl
->GetLogicalScale( x
, y
); }
712 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
713 { m_pimpl
->SetLogicalOrigin(x
,y
); }
714 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
715 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
716 wxPoint
GetLogicalOrigin() const
717 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
719 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
720 { m_pimpl
->SetDeviceOrigin( x
, y
); }
721 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
722 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
723 wxPoint
GetDeviceOrigin() const
724 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
726 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
727 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
730 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
731 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
734 // draw generic object
736 void DrawObject(wxDrawObject
* drawobject
)
738 drawobject
->Draw(*this);
739 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
740 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
743 // -----------------------------------------------
744 // the actual drawing API
746 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
747 int style
= wxFLOOD_SURFACE
)
748 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
749 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
750 int style
= wxFLOOD_SURFACE
)
751 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
753 // fill the area specified by rect with a radial gradient, starting from
754 // initialColour in the centre of the cercle and fading to destColour.
755 void GradientFillConcentric(const wxRect
& rect
,
756 const wxColour
& initialColour
,
757 const wxColour
& destColour
)
758 { m_pimpl
->GradientFillConcentric(rect
, initialColour
, destColour
,
759 wxPoint(rect
.GetWidth() / 2,
760 rect
.GetHeight() / 2)); }
762 void GradientFillConcentric(const wxRect
& rect
,
763 const wxColour
& initialColour
,
764 const wxColour
& destColour
,
765 const wxPoint
& circleCenter
)
766 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
768 // fill the area specified by rect with a linear gradient
769 void GradientFillLinear(const wxRect
& rect
,
770 const wxColour
& initialColour
,
771 const wxColour
& destColour
,
772 wxDirection nDirection
= wxEAST
)
773 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
775 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
776 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
777 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
778 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
780 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
781 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
782 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
783 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
785 void CrossHair(wxCoord x
, wxCoord y
)
786 { m_pimpl
->DoCrossHair(x
, y
); }
787 void CrossHair(const wxPoint
& pt
)
788 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
790 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
791 wxCoord xc
, wxCoord yc
)
792 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
793 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
794 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
796 void DrawCheckMark(wxCoord x
, wxCoord y
,
797 wxCoord width
, wxCoord height
)
798 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
799 void DrawCheckMark(const wxRect
& rect
)
800 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
802 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
803 double sa
, double ea
)
804 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
805 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
806 double sa
, double ea
)
807 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
809 void DrawPoint(wxCoord x
, wxCoord y
)
810 { m_pimpl
->DoDrawPoint(x
, y
); }
811 void DrawPoint(const wxPoint
& pt
)
812 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
814 void DrawLines(int n
, wxPoint points
[],
815 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
816 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
817 void DrawLines(const wxList
*list
,
818 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
819 { m_pimpl
->DrawLines( list
, xoffset
, yoffset
); }
821 void DrawPolygon(int n
, wxPoint points
[],
822 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
823 int fillStyle
= wxODDEVEN_RULE
)
824 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
826 void DrawPolygon(const wxList
*list
,
827 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
828 int fillStyle
= wxODDEVEN_RULE
)
829 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
831 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
832 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
833 int fillStyle
= wxODDEVEN_RULE
)
834 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
836 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
837 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
838 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
839 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
840 void DrawRectangle(const wxRect
& rect
)
841 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
843 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
845 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
846 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
848 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
849 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
850 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
852 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
853 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
854 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
855 { m_pimpl
->DrawCircle(pt
.x
, pt
.y
, radius
); }
857 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
858 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
859 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
860 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
861 void DrawEllipse(const wxRect
& rect
)
862 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
864 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
865 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
866 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
867 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
869 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
870 bool useMask
= false)
871 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
872 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
873 bool useMask
= false)
874 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
876 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
877 { m_pimpl
->DoDrawText(text
, x
, y
); }
878 void DrawText(const wxString
& text
, const wxPoint
& pt
)
879 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
881 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
882 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
883 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
884 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
886 // this version puts both optional bitmap and the text into the given
887 // rectangle and aligns is as specified by alignment parameter; it also
888 // will emphasize the character with the given index if it is != -1 and
889 // return the bounding rectangle if required
890 void DrawLabel(const wxString
& text
,
891 const wxBitmap
& image
,
893 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
895 wxRect
*rectBounding
= NULL
)
896 { m_pimpl
->DrawLabel( text
, image
, rect
, alignment
, indexAccel
, rectBounding
); }
898 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
899 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
901 { m_pimpl
->DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
903 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
904 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
905 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
907 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
908 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
910 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
911 wxDC
*source
, const wxPoint
& srcPt
,
912 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
914 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
915 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
918 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
919 wxCoord dstWidth
, wxCoord dstHeight
,
921 wxCoord srcX
, wxCoord srcY
,
922 wxCoord srcWidth
, wxCoord srcHeight
,
923 int rop
= wxCOPY
, bool useMask
= false,
924 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
926 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
927 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
929 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
930 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
931 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
933 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
934 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
937 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
939 return m_pimpl
->DoGetAsBitmap(subrect
);
943 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
944 void DrawSpline(wxCoord x1
, wxCoord y1
,
945 wxCoord x2
, wxCoord y2
,
946 wxCoord x3
, wxCoord y3
)
947 { m_pimpl
->DrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
948 void DrawSpline(int n
, wxPoint points
[])
949 { m_pimpl
->DrawSpline(n
,points
); }
951 void DrawSpline(wxList
*points
)
952 { m_pimpl
->DoDrawSpline(points
); }
953 #endif // wxUSE_SPLINES
956 #if WXWIN_COMPATIBILITY_2_8
957 // for compatibility with the old code when wxCoord was long everywhere
958 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
960 long *descent
= NULL
,
961 long *externalLeading
= NULL
,
962 const wxFont
*theFont
= NULL
) const );
963 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
964 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
965 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
966 #endif // WXWIN_COMPATIBILITY_2_8
973 DECLARE_ABSTRACT_CLASS(wxImplDC
)
977 #else // wxUSE_NEW_DC
980 class WXDLLEXPORT wxDC
;
981 class WXDLLEXPORT wxDCBase
;
983 class WXDLLEXPORT wxDrawObject
988 : m_isBBoxValid(false)
989 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
992 virtual ~wxDrawObject() { }
994 virtual void Draw(wxDCBase
&) const { }
996 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
1000 if ( x
< m_minX
) m_minX
= x
;
1001 if ( y
< m_minY
) m_minY
= y
;
1002 if ( x
> m_maxX
) m_maxX
= x
;
1003 if ( y
> m_maxY
) m_maxY
= y
;
1007 m_isBBoxValid
= true;
1016 void ResetBoundingBox()
1018 m_isBBoxValid
= false;
1020 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
1023 // Get the final bounding box of the PostScript or Metafile picture.
1025 wxCoord
MinX() const { return m_minX
; }
1026 wxCoord
MaxX() const { return m_maxX
; }
1027 wxCoord
MinY() const { return m_minY
; }
1028 wxCoord
MaxY() const { return m_maxY
; }
1030 //to define the type of object for derived objects
1031 virtual int GetType()=0;
1034 //for boundingbox calculation
1035 bool m_isBBoxValid
:1;
1036 //for boundingbox calculation
1037 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
1040 // ---------------------------------------------------------------------------
1042 // ---------------------------------------------------------------------------
1044 // ---------------------------------------------------------------------------
1045 // wxDC is the device context - object on which any drawing is done
1046 // ---------------------------------------------------------------------------
1048 class WXDLLEXPORT wxDCBase
: public wxObject
1052 virtual ~wxDCBase();
1054 // graphic primitives
1055 // ------------------
1057 virtual void DrawObject(wxDrawObject
* drawobject
)
1059 drawobject
->Draw(*this);
1060 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
1061 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
1064 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1065 int style
= wxFLOOD_SURFACE
)
1066 { return DoFloodFill(x
, y
, col
, style
); }
1067 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
1068 int style
= wxFLOOD_SURFACE
)
1069 { return DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
1071 // fill the area specified by rect with a radial gradient, starting from
1072 // initialColour in the centre of the cercle and fading to destColour.
1073 void GradientFillConcentric(const wxRect
& rect
,
1074 const wxColour
& initialColour
,
1075 const wxColour
& destColour
)
1076 { GradientFillConcentric(rect
, initialColour
, destColour
,
1077 wxPoint(rect
.GetWidth() / 2,
1078 rect
.GetHeight() / 2)); }
1080 void GradientFillConcentric(const wxRect
& rect
,
1081 const wxColour
& initialColour
,
1082 const wxColour
& destColour
,
1083 const wxPoint
& circleCenter
)
1084 { DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
1086 // fill the area specified by rect with a linear gradient
1087 void GradientFillLinear(const wxRect
& rect
,
1088 const wxColour
& initialColour
,
1089 const wxColour
& destColour
,
1090 wxDirection nDirection
= wxEAST
)
1091 { DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
1093 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
1094 { return DoGetPixel(x
, y
, col
); }
1095 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
1096 { return DoGetPixel(pt
.x
, pt
.y
, col
); }
1098 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1099 { DoDrawLine(x1
, y1
, x2
, y2
); }
1100 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
1101 { DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
1103 void CrossHair(wxCoord x
, wxCoord y
)
1104 { DoCrossHair(x
, y
); }
1105 void CrossHair(const wxPoint
& pt
)
1106 { DoCrossHair(pt
.x
, pt
.y
); }
1108 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
1109 wxCoord xc
, wxCoord yc
)
1110 { DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
1111 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
1112 { DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
1114 void DrawCheckMark(wxCoord x
, wxCoord y
,
1115 wxCoord width
, wxCoord height
)
1116 { DoDrawCheckMark(x
, y
, width
, height
); }
1117 void DrawCheckMark(const wxRect
& rect
)
1118 { DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1120 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1121 double sa
, double ea
)
1122 { DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
1123 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
1124 double sa
, double ea
)
1125 { DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
1127 void DrawPoint(wxCoord x
, wxCoord y
)
1128 { DoDrawPoint(x
, y
); }
1129 void DrawPoint(const wxPoint
& pt
)
1130 { DoDrawPoint(pt
.x
, pt
.y
); }
1132 void DrawLines(int n
, wxPoint points
[],
1133 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1134 { DoDrawLines(n
, points
, xoffset
, yoffset
); }
1135 void DrawLines(const wxList
*list
,
1136 wxCoord xoffset
= 0, wxCoord yoffset
= 0);
1138 void DrawPolygon(int n
, wxPoint points
[],
1139 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1140 int fillStyle
= wxODDEVEN_RULE
)
1141 { DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
1143 void DrawPolygon(const wxList
*list
,
1144 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1145 int fillStyle
= wxODDEVEN_RULE
);
1147 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1148 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1149 int fillStyle
= wxODDEVEN_RULE
)
1150 { DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
1152 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1153 { DoDrawRectangle(x
, y
, width
, height
); }
1154 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
1155 { DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1156 void DrawRectangle(const wxRect
& rect
)
1157 { DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1159 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
1161 { DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
1162 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
1164 { DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
1165 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
1166 { DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1168 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1169 { DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1170 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1171 { DrawCircle(pt
.x
, pt
.y
, radius
); }
1173 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1174 { DoDrawEllipse(x
, y
, width
, height
); }
1175 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1176 { DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1177 void DrawEllipse(const wxRect
& rect
)
1178 { DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1180 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1181 { DoDrawIcon(icon
, x
, y
); }
1182 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1183 { DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1185 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1186 bool useMask
= false)
1187 { DoDrawBitmap(bmp
, x
, y
, useMask
); }
1188 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1189 bool useMask
= false)
1190 { DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1192 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1193 { DoDrawText(text
, x
, y
); }
1194 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1195 { DoDrawText(text
, pt
.x
, pt
.y
); }
1197 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1198 { DoDrawRotatedText(text
, x
, y
, angle
); }
1199 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1200 { DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1202 // this version puts both optional bitmap and the text into the given
1203 // rectangle and aligns is as specified by alignment parameter; it also
1204 // will emphasize the character with the given index if it is != -1 and
1205 // return the bounding rectangle if required
1206 virtual void DrawLabel(const wxString
& text
,
1207 const wxBitmap
& image
,
1209 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1210 int indexAccel
= -1,
1211 wxRect
*rectBounding
= NULL
);
1213 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1214 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1215 int indexAccel
= -1)
1216 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1218 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1219 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1220 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1222 return DoBlit(xdest
, ydest
, width
, height
,
1223 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1225 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1226 wxDC
*source
, const wxPoint
& srcPt
,
1227 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
1229 return DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1230 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1233 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1234 wxCoord dstWidth
, wxCoord dstHeight
,
1236 wxCoord srcX
, wxCoord srcY
,
1237 wxCoord srcWidth
, wxCoord srcHeight
,
1238 int rop
= wxCOPY
, bool useMask
= false,
1239 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1241 return DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1242 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1244 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1245 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1246 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1248 return DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1249 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1252 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1254 return DoGetAsBitmap(subrect
);
1258 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
1259 void DrawSpline(wxCoord x1
, wxCoord y1
,
1260 wxCoord x2
, wxCoord y2
,
1261 wxCoord x3
, wxCoord y3
);
1262 void DrawSpline(int n
, wxPoint points
[]);
1264 void DrawSpline(wxList
*points
) { DoDrawSpline(points
); }
1265 #endif // wxUSE_SPLINES
1267 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
1269 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
1270 /*! \param x Upper left corner of bounding box.
1271 * \param y Upper left corner of bounding box.
1272 * \param w Width of bounding box.
1273 * \param h Height of bounding box.
1274 * \param sa Starting angle of arc
1275 * (counterclockwise, start at 3 o'clock, 360 is full circle).
1276 * \param ea Ending angle of arc.
1277 * \param angle Rotation angle, the Arc will be rotated after
1278 * calculating begin and end.
1280 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
1281 wxCoord width
, wxCoord height
,
1282 double sa
= 0, double ea
= 0, double angle
= 0 )
1283 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
1285 void DrawEllipticArcRot( const wxPoint
& pt
,
1287 double sa
= 0, double ea
= 0, double angle
= 0 )
1288 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
1290 void DrawEllipticArcRot( const wxRect
& rect
,
1291 double sa
= 0, double ea
= 0, double angle
= 0 )
1292 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
1294 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
1295 wxCoord w
, wxCoord h
,
1296 double sa
= 0, double ea
= 0, double angle
= 0 );
1298 //! Rotates points around center.
1299 /*! This is a quite straight method, it calculates in pixels
1300 * and so it produces rounding errors.
1301 * \param points The points inside will be rotated.
1302 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
1303 * \param center Center of rotation.
1305 void Rotate( wxList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
1307 // used by DrawEllipticArcRot
1308 // Careful: wxList gets filled with points you have to delete later.
1309 void CalculateEllipticPoints( wxList
* points
,
1310 wxCoord xStart
, wxCoord yStart
,
1311 wxCoord w
, wxCoord h
,
1312 double sa
, double ea
);
1315 // global DC operations
1316 // --------------------
1318 virtual void Clear() = 0;
1320 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
1321 virtual void EndDoc() { }
1323 virtual void StartPage() { }
1324 virtual void EndPage() { }
1326 #if WXWIN_COMPATIBILITY_2_6
1327 wxDEPRECATED( void BeginDrawing() );
1328 wxDEPRECATED( void EndDrawing() );
1329 #endif // WXWIN_COMPATIBILITY_2_6
1332 // set objects to use for drawing
1333 // ------------------------------
1335 virtual void SetFont(const wxFont
& font
) = 0;
1336 virtual void SetPen(const wxPen
& pen
) = 0;
1337 virtual void SetBrush(const wxBrush
& brush
) = 0;
1338 virtual void SetBackground(const wxBrush
& brush
) = 0;
1339 virtual void SetBackgroundMode(int mode
) = 0;
1341 virtual void SetPalette(const wxPalette
& palette
) = 0;
1342 #endif // wxUSE_PALETTE
1347 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1348 { DoSetClippingRegion(x
, y
, width
, height
); }
1349 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
1350 { DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1351 void SetClippingRegion(const wxRect
& rect
)
1352 { DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1353 void SetClippingRegion(const wxRegion
& region
)
1354 { DoSetClippingRegionAsRegion(region
); }
1356 virtual void DestroyClippingRegion() { ResetClipping(); }
1358 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
1359 { DoGetClippingBox(x
, y
, w
, h
); }
1360 void GetClippingBox(wxRect
& rect
) const
1362 DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
);
1368 virtual wxCoord
GetCharHeight() const = 0;
1369 virtual wxCoord
GetCharWidth() const = 0;
1371 // only works for single line strings
1372 void GetTextExtent(const wxString
& string
,
1373 wxCoord
*x
, wxCoord
*y
,
1374 wxCoord
*descent
= NULL
,
1375 wxCoord
*externalLeading
= NULL
,
1376 const wxFont
*theFont
= NULL
) const
1377 { DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
1379 wxSize
GetTextExtent(const wxString
& string
) const
1382 DoGetTextExtent(string
, &w
, &h
);
1383 return wxSize(w
, h
);
1386 // works for single as well as multi-line strings
1387 virtual void GetMultiLineTextExtent(const wxString
& string
,
1390 wxCoord
*heightLine
= NULL
,
1391 const wxFont
*font
= NULL
) const;
1393 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
1396 GetMultiLineTextExtent(string
, &w
, &h
);
1397 return wxSize(w
, h
);
1400 // Measure cumulative width of text after each character
1401 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1402 { return DoGetPartialTextExtents(text
, widths
); }
1405 // size and resolution
1406 // -------------------
1409 void GetSize(int *width
, int *height
) const
1410 { DoGetSize(width
, height
); }
1411 wxSize
GetSize() const
1416 return wxSize(w
, h
);
1420 void GetSizeMM(int* width
, int* height
) const
1421 { DoGetSizeMM(width
, height
); }
1422 wxSize
GetSizeMM() const
1425 DoGetSizeMM(&w
, &h
);
1427 return wxSize(w
, h
);
1430 // query DC capabilities
1431 // ---------------------
1433 virtual bool CanDrawBitmap() const = 0;
1434 virtual bool CanGetTextExtent() const = 0;
1437 virtual int GetDepth() const = 0;
1439 // Resolution in Pixels per inch
1440 virtual wxSize
GetPPI() const = 0;
1442 virtual bool Ok() const { return IsOk(); }
1443 virtual bool IsOk() const { return m_ok
; }
1445 // accessors and setters
1446 // ---------------------
1448 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
1449 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
1450 virtual const wxBrush
& GetBrush() const { return m_brush
; }
1451 virtual const wxFont
& GetFont() const { return m_font
; }
1452 virtual const wxPen
& GetPen() const { return m_pen
; }
1454 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
1455 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
1456 virtual void SetTextForeground(const wxColour
& colour
)
1457 { m_textForegroundColour
= colour
; }
1458 virtual void SetTextBackground(const wxColour
& colour
)
1459 { m_textBackgroundColour
= colour
; }
1462 // coordinates conversions and transforms
1463 // --------------------------------------
1465 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
1466 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
1467 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
1468 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
1469 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
1470 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
1471 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
1472 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
1474 virtual void SetMapMode(int mode
);
1475 virtual int GetMapMode() const { return m_mappingMode
; }
1477 virtual void SetUserScale(double x
, double y
);
1478 virtual void GetUserScale(double *x
, double *y
) const
1480 if ( x
) *x
= m_userScaleX
;
1481 if ( y
) *y
= m_userScaleY
;
1484 virtual void SetLogicalScale(double x
, double y
);
1485 virtual void GetLogicalScale(double *x
, double *y
)
1487 if ( x
) *x
= m_logicalScaleX
;
1488 if ( y
) *y
= m_logicalScaleY
;
1491 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
1492 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1493 { DoGetLogicalOrigin(x
, y
); }
1494 wxPoint
GetLogicalOrigin() const
1495 { wxCoord x
, y
; DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
1497 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
1498 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1499 { DoGetDeviceOrigin(x
, y
); }
1500 wxPoint
GetDeviceOrigin() const
1501 { wxCoord x
, y
; DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
1503 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
1505 virtual void ComputeScaleAndOrigin();
1507 // this needs to overidden if the axis is inverted (such
1508 // as when using Postscript, where 0,0 is the lower left
1509 // corner, not the upper left).
1510 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
1512 // logical functions
1513 // ---------------------------
1515 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
1516 virtual void SetLogicalFunction(int function
) = 0;
1521 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
1523 if ( m_isBBoxValid
)
1525 if ( x
< m_minX
) m_minX
= x
;
1526 if ( y
< m_minY
) m_minY
= y
;
1527 if ( x
> m_maxX
) m_maxX
= x
;
1528 if ( y
> m_maxY
) m_maxY
= y
;
1532 m_isBBoxValid
= true;
1541 void ResetBoundingBox()
1543 m_isBBoxValid
= false;
1545 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
1548 // Get the final bounding box of the PostScript or Metafile picture.
1549 wxCoord
MinX() const { return m_minX
; }
1550 wxCoord
MaxX() const { return m_maxX
; }
1551 wxCoord
MinY() const { return m_minY
; }
1552 wxCoord
MaxY() const { return m_maxY
; }
1554 // misc old functions
1555 // ------------------
1557 #if WXWIN_COMPATIBILITY_2_8
1558 // for compatibility with the old code when wxCoord was long everywhere
1559 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1561 long *descent
= NULL
,
1562 long *externalLeading
= NULL
,
1563 const wxFont
*theFont
= NULL
) const );
1564 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1565 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1566 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1567 #endif // WXWIN_COMPATIBILITY_2_8
1569 // RTL related functions
1570 // ---------------------
1572 // get or change the layout direction (LTR or RTL) for this dc,
1573 // wxLayout_Default is returned if layout direction is not supported
1574 virtual wxLayoutDirection
GetLayoutDirection() const
1575 { return wxLayout_Default
; }
1576 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
))
1580 // the pure virtual functions which should be implemented by wxDC
1581 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1582 int style
= wxFLOOD_SURFACE
) = 0;
1584 virtual void DoGradientFillLinear(const wxRect
& rect
,
1585 const wxColour
& initialColour
,
1586 const wxColour
& destColour
,
1587 wxDirection nDirection
= wxEAST
);
1589 virtual void DoGradientFillConcentric(const wxRect
& rect
,
1590 const wxColour
& initialColour
,
1591 const wxColour
& destColour
,
1592 const wxPoint
& circleCenter
);
1594 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
1596 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
1597 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
1599 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
1600 wxCoord x2
, wxCoord y2
,
1601 wxCoord xc
, wxCoord yc
) = 0;
1602 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
1603 wxCoord width
, wxCoord height
);
1604 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1605 double sa
, double ea
) = 0;
1607 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
1608 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1609 wxCoord width
, wxCoord height
,
1611 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
1612 wxCoord width
, wxCoord height
) = 0;
1614 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
1616 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
1617 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1618 bool useMask
= false) = 0;
1620 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
1621 virtual void DoDrawRotatedText(const wxString
& text
,
1622 wxCoord x
, wxCoord y
, double angle
) = 0;
1624 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
1625 wxCoord width
, wxCoord height
,
1627 wxCoord xsrc
, wxCoord ysrc
,
1629 bool useMask
= false,
1630 wxCoord xsrcMask
= wxDefaultCoord
,
1631 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
1633 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
1634 wxCoord dstWidth
, wxCoord dstHeight
,
1636 wxCoord xsrc
, wxCoord ysrc
,
1637 wxCoord srcWidth
, wxCoord srcHeight
,
1639 bool useMask
= false,
1640 wxCoord xsrcMask
= wxDefaultCoord
,
1641 wxCoord ysrcMask
= wxDefaultCoord
);
1643 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
1644 { return wxNullBitmap
; }
1646 virtual void DoGetSize(int *width
, int *height
) const = 0;
1647 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
1649 virtual void DoDrawLines(int n
, wxPoint points
[],
1650 wxCoord xoffset
, wxCoord yoffset
) = 0;
1651 virtual void DoDrawPolygon(int n
, wxPoint points
[],
1652 wxCoord xoffset
, wxCoord yoffset
,
1653 int fillStyle
= wxODDEVEN_RULE
) = 0;
1654 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1655 wxCoord xoffset
, wxCoord yoffset
,
1658 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
1659 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
1660 wxCoord width
, wxCoord height
) = 0;
1662 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
1663 wxCoord
*w
, wxCoord
*h
) const
1670 *w
= m_clipX2
- m_clipX1
;
1672 *h
= m_clipY2
- m_clipY1
;
1675 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1677 if ( x
) *x
= m_logicalOriginX
;
1678 if ( y
) *y
= m_logicalOriginY
;
1681 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1683 if ( x
) *x
= m_deviceOriginX
;
1684 if ( y
) *y
= m_deviceOriginY
;
1687 virtual void DoGetTextExtent(const wxString
& string
,
1688 wxCoord
*x
, wxCoord
*y
,
1689 wxCoord
*descent
= NULL
,
1690 wxCoord
*externalLeading
= NULL
,
1691 const wxFont
*theFont
= NULL
) const = 0;
1693 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
1696 virtual void DoDrawSpline(wxList
*points
);
1700 // unset clipping variables (after clipping region was destroyed)
1701 void ResetClipping()
1705 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
1712 bool m_isInteractive
:1;
1713 bool m_isBBoxValid
:1;
1715 // coordinate system variables
1717 // TODO short descriptions of what exactly they are would be nice...
1719 wxCoord m_logicalOriginX
, m_logicalOriginY
;
1720 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
1722 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
1723 // is not at 0,0. This was the case under
1724 // Mac's GrafPorts (coordinate system
1725 // used toplevel window's origin) and
1726 // e.g. for Postscript, where the native
1727 // origin in the bottom left corner.
1728 double m_logicalScaleX
, m_logicalScaleY
;
1729 double m_userScaleX
, m_userScaleY
;
1730 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
1732 // Used by SetAxisOrientation() to invert the axes
1733 int m_signX
, m_signY
;
1735 // what is a mm on a screen you don't know the size of?
1736 double m_mm_to_pix_x
,
1739 // bounding and clipping boxes
1740 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
1741 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
1743 int m_logicalFunction
;
1744 int m_backgroundMode
;
1750 wxBrush m_backgroundBrush
;
1751 wxColour m_textForegroundColour
;
1752 wxColour m_textBackgroundColour
;
1756 wxPalette m_palette
;
1757 bool m_hasCustomPalette
;
1758 #endif // wxUSE_PALETTE
1761 DECLARE_NO_COPY_CLASS(wxDCBase
)
1762 DECLARE_ABSTRACT_CLASS(wxDCBase
)
1765 #endif // wxUSE_NEW_DC
1767 // ----------------------------------------------------------------------------
1768 // now include the declaration of wxDC class
1769 // ----------------------------------------------------------------------------
1771 #if defined(__WXPALMOS__)
1772 #include "wx/palmos/dc.h"
1773 #elif defined(__WXMSW__)
1774 #include "wx/msw/dc.h"
1775 #elif defined(__WXMOTIF__)
1776 #include "wx/motif/dc.h"
1777 #elif defined(__WXGTK20__)
1778 #include "wx/gtk/dc.h"
1779 #elif defined(__WXGTK__)
1780 #include "wx/gtk1/dc.h"
1781 #elif defined(__WXX11__)
1782 #include "wx/x11/dc.h"
1783 #elif defined(__WXMGL__)
1784 #include "wx/mgl/dc.h"
1785 #elif defined(__WXDFB__)
1786 #include "wx/dfb/dc.h"
1787 #elif defined(__WXMAC__)
1788 #include "wx/mac/dc.h"
1789 #elif defined(__WXCOCOA__)
1790 #include "wx/cocoa/dc.h"
1791 #elif defined(__WXPM__)
1792 #include "wx/os2/dc.h"
1795 #if wxUSE_GRAPHICS_CONTEXT
1796 #include "wx/dcgraph.h"
1799 // ----------------------------------------------------------------------------
1800 // helper class: you can use it to temporarily change the DC text colour and
1801 // restore it automatically when the object goes out of scope
1802 // ----------------------------------------------------------------------------
1804 class WXDLLEXPORT wxDCTextColourChanger
1807 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1809 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1814 ~wxDCTextColourChanger()
1816 if ( m_colFgOld
.Ok() )
1817 m_dc
.SetTextForeground(m_colFgOld
);
1820 void Set(const wxColour
& col
)
1822 if ( !m_colFgOld
.Ok() )
1823 m_colFgOld
= m_dc
.GetTextForeground();
1824 m_dc
.SetTextForeground(col
);
1830 wxColour m_colFgOld
;
1832 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
1835 // ----------------------------------------------------------------------------
1836 // helper class: you can use it to temporarily change the DC pen and
1837 // restore it automatically when the object goes out of scope
1838 // ----------------------------------------------------------------------------
1840 class WXDLLEXPORT wxDCPenChanger
1843 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1850 if ( m_penOld
.Ok() )
1851 m_dc
.SetPen(m_penOld
);
1859 DECLARE_NO_COPY_CLASS(wxDCPenChanger
)
1862 // ----------------------------------------------------------------------------
1863 // helper class: you can use it to temporarily change the DC brush and
1864 // restore it automatically when the object goes out of scope
1865 // ----------------------------------------------------------------------------
1867 class WXDLLEXPORT wxDCBrushChanger
1870 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1872 m_dc
.SetBrush(brush
);
1877 if ( m_brushOld
.Ok() )
1878 m_dc
.SetBrush(m_brushOld
);
1886 DECLARE_NO_COPY_CLASS(wxDCBrushChanger
)
1889 // ----------------------------------------------------------------------------
1890 // another small helper class: sets the clipping region in its ctor and
1891 // destroys it in the dtor
1892 // ----------------------------------------------------------------------------
1894 class WXDLLEXPORT wxDCClipper
1897 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1898 { dc
.SetClippingRegion(r
); }
1899 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1900 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1901 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1902 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1904 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1909 DECLARE_NO_COPY_CLASS(wxDCClipper
)
1912 #endif // _WX_DC_H_BASE_