]>
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> | |
21 | %} | |
22 | ||
281c54cc RD |
23 | // Turn off the aquisition of the Global Interpreter Lock for the classes and |
24 | // functions in this file | |
25 | %threadWrapperOff | |
26 | ||
6d61d718 RD |
27 | //--------------------------------------------------------------------------- |
28 | ||
29 | ||
30 | %{ | |
31 | #if !wxUSE_GRAPHICS_CONTEXT | |
32 | // C++ stub classes for platforms that don't have wxGraphicsContext yet. | |
33 | ||
cbc3893c KO |
34 | class wxGraphicsObject : public wxObject |
35 | { | |
36 | public : | |
37 | wxGraphicsObject( wxGraphicsRenderer* renderer ) {} | |
38 | wxGraphicsObject( const wxGraphicsObject& obj ) {} | |
39 | virtual ~wxGraphicsObject() {} | |
40 | wxGraphicsRenderer* GetRenderer() const {} | |
41 | } ; | |
42 | ||
43 | class wxGraphicsPen : public wxGraphicsObject | |
44 | { | |
45 | //wxGraphicsPen(wxGraphicsRenderer* renderer) : wxGraphicsObject(renderer) {} | |
46 | virtual ~wxGraphicsPen() {} | |
47 | virtual void Apply( wxGraphicsContext* context) {} | |
48 | virtual wxDouble GetWidth() {} | |
49 | } ; | |
50 | ||
51 | class wxGraphicsBrush : public wxGraphicsObject | |
52 | { | |
53 | public : | |
54 | //wxGraphicsBrush(wxGraphicsRenderer* renderer) {} | |
55 | virtual ~wxGraphicsBrush() {} | |
56 | virtual void Apply( wxGraphicsContext* context) {} | |
57 | } ; | |
58 | ||
59 | class wxGraphicsFont : public wxGraphicsObject | |
60 | { | |
61 | public : | |
62 | //wxGraphicsFont(wxGraphicsRenderer* renderer) {} | |
63 | virtual ~wxGraphicsFont() {} | |
64 | virtual void Apply( wxGraphicsContext* context) {} | |
65 | } ; | |
66 | ||
6d61d718 RD |
67 | class wxGraphicsPath |
68 | { | |
69 | public : | |
70 | wxGraphicsPath() { | |
71 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
72 | PyErr_SetString(PyExc_NotImplementedError, | |
73 | "wxGraphicsPath is not available on this platform."); | |
74 | wxPyEndBlockThreads(blocked); | |
75 | } | |
76 | virtual ~wxGraphicsPath() {} | |
77 | ||
78 | void MoveToPoint( wxDouble, wxDouble ) {} | |
79 | void AddLineToPoint( wxDouble, wxDouble ) {} | |
80 | void AddCurveToPoint( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, wxDouble ) {} | |
81 | void CloseSubpath() {} | |
82 | void GetCurrentPoint( wxDouble&, wxDouble&) {} | |
83 | void AddArc( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, bool ) {} | |
84 | ||
85 | void AddQuadCurveToPoint( wxDouble, wxDouble, wxDouble, wxDouble ) {} | |
86 | void AddRectangle( wxDouble, wxDouble, wxDouble, wxDouble ) {} | |
87 | void AddCircle( wxDouble, wxDouble, wxDouble ) {} | |
88 | void AddArcToPoint( wxDouble, wxDouble , wxDouble, wxDouble, wxDouble ) {} | |
89 | ||
90 | wxPoint2DDouble GetCurrentPoint() { return wxPoint2DDouble(0,0); } | |
91 | void MoveToPoint( const wxPoint2DDouble& ) {} | |
92 | void AddLineToPoint( const wxPoint2DDouble&) {} | |
93 | void AddCurveToPoint( const wxPoint2DDouble&, const wxPoint2DDouble&, const wxPoint2DDouble&) {} | |
94 | void AddArc( const wxPoint2DDouble&, wxDouble, wxDouble, wxDouble, bool) {} | |
95 | }; | |
96 | ||
97 | ||
98 | class wxGraphicsContext | |
99 | { | |
100 | public: | |
101 | wxGraphicsContext() { | |
102 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
103 | PyErr_SetString(PyExc_NotImplementedError, | |
104 | "wxGraphicsContext is not available on this platform."); | |
105 | wxPyEndBlockThreads(blocked); | |
106 | } | |
107 | virtual ~wxGraphicsContext() {} | |
108 | ||
109 | static wxGraphicsContext* Create( const wxWindowDC&) { | |
110 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
111 | PyErr_SetString(PyExc_NotImplementedError, | |
112 | "wxGraphicsPath is not available on this platform."); | |
113 | wxPyEndBlockThreads(blocked); | |
114 | return NULL; | |
115 | } | |
b876c1e4 RD |
116 | |
117 | static wxGraphicsContext* CreateFromNative( void * ) { | |
118 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
119 | PyErr_SetString(PyExc_NotImplementedError, | |
120 | "wxGraphicsContext is not available on this platform."); | |
121 | wxPyEndBlockThreads(blocked); | |
122 | return NULL; | |
cbc3893c KO |
123 | } |
124 | ||
125 | virtual wxGraphicsPen* CreatePen(const wxPen& pen) {} | |
126 | ||
127 | virtual wxGraphicsBrush* CreateBrush(const wxBrush& brush ) {} | |
128 | ||
129 | virtual wxGraphicsBrush* CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, | |
130 | const wxColour&c1, const wxColour&c2) {} | |
131 | ||
132 | virtual wxGraphicsBrush* CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, | |
133 | const wxColour &oColor, const wxColour &cColor) {} | |
134 | ||
135 | virtual wxGraphicsFont* CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) {} | |
136 | ||
b876c1e4 | 137 | |
050441c8 | 138 | wxGraphicsPath * CreatePath() { return NULL; } |
6d61d718 RD |
139 | void PushState() {} |
140 | void PopState() {} | |
141 | void Clip( const wxRegion & ) {} | |
b876c1e4 RD |
142 | void Clip( wxDouble, wxDouble, wxDouble, wxDouble ) {} |
143 | void ResetClip() {} | |
144 | void * GetNativeContext() { return NULL; } | |
6d61d718 RD |
145 | void Translate( wxDouble , wxDouble ) {} |
146 | void Scale( wxDouble , wxDouble ) {} | |
147 | void Rotate( wxDouble ) {} | |
cbc3893c KO |
148 | void SetFont( const wxFont &, bool ) {} |
149 | void SetFont( const wxFont &, const wxColour &) {} | |
6d61d718 RD |
150 | void StrokePath( const wxGraphicsPath * ) {} |
151 | void FillPath( const wxGraphicsPath *, int ) {} | |
152 | void DrawPath( const wxGraphicsPath *, int ) {} | |
153 | void DrawText( const wxString &, wxDouble , wxDouble ) {} | |
154 | void DrawText( const wxString &, wxDouble , wxDouble , wxDouble ) {} | |
155 | void GetTextExtent( const wxString &, wxDouble *, wxDouble *, | |
156 | wxDouble *, wxDouble * ) const {} | |
157 | void GetPartialTextExtents(const wxString& , wxArrayDouble& ) const {} | |
158 | void DrawBitmap( const wxBitmap &, wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
159 | void DrawIcon( const wxIcon &, wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
160 | void StrokeLine( wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
161 | void StrokeLines( size_t , const wxPoint2DDouble *) {} | |
162 | void StrokeLines( size_t , const wxPoint2DDouble *, const wxPoint2DDouble *) {} | |
163 | void DrawLines( size_t , const wxPoint2DDouble *, int ) {} | |
164 | void DrawRectangle( wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
165 | void DrawEllipse( wxDouble , wxDouble, wxDouble , wxDouble) {} | |
166 | void DrawRoundedRectangle( wxDouble , wxDouble , wxDouble , wxDouble , wxDouble ) {} | |
167 | }; | |
168 | ||
169 | ||
170 | class wxGCDC: public wxWindowDC | |
171 | { | |
172 | public: | |
173 | wxGCDC(const wxWindowDC&) { | |
174 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
175 | PyErr_SetString(PyExc_NotImplementedError, | |
176 | "wxGCDC is not available on this platform."); | |
177 | wxPyEndBlockThreads(blocked); | |
178 | } | |
179 | ||
180 | wxGCDC() { | |
181 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
182 | PyErr_SetString(PyExc_NotImplementedError, | |
183 | "wxGCDC is not available on this platform."); | |
184 | wxPyEndBlockThreads(blocked); | |
185 | } | |
186 | ||
187 | virtual ~wxGCDC() {} | |
188 | ||
b876c1e4 RD |
189 | wxGraphicsContext* GetGraphicsContext() { return NULL; } |
190 | void SetGraphicsContext( wxGraphicsContext* ) {} | |
6d61d718 RD |
191 | }; |
192 | ||
193 | #endif | |
194 | %} | |
195 | ||
196 | //--------------------------------------------------------------------------- | |
197 | //--------------------------------------------------------------------------- | |
198 | ||
281c54cc RD |
199 | |
200 | %typemap(in) (size_t points, wxPoint2D* points_array ) { | |
201 | $2 = wxPoint2D_LIST_helper($input, &$1); | |
202 | if ($2 == NULL) SWIG_fail; | |
203 | } | |
204 | %typemap(freearg) (size_t points, wxPoint2D* points_array ) { | |
205 | if ($2) delete [] $2; | |
206 | } | |
207 | ||
208 | ||
209 | ||
6d61d718 RD |
210 | MustHaveApp(wxGraphicsPath); |
211 | MustHaveApp(wxGraphicsContext); | |
212 | MustHaveApp(wxGCDC); | |
213 | ||
214 | //#define wxDouble double | |
215 | typedef double wxDouble; | |
216 | ||
217 | ||
218 | // TODO: Decide which of the overloaded methods should use the primary names | |
219 | ||
cbc3893c KO |
220 | class wxGraphicsObject : public wxObject |
221 | { | |
222 | public : | |
223 | wxGraphicsObject( wxGraphicsRenderer* renderer = NULL ); | |
224 | wxGraphicsObject( const wxGraphicsObject& obj ); | |
225 | virtual ~wxGraphicsObject(); | |
226 | wxGraphicsRenderer* GetRenderer() const; | |
227 | } ; | |
228 | ||
229 | class wxGraphicsPen : public wxGraphicsObject | |
230 | { | |
231 | public : | |
232 | //wxGraphicsPen(wxGraphicsRenderer* renderer); | |
233 | virtual ~wxGraphicsPen(); | |
234 | virtual void Apply( wxGraphicsContext* context); | |
235 | virtual wxDouble GetWidth(); | |
236 | } ; | |
237 | ||
238 | class wxGraphicsBrush : public wxGraphicsObject | |
239 | { | |
240 | public : | |
241 | //wxGraphicsBrush(wxGraphicsRenderer* renderer); | |
242 | virtual ~wxGraphicsBrush(); | |
243 | virtual void Apply( wxGraphicsContext* context); | |
244 | } ; | |
245 | ||
246 | class wxGraphicsFont : public wxGraphicsObject | |
247 | { | |
248 | public : | |
249 | //wxGraphicsFont(wxGraphicsRenderer* renderer); | |
250 | virtual ~wxGraphicsFont(); | |
251 | virtual void Apply( wxGraphicsContext* context); | |
252 | } ; | |
253 | ||
6d61d718 RD |
254 | class wxGraphicsPath |
255 | { | |
256 | public : | |
257 | //wxGraphicsPath(); *** This class is an ABC, so we can't allow instances to be created directly | |
258 | virtual ~wxGraphicsPath(); | |
259 | ||
260 | ||
261 | DocDeclStr( | |
262 | virtual void , MoveToPoint( wxDouble x, wxDouble y ), | |
263 | "Begins a new subpath at (x,y)", ""); | |
264 | // void MoveToPoint( const wxPoint2D& p); | |
265 | ||
266 | ||
267 | DocDeclStr( | |
268 | virtual void , AddLineToPoint( wxDouble x, wxDouble y ), | |
269 | "Adds a straight line from the current point to (x,y) ", ""); | |
270 | // void AddLineToPoint( const wxPoint2D& p); | |
271 | ||
272 | ||
273 | DocDeclStr( | |
274 | virtual void , AddCurveToPoint( wxDouble cx1, wxDouble cy1, | |
275 | wxDouble cx2, wxDouble cy2, | |
276 | wxDouble x, wxDouble y ), | |
277 | "Adds a cubic Bezier curve from the current point, using two control | |
278 | points and an end point", ""); | |
279 | // void AddCurveToPoint( const wxPoint2D& c1, const wxPoint2D& c2, const wxPoint2D& e); | |
280 | ||
281 | ||
282 | DocDeclStr( | |
283 | virtual void , CloseSubpath(), | |
284 | "closes the current sub-path", ""); | |
285 | ||
286 | ||
287 | //virtual void , GetCurrentPoint( wxDouble& x, wxDouble&y), | |
288 | DocDeclStr( | |
289 | wxPoint2D , GetCurrentPoint(), | |
290 | "Gets the last point of the current path, (0,0) if not yet set", ""); | |
291 | ||
292 | ||
293 | DocDeclStr( | |
294 | virtual void , AddArc( wxDouble x, wxDouble y, wxDouble r, | |
295 | wxDouble startAngle, wxDouble endAngle, bool clockwise ), | |
296 | "Adds an arc of a circle centering at (x,y) with radius (r) from | |
297 | startAngle to endAngle", ""); | |
298 | // void AddArc( const wxPoint2D& c, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise); | |
299 | ||
300 | ||
301 | DocDeclStr( | |
302 | virtual void , AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y ), | |
303 | "Adds a quadratic Bezier curve from the current point, using a control | |
304 | point and an end point", ""); | |
305 | ||
306 | ||
307 | DocDeclStr( | |
308 | virtual void , AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ), | |
309 | "Appends a rectangle as a new closed subpath", ""); | |
310 | ||
311 | ||
312 | DocDeclStr( | |
313 | virtual void , AddCircle( wxDouble x, wxDouble y, wxDouble r ), | |
281c54cc | 314 | "Appends a circle as a new closed subpath with the given radius.", ""); |
6d61d718 RD |
315 | |
316 | ||
317 | DocDeclStr( | |
318 | virtual void , AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) , | |
319 | "Draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) | |
320 | to (x2,y2), also a straight line from (current) to (x1,y1)", ""); | |
321 | ||
322 | ||
323 | }; | |
324 | ||
8292b82b RD |
325 | //--------------------------------------------------------------------------- |
326 | ||
327 | /* | |
328 | class wxGraphicsMatrix | |
329 | { | |
330 | public : | |
331 | wxGraphicsMatrix() {} | |
332 | ||
333 | virtual ~wxGraphicsMatrix() {} | |
334 | ||
335 | wxGraphicsMatrix* Concat( const wxGraphicsMatrix *t ) const; | |
336 | ||
337 | // returns the inverse matrix | |
338 | wxGraphicsMatrix* Invert() const; | |
339 | ||
340 | // returns true if the elements of the transformation matrix are equal ? | |
341 | bool operator==(const wxGraphicsMatrix& t) const; | |
342 | ||
343 | // return true if this is the identity matrix | |
344 | bool IsIdentity(); | |
345 | ||
346 | // | |
347 | // transformation | |
348 | // | |
349 | ||
350 | // translate | |
351 | virtual void Translate( wxDouble dx , wxDouble dy ) = 0; | |
352 | ||
353 | // scale | |
354 | virtual void Scale( wxDouble xScale , wxDouble yScale ) = 0; | |
355 | ||
356 | // rotate (radians) | |
357 | virtual void Rotate( wxDouble angle ) = 0; | |
358 | } ; | |
359 | */ | |
360 | ||
361 | ||
6d61d718 RD |
362 | //--------------------------------------------------------------------------- |
363 | ||
364 | ||
365 | class wxGraphicsContext | |
366 | { | |
367 | public: | |
368 | // wxGraphicsContext() This is also an ABC, use Create to make an instance... | |
369 | virtual ~wxGraphicsContext(); | |
8292b82b | 370 | |
2742805a | 371 | %newobject Create; |
8292b82b | 372 | %nokwargs Create; |
2742805a RD |
373 | %pythonAppend Create |
374 | "val.__dc = args[0] # save a ref so the dc will not be deleted before self"; | |
6d61d718 | 375 | static wxGraphicsContext* Create( const wxWindowDC& dc); |
8292b82b RD |
376 | |
377 | static wxGraphicsContext* Create( wxWindow* window ) ; | |
378 | ||
2742805a | 379 | %newobject CreateFromNative; |
8292b82b RD |
380 | static wxGraphicsContext* CreateFromNative( void * context ) ; |
381 | ||
6d61d718 | 382 | |
2742805a | 383 | %newobject CreatePath; |
6d61d718 RD |
384 | // creates a path instance that corresponds to the type of graphics context, ie GDIPlus, cairo, CoreGraphics ... |
385 | DocDeclStr( | |
386 | virtual wxGraphicsPath * , CreatePath(), | |
387 | "", ""); | |
388 | ||
8292b82b | 389 | /* |
cbc3893c KO |
390 | |
391 | %newobject CreatePen | |
392 | virtual wxGraphicsPen* CreatePen(const wxPen& pen); | |
393 | ||
394 | %newobject CreateBrush | |
395 | virtual wxGraphicsBrush* CreateBrush(const wxBrush& brush ); | |
396 | ||
397 | %newobject CreateLinearGradientBrush | |
398 | // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2 | |
399 | virtual wxGraphicsBrush* CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, | |
400 | const wxColour&c1, const wxColour&c2); | |
401 | ||
402 | %newobject CreateRadialGradientBrush | |
403 | // sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc) | |
404 | // with radius r and color cColor | |
405 | virtual wxGraphicsBrush* CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius, | |
406 | const wxColour &oColor, const wxColour &cColor); | |
407 | ||
408 | %newobject CreateFont | |
409 | // sets the font | |
410 | virtual wxGraphicsFont* CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ); | |
411 | ||
8292b82b RD |
412 | // create a 'native' matrix corresponding to these values |
413 | virtual wxGraphicsMatrix* CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, | |
414 | wxDouble c=0.0, wxDouble d=1.0, | |
415 | wxDouble tx=0.0, wxDouble ty=0.0) = 0; | |
416 | */ | |
6d61d718 | 417 | |
8292b82b | 418 | |
6d61d718 RD |
419 | // push the current state of the context, ie the transformation matrix on a stack |
420 | DocDeclStr( | |
421 | virtual void , PushState(), | |
422 | "", ""); | |
423 | ||
424 | ||
425 | // pops a stored state from the stack | |
426 | DocDeclStr( | |
427 | virtual void , PopState(), | |
428 | "", ""); | |
429 | ||
430 | ||
431 | // clips drawings to the region | |
8292b82b | 432 | DocDeclStrName( |
6d61d718 | 433 | virtual void , Clip( const wxRegion ®ion ), |
8292b82b RD |
434 | "", "", |
435 | ClipRegion); | |
436 | ||
437 | // clips drawings to the rect | |
438 | DocDeclStr( | |
439 | virtual void , Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ), | |
440 | "", ""); | |
441 | ||
442 | ||
443 | // resets the clipping to original extent | |
444 | DocDeclStr( | |
445 | virtual void , ResetClip(), | |
6d61d718 RD |
446 | "", ""); |
447 | ||
448 | ||
8292b82b RD |
449 | // returns the native context |
450 | DocDeclStr( | |
451 | virtual void * , GetNativeContext(), | |
452 | "", ""); | |
453 | ||
454 | ||
455 | ||
6d61d718 | 456 | // |
8292b82b | 457 | // transformation: changes the current transformation matrix CTM of the context |
6d61d718 RD |
458 | // |
459 | ||
460 | // translate | |
461 | DocDeclStr( | |
462 | virtual void , Translate( wxDouble dx , wxDouble dy ), | |
463 | "", ""); | |
464 | ||
465 | ||
466 | // scale | |
467 | DocDeclStr( | |
468 | virtual void , Scale( wxDouble xScale , wxDouble yScale ), | |
469 | "", ""); | |
470 | ||
471 | ||
472 | // rotate (radians) | |
473 | DocDeclStr( | |
474 | virtual void , Rotate( wxDouble angle ), | |
475 | "", ""); | |
476 | ||
477 | ||
478 | // | |
479 | // setting the paint | |
480 | // | |
481 | ||
482 | // sets the pan | |
483 | DocDeclStr( | |
484 | virtual void , SetPen( const wxPen &pen ), | |
485 | "", ""); | |
486 | ||
487 | ||
488 | // sets the brush for filling | |
489 | DocDeclStr( | |
490 | virtual void , SetBrush( const wxBrush &brush ), | |
491 | "", ""); | |
492 | ||
493 | ||
6d61d718 RD |
494 | // sets the font |
495 | DocDeclStr( | |
cbc3893c | 496 | virtual void , SetFont( const wxFont &font, bool release = true ), |
6d61d718 RD |
497 | "", ""); |
498 | ||
499 | ||
cbc3893c | 500 | // sets the font |
6d61d718 | 501 | DocDeclStr( |
cbc3893c | 502 | void , SetFont( const wxFont &font, const wxColour& colour ), |
6d61d718 RD |
503 | "", ""); |
504 | ||
cbc3893c | 505 | |
6d61d718 RD |
506 | |
507 | // strokes along a path with the current pen | |
508 | DocDeclStr( | |
509 | virtual void , StrokePath( const wxGraphicsPath *path ), | |
510 | "", ""); | |
511 | ||
512 | ||
513 | // fills a path with the current brush | |
514 | DocDeclStr( | |
515 | virtual void , FillPath( const wxGraphicsPath *path, int fillStyle = wxWINDING_RULE ), | |
516 | "", ""); | |
517 | ||
518 | ||
519 | // draws a path by first filling and then stroking | |
520 | DocDeclStr( | |
521 | virtual void , DrawPath( const wxGraphicsPath *path, int fillStyle = wxWINDING_RULE ), | |
522 | "", ""); | |
523 | ||
524 | ||
525 | // | |
526 | // text | |
527 | // | |
528 | ||
529 | DocDeclStr( | |
530 | virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y ), | |
531 | "", ""); | |
532 | ||
533 | ||
281c54cc | 534 | DocDeclStrName( |
6d61d718 | 535 | virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ), |
281c54cc RD |
536 | "", "", |
537 | DrawRotatedText); | |
6d61d718 RD |
538 | |
539 | ||
752d967c | 540 | DocDeclAStrName( |
6d61d718 RD |
541 | virtual void , GetTextExtent( const wxString &text, |
542 | wxDouble *OUTPUT /*width*/, | |
543 | wxDouble *OUTPUT /*height*/, | |
544 | wxDouble *OUTPUT /*descent*/, | |
545 | wxDouble *OUTPUT /*externalLeading*/ ) const , | |
752d967c RD |
546 | "GetFullTextExtent(self, text) --> (width, height, descent, externalLeading)", |
547 | "", "", | |
548 | GetFullTextExtent); | |
549 | ||
550 | %extend { | |
551 | DocAStr(GetTextExtent, | |
552 | "GetTextExtent(self, text) --> (width, height)", | |
553 | "", ""); | |
554 | ||
555 | PyObject* GetTextExtent( const wxString &text ) | |
556 | { | |
557 | wxDouble width = 0.0, | |
558 | height = 0.0; | |
559 | self->GetTextExtent(text, &width, &height, NULL, NULL); | |
560 | // thread wrapers are turned off for this .i file, so no need to acquire GIL... | |
561 | PyObject* rv = PyTuple_New(2); | |
562 | PyTuple_SET_ITEM(rv, 0, PyFloat_FromDouble(width)); | |
563 | PyTuple_SET_ITEM(rv, 1, PyFloat_FromDouble(height)); | |
564 | return rv; | |
565 | } | |
566 | } | |
6d61d718 RD |
567 | |
568 | ||
281c54cc RD |
569 | %extend { |
570 | DocAStr(GetPartialTextExtents, | |
571 | "GetPartialTextExtents(self, text) -> [widths]", | |
572 | "", ""); | |
573 | wxArrayDouble GetPartialTextExtents(const wxString& text) { | |
574 | wxArrayDouble widths; | |
575 | self->GetPartialTextExtents(text, widths); | |
576 | return widths; | |
577 | } | |
578 | } | |
6d61d718 RD |
579 | |
580 | ||
581 | // | |
582 | // image support | |
583 | // | |
584 | ||
585 | DocDeclStr( | |
586 | virtual void , DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ), | |
587 | "", ""); | |
588 | ||
589 | ||
590 | DocDeclStr( | |
591 | virtual void , DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ), | |
592 | "", ""); | |
593 | ||
594 | ||
595 | // | |
596 | // convenience methods | |
597 | // | |
598 | ||
599 | // strokes a single line | |
600 | DocDeclStr( | |
601 | virtual void , StrokeLine( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2), | |
602 | "", ""); | |
6d61d718 | 603 | |
281c54cc | 604 | |
6d61d718 | 605 | // stroke lines connecting each of the points |
281c54cc RD |
606 | DocDeclAStr( |
607 | virtual void , StrokeLines( size_t points, const wxPoint2D *points_array), | |
608 | "StrokeLines(self, List points)", | |
6d61d718 RD |
609 | "", ""); |
610 | ||
611 | ||
281c54cc RD |
612 | // // stroke disconnected lines from begin to end points |
613 | // virtual void StrokeLines( size_t n, const wxPoint2D *beginPoints, const wxPoint2D *endPoints); | |
614 | ||
281c54cc | 615 | %extend { |
aa43bcc7 | 616 | void StrokeLineSegements(PyObject* beginPoints, PyObject* endPoints) |
281c54cc RD |
617 | { |
618 | size_t c1, c2, count; | |
619 | wxPoint2D* beginP = wxPoint2D_LIST_helper(beginPoints, &c1); | |
620 | wxPoint2D* endP = wxPoint2D_LIST_helper(endPoints, &c2); | |
621 | ||
622 | if ( beginP != NULL && endP != NULL ) | |
623 | { | |
624 | count = wxMin(c1, c2); | |
625 | self->StrokeLines(count, beginP, endP); | |
626 | } | |
627 | delete [] beginP; | |
628 | delete [] endP; | |
629 | } | |
630 | } | |
6d61d718 RD |
631 | |
632 | // draws a polygon | |
633 | DocDeclStr( | |
281c54cc | 634 | virtual void , DrawLines( size_t points, const wxPoint2D *points_array, int fillStyle = wxWINDING_RULE ), |
6d61d718 RD |
635 | "", ""); |
636 | ||
637 | ||
638 | // draws a polygon | |
639 | DocDeclStr( | |
640 | virtual void , DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h), | |
641 | "", ""); | |
642 | ||
643 | ||
644 | // draws an ellipse | |
645 | DocDeclStr( | |
646 | virtual void , DrawEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h), | |
647 | "", ""); | |
648 | ||
649 | ||
650 | // draws a rounded rectangle | |
651 | DocDeclStr( | |
652 | virtual void , DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius), | |
653 | "", ""); | |
654 | ||
6d61d718 RD |
655 | }; |
656 | ||
657 | ||
658 | //--------------------------------------------------------------------------- | |
659 | ||
6240681f RD |
660 | %{ |
661 | #include "wx/dcgraph.h" | |
662 | %} | |
6d61d718 RD |
663 | |
664 | class wxGCDC: public wxDC | |
665 | { | |
666 | public: | |
0e4e6012 RD |
667 | %pythonAppend wxGCDC |
668 | "self.__dc = args[0] # save a ref so the other dc will not be deleted before self"; | |
6d61d718 RD |
669 | wxGCDC(const wxWindowDC& dc); |
670 | //wxGCDC(); | |
671 | virtual ~wxGCDC(); | |
672 | ||
8292b82b RD |
673 | wxGraphicsContext* GetGraphicsContext(); |
674 | virtual void SetGraphicsContext( wxGraphicsContext* ctx ); | |
675 | ||
676 | %property(GraphicsContext, GetGraphicsContext, SetGraphicsContext); | |
6d61d718 RD |
677 | }; |
678 | ||
679 | ||
281c54cc | 680 | //--------------------------------------------------------------------------- |
6d61d718 | 681 | |
281c54cc RD |
682 | // Turn GIL acquisition back on. |
683 | %threadWrapperOn | |
6d61d718 | 684 |