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