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