]>
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 | 27 | |
027aef71 RD |
28 | //--------------------------------------------------------------------------- |
29 | //--------------------------------------------------------------------------- | |
6d61d718 RD |
30 | |
31 | %{ | |
32 | #if !wxUSE_GRAPHICS_CONTEXT | |
95a76b75 RD |
33 | // C++ stub classes for platforms or build configurations that don't have |
34 | // wxGraphicsContext yet. | |
6d61d718 | 35 | |
8bd35413 RD |
36 | class wxGraphicsRenderer; |
37 | class wxGraphicsMatrix; | |
38 | ||
027aef71 | 39 | |
cbc3893c KO |
40 | class wxGraphicsObject : public wxObject |
41 | { | |
42 | public : | |
8bd35413 | 43 | wxGraphicsObject() {} |
95a76b75 RD |
44 | wxGraphicsObject( wxGraphicsRenderer* ) { |
45 | PyErr_SetString(PyExc_NotImplementedError, | |
46 | "wx.GraphicsObject is not available on this platform."); | |
47 | } | |
48 | wxGraphicsObject( const wxGraphicsObject& ) {} | |
49 | virtual ~wxGraphicsObject() {} | |
027aef71 | 50 | bool IsNull() const { return false; } |
95a76b75 | 51 | wxGraphicsRenderer* GetRenderer() const { return NULL; } |
cbc3893c KO |
52 | } ; |
53 | ||
027aef71 RD |
54 | |
55 | ||
cbc3893c KO |
56 | class wxGraphicsPen : public wxGraphicsObject |
57 | { | |
8bd35413 | 58 | public: |
027aef71 | 59 | wxGraphicsPen() {} |
cbc3893c | 60 | virtual ~wxGraphicsPen() {} |
cbc3893c | 61 | } ; |
027aef71 RD |
62 | wxGraphicsPen wxNullGraphicsPen; |
63 | ||
64 | ||
cbc3893c KO |
65 | |
66 | class wxGraphicsBrush : public wxGraphicsObject | |
67 | { | |
68 | public : | |
027aef71 | 69 | wxGraphicsBrush() {} |
cbc3893c | 70 | virtual ~wxGraphicsBrush() {} |
cbc3893c | 71 | } ; |
027aef71 RD |
72 | wxGraphicsBrush wxNullGraphicsBrush; |
73 | ||
74 | ||
cbc3893c KO |
75 | |
76 | class wxGraphicsFont : public wxGraphicsObject | |
77 | { | |
78 | public : | |
027aef71 | 79 | wxGraphicsFont() {} |
cbc3893c | 80 | virtual ~wxGraphicsFont() {} |
cbc3893c | 81 | } ; |
027aef71 RD |
82 | wxGraphicsFont wxNullGraphicsFont; |
83 | ||
84 | ||
cbc3893c | 85 | |
95a76b75 | 86 | class wxGraphicsPath : public wxGraphicsObject |
6d61d718 RD |
87 | { |
88 | public : | |
8bd35413 | 89 | wxGraphicsPath() { } |
95a76b75 | 90 | wxGraphicsPath(wxGraphicsRenderer* ) { |
6d61d718 | 91 | PyErr_SetString(PyExc_NotImplementedError, |
95a76b75 | 92 | "wx.GraphicsPath is not available on this platform."); |
6d61d718 RD |
93 | } |
94 | virtual ~wxGraphicsPath() {} | |
95a76b75 | 95 | |
6d61d718 | 96 | void MoveToPoint( wxDouble, wxDouble ) {} |
95a76b75 RD |
97 | void MoveToPoint( const wxPoint2DDouble& ) {} |
98 | void AddLineToPoint( wxDouble, wxDouble ) {} | |
99 | void AddLineToPoint( const wxPoint2DDouble& ) {} | |
6d61d718 | 100 | void AddCurveToPoint( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, wxDouble ) {} |
95a76b75 | 101 | void AddCurveToPoint( const wxPoint2DDouble&, const wxPoint2DDouble&, const wxPoint2DDouble&) {} |
8bd35413 | 102 | void AddPath( const wxGraphicsPath& ) {} |
6d61d718 | 103 | void CloseSubpath() {} |
8bd35413 RD |
104 | void GetCurrentPoint( wxDouble&, wxDouble&) const {} |
105 | wxPoint2DDouble GetCurrentPoint() const { return wxPoint2D(0,0); } | |
6d61d718 | 106 | void AddArc( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, bool ) {} |
95a76b75 | 107 | void AddArc( const wxPoint2DDouble& , wxDouble, wxDouble , wxDouble , bool ) {} |
6d61d718 RD |
108 | |
109 | void AddQuadCurveToPoint( wxDouble, wxDouble, wxDouble, wxDouble ) {} | |
110 | void AddRectangle( wxDouble, wxDouble, wxDouble, wxDouble ) {} | |
111 | void AddCircle( wxDouble, wxDouble, wxDouble ) {} | |
112 | void AddArcToPoint( wxDouble, wxDouble , wxDouble, wxDouble, wxDouble ) {} | |
113 | ||
95a76b75 RD |
114 | void AddEllipse( wxDouble , wxDouble , wxDouble , wxDouble ) {} |
115 | void AddRoundedRectangle( wxDouble , wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
116 | void * GetNativePath() const { return NULL; } | |
8bd35413 RD |
117 | void UnGetNativePath(void *) const {} |
118 | void Transform( const wxGraphicsMatrix& ) {} | |
119 | void GetBox(wxDouble *, wxDouble *, wxDouble *, wxDouble *) const {} | |
120 | wxRect2D GetBox() const { return wxRect2D(0,0,0,0); } | |
95a76b75 | 121 | |
8bd35413 RD |
122 | bool Contains( wxDouble , wxDouble , int ) const { return false; } |
123 | bool Contains( const wxPoint2DDouble& , int ) const { return false; } | |
6d61d718 | 124 | }; |
b8910074 | 125 | wxGraphicsPath wxNullGraphicsPath; |
6d61d718 RD |
126 | |
127 | ||
95a76b75 RD |
128 | class wxGraphicsMatrix : public wxGraphicsObject |
129 | { | |
130 | public : | |
8bd35413 | 131 | wxGraphicsMatrix() { } |
95a76b75 RD |
132 | wxGraphicsMatrix(wxGraphicsRenderer* ) { |
133 | PyErr_SetString(PyExc_NotImplementedError, | |
134 | "wx.GraphicsMatrix is not available on this platform."); | |
135 | } | |
136 | virtual ~wxGraphicsMatrix() {} | |
8bd35413 RD |
137 | virtual void Concat( const wxGraphicsMatrix & ) {} |
138 | virtual void Copy( const wxGraphicsMatrix & ) {} | |
95a76b75 RD |
139 | virtual void Set(wxDouble , wxDouble , wxDouble , wxDouble , |
140 | wxDouble , wxDouble ) {} | |
141 | virtual void Invert() {} | |
8bd35413 RD |
142 | virtual bool IsEqual( const wxGraphicsMatrix& t) const { return false; } |
143 | virtual bool IsIdentity() const { return false; } | |
95a76b75 RD |
144 | virtual void Translate( wxDouble , wxDouble ) {} |
145 | virtual void Scale( wxDouble , wxDouble ) {} | |
146 | virtual void Rotate( wxDouble ) {} | |
8bd35413 RD |
147 | virtual void TransformPoint( wxDouble *, wxDouble * ) const {} |
148 | virtual void TransformDistance( wxDouble *, wxDouble * ) const {} | |
95a76b75 RD |
149 | virtual void * GetNativeMatrix() const { return NULL; } |
150 | }; | |
b8910074 | 151 | wxGraphicsMatrix wxNullGraphicsMatrix; |
95a76b75 RD |
152 | |
153 | ||
154 | class wxGraphicsContext : public wxGraphicsObject | |
6d61d718 RD |
155 | { |
156 | public: | |
95a76b75 RD |
157 | |
158 | wxGraphicsContext(wxGraphicsRenderer* ) { | |
6d61d718 | 159 | PyErr_SetString(PyExc_NotImplementedError, |
95a76b75 | 160 | "wx.GraphicsContext is not available on this platform."); |
6d61d718 | 161 | } |
95a76b75 | 162 | |
6d61d718 | 163 | virtual ~wxGraphicsContext() {} |
95a76b75 | 164 | |
8bd35413 RD |
165 | static wxGraphicsContext* Create() { |
166 | PyErr_SetString(PyExc_NotImplementedError, | |
167 | "wx.GraphicsContext is not available on this platform."); | |
168 | return NULL; | |
169 | } | |
95a76b75 | 170 | static wxGraphicsContext* Create( const wxWindowDC& ) { |
6d61d718 | 171 | PyErr_SetString(PyExc_NotImplementedError, |
95a76b75 | 172 | "wx.GraphicsContext is not available on this platform."); |
8bd35413 | 173 | return NULL; |
6d61d718 | 174 | } |
b876c1e4 | 175 | |
95a76b75 | 176 | static wxGraphicsContext* CreateFromNative( void * ) { |
b876c1e4 | 177 | PyErr_SetString(PyExc_NotImplementedError, |
95a76b75 | 178 | "wx.GraphicsContext is not available on this platform."); |
8bd35413 | 179 | return NULL; |
cbc3893c KO |
180 | } |
181 | ||
95a76b75 RD |
182 | static wxGraphicsContext* CreateFromNativeWindow( void * ) { |
183 | PyErr_SetString(PyExc_NotImplementedError, | |
184 | "wx.GraphicsContext is not available on this platform."); | |
8bd35413 | 185 | return NULL; |
95a76b75 | 186 | } |
cbc3893c | 187 | |
95a76b75 RD |
188 | static wxGraphicsContext* Create( wxWindow* ) { |
189 | PyErr_SetString(PyExc_NotImplementedError, | |
190 | "wx.GraphicsContext is not available on this platform."); | |
8bd35413 | 191 | return NULL; |
95a76b75 | 192 | } |
cbc3893c | 193 | |
8bd35413 | 194 | wxGraphicsPath CreatePath() { return wxNullGraphicsPath; } |
95a76b75 | 195 | |
8bd35413 | 196 | virtual wxGraphicsPen CreatePen(const wxPen& ) { return wxNullGraphicsPen; } |
95a76b75 | 197 | |
8bd35413 | 198 | virtual wxGraphicsBrush CreateBrush(const wxBrush& ) { return wxNullGraphicsBrush; } |
95a76b75 | 199 | |
027aef71 | 200 | virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble , wxDouble , wxDouble , wxDouble , |
8bd35413 | 201 | const wxColour&, const wxColour&) { return wxNullGraphicsBrush; } |
95a76b75 | 202 | |
027aef71 | 203 | virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, |
95a76b75 | 204 | wxDouble xc, wxDouble yc, wxDouble radius, |
8bd35413 | 205 | const wxColour &oColor, const wxColour &cColor) { return wxNullGraphicsBrush; } |
95a76b75 | 206 | |
8bd35413 | 207 | virtual wxGraphicsFont CreateFont( const wxFont &, const wxColour & ) { return wxNullGraphicsFont; } |
95a76b75 | 208 | |
8bd35413 RD |
209 | virtual wxGraphicsMatrix CreateMatrix( wxDouble, wxDouble, wxDouble, wxDouble, |
210 | wxDouble, wxDouble) { return wxNullGraphicsMatrix; } | |
95a76b75 RD |
211 | |
212 | virtual void PushState() {} | |
213 | virtual void PopState() {} | |
214 | virtual void Clip( const wxRegion & ) {} | |
215 | virtual void Clip( wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
216 | virtual void ResetClip() {} | |
217 | virtual void * GetNativeContext() { return NULL; } | |
218 | virtual void Translate( wxDouble , wxDouble ) {} | |
219 | virtual void Scale( wxDouble , wxDouble ) {} | |
220 | virtual void Rotate( wxDouble ) {} | |
8bd35413 RD |
221 | virtual void ConcatTransform( const wxGraphicsMatrix& ) {} |
222 | virtual void SetTransform( const wxGraphicsMatrix& ) {} | |
223 | virtual wxGraphicsMatrix GetTransform() const { return wxNullGraphicsMatrix; } | |
95a76b75 | 224 | |
027aef71 | 225 | virtual void SetPen( const wxGraphicsPen& ) {} |
95a76b75 RD |
226 | void SetPen( const wxPen& ) {} |
227 | ||
027aef71 | 228 | virtual void SetBrush( const wxGraphicsBrush& ) {} |
95a76b75 RD |
229 | void SetBrush( const wxBrush& ) {} |
230 | ||
027aef71 | 231 | virtual void SetFont( const wxGraphicsFont& ) {} |
95a76b75 RD |
232 | void SetFont( const wxFont&, const wxColour& ) {} |
233 | ||
8bd35413 RD |
234 | virtual void StrokePath( const wxGraphicsPath & ) {} |
235 | virtual void FillPath( const wxGraphicsPath &, int ) {} | |
236 | virtual void DrawPath( const wxGraphicsPath &, int ) {} | |
95a76b75 RD |
237 | |
238 | virtual void DrawText( const wxString &, wxDouble , wxDouble ) {} | |
239 | virtual void DrawText( const wxString &, wxDouble , wxDouble , wxDouble ) {} | |
8bd35413 RD |
240 | virtual void DrawText( const wxString &, wxDouble , wxDouble , wxGraphicsBrush ) {} |
241 | virtual void DrawText( const wxString &, wxDouble , wxDouble , wxDouble , wxGraphicsBrush ) {} | |
95a76b75 RD |
242 | virtual void GetTextExtent( const wxString &, wxDouble *, wxDouble *, |
243 | wxDouble *, wxDouble * ) const {} | |
244 | virtual void GetPartialTextExtents(const wxString& , wxArrayDouble& ) const {} | |
245 | ||
246 | virtual void DrawBitmap( const wxBitmap &, wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
247 | virtual void DrawIcon( const wxIcon &, wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
248 | ||
249 | virtual void StrokeLine( wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
250 | virtual void StrokeLines( size_t , const wxPoint2DDouble *) {} | |
251 | virtual void StrokeLines( size_t , const wxPoint2DDouble *, const wxPoint2DDouble *) {} | |
252 | virtual void DrawLines( size_t , const wxPoint2DDouble *, int ) {} | |
253 | virtual void DrawRectangle( wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
8bd35413 | 254 | virtual void DrawRoundedRectangle( wxDouble , wxDouble , wxDouble , wxDouble , wxDouble ) {} |
95a76b75 RD |
255 | virtual void DrawEllipse( wxDouble , wxDouble , wxDouble , wxDouble ) {} |
256 | virtual void DrawRoundedRectangle( wxDouble wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
257 | virtual bool ShouldOffset() const { return false; } | |
258 | }; | |
259 | ||
260 | ||
261 | class wxGraphicsRenderer : public wxObject | |
262 | { | |
263 | public : | |
264 | wxGraphicsRenderer() { | |
265 | PyErr_SetString(PyExc_NotImplementedError, | |
266 | "wx.GraphicsRenderer is not available on this platform."); | |
267 | } | |
268 | ||
269 | virtual ~wxGraphicsRenderer() {} | |
b876c1e4 | 270 | |
8bd35413 | 271 | static wxGraphicsRenderer* GetDefaultRenderer() { |
95a76b75 RD |
272 | PyErr_SetString(PyExc_NotImplementedError, |
273 | "wx.GraphicsRenderer is not available on this platform."); | |
8bd35413 RD |
274 | return NULL; |
275 | } | |
95a76b75 RD |
276 | |
277 | virtual wxGraphicsContext * CreateContext( const wxWindowDC& ) { return NULL; } | |
278 | virtual wxGraphicsContext * CreateContextFromNativeContext( void * ) { return NULL; } | |
279 | virtual wxGraphicsContext * CreateContextFromNativeWindow( void * ) { return NULL; } | |
280 | virtual wxGraphicsContext * CreateContext( wxWindow* ) { return NULL; } | |
8bd35413 | 281 | virtual wxGraphicsContext * CreateMeasuringContext() { return NULL; } |
95a76b75 | 282 | |
8bd35413 | 283 | virtual wxGraphicsPath CreatePath() { return wxNullGraphicsPath; } |
95a76b75 | 284 | |
8bd35413 RD |
285 | virtual wxGraphicsMatrix CreateMatrix( wxDouble , wxDouble , wxDouble , wxDouble , |
286 | wxDouble , wxDouble ) { return wxNullGraphicsMatrix; } | |
027aef71 | 287 | |
8bd35413 RD |
288 | virtual wxGraphicsPen CreatePen(const wxPen& ) { return wxNullGraphicsPen; } |
289 | virtual wxGraphicsBrush CreateBrush(const wxBrush& ) { return wxNullGraphicsBrush; } | |
290 | virtual wxGraphicsBrush CreateLinearGradientBrush(wxDouble , wxDouble , wxDouble , wxDouble , | |
291 | const wxColour&, const wxColour&) { return wxNullGraphicsBrush; } | |
027aef71 | 292 | virtual wxGraphicsBrush CreateRadialGradientBrush(wxDouble , wxDouble , wxDouble , wxDouble , wxDouble , |
8bd35413 RD |
293 | const wxColour &, const wxColour &) { return wxNullGraphicsBrush; } |
294 | virtual wxGraphicsFont CreateFont( const wxFont & , const wxColour & ) { return wxNullGraphicsFont; } | |
6d61d718 RD |
295 | }; |
296 | ||
297 | ||
95a76b75 | 298 | |
6d61d718 RD |
299 | class wxGCDC: public wxWindowDC |
300 | { | |
301 | public: | |
302 | wxGCDC(const wxWindowDC&) { | |
303 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
304 | PyErr_SetString(PyExc_NotImplementedError, | |
305 | "wxGCDC is not available on this platform."); | |
306 | wxPyEndBlockThreads(blocked); | |
307 | } | |
95a76b75 | 308 | |
49f7b879 RD |
309 | wxGCDC(const wxWindow*) { |
310 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
311 | PyErr_SetString(PyExc_NotImplementedError, | |
312 | "wxGCDC is not available on this platform."); | |
313 | wxPyEndBlockThreads(blocked); | |
314 | } | |
315 | ||
6d61d718 RD |
316 | wxGCDC() { |
317 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
318 | PyErr_SetString(PyExc_NotImplementedError, | |
319 | "wxGCDC is not available on this platform."); | |
320 | wxPyEndBlockThreads(blocked); | |
321 | } | |
95a76b75 | 322 | |
6d61d718 RD |
323 | virtual ~wxGCDC() {} |
324 | ||
b876c1e4 RD |
325 | wxGraphicsContext* GetGraphicsContext() { return NULL; } |
326 | void SetGraphicsContext( wxGraphicsContext* ) {} | |
6d61d718 RD |
327 | }; |
328 | ||
329 | #endif | |
330 | %} | |
331 | ||
332 | //--------------------------------------------------------------------------- | |
333 | //--------------------------------------------------------------------------- | |
334 | ||
281c54cc RD |
335 | |
336 | %typemap(in) (size_t points, wxPoint2D* points_array ) { | |
337 | $2 = wxPoint2D_LIST_helper($input, &$1); | |
338 | if ($2 == NULL) SWIG_fail; | |
339 | } | |
340 | %typemap(freearg) (size_t points, wxPoint2D* points_array ) { | |
341 | if ($2) delete [] $2; | |
342 | } | |
343 | ||
344 | ||
345 | ||
6d61d718 RD |
346 | MustHaveApp(wxGraphicsPath); |
347 | MustHaveApp(wxGraphicsContext); | |
348 | MustHaveApp(wxGCDC); | |
349 | ||
6d61d718 RD |
350 | typedef double wxDouble; |
351 | ||
352 | ||
027aef71 RD |
353 | //--------------------------------------------------------------------------- |
354 | ||
6d61d718 | 355 | |
215a6add RD |
356 | DocStr(wxGraphicsObject, |
357 | "This class is the superclass of native graphics objects like pens | |
358 | etc. It provides the internal reference counting. It is not to be | |
359 | instantiated by user code.", ""); | |
cbc3893c KO |
360 | class wxGraphicsObject : public wxObject |
361 | { | |
362 | public : | |
95a76b75 RD |
363 | wxGraphicsObject( wxGraphicsRenderer* renderer = NULL ); |
364 | virtual ~wxGraphicsObject(); | |
215a6add RD |
365 | |
366 | DocDeclStr( | |
367 | bool , IsNull() const , | |
368 | "Is this object valid (false) or still empty (true)?", ""); | |
369 | ||
370 | DocDeclStr( | |
371 | wxGraphicsRenderer* , GetRenderer() const, | |
372 | "Returns the renderer that was used to create this instance, or | |
373 | ``None`` if it has not been initialized yet.", ""); | |
374 | ||
95a76b75 RD |
375 | }; |
376 | ||
cbc3893c | 377 | |
215a6add RD |
378 | DocStr(wxGraphicsPen, |
379 | "A wx.GraphicsPen is a native representation of a pen. It is used for | |
380 | stroking a path on a `wx.GraphicsContext`. The contents are specific and | |
381 | private to the respective renderer. The only way to get a valid instance | |
382 | is via a CreatePen call on the graphics context or the renderer | |
383 | instance.", ""); | |
cbc3893c KO |
384 | class wxGraphicsPen : public wxGraphicsObject |
385 | { | |
386 | public : | |
027aef71 | 387 | wxGraphicsPen(); |
cbc3893c | 388 | virtual ~wxGraphicsPen(); |
95a76b75 RD |
389 | }; |
390 | ||
215a6add RD |
391 | DocStr(wxGraphicsBrush, |
392 | "A wx.GraphicsBrush is a native representation of a brush. It is used | |
393 | for filling a path on a `wx.GraphicsContext`. The contents are | |
394 | specific and private to the respective renderer. The only way to get a | |
395 | valid instance is via a Create...Brush call on the graphics context or | |
396 | the renderer instance.", ""); | |
cbc3893c KO |
397 | class wxGraphicsBrush : public wxGraphicsObject |
398 | { | |
399 | public : | |
027aef71 | 400 | wxGraphicsBrush(); |
cbc3893c | 401 | virtual ~wxGraphicsBrush(); |
95a76b75 RD |
402 | }; |
403 | ||
cbc3893c | 404 | |
215a6add RD |
405 | DocStr(wxGraphicsFont, |
406 | "A `wx.GraphicsFont` is a native representation of a font (including | |
407 | text colour). The contents are specific an private to the respective | |
408 | renderer. The only way to get a valid instance is via a CreateFont | |
409 | call on the graphics context or the renderer instance.", ""); | |
cbc3893c KO |
410 | class wxGraphicsFont : public wxGraphicsObject |
411 | { | |
412 | public : | |
027aef71 | 413 | wxGraphicsFont(); |
cbc3893c | 414 | virtual ~wxGraphicsFont(); |
95a76b75 RD |
415 | }; |
416 | ||
027aef71 | 417 | |
b8910074 RD |
418 | //--------------------------------------------------------------------------- |
419 | ||
215a6add RD |
420 | DocStr(wxGraphicsMatrix, |
421 | "A wx.GraphicsMatrix is a native representation of an affine | |
422 | matrix. The contents are specific an private to the respective | |
423 | renderer. The only way to get a valid instance is via a CreateMatrix | |
424 | call on the graphics context or the renderer instance.", ""); | |
b8910074 RD |
425 | class wxGraphicsMatrix : public wxGraphicsObject |
426 | { | |
427 | public : | |
8f514ab4 | 428 | wxGraphicsMatrix(); |
b8910074 RD |
429 | virtual ~wxGraphicsMatrix(); |
430 | ||
431 | DocDeclStr( | |
432 | virtual void , Concat( const wxGraphicsMatrix& t ), | |
215a6add | 433 | "Concatenates the passed in matrix to the current matrix.", ""); |
b8910074 | 434 | |
215a6add RD |
435 | // %extend { |
436 | // DocStr(Copy, | |
437 | // "Copy the passed in matrix to this one.", ""); | |
438 | // void Copy( const wxGraphicsMatrix& t ) { | |
439 | // *self = t; | |
440 | // } | |
441 | // } | |
b8910074 RD |
442 | |
443 | ||
444 | DocDeclStr( | |
445 | virtual void , Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, | |
446 | wxDouble tx=0.0, wxDouble ty=0.0), | |
215a6add RD |
447 | "Sets the matrix to the specified values (default values are the |
448 | identity matrix.)", ""); | |
b8910074 RD |
449 | |
450 | ||
451 | DocDeclStr( | |
452 | virtual void , Invert(), | |
215a6add | 453 | "Inverts the matrix.", ""); |
b8910074 RD |
454 | |
455 | ||
456 | DocDeclStr( | |
457 | virtual bool , IsEqual( const wxGraphicsMatrix& t) const, | |
215a6add | 458 | "Returns ``True`` if the elements of the transformation matrix are equal", ""); |
b8910074 RD |
459 | |
460 | ||
461 | DocDeclStr( | |
462 | virtual bool , IsIdentity() const, | |
215a6add | 463 | "Returns ``True`` if this is the identity matrix", ""); |
b8910074 RD |
464 | |
465 | ||
466 | DocDeclStr( | |
467 | virtual void , Translate( wxDouble dx , wxDouble dy ), | |
215a6add | 468 | "Add a translation to this matrix.", ""); |
b8910074 RD |
469 | |
470 | ||
471 | DocDeclStr( | |
472 | virtual void , Scale( wxDouble xScale , wxDouble yScale ), | |
215a6add | 473 | "Scales this matrix.", ""); |
b8910074 RD |
474 | |
475 | ||
476 | DocDeclStr( | |
477 | virtual void , Rotate( wxDouble angle ), | |
215a6add | 478 | "Rotates this matrix. The angle should be specified in radians.", ""); |
b8910074 RD |
479 | |
480 | ||
481 | DocDeclAStr( | |
482 | virtual void , TransformPoint( wxDouble *INOUT, wxDouble *INOUT ) const, | |
483 | "TransformPoint(self, x, y) --> (x, y)", | |
215a6add | 484 | "Applies this matrix to a point, returns the resulting point values", ""); |
b8910074 RD |
485 | |
486 | ||
487 | DocDeclAStr( | |
488 | virtual void , TransformDistance( wxDouble *INOUT, wxDouble *INOUT ) const, | |
489 | "TransformDistance(self, dx, dy) --> (dx, dy)", | |
215a6add RD |
490 | "Applies this matrix to a distance (ie. performs all transforms except |
491 | translations)", ""); | |
b8910074 RD |
492 | |
493 | ||
494 | DocDeclStr( | |
495 | virtual void * , GetNativeMatrix() const, | |
215a6add RD |
496 | "Returns the native representation of the matrix. For CoreGraphics this |
497 | is a CFAffineMatrix pointer. For GDIPlus a Matrix Pointer and for | |
498 | Cairo a cairo_matrix_t pointer. NOTE: For wxPython we still need a | |
499 | way to make this value usable.", ""); | |
b8910074 | 500 | }; |
027aef71 | 501 | |
95a76b75 | 502 | //--------------------------------------------------------------------------- |
cbc3893c | 503 | |
95a76b75 | 504 | class wxGraphicsPath : public wxGraphicsObject |
6d61d718 RD |
505 | { |
506 | public : | |
8f514ab4 | 507 | wxGraphicsPath(); |
6d61d718 | 508 | virtual ~wxGraphicsPath(); |
95a76b75 | 509 | |
027aef71 RD |
510 | |
511 | %nokwargs MoveToPoint; | |
512 | DocStr(MoveToPoint, | |
215a6add | 513 | "Begins a new subpath at the specified point.", ""); |
027aef71 RD |
514 | virtual void MoveToPoint( wxDouble x, wxDouble y ); |
515 | void MoveToPoint( const wxPoint2D& p); | |
95a76b75 | 516 | |
6d61d718 | 517 | |
027aef71 RD |
518 | %nokwargs AddLineToPoint; |
519 | DocStr(AddLineToPoint, | |
215a6add | 520 | "Adds a straight line from the current point to the specified point.", ""); |
027aef71 RD |
521 | virtual void AddLineToPoint( wxDouble x, wxDouble y ); |
522 | void AddLineToPoint( const wxPoint2D& p); | |
95a76b75 | 523 | |
6d61d718 | 524 | |
027aef71 RD |
525 | %nokwargs AddCurveToPoint; |
526 | DocStr(AddCurveToPoint, | |
6d61d718 RD |
527 | "Adds a cubic Bezier curve from the current point, using two control |
528 | points and an end point", ""); | |
027aef71 RD |
529 | virtual void AddCurveToPoint( wxDouble cx1, wxDouble cy1, |
530 | wxDouble cx2, wxDouble cy2, | |
531 | wxDouble x, wxDouble y ); | |
532 | void AddCurveToPoint( const wxPoint2D& c1, const wxPoint2D& c2, const wxPoint2D& e); | |
95a76b75 RD |
533 | |
534 | ||
535 | ||
536 | DocDeclStr( | |
b8910074 | 537 | virtual void , AddPath( const wxGraphicsPath& path ), |
215a6add | 538 | "Adds another path", ""); |
95a76b75 | 539 | |
6d61d718 RD |
540 | |
541 | DocDeclStr( | |
542 | virtual void , CloseSubpath(), | |
215a6add | 543 | "Closes the current sub-path.", ""); |
95a76b75 | 544 | |
6d61d718 | 545 | |
6d61d718 | 546 | DocDeclStr( |
b8910074 | 547 | wxPoint2D , GetCurrentPoint() const, |
6d61d718 | 548 | "Gets the last point of the current path, (0,0) if not yet set", ""); |
95a76b75 | 549 | |
6d61d718 | 550 | |
027aef71 RD |
551 | %nokwargs AddArc; |
552 | DocStr(AddArc, | |
6d61d718 RD |
553 | "Adds an arc of a circle centering at (x,y) with radius (r) from |
554 | startAngle to endAngle", ""); | |
027aef71 RD |
555 | virtual void AddArc( wxDouble x, wxDouble y, wxDouble r, |
556 | wxDouble startAngle, wxDouble endAngle, bool clockwise ); | |
557 | void AddArc( const wxPoint2D& c, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise); | |
95a76b75 | 558 | |
6d61d718 RD |
559 | |
560 | DocDeclStr( | |
561 | virtual void , AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y ), | |
562 | "Adds a quadratic Bezier curve from the current point, using a control | |
563 | point and an end point", ""); | |
95a76b75 | 564 | |
6d61d718 RD |
565 | |
566 | DocDeclStr( | |
567 | virtual void , AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ), | |
215a6add | 568 | "Appends a rectangle as a new closed subpath.", ""); |
95a76b75 | 569 | |
6d61d718 RD |
570 | |
571 | DocDeclStr( | |
572 | virtual void , AddCircle( wxDouble x, wxDouble y, wxDouble r ), | |
215a6add | 573 | "Appends a circle around (x,y) with radius r as a new closed subpath.", ""); |
95a76b75 | 574 | |
6d61d718 RD |
575 | |
576 | DocDeclStr( | |
577 | virtual void , AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) , | |
215a6add | 578 | "Appends an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) |
6d61d718 | 579 | to (x2,y2), also a straight line from (current) to (x1,y1)", ""); |
95a76b75 RD |
580 | |
581 | ||
582 | DocDeclStr( | |
583 | virtual void , AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h), | |
215a6add | 584 | "Appends an ellipse fitting into the passed in rectangle.", ""); |
95a76b75 RD |
585 | |
586 | ||
587 | DocDeclStr( | |
588 | virtual void , AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius), | |
215a6add | 589 | "Appends a rounded rectangle.", ""); |
95a76b75 RD |
590 | |
591 | ||
592 | DocDeclStr( | |
593 | virtual void * , GetNativePath() const, | |
215a6add RD |
594 | "Returns the native path (CGPathRef for Core Graphics, Path pointer for |
595 | GDIPlus and a cairo_path_t pointer for cairo). NOTE: For wxPython we | |
596 | still need a way to make this value usable.", ""); | |
95a76b75 RD |
597 | |
598 | ||
599 | DocDeclStr( | |
b8910074 | 600 | virtual void , UnGetNativePath(void *p) const, |
215a6add RD |
601 | "Gives back the native path returned by GetNativePath() because there |
602 | might be some deallocations necessary (eg on cairo the native path | |
603 | returned by GetNativePath is newly allocated each time).", ""); | |
95a76b75 RD |
604 | |
605 | ||
606 | DocDeclStr( | |
b8910074 | 607 | virtual void , Transform( const wxGraphicsMatrix& matrix ), |
215a6add | 608 | "Transforms each point of this path by the matrix", ""); |
95a76b75 RD |
609 | |
610 | ||
95a76b75 | 611 | DocDeclStr( |
b8910074 | 612 | wxRect2DDouble , GetBox() const, |
215a6add | 613 | "Gets the bounding box enclosing all points (possibly including control points)", ""); |
95a76b75 RD |
614 | |
615 | ||
027aef71 RD |
616 | %nokwargs Contains; |
617 | DocStr(Contains, | |
215a6add | 618 | "Returns ``True`` if the point is within the path.", ""); |
b8910074 RD |
619 | virtual bool Contains( wxDouble x, wxDouble y, int fillStyle = wxODDEVEN_RULE) const; |
620 | bool Contains( const wxPoint2DDouble& c, int fillStyle = wxODDEVEN_RULE) const; | |
6d61d718 RD |
621 | |
622 | }; | |
623 | ||
95a76b75 | 624 | |
b8910074 | 625 | //--------------------------------------------------------------------------- |
95a76b75 | 626 | |
b8910074 RD |
627 | %immutable; |
628 | const wxGraphicsPen wxNullGraphicsPen; | |
629 | const wxGraphicsBrush wxNullGraphicsBrush; | |
630 | const wxGraphicsFont wxNullGraphicsFont; | |
631 | const wxGraphicsMatrix wxNullGraphicsMatrix; | |
632 | const wxGraphicsPath wxNullGraphicsPath; | |
633 | %mutable; | |
95a76b75 | 634 | |
6d61d718 RD |
635 | //--------------------------------------------------------------------------- |
636 | ||
215a6add RD |
637 | DocStr(wxGraphicsContext, |
638 | "A `wx.GraphicsContext` instance is the object that is drawn upon. It is | |
639 | created by a renderer using the CreateContext calls, this can be done | |
640 | either directly using a renderer instance, or indirectly using the | |
641 | static convenience CreateXXX functions of wx.GraphicsContext that | |
642 | always delegate the task to the default renderer.", ""); | |
6d61d718 | 643 | |
95a76b75 | 644 | class wxGraphicsContext : public wxGraphicsObject |
6d61d718 RD |
645 | { |
646 | public: | |
215a6add | 647 | //wxGraphicsContext(); This is an ABC, use Create to make an instance... |
6d61d718 | 648 | virtual ~wxGraphicsContext(); |
8292b82b | 649 | |
2742805a | 650 | %newobject Create; |
8292b82b | 651 | %nokwargs Create; |
2742805a RD |
652 | %pythonAppend Create |
653 | "val.__dc = args[0] # save a ref so the dc will not be deleted before self"; | |
215a6add RD |
654 | DocStr(Create, |
655 | "Creates a wx.GraphicsContext either from a window or a DC.", ""); | |
6d61d718 | 656 | static wxGraphicsContext* Create( const wxWindowDC& dc); |
8292b82b RD |
657 | static wxGraphicsContext* Create( wxWindow* window ) ; |
658 | ||
59c516a3 RD |
659 | DocDeclStrName( |
660 | static wxGraphicsContext* , Create(), | |
661 | "Create a lightwieght context that can be used for measuring text only.", "", | |
662 | CreateMeasuringContext); | |
215a6add | 663 | |
2742805a | 664 | %newobject CreateFromNative; |
215a6add RD |
665 | DocDeclStr( |
666 | static wxGraphicsContext* , CreateFromNative( void * context ) , | |
667 | "Creates a wx.GraphicsContext from a native context. This native context | |
668 | must be eg a CGContextRef for Core Graphics, a Graphics pointer for | |
669 | GDIPlus or a cairo_t pointer for Cairo.", ""); | |
670 | ||
8292b82b | 671 | |
95a76b75 | 672 | %newobject CreateFromNative; |
215a6add RD |
673 | DocDeclStr( |
674 | static wxGraphicsContext* , CreateFromNativeWindow( void * window ) , | |
675 | "Creates a wx.GraphicsContext from a native window.", ""); | |
676 | ||
95a76b75 | 677 | |
6d61d718 | 678 | |
6d61d718 | 679 | DocDeclStr( |
b8910074 | 680 | virtual wxGraphicsPath , CreatePath(), |
215a6add | 681 | "Creates a native graphics path which is initially empty.", ""); |
95a76b75 RD |
682 | |
683 | ||
95a76b75 | 684 | DocDeclStr( |
027aef71 | 685 | virtual wxGraphicsPen , CreatePen(const wxPen& pen), |
215a6add | 686 | "Creates a native pen from a `wx.Pen`.", ""); |
cbc3893c | 687 | |
cbc3893c | 688 | |
95a76b75 | 689 | DocDeclStr( |
027aef71 | 690 | virtual wxGraphicsBrush , CreateBrush(const wxBrush& brush ), |
215a6add | 691 | "Creates a native brush from a `wx.Brush`.", ""); |
95a76b75 RD |
692 | |
693 | ||
95a76b75 | 694 | DocDeclStr( |
027aef71 | 695 | virtual wxGraphicsBrush , |
95a76b75 RD |
696 | CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, |
697 | const wxColour& c1, const wxColour& c2), | |
215a6add RD |
698 | "Creates a native brush, having a linear gradient, starting at (x1,y1) |
699 | with color c1 to (x2,y2) with color c2.", ""); | |
6d61d718 | 700 | |
8292b82b | 701 | |
95a76b75 | 702 | DocDeclStr( |
027aef71 | 703 | virtual wxGraphicsBrush , |
95a76b75 RD |
704 | CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, |
705 | const wxColour &oColor, const wxColour &cColor), | |
215a6add RD |
706 | "Creates a native brush, having a radial gradient originating at |
707 | point (xo,yc) with color oColour and ends on a circle around (xc,yc) with | |
708 | radius r and color cColour.", ""); | |
95a76b75 RD |
709 | |
710 | ||
95a76b75 | 711 | DocDeclStr( |
027aef71 | 712 | virtual wxGraphicsFont , CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ), |
215a6add | 713 | "Creates a native graphics font from a `wx.Font` and a text colour.", ""); |
95a76b75 RD |
714 | |
715 | ||
95a76b75 | 716 | DocDeclStr( |
b8910074 RD |
717 | virtual wxGraphicsMatrix , CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, |
718 | wxDouble c=0.0, wxDouble d=1.0, | |
719 | wxDouble tx=0.0, wxDouble ty=0.0), | |
215a6add RD |
720 | "Creates a native affine transformation matrix from the passed in |
721 | values. The defaults result in an identity matrix.", ""); | |
95a76b75 RD |
722 | |
723 | ||
724 | ||
6d61d718 RD |
725 | DocDeclStr( |
726 | virtual void , PushState(), | |
95a76b75 RD |
727 | "push the current state of the context, ie the transformation matrix on a stack", ""); |
728 | ||
6d61d718 | 729 | |
6d61d718 RD |
730 | DocDeclStr( |
731 | virtual void , PopState(), | |
95a76b75 RD |
732 | "pops a stored state from the stack", ""); |
733 | ||
6d61d718 | 734 | |
8292b82b | 735 | DocDeclStrName( |
6d61d718 | 736 | virtual void , Clip( const wxRegion ®ion ), |
215a6add | 737 | "Clips drawings to the region, combined to current clipping region.", "", |
8292b82b | 738 | ClipRegion); |
95a76b75 | 739 | |
8292b82b | 740 | |
8292b82b RD |
741 | DocDeclStr( |
742 | virtual void , Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ), | |
215a6add | 743 | "Clips drawings to the rectangle.", ""); |
95a76b75 RD |
744 | |
745 | ||
8292b82b RD |
746 | DocDeclStr( |
747 | virtual void , ResetClip(), | |
215a6add | 748 | "Resets the clipping to original shape.", ""); |
95a76b75 | 749 | |
6d61d718 | 750 | |
8292b82b RD |
751 | DocDeclStr( |
752 | virtual void * , GetNativeContext(), | |
215a6add RD |
753 | "Returns the native context (CGContextRef for Core Graphics, Graphics |
754 | pointer for GDIPlus and cairo_t pointer for cairo).", ""); | |
8292b82b RD |
755 | |
756 | ||
6d61d718 RD |
757 | DocDeclStr( |
758 | virtual void , Translate( wxDouble dx , wxDouble dy ), | |
215a6add | 759 | "Translates the current transformation matrix.", ""); |
95a76b75 | 760 | |
6d61d718 | 761 | |
6d61d718 RD |
762 | DocDeclStr( |
763 | virtual void , Scale( wxDouble xScale , wxDouble yScale ), | |
215a6add | 764 | "Scale the current transformation matrix of the context.", ""); |
95a76b75 | 765 | |
6d61d718 | 766 | |
6d61d718 RD |
767 | DocDeclStr( |
768 | virtual void , Rotate( wxDouble angle ), | |
215a6add RD |
769 | "Rotate the current transformation matrix of the context. ``angle`` is |
770 | specified in radians.", ""); | |
6d61d718 | 771 | |
6d61d718 | 772 | |
b8910074 RD |
773 | DocDeclStr( |
774 | virtual void , ConcatTransform( const wxGraphicsMatrix& matrix ), | |
215a6add RD |
775 | "Concatenates the passed in transform with the current transform of |
776 | this context.", ""); | |
b8910074 RD |
777 | |
778 | ||
779 | DocDeclStr( | |
780 | virtual void , SetTransform( const wxGraphicsMatrix& matrix ), | |
215a6add | 781 | "Sets the current transform of this context.", ""); |
b8910074 RD |
782 | |
783 | ||
784 | DocDeclStr( | |
785 | virtual wxGraphicsMatrix , GetTransform() const, | |
215a6add | 786 | "Gets the current transformation matrix of this context.", ""); |
b8910074 RD |
787 | |
788 | ||
789 | ||
6d61d718 | 790 | |
215a6add | 791 | DocStr(SetPen, "Sets the stroke pen", ""); |
95a76b75 | 792 | %nokwargs SetPen; |
027aef71 | 793 | virtual void SetPen( const wxGraphicsPen& pen ); |
95a76b75 RD |
794 | void SetPen( const wxPen& pen ); |
795 | ||
6d61d718 | 796 | |
215a6add | 797 | DocStr(SetBrush, "Sets the brush for filling", ""); |
95a76b75 | 798 | %nokwargs SetBrush; |
027aef71 | 799 | virtual void SetBrush( const wxGraphicsBrush& brush ); |
95a76b75 RD |
800 | void SetBrush( const wxBrush& brush ); |
801 | ||
cbc3893c | 802 | |
215a6add | 803 | DocStr(SetFont, "Sets the font", ""); |
95a76b75 | 804 | %nokwargs SetFont; |
027aef71 | 805 | virtual void SetFont( const wxGraphicsFont& font ); |
95a76b75 | 806 | void SetFont( const wxFont& font, const wxColour& colour = *wxBLACK); |
6d61d718 | 807 | |
95a76b75 RD |
808 | |
809 | ||
6d61d718 | 810 | DocDeclStr( |
b8910074 | 811 | virtual void , StrokePath( const wxGraphicsPath& path ), |
215a6add | 812 | "Strokes along a path with the current pen.", ""); |
6d61d718 | 813 | |
95a76b75 | 814 | |
6d61d718 | 815 | DocDeclStr( |
b8910074 | 816 | virtual void , FillPath( const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE ), |
215a6add | 817 | "Fills a path with the current brush.", ""); |
6d61d718 | 818 | |
95a76b75 | 819 | |
6d61d718 | 820 | DocDeclStr( |
b8910074 | 821 | virtual void , DrawPath( const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE ), |
215a6add | 822 | "Draws the path by first filling and then stroking.", ""); |
95a76b75 | 823 | |
6d61d718 | 824 | |
59c516a3 RD |
825 | %extend { |
826 | DocStr(DrawText, | |
827 | "Draws a text string at the defined position.", ""); | |
828 | void DrawText( const wxString &str, wxDouble x, wxDouble y, | |
829 | const wxGraphicsBrush& backgroundBrush = wxNullGraphicsBrush ) | |
830 | { | |
831 | if ( !backgroundBrush.IsNull() ) | |
832 | self->DrawText(str, x, y, backgroundBrush); | |
833 | else | |
834 | self->DrawText(str, x, y); | |
835 | } | |
6d61d718 | 836 | |
59c516a3 | 837 | DocStr(DrawRotatedText, |
254e112c RD |
838 | "Draws a text string at the defined position, at the specified angle, |
839 | which is given in radians.", ""); | |
59c516a3 RD |
840 | void DrawRotatedText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle, |
841 | const wxGraphicsBrush& backgroundBrush = wxNullGraphicsBrush ) | |
842 | { | |
843 | if ( !backgroundBrush.IsNull() ) | |
844 | self->DrawText(str, x, y, angle, backgroundBrush); | |
845 | else | |
846 | self->DrawText(str, x, y, angle); | |
847 | } | |
848 | } | |
849 | ||
95a76b75 | 850 | |
6d61d718 | 851 | |
752d967c | 852 | DocDeclAStrName( |
6d61d718 RD |
853 | virtual void , GetTextExtent( const wxString &text, |
854 | wxDouble *OUTPUT /*width*/, | |
855 | wxDouble *OUTPUT /*height*/, | |
856 | wxDouble *OUTPUT /*descent*/, | |
857 | wxDouble *OUTPUT /*externalLeading*/ ) const , | |
752d967c | 858 | "GetFullTextExtent(self, text) --> (width, height, descent, externalLeading)", |
215a6add RD |
859 | "Gets the dimensions of the string using the currently selected |
860 | font. ``text`` is the string to measure, ``w`` and ``h`` are the total | |
861 | width and height respectively, ``descent`` is the dimension from the | |
862 | baseline of the font to the bottom of the descender, and | |
863 | ``externalLeading`` is any extra vertical space added to the font by | |
864 | the font designer (usually is zero).", "", | |
752d967c RD |
865 | GetFullTextExtent); |
866 | ||
867 | %extend { | |
868 | DocAStr(GetTextExtent, | |
869 | "GetTextExtent(self, text) --> (width, height)", | |
215a6add RD |
870 | "Gets the dimensions of the string using the currently selected |
871 | font. ``text`` is the string to measure, ``w`` and ``h`` are the total | |
872 | width and height respectively.", ""); | |
95a76b75 | 873 | |
752d967c RD |
874 | PyObject* GetTextExtent( const wxString &text ) |
875 | { | |
876 | wxDouble width = 0.0, | |
877 | height = 0.0; | |
878 | self->GetTextExtent(text, &width, &height, NULL, NULL); | |
879 | // thread wrapers are turned off for this .i file, so no need to acquire GIL... | |
880 | PyObject* rv = PyTuple_New(2); | |
881 | PyTuple_SET_ITEM(rv, 0, PyFloat_FromDouble(width)); | |
882 | PyTuple_SET_ITEM(rv, 1, PyFloat_FromDouble(height)); | |
883 | return rv; | |
884 | } | |
885 | } | |
95a76b75 | 886 | |
6d61d718 | 887 | |
281c54cc RD |
888 | %extend { |
889 | DocAStr(GetPartialTextExtents, | |
890 | "GetPartialTextExtents(self, text) -> [widths]", | |
215a6add RD |
891 | "Returns a list of widths from the beginning of ``text`` to the |
892 | coresponding character in ``text``.", ""); | |
281c54cc RD |
893 | wxArrayDouble GetPartialTextExtents(const wxString& text) { |
894 | wxArrayDouble widths; | |
895 | self->GetPartialTextExtents(text, widths); | |
896 | return widths; | |
897 | } | |
898 | } | |
6d61d718 | 899 | |
6d61d718 RD |
900 | |
901 | DocDeclStr( | |
902 | virtual void , DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ), | |
215a6add RD |
903 | "Draws the bitmap. In case of a mono bitmap, this is treated as a mask |
904 | and the current brush is used for filling.", ""); | |
95a76b75 | 905 | |
6d61d718 RD |
906 | |
907 | DocDeclStr( | |
908 | virtual void , DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ), | |
215a6add | 909 | "Draws the icon.", ""); |
6d61d718 | 910 | |
95a76b75 RD |
911 | |
912 | ||
6d61d718 RD |
913 | DocDeclStr( |
914 | virtual void , StrokeLine( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2), | |
215a6add | 915 | "Strokes a single line.", ""); |
6d61d718 | 916 | |
281c54cc | 917 | |
281c54cc RD |
918 | DocDeclAStr( |
919 | virtual void , StrokeLines( size_t points, const wxPoint2D *points_array), | |
920 | "StrokeLines(self, List points)", | |
215a6add | 921 | "Stroke lines connecting each of the points", ""); |
6d61d718 | 922 | |
281c54cc | 923 | |
281c54cc | 924 | %extend { |
95a76b75 | 925 | DocStr(StrokeLineSegements, |
215a6add | 926 | "Stroke disconnected lines from begin to end points", ""); |
aa43bcc7 | 927 | void StrokeLineSegements(PyObject* beginPoints, PyObject* endPoints) |
281c54cc RD |
928 | { |
929 | size_t c1, c2, count; | |
930 | wxPoint2D* beginP = wxPoint2D_LIST_helper(beginPoints, &c1); | |
931 | wxPoint2D* endP = wxPoint2D_LIST_helper(endPoints, &c2); | |
932 | ||
933 | if ( beginP != NULL && endP != NULL ) | |
934 | { | |
935 | count = wxMin(c1, c2); | |
936 | self->StrokeLines(count, beginP, endP); | |
937 | } | |
938 | delete [] beginP; | |
939 | delete [] endP; | |
940 | } | |
941 | } | |
6d61d718 | 942 | |
95a76b75 | 943 | |
6d61d718 | 944 | DocDeclStr( |
b8910074 RD |
945 | virtual void , DrawLines( size_t points, const wxPoint2D *points_array, |
946 | int fillStyle = wxODDEVEN_RULE ), | |
215a6add | 947 | "Draws a polygon.", ""); |
95a76b75 | 948 | |
6d61d718 | 949 | |
6d61d718 RD |
950 | DocDeclStr( |
951 | virtual void , DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h), | |
215a6add | 952 | "Draws a rectangle.", ""); |
95a76b75 | 953 | |
6d61d718 | 954 | |
6d61d718 RD |
955 | DocDeclStr( |
956 | virtual void , DrawEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h), | |
215a6add | 957 | "Draws an ellipse.", ""); |
95a76b75 | 958 | |
6d61d718 | 959 | |
6d61d718 RD |
960 | DocDeclStr( |
961 | virtual void , DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius), | |
215a6add | 962 | "Draws a rounded rectangle", ""); |
95a76b75 RD |
963 | |
964 | ||
965 | ||
966 | DocDeclStr( | |
967 | virtual bool , ShouldOffset() const, | |
968 | "helper to determine if a 0.5 offset should be applied for the drawing operation", ""); | |
969 | ||
970 | }; | |
971 | ||
972 | ||
973 | //--------------------------------------------------------------------------- | |
974 | ||
975 | class wxGraphicsRenderer : public wxObject | |
976 | { | |
977 | public : | |
978 | // wxGraphicsRenderer(); This is an ABC, use GetDefaultRenderer | |
979 | ||
980 | virtual ~wxGraphicsRenderer(); | |
981 | ||
982 | // %newobject GetDefaultRenderer; ??? | |
983 | static wxGraphicsRenderer* GetDefaultRenderer(); | |
984 | ||
985 | %nokwargs CreateContext; | |
986 | %newobject CreateContext; | |
987 | virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc) ; | |
988 | virtual wxGraphicsContext * CreateContext( wxWindow* window ); | |
989 | ||
59c516a3 RD |
990 | // create a context that can be used for measuring texts only, no drawing allowed |
991 | virtual wxGraphicsContext * CreateMeasuringContext(); | |
992 | ||
95a76b75 RD |
993 | %newobject CreateContextFromNativeContext; |
994 | virtual wxGraphicsContext * CreateContextFromNativeContext( void * context ); | |
995 | ||
996 | %newobject CreateContextFromNativeWindow; | |
997 | virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window ); | |
998 | ||
999 | ||
b8910074 | 1000 | virtual wxGraphicsPath CreatePath(); |
95a76b75 | 1001 | |
b8910074 RD |
1002 | virtual wxGraphicsMatrix CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0, |
1003 | wxDouble tx=0.0, wxDouble ty=0.0); | |
95a76b75 | 1004 | |
027aef71 | 1005 | virtual wxGraphicsPen CreatePen(const wxPen& pen) ; |
95a76b75 | 1006 | |
027aef71 | 1007 | virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) ; |
95a76b75 | 1008 | |
027aef71 | 1009 | virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, |
95a76b75 RD |
1010 | const wxColour&c1, const wxColour&c2); |
1011 | ||
027aef71 | 1012 | virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, |
95a76b75 RD |
1013 | const wxColour &oColor, const wxColour &cColor); |
1014 | ||
027aef71 | 1015 | virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ); |
6d61d718 | 1016 | |
6d61d718 RD |
1017 | }; |
1018 | ||
1019 | ||
95a76b75 | 1020 | |
6d61d718 RD |
1021 | //--------------------------------------------------------------------------- |
1022 | ||
6240681f RD |
1023 | %{ |
1024 | #include "wx/dcgraph.h" | |
1025 | %} | |
6d61d718 RD |
1026 | |
1027 | class wxGCDC: public wxDC | |
1028 | { | |
1029 | public: | |
49f7b879 | 1030 | %nokwargs wxGCDC; |
0e4e6012 RD |
1031 | %pythonAppend wxGCDC |
1032 | "self.__dc = args[0] # save a ref so the other dc will not be deleted before self"; | |
6d61d718 | 1033 | wxGCDC(const wxWindowDC& dc); |
49f7b879 | 1034 | wxGCDC(wxWindow* window); |
6d61d718 RD |
1035 | //wxGCDC(); |
1036 | virtual ~wxGCDC(); | |
1037 | ||
8292b82b RD |
1038 | wxGraphicsContext* GetGraphicsContext(); |
1039 | virtual void SetGraphicsContext( wxGraphicsContext* ctx ); | |
1040 | ||
1041 | %property(GraphicsContext, GetGraphicsContext, SetGraphicsContext); | |
6d61d718 RD |
1042 | }; |
1043 | ||
1044 | ||
281c54cc | 1045 | //--------------------------------------------------------------------------- |
6d61d718 | 1046 | |
281c54cc RD |
1047 | // Turn GIL acquisition back on. |
1048 | %threadWrapperOn | |
6d61d718 | 1049 |