1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DC_H_BASE_
13 #define _WX_DC_H_BASE_
15 // ----------------------------------------------------------------------------
16 // headers which we must include here
17 // ----------------------------------------------------------------------------
19 #include "wx/object.h" // the base class
21 #include "wx/intl.h" // for wxLayoutDirection
22 #include "wx/cursor.h" // we have member variables of these classes
23 #include "wx/font.h" // so we can't do without them
24 #include "wx/colour.h"
25 #include "wx/bitmap.h" // for wxNullBitmap
28 #include "wx/palette.h"
29 #include "wx/dynarray.h"
33 // 1 if using the reorganized DC code
34 #define wxUSE_NEW_DC 0
38 class WXDLLIMPEXP_FWD_CORE wxDC
;
39 class WXDLLIMPEXP_FWD_CORE wxClientDC
;
40 class WXDLLIMPEXP_FWD_CORE wxPaintDC
;
41 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
42 class WXDLLIMPEXP_FWD_CORE wxScreenDC
;
43 class WXDLLIMPEXP_FWD_CORE wxMemoryDC
;
44 class WXDLLIMPEXP_FWD_CORE wxPrinterDC
;
45 #include "wx/cmndata.h"
47 class WXDLLIMPEXP_FWD_CORE wxDCBase
;
50 class WXDLLEXPORT wxDrawObject
55 : m_isBBoxValid(false)
56 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
59 virtual ~wxDrawObject() { }
62 virtual void Draw(wxDC
&) const { }
64 virtual void Draw(wxDCBase
&) const { }
67 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
71 if ( x
< m_minX
) m_minX
= x
;
72 if ( y
< m_minY
) m_minY
= y
;
73 if ( x
> m_maxX
) m_maxX
= x
;
74 if ( y
> m_maxY
) m_maxY
= y
;
87 void ResetBoundingBox()
89 m_isBBoxValid
= false;
91 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
94 // Get the final bounding box of the PostScript or Metafile picture.
96 wxCoord
MinX() const { return m_minX
; }
97 wxCoord
MaxX() const { return m_maxX
; }
98 wxCoord
MinY() const { return m_minY
; }
99 wxCoord
MaxY() const { return m_maxY
; }
101 //to define the type of object for derived objects
102 virtual int GetType()=0;
105 //for boundingbox calculation
106 bool m_isBBoxValid
:1;
107 //for boundingbox calculation
108 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
114 //-----------------------------------------------------------------------------
116 //-----------------------------------------------------------------------------
118 class WXDLLIMPEXP_FWD_CORE wxImplDC
;
120 class WXDLLIMPEXP_CORE wxDCFactory
124 virtual ~wxDCFactory() {}
126 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
) = 0;
127 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
) = 0;
128 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
) = 0;
129 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
) = 0;
130 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
) = 0;
131 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
) = 0;
132 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
) = 0;
133 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
) = 0;
134 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
) = 0;
135 virtual wxImplDC
* CreateScreenDC( wxScreenDC
*owner
) = 0;
136 virtual wxImplDC
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
) = 0;
138 static void SetDCFactory( wxDCFactory
*factory
);
139 static wxDCFactory
*GetFactory();
141 static wxDCFactory
*m_factory
;
144 //-----------------------------------------------------------------------------
146 //-----------------------------------------------------------------------------
148 class WXDLLIMPEXP_CORE wxNativeDCFactory
: public wxDCFactory
151 wxNativeDCFactory() {}
153 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
);
154 virtual wxImplDC
* CreateWindowDC( wxWindowDC
*owner
, wxWindow
*window
);
155 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
);
156 virtual wxImplDC
* CreateClientDC( wxClientDC
*owner
, wxWindow
*window
);
157 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
);
158 virtual wxImplDC
* CreatePaintDC( wxPaintDC
*owner
, wxWindow
*window
);
159 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
);
160 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxBitmap
&bitmap
);
161 virtual wxImplDC
* CreateMemoryDC( wxMemoryDC
*owner
, wxDC
*dc
);
162 virtual wxImplDC
* CreateScreenDC( wxScreenDC
*owner
);
163 virtual wxImplDC
* CreatePrinterDC( wxPrinterDC
*owner
, const wxPrintData
&data
);
166 //-----------------------------------------------------------------------------
168 //-----------------------------------------------------------------------------
170 class WXDLLIMPEXP_CORE wxImplDC
: public wxObject
173 wxImplDC( wxDC
*owner
);
176 wxDC
*GetOwner() const { return m_owner
; }
178 virtual bool IsOk() const { return m_ok
; }
180 // query capabilities
182 virtual bool CanDrawBitmap() const = 0;
183 virtual bool CanGetTextExtent() const = 0;
185 // query dimension, colour deps, resolution
187 virtual void DoGetSize(int *width
, int *height
) const = 0;
188 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
190 virtual int GetDepth() const = 0;
191 virtual wxSize
GetPPI() const = 0;
193 // Right-To-Left (RTL) modes
195 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
196 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
200 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
201 virtual void EndDoc() { }
203 virtual void StartPage() { }
204 virtual void EndPage() { }
206 // flushing the content of this dc immediately eg onto screen
207 virtual void Flush() { }
211 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
215 if ( x
< m_minX
) m_minX
= x
;
216 if ( y
< m_minY
) m_minY
= y
;
217 if ( x
> m_maxX
) m_maxX
= x
;
218 if ( y
> m_maxY
) m_maxY
= y
;
222 m_isBBoxValid
= true;
230 void ResetBoundingBox()
232 m_isBBoxValid
= false;
234 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
237 wxCoord
MinX() const { return m_minX
; }
238 wxCoord
MaxX() const { return m_maxX
; }
239 wxCoord
MinY() const { return m_minY
; }
240 wxCoord
MaxY() const { return m_maxY
; }
242 // setters and getters
244 virtual void SetFont(const wxFont
& font
) = 0;
245 virtual const wxFont
& GetFont() const { return m_font
; }
247 virtual void SetPen(const wxPen
& pen
) = 0;
248 virtual const wxPen
& GetPen() const { return m_pen
; }
250 virtual void SetBrush(const wxBrush
& brush
) = 0;
251 virtual const wxBrush
& GetBrush() const { return m_brush
; }
253 virtual void SetBackground(const wxBrush
& brush
) = 0;
254 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
256 virtual void SetBackgroundMode(int mode
) = 0;
257 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
259 virtual void SetTextForeground(const wxColour
& colour
)
260 { m_textForegroundColour
= colour
; }
261 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
263 virtual void SetTextBackground(const wxColour
& colour
)
264 { m_textBackgroundColour
= colour
; }
265 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
268 virtual void SetPalette(const wxPalette
& palette
) = 0;
269 #endif // wxUSE_PALETTE
273 virtual void SetLogicalFunction(int function
) = 0;
274 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
278 virtual wxCoord
GetCharHeight() const = 0;
279 virtual wxCoord
GetCharWidth() const = 0;
280 virtual void DoGetTextExtent(const wxString
& string
,
281 wxCoord
*x
, wxCoord
*y
,
282 wxCoord
*descent
= NULL
,
283 wxCoord
*externalLeading
= NULL
,
284 const wxFont
*theFont
= NULL
) const = 0;
285 virtual void GetMultiLineTextExtent(const wxString
& string
,
288 wxCoord
*heightLine
= NULL
,
289 const wxFont
*font
= NULL
) const;
290 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
294 virtual void Clear() = 0;
298 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
299 wxCoord width
, wxCoord height
) = 0;
300 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
302 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
303 wxCoord
*w
, wxCoord
*h
) const
310 *w
= m_clipX2
- m_clipX1
;
312 *h
= m_clipY2
- m_clipY1
;
315 virtual void DestroyClippingRegion() { ResetClipping(); }
318 // coordinates conversions and transforms
320 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
321 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
322 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
323 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
324 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
325 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
326 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
327 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
329 virtual void SetMapMode(int mode
);
330 virtual int GetMapMode() const { return m_mappingMode
; }
332 virtual void SetUserScale(double x
, double y
);
333 virtual void GetUserScale(double *x
, double *y
) const
335 if ( x
) *x
= m_userScaleX
;
336 if ( y
) *y
= m_userScaleY
;
339 virtual void SetLogicalScale(double x
, double y
);
340 virtual void GetLogicalScale(double *x
, double *y
)
342 if ( x
) *x
= m_logicalScaleX
;
343 if ( y
) *y
= m_logicalScaleY
;
346 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
347 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
349 if ( x
) *x
= m_logicalOriginX
;
350 if ( y
) *y
= m_logicalOriginY
;
353 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
354 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
356 if ( x
) *x
= m_deviceOriginX
;
357 if ( y
) *y
= m_deviceOriginY
;
360 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
362 virtual void ComputeScaleAndOrigin();
364 // this needs to overidden if the axis is inverted
365 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
367 // ---------------------------------------------------------
368 // the actual drawing API
370 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
371 int style
= wxFLOOD_SURFACE
) = 0;
373 virtual void DoGradientFillLinear(const wxRect
& rect
,
374 const wxColour
& initialColour
,
375 const wxColour
& destColour
,
376 wxDirection nDirection
= wxEAST
);
378 virtual void DoGradientFillConcentric(const wxRect
& rect
,
379 const wxColour
& initialColour
,
380 const wxColour
& destColour
,
381 const wxPoint
& circleCenter
);
383 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
385 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
386 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
388 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
389 wxCoord x2
, wxCoord y2
,
390 wxCoord xc
, wxCoord yc
) = 0;
391 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
392 wxCoord width
, wxCoord height
);
393 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
394 double sa
, double ea
) = 0;
396 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
397 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
398 wxCoord width
, wxCoord height
,
400 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
401 wxCoord width
, wxCoord height
) = 0;
403 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
405 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
406 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
407 bool useMask
= false) = 0;
409 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
410 virtual void DoDrawRotatedText(const wxString
& text
,
411 wxCoord x
, wxCoord y
, double angle
) = 0;
413 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
414 wxCoord width
, wxCoord height
,
416 wxCoord xsrc
, wxCoord ysrc
,
418 bool useMask
= false,
419 wxCoord xsrcMask
= wxDefaultCoord
,
420 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
422 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
423 wxCoord dstWidth
, wxCoord dstHeight
,
425 wxCoord xsrc
, wxCoord ysrc
,
426 wxCoord srcWidth
, wxCoord srcHeight
,
428 bool useMask
= false,
429 wxCoord xsrcMask
= wxDefaultCoord
,
430 wxCoord ysrcMask
= wxDefaultCoord
);
432 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
433 { return wxNullBitmap
; }
436 virtual void DoDrawLines(int n
, wxPoint points
[],
437 wxCoord xoffset
, wxCoord yoffset
) = 0;
438 virtual void DrawLines(const wxPointList
*list
,
439 wxCoord xoffset
, wxCoord yoffset
);
441 virtual void DoDrawPolygon(int n
, wxPoint points
[],
442 wxCoord xoffset
, wxCoord yoffset
,
443 int fillStyle
= wxODDEVEN_RULE
) = 0;
444 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
445 wxCoord xoffset
, wxCoord yoffset
,
447 void DrawPolygon(const wxPointList
*list
,
448 wxCoord xoffset
, wxCoord yoffset
,
453 virtual void DoDrawSpline(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
, wxCoord x3
, wxCoord y3
);
454 virtual void DoDrawSpline(int n
, wxPoint points
[]);
455 virtual void DoDrawSpline(const wxPointList
*points
);
458 // ---------------------------------------------------------
459 // wxMemoryDC Impl API
461 virtual void DoSelect(const wxBitmap
& WXUNUSED(bmp
))
464 virtual const wxBitmap
& GetSelectedBitmap() const
465 { return wxNullBitmap
; }
466 virtual wxBitmap
& GetSelectedBitmap()
467 { return wxNullBitmap
; }
469 // ---------------------------------------------------------
470 // wxPrinterDC Impl API
472 virtual wxRect
GetPaperRect()
473 { int w
= 0; int h
= 0; DoGetSize( &w
, &h
); return wxRect(0,0,w
,h
); }
475 virtual int GetResolution()
482 // unset clipping variables (after clipping region was destroyed)
487 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
494 bool m_isInteractive
:1;
495 bool m_isBBoxValid
:1;
497 // coordinate system variables
499 wxCoord m_logicalOriginX
, m_logicalOriginY
;
500 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
502 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
503 // is not at 0,0. This was the case under
504 // Mac's GrafPorts (coordinate system
505 // used toplevel window's origin) and
506 // e.g. for Postscript, where the native
507 // origin in the bottom left corner.
508 double m_logicalScaleX
, m_logicalScaleY
;
509 double m_userScaleX
, m_userScaleY
;
510 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
512 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
514 // what is a mm on a screen you don't know the size of?
515 double m_mm_to_pix_x
,
518 // bounding and clipping boxes
519 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
520 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
522 int m_logicalFunction
;
523 int m_backgroundMode
;
528 wxBrush m_backgroundBrush
;
529 wxColour m_textForegroundColour
;
530 wxColour m_textBackgroundColour
;
535 bool m_hasCustomPalette
;
536 #endif // wxUSE_PALETTE
539 DECLARE_ABSTRACT_CLASS(wxImplDC
)
543 class wxDC
: public wxObject
546 wxDC() { m_pimpl
= NULL
; }
550 const wxImplDC
*GetImpl() const
555 { return m_pimpl
&& m_pimpl
->IsOk(); }
557 // query capabilities
559 bool CanDrawBitmap() const
560 { return m_pimpl
->CanDrawBitmap(); }
561 bool CanGetTextExtent() const
562 { return m_pimpl
->CanGetTextExtent(); }
564 // query dimension, colour deps, resolution
566 void GetSize(int *width
, int *height
) const
567 { m_pimpl
->DoGetSize(width
, height
); }
569 wxSize
GetSize() const
572 m_pimpl
->DoGetSize(&w
, &h
);
576 void GetSizeMM(int* width
, int* height
) const
577 { m_pimpl
->DoGetSizeMM(width
, height
); }
578 wxSize
GetSizeMM() const
581 m_pimpl
->DoGetSizeMM(&w
, &h
);
586 { return m_pimpl
->GetDepth(); }
587 wxSize
GetPPI() const
588 { return m_pimpl
->GetPPI(); }
590 virtual int GetResolution()
591 { return m_pimpl
->GetResolution(); }
593 // Right-To-Left (RTL) modes
595 void SetLayoutDirection(wxLayoutDirection dir
)
596 { m_pimpl
->SetLayoutDirection( dir
); }
597 wxLayoutDirection
GetLayoutDirection() const
598 { return m_pimpl
->GetLayoutDirection(); }
602 bool StartDoc(const wxString
& message
)
603 { return m_pimpl
->StartDoc(message
); }
605 { m_pimpl
->EndDoc(); }
608 { m_pimpl
->StartPage(); }
610 { m_pimpl
->EndPage(); }
614 void CalcBoundingBox(wxCoord x
, wxCoord y
)
615 { m_pimpl
->CalcBoundingBox(x
,y
); }
616 void ResetBoundingBox()
617 { m_pimpl
->ResetBoundingBox(); }
620 { return m_pimpl
->MinX(); }
622 { return m_pimpl
->MaxX(); }
624 { return m_pimpl
->MinY(); }
626 { return m_pimpl
->MaxY(); }
628 // setters and getters
630 void SetFont(const wxFont
& font
)
631 { m_pimpl
->SetFont( font
); }
632 const wxFont
& GetFont() const
633 { return m_pimpl
->GetFont(); }
635 void SetPen(const wxPen
& pen
)
636 { m_pimpl
->SetPen( pen
); }
637 const wxPen
& GetPen() const
638 { return m_pimpl
->GetPen(); }
640 void SetBrush(const wxBrush
& brush
)
641 { m_pimpl
->SetBrush( brush
); }
642 const wxBrush
& GetBrush() const
643 { return m_pimpl
->GetBrush(); }
645 void SetBackground(const wxBrush
& brush
)
646 { m_pimpl
->SetBackground( brush
); }
647 const wxBrush
& GetBackground() const
648 { return m_pimpl
->GetBackground(); }
650 void SetBackgroundMode(int mode
)
651 { m_pimpl
->SetBackgroundMode( mode
); }
652 int GetBackgroundMode() const
653 { return m_pimpl
->GetBackgroundMode(); }
655 void SetTextForeground(const wxColour
& colour
)
656 { m_pimpl
->SetTextForeground(colour
); }
657 const wxColour
& GetTextForeground() const
658 { return m_pimpl
->GetTextForeground(); }
660 void SetTextBackground(const wxColour
& colour
)
661 { m_pimpl
->SetTextBackground(colour
); }
662 const wxColour
& GetTextBackground() const
663 { return m_pimpl
->GetTextBackground(); }
666 void SetPalette(const wxPalette
& palette
)
667 { m_pimpl
->SetPalette(palette
); }
668 #endif // wxUSE_PALETTE
672 void SetLogicalFunction(int function
)
673 { m_pimpl
->SetLogicalFunction(function
); }
674 int GetLogicalFunction() const
675 { return m_pimpl
->GetLogicalFunction(); }
679 wxCoord
GetCharHeight() const
680 { return m_pimpl
->GetCharHeight(); }
681 wxCoord
GetCharWidth() const
682 { return m_pimpl
->GetCharWidth(); }
684 void GetTextExtent(const wxString
& string
,
685 wxCoord
*x
, wxCoord
*y
,
686 wxCoord
*descent
= NULL
,
687 wxCoord
*externalLeading
= NULL
,
688 const wxFont
*theFont
= NULL
) const
689 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
691 wxSize
GetTextExtent(const wxString
& string
) const
694 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
698 void GetMultiLineTextExtent(const wxString
& string
,
701 wxCoord
*heightLine
= NULL
,
702 const wxFont
*font
= NULL
) const
703 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
705 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
708 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
712 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
713 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
718 { m_pimpl
->Clear(); }
722 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
723 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
724 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
725 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
726 void SetClippingRegion(const wxRect
& rect
)
727 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
728 void SetClippingRegion(const wxRegion
& region
)
729 { m_pimpl
->DoSetClippingRegionAsRegion(region
); }
731 void DestroyClippingRegion()
732 { m_pimpl
->DestroyClippingRegion(); }
734 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
735 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
736 void GetClippingBox(wxRect
& rect
) const
737 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
739 // coordinates conversions and transforms
741 wxCoord
DeviceToLogicalX(wxCoord x
) const
742 { return m_pimpl
->DeviceToLogicalX(x
); }
743 wxCoord
DeviceToLogicalY(wxCoord y
) const
744 { return m_pimpl
->DeviceToLogicalY(y
); }
745 wxCoord
DeviceToLogicalXRel(wxCoord x
) const
746 { return m_pimpl
->DeviceToLogicalXRel(x
); }
747 wxCoord
DeviceToLogicalYRel(wxCoord y
) const
748 { return m_pimpl
->DeviceToLogicalYRel(y
); }
749 wxCoord
LogicalToDeviceX(wxCoord x
) const
750 { return m_pimpl
->LogicalToDeviceX(x
); }
751 wxCoord
LogicalToDeviceY(wxCoord y
) const
752 { return m_pimpl
->LogicalToDeviceY(y
); }
753 wxCoord
LogicalToDeviceXRel(wxCoord x
) const
754 { return m_pimpl
->LogicalToDeviceXRel(x
); }
755 wxCoord
LogicalToDeviceYRel(wxCoord y
) const
756 { return m_pimpl
->LogicalToDeviceYRel(y
); }
758 void SetMapMode(int mode
)
759 { m_pimpl
->SetMapMode(mode
); }
760 int GetMapMode() const
761 { return m_pimpl
->GetMapMode(); }
763 void SetUserScale(double x
, double y
)
764 { m_pimpl
->SetUserScale(x
,y
); }
765 void GetUserScale(double *x
, double *y
) const
766 { m_pimpl
->GetUserScale( x
, y
); }
768 void SetLogicalScale(double x
, double y
)
769 { m_pimpl
->SetLogicalScale( x
, y
); }
770 void GetLogicalScale(double *x
, double *y
)
771 { m_pimpl
->GetLogicalScale( x
, y
); }
773 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
774 { m_pimpl
->SetLogicalOrigin(x
,y
); }
775 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
776 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
777 wxPoint
GetLogicalOrigin() const
778 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
780 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
781 { m_pimpl
->SetDeviceOrigin( x
, y
); }
782 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
783 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
784 wxPoint
GetDeviceOrigin() const
785 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
787 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
788 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
791 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
792 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
795 // draw generic object
797 void DrawObject(wxDrawObject
* drawobject
)
799 drawobject
->Draw(*this);
800 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
801 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
804 // -----------------------------------------------
805 // the actual drawing API
807 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
808 int style
= wxFLOOD_SURFACE
)
809 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
810 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
811 int style
= wxFLOOD_SURFACE
)
812 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
814 // fill the area specified by rect with a radial gradient, starting from
815 // initialColour in the centre of the cercle and fading to destColour.
816 void GradientFillConcentric(const wxRect
& rect
,
817 const wxColour
& initialColour
,
818 const wxColour
& destColour
)
819 { m_pimpl
->DoGradientFillConcentric( rect
, initialColour
, destColour
,
820 wxPoint(rect
.GetWidth() / 2,
821 rect
.GetHeight() / 2)); }
823 void GradientFillConcentric(const wxRect
& rect
,
824 const wxColour
& initialColour
,
825 const wxColour
& destColour
,
826 const wxPoint
& circleCenter
)
827 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
829 // fill the area specified by rect with a linear gradient
830 void GradientFillLinear(const wxRect
& rect
,
831 const wxColour
& initialColour
,
832 const wxColour
& destColour
,
833 wxDirection nDirection
= wxEAST
)
834 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
836 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
837 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
838 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
839 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
841 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
842 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
843 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
844 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
846 void CrossHair(wxCoord x
, wxCoord y
)
847 { m_pimpl
->DoCrossHair(x
, y
); }
848 void CrossHair(const wxPoint
& pt
)
849 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
851 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
852 wxCoord xc
, wxCoord yc
)
853 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
854 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
855 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
857 void DrawCheckMark(wxCoord x
, wxCoord y
,
858 wxCoord width
, wxCoord height
)
859 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
860 void DrawCheckMark(const wxRect
& rect
)
861 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
863 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
864 double sa
, double ea
)
865 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
866 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
867 double sa
, double ea
)
868 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
870 void DrawPoint(wxCoord x
, wxCoord y
)
871 { m_pimpl
->DoDrawPoint(x
, y
); }
872 void DrawPoint(const wxPoint
& pt
)
873 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
875 void DrawLines(int n
, wxPoint points
[],
876 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
877 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
878 void DrawLines(const wxPointList
*list
,
879 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
880 { m_pimpl
->DrawLines( list
, xoffset
, yoffset
); }
881 #if WXWIN_COMPATIBILITY_2_8
882 wxDEPRECATED( void DrawLines(const wxList
*list
,
883 wxCoord xoffset
= 0, wxCoord yoffset
= 0) );
884 #endif // WXWIN_COMPATIBILITY_2_8
886 void DrawPolygon(int n
, wxPoint points
[],
887 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
888 int fillStyle
= wxODDEVEN_RULE
)
889 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
890 void DrawPolygon(const wxPointList
*list
,
891 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
892 int fillStyle
= wxODDEVEN_RULE
)
893 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
894 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
895 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
896 int fillStyle
= wxODDEVEN_RULE
)
897 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
898 #if WXWIN_COMPATIBILITY_2_8
899 wxDEPRECATED( void DrawPolygon(const wxList
*list
,
900 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
901 int fillStyle
= wxODDEVEN_RULE
) );
902 #endif // WXWIN_COMPATIBILITY_2_8
904 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
905 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
906 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
907 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
908 void DrawRectangle(const wxRect
& rect
)
909 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
911 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
913 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
914 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
916 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
917 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
918 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
920 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
921 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
922 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
923 { m_pimpl
->DoDrawEllipse(pt
.x
- radius
, pt
.y
- radius
, 2*radius
, 2*radius
); }
925 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
926 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
927 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
928 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
929 void DrawEllipse(const wxRect
& rect
)
930 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
932 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
933 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
934 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
935 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
937 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
938 bool useMask
= false)
939 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
940 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
941 bool useMask
= false)
942 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
944 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
945 { m_pimpl
->DoDrawText(text
, x
, y
); }
946 void DrawText(const wxString
& text
, const wxPoint
& pt
)
947 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
949 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
950 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
951 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
952 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
954 // this version puts both optional bitmap and the text into the given
955 // rectangle and aligns is as specified by alignment parameter; it also
956 // will emphasize the character with the given index if it is != -1 and
957 // return the bounding rectangle if required
958 void DrawLabel(const wxString
& text
,
959 const wxBitmap
& image
,
961 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
963 wxRect
*rectBounding
= NULL
);
965 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
966 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
968 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
970 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
971 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
972 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
974 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
975 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
977 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
978 wxDC
*source
, const wxPoint
& srcPt
,
979 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
981 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
982 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
985 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
986 wxCoord dstWidth
, wxCoord dstHeight
,
988 wxCoord srcX
, wxCoord srcY
,
989 wxCoord srcWidth
, wxCoord srcHeight
,
990 int rop
= wxCOPY
, bool useMask
= false,
991 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
993 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
994 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
996 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
997 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
998 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1000 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1001 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1004 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1006 return m_pimpl
->DoGetAsBitmap(subrect
);
1010 void DrawSpline(wxCoord x1
, wxCoord y1
,
1011 wxCoord x2
, wxCoord y2
,
1012 wxCoord x3
, wxCoord y3
)
1013 { m_pimpl
->DoDrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
1014 void DrawSpline(int n
, wxPoint points
[])
1015 { m_pimpl
->DoDrawSpline(n
,points
); }
1016 void DrawSpline(const wxPointList
*points
)
1017 { m_pimpl
->DoDrawSpline(points
); }
1018 #endif // wxUSE_SPLINES
1021 #if WXWIN_COMPATIBILITY_2_8
1022 // for compatibility with the old code when wxCoord was long everywhere
1023 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1025 long *descent
= NULL
,
1026 long *externalLeading
= NULL
,
1027 const wxFont
*theFont
= NULL
) const );
1028 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1029 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1030 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1031 #endif // WXWIN_COMPATIBILITY_2_8
1038 DECLARE_ABSTRACT_CLASS(wxImplDC
)
1042 //-----------------------------------------------------------------------------
1044 //-----------------------------------------------------------------------------
1046 class WXDLLIMPEXP_CORE wxWindowDC
: public wxDC
1050 wxWindowDC( wxWindow
*win
);
1053 DECLARE_DYNAMIC_CLASS(wxWindowDC
)
1056 //-----------------------------------------------------------------------------
1058 //-----------------------------------------------------------------------------
1060 class WXDLLIMPEXP_CORE wxClientDC
: public wxDC
1064 wxClientDC( wxWindow
*win
);
1067 DECLARE_DYNAMIC_CLASS(wxClientDC
)
1070 //-----------------------------------------------------------------------------
1072 //-----------------------------------------------------------------------------
1074 class WXDLLIMPEXP_CORE wxPaintDC
: public wxDC
1078 wxPaintDC( wxWindow
*win
);
1081 DECLARE_DYNAMIC_CLASS(wxPaintDC
)
1084 #else // wxUSE_NEW_DC
1087 class WXDLLIMPEXP_FWD_CORE wxDC
;
1089 // ---------------------------------------------------------------------------
1091 // ---------------------------------------------------------------------------
1093 // ---------------------------------------------------------------------------
1094 // wxDC is the device context - object on which any drawing is done
1095 // ---------------------------------------------------------------------------
1097 class WXDLLEXPORT wxDCBase
: public wxObject
1101 virtual ~wxDCBase();
1103 // graphic primitives
1104 // ------------------
1106 virtual void DrawObject(wxDrawObject
* drawobject
)
1108 drawobject
->Draw(*this);
1109 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
1110 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
1113 wxDC
*GetOwner() const { return (wxDC
*) this; }
1115 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1116 int style
= wxFLOOD_SURFACE
)
1117 { return DoFloodFill(x
, y
, col
, style
); }
1118 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
1119 int style
= wxFLOOD_SURFACE
)
1120 { return DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
1122 // fill the area specified by rect with a radial gradient, starting from
1123 // initialColour in the centre of the cercle and fading to destColour.
1124 void GradientFillConcentric(const wxRect
& rect
,
1125 const wxColour
& initialColour
,
1126 const wxColour
& destColour
)
1127 { GradientFillConcentric(rect
, initialColour
, destColour
,
1128 wxPoint(rect
.GetWidth() / 2,
1129 rect
.GetHeight() / 2)); }
1131 void GradientFillConcentric(const wxRect
& rect
,
1132 const wxColour
& initialColour
,
1133 const wxColour
& destColour
,
1134 const wxPoint
& circleCenter
)
1135 { DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
1137 // fill the area specified by rect with a linear gradient
1138 void GradientFillLinear(const wxRect
& rect
,
1139 const wxColour
& initialColour
,
1140 const wxColour
& destColour
,
1141 wxDirection nDirection
= wxEAST
)
1142 { DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
1144 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
1145 { return DoGetPixel(x
, y
, col
); }
1146 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
1147 { return DoGetPixel(pt
.x
, pt
.y
, col
); }
1149 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1150 { DoDrawLine(x1
, y1
, x2
, y2
); }
1151 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
1152 { DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
1154 void CrossHair(wxCoord x
, wxCoord y
)
1155 { DoCrossHair(x
, y
); }
1156 void CrossHair(const wxPoint
& pt
)
1157 { DoCrossHair(pt
.x
, pt
.y
); }
1159 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
1160 wxCoord xc
, wxCoord yc
)
1161 { DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
1162 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
1163 { DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
1165 void DrawCheckMark(wxCoord x
, wxCoord y
,
1166 wxCoord width
, wxCoord height
)
1167 { DoDrawCheckMark(x
, y
, width
, height
); }
1168 void DrawCheckMark(const wxRect
& rect
)
1169 { DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1171 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1172 double sa
, double ea
)
1173 { DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
1174 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
1175 double sa
, double ea
)
1176 { DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
1178 void DrawPoint(wxCoord x
, wxCoord y
)
1179 { DoDrawPoint(x
, y
); }
1180 void DrawPoint(const wxPoint
& pt
)
1181 { DoDrawPoint(pt
.x
, pt
.y
); }
1183 void DrawLines(int n
, wxPoint points
[],
1184 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1185 { DoDrawLines(n
, points
, xoffset
, yoffset
); }
1186 void DrawLines(const wxPointList
*list
,
1187 wxCoord xoffset
= 0, wxCoord yoffset
= 0);
1189 #if WXWIN_COMPATIBILITY_2_8
1190 wxDEPRECATED( void DrawLines(const wxList
*list
,
1191 wxCoord xoffset
= 0, wxCoord yoffset
= 0) );
1192 #endif // WXWIN_COMPATIBILITY_2_8
1195 void DrawPolygon(int n
, wxPoint points
[],
1196 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1197 int fillStyle
= wxODDEVEN_RULE
)
1198 { DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
1200 void DrawPolygon(const wxPointList
*list
,
1201 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1202 int fillStyle
= wxODDEVEN_RULE
);
1204 #if WXWIN_COMPATIBILITY_2_8
1205 wxDEPRECATED( void DrawPolygon(const wxList
*list
,
1206 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1207 int fillStyle
= wxODDEVEN_RULE
) );
1208 #endif // WXWIN_COMPATIBILITY_2_8
1210 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1211 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1212 int fillStyle
= wxODDEVEN_RULE
)
1213 { DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
1215 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1216 { DoDrawRectangle(x
, y
, width
, height
); }
1217 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
1218 { DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1219 void DrawRectangle(const wxRect
& rect
)
1220 { DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1222 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
1224 { DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
1225 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
1227 { DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
1228 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
1229 { DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1231 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1232 { DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1233 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1234 { DrawCircle(pt
.x
, pt
.y
, radius
); }
1236 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1237 { DoDrawEllipse(x
, y
, width
, height
); }
1238 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1239 { DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1240 void DrawEllipse(const wxRect
& rect
)
1241 { DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1243 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1244 { DoDrawIcon(icon
, x
, y
); }
1245 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1246 { DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1248 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1249 bool useMask
= false)
1250 { DoDrawBitmap(bmp
, x
, y
, useMask
); }
1251 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1252 bool useMask
= false)
1253 { DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1255 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1256 { DoDrawText(text
, x
, y
); }
1257 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1258 { DoDrawText(text
, pt
.x
, pt
.y
); }
1260 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1261 { DoDrawRotatedText(text
, x
, y
, angle
); }
1262 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1263 { DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1265 // this version puts both optional bitmap and the text into the given
1266 // rectangle and aligns is as specified by alignment parameter; it also
1267 // will emphasize the character with the given index if it is != -1 and
1268 // return the bounding rectangle if required
1269 virtual void DrawLabel(const wxString
& text
,
1270 const wxBitmap
& image
,
1272 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1273 int indexAccel
= -1,
1274 wxRect
*rectBounding
= NULL
);
1276 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1277 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1278 int indexAccel
= -1)
1279 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1281 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1282 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1283 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1285 return DoBlit(xdest
, ydest
, width
, height
,
1286 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1288 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1289 wxDC
*source
, const wxPoint
& srcPt
,
1290 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
1292 return DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1293 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1296 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1297 wxCoord dstWidth
, wxCoord dstHeight
,
1299 wxCoord srcX
, wxCoord srcY
,
1300 wxCoord srcWidth
, wxCoord srcHeight
,
1301 int rop
= wxCOPY
, bool useMask
= false,
1302 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1304 return DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1305 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1307 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1308 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1309 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1311 return DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1312 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1315 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1317 return DoGetAsBitmap(subrect
);
1321 void DrawSpline(wxCoord x1
, wxCoord y1
,
1322 wxCoord x2
, wxCoord y2
,
1323 wxCoord x3
, wxCoord y3
);
1324 void DrawSpline(int n
, wxPoint points
[]);
1326 void DrawSpline(const wxPointList
*points
) { DoDrawSpline(points
); }
1328 #if WXWIN_COMPATIBILITY_2_8
1329 wxDEPRECATED( void DrawSpline(const wxList
*points
) );
1330 #endif // WXWIN_COMPATIBILITY_2_8
1332 #endif // wxUSE_SPLINES
1334 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
1336 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
1337 /*! \param x Upper left corner of bounding box.
1338 * \param y Upper left corner of bounding box.
1339 * \param w Width of bounding box.
1340 * \param h Height of bounding box.
1341 * \param sa Starting angle of arc
1342 * (counterclockwise, start at 3 o'clock, 360 is full circle).
1343 * \param ea Ending angle of arc.
1344 * \param angle Rotation angle, the Arc will be rotated after
1345 * calculating begin and end.
1347 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
1348 wxCoord width
, wxCoord height
,
1349 double sa
= 0, double ea
= 0, double angle
= 0 )
1350 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
1352 void DrawEllipticArcRot( const wxPoint
& pt
,
1354 double sa
= 0, double ea
= 0, double angle
= 0 )
1355 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
1357 void DrawEllipticArcRot( const wxRect
& rect
,
1358 double sa
= 0, double ea
= 0, double angle
= 0 )
1359 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
1361 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
1362 wxCoord w
, wxCoord h
,
1363 double sa
= 0, double ea
= 0, double angle
= 0 );
1365 //! Rotates points around center.
1366 /*! This is a quite straight method, it calculates in pixels
1367 * and so it produces rounding errors.
1368 * \param points The points inside will be rotated.
1369 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
1370 * \param center Center of rotation.
1372 void Rotate( wxPointList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
1374 // used by DrawEllipticArcRot
1375 // Careful: wxList gets filled with points you have to delete later.
1376 void CalculateEllipticPoints( wxPointList
* points
,
1377 wxCoord xStart
, wxCoord yStart
,
1378 wxCoord w
, wxCoord h
,
1379 double sa
, double ea
);
1382 // global DC operations
1383 // --------------------
1385 virtual void Clear() = 0;
1387 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
1388 virtual void EndDoc() { }
1390 virtual void StartPage() { }
1391 virtual void EndPage() { }
1393 #if WXWIN_COMPATIBILITY_2_6
1394 wxDEPRECATED( void BeginDrawing() );
1395 wxDEPRECATED( void EndDrawing() );
1396 #endif // WXWIN_COMPATIBILITY_2_6
1399 // set objects to use for drawing
1400 // ------------------------------
1402 virtual void SetFont(const wxFont
& font
) = 0;
1403 virtual void SetPen(const wxPen
& pen
) = 0;
1404 virtual void SetBrush(const wxBrush
& brush
) = 0;
1405 virtual void SetBackground(const wxBrush
& brush
) = 0;
1406 virtual void SetBackgroundMode(int mode
) = 0;
1408 virtual void SetPalette(const wxPalette
& palette
) = 0;
1409 #endif // wxUSE_PALETTE
1414 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1415 { DoSetClippingRegion(x
, y
, width
, height
); }
1416 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
1417 { DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1418 void SetClippingRegion(const wxRect
& rect
)
1419 { DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1420 void SetClippingRegion(const wxRegion
& region
)
1421 { DoSetClippingRegionAsRegion(region
); }
1423 virtual void DestroyClippingRegion() { ResetClipping(); }
1425 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
1426 { DoGetClippingBox(x
, y
, w
, h
); }
1427 void GetClippingBox(wxRect
& rect
) const
1429 DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
);
1435 virtual wxCoord
GetCharHeight() const = 0;
1436 virtual wxCoord
GetCharWidth() const = 0;
1438 // only works for single line strings
1439 void GetTextExtent(const wxString
& string
,
1440 wxCoord
*x
, wxCoord
*y
,
1441 wxCoord
*descent
= NULL
,
1442 wxCoord
*externalLeading
= NULL
,
1443 const wxFont
*theFont
= NULL
) const
1444 { DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
1446 wxSize
GetTextExtent(const wxString
& string
) const
1449 DoGetTextExtent(string
, &w
, &h
);
1450 return wxSize(w
, h
);
1453 // works for single as well as multi-line strings
1454 virtual void GetMultiLineTextExtent(const wxString
& string
,
1457 wxCoord
*heightLine
= NULL
,
1458 const wxFont
*font
= NULL
) const;
1460 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
1463 GetMultiLineTextExtent(string
, &w
, &h
);
1464 return wxSize(w
, h
);
1467 // Measure cumulative width of text after each character
1468 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1469 { return DoGetPartialTextExtents(text
, widths
); }
1472 // size and resolution
1473 // -------------------
1476 void GetSize(int *width
, int *height
) const
1477 { DoGetSize(width
, height
); }
1478 wxSize
GetSize() const
1483 return wxSize(w
, h
);
1487 void GetSizeMM(int* width
, int* height
) const
1488 { DoGetSizeMM(width
, height
); }
1489 wxSize
GetSizeMM() const
1492 DoGetSizeMM(&w
, &h
);
1494 return wxSize(w
, h
);
1497 // query DC capabilities
1498 // ---------------------
1500 virtual bool CanDrawBitmap() const = 0;
1501 virtual bool CanGetTextExtent() const = 0;
1504 virtual int GetDepth() const = 0;
1506 // Resolution in Pixels per inch
1507 virtual wxSize
GetPPI() const = 0;
1509 virtual int GetResolution()
1512 virtual bool Ok() const { return IsOk(); }
1513 virtual bool IsOk() const { return m_ok
; }
1515 // accessors and setters
1516 // ---------------------
1518 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
1519 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
1520 virtual const wxBrush
& GetBrush() const { return m_brush
; }
1521 virtual const wxFont
& GetFont() const { return m_font
; }
1522 virtual const wxPen
& GetPen() const { return m_pen
; }
1524 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
1525 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
1526 virtual void SetTextForeground(const wxColour
& colour
)
1527 { m_textForegroundColour
= colour
; }
1528 virtual void SetTextBackground(const wxColour
& colour
)
1529 { m_textBackgroundColour
= colour
; }
1532 // coordinates conversions and transforms
1533 // --------------------------------------
1535 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
1536 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
1537 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
1538 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
1539 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
1540 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
1541 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
1542 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
1544 virtual void SetMapMode(int mode
);
1545 virtual int GetMapMode() const { return m_mappingMode
; }
1547 virtual void SetUserScale(double x
, double y
);
1548 virtual void GetUserScale(double *x
, double *y
) const
1550 if ( x
) *x
= m_userScaleX
;
1551 if ( y
) *y
= m_userScaleY
;
1554 virtual void SetLogicalScale(double x
, double y
);
1555 virtual void GetLogicalScale(double *x
, double *y
)
1557 if ( x
) *x
= m_logicalScaleX
;
1558 if ( y
) *y
= m_logicalScaleY
;
1561 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
1562 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1563 { DoGetLogicalOrigin(x
, y
); }
1564 wxPoint
GetLogicalOrigin() const
1565 { wxCoord x
, y
; DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
1567 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
1568 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1569 { DoGetDeviceOrigin(x
, y
); }
1570 wxPoint
GetDeviceOrigin() const
1571 { wxCoord x
, y
; DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
1573 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
1575 virtual void ComputeScaleAndOrigin();
1577 // this needs to overidden if the axis is inverted (such
1578 // as when using Postscript, where 0,0 is the lower left
1579 // corner, not the upper left).
1580 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
1582 // logical functions
1583 // ---------------------------
1585 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
1586 virtual void SetLogicalFunction(int function
) = 0;
1591 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
1593 if ( m_isBBoxValid
)
1595 if ( x
< m_minX
) m_minX
= x
;
1596 if ( y
< m_minY
) m_minY
= y
;
1597 if ( x
> m_maxX
) m_maxX
= x
;
1598 if ( y
> m_maxY
) m_maxY
= y
;
1602 m_isBBoxValid
= true;
1611 void ResetBoundingBox()
1613 m_isBBoxValid
= false;
1615 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
1618 // Get the final bounding box of the PostScript or Metafile picture.
1619 wxCoord
MinX() const { return m_minX
; }
1620 wxCoord
MaxX() const { return m_maxX
; }
1621 wxCoord
MinY() const { return m_minY
; }
1622 wxCoord
MaxY() const { return m_maxY
; }
1624 // misc old functions
1625 // ------------------
1627 #if WXWIN_COMPATIBILITY_2_8
1628 // for compatibility with the old code when wxCoord was long everywhere
1629 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1631 long *descent
= NULL
,
1632 long *externalLeading
= NULL
,
1633 const wxFont
*theFont
= NULL
) const );
1634 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1635 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1636 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1637 #endif // WXWIN_COMPATIBILITY_2_8
1639 // RTL related functions
1640 // ---------------------
1642 // get or change the layout direction (LTR or RTL) for this dc,
1643 // wxLayout_Default is returned if layout direction is not supported
1644 virtual wxLayoutDirection
GetLayoutDirection() const
1645 { return wxLayout_Default
; }
1646 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
))
1650 // the pure virtual functions which should be implemented by wxDC
1651 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1652 int style
= wxFLOOD_SURFACE
) = 0;
1654 virtual void DoGradientFillLinear(const wxRect
& rect
,
1655 const wxColour
& initialColour
,
1656 const wxColour
& destColour
,
1657 wxDirection nDirection
= wxEAST
);
1659 virtual void DoGradientFillConcentric(const wxRect
& rect
,
1660 const wxColour
& initialColour
,
1661 const wxColour
& destColour
,
1662 const wxPoint
& circleCenter
);
1664 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
1666 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
1667 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
1669 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
1670 wxCoord x2
, wxCoord y2
,
1671 wxCoord xc
, wxCoord yc
) = 0;
1672 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
1673 wxCoord width
, wxCoord height
);
1674 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1675 double sa
, double ea
) = 0;
1677 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
1678 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1679 wxCoord width
, wxCoord height
,
1681 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
1682 wxCoord width
, wxCoord height
) = 0;
1684 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
1686 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
1687 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1688 bool useMask
= false) = 0;
1690 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
1691 virtual void DoDrawRotatedText(const wxString
& text
,
1692 wxCoord x
, wxCoord y
, double angle
) = 0;
1694 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
1695 wxCoord width
, wxCoord height
,
1697 wxCoord xsrc
, wxCoord ysrc
,
1699 bool useMask
= false,
1700 wxCoord xsrcMask
= wxDefaultCoord
,
1701 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
1703 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
1704 wxCoord dstWidth
, wxCoord dstHeight
,
1706 wxCoord xsrc
, wxCoord ysrc
,
1707 wxCoord srcWidth
, wxCoord srcHeight
,
1709 bool useMask
= false,
1710 wxCoord xsrcMask
= wxDefaultCoord
,
1711 wxCoord ysrcMask
= wxDefaultCoord
);
1713 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
1714 { return wxNullBitmap
; }
1716 virtual void DoGetSize(int *width
, int *height
) const = 0;
1717 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
1719 virtual void DoDrawLines(int n
, wxPoint points
[],
1720 wxCoord xoffset
, wxCoord yoffset
) = 0;
1721 virtual void DoDrawPolygon(int n
, wxPoint points
[],
1722 wxCoord xoffset
, wxCoord yoffset
,
1723 int fillStyle
= wxODDEVEN_RULE
) = 0;
1724 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1725 wxCoord xoffset
, wxCoord yoffset
,
1728 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
1729 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
1730 wxCoord width
, wxCoord height
) = 0;
1732 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
1733 wxCoord
*w
, wxCoord
*h
) const
1740 *w
= m_clipX2
- m_clipX1
;
1742 *h
= m_clipY2
- m_clipY1
;
1745 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1747 if ( x
) *x
= m_logicalOriginX
;
1748 if ( y
) *y
= m_logicalOriginY
;
1751 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1753 if ( x
) *x
= m_deviceOriginX
;
1754 if ( y
) *y
= m_deviceOriginY
;
1757 virtual void DoGetTextExtent(const wxString
& string
,
1758 wxCoord
*x
, wxCoord
*y
,
1759 wxCoord
*descent
= NULL
,
1760 wxCoord
*externalLeading
= NULL
,
1761 const wxFont
*theFont
= NULL
) const = 0;
1763 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
1766 virtual void DoDrawSpline(const wxPointList
*points
);
1770 // unset clipping variables (after clipping region was destroyed)
1771 void ResetClipping()
1775 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
1782 bool m_isInteractive
:1;
1783 bool m_isBBoxValid
:1;
1785 // coordinate system variables
1787 // TODO short descriptions of what exactly they are would be nice...
1789 wxCoord m_logicalOriginX
, m_logicalOriginY
;
1790 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
1792 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
1793 // is not at 0,0. This was the case under
1794 // Mac's GrafPorts (coordinate system
1795 // used toplevel window's origin) and
1796 // e.g. for Postscript, where the native
1797 // origin in the bottom left corner.
1798 double m_logicalScaleX
, m_logicalScaleY
;
1799 double m_userScaleX
, m_userScaleY
;
1800 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
1802 // Used by SetAxisOrientation() to invert the axes
1803 int m_signX
, m_signY
;
1805 // what is a mm on a screen you don't know the size of?
1806 double m_mm_to_pix_x
,
1809 // bounding and clipping boxes
1810 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
1811 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
1813 int m_logicalFunction
;
1814 int m_backgroundMode
;
1820 wxBrush m_backgroundBrush
;
1821 wxColour m_textForegroundColour
;
1822 wxColour m_textBackgroundColour
;
1826 wxPalette m_palette
;
1827 bool m_hasCustomPalette
;
1828 #endif // wxUSE_PALETTE
1831 DECLARE_NO_COPY_CLASS(wxDCBase
)
1832 DECLARE_ABSTRACT_CLASS(wxDCBase
)
1835 #endif // wxUSE_NEW_DC
1837 // ----------------------------------------------------------------------------
1838 // now include the declaration of wxDC class
1839 // ----------------------------------------------------------------------------
1841 #if defined(__WXPALMOS__)
1842 #include "wx/palmos/dc.h"
1843 #elif defined(__WXMSW__)
1844 #include "wx/msw/dc.h"
1845 #elif defined(__WXMOTIF__)
1846 #include "wx/motif/dc.h"
1847 #elif defined(__WXGTK20__)
1848 #include "wx/gtk/dc.h"
1849 #elif defined(__WXGTK__)
1850 #include "wx/gtk1/dc.h"
1851 #elif defined(__WXX11__)
1852 #include "wx/x11/dc.h"
1853 #elif defined(__WXMGL__)
1854 #include "wx/mgl/dc.h"
1855 #elif defined(__WXDFB__)
1856 #include "wx/dfb/dc.h"
1857 #elif defined(__WXMAC__)
1858 #include "wx/mac/dc.h"
1859 #elif defined(__WXCOCOA__)
1860 #include "wx/cocoa/dc.h"
1861 #elif defined(__WXPM__)
1862 #include "wx/os2/dc.h"
1865 #if wxUSE_GRAPHICS_CONTEXT
1866 #include "wx/dcgraph.h"
1869 // ----------------------------------------------------------------------------
1870 // helper class: you can use it to temporarily change the DC text colour and
1871 // restore it automatically when the object goes out of scope
1872 // ----------------------------------------------------------------------------
1874 class WXDLLEXPORT wxDCTextColourChanger
1877 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1879 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1884 ~wxDCTextColourChanger()
1886 if ( m_colFgOld
.Ok() )
1887 m_dc
.SetTextForeground(m_colFgOld
);
1890 void Set(const wxColour
& col
)
1892 if ( !m_colFgOld
.Ok() )
1893 m_colFgOld
= m_dc
.GetTextForeground();
1894 m_dc
.SetTextForeground(col
);
1900 wxColour m_colFgOld
;
1902 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
1905 // ----------------------------------------------------------------------------
1906 // helper class: you can use it to temporarily change the DC pen and
1907 // restore it automatically when the object goes out of scope
1908 // ----------------------------------------------------------------------------
1910 class WXDLLEXPORT wxDCPenChanger
1913 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1920 if ( m_penOld
.Ok() )
1921 m_dc
.SetPen(m_penOld
);
1929 DECLARE_NO_COPY_CLASS(wxDCPenChanger
)
1932 // ----------------------------------------------------------------------------
1933 // helper class: you can use it to temporarily change the DC brush and
1934 // restore it automatically when the object goes out of scope
1935 // ----------------------------------------------------------------------------
1937 class WXDLLEXPORT wxDCBrushChanger
1940 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1942 m_dc
.SetBrush(brush
);
1947 if ( m_brushOld
.Ok() )
1948 m_dc
.SetBrush(m_brushOld
);
1956 DECLARE_NO_COPY_CLASS(wxDCBrushChanger
)
1959 // ----------------------------------------------------------------------------
1960 // another small helper class: sets the clipping region in its ctor and
1961 // destroys it in the dtor
1962 // ----------------------------------------------------------------------------
1964 class WXDLLEXPORT wxDCClipper
1967 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1968 { dc
.SetClippingRegion(r
); }
1969 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1970 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1971 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1972 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1974 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1979 DECLARE_NO_COPY_CLASS(wxDCClipper
)
1982 #endif // _WX_DC_H_BASE_