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