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
18 #include "wx/geometry.h"
19 #include "wx/dynarray.h"
20 #include "wx/graphics.h"
22 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
25 class WXDLLEXPORT wxGCDC
: public wxDC
28 wxGCDC( const wxWindowDC
& dc
);
29 wxGCDC( const wxMemoryDC
& dc
);
33 wxGraphicsContext
* GetGraphicsContext();
34 void SetGraphicsContext( wxGraphicsContext
* ctx
);
37 DECLARE_DYNAMIC_CLASS(wxGCDC
)
38 DECLARE_NO_COPY_CLASS(wxGCDC
)
43 class WXDLLEXPORT wxGCDCImpl
: public wxDCImpl
46 wxGCDCImpl( wxDC
*owner
, const wxWindowDC
& dc
);
47 wxGCDCImpl( wxDC
*owner
, const wxMemoryDC
& dc
);
48 wxGCDCImpl( wxDC
*owner
);
50 virtual ~wxGCDCImpl();
55 // implement base class pure virtuals
56 // ----------------------------------
60 virtual bool StartDoc( const wxString
& message
);
61 virtual void EndDoc();
63 virtual void StartPage();
64 virtual void EndPage();
66 // flushing the content of this dc immediately onto screen
69 virtual void SetFont(const wxFont
& font
);
70 virtual void SetPen(const wxPen
& pen
);
71 virtual void SetBrush(const wxBrush
& brush
);
72 virtual void SetBackground(const wxBrush
& brush
);
73 virtual void SetBackgroundMode(int mode
);
74 virtual void SetPalette(const wxPalette
& palette
);
76 virtual void DestroyClippingRegion();
78 virtual wxCoord
GetCharHeight() const;
79 virtual wxCoord
GetCharWidth() const;
81 virtual bool CanDrawBitmap() const;
82 virtual bool CanGetTextExtent() const;
83 virtual int GetDepth() const;
84 virtual wxSize
GetPPI() const;
86 virtual void SetMapMode(int mode
);
88 virtual void SetLogicalFunction(int function
);
90 virtual void SetTextForeground(const wxColour
& colour
);
91 virtual void SetTextBackground(const wxColour
& colour
);
93 virtual void ComputeScaleAndOrigin();
95 wxGraphicsContext
* GetGraphicsContext() { return m_graphicContext
; }
96 virtual void SetGraphicsContext( wxGraphicsContext
* ctx
);
99 // the true implementations
100 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
101 int style
= wxFLOOD_SURFACE
);
103 virtual void DoGradientFillLinear(const wxRect
& rect
,
104 const wxColour
& initialColour
,
105 const wxColour
& destColour
,
106 wxDirection nDirection
= wxEAST
);
108 virtual void DoGradientFillConcentric(const wxRect
& rect
,
109 const wxColour
& initialColour
,
110 const wxColour
& destColour
,
111 const wxPoint
& circleCenter
);
113 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
115 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
118 virtual void DoDrawSpline(const wxPointList
*points
);
121 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
123 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
124 wxCoord x2
, wxCoord y2
,
125 wxCoord xc
, wxCoord yc
);
127 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
128 wxCoord width
, wxCoord height
);
130 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
131 double sa
, double ea
);
133 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
134 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
135 wxCoord width
, wxCoord height
,
137 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
139 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
141 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
142 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
143 bool useMask
= false);
145 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
146 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
149 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
150 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
151 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1);
153 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
154 wxCoord dstWidth
, wxCoord dstHeight
,
156 wxCoord xsrc
, wxCoord ysrc
,
157 wxCoord srcWidth
, wxCoord srcHeight
,
158 int rop
= wxCOPY
, bool useMask
= false,
159 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
);
161 virtual void DoGetSize(int *,int *) const;
162 virtual void DoGetSizeMM(int* width
, int* height
) const;
164 virtual void DoDrawLines(int n
, wxPoint points
[],
165 wxCoord xoffset
, wxCoord yoffset
);
166 virtual void DoDrawPolygon(int n
, wxPoint points
[],
167 wxCoord xoffset
, wxCoord yoffset
,
168 int fillStyle
= wxODDEVEN_RULE
);
169 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
170 wxCoord xoffset
, wxCoord yoffset
,
173 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
);
174 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
175 wxCoord width
, wxCoord height
);
177 virtual void DoGetTextExtent(const wxString
& string
,
178 wxCoord
*x
, wxCoord
*y
,
179 wxCoord
*descent
= NULL
,
180 wxCoord
*externalLeading
= NULL
,
181 const wxFont
*theFont
= NULL
) const;
183 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
187 bool m_logicalFunctionSupported
;
188 double m_mm_to_pix_x
, m_mm_to_pix_y
;
189 wxGraphicsMatrix m_matrixOriginal
;
190 wxGraphicsMatrix m_matrixCurrent
;
192 double m_formerScaleX
, m_formerScaleY
;
194 wxGraphicsContext
* m_graphicContext
;
197 DECLARE_CLASS(wxGCDCImpl
)
198 DECLARE_NO_COPY_CLASS(wxGCDCImpl
)
203 #endif // _WX_GRAPHICS_DC_H_