]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_graphics.i
fix width/height typo in DoSetClientSize, remove unused stuff
[wxWidgets.git] / wxPython / src / _graphics.i
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
23 //---------------------------------------------------------------------------
24
25
26 %{
27 #if !wxUSE_GRAPHICS_CONTEXT
28 // C++ stub classes for platforms that don't have wxGraphicsContext yet.
29
30 class wxGraphicsPath
31 {
32 public :
33 wxGraphicsPath() {
34 wxPyBlock_t blocked = wxPyBeginBlockThreads();
35 PyErr_SetString(PyExc_NotImplementedError,
36 "wxGraphicsPath is not available on this platform.");
37 wxPyEndBlockThreads(blocked);
38 }
39 virtual ~wxGraphicsPath() {}
40
41 void MoveToPoint( wxDouble, wxDouble ) {}
42 void AddLineToPoint( wxDouble, wxDouble ) {}
43 void AddCurveToPoint( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, wxDouble ) {}
44 void CloseSubpath() {}
45 void GetCurrentPoint( wxDouble&, wxDouble&) {}
46 void AddArc( wxDouble, wxDouble, wxDouble, wxDouble, wxDouble, bool ) {}
47
48 void AddQuadCurveToPoint( wxDouble, wxDouble, wxDouble, wxDouble ) {}
49 void AddRectangle( wxDouble, wxDouble, wxDouble, wxDouble ) {}
50 void AddCircle( wxDouble, wxDouble, wxDouble ) {}
51 void AddArcToPoint( wxDouble, wxDouble , wxDouble, wxDouble, wxDouble ) {}
52
53 wxPoint2DDouble GetCurrentPoint() { return wxPoint2DDouble(0,0); }
54 void MoveToPoint( const wxPoint2DDouble& ) {}
55 void AddLineToPoint( const wxPoint2DDouble&) {}
56 void AddCurveToPoint( const wxPoint2DDouble&, const wxPoint2DDouble&, const wxPoint2DDouble&) {}
57 void AddArc( const wxPoint2DDouble&, wxDouble, wxDouble, wxDouble, bool) {}
58 };
59
60
61 class wxGraphicsContext
62 {
63 public:
64 wxGraphicsContext() {
65 wxPyBlock_t blocked = wxPyBeginBlockThreads();
66 PyErr_SetString(PyExc_NotImplementedError,
67 "wxGraphicsContext is not available on this platform.");
68 wxPyEndBlockThreads(blocked);
69 }
70 virtual ~wxGraphicsContext() {}
71
72 static wxGraphicsContext* Create( const wxWindowDC&) {
73 wxPyBlock_t blocked = wxPyBeginBlockThreads();
74 PyErr_SetString(PyExc_NotImplementedError,
75 "wxGraphicsPath is not available on this platform.");
76 wxPyEndBlockThreads(blocked);
77 return NULL;
78 }
79
80 wxGraphicsPath * CreatePath() { return NULL; }
81 void PushState() {}
82 void PopState() {}
83 void Clip( const wxRegion & ) {}
84 void Translate( wxDouble , wxDouble ) {}
85 void Scale( wxDouble , wxDouble ) {}
86 void Rotate( wxDouble ) {}
87 void SetPen( const wxPen & ) {}
88 void SetBrush( const wxBrush & ) {}
89 void SetLinearGradientBrush( wxDouble , wxDouble , wxDouble , wxDouble ,
90 const wxColour&, const wxColour&) {}
91 void SetRadialGradientBrush( wxDouble , wxDouble , wxDouble , wxDouble , wxDouble ,
92 const wxColour &, const wxColour &) {}
93 void SetFont( const wxFont & ) {}
94 void SetTextColor( const wxColour & ) {}
95 void StrokePath( const wxGraphicsPath * ) {}
96 void FillPath( const wxGraphicsPath *, int ) {}
97 void DrawPath( const wxGraphicsPath *, int ) {}
98 void DrawText( const wxString &, wxDouble , wxDouble ) {}
99 void DrawText( const wxString &, wxDouble , wxDouble , wxDouble ) {}
100 void GetTextExtent( const wxString &, wxDouble *, wxDouble *,
101 wxDouble *, wxDouble * ) const {}
102 void GetPartialTextExtents(const wxString& , wxArrayDouble& ) const {}
103 void DrawBitmap( const wxBitmap &, wxDouble , wxDouble , wxDouble , wxDouble ) {}
104 void DrawIcon( const wxIcon &, wxDouble , wxDouble , wxDouble , wxDouble ) {}
105 void StrokeLine( wxDouble , wxDouble , wxDouble , wxDouble ) {}
106 void StrokeLines( size_t , const wxPoint2DDouble *) {}
107 void StrokeLines( size_t , const wxPoint2DDouble *, const wxPoint2DDouble *) {}
108 void DrawLines( size_t , const wxPoint2DDouble *, int ) {}
109 void DrawRectangle( wxDouble , wxDouble , wxDouble , wxDouble ) {}
110 void DrawEllipse( wxDouble , wxDouble, wxDouble , wxDouble) {}
111 void DrawRoundedRectangle( wxDouble , wxDouble , wxDouble , wxDouble , wxDouble ) {}
112 };
113
114
115 class wxGCDC: public wxWindowDC
116 {
117 public:
118 wxGCDC(const wxWindowDC&) {
119 wxPyBlock_t blocked = wxPyBeginBlockThreads();
120 PyErr_SetString(PyExc_NotImplementedError,
121 "wxGCDC is not available on this platform.");
122 wxPyEndBlockThreads(blocked);
123 }
124
125 wxGCDC() {
126 wxPyBlock_t blocked = wxPyBeginBlockThreads();
127 PyErr_SetString(PyExc_NotImplementedError,
128 "wxGCDC is not available on this platform.");
129 wxPyEndBlockThreads(blocked);
130 }
131
132 virtual ~wxGCDC() {}
133
134 wxGraphicsContext* GetGraphicContext() { return NULL; }
135 };
136
137 #endif
138 %}
139
140 //---------------------------------------------------------------------------
141 //---------------------------------------------------------------------------
142
143 MustHaveApp(wxGraphicsPath);
144 MustHaveApp(wxGraphicsContext);
145 MustHaveApp(wxGCDC);
146
147 //#define wxDouble double
148 typedef double wxDouble;
149
150
151 // TODO: Decide which of the overloaded methods should use the primary names
152
153 class wxGraphicsPath
154 {
155 public :
156 //wxGraphicsPath(); *** This class is an ABC, so we can't allow instances to be created directly
157 virtual ~wxGraphicsPath();
158
159
160 DocDeclStr(
161 virtual void , MoveToPoint( wxDouble x, wxDouble y ),
162 "Begins a new subpath at (x,y)", "");
163 // void MoveToPoint( const wxPoint2D& p);
164
165
166 DocDeclStr(
167 virtual void , AddLineToPoint( wxDouble x, wxDouble y ),
168 "Adds a straight line from the current point to (x,y) ", "");
169 // void AddLineToPoint( const wxPoint2D& p);
170
171
172 DocDeclStr(
173 virtual void , AddCurveToPoint( wxDouble cx1, wxDouble cy1,
174 wxDouble cx2, wxDouble cy2,
175 wxDouble x, wxDouble y ),
176 "Adds a cubic Bezier curve from the current point, using two control
177 points and an end point", "");
178 // void AddCurveToPoint( const wxPoint2D& c1, const wxPoint2D& c2, const wxPoint2D& e);
179
180
181 DocDeclStr(
182 virtual void , CloseSubpath(),
183 "closes the current sub-path", "");
184
185
186 //virtual void , GetCurrentPoint( wxDouble& x, wxDouble&y),
187 DocDeclStr(
188 wxPoint2D , GetCurrentPoint(),
189 "Gets the last point of the current path, (0,0) if not yet set", "");
190
191
192 DocDeclStr(
193 virtual void , AddArc( wxDouble x, wxDouble y, wxDouble r,
194 wxDouble startAngle, wxDouble endAngle, bool clockwise ),
195 "Adds an arc of a circle centering at (x,y) with radius (r) from
196 startAngle to endAngle", "");
197 // void AddArc( const wxPoint2D& c, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise);
198
199
200 DocDeclStr(
201 virtual void , AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y ),
202 "Adds a quadratic Bezier curve from the current point, using a control
203 point and an end point", "");
204
205
206 DocDeclStr(
207 virtual void , AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
208 "Appends a rectangle as a new closed subpath", "");
209
210
211 DocDeclStr(
212 virtual void , AddCircle( wxDouble x, wxDouble y, wxDouble r ),
213 "Appends an ellipsis as a new closed subpath fitting the passed rectangle", "");
214
215
216 DocDeclStr(
217 virtual void , AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ,
218 "Draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1)
219 to (x2,y2), also a straight line from (current) to (x1,y1)", "");
220
221
222 };
223
224 //---------------------------------------------------------------------------
225
226
227 class wxGraphicsContext
228 {
229 public:
230 // wxGraphicsContext() This is also an ABC, use Create to make an instance...
231 virtual ~wxGraphicsContext();
232
233 %pythonAppend Create
234 "val.__dc = args[0] # save a ref so the other dc will not be deleted before self";
235 static wxGraphicsContext* Create( const wxWindowDC& dc);
236
237 // creates a path instance that corresponds to the type of graphics context, ie GDIPlus, cairo, CoreGraphics ...
238 DocDeclStr(
239 virtual wxGraphicsPath * , CreatePath(),
240 "", "");
241
242
243 // push the current state of the context, ie the transformation matrix on a stack
244 DocDeclStr(
245 virtual void , PushState(),
246 "", "");
247
248
249 // pops a stored state from the stack
250 DocDeclStr(
251 virtual void , PopState(),
252 "", "");
253
254
255 // clips drawings to the region
256 DocDeclStr(
257 virtual void , Clip( const wxRegion &region ),
258 "", "");
259
260
261 //
262 // transformation
263 //
264
265 // translate
266 DocDeclStr(
267 virtual void , Translate( wxDouble dx , wxDouble dy ),
268 "", "");
269
270
271 // scale
272 DocDeclStr(
273 virtual void , Scale( wxDouble xScale , wxDouble yScale ),
274 "", "");
275
276
277 // rotate (radians)
278 DocDeclStr(
279 virtual void , Rotate( wxDouble angle ),
280 "", "");
281
282
283 //
284 // setting the paint
285 //
286
287 // sets the pan
288 DocDeclStr(
289 virtual void , SetPen( const wxPen &pen ),
290 "", "");
291
292
293 // sets the brush for filling
294 DocDeclStr(
295 virtual void , SetBrush( const wxBrush &brush ),
296 "", "");
297
298
299 // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2
300 DocDeclStr(
301 virtual void , SetLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
302 const wxColour&c1, const wxColour&c2),
303 "", "");
304
305
306 // sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc)
307 // with radius r and color cColor
308 DocDeclStr(
309 virtual void , SetRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc,
310 wxDouble radius,
311 const wxColour &oColor, const wxColour &cColor),
312 "", "");
313
314
315 // sets the font
316 DocDeclStr(
317 virtual void , SetFont( const wxFont &font ),
318 "", "");
319
320
321 // sets the text color
322 DocDeclStr(
323 virtual void , SetTextColor( const wxColour &col ),
324 "", "");
325
326
327 // strokes along a path with the current pen
328 DocDeclStr(
329 virtual void , StrokePath( const wxGraphicsPath *path ),
330 "", "");
331
332
333 // fills a path with the current brush
334 DocDeclStr(
335 virtual void , FillPath( const wxGraphicsPath *path, int fillStyle = wxWINDING_RULE ),
336 "", "");
337
338
339 // draws a path by first filling and then stroking
340 DocDeclStr(
341 virtual void , DrawPath( const wxGraphicsPath *path, int fillStyle = wxWINDING_RULE ),
342 "", "");
343
344
345 //
346 // text
347 //
348
349 DocDeclStr(
350 virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y ),
351 "", "");
352
353
354 DocDeclStr(
355 virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ),
356 "", "");
357
358
359 DocDeclStr(
360 virtual void , GetTextExtent( const wxString &text,
361 wxDouble *OUTPUT /*width*/,
362 wxDouble *OUTPUT /*height*/,
363 wxDouble *OUTPUT /*descent*/,
364 wxDouble *OUTPUT /*externalLeading*/ ) const ,
365 "", "");
366
367
368 DocDeclStr(
369 virtual void , GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const,
370 "", "");
371
372
373 //
374 // image support
375 //
376
377 DocDeclStr(
378 virtual void , DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
379 "", "");
380
381
382 DocDeclStr(
383 virtual void , DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
384 "", "");
385
386
387 //
388 // convenience methods
389 //
390
391 // strokes a single line
392 DocDeclStr(
393 virtual void , StrokeLine( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2),
394 "", "");
395
396
397 // stroke lines connecting each of the points
398 DocDeclStr(
399 virtual void , StrokeLines( size_t n, const wxPoint2D *points),
400 "", "");
401
402
403 // stroke disconnected lines from begin to end points
404 DocDeclStr(
405 virtual void , StrokeLines( size_t n, const wxPoint2D *beginPoints, const wxPoint2D *endPoints),
406 "", "");
407
408
409 // draws a polygon
410 DocDeclStr(
411 virtual void , DrawLines( size_t n, const wxPoint2D *points, int fillStyle = wxWINDING_RULE ),
412 "", "");
413
414
415 // draws a polygon
416 DocDeclStr(
417 virtual void , DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
418 "", "");
419
420
421 // draws an ellipse
422 DocDeclStr(
423 virtual void , DrawEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h),
424 "", "");
425
426
427 // draws a rounded rectangle
428 DocDeclStr(
429 virtual void , DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius),
430 "", "");
431
432
433 };
434
435
436 //---------------------------------------------------------------------------
437
438
439 class wxGCDC: public wxDC
440 {
441 public:
442 %pythonAppend wxGCDC
443 "self.__dc = args[0] # save a ref so the other dc will not be deleted before self";
444 wxGCDC(const wxWindowDC& dc);
445 //wxGCDC();
446 virtual ~wxGCDC();
447
448 wxGraphicsContext* GetGraphicContext();
449 };
450
451
452
453
454 //---------------------------------------------------------------------------