1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: graphics context device bridge header
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_GRAPHICS_DC_H_
12 #define _WX_GRAPHICS_DC_H_
14 #if wxUSE_GRAPHICS_CONTEXT
17 #include "wx/geometry.h"
18 #include "wx/graphics.h"
20 class WXDLLIMPEXP_FWD_CORE wxWindowDC
;
23 class WXDLLIMPEXP_CORE wxGCDC
: public wxDC
26 wxGCDC( const wxWindowDC
& dc
);
27 wxGCDC( const wxMemoryDC
& dc
);
28 #if wxUSE_PRINTING_ARCHITECTURE
29 wxGCDC( const wxPrinterDC
& dc
);
31 #if defined(__WXMSW__) && wxUSE_ENH_METAFILE
32 wxGCDC( const wxEnhMetaFileDC
& dc
);
34 wxGCDC(wxGraphicsContext
* context
);
39 wxGraphicsContext
* GetGraphicsContext() const;
40 void SetGraphicsContext( wxGraphicsContext
* ctx
);
43 // override wxDC virtual functions to provide access to HDC associated with
44 // this Graphics object (implemented in src/msw/graphics.cpp)
45 virtual WXHDC
AcquireHDC();
46 virtual void ReleaseHDC(WXHDC hdc
);
50 DECLARE_DYNAMIC_CLASS(wxGCDC
)
51 wxDECLARE_NO_COPY_CLASS(wxGCDC
);
55 class WXDLLIMPEXP_CORE wxGCDCImpl
: public wxDCImpl
58 wxGCDCImpl( wxDC
*owner
, const wxWindowDC
& dc
);
59 wxGCDCImpl( wxDC
*owner
, const wxMemoryDC
& dc
);
60 #if wxUSE_PRINTING_ARCHITECTURE
61 wxGCDCImpl( wxDC
*owner
, const wxPrinterDC
& dc
);
63 #if defined(__WXMSW__) && wxUSE_ENH_METAFILE
64 wxGCDCImpl( wxDC
*owner
, const wxEnhMetaFileDC
& dc
);
66 wxGCDCImpl( wxDC
*owner
);
68 virtual ~wxGCDCImpl();
70 // implement base class pure virtuals
71 // ----------------------------------
75 virtual bool StartDoc( const wxString
& message
);
76 virtual void EndDoc();
78 virtual void StartPage();
79 virtual void EndPage();
81 // flushing the content of this dc immediately onto screen
84 virtual void SetFont(const wxFont
& font
);
85 virtual void SetPen(const wxPen
& pen
);
86 virtual void SetBrush(const wxBrush
& brush
);
87 virtual void SetBackground(const wxBrush
& brush
);
88 virtual void SetBackgroundMode(int mode
);
89 virtual void SetPalette(const wxPalette
& palette
);
91 virtual void DestroyClippingRegion();
93 virtual wxCoord
GetCharHeight() const;
94 virtual wxCoord
GetCharWidth() const;
96 virtual bool CanDrawBitmap() const;
97 virtual bool CanGetTextExtent() const;
98 virtual int GetDepth() const;
99 virtual wxSize
GetPPI() const;
101 virtual void SetLogicalFunction(wxRasterOperationMode function
);
103 virtual void SetTextForeground(const wxColour
& colour
);
104 virtual void SetTextBackground(const wxColour
& colour
);
106 virtual void ComputeScaleAndOrigin();
108 wxGraphicsContext
* GetGraphicsContext() const { return m_graphicContext
; }
109 virtual void SetGraphicsContext( wxGraphicsContext
* ctx
);
111 virtual void* GetHandle() const;
113 // the true implementations
114 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
115 wxFloodFillStyle style
= wxFLOOD_SURFACE
);
117 virtual void DoGradientFillLinear(const wxRect
& rect
,
118 const wxColour
& initialColour
,
119 const wxColour
& destColour
,
120 wxDirection nDirection
= wxEAST
);
122 virtual void DoGradientFillConcentric(const wxRect
& rect
,
123 const wxColour
& initialColour
,
124 const wxColour
& destColour
,
125 const wxPoint
& circleCenter
);
127 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
129 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
132 virtual void DoDrawSpline(const wxPointList
*points
);
135 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
137 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
138 wxCoord x2
, wxCoord y2
,
139 wxCoord xc
, wxCoord yc
);
141 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
142 wxCoord width
, wxCoord height
);
144 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
145 double sa
, double ea
);
147 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
148 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
149 wxCoord width
, wxCoord height
,
151 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
153 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
155 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
156 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
157 bool useMask
= false);
159 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
160 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
163 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
164 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
165 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
166 wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1);
168 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
169 wxCoord dstWidth
, wxCoord dstHeight
,
171 wxCoord xsrc
, wxCoord ysrc
,
172 wxCoord srcWidth
, wxCoord srcHeight
,
173 wxRasterOperationMode
= wxCOPY
, bool useMask
= false,
174 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
);
176 virtual void DoGetSize(int *,int *) const;
177 virtual void DoGetSizeMM(int* width
, int* height
) const;
179 virtual void DoDrawLines(int n
, const wxPoint points
[],
180 wxCoord xoffset
, wxCoord yoffset
);
181 virtual void DoDrawPolygon(int n
, const wxPoint points
[],
182 wxCoord xoffset
, wxCoord yoffset
,
183 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
);
184 virtual void DoDrawPolyPolygon(int n
, const int count
[], const wxPoint points
[],
185 wxCoord xoffset
, wxCoord yoffset
,
186 wxPolygonFillMode fillStyle
);
188 virtual void DoSetDeviceClippingRegion(const wxRegion
& region
);
189 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
190 wxCoord width
, wxCoord height
);
192 virtual void DoGetTextExtent(const wxString
& string
,
193 wxCoord
*x
, wxCoord
*y
,
194 wxCoord
*descent
= NULL
,
195 wxCoord
*externalLeading
= NULL
,
196 const wxFont
*theFont
= NULL
) const;
198 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
201 virtual wxRect
MSWApplyGDIPlusTransform(const wxRect
& r
) const;
205 // unused int parameter distinguishes this version, which does not create a
206 // wxGraphicsContext, in the expectation that the derived class will do it
207 wxGCDCImpl(wxDC
* owner
, int);
210 bool m_logicalFunctionSupported
;
211 wxGraphicsMatrix m_matrixOriginal
;
212 wxGraphicsMatrix m_matrixCurrent
;
214 double m_formerScaleX
, m_formerScaleY
;
216 wxGraphicsContext
* m_graphicContext
;
219 void Init(wxGraphicsContext
*);
221 DECLARE_CLASS(wxGCDCImpl
)
222 wxDECLARE_NO_COPY_CLASS(wxGCDCImpl
);
225 #endif // wxUSE_GRAPHICS_CONTEXT
226 #endif // _WX_GRAPHICS_DC_H_