1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: graphics context device bridge header
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GRAPHICS_DC_H_
13 #define _WX_GRAPHICS_DC_H_
15 #if wxUSE_GRAPHICS_CONTEXT
17 #include "wx/geometry.h"
18 #include "wx/dynarray.h"
19 #include "wx/graphics.h"
21 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
24 class WXDLLEXPORT wxGCDC
: public wxDC
27 wxGCDC( const wxWindowDC
& dc
);
28 wxGCDC( const wxMemoryDC
& dc
);
31 wxGraphicsContext
* GetGraphicsContext();
32 void SetGraphicsContext( wxGraphicsContext
* ctx
);
35 DECLARE_DYNAMIC_CLASS(wxGCDC
)
36 DECLARE_NO_COPY_CLASS(wxGCDC
)
41 class WXDLLEXPORT wxGCDCImpl
: public wxDCImpl
44 wxGCDCImpl( wxDC
*owner
, const wxWindowDC
& dc
);
45 wxGCDCImpl( wxDC
*owner
, const wxMemoryDC
& dc
);
46 wxGCDCImpl( wxDC
*owner
);
48 virtual ~wxGCDCImpl();
53 // implement base class pure virtuals
54 // ----------------------------------
58 virtual bool StartDoc( const wxString
& message
);
59 virtual void EndDoc();
61 virtual void StartPage();
62 virtual void EndPage();
64 // flushing the content of this dc immediately onto screen
67 virtual void SetFont(const wxFont
& font
);
68 virtual void SetPen(const wxPen
& pen
);
69 virtual void SetBrush(const wxBrush
& brush
);
70 virtual void SetBackground(const wxBrush
& brush
);
71 virtual void SetBackgroundMode(int mode
);
72 virtual void SetPalette(const wxPalette
& palette
);
74 virtual void DestroyClippingRegion();
76 virtual wxCoord
GetCharHeight() const;
77 virtual wxCoord
GetCharWidth() const;
79 virtual bool CanDrawBitmap() const;
80 virtual bool CanGetTextExtent() const;
81 virtual int GetDepth() const;
82 virtual wxSize
GetPPI() const;
84 virtual void SetMapMode(int mode
);
85 virtual void SetUserScale(double x
, double y
);
87 virtual void SetLogicalScale(double x
, double y
);
88 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
89 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
90 virtual void SetAxisOrientation(bool xLeftRight
, bool yBottomUp
);
91 virtual void SetLogicalFunction(int function
);
93 virtual void SetTextForeground(const wxColour
& colour
);
94 virtual void SetTextBackground(const wxColour
& colour
);
96 virtual void ComputeScaleAndOrigin();
98 wxGraphicsContext
* GetGraphicsContext() { return m_graphicContext
; }
99 virtual void SetGraphicsContext( wxGraphicsContext
* ctx
);
102 // the true implementations
103 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
104 int style
= wxFLOOD_SURFACE
);
106 virtual void DoGradientFillLinear(const wxRect
& rect
,
107 const wxColour
& initialColour
,
108 const wxColour
& destColour
,
109 wxDirection nDirection
= wxEAST
);
111 virtual void DoGradientFillConcentric(const wxRect
& rect
,
112 const wxColour
& initialColour
,
113 const wxColour
& destColour
,
114 const wxPoint
& circleCenter
);
116 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
118 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
121 virtual void DoDrawSpline(const wxPointList
*points
);
124 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
126 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
127 wxCoord x2
, wxCoord y2
,
128 wxCoord xc
, wxCoord yc
);
130 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
131 wxCoord width
, wxCoord height
);
133 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
134 double sa
, double ea
);
136 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
137 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
138 wxCoord width
, wxCoord height
,
140 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
142 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
144 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
145 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
146 bool useMask
= false);
148 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
149 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
152 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
153 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
154 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1);
156 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
157 wxCoord dstWidth
, wxCoord dstHeight
,
159 wxCoord xsrc
, wxCoord ysrc
,
160 wxCoord srcWidth
, wxCoord srcHeight
,
161 int rop
= wxCOPY
, bool useMask
= false,
162 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
);
164 virtual void DoGetSize(int *,int *) const;
165 virtual void DoGetSizeMM(int* width
, int* height
) const;
167 virtual void DoDrawLines(int n
, wxPoint points
[],
168 wxCoord xoffset
, wxCoord yoffset
);
169 virtual void DoDrawPolygon(int n
, wxPoint points
[],
170 wxCoord xoffset
, wxCoord yoffset
,
171 int fillStyle
= wxODDEVEN_RULE
);
172 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
173 wxCoord xoffset
, wxCoord yoffset
,
176 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
);
177 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
178 wxCoord width
, wxCoord height
);
180 virtual void DoGetTextExtent(const wxString
& string
,
181 wxCoord
*x
, wxCoord
*y
,
182 wxCoord
*descent
= NULL
,
183 wxCoord
*externalLeading
= NULL
,
184 const wxFont
*theFont
= NULL
) const;
186 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
190 bool m_logicalFunctionSupported
;
191 double m_mm_to_pix_x
, m_mm_to_pix_y
;
192 wxGraphicsMatrix m_matrixOriginal
;
193 wxGraphicsMatrix m_matrixCurrent
;
195 double m_formerScaleX
, m_formerScaleY
;
197 wxGraphicsContext
* m_graphicContext
;
200 DECLARE_CLASS(wxGCDCImpl
)
201 DECLARE_NO_COPY_CLASS(wxGCDCImpl
)
206 #endif // _WX_GRAPHICS_DC_H_