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
;
40 class WXDLLIMPEXP_FWD_CORE wxClientDC
;
41 class WXDLLIMPEXP_FWD_CORE wxPaintDC
;
42 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
43 class WXDLLIMPEXP_FWD_CORE wxScreenDC
;
44 class WXDLLIMPEXP_FWD_CORE wxMemoryDC
;
46 class WXDLLIMPEXP_FWD_CORE wxDCBase
;
49 class WXDLLEXPORT wxDrawObject
54 : m_isBBoxValid(false)
55 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
58 virtual ~wxDrawObject() { }
61 virtual void Draw(wxDC
&) const { }
63 virtual void Draw(wxDCBase
&) const { }
66 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
70 if ( x
< m_minX
) m_minX
= x
;
71 if ( y
< m_minY
) m_minY
= y
;
72 if ( x
> m_maxX
) m_maxX
= x
;
73 if ( y
> m_maxY
) m_maxY
= y
;
86 void ResetBoundingBox()
88 m_isBBoxValid
= false;
90 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
93 // Get the final bounding box of the PostScript or Metafile picture.
95 wxCoord
MinX() const { return m_minX
; }
96 wxCoord
MaxX() const { return m_maxX
; }
97 wxCoord
MinY() const { return m_minY
; }
98 wxCoord
MaxY() const { return m_maxY
; }
100 //to define the type of object for derived objects
101 virtual int GetType()=0;
104 //for boundingbox calculation
105 bool m_isBBoxValid
:1;
106 //for boundingbox calculation
107 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
113 //-----------------------------------------------------------------------------
115 //-----------------------------------------------------------------------------
117 class WXDLLIMPEXP_FWD_CORE wxImplDC
;
119 class WXDLLIMPEXP_CORE wxDCFactory
123 virtual ~wxDCFactory() {}
125 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
) = 0;
126 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
) = 0;
127 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
) = 0;
128 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
) = 0;
129 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
) = 0;
130 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
) = 0;
131 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
) = 0;
132 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
) = 0;
133 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
) = 0;
134 virtual wxImplDC
* CreateScreenDC( wxScreenDC
*owner
) = 0;
136 static void SetDCFactory( wxDCFactory
*factory
);
137 static wxDCFactory
*GetFactory();
139 static wxDCFactory
*m_factory
;
142 //-----------------------------------------------------------------------------
144 //-----------------------------------------------------------------------------
146 class WXDLLIMPEXP_CORE wxNativeDCFactory
: public wxDCFactory
149 wxNativeDCFactory() {}
151 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
);
152 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
);
153 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
);
154 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
);
155 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
);
156 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
);
157 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
);
158 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
);
159 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
);
160 virtual wxImplDC
* CreateScreenDC( wxScreenDC
*owner
);
163 //-----------------------------------------------------------------------------
165 //-----------------------------------------------------------------------------
167 class WXDLLIMPEXP_CORE wxImplDC
: public wxObject
170 wxImplDC( wxDC
*owner
);
173 wxDC
*GetOwner() const { return m_owner
; }
175 virtual bool IsOk() const { return m_ok
; }
177 // query capabilities
179 virtual bool CanDrawBitmap() const = 0;
180 virtual bool CanGetTextExtent() const = 0;
182 // query dimension, colour deps, resolution
184 virtual void DoGetSize(int *width
, int *height
) const = 0;
185 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
187 virtual int GetDepth() const = 0;
188 virtual wxSize
GetPPI() const = 0;
190 // Right-To-Left (RTL) modes
192 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
193 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
197 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
198 virtual void EndDoc() { }
200 virtual void StartPage() { }
201 virtual void EndPage() { }
205 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
209 if ( x
< m_minX
) m_minX
= x
;
210 if ( y
< m_minY
) m_minY
= y
;
211 if ( x
> m_maxX
) m_maxX
= x
;
212 if ( y
> m_maxY
) m_maxY
= y
;
216 m_isBBoxValid
= true;
224 void ResetBoundingBox()
226 m_isBBoxValid
= false;
228 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
231 wxCoord
MinX() const { return m_minX
; }
232 wxCoord
MaxX() const { return m_maxX
; }
233 wxCoord
MinY() const { return m_minY
; }
234 wxCoord
MaxY() const { return m_maxY
; }
236 // setters and getters
238 virtual void SetFont(const wxFont
& font
) = 0;
239 virtual const wxFont
& GetFont() const { return m_font
; }
241 virtual void SetPen(const wxPen
& pen
) = 0;
242 virtual const wxPen
& GetPen() const { return m_pen
; }
244 virtual void SetBrush(const wxBrush
& brush
) = 0;
245 virtual const wxBrush
& GetBrush() const { return m_brush
; }
247 virtual void SetBackground(const wxBrush
& brush
) = 0;
248 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
250 virtual void SetBackgroundMode(int mode
) = 0;
251 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
253 virtual void SetTextForeground(const wxColour
& colour
)
254 { m_textForegroundColour
= colour
; }
255 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
257 virtual void SetTextBackground(const wxColour
& colour
)
258 { m_textBackgroundColour
= colour
; }
259 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
262 virtual void SetPalette(const wxPalette
& palette
) = 0;
263 #endif // wxUSE_PALETTE
267 virtual void SetLogicalFunction(int function
) = 0;
268 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
272 virtual wxCoord
GetCharHeight() const = 0;
273 virtual wxCoord
GetCharWidth() const = 0;
274 virtual void DoGetTextExtent(const wxString
& string
,
275 wxCoord
*x
, wxCoord
*y
,
276 wxCoord
*descent
= NULL
,
277 wxCoord
*externalLeading
= NULL
,
278 const wxFont
*theFont
= NULL
) const = 0;
279 virtual void GetMultiLineTextExtent(const wxString
& string
,
282 wxCoord
*heightLine
= NULL
,
283 const wxFont
*font
= NULL
) const;
284 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
288 virtual void Clear() = 0;
292 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
293 wxCoord width
, wxCoord height
) = 0;
294 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
296 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
297 wxCoord
*w
, wxCoord
*h
) const
304 *w
= m_clipX2
- m_clipX1
;
306 *h
= m_clipY2
- m_clipY1
;
309 virtual void DestroyClippingRegion() { ResetClipping(); }
312 // coordinates conversions and transforms
314 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
315 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
316 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
317 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
318 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
319 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
320 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
321 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
323 virtual void SetMapMode(int mode
);
324 virtual int GetMapMode() const { return m_mappingMode
; }
326 virtual void SetUserScale(double x
, double y
);
327 virtual void GetUserScale(double *x
, double *y
) const
329 if ( x
) *x
= m_userScaleX
;
330 if ( y
) *y
= m_userScaleY
;
333 virtual void SetLogicalScale(double x
, double y
);
334 virtual void GetLogicalScale(double *x
, double *y
)
336 if ( x
) *x
= m_logicalScaleX
;
337 if ( y
) *y
= m_logicalScaleY
;
340 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
341 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
343 if ( x
) *x
= m_logicalOriginX
;
344 if ( y
) *y
= m_logicalOriginY
;
347 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
348 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
350 if ( x
) *x
= m_deviceOriginX
;
351 if ( y
) *y
= m_deviceOriginY
;
354 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
356 virtual void ComputeScaleAndOrigin();
358 // this needs to overidden if the axis is inverted
359 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
361 // ---------------------------------------------------------
362 // the actual drawing API
364 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
365 int style
= wxFLOOD_SURFACE
) = 0;
367 virtual void DoGradientFillLinear(const wxRect
& rect
,
368 const wxColour
& initialColour
,
369 const wxColour
& destColour
,
370 wxDirection nDirection
= wxEAST
);
372 virtual void DoGradientFillConcentric(const wxRect
& rect
,
373 const wxColour
& initialColour
,
374 const wxColour
& destColour
,
375 const wxPoint
& circleCenter
);
377 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
379 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
380 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
382 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
383 wxCoord x2
, wxCoord y2
,
384 wxCoord xc
, wxCoord yc
) = 0;
385 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
386 wxCoord width
, wxCoord height
);
387 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
388 double sa
, double ea
) = 0;
390 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
391 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
392 wxCoord width
, wxCoord height
,
394 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
395 wxCoord width
, wxCoord height
) = 0;
397 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
399 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
400 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
401 bool useMask
= false) = 0;
403 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
404 virtual void DoDrawRotatedText(const wxString
& text
,
405 wxCoord x
, wxCoord y
, double angle
) = 0;
407 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
408 wxCoord width
, wxCoord height
,
410 wxCoord xsrc
, wxCoord ysrc
,
412 bool useMask
= false,
413 wxCoord xsrcMask
= wxDefaultCoord
,
414 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
416 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
417 wxCoord dstWidth
, wxCoord dstHeight
,
419 wxCoord xsrc
, wxCoord ysrc
,
420 wxCoord srcWidth
, wxCoord srcHeight
,
422 bool useMask
= false,
423 wxCoord xsrcMask
= wxDefaultCoord
,
424 wxCoord ysrcMask
= wxDefaultCoord
);
426 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
427 { return wxNullBitmap
; }
430 virtual void DoDrawLines(int n
, wxPoint points
[],
431 wxCoord xoffset
, wxCoord yoffset
) = 0;
432 virtual void DoDrawPolygon(int n
, wxPoint points
[],
433 wxCoord xoffset
, wxCoord yoffset
,
434 int fillStyle
= wxODDEVEN_RULE
) = 0;
435 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
436 wxCoord xoffset
, wxCoord yoffset
,
442 virtual void DoDrawSpline(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
, wxCoord x3
, wxCoord y3
);
443 virtual void DoDrawSpline(int n
, wxPoint points
[]);
444 virtual void DoDrawSpline(wxList
*points
);
451 // unset clipping variables (after clipping region was destroyed)
456 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
463 bool m_isInteractive
:1;
464 bool m_isBBoxValid
:1;
466 // coordinate system variables
468 wxCoord m_logicalOriginX
, m_logicalOriginY
;
469 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
471 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
472 // is not at 0,0. This was the case under
473 // Mac's GrafPorts (coordinate system
474 // used toplevel window's origin) and
475 // e.g. for Postscript, where the native
476 // origin in the bottom left corner.
477 double m_logicalScaleX
, m_logicalScaleY
;
478 double m_userScaleX
, m_userScaleY
;
479 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
481 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
483 // what is a mm on a screen you don't know the size of?
484 double m_mm_to_pix_x
,
487 // bounding and clipping boxes
488 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
489 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
491 int m_logicalFunction
;
492 int m_backgroundMode
;
497 wxBrush m_backgroundBrush
;
498 wxColour m_textForegroundColour
;
499 wxColour m_textBackgroundColour
;
504 bool m_hasCustomPalette
;
505 #endif // wxUSE_PALETTE
508 DECLARE_ABSTRACT_CLASS(wxImplDC
)
512 class wxDC
: public wxObject
515 wxDC() { m_pimpl
= NULL
; }
521 { return m_pimpl
&& m_pimpl
->IsOk(); }
523 // query capabilities
525 bool CanDrawBitmap() const
526 { return m_pimpl
->CanDrawBitmap(); }
527 bool CanGetTextExtent() const
528 { return m_pimpl
->CanGetTextExtent(); }
530 // query dimension, colour deps, resolution
532 void GetSize(int *width
, int *height
) const
533 { m_pimpl
->DoGetSize(width
, height
); }
535 wxSize
GetSize() const
538 m_pimpl
->DoGetSize(&w
, &h
);
542 void GetSizeMM(int* width
, int* height
) const
543 { m_pimpl
->DoGetSizeMM(width
, height
); }
544 wxSize
GetSizeMM() const
547 m_pimpl
->DoGetSizeMM(&w
, &h
);
552 { return m_pimpl
->GetDepth(); }
553 wxSize
GetPPI() const
554 { return m_pimpl
->GetPPI(); }
556 // Right-To-Left (RTL) modes
558 void SetLayoutDirection(wxLayoutDirection dir
)
559 { m_pimpl
->SetLayoutDirection( dir
); }
560 wxLayoutDirection
GetLayoutDirection() const
561 { return m_pimpl
->GetLayoutDirection(); }
565 bool StartDoc(const wxString
& message
)
566 { return m_pimpl
->StartDoc(message
); }
568 { m_pimpl
->EndDoc(); }
571 { m_pimpl
->StartPage(); }
573 { m_pimpl
->EndPage(); }
577 void CalcBoundingBox(wxCoord x
, wxCoord y
)
578 { m_pimpl
->CalcBoundingBox(x
,y
); }
579 void ResetBoundingBox()
580 { m_pimpl
->ResetBoundingBox(); }
583 { return m_pimpl
->MinX(); }
585 { return m_pimpl
->MaxX(); }
587 { return m_pimpl
->MinY(); }
589 { return m_pimpl
->MaxY(); }
591 // setters and getters
593 void SetFont(const wxFont
& font
)
594 { m_pimpl
->SetFont( font
); }
595 const wxFont
& GetFont() const
596 { return m_pimpl
->GetFont(); }
598 void SetPen(const wxPen
& pen
)
599 { m_pimpl
->SetPen( pen
); }
600 const wxPen
& GetPen() const
601 { return m_pimpl
->GetPen(); }
603 void SetBrush(const wxBrush
& brush
)
604 { m_pimpl
->SetBrush( brush
); }
605 const wxBrush
& GetBrush() const
606 { return m_pimpl
->GetBrush(); }
608 void SetBackground(const wxBrush
& brush
)
609 { m_pimpl
->SetBackground( brush
); }
610 const wxBrush
& GetBackground() const
611 { return m_pimpl
->GetBackground(); }
613 void SetBackgroundMode(int mode
)
614 { m_pimpl
->SetBackgroundMode( mode
); }
615 int GetBackgroundMode() const
616 { return m_pimpl
->GetBackgroundMode(); }
618 void SetTextForeground(const wxColour
& colour
)
619 { m_pimpl
->SetTextForeground(colour
); }
620 const wxColour
& GetTextForeground() const
621 { return m_pimpl
->GetTextForeground(); }
623 void SetTextBackground(const wxColour
& colour
)
624 { m_pimpl
->SetTextBackground(colour
); }
625 const wxColour
& GetTextBackground() const
626 { return m_pimpl
->GetTextBackground(); }
629 void SetPalette(const wxPalette
& palette
)
630 { m_pimpl
->SetPalette(palette
); }
631 #endif // wxUSE_PALETTE
635 void SetLogicalFunction(int function
)
636 { m_pimpl
->SetLogicalFunction(function
); }
637 int GetLogicalFunction() const
638 { return m_pimpl
->GetLogicalFunction(); }
642 wxCoord
GetCharHeight() const
643 { return m_pimpl
->GetCharHeight(); }
644 wxCoord
GetCharWidth() const
645 { return m_pimpl
->GetCharWidth(); }
647 void GetTextExtent(const wxString
& string
,
648 wxCoord
*x
, wxCoord
*y
,
649 wxCoord
*descent
= NULL
,
650 wxCoord
*externalLeading
= NULL
,
651 const wxFont
*theFont
= NULL
) const
652 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
654 wxSize
GetTextExtent(const wxString
& string
) const
657 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
661 void GetMultiLineTextExtent(const wxString
& string
,
664 wxCoord
*heightLine
= NULL
,
665 const wxFont
*font
= NULL
) const
666 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
668 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
671 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
675 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
676 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
681 { m_pimpl
->Clear(); }
685 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
686 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
687 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
688 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
689 void SetClippingRegion(const wxRect
& rect
)
690 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
691 void SetClippingRegion(const wxRegion
& region
)
692 { m_pimpl
->DoSetClippingRegionAsRegion(region
); }
694 void DestroyClippingRegion()
695 { m_pimpl
->DestroyClippingRegion(); }
697 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
698 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
699 void GetClippingBox(wxRect
& rect
) const
700 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
702 // coordinates conversions and transforms
704 wxCoord
DeviceToLogicalX(wxCoord x
) const
705 { return m_pimpl
->DeviceToLogicalX(x
); }
706 wxCoord
DeviceToLogicalY(wxCoord y
) const
707 { return m_pimpl
->DeviceToLogicalY(y
); }
708 wxCoord
DeviceToLogicalXRel(wxCoord x
) const
709 { return m_pimpl
->DeviceToLogicalXRel(x
); }
710 wxCoord
DeviceToLogicalYRel(wxCoord y
) const
711 { return m_pimpl
->DeviceToLogicalYRel(y
); }
712 wxCoord
LogicalToDeviceX(wxCoord x
) const
713 { return m_pimpl
->LogicalToDeviceX(x
); }
714 wxCoord
LogicalToDeviceY(wxCoord y
) const
715 { return m_pimpl
->LogicalToDeviceY(y
); }
716 wxCoord
LogicalToDeviceXRel(wxCoord x
) const
717 { return m_pimpl
->LogicalToDeviceXRel(x
); }
718 wxCoord
LogicalToDeviceYRel(wxCoord y
) const
719 { return m_pimpl
->LogicalToDeviceYRel(y
); }
721 void SetMapMode(int mode
)
722 { m_pimpl
->SetMapMode(mode
); }
723 int GetMapMode() const
724 { return m_pimpl
->GetMapMode(); }
726 void SetUserScale(double x
, double y
)
727 { m_pimpl
->SetUserScale(x
,y
); }
728 void GetUserScale(double *x
, double *y
) const
729 { m_pimpl
->GetUserScale( x
, y
); }
731 void SetLogicalScale(double x
, double y
)
732 { m_pimpl
->SetLogicalScale( x
, y
); }
733 void GetLogicalScale(double *x
, double *y
)
734 { m_pimpl
->GetLogicalScale( x
, y
); }
736 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
737 { m_pimpl
->SetLogicalOrigin(x
,y
); }
738 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
739 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
740 wxPoint
GetLogicalOrigin() const
741 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
743 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
744 { m_pimpl
->SetDeviceOrigin( x
, y
); }
745 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
746 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
747 wxPoint
GetDeviceOrigin() const
748 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
750 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
751 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
754 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
755 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
758 // draw generic object
760 void DrawObject(wxDrawObject
* drawobject
)
762 drawobject
->Draw(*this);
763 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
764 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
767 // -----------------------------------------------
768 // the actual drawing API
770 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
771 int style
= wxFLOOD_SURFACE
)
772 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
773 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
774 int style
= wxFLOOD_SURFACE
)
775 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
777 // fill the area specified by rect with a radial gradient, starting from
778 // initialColour in the centre of the cercle and fading to destColour.
779 void GradientFillConcentric(const wxRect
& rect
,
780 const wxColour
& initialColour
,
781 const wxColour
& destColour
)
782 { m_pimpl
->DoGradientFillConcentric( rect
, initialColour
, destColour
,
783 wxPoint(rect
.GetWidth() / 2,
784 rect
.GetHeight() / 2)); }
786 void GradientFillConcentric(const wxRect
& rect
,
787 const wxColour
& initialColour
,
788 const wxColour
& destColour
,
789 const wxPoint
& circleCenter
)
790 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
792 // fill the area specified by rect with a linear gradient
793 void GradientFillLinear(const wxRect
& rect
,
794 const wxColour
& initialColour
,
795 const wxColour
& destColour
,
796 wxDirection nDirection
= wxEAST
)
797 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
799 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
800 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
801 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
802 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
804 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
805 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
806 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
807 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
809 void CrossHair(wxCoord x
, wxCoord y
)
810 { m_pimpl
->DoCrossHair(x
, y
); }
811 void CrossHair(const wxPoint
& pt
)
812 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
814 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
815 wxCoord xc
, wxCoord yc
)
816 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
817 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
818 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
820 void DrawCheckMark(wxCoord x
, wxCoord y
,
821 wxCoord width
, wxCoord height
)
822 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
823 void DrawCheckMark(const wxRect
& rect
)
824 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
826 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
827 double sa
, double ea
)
828 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
829 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
830 double sa
, double ea
)
831 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
833 void DrawPoint(wxCoord x
, wxCoord y
)
834 { m_pimpl
->DoDrawPoint(x
, y
); }
835 void DrawPoint(const wxPoint
& pt
)
836 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
838 void DrawLines(int n
, wxPoint points
[],
839 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
840 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
843 // needs to be removed
844 void DrawLines(const wxList
*list
,
845 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
848 void DrawPolygon(int n
, wxPoint points
[],
849 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
850 int fillStyle
= wxODDEVEN_RULE
)
851 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
854 // needs to be removed
855 void DrawPolygon(const wxList
*list
,
856 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
857 int fillStyle
= wxODDEVEN_RULE
)
858 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
861 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
862 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
863 int fillStyle
= wxODDEVEN_RULE
)
864 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
866 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
867 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
868 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
869 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
870 void DrawRectangle(const wxRect
& rect
)
871 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
873 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
875 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
876 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
878 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
879 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
880 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
882 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
883 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
884 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
885 { m_pimpl
->DoDrawEllipse(pt
.x
- radius
, pt
.y
- radius
, 2*radius
, 2*radius
); }
887 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
888 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
889 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
890 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
891 void DrawEllipse(const wxRect
& rect
)
892 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
894 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
895 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
896 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
897 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
899 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
900 bool useMask
= false)
901 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
902 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
903 bool useMask
= false)
904 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
906 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
907 { m_pimpl
->DoDrawText(text
, x
, y
); }
908 void DrawText(const wxString
& text
, const wxPoint
& pt
)
909 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
911 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
912 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
913 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
914 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
916 // this version puts both optional bitmap and the text into the given
917 // rectangle and aligns is as specified by alignment parameter; it also
918 // will emphasize the character with the given index if it is != -1 and
919 // return the bounding rectangle if required
920 void DrawLabel(const wxString
& text
,
921 const wxBitmap
& image
,
923 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
925 wxRect
*rectBounding
= NULL
);
927 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
928 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
930 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
932 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
933 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
934 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
936 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
937 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
939 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
940 wxDC
*source
, const wxPoint
& srcPt
,
941 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
943 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
944 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
947 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
948 wxCoord dstWidth
, wxCoord dstHeight
,
950 wxCoord srcX
, wxCoord srcY
,
951 wxCoord srcWidth
, wxCoord srcHeight
,
952 int rop
= wxCOPY
, bool useMask
= false,
953 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
955 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
956 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
958 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
959 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
960 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
962 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
963 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
966 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
968 return m_pimpl
->DoGetAsBitmap(subrect
);
972 void DrawSpline(wxCoord x1
, wxCoord y1
,
973 wxCoord x2
, wxCoord y2
,
974 wxCoord x3
, wxCoord y3
)
975 { m_pimpl
->DoDrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
976 void DrawSpline(int n
, wxPoint points
[])
977 { m_pimpl
->DoDrawSpline(n
,points
); }
980 // needs to be removed
981 void DrawSpline(wxList
*points
)
982 { m_pimpl
->DoDrawSpline(points
); }
984 #endif // wxUSE_SPLINES
987 #if WXWIN_COMPATIBILITY_2_8
988 // for compatibility with the old code when wxCoord was long everywhere
989 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
991 long *descent
= NULL
,
992 long *externalLeading
= NULL
,
993 const wxFont
*theFont
= NULL
) const );
994 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
995 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
996 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
997 #endif // WXWIN_COMPATIBILITY_2_8
1004 DECLARE_ABSTRACT_CLASS(wxImplDC
)
1008 //-----------------------------------------------------------------------------
1010 //-----------------------------------------------------------------------------
1012 class WXDLLIMPEXP_CORE wxWindowDC
: public wxDC
1016 wxWindowDC( wxWindow
*win
);
1019 DECLARE_DYNAMIC_CLASS(wxWindowDC
)
1022 //-----------------------------------------------------------------------------
1024 //-----------------------------------------------------------------------------
1026 class WXDLLIMPEXP_CORE wxClientDC
: public wxDC
1030 wxClientDC( wxWindow
*win
);
1033 DECLARE_DYNAMIC_CLASS(wxClientDC
)
1036 //-----------------------------------------------------------------------------
1038 //-----------------------------------------------------------------------------
1040 class WXDLLIMPEXP_CORE wxPaintDC
: public wxDC
1044 wxPaintDC( wxWindow
*win
);
1047 DECLARE_DYNAMIC_CLASS(wxPaintDC
)
1050 #else // wxUSE_NEW_DC
1053 class WXDLLIMPEXP_FWD_CORE wxDC
;
1055 // ---------------------------------------------------------------------------
1057 // ---------------------------------------------------------------------------
1059 // ---------------------------------------------------------------------------
1060 // wxDC is the device context - object on which any drawing is done
1061 // ---------------------------------------------------------------------------
1063 class WXDLLEXPORT wxDCBase
: public wxObject
1067 virtual ~wxDCBase();
1069 // graphic primitives
1070 // ------------------
1072 virtual void DrawObject(wxDrawObject
* drawobject
)
1074 drawobject
->Draw(*this);
1075 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
1076 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
1079 wxDC
*GetOwner() const { return (wxDC
*) this; }
1081 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1082 int style
= wxFLOOD_SURFACE
)
1083 { return DoFloodFill(x
, y
, col
, style
); }
1084 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
1085 int style
= wxFLOOD_SURFACE
)
1086 { return DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
1088 // fill the area specified by rect with a radial gradient, starting from
1089 // initialColour in the centre of the cercle and fading to destColour.
1090 void GradientFillConcentric(const wxRect
& rect
,
1091 const wxColour
& initialColour
,
1092 const wxColour
& destColour
)
1093 { GradientFillConcentric(rect
, initialColour
, destColour
,
1094 wxPoint(rect
.GetWidth() / 2,
1095 rect
.GetHeight() / 2)); }
1097 void GradientFillConcentric(const wxRect
& rect
,
1098 const wxColour
& initialColour
,
1099 const wxColour
& destColour
,
1100 const wxPoint
& circleCenter
)
1101 { DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
1103 // fill the area specified by rect with a linear gradient
1104 void GradientFillLinear(const wxRect
& rect
,
1105 const wxColour
& initialColour
,
1106 const wxColour
& destColour
,
1107 wxDirection nDirection
= wxEAST
)
1108 { DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
1110 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
1111 { return DoGetPixel(x
, y
, col
); }
1112 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
1113 { return DoGetPixel(pt
.x
, pt
.y
, col
); }
1115 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1116 { DoDrawLine(x1
, y1
, x2
, y2
); }
1117 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
1118 { DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
1120 void CrossHair(wxCoord x
, wxCoord y
)
1121 { DoCrossHair(x
, y
); }
1122 void CrossHair(const wxPoint
& pt
)
1123 { DoCrossHair(pt
.x
, pt
.y
); }
1125 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
1126 wxCoord xc
, wxCoord yc
)
1127 { DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
1128 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
1129 { DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
1131 void DrawCheckMark(wxCoord x
, wxCoord y
,
1132 wxCoord width
, wxCoord height
)
1133 { DoDrawCheckMark(x
, y
, width
, height
); }
1134 void DrawCheckMark(const wxRect
& rect
)
1135 { DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1137 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1138 double sa
, double ea
)
1139 { DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
1140 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
1141 double sa
, double ea
)
1142 { DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
1144 void DrawPoint(wxCoord x
, wxCoord y
)
1145 { DoDrawPoint(x
, y
); }
1146 void DrawPoint(const wxPoint
& pt
)
1147 { DoDrawPoint(pt
.x
, pt
.y
); }
1149 void DrawLines(int n
, wxPoint points
[],
1150 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1151 { DoDrawLines(n
, points
, xoffset
, yoffset
); }
1152 void DrawLines(const wxList
*list
,
1153 wxCoord xoffset
= 0, wxCoord yoffset
= 0);
1155 void DrawPolygon(int n
, wxPoint points
[],
1156 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1157 int fillStyle
= wxODDEVEN_RULE
)
1158 { DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
1160 void DrawPolygon(const wxList
*list
,
1161 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1162 int fillStyle
= wxODDEVEN_RULE
);
1164 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1165 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1166 int fillStyle
= wxODDEVEN_RULE
)
1167 { DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
1169 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1170 { DoDrawRectangle(x
, y
, width
, height
); }
1171 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
1172 { DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1173 void DrawRectangle(const wxRect
& rect
)
1174 { DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1176 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
1178 { DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
1179 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
1181 { DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
1182 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
1183 { DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1185 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1186 { DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1187 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1188 { DrawCircle(pt
.x
, pt
.y
, radius
); }
1190 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1191 { DoDrawEllipse(x
, y
, width
, height
); }
1192 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1193 { DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1194 void DrawEllipse(const wxRect
& rect
)
1195 { DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1197 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1198 { DoDrawIcon(icon
, x
, y
); }
1199 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1200 { DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1202 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1203 bool useMask
= false)
1204 { DoDrawBitmap(bmp
, x
, y
, useMask
); }
1205 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1206 bool useMask
= false)
1207 { DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1209 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1210 { DoDrawText(text
, x
, y
); }
1211 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1212 { DoDrawText(text
, pt
.x
, pt
.y
); }
1214 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1215 { DoDrawRotatedText(text
, x
, y
, angle
); }
1216 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1217 { DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1219 // this version puts both optional bitmap and the text into the given
1220 // rectangle and aligns is as specified by alignment parameter; it also
1221 // will emphasize the character with the given index if it is != -1 and
1222 // return the bounding rectangle if required
1223 virtual void DrawLabel(const wxString
& text
,
1224 const wxBitmap
& image
,
1226 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1227 int indexAccel
= -1,
1228 wxRect
*rectBounding
= NULL
);
1230 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1231 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1232 int indexAccel
= -1)
1233 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1235 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1236 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1237 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1239 return DoBlit(xdest
, ydest
, width
, height
,
1240 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1242 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1243 wxDC
*source
, const wxPoint
& srcPt
,
1244 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
1246 return DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1247 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1250 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1251 wxCoord dstWidth
, wxCoord dstHeight
,
1253 wxCoord srcX
, wxCoord srcY
,
1254 wxCoord srcWidth
, wxCoord srcHeight
,
1255 int rop
= wxCOPY
, bool useMask
= false,
1256 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1258 return DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1259 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1261 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1262 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1263 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1265 return DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1266 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1269 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1271 return DoGetAsBitmap(subrect
);
1275 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
1276 void DrawSpline(wxCoord x1
, wxCoord y1
,
1277 wxCoord x2
, wxCoord y2
,
1278 wxCoord x3
, wxCoord y3
);
1279 void DrawSpline(int n
, wxPoint points
[]);
1281 void DrawSpline(wxList
*points
) { DoDrawSpline(points
); }
1282 #endif // wxUSE_SPLINES
1284 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
1286 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
1287 /*! \param x Upper left corner of bounding box.
1288 * \param y Upper left corner of bounding box.
1289 * \param w Width of bounding box.
1290 * \param h Height of bounding box.
1291 * \param sa Starting angle of arc
1292 * (counterclockwise, start at 3 o'clock, 360 is full circle).
1293 * \param ea Ending angle of arc.
1294 * \param angle Rotation angle, the Arc will be rotated after
1295 * calculating begin and end.
1297 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
1298 wxCoord width
, wxCoord height
,
1299 double sa
= 0, double ea
= 0, double angle
= 0 )
1300 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
1302 void DrawEllipticArcRot( const wxPoint
& pt
,
1304 double sa
= 0, double ea
= 0, double angle
= 0 )
1305 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
1307 void DrawEllipticArcRot( const wxRect
& rect
,
1308 double sa
= 0, double ea
= 0, double angle
= 0 )
1309 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
1311 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
1312 wxCoord w
, wxCoord h
,
1313 double sa
= 0, double ea
= 0, double angle
= 0 );
1315 //! Rotates points around center.
1316 /*! This is a quite straight method, it calculates in pixels
1317 * and so it produces rounding errors.
1318 * \param points The points inside will be rotated.
1319 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
1320 * \param center Center of rotation.
1322 void Rotate( wxList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
1324 // used by DrawEllipticArcRot
1325 // Careful: wxList gets filled with points you have to delete later.
1326 void CalculateEllipticPoints( wxList
* points
,
1327 wxCoord xStart
, wxCoord yStart
,
1328 wxCoord w
, wxCoord h
,
1329 double sa
, double ea
);
1332 // global DC operations
1333 // --------------------
1335 virtual void Clear() = 0;
1337 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
1338 virtual void EndDoc() { }
1340 virtual void StartPage() { }
1341 virtual void EndPage() { }
1343 #if WXWIN_COMPATIBILITY_2_6
1344 wxDEPRECATED( void BeginDrawing() );
1345 wxDEPRECATED( void EndDrawing() );
1346 #endif // WXWIN_COMPATIBILITY_2_6
1349 // set objects to use for drawing
1350 // ------------------------------
1352 virtual void SetFont(const wxFont
& font
) = 0;
1353 virtual void SetPen(const wxPen
& pen
) = 0;
1354 virtual void SetBrush(const wxBrush
& brush
) = 0;
1355 virtual void SetBackground(const wxBrush
& brush
) = 0;
1356 virtual void SetBackgroundMode(int mode
) = 0;
1358 virtual void SetPalette(const wxPalette
& palette
) = 0;
1359 #endif // wxUSE_PALETTE
1364 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1365 { DoSetClippingRegion(x
, y
, width
, height
); }
1366 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
1367 { DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1368 void SetClippingRegion(const wxRect
& rect
)
1369 { DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1370 void SetClippingRegion(const wxRegion
& region
)
1371 { DoSetClippingRegionAsRegion(region
); }
1373 virtual void DestroyClippingRegion() { ResetClipping(); }
1375 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
1376 { DoGetClippingBox(x
, y
, w
, h
); }
1377 void GetClippingBox(wxRect
& rect
) const
1379 DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
);
1385 virtual wxCoord
GetCharHeight() const = 0;
1386 virtual wxCoord
GetCharWidth() const = 0;
1388 // only works for single line strings
1389 void GetTextExtent(const wxString
& string
,
1390 wxCoord
*x
, wxCoord
*y
,
1391 wxCoord
*descent
= NULL
,
1392 wxCoord
*externalLeading
= NULL
,
1393 const wxFont
*theFont
= NULL
) const
1394 { DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
1396 wxSize
GetTextExtent(const wxString
& string
) const
1399 DoGetTextExtent(string
, &w
, &h
);
1400 return wxSize(w
, h
);
1403 // works for single as well as multi-line strings
1404 virtual void GetMultiLineTextExtent(const wxString
& string
,
1407 wxCoord
*heightLine
= NULL
,
1408 const wxFont
*font
= NULL
) const;
1410 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
1413 GetMultiLineTextExtent(string
, &w
, &h
);
1414 return wxSize(w
, h
);
1417 // Measure cumulative width of text after each character
1418 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1419 { return DoGetPartialTextExtents(text
, widths
); }
1422 // size and resolution
1423 // -------------------
1426 void GetSize(int *width
, int *height
) const
1427 { DoGetSize(width
, height
); }
1428 wxSize
GetSize() const
1433 return wxSize(w
, h
);
1437 void GetSizeMM(int* width
, int* height
) const
1438 { DoGetSizeMM(width
, height
); }
1439 wxSize
GetSizeMM() const
1442 DoGetSizeMM(&w
, &h
);
1444 return wxSize(w
, h
);
1447 // query DC capabilities
1448 // ---------------------
1450 virtual bool CanDrawBitmap() const = 0;
1451 virtual bool CanGetTextExtent() const = 0;
1454 virtual int GetDepth() const = 0;
1456 // Resolution in Pixels per inch
1457 virtual wxSize
GetPPI() const = 0;
1459 virtual bool Ok() const { return IsOk(); }
1460 virtual bool IsOk() const { return m_ok
; }
1462 // accessors and setters
1463 // ---------------------
1465 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
1466 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
1467 virtual const wxBrush
& GetBrush() const { return m_brush
; }
1468 virtual const wxFont
& GetFont() const { return m_font
; }
1469 virtual const wxPen
& GetPen() const { return m_pen
; }
1471 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
1472 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
1473 virtual void SetTextForeground(const wxColour
& colour
)
1474 { m_textForegroundColour
= colour
; }
1475 virtual void SetTextBackground(const wxColour
& colour
)
1476 { m_textBackgroundColour
= colour
; }
1479 // coordinates conversions and transforms
1480 // --------------------------------------
1482 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
1483 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
1484 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
1485 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
1486 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
1487 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
1488 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
1489 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
1491 virtual void SetMapMode(int mode
);
1492 virtual int GetMapMode() const { return m_mappingMode
; }
1494 virtual void SetUserScale(double x
, double y
);
1495 virtual void GetUserScale(double *x
, double *y
) const
1497 if ( x
) *x
= m_userScaleX
;
1498 if ( y
) *y
= m_userScaleY
;
1501 virtual void SetLogicalScale(double x
, double y
);
1502 virtual void GetLogicalScale(double *x
, double *y
)
1504 if ( x
) *x
= m_logicalScaleX
;
1505 if ( y
) *y
= m_logicalScaleY
;
1508 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
1509 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1510 { DoGetLogicalOrigin(x
, y
); }
1511 wxPoint
GetLogicalOrigin() const
1512 { wxCoord x
, y
; DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
1514 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
1515 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1516 { DoGetDeviceOrigin(x
, y
); }
1517 wxPoint
GetDeviceOrigin() const
1518 { wxCoord x
, y
; DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
1520 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
1522 virtual void ComputeScaleAndOrigin();
1524 // this needs to overidden if the axis is inverted (such
1525 // as when using Postscript, where 0,0 is the lower left
1526 // corner, not the upper left).
1527 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
1529 // logical functions
1530 // ---------------------------
1532 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
1533 virtual void SetLogicalFunction(int function
) = 0;
1538 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
1540 if ( m_isBBoxValid
)
1542 if ( x
< m_minX
) m_minX
= x
;
1543 if ( y
< m_minY
) m_minY
= y
;
1544 if ( x
> m_maxX
) m_maxX
= x
;
1545 if ( y
> m_maxY
) m_maxY
= y
;
1549 m_isBBoxValid
= true;
1558 void ResetBoundingBox()
1560 m_isBBoxValid
= false;
1562 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
1565 // Get the final bounding box of the PostScript or Metafile picture.
1566 wxCoord
MinX() const { return m_minX
; }
1567 wxCoord
MaxX() const { return m_maxX
; }
1568 wxCoord
MinY() const { return m_minY
; }
1569 wxCoord
MaxY() const { return m_maxY
; }
1571 // misc old functions
1572 // ------------------
1574 #if WXWIN_COMPATIBILITY_2_8
1575 // for compatibility with the old code when wxCoord was long everywhere
1576 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1578 long *descent
= NULL
,
1579 long *externalLeading
= NULL
,
1580 const wxFont
*theFont
= NULL
) const );
1581 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1582 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1583 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1584 #endif // WXWIN_COMPATIBILITY_2_8
1586 // RTL related functions
1587 // ---------------------
1589 // get or change the layout direction (LTR or RTL) for this dc,
1590 // wxLayout_Default is returned if layout direction is not supported
1591 virtual wxLayoutDirection
GetLayoutDirection() const
1592 { return wxLayout_Default
; }
1593 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
))
1597 // the pure virtual functions which should be implemented by wxDC
1598 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1599 int style
= wxFLOOD_SURFACE
) = 0;
1601 virtual void DoGradientFillLinear(const wxRect
& rect
,
1602 const wxColour
& initialColour
,
1603 const wxColour
& destColour
,
1604 wxDirection nDirection
= wxEAST
);
1606 virtual void DoGradientFillConcentric(const wxRect
& rect
,
1607 const wxColour
& initialColour
,
1608 const wxColour
& destColour
,
1609 const wxPoint
& circleCenter
);
1611 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
1613 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
1614 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
1616 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
1617 wxCoord x2
, wxCoord y2
,
1618 wxCoord xc
, wxCoord yc
) = 0;
1619 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
1620 wxCoord width
, wxCoord height
);
1621 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1622 double sa
, double ea
) = 0;
1624 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
1625 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1626 wxCoord width
, wxCoord height
,
1628 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
1629 wxCoord width
, wxCoord height
) = 0;
1631 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
1633 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
1634 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1635 bool useMask
= false) = 0;
1637 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
1638 virtual void DoDrawRotatedText(const wxString
& text
,
1639 wxCoord x
, wxCoord y
, double angle
) = 0;
1641 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
1642 wxCoord width
, wxCoord height
,
1644 wxCoord xsrc
, wxCoord ysrc
,
1646 bool useMask
= false,
1647 wxCoord xsrcMask
= wxDefaultCoord
,
1648 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
1650 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
1651 wxCoord dstWidth
, wxCoord dstHeight
,
1653 wxCoord xsrc
, wxCoord ysrc
,
1654 wxCoord srcWidth
, wxCoord srcHeight
,
1656 bool useMask
= false,
1657 wxCoord xsrcMask
= wxDefaultCoord
,
1658 wxCoord ysrcMask
= wxDefaultCoord
);
1660 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
1661 { return wxNullBitmap
; }
1663 virtual void DoGetSize(int *width
, int *height
) const = 0;
1664 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
1666 virtual void DoDrawLines(int n
, wxPoint points
[],
1667 wxCoord xoffset
, wxCoord yoffset
) = 0;
1668 virtual void DoDrawPolygon(int n
, wxPoint points
[],
1669 wxCoord xoffset
, wxCoord yoffset
,
1670 int fillStyle
= wxODDEVEN_RULE
) = 0;
1671 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1672 wxCoord xoffset
, wxCoord yoffset
,
1675 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
1676 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
1677 wxCoord width
, wxCoord height
) = 0;
1679 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
1680 wxCoord
*w
, wxCoord
*h
) const
1687 *w
= m_clipX2
- m_clipX1
;
1689 *h
= m_clipY2
- m_clipY1
;
1692 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1694 if ( x
) *x
= m_logicalOriginX
;
1695 if ( y
) *y
= m_logicalOriginY
;
1698 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1700 if ( x
) *x
= m_deviceOriginX
;
1701 if ( y
) *y
= m_deviceOriginY
;
1704 virtual void DoGetTextExtent(const wxString
& string
,
1705 wxCoord
*x
, wxCoord
*y
,
1706 wxCoord
*descent
= NULL
,
1707 wxCoord
*externalLeading
= NULL
,
1708 const wxFont
*theFont
= NULL
) const = 0;
1710 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
1713 virtual void DoDrawSpline(wxList
*points
);
1717 // unset clipping variables (after clipping region was destroyed)
1718 void ResetClipping()
1722 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
1729 bool m_isInteractive
:1;
1730 bool m_isBBoxValid
:1;
1732 // coordinate system variables
1734 // TODO short descriptions of what exactly they are would be nice...
1736 wxCoord m_logicalOriginX
, m_logicalOriginY
;
1737 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
1739 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
1740 // is not at 0,0. This was the case under
1741 // Mac's GrafPorts (coordinate system
1742 // used toplevel window's origin) and
1743 // e.g. for Postscript, where the native
1744 // origin in the bottom left corner.
1745 double m_logicalScaleX
, m_logicalScaleY
;
1746 double m_userScaleX
, m_userScaleY
;
1747 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
1749 // Used by SetAxisOrientation() to invert the axes
1750 int m_signX
, m_signY
;
1752 // what is a mm on a screen you don't know the size of?
1753 double m_mm_to_pix_x
,
1756 // bounding and clipping boxes
1757 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
1758 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
1760 int m_logicalFunction
;
1761 int m_backgroundMode
;
1767 wxBrush m_backgroundBrush
;
1768 wxColour m_textForegroundColour
;
1769 wxColour m_textBackgroundColour
;
1773 wxPalette m_palette
;
1774 bool m_hasCustomPalette
;
1775 #endif // wxUSE_PALETTE
1778 DECLARE_NO_COPY_CLASS(wxDCBase
)
1779 DECLARE_ABSTRACT_CLASS(wxDCBase
)
1782 #endif // wxUSE_NEW_DC
1784 // ----------------------------------------------------------------------------
1785 // now include the declaration of wxDC class
1786 // ----------------------------------------------------------------------------
1788 #if defined(__WXPALMOS__)
1789 #include "wx/palmos/dc.h"
1790 #elif defined(__WXMSW__)
1791 #include "wx/msw/dc.h"
1792 #elif defined(__WXMOTIF__)
1793 #include "wx/motif/dc.h"
1794 #elif defined(__WXGTK20__)
1795 #include "wx/gtk/dc.h"
1796 #elif defined(__WXGTK__)
1797 #include "wx/gtk1/dc.h"
1798 #elif defined(__WXX11__)
1799 #include "wx/x11/dc.h"
1800 #elif defined(__WXMGL__)
1801 #include "wx/mgl/dc.h"
1802 #elif defined(__WXDFB__)
1803 #include "wx/dfb/dc.h"
1804 #elif defined(__WXMAC__)
1805 #include "wx/mac/dc.h"
1806 #elif defined(__WXCOCOA__)
1807 #include "wx/cocoa/dc.h"
1808 #elif defined(__WXPM__)
1809 #include "wx/os2/dc.h"
1812 #if wxUSE_GRAPHICS_CONTEXT
1813 #include "wx/dcgraph.h"
1816 // ----------------------------------------------------------------------------
1817 // helper class: you can use it to temporarily change the DC text colour and
1818 // restore it automatically when the object goes out of scope
1819 // ----------------------------------------------------------------------------
1821 class WXDLLEXPORT wxDCTextColourChanger
1824 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1826 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1831 ~wxDCTextColourChanger()
1833 if ( m_colFgOld
.Ok() )
1834 m_dc
.SetTextForeground(m_colFgOld
);
1837 void Set(const wxColour
& col
)
1839 if ( !m_colFgOld
.Ok() )
1840 m_colFgOld
= m_dc
.GetTextForeground();
1841 m_dc
.SetTextForeground(col
);
1847 wxColour m_colFgOld
;
1849 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
1852 // ----------------------------------------------------------------------------
1853 // helper class: you can use it to temporarily change the DC pen and
1854 // restore it automatically when the object goes out of scope
1855 // ----------------------------------------------------------------------------
1857 class WXDLLEXPORT wxDCPenChanger
1860 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1867 if ( m_penOld
.Ok() )
1868 m_dc
.SetPen(m_penOld
);
1876 DECLARE_NO_COPY_CLASS(wxDCPenChanger
)
1879 // ----------------------------------------------------------------------------
1880 // helper class: you can use it to temporarily change the DC brush and
1881 // restore it automatically when the object goes out of scope
1882 // ----------------------------------------------------------------------------
1884 class WXDLLEXPORT wxDCBrushChanger
1887 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1889 m_dc
.SetBrush(brush
);
1894 if ( m_brushOld
.Ok() )
1895 m_dc
.SetBrush(m_brushOld
);
1903 DECLARE_NO_COPY_CLASS(wxDCBrushChanger
)
1906 // ----------------------------------------------------------------------------
1907 // another small helper class: sets the clipping region in its ctor and
1908 // destroys it in the dtor
1909 // ----------------------------------------------------------------------------
1911 class WXDLLEXPORT wxDCClipper
1914 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1915 { dc
.SetClippingRegion(r
); }
1916 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1917 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1918 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1919 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1921 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1926 DECLARE_NO_COPY_CLASS(wxDCClipper
)
1929 #endif // _WX_DC_H_BASE_