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
40 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
44 class WXDLLIMPEXP_FWD_CORE wxImplDC
;
46 class WXDLLIMPEXP_CORE wxDCFactory
50 virtual ~wxDCFactory() {}
52 virtual wxImplDC
* CreateWindowDC() = 0;
53 virtual wxImplDC
* CreateWindowDC( wxWindow
*window
) = 0;
54 virtual wxImplDC
* CreateClientDC() = 0;
55 virtual wxImplDC
* CreateClientDC( wxWindow
*window
) = 0;
56 virtual wxImplDC
* CreatePaintDC() = 0;
57 virtual wxImplDC
* CreatePaintDC( wxWindow
*window
) = 0;
58 virtual wxImplDC
* CreateMemoryDC() = 0;
59 virtual wxImplDC
* CreateMemoryDC( wxBitmap
&bitmap
) = 0;
60 virtual wxImplDC
* CreateMemoryDC( wxDC
*dc
) = 0;
62 static void SetDCFactory( wxDCFactory
*factory
);
63 static wxDCFactory
*GetFactory();
65 static wxDCFactory
*m_factory
;
68 //-----------------------------------------------------------------------------
70 //-----------------------------------------------------------------------------
72 class WXDLLIMPEXP_CORE wxDCFactory
75 wxNativeDCFactory() {}
77 virtual wxImplDC
* CreateWindowDC();
78 virtual wxImplDC
* CreateWindowDC( wxWindow
*window
);
79 virtual wxImplDC
* CreateClientDC();
80 virtual wxImplDC
* CreateClientDC( wxWindow
*window
);
81 virtual wxImplDC
* CreatePaintDC();
82 virtual wxImplDC
* CreatePaintDC( wxWindow
*window
);
83 virtual wxImplDC
* CreateMemoryDC();
84 virtual wxImplDC
* CreateMemoryDC( wxBitmap
&bitmap
);
85 virtual wxImplDC
* CreateMemoryDC( wxDC
*dc
);
88 //-----------------------------------------------------------------------------
90 //-----------------------------------------------------------------------------
92 class WXDLLIMPEXP_CORE wxWindowDC
: public wxDC
96 wxWindowDC( wxWindow
*win
);
99 DECLARE_DYNAMIC_CLASS(wxWindowDC
)
102 //-----------------------------------------------------------------------------
104 //-----------------------------------------------------------------------------
106 class WXDLLIMPEXP_CORE wxClientDC
: public wxDC
110 wxClientDC( wxWindow
*win
);
113 DECLARE_DYNAMIC_CLASS(wxClientDC
)
116 //-----------------------------------------------------------------------------
118 //-----------------------------------------------------------------------------
120 class WXDLLIMPEXP_CORE wxMemoryDC
: public wxDC
124 wxMemoryDC( wxBitmap
& bitmap
);
125 wxMemoryDC( wxDC
*dc
);
128 DECLARE_DYNAMIC_CLASS(wxMemoryDC
)
131 //-----------------------------------------------------------------------------
133 //-----------------------------------------------------------------------------
135 class WXDLLIMPEXP_CORE wxPaintDC
: public wxDC
139 wxPaintDC( wxWindow
*win
);
142 DECLARE_DYNAMIC_CLASS(wxPaintDC
)
145 //-----------------------------------------------------------------------------
147 //-----------------------------------------------------------------------------
149 class WXDLLIMPEXP_CORE wxImplDC
: public wxObject
152 wxImplDC( wxDC
*owner
);
155 wxDC
*GetOwner() { return m_owner
; }
157 virtual bool IsOk() const { return m_ok
; }
159 // query capabilities
161 virtual bool CanDrawBitmap() const = 0;
162 virtual bool CanGetTextExtent() const = 0;
164 // query dimension, colour deps, resolution
166 virtual void DoGetSize(int *width
, int *height
) const = 0;
167 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
169 virtual int GetDepth() const = 0;
170 virtual wxSize
GetPPI() const = 0;
172 // Right-To-Left (RTL) modes
174 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
)) { }
175 virtual wxLayoutDirection
GetLayoutDirection() const { return wxLayout_Default
; }
179 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
180 virtual void EndDoc() { }
182 virtual void StartPage() { }
183 virtual void EndPage() { }
187 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
);
191 if ( x
< m_minX
) m_minX
= x
;
192 if ( y
< m_minY
) m_minY
= y
;
193 if ( x
> m_maxX
) m_maxX
= x
;
194 if ( y
> m_maxY
) m_maxY
= y
;
198 m_isBBoxValid
= true;
206 void ResetBoundingBox();
208 m_isBBoxValid
= false;
210 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
213 wxCoord
MinX() const { return m_minX
; }
214 wxCoord
MaxX() const { return m_maxX
; }
215 wxCoord
MinY() const { return m_minY
; }
216 wxCoord
MaxY() const { return m_maxY
; }
218 // setters and getters
220 virtual void SetFont(const wxFont
& font
) = 0;
221 virtual const wxFont
& GetFont() const { return m_font
; }
223 virtual void SetPen(const wxPen
& pen
) = 0;
224 virtual const wxPen
& GetPen() const { return m_pen
; }
226 virtual void SetBrush(const wxBrush
& brush
) = 0;
227 virtual const wxBrush
& GetBrush() const { return m_brush
; }
229 virtual void SetBackground(const wxBrush
& brush
) = 0;
230 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
232 virtual void SetBackgroundMode(int mode
) = 0;
233 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
235 virtual void SetTextForeground(const wxColour
& colour
)
236 { m_textForegroundColour
= colour
; }
237 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
239 virtual void SetTextBackground(const wxColour
& colour
)
240 { m_textBackgroundColour
= colour
; }
241 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
244 virtual void SetPalette(const wxPalette
& palette
) = 0;
245 #endif // wxUSE_PALETTE
249 virtual void SetLogicalFunction(int function
) = 0;
250 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
254 virtual wxCoord
GetCharHeight() const = 0;
255 virtual wxCoord
GetCharWidth() const = 0;
256 virtual void DoGetTextExtent(const wxString
& string
,
257 wxCoord
*x
, wxCoord
*y
,
258 wxCoord
*descent
= NULL
,
259 wxCoord
*externalLeading
= NULL
,
260 const wxFont
*theFont
= NULL
) const = 0;
261 virtual void GetMultiLineTextExtent(const wxString
& string
,
264 wxCoord
*heightLine
= NULL
,
265 const wxFont
*font
= NULL
) const;
266 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
270 virtual void Clear() = 0;
274 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
275 wxCoord width
, wxCoord height
) = 0;
276 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
278 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
279 wxCoord
*w
, wxCoord
*h
) const
286 *w
= m_clipX2
- m_clipX1
;
288 *h
= m_clipY2
- m_clipY1
;
291 virtual void DestroyClippingRegion() { ResetClipping(); }
294 // coordinates conversions and transforms
296 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
297 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
298 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
299 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
300 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
301 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
302 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
303 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
305 virtual void SetMapMode(int mode
);
306 virtual int GetMapMode() const { return m_mappingMode
; }
308 virtual void SetUserScale(double x
, double y
);
309 virtual void GetUserScale(double *x
, double *y
) const
311 if ( x
) *x
= m_userScaleX
;
312 if ( y
) *y
= m_userScaleY
;
315 virtual void SetLogicalScale(double x
, double y
);
316 virtual void GetLogicalScale(double *x
, double *y
)
318 if ( x
) *x
= m_logicalScaleX
;
319 if ( y
) *y
= m_logicalScaleY
;
322 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
323 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
325 if ( x
) *x
= m_logicalOriginX
;
326 if ( y
) *y
= m_logicalOriginY
;
329 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
330 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
332 if ( x
) *x
= m_deviceOriginX
;
333 if ( y
) *y
= m_deviceOriginY
;
336 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
338 virtual void ComputeScaleAndOrigin();
340 // this needs to overidden if the axis is inverted
341 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
343 // ---------------------------------------------------------
344 // the actual drawing API
346 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
347 int style
= wxFLOOD_SURFACE
) = 0;
349 virtual void DoGradientFillLinear(const wxRect
& rect
,
350 const wxColour
& initialColour
,
351 const wxColour
& destColour
,
352 wxDirection nDirection
= wxEAST
);
354 virtual void DoGradientFillConcentric(const wxRect
& rect
,
355 const wxColour
& initialColour
,
356 const wxColour
& destColour
,
357 const wxPoint
& circleCenter
);
359 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
361 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
362 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
364 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
365 wxCoord x2
, wxCoord y2
,
366 wxCoord xc
, wxCoord yc
) = 0;
367 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
368 wxCoord width
, wxCoord height
);
369 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
370 double sa
, double ea
) = 0;
372 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
373 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
374 wxCoord width
, wxCoord height
,
376 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
377 wxCoord width
, wxCoord height
) = 0;
379 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
381 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
382 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
383 bool useMask
= false) = 0;
385 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
386 virtual void DoDrawRotatedText(const wxString
& text
,
387 wxCoord x
, wxCoord y
, double angle
) = 0;
389 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
390 wxCoord width
, wxCoord height
,
392 wxCoord xsrc
, wxCoord ysrc
,
394 bool useMask
= false,
395 wxCoord xsrcMask
= wxDefaultCoord
,
396 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
398 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
399 wxCoord dstWidth
, wxCoord dstHeight
,
401 wxCoord xsrc
, wxCoord ysrc
,
402 wxCoord srcWidth
, wxCoord srcHeight
,
404 bool useMask
= false,
405 wxCoord xsrcMask
= wxDefaultCoord
,
406 wxCoord ysrcMask
= wxDefaultCoord
);
408 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
409 { return wxNullBitmap
; }
412 virtual void DoDrawLines(int n
, wxPoint points
[],
413 wxCoord xoffset
, wxCoord yoffset
) = 0;
414 virtual void DoDrawPolygon(int n
, wxPoint points
[],
415 wxCoord xoffset
, wxCoord yoffset
,
416 int fillStyle
= wxODDEVEN_RULE
) = 0;
417 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
418 wxCoord xoffset
, wxCoord yoffset
,
424 virtual void DoDrawSpline(wxList
*points
);
431 // unset clipping variables (after clipping region was destroyed)
436 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
443 bool m_isInteractive
:1;
444 bool m_isBBoxValid
:1;
446 // coordinate system variables
448 wxCoord m_logicalOriginX
, m_logicalOriginY
;
449 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
451 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
452 // is not at 0,0. This was the case under
453 // Mac's GrafPorts (coordinate system
454 // used toplevel window's origin) and
455 // e.g. for Postscript, where the native
456 // origin in the bottom left corner.
457 double m_logicalScaleX
, m_logicalScaleY
;
458 double m_userScaleX
, m_userScaleY
;
459 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
461 int m_signX
, m_signY
; // Used by SetAxisOrientation() to invert the axes
463 // what is a mm on a screen you don't know the size of?
464 double m_mm_to_pix_x
,
467 // bounding and clipping boxes
468 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
469 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
471 int m_logicalFunction
;
472 int m_backgroundMode
;
477 wxBrush m_backgroundBrush
;
478 wxColour m_textForegroundColour
;
479 wxColour m_textBackgroundColour
;
484 bool m_hasCustomPalette
;
485 #endif // wxUSE_PALETTE
488 DECLARE_ABSTRACT_CLASS(wxImplDC
)
492 class wxDC
: public wxObject
495 wxDC() { m_pimpl
= NULL
; }
498 { return m_pimpl
&& m_pimpl
->IsOk(); }
500 // query capabilities
502 bool CanDrawBitmap() const
503 { return m_pimpl
->CanDrawBitmap(); }
504 bool CanGetTextExtent() const
505 { return m_pimpl
->CanGetTextExtent(); }
507 // query dimension, colour deps, resolution
509 void GetSize(int *width
, int *height
) const
510 { m_pimpl
->DoGetSize(width
, height
); }
512 wxSize
GetSize() const
515 m_pimpl
->DoGetSize(&w
, &h
);
519 void GetSizeMM(int* width
, int* height
) const
520 { m_pimpl
->DoGetSizeMM(width
, height
); }
521 wxSize
GetSizeMM() const
524 m_pimpl
->DoGetSizeMM(&w
, &h
);
529 { return m_pimpl
->GetDepth(); }
530 wxSize
GetPPI() const
531 { return m_pimpl
->GetPPI(); }
533 // Right-To-Left (RTL) modes
535 void SetLayoutDirection(wxLayoutDirection dir
)
536 { m_pimpl
->SetLayoutDirection( dir
); }
537 wxLayoutDirection
GetLayoutDirection() const
538 { return m_pimpl
->GetLayoutDirection(); }
542 bool StartDoc(const wxString
& message
)
543 { return m_pimpl
->StartDoc(message
); }
545 { m_pimpl
->EndDoc(); }
548 { m_pimpl
->StartPage(); }
550 { m_pimpl
->EndPage(); }
554 void CalcBoundingBox(wxCoord x
, wxCoord y
)
555 { m_pimpl
->CalcBoundingBox(x
,y
); }
556 void ResetBoundingBox()
557 { m_pimpl
->ResetBoundingBox(); }
560 { return m_pimpl
->MinX(); }
562 { return m_pimpl
->MaxX(); }
564 { return m_pimpl
->MinY(); }
566 { return m_pimpl
->MaxY(); }
568 // setters and getters
570 void SetFont(const wxFont
& font
)
571 { m_pimpl
->SetFont( font
); }
572 const wxFont
& GetFont() const
573 { return m_pimpl
->GetFont(); }
575 void SetPen(const wxPen
& pen
)
576 { m_pimpl
->SetPen( pen
); }
577 const wxPen
& GetPen() const
578 { return m_pimpl
->GetPen(); }
580 void SetBrush(const wxBrush
& brush
)
581 { m_pimpl
->SetBrush( brush
); }
582 const wxBrush
& GetBrush() const
583 { return m_pimpl
->GetBrush(); }
585 void SetBackground(const wxBrush
& brush
)
586 { m_pimpl
->SetBackground( brush
); }
587 const wxBrush
& GetBackground() const
588 { return m_pimpl
->GetBackground(); }
590 void SetBackgroundMode(int mode
)
591 { m_pimpl
->SetBackground( mode
); }
592 int GetBackgroundMode() const
593 { return m_pimpl
->GetBackground(); }
595 void SetTextForeground(const wxColour
& colour
)
596 { m_pimpl
->SetTextForeground(colour
); }
597 const wxColour
& GetTextForeground() const
598 { return m_pimpl
->GetTextForeground(); }
600 void SetTextBackground(const wxColour
& colour
)
601 { m_pimpl
->SetTextBackground(colour
); }
602 const wxColour
& GetTextBackground() const
603 { return m_pimpl
->GetTextBackground(); }
606 void SetPalette(const wxPalette
& palette
)
607 { m_pimpl
->SetPalette(palette
); }
608 #endif // wxUSE_PALETTE
612 void SetLogicalFunction(int function
)
613 { m_pimpl
->SetLogicalFunction(function
); }
614 int GetLogicalFunction() const
615 { return m_pimpl
->GetLogicalFunction(); }
619 wxCoord
GetCharHeight() const
620 { return m_pimpl
->GetCharHeight(); }
621 wxCoord
GetCharWidth() const
622 { return m_pimpl
->GetCharWidth(); }
624 void GetTextExtent(const wxString
& string
,
625 wxCoord
*x
, wxCoord
*y
,
626 wxCoord
*descent
= NULL
,
627 wxCoord
*externalLeading
= NULL
,
628 const wxFont
*theFont
= NULL
) const
629 { m_pimpl
->DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
631 wxSize
GetTextExtent(const wxString
& string
) const
634 m_pimpl
->DoGetTextExtent(string
, &w
, &h
);
638 void GetMultiLineTextExtent(const wxString
& string
,
641 wxCoord
*heightLine
= NULL
,
642 const wxFont
*font
= NULL
) const
643 { m_pimpl
->GetMultiLineTextExtent( string
, width
, height
, heightLine
, font
); }
645 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
648 m_pimpl
->GetMultiLineTextExtent(string
, &w
, &h
);
652 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
653 { return m_pimpl
->DoGetPartialTextExtents(text
, widths
); }
658 { m_pimpl
->Clear(); }
662 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
663 { m_pimpl
->DoSetClippingRegion(x
, y
, width
, height
); }
664 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
665 { m_pimpl
->DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
666 void SetClippingRegion(const wxRect
& rect
)
667 { m_pimpl
->DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
668 void SetClippingRegion(const wxRegion
& region
)
669 { m_pimpl
->DoSetClippingRegionAsRegion(region
); }
671 void DestroyClippingRegion()
672 { m_pimpl
->DestroyClippingRegion(); }
674 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
675 { m_pimpl
->DoGetClippingBox(x
, y
, w
, h
); }
676 void GetClippingBox(wxRect
& rect
) const
677 { m_pimpl
->DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
); }
679 // coordinates conversions and transforms
681 wxCoord
DeviceToLogicalX(wxCoord x
) const
682 { return m_pimpl
->DeviceToLogicalX(x
); }
683 wxCoord
DeviceToLogicalY(wxCoord y
) const;
684 { return m_pimpl
->DeviceToLogicalY(y
); }
685 wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
686 { return m_pimpl
->DeviceToLogicalXRel(x
); }
687 wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
688 { return m_pimpl
->DeviceToLogicalYRel(y
); }
689 wxCoord
LogicalToDeviceX(wxCoord x
) const;
690 { return m_pimpl
->LogicalToDeviceX(x
); }
691 wxCoord
LogicalToDeviceY(wxCoord y
) const;
692 { return m_pimpl
->LogicalToDeviceY(y
); }
693 wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
694 { return m_pimpl
->LogicalToDeviceXRel(x
); }
695 wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
696 { return m_pimpl
->LogicalToDeviceYRel(y
); }
698 void SetMapMode(int mode
)
699 { m_pimpl
->SetMapMode(mode
); }
700 int GetMapMode() const
701 { return m_pimpl
->GetMapMode(); }
703 void SetUserScale(double x
, double y
)
704 { m_pimpl
->SetUserScale(x
,y
); }
705 void GetUserScale(double *x
, double *y
) const
706 { m_pimpl
->GetUserScale( x
, y
); }
708 void SetLogicalScale(double x
, double y
)
709 { m_pimpl
->SetLogicalScale( x
, y
); }
710 void GetLogicalScale(double *x
, double *y
)
711 { m_pimpl
->GetLogicalScale( x
, y
); }
713 void SetLogicalOrigin(wxCoord x
, wxCoord y
)
714 { m_pimpl
->SetLogicalOrigin(x
,y
); }
715 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
716 { m_pimpl
->DoGetLogicalOrigin(x
, y
); }
717 wxPoint
GetLogicalOrigin() const
718 { wxCoord x
, y
; m_pimpl
->DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
720 void SetDeviceOrigin(wxCoord x
, wxCoord y
)
721 { m_pimpl
->SetDeviceOrigin( x
, y
); }
722 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
723 { m_pimpl
->DoGetDeviceOrigin(x
, y
); }
724 wxPoint
GetDeviceOrigin() const
725 { wxCoord x
, y
; m_pimpl
->DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
727 void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
)
728 { m_pimpl
->SetAxisOrientation(xLeftRight
, yBottomUp
); }
731 void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
)
732 { m_pimpl
->SetDeviceLocalOrigin( x
, y
); }
735 // draw generic object
737 void DrawObject(wxDrawObject
* drawobject
)
739 drawobject
->Draw(*this);
740 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
741 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
744 // -----------------------------------------------
745 // the actual drawing API
747 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
748 int style
= wxFLOOD_SURFACE
)
749 { return m_pimpl
->DoFloodFill(x
, y
, col
, style
); }
750 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
751 int style
= wxFLOOD_SURFACE
)
752 { return m_pimpl
->DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
754 // fill the area specified by rect with a radial gradient, starting from
755 // initialColour in the centre of the cercle and fading to destColour.
756 void GradientFillConcentric(const wxRect
& rect
,
757 const wxColour
& initialColour
,
758 const wxColour
& destColour
)
759 { m_pimpl
->GradientFillConcentric(rect
, initialColour
, destColour
,
760 wxPoint(rect
.GetWidth() / 2,
761 rect
.GetHeight() / 2)); }
763 void GradientFillConcentric(const wxRect
& rect
,
764 const wxColour
& initialColour
,
765 const wxColour
& destColour
,
766 const wxPoint
& circleCenter
)
767 { m_pimpl
->DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
769 // fill the area specified by rect with a linear gradient
770 void GradientFillLinear(const wxRect
& rect
,
771 const wxColour
& initialColour
,
772 const wxColour
& destColour
,
773 wxDirection nDirection
= wxEAST
)
774 { m_pimpl
->DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
776 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
777 { return m_pimpl
->DoGetPixel(x
, y
, col
); }
778 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
779 { return m_pimpl
->DoGetPixel(pt
.x
, pt
.y
, col
); }
781 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
782 { m_pimpl
->DoDrawLine(x1
, y1
, x2
, y2
); }
783 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
784 { m_pimpl
->DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
786 void CrossHair(wxCoord x
, wxCoord y
)
787 { m_pimpl
->DoCrossHair(x
, y
); }
788 void CrossHair(const wxPoint
& pt
)
789 { m_pimpl
->DoCrossHair(pt
.x
, pt
.y
); }
791 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
792 wxCoord xc
, wxCoord yc
)
793 { m_pimpl
->DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
794 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
795 { m_pimpl
->DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
797 void DrawCheckMark(wxCoord x
, wxCoord y
,
798 wxCoord width
, wxCoord height
)
799 { m_pimpl
->DoDrawCheckMark(x
, y
, width
, height
); }
800 void DrawCheckMark(const wxRect
& rect
)
801 { m_pimpl
->DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
803 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
804 double sa
, double ea
)
805 { m_pimpl
->DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
806 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
807 double sa
, double ea
)
808 { m_pimpl
->DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
810 void DrawPoint(wxCoord x
, wxCoord y
)
811 { m_pimpl
->DoDrawPoint(x
, y
); }
812 void DrawPoint(const wxPoint
& pt
)
813 { m_pimpl
->DoDrawPoint(pt
.x
, pt
.y
); }
815 void DrawLines(int n
, wxPoint points
[],
816 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
817 { m_pimpl
->DoDrawLines(n
, points
, xoffset
, yoffset
); }
818 void DrawLines(const wxList
*list
,
819 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
820 { m_pimpl
->DrawLines( list
, xoffset
, yoffset
); }
822 void DrawPolygon(int n
, wxPoint points
[],
823 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
824 int fillStyle
= wxODDEVEN_RULE
)
825 { m_pimpl
->DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
827 void DrawPolygon(const wxList
*list
,
828 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
829 int fillStyle
= wxODDEVEN_RULE
)
830 { m_pimpl
->DrawPolygon( list
, xoffset
, yoffset
, fillStyle
); }
832 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
833 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
834 int fillStyle
= wxODDEVEN_RULE
)
835 { m_pimpl
->DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
837 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
838 { m_pimpl
->DoDrawRectangle(x
, y
, width
, height
); }
839 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
840 { m_pimpl
->DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
841 void DrawRectangle(const wxRect
& rect
)
842 { m_pimpl
->DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
844 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
846 { m_pimpl
->DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
847 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
849 { m_pimpl
->DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
850 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
851 { m_pimpl
->DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
853 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
854 { m_pimpl
->DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
855 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
856 { m_pimpl
->DrawCircle(pt
.x
, pt
.y
, radius
); }
858 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
859 { m_pimpl
->DoDrawEllipse(x
, y
, width
, height
); }
860 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
861 { m_pimpl
->DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
862 void DrawEllipse(const wxRect
& rect
)
863 { m_pimpl
->DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
865 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
866 { m_pimpl
->DoDrawIcon(icon
, x
, y
); }
867 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
868 { m_pimpl
->DoDrawIcon(icon
, pt
.x
, pt
.y
); }
870 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
871 bool useMask
= false)
872 { m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
); }
873 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
874 bool useMask
= false)
875 { m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
877 virtual void DrawScaledBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
, bool useMask
= false, int quality
= wxIMAGE_QUALITY_NORMAL
)
879 if (bmp
.GetWidth() != w
|| bmp
.GetHeight() != h
)
881 if (quality
!= wxIMAGE_QUALITY_HIGH
)
882 quality
= wxIMAGE_QUALITY_NORMAL
;
883 wxImage tmpImg
= bmp
.ConvertToImage();
884 tmpImg
.Rescale( w
, h
, quality
);
885 wxBitmap
scaledBmp(tmpImg
);
886 m_pimpl
->DoDrawBitmap(scaledBmp
, x
, y
, useMask
);
889 m_pimpl
->DoDrawBitmap(bmp
, x
, y
, useMask
);
891 virtual void DrawScaledBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
, const wxSize
& sz
, bool useMask
= false, int quality
= wxIMAGE_QUALITY_NORMAL
)
893 if (bmp
.GetWidth() != sz
.x
|| bmp
.GetHeight() != sz
.y
)
895 if (quality
!= wxIMAGE_QUALITY_HIGH
)
896 quality
= wxIMAGE_QUALITY_NORMAL
;
897 wxImage tmpImg
= bmp
.ConvertToImage();
898 tmpImg
.Rescale( sz
.x
, sz
.y
, quality
);
899 wxBitmap
scaledBmp(tmpImg
);
900 m_pimpl
->DoDrawBitmap(scaledBmp
, pt
.x
, pt
.y
, useMask
);
903 m_pimpl
->DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
);
905 virtual void DrawScaledBitmap(const wxBitmap
&bmp
, const wxRect
& rect
, bool useMask
= false, int quality
= wxIMAGE_QUALITY_NORMAL
)
907 if (bmp
.GetWidth() != rect
.width
|| bmp
.GetHeight() != rect
.height
)
909 if (quality
!= wxIMAGE_QUALITY_HIGH
)
910 quality
= wxIMAGE_QUALITY_NORMAL
;
911 wxImage tmpImg
= bmp
.ConvertToImage();
912 tmpImg
.Rescale( rect
.width
, rect
.height
, quality
);
913 wxBitmap
scaledBmp(tmpImg
);
914 m_pimpl
->DoDrawBitmap(scaledBmp
, rect
.x
, rect
.y
, useMask
);
917 m_pimpl
->DoDrawBitmap(bmp
, rect
.x
, rect
.y
, useMask
);
920 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
921 { m_pimpl
->DoDrawText(text
, x
, y
); }
922 void DrawText(const wxString
& text
, const wxPoint
& pt
)
923 { m_pimpl
->DoDrawText(text
, pt
.x
, pt
.y
); }
925 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
926 { m_pimpl
->DoDrawRotatedText(text
, x
, y
, angle
); }
927 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
928 { m_pimpl
->DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
930 // this version puts both optional bitmap and the text into the given
931 // rectangle and aligns is as specified by alignment parameter; it also
932 // will emphasize the character with the given index if it is != -1 and
933 // return the bounding rectangle if required
934 void DrawLabel(const wxString
& text
,
935 const wxBitmap
& image
,
937 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
939 wxRect
*rectBounding
= NULL
)
940 { m_pimpl
->DrawLabel( text
, image
, rect
, alignment
, indexAccel
, rectBounding
); }
942 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
943 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
945 { m_pimpl
->DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
947 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
948 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
949 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
951 return m_pimpl
->DoBlit(xdest
, ydest
, width
, height
,
952 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
954 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
955 wxDC
*source
, const wxPoint
& srcPt
,
956 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
958 return m_pimpl
->DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
959 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
962 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
963 wxCoord dstWidth
, wxCoord dstHeight
,
965 wxCoord srcX
, wxCoord srcY
,
966 wxCoord srcWidth
, wxCoord srcHeight
,
967 int rop
= wxCOPY
, bool useMask
= false,
968 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
970 return m_pimpl
->DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
971 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
973 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
974 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
975 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
977 return m_pimpl
->DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
978 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
981 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
983 return m_pimpl
->DoGetAsBitmap(subrect
);
987 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
988 void DrawSpline(wxCoord x1
, wxCoord y1
,
989 wxCoord x2
, wxCoord y2
,
990 wxCoord x3
, wxCoord y3
)
991 { m_pimpl
->DrawSpline(x1
,y1
,x2
,y2
,x3
,y3
); }
992 void DrawSpline(int n
, wxPoint points
[])
993 { m_pimpl
->DrawSpline(n
,points
); }
995 void DrawSpline(wxList
*points
)
996 { m_pimpl
->DoDrawSpline(points
); }
997 #endif // wxUSE_SPLINES
1000 #if WXWIN_COMPATIBILITY_2_8
1001 // for compatibility with the old code when wxCoord was long everywhere
1002 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1004 long *descent
= NULL
,
1005 long *externalLeading
= NULL
,
1006 const wxFont
*theFont
= NULL
) const );
1007 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1008 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1009 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1010 #endif // WXWIN_COMPATIBILITY_2_8
1017 DECLARE_ABSTRACT_CLASS(wxImplDC
)
1021 #else // wxUSE_NEW_DC
1024 class WXDLLIMPEXP_FWD_CORE wxDC
;
1025 class WXDLLIMPEXP_FWD_CORE wxDCBase
;
1027 class WXDLLEXPORT wxDrawObject
1032 : m_isBBoxValid(false)
1033 , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
1036 virtual ~wxDrawObject() { }
1038 virtual void Draw(wxDCBase
&) const { }
1040 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
1042 if ( m_isBBoxValid
)
1044 if ( x
< m_minX
) m_minX
= x
;
1045 if ( y
< m_minY
) m_minY
= y
;
1046 if ( x
> m_maxX
) m_maxX
= x
;
1047 if ( y
> m_maxY
) m_maxY
= y
;
1051 m_isBBoxValid
= true;
1060 void ResetBoundingBox()
1062 m_isBBoxValid
= false;
1064 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
1067 // Get the final bounding box of the PostScript or Metafile picture.
1069 wxCoord
MinX() const { return m_minX
; }
1070 wxCoord
MaxX() const { return m_maxX
; }
1071 wxCoord
MinY() const { return m_minY
; }
1072 wxCoord
MaxY() const { return m_maxY
; }
1074 //to define the type of object for derived objects
1075 virtual int GetType()=0;
1078 //for boundingbox calculation
1079 bool m_isBBoxValid
:1;
1080 //for boundingbox calculation
1081 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
1084 // ---------------------------------------------------------------------------
1086 // ---------------------------------------------------------------------------
1088 // ---------------------------------------------------------------------------
1089 // wxDC is the device context - object on which any drawing is done
1090 // ---------------------------------------------------------------------------
1092 class WXDLLEXPORT wxDCBase
: public wxObject
1096 virtual ~wxDCBase();
1098 // graphic primitives
1099 // ------------------
1101 virtual void DrawObject(wxDrawObject
* drawobject
)
1103 drawobject
->Draw(*this);
1104 CalcBoundingBox(drawobject
->MinX(),drawobject
->MinY());
1105 CalcBoundingBox(drawobject
->MaxX(),drawobject
->MaxY());
1108 bool FloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1109 int style
= wxFLOOD_SURFACE
)
1110 { return DoFloodFill(x
, y
, col
, style
); }
1111 bool FloodFill(const wxPoint
& pt
, const wxColour
& col
,
1112 int style
= wxFLOOD_SURFACE
)
1113 { return DoFloodFill(pt
.x
, pt
.y
, col
, style
); }
1115 // fill the area specified by rect with a radial gradient, starting from
1116 // initialColour in the centre of the cercle and fading to destColour.
1117 void GradientFillConcentric(const wxRect
& rect
,
1118 const wxColour
& initialColour
,
1119 const wxColour
& destColour
)
1120 { GradientFillConcentric(rect
, initialColour
, destColour
,
1121 wxPoint(rect
.GetWidth() / 2,
1122 rect
.GetHeight() / 2)); }
1124 void GradientFillConcentric(const wxRect
& rect
,
1125 const wxColour
& initialColour
,
1126 const wxColour
& destColour
,
1127 const wxPoint
& circleCenter
)
1128 { DoGradientFillConcentric(rect
, initialColour
, destColour
, circleCenter
); }
1130 // fill the area specified by rect with a linear gradient
1131 void GradientFillLinear(const wxRect
& rect
,
1132 const wxColour
& initialColour
,
1133 const wxColour
& destColour
,
1134 wxDirection nDirection
= wxEAST
)
1135 { DoGradientFillLinear(rect
, initialColour
, destColour
, nDirection
); }
1137 bool GetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const
1138 { return DoGetPixel(x
, y
, col
); }
1139 bool GetPixel(const wxPoint
& pt
, wxColour
*col
) const
1140 { return DoGetPixel(pt
.x
, pt
.y
, col
); }
1142 void DrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
1143 { DoDrawLine(x1
, y1
, x2
, y2
); }
1144 void DrawLine(const wxPoint
& pt1
, const wxPoint
& pt2
)
1145 { DoDrawLine(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
); }
1147 void CrossHair(wxCoord x
, wxCoord y
)
1148 { DoCrossHair(x
, y
); }
1149 void CrossHair(const wxPoint
& pt
)
1150 { DoCrossHair(pt
.x
, pt
.y
); }
1152 void DrawArc(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
,
1153 wxCoord xc
, wxCoord yc
)
1154 { DoDrawArc(x1
, y1
, x2
, y2
, xc
, yc
); }
1155 void DrawArc(const wxPoint
& pt1
, const wxPoint
& pt2
, const wxPoint
& centre
)
1156 { DoDrawArc(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
); }
1158 void DrawCheckMark(wxCoord x
, wxCoord y
,
1159 wxCoord width
, wxCoord height
)
1160 { DoDrawCheckMark(x
, y
, width
, height
); }
1161 void DrawCheckMark(const wxRect
& rect
)
1162 { DoDrawCheckMark(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1164 void DrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1165 double sa
, double ea
)
1166 { DoDrawEllipticArc(x
, y
, w
, h
, sa
, ea
); }
1167 void DrawEllipticArc(const wxPoint
& pt
, const wxSize
& sz
,
1168 double sa
, double ea
)
1169 { DoDrawEllipticArc(pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
); }
1171 void DrawPoint(wxCoord x
, wxCoord y
)
1172 { DoDrawPoint(x
, y
); }
1173 void DrawPoint(const wxPoint
& pt
)
1174 { DoDrawPoint(pt
.x
, pt
.y
); }
1176 void DrawLines(int n
, wxPoint points
[],
1177 wxCoord xoffset
= 0, wxCoord yoffset
= 0)
1178 { DoDrawLines(n
, points
, xoffset
, yoffset
); }
1179 void DrawLines(const wxList
*list
,
1180 wxCoord xoffset
= 0, wxCoord yoffset
= 0);
1182 void DrawPolygon(int n
, wxPoint points
[],
1183 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1184 int fillStyle
= wxODDEVEN_RULE
)
1185 { DoDrawPolygon(n
, points
, xoffset
, yoffset
, fillStyle
); }
1187 void DrawPolygon(const wxList
*list
,
1188 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1189 int fillStyle
= wxODDEVEN_RULE
);
1191 void DrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1192 wxCoord xoffset
= 0, wxCoord yoffset
= 0,
1193 int fillStyle
= wxODDEVEN_RULE
)
1194 { DoDrawPolyPolygon(n
, count
, points
, xoffset
, yoffset
, fillStyle
); }
1196 void DrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1197 { DoDrawRectangle(x
, y
, width
, height
); }
1198 void DrawRectangle(const wxPoint
& pt
, const wxSize
& sz
)
1199 { DoDrawRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1200 void DrawRectangle(const wxRect
& rect
)
1201 { DoDrawRectangle(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1203 void DrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
,
1205 { DoDrawRoundedRectangle(x
, y
, width
, height
, radius
); }
1206 void DrawRoundedRectangle(const wxPoint
& pt
, const wxSize
& sz
,
1208 { DoDrawRoundedRectangle(pt
.x
, pt
.y
, sz
.x
, sz
.y
, radius
); }
1209 void DrawRoundedRectangle(const wxRect
& r
, double radius
)
1210 { DoDrawRoundedRectangle(r
.x
, r
.y
, r
.width
, r
.height
, radius
); }
1212 void DrawCircle(wxCoord x
, wxCoord y
, wxCoord radius
)
1213 { DoDrawEllipse(x
- radius
, y
- radius
, 2*radius
, 2*radius
); }
1214 void DrawCircle(const wxPoint
& pt
, wxCoord radius
)
1215 { DrawCircle(pt
.x
, pt
.y
, radius
); }
1217 void DrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1218 { DoDrawEllipse(x
, y
, width
, height
); }
1219 void DrawEllipse(const wxPoint
& pt
, const wxSize
& sz
)
1220 { DoDrawEllipse(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1221 void DrawEllipse(const wxRect
& rect
)
1222 { DoDrawEllipse(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1224 void DrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
)
1225 { DoDrawIcon(icon
, x
, y
); }
1226 void DrawIcon(const wxIcon
& icon
, const wxPoint
& pt
)
1227 { DoDrawIcon(icon
, pt
.x
, pt
.y
); }
1229 void DrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1230 bool useMask
= false)
1231 { DoDrawBitmap(bmp
, x
, y
, useMask
); }
1232 void DrawBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
,
1233 bool useMask
= false)
1234 { DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
); }
1236 virtual void DrawScaledBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
, bool useMask
= false, int quality
= wxIMAGE_QUALITY_NORMAL
)
1238 if (bmp
.GetWidth() != w
|| bmp
.GetHeight() != h
)
1240 if (quality
!= wxIMAGE_QUALITY_HIGH
)
1241 quality
= wxIMAGE_QUALITY_NORMAL
;
1242 wxImage tmpImg
= bmp
.ConvertToImage();
1243 tmpImg
.Rescale( w
, h
, quality
);
1244 wxBitmap
scaledBmp(tmpImg
);
1245 DoDrawBitmap(scaledBmp
, x
, y
, useMask
);
1248 DoDrawBitmap(bmp
, x
, y
, useMask
);
1250 virtual void DrawScaledBitmap(const wxBitmap
&bmp
, const wxPoint
& pt
, const wxSize
& sz
, bool useMask
= false, int quality
= wxIMAGE_QUALITY_NORMAL
)
1252 if (bmp
.GetWidth() != sz
.x
|| bmp
.GetHeight() != sz
.y
)
1254 if (quality
!= wxIMAGE_QUALITY_HIGH
)
1255 quality
= wxIMAGE_QUALITY_NORMAL
;
1256 wxImage tmpImg
= bmp
.ConvertToImage();
1257 tmpImg
.Rescale( sz
.x
, sz
.y
, quality
);
1258 wxBitmap
scaledBmp(tmpImg
);
1259 DoDrawBitmap(scaledBmp
, pt
.x
, pt
.y
, useMask
);
1262 DoDrawBitmap(bmp
, pt
.x
, pt
.y
, useMask
);
1264 virtual void DrawScaledBitmap(const wxBitmap
&bmp
, const wxRect
& rect
, bool useMask
= false, int quality
= wxIMAGE_QUALITY_NORMAL
)
1266 if (bmp
.GetWidth() != rect
.width
|| bmp
.GetHeight() != rect
.height
)
1268 if (quality
!= wxIMAGE_QUALITY_HIGH
)
1269 quality
= wxIMAGE_QUALITY_NORMAL
;
1270 wxImage tmpImg
= bmp
.ConvertToImage();
1271 tmpImg
.Rescale( rect
.width
, rect
.height
, quality
);
1272 wxBitmap
scaledBmp(tmpImg
);
1273 DoDrawBitmap(scaledBmp
, rect
.x
, rect
.y
, useMask
);
1276 DoDrawBitmap(bmp
, rect
.x
, rect
.y
, useMask
);
1279 void DrawText(const wxString
& text
, wxCoord x
, wxCoord y
)
1280 { DoDrawText(text
, x
, y
); }
1281 void DrawText(const wxString
& text
, const wxPoint
& pt
)
1282 { DoDrawText(text
, pt
.x
, pt
.y
); }
1284 void DrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
)
1285 { DoDrawRotatedText(text
, x
, y
, angle
); }
1286 void DrawRotatedText(const wxString
& text
, const wxPoint
& pt
, double angle
)
1287 { DoDrawRotatedText(text
, pt
.x
, pt
.y
, angle
); }
1289 // this version puts both optional bitmap and the text into the given
1290 // rectangle and aligns is as specified by alignment parameter; it also
1291 // will emphasize the character with the given index if it is != -1 and
1292 // return the bounding rectangle if required
1293 virtual void DrawLabel(const wxString
& text
,
1294 const wxBitmap
& image
,
1296 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1297 int indexAccel
= -1,
1298 wxRect
*rectBounding
= NULL
);
1300 void DrawLabel(const wxString
& text
, const wxRect
& rect
,
1301 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
1302 int indexAccel
= -1)
1303 { DrawLabel(text
, wxNullBitmap
, rect
, alignment
, indexAccel
); }
1305 bool Blit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1306 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
1307 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
)
1309 return DoBlit(xdest
, ydest
, width
, height
,
1310 source
, xsrc
, ysrc
, rop
, useMask
, xsrcMask
, ysrcMask
);
1312 bool Blit(const wxPoint
& destPt
, const wxSize
& sz
,
1313 wxDC
*source
, const wxPoint
& srcPt
,
1314 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcPtMask
= wxDefaultPosition
)
1316 return DoBlit(destPt
.x
, destPt
.y
, sz
.x
, sz
.y
,
1317 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
, srcPtMask
.x
, srcPtMask
.y
);
1320 bool StretchBlit(wxCoord dstX
, wxCoord dstY
,
1321 wxCoord dstWidth
, wxCoord dstHeight
,
1323 wxCoord srcX
, wxCoord srcY
,
1324 wxCoord srcWidth
, wxCoord srcHeight
,
1325 int rop
= wxCOPY
, bool useMask
= false,
1326 wxCoord srcMaskX
= wxDefaultCoord
, wxCoord srcMaskY
= wxDefaultCoord
)
1328 return DoStretchBlit(dstX
, dstY
, dstWidth
, dstHeight
,
1329 source
, srcX
, srcY
, srcWidth
, srcHeight
, rop
, useMask
, srcMaskX
, srcMaskY
);
1331 bool StretchBlit(const wxPoint
& dstPt
, const wxSize
& dstSize
,
1332 wxDC
*source
, const wxPoint
& srcPt
, const wxSize
& srcSize
,
1333 int rop
= wxCOPY
, bool useMask
= false, const wxPoint
& srcMaskPt
= wxDefaultPosition
)
1335 return DoStretchBlit(dstPt
.x
, dstPt
.y
, dstSize
.x
, dstSize
.y
,
1336 source
, srcPt
.x
, srcPt
.y
, srcSize
.x
, srcSize
.y
, rop
, useMask
, srcMaskPt
.x
, srcMaskPt
.y
);
1339 wxBitmap
GetAsBitmap(const wxRect
*subrect
= (const wxRect
*) NULL
) const
1341 return DoGetAsBitmap(subrect
);
1345 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
1346 void DrawSpline(wxCoord x1
, wxCoord y1
,
1347 wxCoord x2
, wxCoord y2
,
1348 wxCoord x3
, wxCoord y3
);
1349 void DrawSpline(int n
, wxPoint points
[]);
1351 void DrawSpline(wxList
*points
) { DoDrawSpline(points
); }
1352 #endif // wxUSE_SPLINES
1354 // Eventually we will have wxUSE_GENERIC_DRAWELLIPSE
1356 //! Generic method to draw ellipses, circles and arcs with current pen and brush.
1357 /*! \param x Upper left corner of bounding box.
1358 * \param y Upper left corner of bounding box.
1359 * \param w Width of bounding box.
1360 * \param h Height of bounding box.
1361 * \param sa Starting angle of arc
1362 * (counterclockwise, start at 3 o'clock, 360 is full circle).
1363 * \param ea Ending angle of arc.
1364 * \param angle Rotation angle, the Arc will be rotated after
1365 * calculating begin and end.
1367 void DrawEllipticArcRot( wxCoord x
, wxCoord y
,
1368 wxCoord width
, wxCoord height
,
1369 double sa
= 0, double ea
= 0, double angle
= 0 )
1370 { DoDrawEllipticArcRot( x
, y
, width
, height
, sa
, ea
, angle
); }
1372 void DrawEllipticArcRot( const wxPoint
& pt
,
1374 double sa
= 0, double ea
= 0, double angle
= 0 )
1375 { DoDrawEllipticArcRot( pt
.x
, pt
.y
, sz
.x
, sz
.y
, sa
, ea
, angle
); }
1377 void DrawEllipticArcRot( const wxRect
& rect
,
1378 double sa
= 0, double ea
= 0, double angle
= 0 )
1379 { DoDrawEllipticArcRot( rect
.x
, rect
.y
, rect
.width
, rect
.height
, sa
, ea
, angle
); }
1381 virtual void DoDrawEllipticArcRot( wxCoord x
, wxCoord y
,
1382 wxCoord w
, wxCoord h
,
1383 double sa
= 0, double ea
= 0, double angle
= 0 );
1385 //! Rotates points around center.
1386 /*! This is a quite straight method, it calculates in pixels
1387 * and so it produces rounding errors.
1388 * \param points The points inside will be rotated.
1389 * \param angle Rotating angle (counterclockwise, start at 3 o'clock, 360 is full circle).
1390 * \param center Center of rotation.
1392 void Rotate( wxList
* points
, double angle
, wxPoint center
= wxPoint(0,0) );
1394 // used by DrawEllipticArcRot
1395 // Careful: wxList gets filled with points you have to delete later.
1396 void CalculateEllipticPoints( wxList
* points
,
1397 wxCoord xStart
, wxCoord yStart
,
1398 wxCoord w
, wxCoord h
,
1399 double sa
, double ea
);
1402 // global DC operations
1403 // --------------------
1405 virtual void Clear() = 0;
1407 virtual bool StartDoc(const wxString
& WXUNUSED(message
)) { return true; }
1408 virtual void EndDoc() { }
1410 virtual void StartPage() { }
1411 virtual void EndPage() { }
1413 #if WXWIN_COMPATIBILITY_2_6
1414 wxDEPRECATED( void BeginDrawing() );
1415 wxDEPRECATED( void EndDrawing() );
1416 #endif // WXWIN_COMPATIBILITY_2_6
1419 // set objects to use for drawing
1420 // ------------------------------
1422 virtual void SetFont(const wxFont
& font
) = 0;
1423 virtual void SetPen(const wxPen
& pen
) = 0;
1424 virtual void SetBrush(const wxBrush
& brush
) = 0;
1425 virtual void SetBackground(const wxBrush
& brush
) = 0;
1426 virtual void SetBackgroundMode(int mode
) = 0;
1428 virtual void SetPalette(const wxPalette
& palette
) = 0;
1429 #endif // wxUSE_PALETTE
1434 void SetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1435 { DoSetClippingRegion(x
, y
, width
, height
); }
1436 void SetClippingRegion(const wxPoint
& pt
, const wxSize
& sz
)
1437 { DoSetClippingRegion(pt
.x
, pt
.y
, sz
.x
, sz
.y
); }
1438 void SetClippingRegion(const wxRect
& rect
)
1439 { DoSetClippingRegion(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
1440 void SetClippingRegion(const wxRegion
& region
)
1441 { DoSetClippingRegionAsRegion(region
); }
1443 virtual void DestroyClippingRegion() { ResetClipping(); }
1445 void GetClippingBox(wxCoord
*x
, wxCoord
*y
, wxCoord
*w
, wxCoord
*h
) const
1446 { DoGetClippingBox(x
, y
, w
, h
); }
1447 void GetClippingBox(wxRect
& rect
) const
1449 DoGetClippingBox(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
);
1455 virtual wxCoord
GetCharHeight() const = 0;
1456 virtual wxCoord
GetCharWidth() const = 0;
1458 // only works for single line strings
1459 void GetTextExtent(const wxString
& string
,
1460 wxCoord
*x
, wxCoord
*y
,
1461 wxCoord
*descent
= NULL
,
1462 wxCoord
*externalLeading
= NULL
,
1463 const wxFont
*theFont
= NULL
) const
1464 { DoGetTextExtent(string
, x
, y
, descent
, externalLeading
, theFont
); }
1466 wxSize
GetTextExtent(const wxString
& string
) const
1469 DoGetTextExtent(string
, &w
, &h
);
1470 return wxSize(w
, h
);
1473 // works for single as well as multi-line strings
1474 virtual void GetMultiLineTextExtent(const wxString
& string
,
1477 wxCoord
*heightLine
= NULL
,
1478 const wxFont
*font
= NULL
) const;
1480 wxSize
GetMultiLineTextExtent(const wxString
& string
) const
1483 GetMultiLineTextExtent(string
, &w
, &h
);
1484 return wxSize(w
, h
);
1487 // Measure cumulative width of text after each character
1488 bool GetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1489 { return DoGetPartialTextExtents(text
, widths
); }
1492 // size and resolution
1493 // -------------------
1496 void GetSize(int *width
, int *height
) const
1497 { DoGetSize(width
, height
); }
1498 wxSize
GetSize() const
1503 return wxSize(w
, h
);
1507 void GetSizeMM(int* width
, int* height
) const
1508 { DoGetSizeMM(width
, height
); }
1509 wxSize
GetSizeMM() const
1512 DoGetSizeMM(&w
, &h
);
1514 return wxSize(w
, h
);
1517 // query DC capabilities
1518 // ---------------------
1520 virtual bool CanDrawBitmap() const = 0;
1521 virtual bool CanGetTextExtent() const = 0;
1524 virtual int GetDepth() const = 0;
1526 // Resolution in Pixels per inch
1527 virtual wxSize
GetPPI() const = 0;
1529 virtual bool Ok() const { return IsOk(); }
1530 virtual bool IsOk() const { return m_ok
; }
1532 // accessors and setters
1533 // ---------------------
1535 virtual int GetBackgroundMode() const { return m_backgroundMode
; }
1536 virtual const wxBrush
& GetBackground() const { return m_backgroundBrush
; }
1537 virtual const wxBrush
& GetBrush() const { return m_brush
; }
1538 virtual const wxFont
& GetFont() const { return m_font
; }
1539 virtual const wxPen
& GetPen() const { return m_pen
; }
1541 virtual const wxColour
& GetTextForeground() const { return m_textForegroundColour
; }
1542 virtual const wxColour
& GetTextBackground() const { return m_textBackgroundColour
; }
1543 virtual void SetTextForeground(const wxColour
& colour
)
1544 { m_textForegroundColour
= colour
; }
1545 virtual void SetTextBackground(const wxColour
& colour
)
1546 { m_textBackgroundColour
= colour
; }
1549 // coordinates conversions and transforms
1550 // --------------------------------------
1552 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
1553 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
1554 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
1555 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
1556 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
1557 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
1558 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
1559 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const;
1561 virtual void SetMapMode(int mode
);
1562 virtual int GetMapMode() const { return m_mappingMode
; }
1564 virtual void SetUserScale(double x
, double y
);
1565 virtual void GetUserScale(double *x
, double *y
) const
1567 if ( x
) *x
= m_userScaleX
;
1568 if ( y
) *y
= m_userScaleY
;
1571 virtual void SetLogicalScale(double x
, double y
);
1572 virtual void GetLogicalScale(double *x
, double *y
)
1574 if ( x
) *x
= m_logicalScaleX
;
1575 if ( y
) *y
= m_logicalScaleY
;
1578 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
1579 void GetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1580 { DoGetLogicalOrigin(x
, y
); }
1581 wxPoint
GetLogicalOrigin() const
1582 { wxCoord x
, y
; DoGetLogicalOrigin(&x
, &y
); return wxPoint(x
, y
); }
1584 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
1585 void GetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1586 { DoGetDeviceOrigin(x
, y
); }
1587 wxPoint
GetDeviceOrigin() const
1588 { wxCoord x
, y
; DoGetDeviceOrigin(&x
, &y
); return wxPoint(x
, y
); }
1590 virtual void SetDeviceLocalOrigin( wxCoord x
, wxCoord y
);
1592 virtual void ComputeScaleAndOrigin();
1594 // this needs to overidden if the axis is inverted (such
1595 // as when using Postscript, where 0,0 is the lower left
1596 // corner, not the upper left).
1597 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
1599 // logical functions
1600 // ---------------------------
1602 virtual int GetLogicalFunction() const { return m_logicalFunction
; }
1603 virtual void SetLogicalFunction(int function
) = 0;
1608 virtual void CalcBoundingBox(wxCoord x
, wxCoord y
)
1610 if ( m_isBBoxValid
)
1612 if ( x
< m_minX
) m_minX
= x
;
1613 if ( y
< m_minY
) m_minY
= y
;
1614 if ( x
> m_maxX
) m_maxX
= x
;
1615 if ( y
> m_maxY
) m_maxY
= y
;
1619 m_isBBoxValid
= true;
1628 void ResetBoundingBox()
1630 m_isBBoxValid
= false;
1632 m_minX
= m_maxX
= m_minY
= m_maxY
= 0;
1635 // Get the final bounding box of the PostScript or Metafile picture.
1636 wxCoord
MinX() const { return m_minX
; }
1637 wxCoord
MaxX() const { return m_maxX
; }
1638 wxCoord
MinY() const { return m_minY
; }
1639 wxCoord
MaxY() const { return m_maxY
; }
1641 // misc old functions
1642 // ------------------
1644 #if WXWIN_COMPATIBILITY_2_8
1645 // for compatibility with the old code when wxCoord was long everywhere
1646 wxDEPRECATED( void GetTextExtent(const wxString
& string
,
1648 long *descent
= NULL
,
1649 long *externalLeading
= NULL
,
1650 const wxFont
*theFont
= NULL
) const );
1651 wxDEPRECATED( void GetLogicalOrigin(long *x
, long *y
) const );
1652 wxDEPRECATED( void GetDeviceOrigin(long *x
, long *y
) const );
1653 wxDEPRECATED( void GetClippingBox(long *x
, long *y
, long *w
, long *h
) const );
1654 #endif // WXWIN_COMPATIBILITY_2_8
1656 // RTL related functions
1657 // ---------------------
1659 // get or change the layout direction (LTR or RTL) for this dc,
1660 // wxLayout_Default is returned if layout direction is not supported
1661 virtual wxLayoutDirection
GetLayoutDirection() const
1662 { return wxLayout_Default
; }
1663 virtual void SetLayoutDirection(wxLayoutDirection
WXUNUSED(dir
))
1667 // the pure virtual functions which should be implemented by wxDC
1668 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
1669 int style
= wxFLOOD_SURFACE
) = 0;
1671 virtual void DoGradientFillLinear(const wxRect
& rect
,
1672 const wxColour
& initialColour
,
1673 const wxColour
& destColour
,
1674 wxDirection nDirection
= wxEAST
);
1676 virtual void DoGradientFillConcentric(const wxRect
& rect
,
1677 const wxColour
& initialColour
,
1678 const wxColour
& destColour
,
1679 const wxPoint
& circleCenter
);
1681 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const = 0;
1683 virtual void DoDrawPoint(wxCoord x
, wxCoord y
) = 0;
1684 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
) = 0;
1686 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
1687 wxCoord x2
, wxCoord y2
,
1688 wxCoord xc
, wxCoord yc
) = 0;
1689 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
1690 wxCoord width
, wxCoord height
);
1691 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
1692 double sa
, double ea
) = 0;
1694 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) = 0;
1695 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1696 wxCoord width
, wxCoord height
,
1698 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
,
1699 wxCoord width
, wxCoord height
) = 0;
1701 virtual void DoCrossHair(wxCoord x
, wxCoord y
) = 0;
1703 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
) = 0;
1704 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
1705 bool useMask
= false) = 0;
1707 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
) = 0;
1708 virtual void DoDrawRotatedText(const wxString
& text
,
1709 wxCoord x
, wxCoord y
, double angle
) = 0;
1711 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
,
1712 wxCoord width
, wxCoord height
,
1714 wxCoord xsrc
, wxCoord ysrc
,
1716 bool useMask
= false,
1717 wxCoord xsrcMask
= wxDefaultCoord
,
1718 wxCoord ysrcMask
= wxDefaultCoord
) = 0;
1720 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
1721 wxCoord dstWidth
, wxCoord dstHeight
,
1723 wxCoord xsrc
, wxCoord ysrc
,
1724 wxCoord srcWidth
, wxCoord srcHeight
,
1726 bool useMask
= false,
1727 wxCoord xsrcMask
= wxDefaultCoord
,
1728 wxCoord ysrcMask
= wxDefaultCoord
);
1730 virtual wxBitmap
DoGetAsBitmap(const wxRect
*WXUNUSED(subrect
)) const
1731 { return wxNullBitmap
; }
1733 virtual void DoGetSize(int *width
, int *height
) const = 0;
1734 virtual void DoGetSizeMM(int* width
, int* height
) const = 0;
1736 virtual void DoDrawLines(int n
, wxPoint points
[],
1737 wxCoord xoffset
, wxCoord yoffset
) = 0;
1738 virtual void DoDrawPolygon(int n
, wxPoint points
[],
1739 wxCoord xoffset
, wxCoord yoffset
,
1740 int fillStyle
= wxODDEVEN_RULE
) = 0;
1741 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
1742 wxCoord xoffset
, wxCoord yoffset
,
1745 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
) = 0;
1746 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
1747 wxCoord width
, wxCoord height
) = 0;
1749 virtual void DoGetClippingBox(wxCoord
*x
, wxCoord
*y
,
1750 wxCoord
*w
, wxCoord
*h
) const
1757 *w
= m_clipX2
- m_clipX1
;
1759 *h
= m_clipY2
- m_clipY1
;
1762 virtual void DoGetLogicalOrigin(wxCoord
*x
, wxCoord
*y
) const
1764 if ( x
) *x
= m_logicalOriginX
;
1765 if ( y
) *y
= m_logicalOriginY
;
1768 virtual void DoGetDeviceOrigin(wxCoord
*x
, wxCoord
*y
) const
1770 if ( x
) *x
= m_deviceOriginX
;
1771 if ( y
) *y
= m_deviceOriginY
;
1774 virtual void DoGetTextExtent(const wxString
& string
,
1775 wxCoord
*x
, wxCoord
*y
,
1776 wxCoord
*descent
= NULL
,
1777 wxCoord
*externalLeading
= NULL
,
1778 const wxFont
*theFont
= NULL
) const = 0;
1780 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
1783 virtual void DoDrawSpline(wxList
*points
);
1787 // unset clipping variables (after clipping region was destroyed)
1788 void ResetClipping()
1792 m_clipX1
= m_clipX2
= m_clipY1
= m_clipY2
= 0;
1799 bool m_isInteractive
:1;
1800 bool m_isBBoxValid
:1;
1802 // coordinate system variables
1804 // TODO short descriptions of what exactly they are would be nice...
1806 wxCoord m_logicalOriginX
, m_logicalOriginY
;
1807 wxCoord m_deviceOriginX
, m_deviceOriginY
; // Usually 0,0, can be change by user
1809 wxCoord m_deviceLocalOriginX
, m_deviceLocalOriginY
; // non-zero if native top-left corner
1810 // is not at 0,0. This was the case under
1811 // Mac's GrafPorts (coordinate system
1812 // used toplevel window's origin) and
1813 // e.g. for Postscript, where the native
1814 // origin in the bottom left corner.
1815 double m_logicalScaleX
, m_logicalScaleY
;
1816 double m_userScaleX
, m_userScaleY
;
1817 double m_scaleX
, m_scaleY
; // calculated from logical scale and user scale
1819 // Used by SetAxisOrientation() to invert the axes
1820 int m_signX
, m_signY
;
1822 // what is a mm on a screen you don't know the size of?
1823 double m_mm_to_pix_x
,
1826 // bounding and clipping boxes
1827 wxCoord m_minX
, m_minY
, m_maxX
, m_maxY
;
1828 wxCoord m_clipX1
, m_clipY1
, m_clipX2
, m_clipY2
;
1830 int m_logicalFunction
;
1831 int m_backgroundMode
;
1837 wxBrush m_backgroundBrush
;
1838 wxColour m_textForegroundColour
;
1839 wxColour m_textBackgroundColour
;
1843 wxPalette m_palette
;
1844 bool m_hasCustomPalette
;
1845 #endif // wxUSE_PALETTE
1848 DECLARE_NO_COPY_CLASS(wxDCBase
)
1849 DECLARE_ABSTRACT_CLASS(wxDCBase
)
1852 #endif // wxUSE_NEW_DC
1854 // ----------------------------------------------------------------------------
1855 // now include the declaration of wxDC class
1856 // ----------------------------------------------------------------------------
1858 #if defined(__WXPALMOS__)
1859 #include "wx/palmos/dc.h"
1860 #elif defined(__WXMSW__)
1861 #include "wx/msw/dc.h"
1862 #elif defined(__WXMOTIF__)
1863 #include "wx/motif/dc.h"
1864 #elif defined(__WXGTK20__)
1865 #include "wx/gtk/dc.h"
1866 #elif defined(__WXGTK__)
1867 #include "wx/gtk1/dc.h"
1868 #elif defined(__WXX11__)
1869 #include "wx/x11/dc.h"
1870 #elif defined(__WXMGL__)
1871 #include "wx/mgl/dc.h"
1872 #elif defined(__WXDFB__)
1873 #include "wx/dfb/dc.h"
1874 #elif defined(__WXMAC__)
1875 #include "wx/mac/dc.h"
1876 #elif defined(__WXCOCOA__)
1877 #include "wx/cocoa/dc.h"
1878 #elif defined(__WXPM__)
1879 #include "wx/os2/dc.h"
1882 #if wxUSE_GRAPHICS_CONTEXT
1883 #include "wx/dcgraph.h"
1886 // ----------------------------------------------------------------------------
1887 // helper class: you can use it to temporarily change the DC text colour and
1888 // restore it automatically when the object goes out of scope
1889 // ----------------------------------------------------------------------------
1891 class WXDLLEXPORT wxDCTextColourChanger
1894 wxDCTextColourChanger(wxDC
& dc
) : m_dc(dc
), m_colFgOld() { }
1896 wxDCTextColourChanger(wxDC
& dc
, const wxColour
& col
) : m_dc(dc
)
1901 ~wxDCTextColourChanger()
1903 if ( m_colFgOld
.Ok() )
1904 m_dc
.SetTextForeground(m_colFgOld
);
1907 void Set(const wxColour
& col
)
1909 if ( !m_colFgOld
.Ok() )
1910 m_colFgOld
= m_dc
.GetTextForeground();
1911 m_dc
.SetTextForeground(col
);
1917 wxColour m_colFgOld
;
1919 DECLARE_NO_COPY_CLASS(wxDCTextColourChanger
)
1922 // ----------------------------------------------------------------------------
1923 // helper class: you can use it to temporarily change the DC pen and
1924 // restore it automatically when the object goes out of scope
1925 // ----------------------------------------------------------------------------
1927 class WXDLLEXPORT wxDCPenChanger
1930 wxDCPenChanger(wxDC
& dc
, const wxPen
& pen
) : m_dc(dc
), m_penOld(dc
.GetPen())
1937 if ( m_penOld
.Ok() )
1938 m_dc
.SetPen(m_penOld
);
1946 DECLARE_NO_COPY_CLASS(wxDCPenChanger
)
1949 // ----------------------------------------------------------------------------
1950 // helper class: you can use it to temporarily change the DC brush and
1951 // restore it automatically when the object goes out of scope
1952 // ----------------------------------------------------------------------------
1954 class WXDLLEXPORT wxDCBrushChanger
1957 wxDCBrushChanger(wxDC
& dc
, const wxBrush
& brush
) : m_dc(dc
), m_brushOld(dc
.GetBrush())
1959 m_dc
.SetBrush(brush
);
1964 if ( m_brushOld
.Ok() )
1965 m_dc
.SetBrush(m_brushOld
);
1973 DECLARE_NO_COPY_CLASS(wxDCBrushChanger
)
1976 // ----------------------------------------------------------------------------
1977 // another small helper class: sets the clipping region in its ctor and
1978 // destroys it in the dtor
1979 // ----------------------------------------------------------------------------
1981 class WXDLLEXPORT wxDCClipper
1984 wxDCClipper(wxDC
& dc
, const wxRegion
& r
) : m_dc(dc
)
1985 { dc
.SetClippingRegion(r
); }
1986 wxDCClipper(wxDC
& dc
, const wxRect
& r
) : m_dc(dc
)
1987 { dc
.SetClippingRegion(r
.x
, r
.y
, r
.width
, r
.height
); }
1988 wxDCClipper(wxDC
& dc
, wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) : m_dc(dc
)
1989 { dc
.SetClippingRegion(x
, y
, w
, h
); }
1991 ~wxDCClipper() { m_dc
.DestroyClippingRegion(); }
1996 DECLARE_NO_COPY_CLASS(wxDCClipper
)
1999 #endif // _WX_DC_H_BASE_