]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/src/_gdicmn.i
reSWIGged
[wxWidgets.git] / wxPython / src / _gdicmn.i
... / ...
CommitLineData
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
20enum wxBitmapType
21{
22 wxBITMAP_TYPE_INVALID, // should be == 0 for compatibility!
23 wxBITMAP_TYPE_BMP,
24 wxBITMAP_TYPE_ICO,
25 wxBITMAP_TYPE_CUR,
26 wxBITMAP_TYPE_XBM,
27 wxBITMAP_TYPE_XBM_DATA,
28 wxBITMAP_TYPE_XPM,
29 wxBITMAP_TYPE_XPM_DATA,
30 wxBITMAP_TYPE_TIF,
31 wxBITMAP_TYPE_GIF,
32 wxBITMAP_TYPE_PNG,
33 wxBITMAP_TYPE_JPEG,
34 wxBITMAP_TYPE_PNM,
35 wxBITMAP_TYPE_PCX,
36 wxBITMAP_TYPE_PICT,
37 wxBITMAP_TYPE_ICON,
38 wxBITMAP_TYPE_ANI,
39 wxBITMAP_TYPE_IFF,
40 wxBITMAP_TYPE_MACCURSOR,
41
42// wxBITMAP_TYPE_BMP_RESOURCE,
43// wxBITMAP_TYPE_RESOURCE = wxBITMAP_TYPE_BMP_RESOURCE,
44// wxBITMAP_TYPE_ICO_RESOURCE,
45// wxBITMAP_TYPE_CUR_RESOURCE,
46// wxBITMAP_TYPE_TIF_RESOURCE,
47// wxBITMAP_TYPE_GIF_RESOURCE,
48// wxBITMAP_TYPE_PNG_RESOURCE,
49// wxBITMAP_TYPE_JPEG_RESOURCE,
50// wxBITMAP_TYPE_PNM_RESOURCE,
51// wxBITMAP_TYPE_PCX_RESOURCE,
52// wxBITMAP_TYPE_PICT_RESOURCE,
53// wxBITMAP_TYPE_ICON_RESOURCE,
54// wxBITMAP_TYPE_MACCURSOR_RESOURCE,
55
56 wxBITMAP_TYPE_ANY = 50
57};
58
59// Standard cursors
60enum wxStockCursor
61{
62 wxCURSOR_NONE, // should be 0
63 wxCURSOR_ARROW,
64 wxCURSOR_RIGHT_ARROW,
65 wxCURSOR_BULLSEYE,
66 wxCURSOR_CHAR,
67 wxCURSOR_CROSS,
68 wxCURSOR_HAND,
69 wxCURSOR_IBEAM,
70 wxCURSOR_LEFT_BUTTON,
71 wxCURSOR_MAGNIFIER,
72 wxCURSOR_MIDDLE_BUTTON,
73 wxCURSOR_NO_ENTRY,
74 wxCURSOR_PAINT_BRUSH,
75 wxCURSOR_PENCIL,
76 wxCURSOR_POINT_LEFT,
77 wxCURSOR_POINT_RIGHT,
78 wxCURSOR_QUESTION_ARROW,
79 wxCURSOR_RIGHT_BUTTON,
80 wxCURSOR_SIZENESW,
81 wxCURSOR_SIZENS,
82 wxCURSOR_SIZENWSE,
83 wxCURSOR_SIZEWE,
84 wxCURSOR_SIZING,
85 wxCURSOR_SPRAYCAN,
86 wxCURSOR_WAIT,
87 wxCURSOR_WATCH,
88 wxCURSOR_BLANK,
89 wxCURSOR_DEFAULT, // standard X11 cursor
90 wxCURSOR_COPY_ARROW , // MacOS Theme Plus arrow
91
92// #ifdef __X__
93// // Not yet implemented for Windows
94// wxCURSOR_CROSS_REVERSE,
95// wxCURSOR_DOUBLE_ARROW,
96// wxCURSOR_BASED_ARROW_UP,
97// wxCURSOR_BASED_ARROW_DOWN,
98// #endif // X11
99
100 wxCURSOR_ARROWWAIT,
101
102 wxCURSOR_MAX
103};
104
105%{
106#ifndef __WXMAC__
107#define wxCURSOR_COPY_ARROW wxCURSOR_ARROW
108#endif
109%}
110
111//---------------------------------------------------------------------------
112%newgroup
113
114DocStr( wxSize,
115"wx.Size is a useful data structure used to represent the size of something.
116It simply contians integer width and height proprtites. In most places in
117wxPython where a wx.Size is expected a (width,height) tuple can be used
118instead.");
119
120class wxSize
121{
122public:
123 %name(width) int x;
124 %name(height)int y;
125 %pythoncode { x = width; y = height }
126
127 DocCtorStr(
128 wxSize(int w=0, int h=0),
129 "Creates a size object.");
130
131 ~wxSize();
132
133 DocDeclStr(
134 bool, operator==(const wxSize& sz),
135 "Test for equality of wx.Size objects.");
136
137 DocDeclStr(
138 bool, operator!=(const wxSize& sz),
139 "Test for inequality.");
140
141 DocDeclStr(
142 wxSize, operator+(const wxSize& sz),
143 "Add sz's proprties to this and return the result.");
144
145 DocDeclStr(
146 wxSize, operator-(const wxSize& sz),
147 "Subtract sz's properties from this and return the result.");
148
149 DocDeclStr(
150 void, IncTo(const wxSize& sz),
151 "Increments this object so that both of its dimensions are not less\n"
152 "than the corresponding dimensions of the size.");
153
154 DocDeclStr(
155 void, DecTo(const wxSize& sz),
156 "Decrements this object so that both of its dimensions are not greater\n"
157 "than the corresponding dimensions of the size.");
158
159 DocDeclStr(
160 void, Set(int w, int h),
161 "Set both width and height.");
162
163 void SetWidth(int w);
164 void SetHeight(int h);
165 int GetWidth() const;
166 int GetHeight() const;
167
168 //int GetX() const;
169 //int GetY() const;
170
171 %extend {
172 DocAStr(Get,
173 "Get() -> (width,height)",
174 "Returns the width and height properties as a tuple.");
175 PyObject* Get() {
176 wxPyBeginBlockThreads();
177 PyObject* tup = PyTuple_New(2);
178 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
179 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
180 wxPyEndBlockThreads();
181 return tup;
182 }
183 }
184 %pythoncode {
185 asTuple = Get
186 def __str__(self): return str(self.Get())
187 def __repr__(self): return 'wx.Size'+str(self.Get())
188 def __len__(self): return len(self.Get())
189 def __getitem__(self, index): return self.Get()[index]
190 def __setitem__(self, index, val):
191 if index == 0: self.width = val
192 elif index == 1: self.height = val
193 else: raise IndexError
194 def __nonzero__(self): return self.Get() != (0,0)
195 __safe_for_unpickling__ = True
196 def __reduce__(self): return (wx.Size, self.Get())
197 }
198
199};
200
201//---------------------------------------------------------------------------
202%newgroup
203
204DocStr( wxRealPoint,
205"A data structure for representing a point or position with floating point x
206and y properties. In wxPython most places that expect a wx.RealPoint can also
207accept a (x,y) tuple.");
208class wxRealPoint
209{
210public:
211 double x;
212 double y;
213
214 DocCtorStr(
215 wxRealPoint(double x=0.0, double y=0.0),
216 "Create a wx.RealPoint object");
217
218 ~wxRealPoint();
219
220 DocDeclStr(
221 bool, operator==(const wxRealPoint& pt),
222 "Test for equality of wx.RealPoint objects.");
223
224 DocDeclStr(
225 bool, operator!=(const wxRealPoint& pt),
226 "Test for inequality of wx.RealPoint objects.");
227
228
229 DocDeclStr(
230 wxRealPoint, operator+(const wxRealPoint& pt),
231 "Add pt's proprties to this and return the result.");
232
233 DocDeclStr(
234 wxRealPoint, operator-(const wxRealPoint& pt),
235 "Subtract pt's proprties from this and return the result");
236
237
238 %extend {
239 DocStr(Set, "Set both the x and y properties");
240 void Set(double x, double y) {
241 self->x = x;
242 self->y = y;
243 }
244
245 DocAStr(Get,
246 "Get() -> (x,y)",
247 "Return the x and y properties as a tuple. ");
248 PyObject* Get() {
249 wxPyBeginBlockThreads();
250 PyObject* tup = PyTuple_New(2);
251 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
252 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
253 wxPyEndBlockThreads();
254 return tup;
255 }
256 }
257
258 %pythoncode {
259 asTuple = Get
260 def __str__(self): return str(self.Get())
261 def __repr__(self): return 'wx.RealPoint'+str(self.Get())
262 def __len__(self): return len(self.Get())
263 def __getitem__(self, index): return self.Get()[index]
264 def __setitem__(self, index, val):
265 if index == 0: self.x = val
266 elif index == 1: self.y = val
267 else: raise IndexError
268 def __nonzero__(self): return self.Get() != (0.0, 0.0)
269 __safe_for_unpickling__ = True
270 def __reduce__(self): return (wx.RealPoint, self.Get())
271 }
272};
273
274
275//---------------------------------------------------------------------------
276%newgroup
277
278
279DocStr(wxPoint,
280"A data structure for representing a point or position with integer x and y
281properties. Most places in wxPython that expect a wx.Point can also accept a
282(x,y) tuple.");
283
284class wxPoint
285{
286public:
287 int x, y;
288
289 DocCtorStr(
290 wxPoint(int x=0, int y=0),
291 "Create a wx.Point object");
292
293 ~wxPoint();
294
295
296 DocDeclStr(
297 bool, operator==(const wxPoint& pt),
298 "Test for equality of wx.Point objects.");
299
300 DocDeclStr(
301 bool, operator!=(const wxPoint& pt),
302 "Test for inequality of wx.Point objects.");
303
304
305
306// %nokwargs operator+;
307// %nokwargs operator-;
308// %nokwargs operator+=;
309// %nokwargs operator-=;
310
311 DocDeclStr(
312 wxPoint, operator+(const wxPoint& pt),
313 "Add pt's proprties to this and return the result.");
314
315
316 DocDeclStr(
317 wxPoint, operator-(const wxPoint& pt),
318 "Subtract pt's proprties from this and return the result");
319
320
321 DocDeclStr(
322 wxPoint&, operator+=(const wxPoint& pt),
323 "Add pt to this object.");
324
325 DocDeclStr(
326 wxPoint&, operator-=(const wxPoint& pt),
327 "Subtract pt from this object.");
328
329
330
331// DocDeclStr(
332// wxPoint, operator+(const wxSize& sz),
333// "Add sz to this Point and return the result.");
334
335// DocDeclStr(
336// wxPoint, operator-(const wxSize& sz),
337// "Subtract sz from this Point and return the result");
338
339
340// DocDeclStr(
341// wxPoint&, operator+=(const wxSize& sz),
342// "Add sz to this object.");
343
344// DocDeclStr(
345// wxPoint&, operator-=(const wxSize& sz),
346// "Subtract sz from this object.");
347
348
349
350
351 %extend {
352 DocStr(Set, "Set both the x and y properties");
353 void Set(long x, long y) {
354 self->x = x;
355 self->y = y;
356 }
357
358 DocAStr(Get,
359 "Get() -> (x,y)",
360 "Return the x and y properties as a tuple. ");
361 PyObject* Get() {
362 wxPyBeginBlockThreads();
363 PyObject* tup = PyTuple_New(2);
364 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
365 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
366 wxPyEndBlockThreads();
367 return tup;
368 }
369 }
370
371 %pythoncode {
372 asTuple = Get
373 def __str__(self): return str(self.Get())
374 def __repr__(self): return 'wx.Point'+str(self.Get())
375 def __len__(self): return len(self.Get())
376 def __getitem__(self, index): return self.Get()[index]
377 def __setitem__(self, index, val):
378 if index == 0: self.x = val
379 elif index == 1: self.y = val
380 else: raise IndexError
381 def __nonzero__(self): return self.Get() != (0,0)
382 __safe_for_unpickling__ = True
383 def __reduce__(self): return (wx.Point, self.Get())
384 }
385};
386
387//---------------------------------------------------------------------------
388%newgroup
389
390
391DocStr(wxRect,
392"A class for representing and manipulating rectangles. It has x, y, width and
393height properties. In wxPython most palces that expect a wx.Rect can also
394accept a (x,y,width,height) tuple.");
395
396class wxRect
397{
398public:
399 DocCtorStr(
400 wxRect(int x=0, int y=0, int width=0, int height=0),
401 "Create a new Rect object.");
402
403 DocCtorStrName(
404 wxRect(const wxPoint& topLeft, const wxPoint& bottomRight),
405 "Create a new Rect object from Points representing two corners.",
406 RectPP);
407
408 DocCtorStrName(
409 wxRect(const wxPoint& pos, const wxSize& size),
410 "Create a new Rect from a position and size.",
411 RectPS);
412
413 ~wxRect();
414
415 int GetX() const;
416 void SetX(int x);
417
418 int GetY();
419 void SetY(int y);
420
421 int GetWidth() const;
422 void SetWidth(int w);
423
424 int GetHeight() const;
425 void SetHeight(int h);
426
427 wxPoint GetPosition() const;
428 void SetPosition( const wxPoint &p );
429
430 wxSize GetSize() const;
431 void SetSize( const wxSize &s );
432
433 wxPoint GetTopLeft() const;
434 void SetTopLeft(const wxPoint &p);
435 wxPoint GetBottomRight() const;
436 void SetBottomRight(const wxPoint &p);
437
438// wxPoint GetLeftTop() const;
439// void SetLeftTop(const wxPoint &p);
440// wxPoint GetRightBottom() const;
441// void SetRightBottom(const wxPoint &p);
442
443 int GetLeft() const;
444 int GetTop() const;
445 int GetBottom() const;
446 int GetRight() const;
447
448 void SetLeft(int left);
449 void SetRight(int right);
450 void SetTop(int top);
451 void SetBottom(int bottom);
452
453 %pythoncode {
454 position = property(GetPosition, SetPosition)
455 size = property(GetSize, SetSize)
456 left = property(GetLeft, SetLeft)
457 right = property(GetRight, SetRight)
458 top = property(GetTop, SetTop)
459 bottom = property(GetBottom, SetBottom)
460 }
461
462 DocDeclStr(
463 wxRect&, Inflate(wxCoord dx, wxCoord dy),
464 "Increase the rectangle size by dx in x direction and dy in y direction. Both\n"
465 "(or one of) parameters may be negative to decrease the rectangle size.");
466
467 DocDeclStr(
468 wxRect&, Deflate(wxCoord dx, wxCoord dy),
469 "Decrease the rectangle size by dx in x direction and dy in y direction. Both\n"
470 "(or one of) parameters may be negative to increase the rectngle size. This\n"
471 "method is the opposite of Inflate.");
472
473 DocDeclStrName(
474 void, Offset(wxCoord dx, wxCoord dy),
475 "Moves the rectangle by the specified offset. If dx is positive, the rectangle\n"
476 "is moved to the right, if dy is positive, it is moved to the bottom, otherwise\n"
477 "it is moved to the left or top respectively.",
478 OffsetXY);
479
480 DocDeclStr(
481 void, Offset(const wxPoint& pt),
482 "Same as OffsetXY but uses dx,dy from Point");
483
484 DocDeclStr(
485 wxRect&, Intersect(const wxRect& rect),
486 "Return the intersectsion of this rectangle and rect.");
487
488 DocDeclStr(
489 wxRect, operator+(const wxRect& rect) const,
490 "Add the properties of rect to this rectangle and return the result.");
491
492 DocDeclStr(
493 wxRect&, operator+=(const wxRect& rect),
494 "Add the properties of rect to this rectangle, updating this rectangle.");
495
496 DocDeclStr(
497 bool, operator==(const wxRect& rect) const,
498 "Test for equality.");
499
500 DocDeclStr(
501 bool, operator!=(const wxRect& rect) const,
502 "Test for inequality.");
503
504
505 DocStr( Inside, "Return True if the point is (not strcitly) inside the rect.");
506 %name(InsideXY)bool Inside(int x, int y) const;
507 bool Inside(const wxPoint& pt) const;
508
509 DocDeclStr(
510 bool, Intersects(const wxRect& rect) const,
511 "Returns True if the rectangles have a non empty intersection.");
512
513
514 int x, y, width, height;
515
516
517 %extend {
518 DocStr(Set, "Set all rectangle properties.");
519 void Set(int x=0, int y=0, int width=0, int height=0) {
520 self->x = x;
521 self->y = y;
522 self->width = width;
523 self->height = height;
524 }
525
526 DocAStr(Get,
527 "Get() -> (x,y,width,height)",
528 "Return the rectangle properties as a tuple.");
529 PyObject* Get() {
530 wxPyBeginBlockThreads();
531 PyObject* tup = PyTuple_New(4);
532 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
533 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
534 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
535 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
536 wxPyEndBlockThreads();
537 return tup;
538 }
539 }
540
541 %pythoncode {
542 asTuple = Get
543 def __str__(self): return str(self.Get())
544 def __repr__(self): return 'wx.Rect'+str(self.Get())
545 def __len__(self): return len(self.Get())
546 def __getitem__(self, index): return self.Get()[index]
547 def __setitem__(self, index, val):
548 if index == 0: self.x = val
549 elif index == 1: self.y = val
550 elif index == 2: self.width = val
551 elif index == 3: self.height = val
552 else: raise IndexError
553 def __nonzero__(self): return self.Get() != (0,0,0,0)
554 __safe_for_unpickling__ = True
555 def __reduce__(self): return (wx.Rect, self.Get())
556 }
557};
558
559
560DocAStr(wxIntersectRect,
561 "IntersectRect(Rect r1, Rect r2) -> Rect",
562 "Calculate and return the intersection of r1 and r2.");
563%inline %{
564 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
565 wxRegion reg1(*r1);
566 wxRegion reg2(*r2);
567 wxRect dest(0,0,0,0);
568 PyObject* obj;
569
570 reg1.Intersect(reg2);
571 dest = reg1.GetBox();
572
573 if (dest != wxRect(0,0,0,0)) {
574 wxPyBeginBlockThreads();
575 wxRect* newRect = new wxRect(dest);
576 obj = wxPyConstructObject((void*)newRect, wxT("wxRect"), True);
577 wxPyEndBlockThreads();
578 return obj;
579 }
580 Py_INCREF(Py_None);
581 return Py_None;
582 }
583%}
584
585//---------------------------------------------------------------------------
586%newgroup
587
588
589DocStr(wxPoint2D,
590 "wx.Point2Ds represent a point or a vector in a 2d coordinate system with floating point values.");
591
592class wxPoint2D
593{
594public:
595 DocStr(wxPoint2D, "Create a w.Point2D object.");
596 wxPoint2D( double x=0.0 , double y=0.0 );
597 %name(Point2DCopy) wxPoint2D( const wxPoint2D &pt );
598 %name(Point2DFromPoint) wxPoint2D( const wxPoint &pt );
599
600 DocDeclAStr(
601 void, GetFloor( int *OUTPUT , int *OUTPUT ) const,
602 "GetFloor() -> (x,y)",
603 "Convert to integer");
604
605 DocDeclAStr(
606 void, GetRounded( int *OUTPUT , int *OUTPUT ) const,
607 "GetRounded() -> (x,y)",
608 "Convert to integer");
609
610 double GetVectorLength() const;
611 double GetVectorAngle() const ;
612 void SetVectorLength( double length );
613 void SetVectorAngle( double degrees );
614
615 // LinkError: void SetPolarCoordinates( double angle , double length );
616 // LinkError: void Normalize();
617 %pythoncode {
618 def SetPolarCoordinates(self, angle, length):
619 self.SetVectorLength(length)
620 self.SetVectorAngle(angle)
621 def Normalize(self):
622 self.SetVectorLength(1.0)
623 }
624
625 double GetDistance( const wxPoint2D &pt ) const;
626 double GetDistanceSquare( const wxPoint2D &pt ) const;
627 double GetDotProduct( const wxPoint2D &vec ) const;
628 double GetCrossProduct( const wxPoint2D &vec ) const;
629
630 DocDeclStr(
631 wxPoint2D, operator-(),
632 "the reflection of this point");
633
634 wxPoint2D& operator+=(const wxPoint2D& pt);
635 wxPoint2D& operator-=(const wxPoint2D& pt);
636
637 wxPoint2D& operator*=(const wxPoint2D& pt);
638 wxPoint2D& operator/=(const wxPoint2D& pt);
639
640 DocDeclStr(
641 bool, operator==(const wxPoint2D& pt) const,
642 "Test for equality");
643
644 DocDeclStr(
645 bool, operator!=(const wxPoint2D& pt) const,
646 "Test for inequality");
647
648 %name(x)double m_x;
649 %name(y)double m_y;
650
651 %extend {
652 void Set( double x=0 , double y=0 ) {
653 self->m_x = x;
654 self->m_y = y;
655 }
656
657 DocAStr(Get,
658 "Get() -> (x,y)",
659 "Return x and y properties as a tuple.");
660 PyObject* Get() {
661 wxPyBeginBlockThreads();
662 PyObject* tup = PyTuple_New(2);
663 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x));
664 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y));
665 wxPyEndBlockThreads();
666 return tup;
667 }
668 }
669
670 %pythoncode {
671 asTuple = Get
672 def __str__(self): return str(self.Get())
673 def __repr__(self): return 'wx.Point2D'+str(self.Get())
674 def __len__(self): return len(self.Get())
675 def __getitem__(self, index): return self.Get()[index]
676 def __setitem__(self, index, val):
677 if index == 0: self.x = val
678 elif index == 1: self.y = val
679 else: raise IndexError
680 def __nonzero__(self): return self.Get() != (0.0, 0.0)
681 __safe_for_unpickling__ = True
682 def __reduce__(self): return (wx.Point2D, self.Get())
683 }
684};
685
686
687//---------------------------------------------------------------------------
688
689%immutable;
690const wxPoint wxDefaultPosition;
691const wxSize wxDefaultSize;
692%mutable;
693
694//---------------------------------------------------------------------------