]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_gdicmn.i
Recent changes in SWIG make this patch no longer necessary
[wxWidgets.git] / wxPython / src / _gdicmn.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _gdicmn.i
3 // Purpose: SWIG interface for common GDI stuff and misc classes
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 13-Sept-2003
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17 %newgroup
18
19
20 enum wxBitmapType
21 {
22 wxBITMAP_TYPE_INVALID, // should be == 0 for compatibility!
23 wxBITMAP_TYPE_BMP,
24 wxBITMAP_TYPE_BMP_RESOURCE,
25 wxBITMAP_TYPE_RESOURCE = wxBITMAP_TYPE_BMP_RESOURCE,
26 wxBITMAP_TYPE_ICO,
27 wxBITMAP_TYPE_ICO_RESOURCE,
28 wxBITMAP_TYPE_CUR,
29 wxBITMAP_TYPE_CUR_RESOURCE,
30 wxBITMAP_TYPE_XBM,
31 wxBITMAP_TYPE_XBM_DATA,
32 wxBITMAP_TYPE_XPM,
33 wxBITMAP_TYPE_XPM_DATA,
34 wxBITMAP_TYPE_TIF,
35 wxBITMAP_TYPE_TIF_RESOURCE,
36 wxBITMAP_TYPE_GIF,
37 wxBITMAP_TYPE_GIF_RESOURCE,
38 wxBITMAP_TYPE_PNG,
39 wxBITMAP_TYPE_PNG_RESOURCE,
40 wxBITMAP_TYPE_JPEG,
41 wxBITMAP_TYPE_JPEG_RESOURCE,
42 wxBITMAP_TYPE_PNM,
43 wxBITMAP_TYPE_PNM_RESOURCE,
44 wxBITMAP_TYPE_PCX,
45 wxBITMAP_TYPE_PCX_RESOURCE,
46 wxBITMAP_TYPE_PICT,
47 wxBITMAP_TYPE_PICT_RESOURCE,
48 wxBITMAP_TYPE_ICON,
49 wxBITMAP_TYPE_ICON_RESOURCE,
50 wxBITMAP_TYPE_ANI,
51 wxBITMAP_TYPE_IFF,
52 wxBITMAP_TYPE_MACCURSOR,
53 wxBITMAP_TYPE_MACCURSOR_RESOURCE,
54 wxBITMAP_TYPE_ANY = 50
55 };
56
57 // Standard cursors
58 enum wxStockCursor
59 {
60 wxCURSOR_NONE, // should be 0
61 wxCURSOR_ARROW,
62 wxCURSOR_RIGHT_ARROW,
63 wxCURSOR_BULLSEYE,
64 wxCURSOR_CHAR,
65 wxCURSOR_CROSS,
66 wxCURSOR_HAND,
67 wxCURSOR_IBEAM,
68 wxCURSOR_LEFT_BUTTON,
69 wxCURSOR_MAGNIFIER,
70 wxCURSOR_MIDDLE_BUTTON,
71 wxCURSOR_NO_ENTRY,
72 wxCURSOR_PAINT_BRUSH,
73 wxCURSOR_PENCIL,
74 wxCURSOR_POINT_LEFT,
75 wxCURSOR_POINT_RIGHT,
76 wxCURSOR_QUESTION_ARROW,
77 wxCURSOR_RIGHT_BUTTON,
78 wxCURSOR_SIZENESW,
79 wxCURSOR_SIZENS,
80 wxCURSOR_SIZENWSE,
81 wxCURSOR_SIZEWE,
82 wxCURSOR_SIZING,
83 wxCURSOR_SPRAYCAN,
84 wxCURSOR_WAIT,
85 wxCURSOR_WATCH,
86 wxCURSOR_BLANK,
87 wxCURSOR_DEFAULT, // standard X11 cursor
88 wxCURSOR_COPY_ARROW , // MacOS Theme Plus arrow
89
90 // #ifdef __X__
91 // // Not yet implemented for Windows
92 // wxCURSOR_CROSS_REVERSE,
93 // wxCURSOR_DOUBLE_ARROW,
94 // wxCURSOR_BASED_ARROW_UP,
95 // wxCURSOR_BASED_ARROW_DOWN,
96 // #endif // X11
97
98 wxCURSOR_ARROWWAIT,
99
100 wxCURSOR_MAX
101 };
102
103 %{
104 #ifndef __WXMAC__
105 #define wxCURSOR_COPY_ARROW wxCURSOR_ARROW
106 #endif
107 %}
108
109 //---------------------------------------------------------------------------
110 %newgroup
111 %noautorepr wxSize;
112
113 class wxSize
114 {
115 public:
116 //int x; // TODO: Can these be removed and just use width and height?
117 //int y;
118 %name(width) int x;
119 %name(height)int y;
120
121 wxSize(int w=0, int h=0);
122 ~wxSize();
123
124 bool operator==(const wxSize& sz) const;
125 bool operator!=(const wxSize& sz) const;
126
127 wxSize operator+(const wxSize& sz);
128 wxSize operator-(const wxSize& sz);
129
130 void IncTo(const wxSize& sz);
131 void DecTo(const wxSize& sz);
132
133 void Set(int xx, int yy);
134 void SetWidth(int w);
135 void SetHeight(int h);
136 int GetWidth() const;
137 int GetHeight() const;
138
139 int GetX() const;
140 int GetY() const;
141
142 %extend {
143 PyObject* asTuple() {
144 wxPyBeginBlockThreads();
145 PyObject* tup = PyTuple_New(2);
146 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
147 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
148 wxPyEndBlockThreads();
149 return tup;
150 }
151 }
152 %pythoncode {
153 def __str__(self): return str(self.asTuple())
154 def __repr__(self): return 'wxSize'+str(self.asTuple())
155 def __len__(self): return len(self.asTuple())
156 def __getitem__(self, index): return self.asTuple()[index]
157 def __setitem__(self, index, val):
158 if index == 0: self.width = val
159 elif index == 1: self.height = val
160 else: raise IndexError
161 def __nonzero__(self): return self.asTuple() != (0,0)
162 def __getinitargs__(self): return ()
163 def __getstate__(self): return self.asTuple()
164 def __setstate__(self, state): self.Set(*state)
165 }
166
167 };
168
169 //---------------------------------------------------------------------------
170 %newgroup
171 %noautorepr wxRealPoint;
172
173 class wxRealPoint
174 {
175 public:
176 double x;
177 double y;
178
179 wxRealPoint(double x=0.0, double y=0.0);
180 ~wxRealPoint();
181
182 wxRealPoint operator+(const wxRealPoint& pt) const;
183 wxRealPoint operator-(const wxRealPoint& pt) const;
184
185 bool operator==(const wxRealPoint& pt) const;
186 bool operator!=(const wxRealPoint& pt) const;
187
188 %extend {
189 void Set(double x, double y) {
190 self->x = x;
191 self->y = y;
192 }
193 PyObject* asTuple() {
194 wxPyBeginBlockThreads();
195 PyObject* tup = PyTuple_New(2);
196 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
197 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
198 wxPyEndBlockThreads();
199 return tup;
200 }
201 }
202
203 %pythoncode {
204 def __str__(self): return str(self.asTuple())
205 def __repr__(self): return 'wxRealPoint'+str(self.asTuple())
206 def __len__(self): return len(self.asTuple())
207 def __getitem__(self, index): return self.asTuple()[index]
208 def __setitem__(self, index, val):
209 if index == 0: self.width = val
210 elif index == 1: self.height = val
211 else: raise IndexError
212 def __nonzero__(self): return self.asTuple() != (0.0, 0.0)
213 def __getinitargs__(self): return ()
214 def __getstate__(self): return self.asTuple()
215 def __setstate__(self, state): self.Set(*state)
216 }
217 };
218
219 //---------------------------------------------------------------------------
220 %newgroup
221 %noautorepr wxPoint;
222
223 class wxPoint
224 {
225 public:
226 int x, y;
227
228 wxPoint(int x=0, int y=0);
229 ~wxPoint();
230
231 bool operator==(const wxPoint& p) const;
232 bool operator!=(const wxPoint& p) const;
233
234 wxPoint operator+(const wxPoint& p) const;
235 wxPoint operator-(const wxPoint& p) const;
236
237 wxPoint& operator+=(const wxPoint& p);
238 wxPoint& operator-=(const wxPoint& p);
239
240 %extend {
241 void Set(long x, long y) {
242 self->x = x;
243 self->y = y;
244 }
245 PyObject* asTuple() {
246 wxPyBeginBlockThreads();
247 PyObject* tup = PyTuple_New(2);
248 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
249 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
250 wxPyEndBlockThreads();
251 return tup;
252 }
253 }
254
255 %pythoncode {
256 def __str__(self): return str(self.asTuple())
257 def __repr__(self): return 'wxPoint'+str(self.asTuple())
258 def __len__(self): return len(self.asTuple())
259 def __getitem__(self, index): return self.asTuple()[index]
260 def __setitem__(self, index, val):
261 if index == 0: self.x = val
262 elif index == 1: self.y = val
263 else: raise IndexError
264 def __nonzero__(self): return self.asTuple() != (0,0)
265 def __getinitargs__(self): return ()
266 def __getstate__(self): return self.asTuple()
267 def __setstate__(self, state): self.Set(*state)
268 }
269 };
270
271 //---------------------------------------------------------------------------
272 %newgroup
273 %noautorepr wxRect;
274
275 class wxRect
276 {
277 public:
278 wxRect(int x=0, int y=0, int width=0, int height=0);
279 %name(RectPP) wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
280 %name(RectPS) wxRect(const wxPoint& pos, const wxSize& size);
281 ~wxRect();
282
283 int GetX() const;
284 void SetX(int x);
285
286 int GetY();
287 void SetY(int y);
288
289 int GetWidth() const;
290 void SetWidth(int w);
291
292 int GetHeight() const;
293 void SetHeight(int h);
294
295 wxPoint GetPosition() const;
296 void SetPosition( const wxPoint &p );
297
298 wxSize GetSize() const;
299 void SetSize( const wxSize &s );
300
301 int GetLeft() const;
302 int GetTop() const;
303 int GetBottom() const;
304 int GetRight() const;
305
306 void SetLeft(int left);
307 void SetRight(int right);
308 void SetTop(int top);
309 void SetBottom(int bottom);
310
311 wxRect& Inflate(wxCoord dx, wxCoord dy);
312 wxRect& Deflate(wxCoord dx, wxCoord dy);
313
314 %name(OffsetXY)void Offset(wxCoord dx, wxCoord dy);
315 void Offset(const wxPoint& pt);
316
317 wxRect& Intersect(const wxRect& rect);
318
319 wxRect operator+(const wxRect& rect) const;
320 wxRect& operator+=(const wxRect& rect);
321
322 bool operator==(const wxRect& rect) const;
323 bool operator!=(const wxRect& rect) const { return !(*this == rect); }
324
325 // return TRUE if the point is (not strcitly) inside the rect
326 %name(InsideXY)bool Inside(int x, int y) const;
327 bool Inside(const wxPoint& pt) const;
328
329 // return TRUE if the rectangles have a non empty intersection
330 bool Intersects(const wxRect& rect) const;
331
332 int x, y, width, height;
333
334
335 %extend {
336 void Set(int x=0, int y=0, int width=0, int height=0) {
337 self->x = x;
338 self->y = y;
339 self->width = width;
340 self->height = height;
341 }
342
343 PyObject* asTuple() {
344 wxPyBeginBlockThreads();
345 PyObject* tup = PyTuple_New(4);
346 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
347 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
348 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
349 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
350 wxPyEndBlockThreads();
351 return tup;
352 }
353 }
354
355 %pythoncode {
356 def __str__(self): return str(self.asTuple())
357 def __repr__(self): return 'wxRect'+str(self.asTuple())
358 def __len__(self): return len(self.asTuple())
359 def __getitem__(self, index): return self.asTuple()[index]
360 def __setitem__(self, index, val):
361 if index == 0: self.x = val
362 elif index == 1: self.y = val
363 elif index == 2: self.width = val
364 elif index == 3: self.height = val
365 else: raise IndexError
366 def __nonzero__(self): return self.asTuple() != (0,0,0,0)
367 def __getinitargs__(self): return ()
368 def __getstate__(self): return self.asTuple()
369 def __setstate__(self, state): self.Set(*state)
370 }
371 };
372
373
374 %inline %{
375 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
376 wxRegion reg1(*r1);
377 wxRegion reg2(*r2);
378 wxRect dest(0,0,0,0);
379 PyObject* obj;
380
381 reg1.Intersect(reg2);
382 dest = reg1.GetBox();
383
384 if (dest != wxRect(0,0,0,0)) {
385 wxPyBeginBlockThreads();
386 wxRect* newRect = new wxRect(dest);
387 obj = wxPyConstructObject((void*)newRect, wxT("wxRect"), true);
388 wxPyEndBlockThreads();
389 return obj;
390 }
391 Py_INCREF(Py_None);
392 return Py_None;
393 }
394 %}
395
396 //---------------------------------------------------------------------------
397 %newgroup
398 %noautorepr wxPoint2D;
399
400 // wxPoint2Ds represent a point or a vector in a 2d coordinate system
401
402 class wxPoint2D
403 {
404 public :
405 wxPoint2D( double x=0.0 , double y=0.0 );
406 %name(Point2DCopy) wxPoint2D( const wxPoint2D &pt );
407 %name(Point2DFromPoint) wxPoint2D( const wxPoint &pt );
408
409 // two different conversions to integers, floor and rounding
410 void GetFloor( int *OUTPUT , int *OUTPUT ) const;
411 void GetRounded( int *OUTPUT , int *OUTPUT ) const;
412
413 double GetVectorLength() const;
414 double GetVectorAngle() const ;
415 void SetVectorLength( double length );
416 void SetVectorAngle( double degrees );
417 // LinkError: void SetPolarCoordinates( double angle , double length );
418 // LinkError: void Normalize();
419 %pythoncode {
420 def SetPolarCoordinates(self, angle, length):
421 self.SetVectorLength(length)
422 self.SetVectorAngle(angle)
423 def Normalize(self):
424 self.SetVectorLength(1.0)
425 }
426
427 double GetDistance( const wxPoint2D &pt ) const;
428 double GetDistanceSquare( const wxPoint2D &pt ) const;
429 double GetDotProduct( const wxPoint2D &vec ) const;
430 double GetCrossProduct( const wxPoint2D &vec ) const;
431
432 // the reflection of this point
433 wxPoint2D operator-();
434
435 wxPoint2D& operator+=(const wxPoint2D& pt);
436 wxPoint2D& operator-=(const wxPoint2D& pt);
437
438 wxPoint2D& operator*=(const wxPoint2D& pt);
439 wxPoint2D& operator/=(const wxPoint2D& pt);
440
441 bool operator==(const wxPoint2D& pt) const;
442 bool operator!=(const wxPoint2D& pt) const;
443
444 double m_x;
445 double m_y;
446 %name(x)double m_x;
447 %name(y)double m_y;
448
449 %extend {
450 void Set( double x=0 , double y=0 ) {
451 self->m_x = x;
452 self->m_y = y;
453 }
454 PyObject* asTuple() {
455 wxPyBeginBlockThreads();
456 PyObject* tup = PyTuple_New(2);
457 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x));
458 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y));
459 wxPyEndBlockThreads();
460 return tup;
461 }
462 }
463
464 %pythoncode {
465 def __str__(self): return str(self.asTuple())
466 def __repr__(self): return 'wxPoint2D'+str(self.asTuple())
467 def __len__(self): return len(self.asTuple())
468 def __getitem__(self, index): return self.asTuple()[index]
469 def __setitem__(self, index, val):
470 if index == 0: self.m_x = val
471 elif index == 1: self.m_yt = val
472 else: raise IndexError
473 def __nonzero__(self): return self.asTuple() != (0.0, 0.0)
474 def __getinitargs__(self): return ()
475 def __getstate__(self): return self.asTuple()
476 def __setstate__(self, state): self.Set(*state)
477
478 }
479 };
480
481
482 //---------------------------------------------------------------------------
483
484 %immutable;
485 const wxPoint wxDefaultPosition;
486 const wxSize wxDefaultSize;
487 %mutable;
488
489 //---------------------------------------------------------------------------