]> git.saurik.com Git - wxWidgets.git/blob - include/wx/dcgraph.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / dcgraph.h
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 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_GRAPHICS_DC_H_
12 #define _WX_GRAPHICS_DC_H_
13
14 #if wxUSE_GRAPHICS_CONTEXT
15
16 #include "wx/dc.h"
17 #include "wx/geometry.h"
18 #include "wx/graphics.h"
19
20 class WXDLLIMPEXP_FWD_CORE wxWindowDC;
21
22
23 class WXDLLIMPEXP_CORE wxGCDC: public wxDC
24 {
25 public:
26 wxGCDC( const wxWindowDC& dc );
27 wxGCDC( const wxMemoryDC& dc );
28 #if wxUSE_PRINTING_ARCHITECTURE
29 wxGCDC( const wxPrinterDC& dc );
30 #endif
31 #if defined(__WXMSW__) && wxUSE_ENH_METAFILE
32 wxGCDC( const wxEnhMetaFileDC& dc );
33 #endif
34 wxGCDC(wxGraphicsContext* context);
35
36 wxGCDC();
37 virtual ~wxGCDC();
38
39 wxGraphicsContext* GetGraphicsContext() const;
40 void SetGraphicsContext( wxGraphicsContext* ctx );
41
42 #ifdef __WXMSW__
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);
47 #endif // __WXMSW__
48
49 private:
50 DECLARE_DYNAMIC_CLASS(wxGCDC)
51 wxDECLARE_NO_COPY_CLASS(wxGCDC);
52 };
53
54
55 class WXDLLIMPEXP_CORE wxGCDCImpl: public wxDCImpl
56 {
57 public:
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 );
62 #endif
63 #if defined(__WXMSW__) && wxUSE_ENH_METAFILE
64 wxGCDCImpl( wxDC *owner, const wxEnhMetaFileDC& dc );
65 #endif
66 wxGCDCImpl( wxDC *owner );
67
68 virtual ~wxGCDCImpl();
69
70 // implement base class pure virtuals
71 // ----------------------------------
72
73 virtual void Clear();
74
75 virtual bool StartDoc( const wxString& message );
76 virtual void EndDoc();
77
78 virtual void StartPage();
79 virtual void EndPage();
80
81 // flushing the content of this dc immediately onto screen
82 virtual void Flush();
83
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);
90
91 virtual void DestroyClippingRegion();
92
93 virtual wxCoord GetCharHeight() const;
94 virtual wxCoord GetCharWidth() const;
95
96 virtual bool CanDrawBitmap() const;
97 virtual bool CanGetTextExtent() const;
98 virtual int GetDepth() const;
99 virtual wxSize GetPPI() const;
100
101 virtual void SetLogicalFunction(wxRasterOperationMode function);
102
103 virtual void SetTextForeground(const wxColour& colour);
104 virtual void SetTextBackground(const wxColour& colour);
105
106 virtual void ComputeScaleAndOrigin();
107
108 wxGraphicsContext* GetGraphicsContext() const { return m_graphicContext; }
109 virtual void SetGraphicsContext( wxGraphicsContext* ctx );
110
111 virtual void* GetHandle() const;
112
113 // the true implementations
114 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
115 wxFloodFillStyle style = wxFLOOD_SURFACE);
116
117 virtual void DoGradientFillLinear(const wxRect& rect,
118 const wxColour& initialColour,
119 const wxColour& destColour,
120 wxDirection nDirection = wxEAST);
121
122 virtual void DoGradientFillConcentric(const wxRect& rect,
123 const wxColour& initialColour,
124 const wxColour& destColour,
125 const wxPoint& circleCenter);
126
127 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
128
129 virtual void DoDrawPoint(wxCoord x, wxCoord y);
130
131 #if wxUSE_SPLINES
132 virtual void DoDrawSpline(const wxPointList *points);
133 #endif
134
135 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
136
137 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
138 wxCoord x2, wxCoord y2,
139 wxCoord xc, wxCoord yc);
140
141 virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
142 wxCoord width, wxCoord height);
143
144 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
145 double sa, double ea);
146
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,
150 double radius);
151 virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
152
153 virtual void DoCrossHair(wxCoord x, wxCoord y);
154
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);
158
159 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
160 virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
161 double angle);
162
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);
167
168 virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest,
169 wxCoord dstWidth, wxCoord dstHeight,
170 wxDC *source,
171 wxCoord xsrc, wxCoord ysrc,
172 wxCoord srcWidth, wxCoord srcHeight,
173 wxRasterOperationMode = wxCOPY, bool useMask = false,
174 wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
175
176 virtual void DoGetSize(int *,int *) const;
177 virtual void DoGetSizeMM(int* width, int* height) const;
178
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);
187
188 virtual void DoSetDeviceClippingRegion(const wxRegion& region);
189 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
190 wxCoord width, wxCoord height);
191
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;
197
198 virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
199
200 #ifdef __WXMSW__
201 virtual wxRect MSWApplyGDIPlusTransform(const wxRect& r) const;
202 #endif // __WXMSW__
203
204 protected:
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);
208
209 // scaling variables
210 bool m_logicalFunctionSupported;
211 wxGraphicsMatrix m_matrixOriginal;
212 wxGraphicsMatrix m_matrixCurrent;
213
214 double m_formerScaleX, m_formerScaleY;
215
216 wxGraphicsContext* m_graphicContext;
217
218 private:
219 void Init(wxGraphicsContext*);
220
221 DECLARE_CLASS(wxGCDCImpl)
222 wxDECLARE_NO_COPY_CLASS(wxGCDCImpl);
223 };
224
225 #endif // wxUSE_GRAPHICS_CONTEXT
226 #endif // _WX_GRAPHICS_DC_H_