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/graphics.h"
21 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
24 class WXDLLIMPEXP_CORE wxGCDC
: public wxDC
27 wxGCDC( const wxWindowDC
& dc
);
28 wxGCDC( const wxMemoryDC
& dc
);
29 #if wxUSE_PRINTING_ARCHITECTURE
30 wxGCDC( const wxPrinterDC
& dc
);
32 #if defined(__WXMSW__) && wxUSE_ENH_METAFILE
33 wxGCDC( const wxEnhMetaFileDC
& dc
);
35 wxGCDC(wxGraphicsContext
* context
);
40 wxGraphicsContext
* GetGraphicsContext() const;
41 void SetGraphicsContext( wxGraphicsContext
* ctx
);
44 // override wxDC virtual functions to provide access to HDC associated with
45 // this Graphics object (implemented in src/msw/graphics.cpp)
46 virtual WXHDC
AcquireHDC();
47 virtual void ReleaseHDC(WXHDC hdc
);
51 DECLARE_DYNAMIC_CLASS(wxGCDC
)
52 wxDECLARE_NO_COPY_CLASS(wxGCDC
);
56 class WXDLLIMPEXP_CORE wxGCDCImpl
: public wxDCImpl
59 wxGCDCImpl( wxDC
*owner
, const wxWindowDC
& dc
);
60 wxGCDCImpl( wxDC
*owner
, const wxMemoryDC
& dc
);
61 #if wxUSE_PRINTING_ARCHITECTURE
62 wxGCDCImpl( wxDC
*owner
, const wxPrinterDC
& dc
);
64 #if defined(__WXMSW__) && wxUSE_ENH_METAFILE
65 wxGCDCImpl( wxDC
*owner
, const wxEnhMetaFileDC
& dc
);
67 wxGCDCImpl( wxDC
*owner
);
69 virtual ~wxGCDCImpl();
71 // implement base class pure virtuals
72 // ----------------------------------
76 virtual bool StartDoc( const wxString
& message
);
77 virtual void EndDoc();
79 virtual void StartPage();
80 virtual void EndPage();
82 // flushing the content of this dc immediately onto screen
85 virtual void SetFont(const wxFont
& font
);
86 virtual void SetPen(const wxPen
& pen
);
87 virtual void SetBrush(const wxBrush
& brush
);
88 virtual void SetBackground(const wxBrush
& brush
);
89 virtual void SetBackgroundMode(int mode
);
90 virtual void SetPalette(const wxPalette
& palette
);
92 virtual void DestroyClippingRegion();
94 virtual wxCoord
GetCharHeight() const;
95 virtual wxCoord
GetCharWidth() const;
97 virtual bool CanDrawBitmap() const;
98 virtual bool CanGetTextExtent() const;
99 virtual int GetDepth() const;
100 virtual wxSize
GetPPI() const;
102 virtual void SetLogicalFunction(wxRasterOperationMode function
);
104 virtual void SetTextForeground(const wxColour
& colour
);
105 virtual void SetTextBackground(const wxColour
& colour
);
107 virtual void ComputeScaleAndOrigin();
109 wxGraphicsContext
* GetGraphicsContext() const { return m_graphicContext
; }
110 virtual void SetGraphicsContext( wxGraphicsContext
* ctx
);
112 virtual void* GetHandle() const;
114 // the true implementations
115 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
116 wxFloodFillStyle style
= wxFLOOD_SURFACE
);
118 virtual void DoGradientFillLinear(const wxRect
& rect
,
119 const wxColour
& initialColour
,
120 const wxColour
& destColour
,
121 wxDirection nDirection
= wxEAST
);
123 virtual void DoGradientFillConcentric(const wxRect
& rect
,
124 const wxColour
& initialColour
,
125 const wxColour
& destColour
,
126 const wxPoint
& circleCenter
);
128 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
130 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
133 virtual void DoDrawSpline(const wxPointList
*points
);
136 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
138 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
139 wxCoord x2
, wxCoord y2
,
140 wxCoord xc
, wxCoord yc
);
142 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
143 wxCoord width
, wxCoord height
);
145 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
146 double sa
, double ea
);
148 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
149 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
150 wxCoord width
, wxCoord height
,
152 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
154 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
156 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
157 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
158 bool useMask
= false);
160 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
161 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
164 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
165 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
166 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
167 wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1);
169 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
170 wxCoord dstWidth
, wxCoord dstHeight
,
172 wxCoord xsrc
, wxCoord ysrc
,
173 wxCoord srcWidth
, wxCoord srcHeight
,
174 wxRasterOperationMode
= wxCOPY
, bool useMask
= false,
175 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
);
177 virtual void DoGetSize(int *,int *) const;
178 virtual void DoGetSizeMM(int* width
, int* height
) const;
180 virtual void DoDrawLines(int n
, wxPoint points
[],
181 wxCoord xoffset
, wxCoord yoffset
);
182 virtual void DoDrawPolygon(int n
, wxPoint points
[],
183 wxCoord xoffset
, wxCoord yoffset
,
184 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
);
185 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
186 wxCoord xoffset
, wxCoord yoffset
,
187 wxPolygonFillMode fillStyle
);
189 virtual void DoSetDeviceClippingRegion(const wxRegion
& region
);
190 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
191 wxCoord width
, wxCoord height
);
193 virtual void DoGetTextExtent(const wxString
& string
,
194 wxCoord
*x
, wxCoord
*y
,
195 wxCoord
*descent
= NULL
,
196 wxCoord
*externalLeading
= NULL
,
197 const wxFont
*theFont
= NULL
) const;
199 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
202 virtual wxRect
MSWApplyGDIPlusTransform(const wxRect
& r
) const;
206 // unused int parameter distinguishes this version, which does not create a
207 // wxGraphicsContext, in the expectation that the derived class will do it
208 wxGCDCImpl(wxDC
* owner
, int);
211 bool m_logicalFunctionSupported
;
212 wxGraphicsMatrix m_matrixOriginal
;
213 wxGraphicsMatrix m_matrixCurrent
;
215 double m_formerScaleX
, m_formerScaleY
;
217 wxGraphicsContext
* m_graphicContext
;
220 void Init(wxGraphicsContext
*);
222 DECLARE_CLASS(wxGCDCImpl
)
223 wxDECLARE_NO_COPY_CLASS(wxGCDCImpl
);
226 #endif // wxUSE_GRAPHICS_CONTEXT
227 #endif // _WX_GRAPHICS_DC_H_