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"
34 // 1 if using the reorganized DC code
35 #define wxUSE_NEW_DC 0
39 class WXDLLIMPEXP_FWD_CORE wxDC
;
41 class WXDLLIMPEXP_FWD_CORE wxDCBase
;
44 class WXDLLEXPORT wxDrawObject
49 : m_isBBoxValid(false)
50 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
53 virtual ~wxDrawObject() { }
56 virtual void Draw(wxDC
&) const { }
58 virtual void Draw(wxDCBase
&) const { }
61 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
65 if ( x
< m_minX
) m_minX
= x
;
66 if ( y
< m_minY
) m_minY
= y
;
67 if ( x
> m_maxX
) m_maxX
= x
;
68 if ( y
> m_maxY
) m_maxY
= y
;
81 void ResetBoundingBox()
83 m_isBBoxValid
= false;
85 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
88 // Get the final bounding box of the PostScript or Metafile picture.
90 wxCoord
MinX() const { return m_minX
; }
91 wxCoord
MaxX() const { return m_maxX
; }
92 wxCoord
MinY() const { return m_minY
; }
93 wxCoord
MaxY() const { return m_maxY
; }
95 //to define the type of object for derived objects
96 virtual int GetType()=0;
99 //for boundingbox calculation
100 bool m_isBBoxValid
:1;
101 //for boundingbox calculation
102 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
108 //-----------------------------------------------------------------------------
110 //-----------------------------------------------------------------------------
112 class WXDLLIMPEXP_FWD_CORE wxImplDC
;
114 class WXDLLIMPEXP_CORE wxDCFactory
118 virtual ~wxDCFactory() {}
120 virtual wxImplDC
* CreateWindowDC() = 0;
121 virtual wxImplDC
* CreateWindowDC( wxWindow
*window
) = 0;
122 virtual wxImplDC
* CreateClientDC() = 0;
123 virtual wxImplDC
* CreateClientDC( wxWindow
*window
) = 0;
124 virtual wxImplDC
* CreatePaintDC() = 0;
125 virtual wxImplDC
* CreatePaintDC( wxWindow
*window
) = 0;
126 virtual wxImplDC
* CreateMemoryDC() = 0;
127 virtual wxImplDC
* CreateMemoryDC( wxBitmap
&bitmap
) = 0;
128 virtual wxImplDC
* CreateMemoryDC( wxDC
*dc
) = 0;
130 static void SetDCFactory( wxDCFactory
*factory
);
131 static wxDCFactory
*GetFactory();
133 static wxDCFactory
*m_factory
;
136 //-----------------------------------------------------------------------------
138 //-----------------------------------------------------------------------------
140 class WXDLLIMPEXP_CORE wxNativeDCFactory
143 wxNativeDCFactory() {}
145 virtual wxImplDC
* CreateWindowDC();
146 virtual wxImplDC
* CreateWindowDC( wxWindow
*window
);
147 virtual wxImplDC
* CreateClientDC();
148 virtual wxImplDC
* CreateClientDC( wxWindow
*window
);
149 virtual wxImplDC
* CreatePaintDC();
150 virtual wxImplDC
* CreatePaintDC( wxWindow
*window
);
151 virtual wxImplDC
* CreateMemoryDC();
152 virtual wxImplDC
* CreateMemoryDC( wxBitmap
&bitmap
);
153 virtual wxImplDC
* CreateMemoryDC( wxDC
*dc
);
156 //-----------------------------------------------------------------------------
158 //-----------------------------------------------------------------------------
160 class WXDLLIMPEXP_CORE wxImplDC
: public wxObject
163 wxImplDC( wxDC
*owner
);
166 wxDC
*GetOwner() { return m_owner
; }
168 virtual bool IsOk() const { return m_ok
; }
170 // query capabilities
172 virtual bool CanDrawBitmap() const = 0;
173 virtual bool CanGetTextExtent() const = 0;
175 // query dimension, colour deps, resolution
177 virtual void DoGetSize(int *width
, int *height
) const = 0;
178 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
180 virtual int GetDepth() const = 0;
181 virtual wxSize
GetPPI() const = 0;
183 // Right-To-Left (RTL) modes
185 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
186 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
190 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
191 virtual void EndDoc() { }
193 virtual void StartPage() { }
194 virtual void EndPage() { }
198 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
202 if ( x
< m_minX
) m_minX
= x
;
203 if ( y
< m_minY
) m_minY
= y
;
204 if ( x
> m_maxX
) m_maxX
= x
;
205 if ( y
> m_maxY
) m_maxY
= y
;
209 m_isBBoxValid
= true;
217 void ResetBoundingBox()
219 m_isBBoxValid
= false;
221 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
224 wxCoord
MinX() const { return m_minX
; }
225 wxCoord
MaxX() const { return m_maxX
; }
226 wxCoord
MinY() const { return m_minY
; }
227 wxCoord
MaxY() const { return m_maxY
; }
229 // setters and getters
231 virtual void SetFont(const wxFont
& font
) = 0;
232 virtual const wxFont
& GetFont() const { return m_font
; }
234 virtual void SetPen(const wxPen
& pen
) = 0;
235 virtual const wxPen
& GetPen() const { return m_pen
; }
237 virtual void SetBrush(const wxBrush
& brush
) = 0;
238 virtual const wxBrush
& GetBrush() const { return m_brush
; }
240 virtual void SetBackground(const wxBrush
& brush
) = 0;
241 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
243 virtual void SetBackgroundMode(int mode
) = 0;
244 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
246 virtual void SetTextForeground(const wxColour
& colour
)
247 { m_textForegroundColour
= colour
; }
248 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
250 virtual void SetTextBackground(const wxColour
& colour
)
251 { m_textBackgroundColour
= colour
; }
252 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
255 virtual void SetPalette(const wxPalette
& palette
) = 0;
256 #endif // wxUSE_PALETTE
260 virtual void SetLogicalFunction(int function
) = 0;
261 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
265 virtual wxCoord
GetCharHeight() const = 0;
266 virtual wxCoord
GetCharWidth() const = 0;
267 virtual void DoGetTextExtent(const wxString
& string
,
268 wxCoord
*x
, wxCoord
*y
,
269 wxCoord
*descent
= NULL
,
270 wxCoord
*externalLeading
= NULL
,
271 const wxFont
*theFont
= NULL
) const = 0;
272 virtual void GetMultiLineTextExtent(const wxString
& string
,
275 wxCoord
*heightLine
= NULL
,
276 const wxFont
*font
= NULL
) const;
277 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
281 virtual void Clear() = 0;
285 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
286 wxCoord width
, wxCoord height
) = 0;
287 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
289 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
290 wxCoord
*w
, wxCoord
*h
) const
297 *w
= m_clipX2
- m_clipX1
;
299 *h
= m_clipY2
- m_clipY1
;
302 virtual void DestroyClippingRegion() { ResetClipping(); }
305 // coordinates conversions and transforms
307 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
308 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
309 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
310 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
311 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
312 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
313 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
314 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
316 virtual void SetMapMode(int mode
);
317 virtual int GetMapMode() const { return m_mappingMode
; }
319 virtual void SetUserScale(double x
, double y
);
320 virtual void GetUserScale(double *x
, double *y
) const
322 if ( x
) *x
= m_userScaleX
;
323 if ( y
) *y
= m_userScaleY
;
326 virtual void SetLogicalScale(double x
, double y
);
327 virtual void GetLogicalScale(double *x
, double *y
)
329 if ( x
) *x
= m_logicalScaleX
;
330 if ( y
) *y
= m_logicalScaleY
;
333 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
334 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
336 if ( x
) *x
= m_logicalOriginX
;
337 if ( y
) *y
= m_logicalOriginY
;
340 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
341 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
343 if ( x
) *x
= m_deviceOriginX
;
344 if ( y
) *y
= m_deviceOriginY
;
347 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
349 virtual void ComputeScaleAndOrigin();
351 // this needs to overidden if the axis is inverted
352 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
354 // ---------------------------------------------------------
355 // the actual drawing API
357 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
358 int style
= wxFLOOD_SURFACE
) = 0;
360 virtual void DoGradientFillLinear(const wxRect
& rect
,
361 const wxColour
& initialColour
,
362 const wxColour
& destColour
,
363 wxDirection nDirection
= wxEAST
);
365 virtual void DoGradientFillConcentric(const wxRect
& rect
,
366 const wxColour
& initialColour
,
367 const wxColour
& destColour
,
368 const wxPoint
& circleCenter
);
370 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
372 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
373 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
375 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
376 wxCoord x2
, wxCoord y2
,
377 wxCoord xc
, wxCoord yc
) = 0;
378 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
379 wxCoord width
, wxCoord height
);
380 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
381 double sa
, double ea
) = 0;
383 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
384 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
385 wxCoord width
, wxCoord height
,
387 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
388 wxCoord width
, wxCoord height
) = 0;
390 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
392 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
393 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
394 bool useMask
= false) = 0;
396 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
397 virtual void DoDrawRotatedText(const wxString
& text
,
398 wxCoord x
, wxCoord y
, double angle
) = 0;
400 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
401 wxCoord width
, wxCoord height
,
403 wxCoord xsrc
, wxCoord ysrc
,
405 bool useMask
= false,
406 wxCoord xsrcMask
= wxDefaultCoord
,
407 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
409 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
410 wxCoord dstWidth
, wxCoord dstHeight
,
412 wxCoord xsrc
, wxCoord ysrc
,
413 wxCoord srcWidth
, wxCoord srcHeight
,
415 bool useMask
= false,
416 wxCoord xsrcMask
= wxDefaultCoord
,
417 wxCoord ysrcMask
= wxDefaultCoord
);
419 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
420 { return wxNullBitmap
; }
423 virtual void DoDrawLines(int n
, wxPoint points
[],
424 wxCoord xoffset
, wxCoord yoffset
) = 0;
425 virtual void DoDrawPolygon(int n
, wxPoint points
[],
426 wxCoord xoffset
, wxCoord yoffset
,
427 int fillStyle
= wxODDEVEN_RULE
) = 0;
428 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
429 wxCoord xoffset
, wxCoord yoffset
,
435 virtual void DoDrawSpline(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
, wxCoord x3
, wxCoord y3
);
436 virtual void DoDrawSpline(int n
, wxPoint points
[]);
437 virtual void DoDrawSpline(wxList
*points
);
444 // unset clipping variables (after clipping region was destroyed)
449 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
456 bool m_isInteractive
:1;
457 bool m_isBBoxValid
:1;
459 // coordinate system variables
461 wxCoord m_logicalOriginX
, m_logicalOriginY
;
462 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
464 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
465 // is not at 0,0. This was the case under
466 // Mac's GrafPorts (coordinate system
467 // used toplevel window's origin) and
468 // e.g. for Postscript, where the native
469 // origin in the bottom left corner.
470 double m_logicalScaleX
, m_logicalScaleY
;
471 double m_userScaleX
, m_userScaleY
;
472 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
474 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
476 // what is a mm on a screen you don't know the size of?
477 double m_mm_to_pix_x
,
480 // bounding and clipping boxes
481 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
482 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
484 int m_logicalFunction
;
485 int m_backgroundMode
;
490 wxBrush m_backgroundBrush
;
491 wxColour m_textForegroundColour
;
492 wxColour m_textBackgroundColour
;
497 bool m_hasCustomPalette
;
498 #endif // wxUSE_PALETTE
501 DECLARE_ABSTRACT_CLASS(wxImplDC
)
505 class wxDC
: public wxObject
508 wxDC() { m_pimpl
= NULL
; }
511 { return m_pimpl
&& m_pimpl
->IsOk(); }
513 // query capabilities
515 bool CanDrawBitmap() const
516 { return m_pimpl
->CanDrawBitmap(); }
517 bool CanGetTextExtent() const
518 { return m_pimpl
->CanGetTextExtent(); }
520 // query dimension, colour deps, resolution
522 void GetSize(int *width
, int *height
) const
523 { m_pimpl
->DoGetSize(width
, height
); }
525 wxSize
GetSize() const
528 m_pimpl
->DoGetSize(&w
, &h
);
532 void GetSizeMM(int* width
, int* height
) const
533 { m_pimpl
->DoGetSizeMM(width
, height
); }
534 wxSize
GetSizeMM() const
537 m_pimpl
->DoGetSizeMM(&w
, &h
);
542 { return m_pimpl
->GetDepth(); }
543 wxSize
GetPPI() const
544 { return m_pimpl
->GetPPI(); }
546 // Right-To-Left (RTL) modes
548 void SetLayoutDirection(wxLayoutDirection dir
)
549 { m_pimpl
->SetLayoutDirection( dir
); }
550 wxLayoutDirection
GetLayoutDirection() const
551 { return m_pimpl
->GetLayoutDirection(); }
555 bool StartDoc(const wxString
& message
)
556 { return m_pimpl
->StartDoc(message
); }
558 { m_pimpl
->EndDoc(); }
561 { m_pimpl
->StartPage(); }
563 { m_pimpl
->EndPage(); }
567 void CalcBoundingBox(wxCoord x
, wxCoord y
)
568 { m_pimpl
->CalcBoundingBox(x
,y
); }
569 void ResetBoundingBox()
570 { m_pimpl
->ResetBoundingBox(); }
573 { return m_pimpl
->MinX(); }
575 { return m_pimpl
->MaxX(); }
577 { return m_pimpl
->MinY(); }
579 { return m_pimpl
->MaxY(); }
581 // setters and getters
583 void SetFont(const wxFont
& font
)
584 { m_pimpl
->SetFont( font
); }
585 const wxFont
& GetFont() const
586 { return m_pimpl
->GetFont(); }
588 void SetPen(const wxPen
& pen
)
589 { m_pimpl
->SetPen( pen
); }
590 const wxPen
& GetPen() const
591 { return m_pimpl
->GetPen(); }
593 void SetBrush(const wxBrush
& brush
)
594 { m_pimpl
->SetBrush( brush
); }
595 const wxBrush
& GetBrush() const
596 { return m_pimpl
->GetBrush(); }
598 void SetBackground(const wxBrush
& brush
)
599 { m_pimpl
->SetBackground( brush
); }
600 const wxBrush
& GetBackground() const
601 { return m_pimpl
->GetBackground(); }
603 void SetBackgroundMode(int mode
)
604 { m_pimpl
->SetBackgroundMode( mode
); }
605 int GetBackgroundMode() const
606 { return m_pimpl
->GetBackgroundMode(); }
608 void SetTextForeground(const wxColour
& colour
)
609 { m_pimpl
->SetTextForeground(colour
); }
610 const wxColour
& GetTextForeground() const
611 { return m_pimpl
->GetTextForeground(); }
613 void SetTextBackground(const wxColour
& colour
)
614 { m_pimpl
->SetTextBackground(colour
); }
615 const wxColour
& GetTextBackground() const
616 { return m_pimpl
->GetTextBackground(); }
619 void SetPalette(const wxPalette
& palette
)
620 { m_pimpl
->SetPalette(palette
); }
621 #endif // wxUSE_PALETTE
625 void SetLogicalFunction(int function
)
626 { m_pimpl
->SetLogicalFunction(function
); }
627 int GetLogicalFunction() const
628 { return m_pimpl
->GetLogicalFunction(); }
632 wxCoord
GetCharHeight() const
633 { return m_pimpl
->GetCharHeight(); }
634 wxCoord
GetCharWidth() const
635 { return m_pimpl
->GetCharWidth(); }
637 void GetTextExtent(const wxString
& string
,
638 wxCoord
*x
, wxCoord
*y
,
639 wxCoord
*descent
= NULL
,
640 wxCoord
*externalLeading
= NULL
,
641 const wxFont
*theFont
= NULL
) const
642 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
644 wxSize
GetTextExtent(const wxString
& string
) const
647 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
651 void GetMultiLineTextExtent(const wxString
& string
,
654 wxCoord
*heightLine
= NULL
,
655 const wxFont
*font
= NULL
) const
656 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
658 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
661 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
665 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
666 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
671 { m_pimpl
->Clear(); }
675 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
676 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
677 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
678 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
679 void SetClippingRegion(const wxRect
& rect
)
680 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
681 void SetClippingRegion(const wxRegion
& region
)
682 { m_pimpl
->DoSetClippingRegionAsRegion(region
); }
684 void DestroyClippingRegion()
685 { m_pimpl
->DestroyClippingRegion(); }
687 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
688 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
689 void GetClippingBox(wxRect
& rect
) const
690 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
692 // coordinates conversions and transforms
694 wxCoord
DeviceToLogicalX(wxCoord x
) const
695 { return m_pimpl
->DeviceToLogicalX(x
); }
696 wxCoord
DeviceToLogicalY(wxCoord y
) const
697 { return m_pimpl
->DeviceToLogicalY(y
); }
698 wxCoord
DeviceToLogicalXRel(wxCoord x
) const
699 { return m_pimpl
->DeviceToLogicalXRel(x
); }
700 wxCoord
DeviceToLogicalYRel(wxCoord y
) const
701 { return m_pimpl
->DeviceToLogicalYRel(y
); }
702 wxCoord
LogicalToDeviceX(wxCoord x
) const
703 { return m_pimpl
->LogicalToDeviceX(x
); }
704 wxCoord
LogicalToDeviceY(wxCoord y
) const
705 { return m_pimpl
->LogicalToDeviceY(y
); }
706 wxCoord
LogicalToDeviceXRel(wxCoord x
) const
707 { return m_pimpl
->LogicalToDeviceXRel(x
); }
708 wxCoord
LogicalToDeviceYRel(wxCoord y
) const
709 { return m_pimpl
->LogicalToDeviceYRel(y
); }
711 void SetMapMode(int mode
)
712 { m_pimpl
->SetMapMode(mode
); }
713 int GetMapMode() const
714 { return m_pimpl
->GetMapMode(); }
716 void SetUserScale(double x
, double y
)
717 { m_pimpl
->SetUserScale(x
,y
); }
718 void GetUserScale(double *x
, double *y
) const
719 { m_pimpl
->GetUserScale( x
, y
); }
721 void SetLogicalScale(double x
, double y
)
722 { m_pimpl
->SetLogicalScale( x
, y
); }
723 void GetLogicalScale(double *x
, double *y
)
724 { m_pimpl
->GetLogicalScale( x
, y
); }
726 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
727 { m_pimpl
->SetLogicalOrigin(x
,y
); }
728 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
729 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
730 wxPoint
GetLogicalOrigin() const
731 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
733 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
734 { m_pimpl
->SetDeviceOrigin( x
, y
); }
735 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
736 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
737 wxPoint
GetDeviceOrigin() const
738 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
740 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
741 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
744 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
745 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
748 // draw generic object
750 void DrawObject(wxDrawObject
* drawobject
)
752 drawobject
->Draw(*this);
753 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
754 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
757 // -----------------------------------------------
758 // the actual drawing API
760 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
761 int style
= wxFLOOD_SURFACE
)
762 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
763 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
764 int style
= wxFLOOD_SURFACE
)
765 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
767 // fill the area specified by rect with a radial gradient, starting from
768 // initialColour in the centre of the cercle and fading to destColour.
769 void GradientFillConcentric(const wxRect
& rect
,
770 const wxColour
& initialColour
,
771 const wxColour
& destColour
)
772 { m_pimpl
->DoGradientFillConcentric( rect
, initialColour
, destColour
,
773 wxPoint(rect
.GetWidth() / 2,
774 rect
.GetHeight() / 2)); }
776 void GradientFillConcentric(const wxRect
& rect
,
777 const wxColour
& initialColour
,
778 const wxColour
& destColour
,
779 const wxPoint
& circleCenter
)
780 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
782 // fill the area specified by rect with a linear gradient
783 void GradientFillLinear(const wxRect
& rect
,
784 const wxColour
& initialColour
,
785 const wxColour
& destColour
,
786 wxDirection nDirection
= wxEAST
)
787 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
789 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
790 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
791 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
792 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
794 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
795 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
796 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
797 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
799 void CrossHair(wxCoord x
, wxCoord y
)
800 { m_pimpl
->DoCrossHair(x
, y
); }
801 void CrossHair(const wxPoint
& pt
)
802 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
804 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
805 wxCoord xc
, wxCoord yc
)
806 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
807 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
808 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
810 void DrawCheckMark(wxCoord x
, wxCoord y
,
811 wxCoord width
, wxCoord height
)
812 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
813 void DrawCheckMark(const wxRect
& rect
)
814 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
816 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
817 double sa
, double ea
)
818 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
819 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
820 double sa
, double ea
)
821 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
823 void DrawPoint(wxCoord x
, wxCoord y
)
824 { m_pimpl
->DoDrawPoint(x
, y
); }
825 void DrawPoint(const wxPoint
& pt
)
826 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
828 void DrawLines(int n
, wxPoint points
[],
829 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
830 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
833 // needs to be removed
834 void DrawLines(const wxList
*list
,
835 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
838 void DrawPolygon(int n
, wxPoint points
[],
839 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
840 int fillStyle
= wxODDEVEN_RULE
)
841 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
844 // needs to be removed
845 void DrawPolygon(const wxList
*list
,
846 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
847 int fillStyle
= wxODDEVEN_RULE
)
848 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
851 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
852 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
853 int fillStyle
= wxODDEVEN_RULE
)
854 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
856 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
857 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
858 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
859 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
860 void DrawRectangle(const wxRect
& rect
)
861 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
863 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
865 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
866 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
868 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
869 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
870 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
872 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
873 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
874 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
875 { m_pimpl
->DoDrawEllipse(pt
.x
- radius
, pt
.y
- radius
, 2*radius
, 2*radius
); }
877 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
878 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
879 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
880 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
881 void DrawEllipse(const wxRect
& rect
)
882 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
884 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
885 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
886 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
887 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
889 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
890 bool useMask
= false)
891 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
892 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
893 bool useMask
= false)
894 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
896 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
897 { m_pimpl
->DoDrawText(text
, x
, y
); }
898 void DrawText(const wxString
& text
, const wxPoint
& pt
)
899 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
901 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
902 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
903 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
904 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
906 // this version puts both optional bitmap and the text into the given
907 // rectangle and aligns is as specified by alignment parameter; it also
908 // will emphasize the character with the given index if it is != -1 and
909 // return the bounding rectangle if required
910 void DrawLabel(const wxString
& text
,
911 const wxBitmap
& image
,
913 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
915 wxRect
*rectBounding
= NULL
);
917 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
918 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
920 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
922 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
923 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
924 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
926 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
927 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
929 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
930 wxDC
*source
, const wxPoint
& srcPt
,
931 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
933 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
934 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
937 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
938 wxCoord dstWidth
, wxCoord dstHeight
,
940 wxCoord srcX
, wxCoord srcY
,
941 wxCoord srcWidth
, wxCoord srcHeight
,
942 int rop
= wxCOPY
, bool useMask
= false,
943 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
945 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
946 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
948 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
949 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
950 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
952 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
953 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
956 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
958 return m_pimpl
->DoGetAsBitmap(subrect
);
962 void DrawSpline(wxCoord x1
, wxCoord y1
,
963 wxCoord x2
, wxCoord y2
,
964 wxCoord x3
, wxCoord y3
)
965 { m_pimpl
->DoDrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
966 void DrawSpline(int n
, wxPoint points
[])
967 { m_pimpl
->DoDrawSpline(n
,points
); }
970 // needs to be removed
971 void DrawSpline(wxList
*points
)
972 { m_pimpl
->DoDrawSpline(points
); }
974 #endif // wxUSE_SPLINES
977 #if WXWIN_COMPATIBILITY_2_8
978 // for compatibility with the old code when wxCoord was long everywhere
979 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
981 long *descent
= NULL
,
982 long *externalLeading
= NULL
,
983 const wxFont
*theFont
= NULL
) const );
984 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
985 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
986 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
987 #endif // WXWIN_COMPATIBILITY_2_8
994 DECLARE_ABSTRACT_CLASS(wxImplDC
)
998 //-----------------------------------------------------------------------------
1000 //-----------------------------------------------------------------------------
1002 class WXDLLIMPEXP_CORE wxWindowDC
: public wxDC
1006 wxWindowDC( wxWindow
*win
);
1009 DECLARE_DYNAMIC_CLASS(wxWindowDC
)
1012 //-----------------------------------------------------------------------------
1014 //-----------------------------------------------------------------------------
1016 class WXDLLIMPEXP_CORE wxClientDC
: public wxDC
1020 wxClientDC( wxWindow
*win
);
1023 DECLARE_DYNAMIC_CLASS(wxClientDC
)
1026 //-----------------------------------------------------------------------------
1028 //-----------------------------------------------------------------------------
1030 class WXDLLIMPEXP_CORE wxMemoryDC
: public wxDC
1034 wxMemoryDC( wxBitmap
& bitmap
);
1035 wxMemoryDC( wxDC
*dc
);
1038 DECLARE_DYNAMIC_CLASS(wxMemoryDC
)
1041 //-----------------------------------------------------------------------------
1043 //-----------------------------------------------------------------------------
1045 class WXDLLIMPEXP_CORE wxPaintDC
: public wxDC
1049 wxPaintDC( wxWindow
*win
);
1052 DECLARE_DYNAMIC_CLASS(wxPaintDC
)
1055 #else // wxUSE_NEW_DC
1058 class WXDLLIMPEXP_FWD_CORE wxDC
;
1060 // ---------------------------------------------------------------------------
1062 // ---------------------------------------------------------------------------
1064 // ---------------------------------------------------------------------------
1065 // wxDC is the device context - object on which any drawing is done
1066 // ---------------------------------------------------------------------------
1068 class WXDLLEXPORT wxDCBase
: public wxObject
1072 virtual ~wxDCBase();
1074 // graphic primitives
1075 // ------------------
1077 virtual void DrawObject(wxDrawObject
* drawobject
)
1079 drawobject
->Draw(*this);
1080 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
1081 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
1084 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1085 int style
= wxFLOOD_SURFACE
)
1086 { return DoFloodFill(x
, y
, col
, style
); }
1087 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
1088 int style
= wxFLOOD_SURFACE
)
1089 { return DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
1091 // fill the area specified by rect with a radial gradient, starting from
1092 // initialColour in the centre of the cercle and fading to destColour.
1093 void GradientFillConcentric(const wxRect
& rect
,
1094 const wxColour
& initialColour
,
1095 const wxColour
& destColour
)
1096 { GradientFillConcentric(rect
, initialColour
, destColour
,
1097 wxPoint(rect
.GetWidth() / 2,
1098 rect
.GetHeight() / 2)); }
1100 void GradientFillConcentric(const wxRect
& rect
,
1101 const wxColour
& initialColour
,
1102 const wxColour
& destColour
,
1103 const wxPoint
& circleCenter
)
1104 { DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
1106 // fill the area specified by rect with a linear gradient
1107 void GradientFillLinear(const wxRect
& rect
,
1108 const wxColour
& initialColour
,
1109 const wxColour
& destColour
,
1110 wxDirection nDirection
= wxEAST
)
1111 { DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
1113 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
1114 { return DoGetPixel(x
, y
, col
); }
1115 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
1116 { return DoGetPixel(pt
.x
, pt
.y
, col
); }
1118 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1119 { DoDrawLine(x1
, y1
, x2
, y2
); }
1120 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
1121 { DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
1123 void CrossHair(wxCoord x
, wxCoord y
)
1124 { DoCrossHair(x
, y
); }
1125 void CrossHair(const wxPoint
& pt
)
1126 { DoCrossHair(pt
.x
, pt
.y
); }
1128 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
1129 wxCoord xc
, wxCoord yc
)
1130 { DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
1131 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
1132 { DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
1134 void DrawCheckMark(wxCoord x
, wxCoord y
,
1135 wxCoord width
, wxCoord height
)
1136 { DoDrawCheckMark(x
, y
, width
, height
); }
1137 void DrawCheckMark(const wxRect
& rect
)
1138 { DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1140 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1141 double sa
, double ea
)
1142 { DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
1143 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
1144 double sa
, double ea
)
1145 { DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
1147 void DrawPoint(wxCoord x
, wxCoord y
)
1148 { DoDrawPoint(x
, y
); }
1149 void DrawPoint(const wxPoint
& pt
)
1150 { DoDrawPoint(pt
.x
, pt
.y
); }
1152 void DrawLines(int n
, wxPoint points
[],
1153 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1154 { DoDrawLines(n
, points
, xoffset
, yoffset
); }
1155 void DrawLines(const wxList
*list
,
1156 wxCoord xoffset
= 0, wxCoord yoffset
= 0);
1158 void DrawPolygon(int n
, wxPoint points
[],
1159 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1160 int fillStyle
= wxODDEVEN_RULE
)
1161 { DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
1163 void DrawPolygon(const wxList
*list
,
1164 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1165 int fillStyle
= wxODDEVEN_RULE
);
1167 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1168 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1169 int fillStyle
= wxODDEVEN_RULE
)
1170 { DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
1172 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1173 { DoDrawRectangle(x
, y
, width
, height
); }
1174 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
1175 { DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1176 void DrawRectangle(const wxRect
& rect
)
1177 { DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1179 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
1181 { DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
1182 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
1184 { DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
1185 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
1186 { DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1188 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1189 { DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1190 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1191 { DrawCircle(pt
.x
, pt
.y
, radius
); }
1193 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1194 { DoDrawEllipse(x
, y
, width
, height
); }
1195 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1196 { DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1197 void DrawEllipse(const wxRect
& rect
)
1198 { DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1200 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1201 { DoDrawIcon(icon
, x
, y
); }
1202 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1203 { DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1205 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1206 bool useMask
= false)
1207 { DoDrawBitmap(bmp
, x
, y
, useMask
); }
1208 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1209 bool useMask
= false)
1210 { DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1212 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1213 { DoDrawText(text
, x
, y
); }
1214 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1215 { DoDrawText(text
, pt
.x
, pt
.y
); }
1217 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1218 { DoDrawRotatedText(text
, x
, y
, angle
); }
1219 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1220 { DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1222 // this version puts both optional bitmap and the text into the given
1223 // rectangle and aligns is as specified by alignment parameter; it also
1224 // will emphasize the character with the given index if it is != -1 and
1225 // return the bounding rectangle if required
1226 virtual void DrawLabel(const wxString
& text
,
1227 const wxBitmap
& image
,
1229 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1230 int indexAccel
= -1,
1231 wxRect
*rectBounding
= NULL
);
1233 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1234 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1235 int indexAccel
= -1)
1236 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1238 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1239 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1240 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1242 return DoBlit(xdest
, ydest
, width
, height
,
1243 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1245 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1246 wxDC
*source
, const wxPoint
& srcPt
,
1247 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
1249 return DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1250 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1253 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1254 wxCoord dstWidth
, wxCoord dstHeight
,
1256 wxCoord srcX
, wxCoord srcY
,
1257 wxCoord srcWidth
, wxCoord srcHeight
,
1258 int rop
= wxCOPY
, bool useMask
= false,
1259 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1261 return DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1262 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1264 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1265 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1266 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1268 return DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1269 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1272 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1274 return DoGetAsBitmap(subrect
);
1278 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
1279 void DrawSpline(wxCoord x1
, wxCoord y1
,
1280 wxCoord x2
, wxCoord y2
,
1281 wxCoord x3
, wxCoord y3
);
1282 void DrawSpline(int n
, wxPoint points
[]);
1284 void DrawSpline(wxList
*points
) { DoDrawSpline(points
); }
1285 #endif // wxUSE_SPLINES
1287 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
1289 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
1290 /*! \param x Upper left corner of bounding box.
1291 * \param y Upper left corner of bounding box.
1292 * \param w Width of bounding box.
1293 * \param h Height of bounding box.
1294 * \param sa Starting angle of arc
1295 * (counterclockwise, start at 3 o'clock, 360 is full circle).
1296 * \param ea Ending angle of arc.
1297 * \param angle Rotation angle, the Arc will be rotated after
1298 * calculating begin and end.
1300 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
1301 wxCoord width
, wxCoord height
,
1302 double sa
= 0, double ea
= 0, double angle
= 0 )
1303 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
1305 void DrawEllipticArcRot( const wxPoint
& pt
,
1307 double sa
= 0, double ea
= 0, double angle
= 0 )
1308 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
1310 void DrawEllipticArcRot( const wxRect
& rect
,
1311 double sa
= 0, double ea
= 0, double angle
= 0 )
1312 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
1314 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
1315 wxCoord w
, wxCoord h
,
1316 double sa
= 0, double ea
= 0, double angle
= 0 );
1318 //! Rotates points around center.
1319 /*! This is a quite straight method, it calculates in pixels
1320 * and so it produces rounding errors.
1321 * \param points The points inside will be rotated.
1322 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
1323 * \param center Center of rotation.
1325 void Rotate( wxList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
1327 // used by DrawEllipticArcRot
1328 // Careful: wxList gets filled with points you have to delete later.
1329 void CalculateEllipticPoints( wxList
* points
,
1330 wxCoord xStart
, wxCoord yStart
,
1331 wxCoord w
, wxCoord h
,
1332 double sa
, double ea
);
1335 // global DC operations
1336 // --------------------
1338 virtual void Clear() = 0;
1340 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
1341 virtual void EndDoc() { }
1343 virtual void StartPage() { }
1344 virtual void EndPage() { }
1346 #if WXWIN_COMPATIBILITY_2_6
1347 wxDEPRECATED( void BeginDrawing() );
1348 wxDEPRECATED( void EndDrawing() );
1349 #endif // WXWIN_COMPATIBILITY_2_6
1352 // set objects to use for drawing
1353 // ------------------------------
1355 virtual void SetFont(const wxFont
& font
) = 0;
1356 virtual void SetPen(const wxPen
& pen
) = 0;
1357 virtual void SetBrush(const wxBrush
& brush
) = 0;
1358 virtual void SetBackground(const wxBrush
& brush
) = 0;
1359 virtual void SetBackgroundMode(int mode
) = 0;
1361 virtual void SetPalette(const wxPalette
& palette
) = 0;
1362 #endif // wxUSE_PALETTE
1367 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1368 { DoSetClippingRegion(x
, y
, width
, height
); }
1369 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
1370 { DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1371 void SetClippingRegion(const wxRect
& rect
)
1372 { DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1373 void SetClippingRegion(const wxRegion
& region
)
1374 { DoSetClippingRegionAsRegion(region
); }
1376 virtual void DestroyClippingRegion() { ResetClipping(); }
1378 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
1379 { DoGetClippingBox(x
, y
, w
, h
); }
1380 void GetClippingBox(wxRect
& rect
) const
1382 DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
);
1388 virtual wxCoord
GetCharHeight() const = 0;
1389 virtual wxCoord
GetCharWidth() const = 0;
1391 // only works for single line strings
1392 void GetTextExtent(const wxString
& string
,
1393 wxCoord
*x
, wxCoord
*y
,
1394 wxCoord
*descent
= NULL
,
1395 wxCoord
*externalLeading
= NULL
,
1396 const wxFont
*theFont
= NULL
) const
1397 { DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
1399 wxSize
GetTextExtent(const wxString
& string
) const
1402 DoGetTextExtent(string
, &w
, &h
);
1403 return wxSize(w
, h
);
1406 // works for single as well as multi-line strings
1407 virtual void GetMultiLineTextExtent(const wxString
& string
,
1410 wxCoord
*heightLine
= NULL
,
1411 const wxFont
*font
= NULL
) const;
1413 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
1416 GetMultiLineTextExtent(string
, &w
, &h
);
1417 return wxSize(w
, h
);
1420 // Measure cumulative width of text after each character
1421 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1422 { return DoGetPartialTextExtents(text
, widths
); }
1425 // size and resolution
1426 // -------------------
1429 void GetSize(int *width
, int *height
) const
1430 { DoGetSize(width
, height
); }
1431 wxSize
GetSize() const
1436 return wxSize(w
, h
);
1440 void GetSizeMM(int* width
, int* height
) const
1441 { DoGetSizeMM(width
, height
); }
1442 wxSize
GetSizeMM() const
1445 DoGetSizeMM(&w
, &h
);
1447 return wxSize(w
, h
);
1450 // query DC capabilities
1451 // ---------------------
1453 virtual bool CanDrawBitmap() const = 0;
1454 virtual bool CanGetTextExtent() const = 0;
1457 virtual int GetDepth() const = 0;
1459 // Resolution in Pixels per inch
1460 virtual wxSize
GetPPI() const = 0;
1462 virtual bool Ok() const { return IsOk(); }
1463 virtual bool IsOk() const { return m_ok
; }
1465 // accessors and setters
1466 // ---------------------
1468 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
1469 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
1470 virtual const wxBrush
& GetBrush() const { return m_brush
; }
1471 virtual const wxFont
& GetFont() const { return m_font
; }
1472 virtual const wxPen
& GetPen() const { return m_pen
; }
1474 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
1475 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
1476 virtual void SetTextForeground(const wxColour
& colour
)
1477 { m_textForegroundColour
= colour
; }
1478 virtual void SetTextBackground(const wxColour
& colour
)
1479 { m_textBackgroundColour
= colour
; }
1482 // coordinates conversions and transforms
1483 // --------------------------------------
1485 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
1486 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
1487 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
1488 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
1489 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
1490 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
1491 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
1492 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
1494 virtual void SetMapMode(int mode
);
1495 virtual int GetMapMode() const { return m_mappingMode
; }
1497 virtual void SetUserScale(double x
, double y
);
1498 virtual void GetUserScale(double *x
, double *y
) const
1500 if ( x
) *x
= m_userScaleX
;
1501 if ( y
) *y
= m_userScaleY
;
1504 virtual void SetLogicalScale(double x
, double y
);
1505 virtual void GetLogicalScale(double *x
, double *y
)
1507 if ( x
) *x
= m_logicalScaleX
;
1508 if ( y
) *y
= m_logicalScaleY
;
1511 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
1512 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1513 { DoGetLogicalOrigin(x
, y
); }
1514 wxPoint
GetLogicalOrigin() const
1515 { wxCoord x
, y
; DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
1517 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
1518 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1519 { DoGetDeviceOrigin(x
, y
); }
1520 wxPoint
GetDeviceOrigin() const
1521 { wxCoord x
, y
; DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
1523 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
1525 virtual void ComputeScaleAndOrigin();
1527 // this needs to overidden if the axis is inverted (such
1528 // as when using Postscript, where 0,0 is the lower left
1529 // corner, not the upper left).
1530 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
1532 // logical functions
1533 // ---------------------------
1535 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
1536 virtual void SetLogicalFunction(int function
) = 0;
1541 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
1543 if ( m_isBBoxValid
)
1545 if ( x
< m_minX
) m_minX
= x
;
1546 if ( y
< m_minY
) m_minY
= y
;
1547 if ( x
> m_maxX
) m_maxX
= x
;
1548 if ( y
> m_maxY
) m_maxY
= y
;
1552 m_isBBoxValid
= true;
1561 void ResetBoundingBox()
1563 m_isBBoxValid
= false;
1565 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
1568 // Get the final bounding box of the PostScript or Metafile picture.
1569 wxCoord
MinX() const { return m_minX
; }
1570 wxCoord
MaxX() const { return m_maxX
; }
1571 wxCoord
MinY() const { return m_minY
; }
1572 wxCoord
MaxY() const { return m_maxY
; }
1574 // misc old functions
1575 // ------------------
1577 #if WXWIN_COMPATIBILITY_2_8
1578 // for compatibility with the old code when wxCoord was long everywhere
1579 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1581 long *descent
= NULL
,
1582 long *externalLeading
= NULL
,
1583 const wxFont
*theFont
= NULL
) const );
1584 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1585 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1586 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1587 #endif // WXWIN_COMPATIBILITY_2_8
1589 // RTL related functions
1590 // ---------------------
1592 // get or change the layout direction (LTR or RTL) for this dc,
1593 // wxLayout_Default is returned if layout direction is not supported
1594 virtual wxLayoutDirection
GetLayoutDirection() const
1595 { return wxLayout_Default
; }
1596 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
))
1600 // the pure virtual functions which should be implemented by wxDC
1601 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1602 int style
= wxFLOOD_SURFACE
) = 0;
1604 virtual void DoGradientFillLinear(const wxRect
& rect
,
1605 const wxColour
& initialColour
,
1606 const wxColour
& destColour
,
1607 wxDirection nDirection
= wxEAST
);
1609 virtual void DoGradientFillConcentric(const wxRect
& rect
,
1610 const wxColour
& initialColour
,
1611 const wxColour
& destColour
,
1612 const wxPoint
& circleCenter
);
1614 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
1616 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
1617 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
1619 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
1620 wxCoord x2
, wxCoord y2
,
1621 wxCoord xc
, wxCoord yc
) = 0;
1622 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
1623 wxCoord width
, wxCoord height
);
1624 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1625 double sa
, double ea
) = 0;
1627 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
1628 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1629 wxCoord width
, wxCoord height
,
1631 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
1632 wxCoord width
, wxCoord height
) = 0;
1634 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
1636 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
1637 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1638 bool useMask
= false) = 0;
1640 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
1641 virtual void DoDrawRotatedText(const wxString
& text
,
1642 wxCoord x
, wxCoord y
, double angle
) = 0;
1644 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
1645 wxCoord width
, wxCoord height
,
1647 wxCoord xsrc
, wxCoord ysrc
,
1649 bool useMask
= false,
1650 wxCoord xsrcMask
= wxDefaultCoord
,
1651 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
1653 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
1654 wxCoord dstWidth
, wxCoord dstHeight
,
1656 wxCoord xsrc
, wxCoord ysrc
,
1657 wxCoord srcWidth
, wxCoord srcHeight
,
1659 bool useMask
= false,
1660 wxCoord xsrcMask
= wxDefaultCoord
,
1661 wxCoord ysrcMask
= wxDefaultCoord
);
1663 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
1664 { return wxNullBitmap
; }
1666 virtual void DoGetSize(int *width
, int *height
) const = 0;
1667 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
1669 virtual void DoDrawLines(int n
, wxPoint points
[],
1670 wxCoord xoffset
, wxCoord yoffset
) = 0;
1671 virtual void DoDrawPolygon(int n
, wxPoint points
[],
1672 wxCoord xoffset
, wxCoord yoffset
,
1673 int fillStyle
= wxODDEVEN_RULE
) = 0;
1674 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1675 wxCoord xoffset
, wxCoord yoffset
,
1678 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
1679 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
1680 wxCoord width
, wxCoord height
) = 0;
1682 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
1683 wxCoord
*w
, wxCoord
*h
) const
1690 *w
= m_clipX2
- m_clipX1
;
1692 *h
= m_clipY2
- m_clipY1
;
1695 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1697 if ( x
) *x
= m_logicalOriginX
;
1698 if ( y
) *y
= m_logicalOriginY
;
1701 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1703 if ( x
) *x
= m_deviceOriginX
;
1704 if ( y
) *y
= m_deviceOriginY
;
1707 virtual void DoGetTextExtent(const wxString
& string
,
1708 wxCoord
*x
, wxCoord
*y
,
1709 wxCoord
*descent
= NULL
,
1710 wxCoord
*externalLeading
= NULL
,
1711 const wxFont
*theFont
= NULL
) const = 0;
1713 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
1716 virtual void DoDrawSpline(wxList
*points
);
1720 // unset clipping variables (after clipping region was destroyed)
1721 void ResetClipping()
1725 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
1732 bool m_isInteractive
:1;
1733 bool m_isBBoxValid
:1;
1735 // coordinate system variables
1737 // TODO short descriptions of what exactly they are would be nice...
1739 wxCoord m_logicalOriginX
, m_logicalOriginY
;
1740 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
1742 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
1743 // is not at 0,0. This was the case under
1744 // Mac's GrafPorts (coordinate system
1745 // used toplevel window's origin) and
1746 // e.g. for Postscript, where the native
1747 // origin in the bottom left corner.
1748 double m_logicalScaleX
, m_logicalScaleY
;
1749 double m_userScaleX
, m_userScaleY
;
1750 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
1752 // Used by SetAxisOrientation() to invert the axes
1753 int m_signX
, m_signY
;
1755 // what is a mm on a screen you don't know the size of?
1756 double m_mm_to_pix_x
,
1759 // bounding and clipping boxes
1760 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
1761 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
1763 int m_logicalFunction
;
1764 int m_backgroundMode
;
1770 wxBrush m_backgroundBrush
;
1771 wxColour m_textForegroundColour
;
1772 wxColour m_textBackgroundColour
;
1776 wxPalette m_palette
;
1777 bool m_hasCustomPalette
;
1778 #endif // wxUSE_PALETTE
1781 DECLARE_NO_COPY_CLASS(wxDCBase
)
1782 DECLARE_ABSTRACT_CLASS(wxDCBase
)
1785 #endif // wxUSE_NEW_DC
1787 // ----------------------------------------------------------------------------
1788 // now include the declaration of wxDC class
1789 // ----------------------------------------------------------------------------
1791 #if defined(__WXPALMOS__)
1792 #include "wx/palmos/dc.h"
1793 #elif defined(__WXMSW__)
1794 #include "wx/msw/dc.h"
1795 #elif defined(__WXMOTIF__)
1796 #include "wx/motif/dc.h"
1797 #elif defined(__WXGTK20__)
1798 #include "wx/gtk/dc.h"
1799 #elif defined(__WXGTK__)
1800 #include "wx/gtk1/dc.h"
1801 #elif defined(__WXX11__)
1802 #include "wx/x11/dc.h"
1803 #elif defined(__WXMGL__)
1804 #include "wx/mgl/dc.h"
1805 #elif defined(__WXDFB__)
1806 #include "wx/dfb/dc.h"
1807 #elif defined(__WXMAC__)
1808 #include "wx/mac/dc.h"
1809 #elif defined(__WXCOCOA__)
1810 #include "wx/cocoa/dc.h"
1811 #elif defined(__WXPM__)
1812 #include "wx/os2/dc.h"
1815 #if wxUSE_GRAPHICS_CONTEXT
1816 #include "wx/dcgraph.h"
1819 // ----------------------------------------------------------------------------
1820 // helper class: you can use it to temporarily change the DC text colour and
1821 // restore it automatically when the object goes out of scope
1822 // ----------------------------------------------------------------------------
1824 class WXDLLEXPORT wxDCTextColourChanger
1827 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1829 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1834 ~wxDCTextColourChanger()
1836 if ( m_colFgOld
.Ok() )
1837 m_dc
.SetTextForeground(m_colFgOld
);
1840 void Set(const wxColour
& col
)
1842 if ( !m_colFgOld
.Ok() )
1843 m_colFgOld
= m_dc
.GetTextForeground();
1844 m_dc
.SetTextForeground(col
);
1850 wxColour m_colFgOld
;
1852 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
1855 // ----------------------------------------------------------------------------
1856 // helper class: you can use it to temporarily change the DC pen and
1857 // restore it automatically when the object goes out of scope
1858 // ----------------------------------------------------------------------------
1860 class WXDLLEXPORT wxDCPenChanger
1863 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1870 if ( m_penOld
.Ok() )
1871 m_dc
.SetPen(m_penOld
);
1879 DECLARE_NO_COPY_CLASS(wxDCPenChanger
)
1882 // ----------------------------------------------------------------------------
1883 // helper class: you can use it to temporarily change the DC brush and
1884 // restore it automatically when the object goes out of scope
1885 // ----------------------------------------------------------------------------
1887 class WXDLLEXPORT wxDCBrushChanger
1890 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1892 m_dc
.SetBrush(brush
);
1897 if ( m_brushOld
.Ok() )
1898 m_dc
.SetBrush(m_brushOld
);
1906 DECLARE_NO_COPY_CLASS(wxDCBrushChanger
)
1909 // ----------------------------------------------------------------------------
1910 // another small helper class: sets the clipping region in its ctor and
1911 // destroys it in the dtor
1912 // ----------------------------------------------------------------------------
1914 class WXDLLEXPORT wxDCClipper
1917 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1918 { dc
.SetClippingRegion(r
); }
1919 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1920 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1921 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1922 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1924 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1929 DECLARE_NO_COPY_CLASS(wxDCClipper
)
1932 #endif // _WX_DC_H_BASE_