]>
Commit | Line | Data |
---|---|---|
6d61d718 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: _graphics.i | |
3 | // Purpose: Wrapper definitions for wx.GraphicsPath, wx.GraphicsContext | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 2-Oct-2006 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2006 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | // Not a %module | |
14 | ||
15 | ||
16 | //--------------------------------------------------------------------------- | |
17 | %newgroup | |
18 | ||
19 | %{ | |
20 | #include <wx/graphics.h> | |
95a76b75 | 21 | %} |
6d61d718 | 22 | |
281c54cc RD |
23 | // Turn off the aquisition of the Global Interpreter Lock for the classes and |
24 | // functions in this file | |
25 | %threadWrapperOff | |
26 | ||
6d61d718 RD |
27 | //--------------------------------------------------------------------------- |
28 | ||
29 | ||
30 | %{ | |
31 | #if !wxUSE_GRAPHICS_CONTEXT | |
95a76b75 RD |
32 | // C++ stub classes for platforms or build configurations that don't have |
33 | // wxGraphicsContext yet. | |
6d61d718 | 34 | |
cbc3893c KO |
35 | class wxGraphicsObject : public wxObject |
36 | { | |
37 | public : | |
95a76b75 RD |
38 | wxGraphicsObject( wxGraphicsRenderer* ) { |
39 | PyErr_SetString(PyExc_NotImplementedError, | |
40 | "wx.GraphicsObject is not available on this platform."); | |
41 | } | |
42 | wxGraphicsObject( const wxGraphicsObject& ) {} | |
43 | virtual ~wxGraphicsObject() {} | |
44 | wxGraphicsRenderer* GetRenderer() const { return NULL; } | |
cbc3893c KO |
45 | } ; |
46 | ||
47 | class wxGraphicsPen : public wxGraphicsObject | |
48 | { | |
95a76b75 | 49 | //wxGraphicsPen(wxGraphicsRenderer* ) {} |
cbc3893c | 50 | virtual ~wxGraphicsPen() {} |
95a76b75 RD |
51 | virtual void Apply( wxGraphicsContext* ) {} |
52 | virtual wxDouble GetWidth() { return 0; } | |
cbc3893c KO |
53 | } ; |
54 | ||
55 | class wxGraphicsBrush : public wxGraphicsObject | |
56 | { | |
57 | public : | |
58 | //wxGraphicsBrush(wxGraphicsRenderer* renderer) {} | |
59 | virtual ~wxGraphicsBrush() {} | |
95a76b75 | 60 | virtual void Apply( wxGraphicsContext* ) {} |
cbc3893c KO |
61 | } ; |
62 | ||
63 | class wxGraphicsFont : public wxGraphicsObject | |
64 | { | |
65 | public : | |
66 | //wxGraphicsFont(wxGraphicsRenderer* renderer) {} | |
67 | virtual ~wxGraphicsFont() {} | |
95a76b75 | 68 | virtual void Apply( wxGraphicsContext* ) {} |
cbc3893c KO |
69 | } ; |
70 | ||
95a76b75 | 71 | class wxGraphicsPath : public wxGraphicsObject |
6d61d718 RD |
72 | { |
73 | public : | |
95a76b75 | 74 | wxGraphicsPath(wxGraphicsRenderer* ) { |
6d61d718 | 75 | PyErr_SetString(PyExc_NotImplementedError, |
95a76b75 | 76 | "wx.GraphicsPath is not available on this platform."); |
6d61d718 RD |
77 | } |
78 | virtual ~wxGraphicsPath() {} | |
95a76b75 RD |
79 | |
80 | virtual wxGraphicsPath *Clone() const { return NULL; } | |
81 | ||
6d61d718 | 82 | void MoveToPoint( wxDouble, wxDouble ) {} |
95a76b75 RD |
83 | void MoveToPoint( const wxPoint2DDouble& ) {} |
84 | void AddLineToPoint( wxDouble, wxDouble ) {} | |
85 | void AddLineToPoint( const wxPoint2DDouble& ) {} | |
6d61d718 | 86 | void AddCurveToPoint( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, wxDouble ) {} |
95a76b75 RD |
87 | void AddCurveToPoint( const wxPoint2DDouble&, const wxPoint2DDouble&, const wxPoint2DDouble&) {} |
88 | void AddPath( const wxGraphicsPath* ) {} | |
6d61d718 RD |
89 | void CloseSubpath() {} |
90 | void GetCurrentPoint( wxDouble&, wxDouble&) {} | |
95a76b75 | 91 | wxPoint2DDouble GetCurrentPoint() { reutrn wxPoint2D(0,0); } |
6d61d718 | 92 | void AddArc( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, bool ) {} |
95a76b75 | 93 | void AddArc( const wxPoint2DDouble& , wxDouble, wxDouble , wxDouble , bool ) {} |
6d61d718 RD |
94 | |
95 | void AddQuadCurveToPoint( wxDouble, wxDouble, wxDouble, wxDouble ) {} | |
96 | void AddRectangle( wxDouble, wxDouble, wxDouble, wxDouble ) {} | |
97 | void AddCircle( wxDouble, wxDouble, wxDouble ) {} | |
98 | void AddArcToPoint( wxDouble, wxDouble , wxDouble, wxDouble, wxDouble ) {} | |
99 | ||
95a76b75 RD |
100 | void AddEllipse( wxDouble , wxDouble , wxDouble , wxDouble ) {} |
101 | void AddRoundedRectangle( wxDouble , wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
102 | void * GetNativePath() const { return NULL; } | |
103 | void UnGetNativePath(void *) {} | |
104 | void Transform( wxGraphicsMatrix* ) {} | |
105 | void GetBox(wxDouble *, wxDouble *, wxDouble *, wxDouble *) {} | |
106 | wxRect2D GetBox() { return wxRect2D(0,0,0,0); } | |
107 | ||
108 | bool Contains( wxDouble , wxDouble , int ) { return false; } | |
109 | bool Contains( const wxPoint2DDouble& , int ) { return false; } | |
6d61d718 RD |
110 | }; |
111 | ||
112 | ||
95a76b75 RD |
113 | class wxGraphicsMatrix : public wxGraphicsObject |
114 | { | |
115 | public : | |
116 | wxGraphicsMatrix(wxGraphicsRenderer* ) { | |
117 | PyErr_SetString(PyExc_NotImplementedError, | |
118 | "wx.GraphicsMatrix is not available on this platform."); | |
119 | } | |
120 | virtual ~wxGraphicsMatrix() {} | |
121 | virtual wxGraphicsMatrix *Clone() const { return NULL; } | |
122 | virtual void Concat( const wxGraphicsMatrix * ) {} | |
123 | virtual void Copy( const wxGraphicsMatrix * ) {} | |
124 | virtual void Set(wxDouble , wxDouble , wxDouble , wxDouble , | |
125 | wxDouble , wxDouble ) {} | |
126 | virtual void Invert() {} | |
127 | virtual bool IsEqual( const wxGraphicsMatrix* t) const {} | |
128 | virtual bool IsIdentity() { return false; } | |
129 | virtual void Translate( wxDouble , wxDouble ) {} | |
130 | virtual void Scale( wxDouble , wxDouble ) {} | |
131 | virtual void Rotate( wxDouble ) {} | |
132 | virtual void TransformPoint( wxDouble *, wxDouble * ) {} | |
133 | virtual void TransformDistance( wxDouble *, wxDouble * ) {} | |
134 | virtual void * GetNativeMatrix() const { return NULL; } | |
135 | }; | |
136 | ||
137 | ||
138 | ||
139 | class wxGraphicsContext : public wxGraphicsObject | |
6d61d718 RD |
140 | { |
141 | public: | |
95a76b75 RD |
142 | |
143 | wxGraphicsContext(wxGraphicsRenderer* ) { | |
6d61d718 | 144 | PyErr_SetString(PyExc_NotImplementedError, |
95a76b75 | 145 | "wx.GraphicsContext is not available on this platform."); |
6d61d718 | 146 | } |
95a76b75 | 147 | |
6d61d718 | 148 | virtual ~wxGraphicsContext() {} |
95a76b75 RD |
149 | |
150 | static wxGraphicsContext* Create( const wxWindowDC& ) { | |
6d61d718 | 151 | PyErr_SetString(PyExc_NotImplementedError, |
95a76b75 | 152 | "wx.GraphicsContext is not available on this platform."); |
6d61d718 | 153 | } |
b876c1e4 | 154 | |
95a76b75 | 155 | static wxGraphicsContext* CreateFromNative( void * ) { |
b876c1e4 | 156 | PyErr_SetString(PyExc_NotImplementedError, |
95a76b75 | 157 | "wx.GraphicsContext is not available on this platform."); |
cbc3893c KO |
158 | } |
159 | ||
95a76b75 RD |
160 | static wxGraphicsContext* CreateFromNativeWindow( void * ) { |
161 | PyErr_SetString(PyExc_NotImplementedError, | |
162 | "wx.GraphicsContext is not available on this platform."); | |
163 | } | |
cbc3893c | 164 | |
95a76b75 RD |
165 | static wxGraphicsContext* Create( wxWindow* ) { |
166 | PyErr_SetString(PyExc_NotImplementedError, | |
167 | "wx.GraphicsContext is not available on this platform."); | |
168 | } | |
cbc3893c | 169 | |
95a76b75 RD |
170 | wxGraphicsPath * CreatePath() { return NULL; } |
171 | ||
172 | virtual wxGraphicsPen* CreatePen(const wxPen& ) { return NULL; } | |
173 | ||
174 | virtual wxGraphicsBrush* CreateBrush(const wxBrush& ) { return NULL; } | |
175 | ||
176 | virtual wxGraphicsBrush* CreateLinearGradientBrush( wxDouble , wxDouble , wxDouble , wxDouble , | |
177 | const wxColour&, const wxColour&) { return NULL; } | |
178 | ||
179 | virtual wxGraphicsBrush* CreateRadialGradientBrush( wxDouble xo, wxDouble yo, | |
180 | wxDouble xc, wxDouble yc, wxDouble radius, | |
181 | const wxColour &oColor, const wxColour &cColor) { return NULL; } | |
182 | ||
183 | virtual wxGraphicsFont* CreateFont( const wxFont &, const wxColour & ) { return NULL; } | |
184 | ||
185 | virtual wxGraphicsMatrix* CreateMatrix( wxDouble, wxDouble, wxDouble, wxDouble, | |
186 | wxDouble, wxDouble) { return NULL; } | |
187 | ||
188 | virtual void PushState() {} | |
189 | virtual void PopState() {} | |
190 | virtual void Clip( const wxRegion & ) {} | |
191 | virtual void Clip( wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
192 | virtual void ResetClip() {} | |
193 | virtual void * GetNativeContext() { return NULL; } | |
194 | virtual void Translate( wxDouble , wxDouble ) {} | |
195 | virtual void Scale( wxDouble , wxDouble ) {} | |
196 | virtual void Rotate( wxDouble ) {} | |
197 | virtual void ConcatTransform( const wxGraphicsMatrix* ) {} | |
198 | virtual void SetTransform( const wxGraphicsMatrix* ) {} | |
199 | virtual void GetTransform( wxGraphicsMatrix* ) {} | |
200 | ||
201 | virtual void SetPen( wxGraphicsPen* , bool ) {} | |
202 | void SetPen( const wxPen& ) {} | |
203 | ||
204 | virtual void SetBrush( wxGraphicsBrush* , bool ) {} | |
205 | void SetBrush( const wxBrush& ) {} | |
206 | ||
207 | virtual void SetFont( wxGraphicsFont*, bool ) {} | |
208 | void SetFont( const wxFont&, const wxColour& ) {} | |
209 | ||
210 | virtual void StrokePath( const wxGraphicsPath * ) {} | |
211 | virtual void FillPath( const wxGraphicsPath *, int ) {} | |
212 | virtual void DrawPath( const wxGraphicsPath *, int ) {} | |
213 | ||
214 | virtual void DrawText( const wxString &, wxDouble , wxDouble ) {} | |
215 | virtual void DrawText( const wxString &, wxDouble , wxDouble , wxDouble ) {} | |
216 | virtual void GetTextExtent( const wxString &, wxDouble *, wxDouble *, | |
217 | wxDouble *, wxDouble * ) const {} | |
218 | virtual void GetPartialTextExtents(const wxString& , wxArrayDouble& ) const {} | |
219 | ||
220 | virtual void DrawBitmap( const wxBitmap &, wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
221 | virtual void DrawIcon( const wxIcon &, wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
222 | ||
223 | virtual void StrokeLine( wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
224 | virtual void StrokeLines( size_t , const wxPoint2DDouble *) {} | |
225 | virtual void StrokeLines( size_t , const wxPoint2DDouble *, const wxPoint2DDouble *) {} | |
226 | virtual void DrawLines( size_t , const wxPoint2DDouble *, int ) {} | |
227 | virtual void DrawRectangle( wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
228 | virtual void DrawEllipse( wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
229 | virtual void DrawRoundedRectangle( wxDouble wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
230 | virtual bool ShouldOffset() const { return false; } | |
231 | }; | |
232 | ||
233 | ||
234 | class wxGraphicsRenderer : public wxObject | |
235 | { | |
236 | public : | |
237 | wxGraphicsRenderer() { | |
238 | PyErr_SetString(PyExc_NotImplementedError, | |
239 | "wx.GraphicsRenderer is not available on this platform."); | |
240 | } | |
241 | ||
242 | virtual ~wxGraphicsRenderer() {} | |
b876c1e4 | 243 | |
95a76b75 RD |
244 | static wxGraphicsRenderer* GetDefaultRenderer( |
245 | PyErr_SetString(PyExc_NotImplementedError, | |
246 | "wx.GraphicsRenderer is not available on this platform."); | |
247 | ); | |
248 | ||
249 | virtual wxGraphicsContext * CreateContext( const wxWindowDC& ) { return NULL; } | |
250 | virtual wxGraphicsContext * CreateContextFromNativeContext( void * ) { return NULL; } | |
251 | virtual wxGraphicsContext * CreateContextFromNativeWindow( void * ) { return NULL; } | |
252 | virtual wxGraphicsContext * CreateContext( wxWindow* ) { return NULL; } | |
253 | ||
254 | virtual wxGraphicsPath * CreatePath() { return NULL; } | |
255 | ||
256 | virtual wxGraphicsMatrix * CreateMatrix( wxDouble , wxDouble , wxDouble , wxDouble , | |
257 | wxDouble , wxDouble ) {} | |
258 | ||
259 | virtual wxGraphicsPen* CreatePen(const wxPen& ) { return NULL; } | |
260 | virtual wxGraphicsBrush* CreateBrush(const wxBrush& ) { return NULL; } | |
261 | virtual wxGraphicsBrush* CreateLinearGradientBrush( | |
262 | wxDouble , wxDouble , wxDouble , wxDouble , | |
263 | const wxColour&, const wxColour&) { return NULL; } | |
264 | virtual wxGraphicsBrush* CreateRadialGradientBrush( | |
265 | wxDouble , wxDouble , wxDouble , wxDouble , wxDouble , | |
266 | const wxColour &, const wxColour &) { return NULL; } | |
267 | virtual wxGraphicsFont* CreateFont( const wxFont & , const wxColour & ) { return NULL; } | |
6d61d718 RD |
268 | }; |
269 | ||
270 | ||
95a76b75 | 271 | |
6d61d718 RD |
272 | class wxGCDC: public wxWindowDC |
273 | { | |
274 | public: | |
275 | wxGCDC(const wxWindowDC&) { | |
276 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
277 | PyErr_SetString(PyExc_NotImplementedError, | |
278 | "wxGCDC is not available on this platform."); | |
279 | wxPyEndBlockThreads(blocked); | |
280 | } | |
95a76b75 | 281 | |
6d61d718 RD |
282 | wxGCDC() { |
283 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
284 | PyErr_SetString(PyExc_NotImplementedError, | |
285 | "wxGCDC is not available on this platform."); | |
286 | wxPyEndBlockThreads(blocked); | |
287 | } | |
95a76b75 | 288 | |
6d61d718 RD |
289 | virtual ~wxGCDC() {} |
290 | ||
b876c1e4 RD |
291 | wxGraphicsContext* GetGraphicsContext() { return NULL; } |
292 | void SetGraphicsContext( wxGraphicsContext* ) {} | |
6d61d718 RD |
293 | }; |
294 | ||
295 | #endif | |
296 | %} | |
297 | ||
298 | //--------------------------------------------------------------------------- | |
299 | //--------------------------------------------------------------------------- | |
300 | ||
281c54cc RD |
301 | |
302 | %typemap(in) (size_t points, wxPoint2D* points_array ) { | |
303 | $2 = wxPoint2D_LIST_helper($input, &$1); | |
304 | if ($2 == NULL) SWIG_fail; | |
305 | } | |
306 | %typemap(freearg) (size_t points, wxPoint2D* points_array ) { | |
307 | if ($2) delete [] $2; | |
308 | } | |
309 | ||
310 | ||
311 | ||
6d61d718 RD |
312 | MustHaveApp(wxGraphicsPath); |
313 | MustHaveApp(wxGraphicsContext); | |
314 | MustHaveApp(wxGCDC); | |
315 | ||
6d61d718 RD |
316 | typedef double wxDouble; |
317 | ||
318 | ||
6d61d718 | 319 | |
cbc3893c KO |
320 | class wxGraphicsObject : public wxObject |
321 | { | |
322 | public : | |
95a76b75 RD |
323 | wxGraphicsObject( wxGraphicsRenderer* renderer = NULL ); |
324 | virtual ~wxGraphicsObject(); | |
325 | wxGraphicsRenderer* GetRenderer() const; | |
326 | }; | |
327 | ||
cbc3893c KO |
328 | |
329 | class wxGraphicsPen : public wxGraphicsObject | |
330 | { | |
331 | public : | |
332 | //wxGraphicsPen(wxGraphicsRenderer* renderer); | |
333 | virtual ~wxGraphicsPen(); | |
334 | virtual void Apply( wxGraphicsContext* context); | |
335 | virtual wxDouble GetWidth(); | |
95a76b75 RD |
336 | }; |
337 | ||
cbc3893c KO |
338 | |
339 | class wxGraphicsBrush : public wxGraphicsObject | |
340 | { | |
341 | public : | |
342 | //wxGraphicsBrush(wxGraphicsRenderer* renderer); | |
343 | virtual ~wxGraphicsBrush(); | |
344 | virtual void Apply( wxGraphicsContext* context); | |
95a76b75 RD |
345 | }; |
346 | ||
cbc3893c KO |
347 | |
348 | class wxGraphicsFont : public wxGraphicsObject | |
349 | { | |
350 | public : | |
351 | //wxGraphicsFont(wxGraphicsRenderer* renderer); | |
352 | virtual ~wxGraphicsFont(); | |
353 | virtual void Apply( wxGraphicsContext* context); | |
95a76b75 RD |
354 | }; |
355 | ||
356 | //--------------------------------------------------------------------------- | |
cbc3893c | 357 | |
95a76b75 | 358 | class wxGraphicsPath : public wxGraphicsObject |
6d61d718 RD |
359 | { |
360 | public : | |
95a76b75 | 361 | //wxGraphicsPath(wxGraphicsRenderer* renderer); *** This class is an ABC, so we can't allow instances to be created directly |
6d61d718 | 362 | virtual ~wxGraphicsPath(); |
95a76b75 RD |
363 | |
364 | virtual wxGraphicsPath *Clone() const = 0; | |
6d61d718 RD |
365 | |
366 | DocDeclStr( | |
367 | virtual void , MoveToPoint( wxDouble x, wxDouble y ), | |
368 | "Begins a new subpath at (x,y)", ""); | |
369 | // void MoveToPoint( const wxPoint2D& p); | |
95a76b75 | 370 | |
6d61d718 RD |
371 | |
372 | DocDeclStr( | |
373 | virtual void , AddLineToPoint( wxDouble x, wxDouble y ), | |
374 | "Adds a straight line from the current point to (x,y) ", ""); | |
375 | // void AddLineToPoint( const wxPoint2D& p); | |
95a76b75 | 376 | |
6d61d718 RD |
377 | |
378 | DocDeclStr( | |
379 | virtual void , AddCurveToPoint( wxDouble cx1, wxDouble cy1, | |
380 | wxDouble cx2, wxDouble cy2, | |
381 | wxDouble x, wxDouble y ), | |
382 | "Adds a cubic Bezier curve from the current point, using two control | |
383 | points and an end point", ""); | |
384 | // void AddCurveToPoint( const wxPoint2D& c1, const wxPoint2D& c2, const wxPoint2D& e); | |
95a76b75 RD |
385 | |
386 | ||
387 | ||
388 | DocDeclStr( | |
389 | virtual void , AddPath( const wxGraphicsPath* path ), | |
390 | "adds another path", ""); | |
391 | ||
6d61d718 RD |
392 | |
393 | DocDeclStr( | |
394 | virtual void , CloseSubpath(), | |
395 | "closes the current sub-path", ""); | |
95a76b75 | 396 | |
6d61d718 RD |
397 | |
398 | //virtual void , GetCurrentPoint( wxDouble& x, wxDouble&y), | |
399 | DocDeclStr( | |
400 | wxPoint2D , GetCurrentPoint(), | |
401 | "Gets the last point of the current path, (0,0) if not yet set", ""); | |
95a76b75 | 402 | |
6d61d718 RD |
403 | |
404 | DocDeclStr( | |
405 | virtual void , AddArc( wxDouble x, wxDouble y, wxDouble r, | |
406 | wxDouble startAngle, wxDouble endAngle, bool clockwise ), | |
407 | "Adds an arc of a circle centering at (x,y) with radius (r) from | |
408 | startAngle to endAngle", ""); | |
409 | // void AddArc( const wxPoint2D& c, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise); | |
95a76b75 | 410 | |
6d61d718 RD |
411 | |
412 | DocDeclStr( | |
413 | virtual void , AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y ), | |
414 | "Adds a quadratic Bezier curve from the current point, using a control | |
415 | point and an end point", ""); | |
95a76b75 | 416 | |
6d61d718 RD |
417 | |
418 | DocDeclStr( | |
419 | virtual void , AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ), | |
420 | "Appends a rectangle as a new closed subpath", ""); | |
95a76b75 | 421 | |
6d61d718 RD |
422 | |
423 | DocDeclStr( | |
424 | virtual void , AddCircle( wxDouble x, wxDouble y, wxDouble r ), | |
281c54cc | 425 | "Appends a circle as a new closed subpath with the given radius.", ""); |
95a76b75 | 426 | |
6d61d718 RD |
427 | |
428 | DocDeclStr( | |
429 | virtual void , AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) , | |
430 | "Draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) | |
431 | to (x2,y2), also a straight line from (current) to (x1,y1)", ""); | |
95a76b75 RD |
432 | |
433 | ||
434 | DocDeclStr( | |
435 | virtual void , AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h), | |
436 | "appends an ellipse", ""); | |
437 | ||
438 | ||
439 | DocDeclStr( | |
440 | virtual void , AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius), | |
441 | "appends a rounded rectangle", ""); | |
442 | ||
443 | ||
444 | DocDeclStr( | |
445 | virtual void * , GetNativePath() const, | |
446 | "returns the native path", ""); | |
447 | ||
448 | ||
449 | DocDeclStr( | |
450 | virtual void , UnGetNativePath(void *p), | |
451 | "give the native path returned by GetNativePath() back (there might be some | |
452 | deallocations necessary)", ""); | |
453 | ||
454 | ||
455 | DocDeclStr( | |
456 | virtual void , Transform( wxGraphicsMatrix* matrix ), | |
457 | "transforms each point of this path by the matrix", ""); | |
458 | ||
459 | ||
460 | //virtual void GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h) =0; | |
461 | DocDeclStr( | |
462 | wxRect2DDouble , GetBox(), | |
463 | "gets the bounding box enclosing all points (possibly including control points)", ""); | |
464 | ||
465 | ||
466 | DocDeclStr( | |
467 | virtual bool , Contains( wxDouble x, wxDouble y, int fillStyle = wxWINDING_RULE), | |
468 | "", ""); | |
469 | //bool Contains( const wxPoint2DDouble& c, int fillStyle = wxWINDING_RULE); | |
6d61d718 RD |
470 | |
471 | }; | |
472 | ||
8292b82b RD |
473 | //--------------------------------------------------------------------------- |
474 | ||
95a76b75 | 475 | class wxGraphicsMatrix : public wxGraphicsObject |
8292b82b RD |
476 | { |
477 | public : | |
95a76b75 | 478 | // wxGraphicsMatrix(wxGraphicsRenderer* renderer); *** This class is an ABC |
8292b82b | 479 | |
95a76b75 | 480 | virtual ~wxGraphicsMatrix(); |
8292b82b | 481 | |
95a76b75 RD |
482 | virtual wxGraphicsMatrix *Clone() const; |
483 | ||
484 | DocDeclStr( | |
485 | virtual void , Concat( const wxGraphicsMatrix *t ), | |
486 | "concatenates the matrix", ""); | |
487 | ||
488 | ||
489 | DocDeclStr( | |
490 | virtual void , Copy( const wxGraphicsMatrix *t ), | |
491 | "copies the passed in matrix", ""); | |
492 | ||
493 | ||
494 | DocDeclStr( | |
495 | virtual void , Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, | |
496 | wxDouble tx=0.0, wxDouble ty=0.0), | |
497 | "sets the matrix to the respective values", ""); | |
498 | ||
499 | ||
500 | DocDeclStr( | |
501 | virtual void , Invert(), | |
502 | "makes this the inverse matrix", ""); | |
503 | ||
504 | ||
505 | DocDeclStr( | |
506 | virtual bool , IsEqual( const wxGraphicsMatrix* t) const, | |
507 | "returns true if the elements of the transformation matrix are equal", ""); | |
8292b82b RD |
508 | |
509 | ||
95a76b75 RD |
510 | DocDeclStr( |
511 | virtual bool , IsIdentity(), | |
512 | "return true if this is the identity matrix", ""); | |
513 | ||
514 | ||
515 | DocDeclStr( | |
516 | virtual void , Translate( wxDouble dx , wxDouble dy ), | |
517 | "add the translation to this matrix", ""); | |
518 | ||
519 | ||
520 | DocDeclStr( | |
521 | virtual void , Scale( wxDouble xScale , wxDouble yScale ), | |
522 | "add the scale to this matrix", ""); | |
523 | ||
524 | ||
525 | DocDeclStr( | |
526 | virtual void , Rotate( wxDouble angle ), | |
527 | "add the rotation to this matrix (radians)", ""); | |
528 | ||
529 | ||
530 | DocDeclAStr( | |
531 | virtual void , TransformPoint( wxDouble *INOUT, wxDouble *INOUT ), | |
532 | "TransformPoint(self, x, y) --> (x, y)", | |
533 | "applies that matrix to the point", ""); | |
534 | ||
535 | ||
536 | DocDeclAStr( | |
537 | virtual void , TransformDistance( wxDouble *INOUT, wxDouble *INOUT ), | |
538 | "TransformDistance(self, dx, dy) --> (dx, dy)", | |
539 | "applies the matrix except for translations", ""); | |
540 | ||
541 | ||
542 | DocDeclStr( | |
543 | virtual void * , GetNativeMatrix() const, | |
544 | "returns the native representation", ""); | |
545 | }; | |
546 | ||
6d61d718 RD |
547 | //--------------------------------------------------------------------------- |
548 | ||
549 | ||
95a76b75 | 550 | class wxGraphicsContext : public wxGraphicsObject |
6d61d718 RD |
551 | { |
552 | public: | |
553 | // wxGraphicsContext() This is also an ABC, use Create to make an instance... | |
554 | virtual ~wxGraphicsContext(); | |
8292b82b | 555 | |
2742805a | 556 | %newobject Create; |
8292b82b | 557 | %nokwargs Create; |
2742805a RD |
558 | %pythonAppend Create |
559 | "val.__dc = args[0] # save a ref so the dc will not be deleted before self"; | |
6d61d718 | 560 | static wxGraphicsContext* Create( const wxWindowDC& dc); |
95a76b75 | 561 | |
8292b82b RD |
562 | static wxGraphicsContext* Create( wxWindow* window ) ; |
563 | ||
2742805a | 564 | %newobject CreateFromNative; |
8292b82b RD |
565 | static wxGraphicsContext* CreateFromNative( void * context ) ; |
566 | ||
95a76b75 RD |
567 | %newobject CreateFromNative; |
568 | static wxGraphicsContext* CreateFromNativeWindow( void * window ) ; | |
569 | ||
6d61d718 | 570 | |
2742805a | 571 | %newobject CreatePath; |
6d61d718 RD |
572 | DocDeclStr( |
573 | virtual wxGraphicsPath * , CreatePath(), | |
95a76b75 RD |
574 | "creates a path instance that corresponds to the type of graphics context, ie GDIPlus, Cairo, CoreGraphics ...", ""); |
575 | ||
576 | ||
577 | %newobject CreatePen; | |
578 | DocDeclStr( | |
579 | virtual wxGraphicsPen* , CreatePen(const wxPen& pen), | |
6d61d718 | 580 | "", ""); |
cbc3893c | 581 | |
cbc3893c | 582 | |
95a76b75 RD |
583 | %newobject CreateBrush; |
584 | DocDeclStr( | |
585 | virtual wxGraphicsBrush* , CreateBrush(const wxBrush& brush ), | |
586 | "", ""); | |
587 | ||
588 | ||
589 | %newobject CreateLinearGradientBrush; | |
590 | DocDeclStr( | |
591 | virtual wxGraphicsBrush* , | |
592 | CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, | |
593 | const wxColour& c1, const wxColour& c2), | |
594 | "sets the brush to a linear gradient, starting at (x1,y1) with color c1 | |
595 | to (x2,y2) with color c2", ""); | |
6d61d718 | 596 | |
8292b82b | 597 | |
95a76b75 RD |
598 | %newobject CreateRadialGradientBrush; |
599 | DocDeclStr( | |
600 | virtual wxGraphicsBrush* , | |
601 | CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, | |
602 | const wxColour &oColor, const wxColour &cColor), | |
603 | "sets the brush to a radial gradient originating at (xo,yc) with color | |
604 | oColor and ends on a circle around (xc,yc) with radius r and color | |
605 | cColor | |
606 | ", ""); | |
607 | ||
608 | ||
609 | %newobject CreateFont; | |
610 | DocDeclStr( | |
611 | virtual wxGraphicsFont* , CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ), | |
612 | "sets the font", ""); | |
613 | ||
614 | ||
615 | %newobject CreateMatrix; | |
616 | DocDeclStr( | |
617 | virtual wxGraphicsMatrix* , CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, | |
618 | wxDouble c=0.0, wxDouble d=1.0, | |
619 | wxDouble tx=0.0, wxDouble ty=0.0), | |
620 | "create a 'native' matrix corresponding to these values", ""); | |
621 | ||
622 | ||
623 | ||
6d61d718 RD |
624 | DocDeclStr( |
625 | virtual void , PushState(), | |
95a76b75 RD |
626 | "push the current state of the context, ie the transformation matrix on a stack", ""); |
627 | ||
6d61d718 | 628 | |
6d61d718 RD |
629 | DocDeclStr( |
630 | virtual void , PopState(), | |
95a76b75 RD |
631 | "pops a stored state from the stack", ""); |
632 | ||
6d61d718 | 633 | |
8292b82b | 634 | DocDeclStrName( |
6d61d718 | 635 | virtual void , Clip( const wxRegion ®ion ), |
95a76b75 | 636 | "clips drawings to the region", "", |
8292b82b | 637 | ClipRegion); |
95a76b75 | 638 | |
8292b82b | 639 | |
8292b82b RD |
640 | DocDeclStr( |
641 | virtual void , Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ), | |
95a76b75 RD |
642 | "clips drawings to the rect", ""); |
643 | ||
644 | ||
8292b82b RD |
645 | DocDeclStr( |
646 | virtual void , ResetClip(), | |
95a76b75 RD |
647 | "resets the clipping to original extent", ""); |
648 | ||
6d61d718 | 649 | |
8292b82b RD |
650 | DocDeclStr( |
651 | virtual void * , GetNativeContext(), | |
95a76b75 | 652 | "returns the native context", ""); |
8292b82b RD |
653 | |
654 | ||
6d61d718 RD |
655 | DocDeclStr( |
656 | virtual void , Translate( wxDouble dx , wxDouble dy ), | |
95a76b75 RD |
657 | "translate the current transformation matrix CTM of the context", ""); |
658 | ||
6d61d718 | 659 | |
6d61d718 RD |
660 | DocDeclStr( |
661 | virtual void , Scale( wxDouble xScale , wxDouble yScale ), | |
95a76b75 RD |
662 | "scale the current transformation matrix CTM of the context", ""); |
663 | ||
6d61d718 | 664 | |
6d61d718 RD |
665 | DocDeclStr( |
666 | virtual void , Rotate( wxDouble angle ), | |
95a76b75 | 667 | "rotate (radians) the current transformation matrix CTM of the context", ""); |
6d61d718 | 668 | |
6d61d718 | 669 | |
6d61d718 | 670 | |
95a76b75 RD |
671 | DocStr(SetPen, "sets the stroke pen", ""); |
672 | %nokwargs SetPen; | |
673 | virtual void SetPen( wxGraphicsPen* pen , bool release = true ); | |
674 | void SetPen( const wxPen& pen ); | |
675 | ||
6d61d718 | 676 | |
95a76b75 RD |
677 | DocStr(SetBrush, "sets the brush for filling", ""); |
678 | %nokwargs SetBrush; | |
679 | virtual void SetBrush( wxGraphicsBrush* brush , bool release = true ); | |
680 | void SetBrush( const wxBrush& brush ); | |
681 | ||
cbc3893c | 682 | |
95a76b75 RD |
683 | DocStr(SetFont, "sets the font", ""); |
684 | %nokwargs SetFont; | |
685 | virtual void SetFont( wxGraphicsFont* font, bool release = true ); | |
686 | void SetFont( const wxFont& font, const wxColour& colour = *wxBLACK); | |
6d61d718 | 687 | |
95a76b75 RD |
688 | |
689 | ||
6d61d718 RD |
690 | DocDeclStr( |
691 | virtual void , StrokePath( const wxGraphicsPath *path ), | |
95a76b75 | 692 | "strokes along a path with the current pen", ""); |
6d61d718 | 693 | |
95a76b75 | 694 | |
6d61d718 RD |
695 | DocDeclStr( |
696 | virtual void , FillPath( const wxGraphicsPath *path, int fillStyle = wxWINDING_RULE ), | |
95a76b75 | 697 | "fills a path with the current brush", ""); |
6d61d718 | 698 | |
95a76b75 | 699 | |
6d61d718 RD |
700 | DocDeclStr( |
701 | virtual void , DrawPath( const wxGraphicsPath *path, int fillStyle = wxWINDING_RULE ), | |
95a76b75 RD |
702 | "draws a path by first filling and then stroking", ""); |
703 | ||
6d61d718 | 704 | |
6d61d718 RD |
705 | DocDeclStr( |
706 | virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y ), | |
707 | "", ""); | |
95a76b75 | 708 | |
6d61d718 | 709 | |
281c54cc | 710 | DocDeclStrName( |
6d61d718 | 711 | virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ), |
281c54cc RD |
712 | "", "", |
713 | DrawRotatedText); | |
95a76b75 | 714 | |
6d61d718 | 715 | |
752d967c | 716 | DocDeclAStrName( |
6d61d718 RD |
717 | virtual void , GetTextExtent( const wxString &text, |
718 | wxDouble *OUTPUT /*width*/, | |
719 | wxDouble *OUTPUT /*height*/, | |
720 | wxDouble *OUTPUT /*descent*/, | |
721 | wxDouble *OUTPUT /*externalLeading*/ ) const , | |
752d967c RD |
722 | "GetFullTextExtent(self, text) --> (width, height, descent, externalLeading)", |
723 | "", "", | |
724 | GetFullTextExtent); | |
725 | ||
726 | %extend { | |
727 | DocAStr(GetTextExtent, | |
728 | "GetTextExtent(self, text) --> (width, height)", | |
729 | "", ""); | |
95a76b75 | 730 | |
752d967c RD |
731 | PyObject* GetTextExtent( const wxString &text ) |
732 | { | |
733 | wxDouble width = 0.0, | |
734 | height = 0.0; | |
735 | self->GetTextExtent(text, &width, &height, NULL, NULL); | |
736 | // thread wrapers are turned off for this .i file, so no need to acquire GIL... | |
737 | PyObject* rv = PyTuple_New(2); | |
738 | PyTuple_SET_ITEM(rv, 0, PyFloat_FromDouble(width)); | |
739 | PyTuple_SET_ITEM(rv, 1, PyFloat_FromDouble(height)); | |
740 | return rv; | |
741 | } | |
742 | } | |
95a76b75 | 743 | |
6d61d718 | 744 | |
281c54cc RD |
745 | %extend { |
746 | DocAStr(GetPartialTextExtents, | |
747 | "GetPartialTextExtents(self, text) -> [widths]", | |
748 | "", ""); | |
749 | wxArrayDouble GetPartialTextExtents(const wxString& text) { | |
750 | wxArrayDouble widths; | |
751 | self->GetPartialTextExtents(text, widths); | |
752 | return widths; | |
753 | } | |
754 | } | |
6d61d718 | 755 | |
6d61d718 RD |
756 | |
757 | DocDeclStr( | |
758 | virtual void , DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ), | |
759 | "", ""); | |
95a76b75 | 760 | |
6d61d718 RD |
761 | |
762 | DocDeclStr( | |
763 | virtual void , DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ), | |
764 | "", ""); | |
6d61d718 | 765 | |
95a76b75 RD |
766 | |
767 | ||
6d61d718 RD |
768 | DocDeclStr( |
769 | virtual void , StrokeLine( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2), | |
95a76b75 | 770 | "strokes a single line", ""); |
6d61d718 | 771 | |
281c54cc | 772 | |
281c54cc RD |
773 | DocDeclAStr( |
774 | virtual void , StrokeLines( size_t points, const wxPoint2D *points_array), | |
775 | "StrokeLines(self, List points)", | |
95a76b75 | 776 | "stroke lines connecting each of the points", ""); |
6d61d718 | 777 | |
281c54cc | 778 | |
281c54cc | 779 | %extend { |
95a76b75 RD |
780 | DocStr(StrokeLineSegements, |
781 | "stroke disconnected lines from begin to end points", ""); | |
aa43bcc7 | 782 | void StrokeLineSegements(PyObject* beginPoints, PyObject* endPoints) |
281c54cc RD |
783 | { |
784 | size_t c1, c2, count; | |
785 | wxPoint2D* beginP = wxPoint2D_LIST_helper(beginPoints, &c1); | |
786 | wxPoint2D* endP = wxPoint2D_LIST_helper(endPoints, &c2); | |
787 | ||
788 | if ( beginP != NULL && endP != NULL ) | |
789 | { | |
790 | count = wxMin(c1, c2); | |
791 | self->StrokeLines(count, beginP, endP); | |
792 | } | |
793 | delete [] beginP; | |
794 | delete [] endP; | |
795 | } | |
796 | } | |
6d61d718 | 797 | |
95a76b75 | 798 | |
6d61d718 | 799 | DocDeclStr( |
281c54cc | 800 | virtual void , DrawLines( size_t points, const wxPoint2D *points_array, int fillStyle = wxWINDING_RULE ), |
95a76b75 RD |
801 | "draws a polygon", ""); |
802 | ||
6d61d718 | 803 | |
6d61d718 RD |
804 | DocDeclStr( |
805 | virtual void , DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h), | |
95a76b75 RD |
806 | "draws a rectangle", ""); |
807 | ||
6d61d718 | 808 | |
6d61d718 RD |
809 | DocDeclStr( |
810 | virtual void , DrawEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h), | |
95a76b75 RD |
811 | "draws an ellipse", ""); |
812 | ||
6d61d718 | 813 | |
6d61d718 RD |
814 | DocDeclStr( |
815 | virtual void , DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius), | |
95a76b75 RD |
816 | "draws a rounded rectangle", ""); |
817 | ||
818 | ||
819 | ||
820 | DocDeclStr( | |
821 | virtual bool , ShouldOffset() const, | |
822 | "helper to determine if a 0.5 offset should be applied for the drawing operation", ""); | |
823 | ||
824 | }; | |
825 | ||
826 | ||
827 | //--------------------------------------------------------------------------- | |
828 | ||
829 | class wxGraphicsRenderer : public wxObject | |
830 | { | |
831 | public : | |
832 | // wxGraphicsRenderer(); This is an ABC, use GetDefaultRenderer | |
833 | ||
834 | virtual ~wxGraphicsRenderer(); | |
835 | ||
836 | // %newobject GetDefaultRenderer; ??? | |
837 | static wxGraphicsRenderer* GetDefaultRenderer(); | |
838 | ||
839 | %nokwargs CreateContext; | |
840 | %newobject CreateContext; | |
841 | virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) ; | |
842 | virtual wxGraphicsContext * CreateContext( wxWindow* window ); | |
843 | ||
844 | %newobject CreateContextFromNativeContext; | |
845 | virtual wxGraphicsContext * CreateContextFromNativeContext( void * context ); | |
846 | ||
847 | %newobject CreateContextFromNativeWindow; | |
848 | virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window ); | |
849 | ||
850 | ||
851 | %newobject CreatePath; | |
852 | virtual wxGraphicsPath * CreatePath(); | |
853 | ||
854 | %newobject CreateMatrix; | |
855 | virtual wxGraphicsMatrix * CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, | |
856 | wxDouble tx=0.0, wxDouble ty=0.0); | |
857 | ||
858 | %newobject CreatePen; | |
859 | virtual wxGraphicsPen* CreatePen(const wxPen& pen) ; | |
860 | ||
861 | %newobject CreateBrush; | |
862 | virtual wxGraphicsBrush* CreateBrush(const wxBrush& brush ) ; | |
863 | ||
864 | %newobject CreateLinearGradientBrush; | |
865 | virtual wxGraphicsBrush* CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, | |
866 | const wxColour&c1, const wxColour&c2); | |
867 | ||
868 | %newobject CreateRadialGradientBrush; | |
869 | virtual wxGraphicsBrush* CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, | |
870 | const wxColour &oColor, const wxColour &cColor); | |
871 | ||
872 | %newobject CreateFont; | |
873 | virtual wxGraphicsFont* CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ); | |
6d61d718 | 874 | |
6d61d718 RD |
875 | }; |
876 | ||
877 | ||
95a76b75 | 878 | |
6d61d718 RD |
879 | //--------------------------------------------------------------------------- |
880 | ||
6240681f RD |
881 | %{ |
882 | #include "wx/dcgraph.h" | |
883 | %} | |
6d61d718 RD |
884 | |
885 | class wxGCDC: public wxDC | |
886 | { | |
887 | public: | |
0e4e6012 RD |
888 | %pythonAppend wxGCDC |
889 | "self.__dc = args[0] # save a ref so the other dc will not be deleted before self"; | |
6d61d718 RD |
890 | wxGCDC(const wxWindowDC& dc); |
891 | //wxGCDC(); | |
892 | virtual ~wxGCDC(); | |
893 | ||
8292b82b RD |
894 | wxGraphicsContext* GetGraphicsContext(); |
895 | virtual void SetGraphicsContext( wxGraphicsContext* ctx ); | |
896 | ||
897 | %property(GraphicsContext, GetGraphicsContext, SetGraphicsContext); | |
6d61d718 RD |
898 | }; |
899 | ||
900 | ||
281c54cc | 901 | //--------------------------------------------------------------------------- |
6d61d718 | 902 | |
281c54cc RD |
903 | // Turn GIL acquisition back on. |
904 | %threadWrapperOn | |
6d61d718 | 905 |