1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface for common GDI stuff and misc classes
7 // Created: 13-Sept-2003
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
22 wxBITMAP_TYPE_INVALID, // should be == 0 for compatibility!
27 wxBITMAP_TYPE_XBM_DATA,
29 wxBITMAP_TYPE_XPM_DATA,
40 wxBITMAP_TYPE_MACCURSOR,
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,
56 wxBITMAP_TYPE_ANY = 50
62 wxCURSOR_NONE, // should be 0
72 wxCURSOR_MIDDLE_BUTTON,
78 wxCURSOR_QUESTION_ARROW,
79 wxCURSOR_RIGHT_BUTTON,
89 wxCURSOR_DEFAULT, // standard X11 cursor
90 wxCURSOR_COPY_ARROW , // MacOS Theme Plus arrow
93 // // Not yet implemented for Windows
94 // wxCURSOR_CROSS_REVERSE,
95 // wxCURSOR_DOUBLE_ARROW,
96 // wxCURSOR_BASED_ARROW_UP,
97 // wxCURSOR_BASED_ARROW_DOWN,
107 #define wxCURSOR_COPY_ARROW wxCURSOR_ARROW
111 //---------------------------------------------------------------------------
115 "wx.Size is a useful data structure used to represent the size of something.
116 It simply contians integer width and height proprtites. In most places in
117 wxPython where a wx.Size is expected a (width,height) tuple can be used
125 %pythoncode { x = width; y = height }
128 wxSize(int w=0, int h=0),
129 "Creates a size object.");
134 // bool __eq__(const wxSize* other) { return other ? (*self == *other) : False; }
135 // bool __ne__(const wxSize* other) { return other ? (*self != *other) : True; }
139 bool, operator==(const wxSize& sz),
140 "Test for equality of wx.Size objects.");
143 bool, operator!=(const wxSize& sz),
144 "Test for inequality.");
147 wxSize, operator+(const wxSize& sz),
148 "Add sz's proprties to this and return the result.");
151 wxSize, operator-(const wxSize& sz),
152 "Subtract sz's properties from this and return the result.");
155 void, IncTo(const wxSize& sz),
156 "Increments this object so that both of its dimensions are not less\n"
157 "than the corresponding dimensions of the size.");
160 void, DecTo(const wxSize& sz),
161 "Decrements this object so that both of its dimensions are not greater\n"
162 "than the corresponding dimensions of the size.");
165 void, Set(int w, int h),
166 "Set both width and height.");
168 void SetWidth(int w);
169 void SetHeight(int h);
170 int GetWidth() const;
171 int GetHeight() const;
178 "Get() -> (width,height)",
179 "Returns the width and height properties as a tuple.");
181 wxPyBeginBlockThreads();
182 PyObject* tup = PyTuple_New(2);
183 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
184 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
185 wxPyEndBlockThreads();
191 def __str__(self): return str(self.Get())
192 def __repr__(self): return 'wx.Size'+str(self.Get())
193 def __len__(self): return len(self.Get())
194 def __getitem__(self, index): return self.Get()[index]
195 def __setitem__(self, index, val):
196 if index == 0: self.width = val
197 elif index == 1: self.height = val
198 else: raise IndexError
199 def __nonzero__(self): return self.Get() != (0,0)
200 __safe_for_unpickling__ = True
201 def __reduce__(self): return (wx.Size, self.Get())
206 //---------------------------------------------------------------------------
210 "A data structure for representing a point or position with floating point x
211 and y properties. In wxPython most places that expect a wx.RealPoint can also
212 accept a (x,y) tuple.");
220 wxRealPoint(double x=0.0, double y=0.0),
221 "Create a wx.RealPoint object");
226 bool, operator==(const wxRealPoint& pt),
227 "Test for equality of wx.RealPoint objects.");
230 bool, operator!=(const wxRealPoint& pt),
231 "Test for inequality of wx.RealPoint objects.");
235 wxRealPoint, operator+(const wxRealPoint& pt),
236 "Add pt's proprties to this and return the result.");
239 wxRealPoint, operator-(const wxRealPoint& pt),
240 "Subtract pt's proprties from this and return the result");
244 DocStr(Set, "Set both the x and y properties");
245 void Set(double x, double y) {
252 "Return the x and y properties as a tuple. ");
254 wxPyBeginBlockThreads();
255 PyObject* tup = PyTuple_New(2);
256 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
257 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
258 wxPyEndBlockThreads();
265 def __str__(self): return str(self.Get())
266 def __repr__(self): return 'wx.RealPoint'+str(self.Get())
267 def __len__(self): return len(self.Get())
268 def __getitem__(self, index): return self.Get()[index]
269 def __setitem__(self, index, val):
270 if index == 0: self.x = val
271 elif index == 1: self.y = val
272 else: raise IndexError
273 def __nonzero__(self): return self.Get() != (0.0, 0.0)
274 __safe_for_unpickling__ = True
275 def __reduce__(self): return (wx.RealPoint, self.Get())
280 //---------------------------------------------------------------------------
285 "A data structure for representing a point or position with integer x and y
286 properties. Most places in wxPython that expect a wx.Point can also accept a
295 wxPoint(int x=0, int y=0),
296 "Create a wx.Point object");
302 bool, operator==(const wxPoint& pt),
303 "Test for equality of wx.Point objects.");
306 bool, operator!=(const wxPoint& pt),
307 "Test for inequality of wx.Point objects.");
311 // %nokwargs operator+;
312 // %nokwargs operator-;
313 // %nokwargs operator+=;
314 // %nokwargs operator-=;
317 wxPoint, operator+(const wxPoint& pt),
318 "Add pt's proprties to this and return the result.");
322 wxPoint, operator-(const wxPoint& pt),
323 "Subtract pt's proprties from this and return the result");
327 wxPoint&, operator+=(const wxPoint& pt),
328 "Add pt to this object.");
331 wxPoint&, operator-=(const wxPoint& pt),
332 "Subtract pt from this object.");
337 // wxPoint, operator+(const wxSize& sz),
338 // "Add sz to this Point and return the result.");
341 // wxPoint, operator-(const wxSize& sz),
342 // "Subtract sz from this Point and return the result");
346 // wxPoint&, operator+=(const wxSize& sz),
347 // "Add sz to this object.");
350 // wxPoint&, operator-=(const wxSize& sz),
351 // "Subtract sz from this object.");
357 DocStr(Set, "Set both the x and y properties");
358 void Set(long x, long y) {
365 "Return the x and y properties as a tuple. ");
367 wxPyBeginBlockThreads();
368 PyObject* tup = PyTuple_New(2);
369 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
370 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
371 wxPyEndBlockThreads();
378 def __str__(self): return str(self.Get())
379 def __repr__(self): return 'wx.Point'+str(self.Get())
380 def __len__(self): return len(self.Get())
381 def __getitem__(self, index): return self.Get()[index]
382 def __setitem__(self, index, val):
383 if index == 0: self.x = val
384 elif index == 1: self.y = val
385 else: raise IndexError
386 def __nonzero__(self): return self.Get() != (0,0)
387 __safe_for_unpickling__ = True
388 def __reduce__(self): return (wx.Point, self.Get())
392 //---------------------------------------------------------------------------
397 "A class for representing and manipulating rectangles. It has x, y, width and
398 height properties. In wxPython most palces that expect a wx.Rect can also
399 accept a (x,y,width,height) tuple.");
405 wxRect(int x=0, int y=0, int width=0, int height=0),
406 "Create a new Rect object.");
409 wxRect(const wxPoint& topLeft, const wxPoint& bottomRight),
410 "Create a new Rect object from Points representing two corners.",
414 wxRect(const wxPoint& pos, const wxSize& size),
415 "Create a new Rect from a position and size.",
426 int GetWidth() const;
427 void SetWidth(int w);
429 int GetHeight() const;
430 void SetHeight(int h);
432 wxPoint GetPosition() const;
433 void SetPosition( const wxPoint &p );
435 wxSize GetSize() const;
436 void SetSize( const wxSize &s );
438 wxPoint GetTopLeft() const;
439 void SetTopLeft(const wxPoint &p);
440 wxPoint GetBottomRight() const;
441 void SetBottomRight(const wxPoint &p);
443 // wxPoint GetLeftTop() const;
444 // void SetLeftTop(const wxPoint &p);
445 // wxPoint GetRightBottom() const;
446 // void SetRightBottom(const wxPoint &p);
450 int GetBottom() const;
451 int GetRight() const;
453 void SetLeft(int left);
454 void SetRight(int right);
455 void SetTop(int top);
456 void SetBottom(int bottom);
459 position = property(GetPosition, SetPosition)
460 size = property(GetSize, SetSize)
461 left = property(GetLeft, SetLeft)
462 right = property(GetRight, SetRight)
463 top = property(GetTop, SetTop)
464 bottom = property(GetBottom, SetBottom)
468 wxRect&, Inflate(wxCoord dx, wxCoord dy),
469 "Increase the rectangle size by dx in x direction and dy in y direction. Both\n"
470 "(or one of) parameters may be negative to decrease the rectangle size.");
473 wxRect&, Deflate(wxCoord dx, wxCoord dy),
474 "Decrease the rectangle size by dx in x direction and dy in y direction. Both\n"
475 "(or one of) parameters may be negative to increase the rectngle size. This\n"
476 "method is the opposite of Inflate.");
479 void, Offset(wxCoord dx, wxCoord dy),
480 "Moves the rectangle by the specified offset. If dx is positive, the rectangle\n"
481 "is moved to the right, if dy is positive, it is moved to the bottom, otherwise\n"
482 "it is moved to the left or top respectively.",
486 void, Offset(const wxPoint& pt),
487 "Same as OffsetXY but uses dx,dy from Point");
490 wxRect&, Intersect(const wxRect& rect),
491 "Return the intersectsion of this rectangle and rect.");
494 wxRect, operator+(const wxRect& rect) const,
495 "Add the properties of rect to this rectangle and return the result.");
498 wxRect&, operator+=(const wxRect& rect),
499 "Add the properties of rect to this rectangle, updating this rectangle.");
502 bool, operator==(const wxRect& rect) const,
503 "Test for equality.");
506 bool, operator!=(const wxRect& rect) const,
507 "Test for inequality.");
510 DocStr( Inside, "Return True if the point is (not strcitly) inside the rect.");
511 %name(InsideXY)bool Inside(int x, int y) const;
512 bool Inside(const wxPoint& pt) const;
515 bool, Intersects(const wxRect& rect) const,
516 "Returns True if the rectangles have a non empty intersection.");
519 int x, y, width, height;
523 DocStr(Set, "Set all rectangle properties.");
524 void Set(int x=0, int y=0, int width=0, int height=0) {
528 self->height = height;
532 "Get() -> (x,y,width,height)",
533 "Return the rectangle properties as a tuple.");
535 wxPyBeginBlockThreads();
536 PyObject* tup = PyTuple_New(4);
537 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
538 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
539 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
540 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
541 wxPyEndBlockThreads();
548 def __str__(self): return str(self.Get())
549 def __repr__(self): return 'wx.Rect'+str(self.Get())
550 def __len__(self): return len(self.Get())
551 def __getitem__(self, index): return self.Get()[index]
552 def __setitem__(self, index, val):
553 if index == 0: self.x = val
554 elif index == 1: self.y = val
555 elif index == 2: self.width = val
556 elif index == 3: self.height = val
557 else: raise IndexError
558 def __nonzero__(self): return self.Get() != (0,0,0,0)
559 __safe_for_unpickling__ = True
560 def __reduce__(self): return (wx.Rect, self.Get())
565 DocAStr(wxIntersectRect,
566 "IntersectRect(Rect r1, Rect r2) -> Rect",
567 "Calculate and return the intersection of r1 and r2.");
569 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
572 wxRect dest(0,0,0,0);
575 reg1.Intersect(reg2);
576 dest = reg1.GetBox();
578 if (dest != wxRect(0,0,0,0)) {
579 wxPyBeginBlockThreads();
580 wxRect* newRect = new wxRect(dest);
581 obj = wxPyConstructObject((void*)newRect, wxT("wxRect"), True);
582 wxPyEndBlockThreads();
590 //---------------------------------------------------------------------------
595 "wx.Point2Ds represent a point or a vector in a 2d coordinate system with floating point values.");
600 DocStr(wxPoint2D, "Create a w.Point2D object.");
601 wxPoint2D( double x=0.0 , double y=0.0 );
602 %name(Point2DCopy) wxPoint2D( const wxPoint2D &pt );
603 %name(Point2DFromPoint) wxPoint2D( const wxPoint &pt );
606 void, GetFloor( int *OUTPUT , int *OUTPUT ) const,
607 "GetFloor() -> (x,y)",
608 "Convert to integer");
611 void, GetRounded( int *OUTPUT , int *OUTPUT ) const,
612 "GetRounded() -> (x,y)",
613 "Convert to integer");
615 double GetVectorLength() const;
616 double GetVectorAngle() const ;
617 void SetVectorLength( double length );
618 void SetVectorAngle( double degrees );
620 // LinkError: void SetPolarCoordinates( double angle , double length );
621 // LinkError: void Normalize();
623 def SetPolarCoordinates(self, angle, length):
624 self.SetVectorLength(length)
625 self.SetVectorAngle(angle)
627 self.SetVectorLength(1.0)
630 double GetDistance( const wxPoint2D &pt ) const;
631 double GetDistanceSquare( const wxPoint2D &pt ) const;
632 double GetDotProduct( const wxPoint2D &vec ) const;
633 double GetCrossProduct( const wxPoint2D &vec ) const;
636 wxPoint2D, operator-(),
637 "the reflection of this point");
639 wxPoint2D& operator+=(const wxPoint2D& pt);
640 wxPoint2D& operator-=(const wxPoint2D& pt);
642 wxPoint2D& operator*=(const wxPoint2D& pt);
643 wxPoint2D& operator/=(const wxPoint2D& pt);
646 bool, operator==(const wxPoint2D& pt) const,
647 "Test for equality");
650 bool, operator!=(const wxPoint2D& pt) const,
651 "Test for inequality");
657 void Set( double x=0 , double y=0 ) {
664 "Return x and y properties as a tuple.");
666 wxPyBeginBlockThreads();
667 PyObject* tup = PyTuple_New(2);
668 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x));
669 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y));
670 wxPyEndBlockThreads();
677 def __str__(self): return str(self.Get())
678 def __repr__(self): return 'wx.Point2D'+str(self.Get())
679 def __len__(self): return len(self.Get())
680 def __getitem__(self, index): return self.Get()[index]
681 def __setitem__(self, index, val):
682 if index == 0: self.x = val
683 elif index == 1: self.y = val
684 else: raise IndexError
685 def __nonzero__(self): return self.Get() != (0.0, 0.0)
686 __safe_for_unpickling__ = True
687 def __reduce__(self): return (wx.Point2D, self.Get())
692 //---------------------------------------------------------------------------
695 const wxPoint wxDefaultPosition;
696 const wxSize wxDefaultSize;
699 //---------------------------------------------------------------------------