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
);
38 wxGraphicsContext
* GetGraphicsContext() const;
39 void SetGraphicsContext( wxGraphicsContext
* ctx
);
42 // override wxDC virtual functions to provide access to HDC associated with
43 // this Graphics object (implemented in src/msw/graphics.cpp)
44 virtual WXHDC
AcquireHDC();
45 virtual void ReleaseHDC(WXHDC hdc
);
49 DECLARE_DYNAMIC_CLASS(wxGCDC
)
50 wxDECLARE_NO_COPY_CLASS(wxGCDC
);
54 class WXDLLIMPEXP_CORE wxGCDCImpl
: public wxDCImpl
57 wxGCDCImpl( wxDC
*owner
, const wxWindowDC
& dc
);
58 wxGCDCImpl( wxDC
*owner
, const wxMemoryDC
& dc
);
59 #if wxUSE_PRINTING_ARCHITECTURE
60 wxGCDCImpl( wxDC
*owner
, const wxPrinterDC
& dc
);
62 #if defined(__WXMSW__) && wxUSE_ENH_METAFILE
63 wxGCDCImpl( wxDC
*owner
, const wxEnhMetaFileDC
& dc
);
65 wxGCDCImpl( wxDC
*owner
);
67 virtual ~wxGCDCImpl();
72 // implement base class pure virtuals
73 // ----------------------------------
77 virtual bool StartDoc( const wxString
& message
);
78 virtual void EndDoc();
80 virtual void StartPage();
81 virtual void EndPage();
83 // flushing the content of this dc immediately onto screen
86 virtual void SetFont(const wxFont
& font
);
87 virtual void SetPen(const wxPen
& pen
);
88 virtual void SetBrush(const wxBrush
& brush
);
89 virtual void SetBackground(const wxBrush
& brush
);
90 virtual void SetBackgroundMode(int mode
);
91 virtual void SetPalette(const wxPalette
& palette
);
93 virtual void DestroyClippingRegion();
95 virtual wxCoord
GetCharHeight() const;
96 virtual wxCoord
GetCharWidth() const;
98 virtual bool CanDrawBitmap() const;
99 virtual bool CanGetTextExtent() const;
100 virtual int GetDepth() const;
101 virtual wxSize
GetPPI() const;
103 virtual void SetMapMode(wxMappingMode mode
);
105 virtual void SetLogicalFunction(wxRasterOperationMode function
);
107 virtual void SetTextForeground(const wxColour
& colour
);
108 virtual void SetTextBackground(const wxColour
& colour
);
110 virtual void ComputeScaleAndOrigin();
112 wxGraphicsContext
* GetGraphicsContext() const { return m_graphicContext
; }
113 virtual void SetGraphicsContext( wxGraphicsContext
* ctx
);
115 // the true implementations
116 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
117 wxFloodFillStyle style
= wxFLOOD_SURFACE
);
119 virtual void DoGradientFillLinear(const wxRect
& rect
,
120 const wxColour
& initialColour
,
121 const wxColour
& destColour
,
122 wxDirection nDirection
= wxEAST
);
124 virtual void DoGradientFillConcentric(const wxRect
& rect
,
125 const wxColour
& initialColour
,
126 const wxColour
& destColour
,
127 const wxPoint
& circleCenter
);
129 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
131 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
134 virtual void DoDrawSpline(const wxPointList
*points
);
137 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
139 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
140 wxCoord x2
, wxCoord y2
,
141 wxCoord xc
, wxCoord yc
);
143 virtual void DoDrawCheckMark(wxCoord x
, wxCoord y
,
144 wxCoord width
, wxCoord height
);
146 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
147 double sa
, double ea
);
149 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
150 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
151 wxCoord width
, wxCoord height
,
153 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
155 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
157 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
158 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
159 bool useMask
= false);
161 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
162 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
165 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
166 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
167 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
168 wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1);
170 virtual bool DoStretchBlit(wxCoord xdest
, wxCoord ydest
,
171 wxCoord dstWidth
, wxCoord dstHeight
,
173 wxCoord xsrc
, wxCoord ysrc
,
174 wxCoord srcWidth
, wxCoord srcHeight
,
175 wxRasterOperationMode
= wxCOPY
, bool useMask
= false,
176 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
);
178 virtual void DoGetSize(int *,int *) const;
179 virtual void DoGetSizeMM(int* width
, int* height
) const;
181 virtual void DoDrawLines(int n
, wxPoint points
[],
182 wxCoord xoffset
, wxCoord yoffset
);
183 virtual void DoDrawPolygon(int n
, wxPoint points
[],
184 wxCoord xoffset
, wxCoord yoffset
,
185 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
);
186 virtual void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[],
187 wxCoord xoffset
, wxCoord yoffset
,
188 wxPolygonFillMode fillStyle
);
190 virtual void DoSetDeviceClippingRegion(const wxRegion
& region
);
191 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
192 wxCoord width
, wxCoord height
);
194 virtual void DoGetTextExtent(const wxString
& string
,
195 wxCoord
*x
, wxCoord
*y
,
196 wxCoord
*descent
= NULL
,
197 wxCoord
*externalLeading
= NULL
,
198 const wxFont
*theFont
= NULL
) const;
200 virtual bool DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const;
203 virtual wxRect
MSWApplyGDIPlusTransform(const wxRect
& r
) const;
208 bool m_logicalFunctionSupported
;
209 double m_mm_to_pix_x
, m_mm_to_pix_y
;
210 wxGraphicsMatrix m_matrixOriginal
;
211 wxGraphicsMatrix m_matrixCurrent
;
213 double m_formerScaleX
, m_formerScaleY
;
215 wxGraphicsContext
* m_graphicContext
;
217 DECLARE_CLASS(wxGCDCImpl
)
218 wxDECLARE_NO_COPY_CLASS(wxGCDCImpl
);
221 #endif // wxUSE_GRAPHICS_CONTEXT
222 #endif // _WX_GRAPHICS_DC_H_