]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/dcgraph.h | |
3 | // Purpose: graphics context device bridge header | |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: | |
7 | // Copyright: (c) Stefan Csomor | |
8 | // RCS-ID: $Id$ | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_GRAPHICS_DC_H_ | |
13 | #define _WX_GRAPHICS_DC_H_ | |
14 | ||
15 | #if wxUSE_GRAPHICS_CONTEXT | |
16 | ||
17 | #include "wx/dc.h" | |
18 | #include "wx/geometry.h" | |
19 | #include "wx/graphics.h" | |
20 | ||
21 | class WXDLLIMPEXP_FWD_CORE wxWindowDC; | |
22 | ||
23 | ||
24 | class WXDLLIMPEXP_CORE wxGCDC: public wxDC | |
25 | { | |
26 | public: | |
27 | wxGCDC( const wxWindowDC& dc ); | |
28 | wxGCDC( const wxMemoryDC& dc ); | |
29 | #if wxUSE_PRINTING_ARCHITECTURE | |
30 | wxGCDC( const wxPrinterDC& dc ); | |
31 | #endif | |
32 | #if defined(__WXMSW__) && wxUSE_ENH_METAFILE | |
33 | wxGCDC( const wxEnhMetaFileDC& dc ); | |
34 | #endif | |
35 | wxGCDC(wxGraphicsContext* context); | |
36 | ||
37 | wxGCDC(); | |
38 | virtual ~wxGCDC(); | |
39 | ||
40 | wxGraphicsContext* GetGraphicsContext() const; | |
41 | void SetGraphicsContext( wxGraphicsContext* ctx ); | |
42 | ||
43 | #ifdef __WXMSW__ | |
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); | |
48 | #endif // __WXMSW__ | |
49 | ||
50 | private: | |
51 | DECLARE_DYNAMIC_CLASS(wxGCDC) | |
52 | wxDECLARE_NO_COPY_CLASS(wxGCDC); | |
53 | }; | |
54 | ||
55 | ||
56 | class WXDLLIMPEXP_CORE wxGCDCImpl: public wxDCImpl | |
57 | { | |
58 | public: | |
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 ); | |
63 | #endif | |
64 | #if defined(__WXMSW__) && wxUSE_ENH_METAFILE | |
65 | wxGCDCImpl( wxDC *owner, const wxEnhMetaFileDC& dc ); | |
66 | #endif | |
67 | wxGCDCImpl( wxDC *owner ); | |
68 | ||
69 | virtual ~wxGCDCImpl(); | |
70 | ||
71 | void Init(); | |
72 | ||
73 | ||
74 | // implement base class pure virtuals | |
75 | // ---------------------------------- | |
76 | ||
77 | virtual void Clear(); | |
78 | ||
79 | virtual bool StartDoc( const wxString& message ); | |
80 | virtual void EndDoc(); | |
81 | ||
82 | virtual void StartPage(); | |
83 | virtual void EndPage(); | |
84 | ||
85 | // flushing the content of this dc immediately onto screen | |
86 | virtual void Flush(); | |
87 | ||
88 | virtual void SetFont(const wxFont& font); | |
89 | virtual void SetPen(const wxPen& pen); | |
90 | virtual void SetBrush(const wxBrush& brush); | |
91 | virtual void SetBackground(const wxBrush& brush); | |
92 | virtual void SetBackgroundMode(int mode); | |
93 | virtual void SetPalette(const wxPalette& palette); | |
94 | ||
95 | virtual void DestroyClippingRegion(); | |
96 | ||
97 | virtual wxCoord GetCharHeight() const; | |
98 | virtual wxCoord GetCharWidth() const; | |
99 | ||
100 | virtual bool CanDrawBitmap() const; | |
101 | virtual bool CanGetTextExtent() const; | |
102 | virtual int GetDepth() const; | |
103 | virtual wxSize GetPPI() const; | |
104 | ||
105 | virtual void SetMapMode(wxMappingMode mode); | |
106 | ||
107 | virtual void SetLogicalFunction(wxRasterOperationMode function); | |
108 | ||
109 | virtual void SetTextForeground(const wxColour& colour); | |
110 | virtual void SetTextBackground(const wxColour& colour); | |
111 | ||
112 | virtual void ComputeScaleAndOrigin(); | |
113 | ||
114 | wxGraphicsContext* GetGraphicsContext() const { return m_graphicContext; } | |
115 | virtual void SetGraphicsContext( wxGraphicsContext* ctx ); | |
116 | ||
117 | // the true implementations | |
118 | virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, | |
119 | wxFloodFillStyle style = wxFLOOD_SURFACE); | |
120 | ||
121 | virtual void DoGradientFillLinear(const wxRect& rect, | |
122 | const wxColour& initialColour, | |
123 | const wxColour& destColour, | |
124 | wxDirection nDirection = wxEAST); | |
125 | ||
126 | virtual void DoGradientFillConcentric(const wxRect& rect, | |
127 | const wxColour& initialColour, | |
128 | const wxColour& destColour, | |
129 | const wxPoint& circleCenter); | |
130 | ||
131 | virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; | |
132 | ||
133 | virtual void DoDrawPoint(wxCoord x, wxCoord y); | |
134 | ||
135 | #if wxUSE_SPLINES | |
136 | virtual void DoDrawSpline(const wxPointList *points); | |
137 | #endif | |
138 | ||
139 | virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
140 | ||
141 | virtual void DoDrawArc(wxCoord x1, wxCoord y1, | |
142 | wxCoord x2, wxCoord y2, | |
143 | wxCoord xc, wxCoord yc); | |
144 | ||
145 | virtual void DoDrawCheckMark(wxCoord x, wxCoord y, | |
146 | wxCoord width, wxCoord height); | |
147 | ||
148 | virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, | |
149 | double sa, double ea); | |
150 | ||
151 | virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
152 | virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, | |
153 | wxCoord width, wxCoord height, | |
154 | double radius); | |
155 | virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
156 | ||
157 | virtual void DoCrossHair(wxCoord x, wxCoord y); | |
158 | ||
159 | virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); | |
160 | virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
161 | bool useMask = false); | |
162 | ||
163 | virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); | |
164 | virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, | |
165 | double angle); | |
166 | ||
167 | virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, | |
168 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
169 | wxRasterOperationMode rop = wxCOPY, bool useMask = false, | |
170 | wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); | |
171 | ||
172 | virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest, | |
173 | wxCoord dstWidth, wxCoord dstHeight, | |
174 | wxDC *source, | |
175 | wxCoord xsrc, wxCoord ysrc, | |
176 | wxCoord srcWidth, wxCoord srcHeight, | |
177 | wxRasterOperationMode = wxCOPY, bool useMask = false, | |
178 | wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord); | |
179 | ||
180 | virtual void DoGetSize(int *,int *) const; | |
181 | virtual void DoGetSizeMM(int* width, int* height) const; | |
182 | ||
183 | virtual void DoDrawLines(int n, wxPoint points[], | |
184 | wxCoord xoffset, wxCoord yoffset); | |
185 | virtual void DoDrawPolygon(int n, wxPoint points[], | |
186 | wxCoord xoffset, wxCoord yoffset, | |
187 | wxPolygonFillMode fillStyle = wxODDEVEN_RULE); | |
188 | virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[], | |
189 | wxCoord xoffset, wxCoord yoffset, | |
190 | wxPolygonFillMode fillStyle); | |
191 | ||
192 | virtual void DoSetDeviceClippingRegion(const wxRegion& region); | |
193 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, | |
194 | wxCoord width, wxCoord height); | |
195 | ||
196 | virtual void DoGetTextExtent(const wxString& string, | |
197 | wxCoord *x, wxCoord *y, | |
198 | wxCoord *descent = NULL, | |
199 | wxCoord *externalLeading = NULL, | |
200 | const wxFont *theFont = NULL) const; | |
201 | ||
202 | virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const; | |
203 | ||
204 | #ifdef __WXMSW__ | |
205 | virtual wxRect MSWApplyGDIPlusTransform(const wxRect& r) const; | |
206 | #endif // __WXMSW__ | |
207 | ||
208 | protected: | |
209 | // scaling variables | |
210 | bool m_logicalFunctionSupported; | |
211 | double m_mm_to_pix_x, m_mm_to_pix_y; | |
212 | wxGraphicsMatrix m_matrixOriginal; | |
213 | wxGraphicsMatrix m_matrixCurrent; | |
214 | ||
215 | double m_formerScaleX, m_formerScaleY; | |
216 | ||
217 | wxGraphicsContext* m_graphicContext; | |
218 | ||
219 | DECLARE_CLASS(wxGCDCImpl) | |
220 | wxDECLARE_NO_COPY_CLASS(wxGCDCImpl); | |
221 | }; | |
222 | ||
223 | #endif // wxUSE_GRAPHICS_CONTEXT | |
224 | #endif // _WX_GRAPHICS_DC_H_ |