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!
24 wxBITMAP_TYPE_BMP_RESOURCE,
25 wxBITMAP_TYPE_RESOURCE = wxBITMAP_TYPE_BMP_RESOURCE,
27 wxBITMAP_TYPE_ICO_RESOURCE,
29 wxBITMAP_TYPE_CUR_RESOURCE,
31 wxBITMAP_TYPE_XBM_DATA,
33 wxBITMAP_TYPE_XPM_DATA,
35 wxBITMAP_TYPE_TIF_RESOURCE,
37 wxBITMAP_TYPE_GIF_RESOURCE,
39 wxBITMAP_TYPE_PNG_RESOURCE,
41 wxBITMAP_TYPE_JPEG_RESOURCE,
43 wxBITMAP_TYPE_PNM_RESOURCE,
45 wxBITMAP_TYPE_PCX_RESOURCE,
47 wxBITMAP_TYPE_PICT_RESOURCE,
49 wxBITMAP_TYPE_ICON_RESOURCE,
52 wxBITMAP_TYPE_MACCURSOR,
53 wxBITMAP_TYPE_MACCURSOR_RESOURCE,
54 wxBITMAP_TYPE_ANY = 50
60 wxCURSOR_NONE, // should be 0
70 wxCURSOR_MIDDLE_BUTTON,
76 wxCURSOR_QUESTION_ARROW,
77 wxCURSOR_RIGHT_BUTTON,
87 wxCURSOR_DEFAULT, // standard X11 cursor
88 wxCURSOR_COPY_ARROW , // MacOS Theme Plus arrow
91 // // Not yet implemented for Windows
92 // wxCURSOR_CROSS_REVERSE,
93 // wxCURSOR_DOUBLE_ARROW,
94 // wxCURSOR_BASED_ARROW_UP,
95 // wxCURSOR_BASED_ARROW_DOWN,
105 #define wxCURSOR_COPY_ARROW wxCURSOR_ARROW
109 //---------------------------------------------------------------------------
113 "wx.Size is a useful data structure used to represent the size of something.
114 It simply contians integer width and height proprtites. In most places in
115 wxPython where a wx.Size is expected a (width,height) tuple can be used
125 wxSize(int w=0, int h=0),
126 "Creates a size object.");
131 bool, operator==(const wxSize& sz),
132 "Test for equality of wx.Size objects.");
135 bool, operator!=(const wxSize& sz),
136 "Test for inequality.");
139 wxSize, operator+(const wxSize& sz),
140 "Add sz's proprties to this and return the result.");
143 wxSize, operator-(const wxSize& sz),
144 "Subtract sz's properties from this and return the result.");
147 void, IncTo(const wxSize& sz),
148 "Increments this object so that both of its dimensions are not less\n"
149 "than the corresponding dimensions of the size.");
152 void, DecTo(const wxSize& sz),
153 "Decrements this object so that both of its dimensions are not greater\n"
154 "than the corresponding dimensions of the size.");
157 void, Set(int w, int h),
158 "Set both width and height.");
160 void SetWidth(int w);
161 void SetHeight(int h);
162 int GetWidth() const;
163 int GetHeight() const;
170 "Get() -> (width,height)",
171 "Returns the width and height properties as a tuple.");
173 wxPyBeginBlockThreads();
174 PyObject* tup = PyTuple_New(2);
175 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
176 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
177 wxPyEndBlockThreads();
183 def __str__(self): return str(self.Get())
184 def __repr__(self): return 'wx.Size'+str(self.Get())
185 def __len__(self): return len(self.Get())
186 def __getitem__(self, index): return self.Get()[index]
187 def __setitem__(self, index, val):
188 if index == 0: self.width = val
189 elif index == 1: self.height = val
190 else: raise IndexError
191 def __nonzero__(self): return self.Get() != (0,0)
192 def __getinitargs__(self): return ()
193 def __getstate__(self): return self.Get()
194 def __setstate__(self, state): self.Set(*state)
199 //---------------------------------------------------------------------------
203 "A data structure for representing a point or position with floating point x
204 and y properties. In wxPython most places that expect a wx.RealPoint can also
205 accept a (x,y) tuple.");
213 wxRealPoint(double x=0.0, double y=0.0),
214 "Create a wx.RealPoint object");
219 bool, operator==(const wxRealPoint& pt),
220 "Test for equality of wx.RealPoint objects.");
223 bool, operator!=(const wxRealPoint& pt),
224 "Test for inequality of wx.RealPoint objects.");
228 wxRealPoint, operator+(const wxRealPoint& pt),
229 "Add pt's proprties to this and return the result.");
232 wxRealPoint, operator-(const wxRealPoint& pt),
233 "Subtract pt's proprties from this and return the result");
237 DocStr(Set, "Set both the x and y properties");
238 void Set(double x, double y) {
245 "Return the x and y properties as a tuple. ");
247 wxPyBeginBlockThreads();
248 PyObject* tup = PyTuple_New(2);
249 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
250 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
251 wxPyEndBlockThreads();
258 def __str__(self): return str(self.Get())
259 def __repr__(self): return 'wx.RealPoint'+str(self.Get())
260 def __len__(self): return len(self.Get())
261 def __getitem__(self, index): return self.Get()[index]
262 def __setitem__(self, index, val):
263 if index == 0: self.x = val
264 elif index == 1: self.y = val
265 else: raise IndexError
266 def __nonzero__(self): return self.Get() != (0.0, 0.0)
267 def __getinitargs__(self): return ()
268 def __getstate__(self): return self.Get()
269 def __setstate__(self, state): self.Set(*state)
274 //---------------------------------------------------------------------------
279 "A data structure for representing a point or position with integer x and y
280 properties. Most places in wxPython that expect a wx.Point can also accept a
289 wxPoint(int x=0, int y=0),
290 "Create a wx.Point object");
296 bool, operator==(const wxPoint& pt),
297 "Test for equality of wx.Point objects.");
300 bool, operator!=(const wxPoint& pt),
301 "Test for inequality of wx.Point objects.");
305 wxPoint, operator+(const wxPoint& pt),
306 "Add pt's proprties to this and return the result.");
309 wxPoint, operator-(const wxPoint& pt),
310 "Subtract pt's proprties from this and return the result");
314 wxPoint&, operator+=(const wxPoint& pt),
315 "Add pt to this object.");
318 wxPoint&, operator-=(const wxPoint& pt),
319 "Subtract pt from this object.");
323 DocStr(Set, "Set both the x and y properties");
324 void Set(long x, long y) {
331 "Return the x and y properties as a tuple. ");
333 wxPyBeginBlockThreads();
334 PyObject* tup = PyTuple_New(2);
335 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
336 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
337 wxPyEndBlockThreads();
344 def __str__(self): return str(self.Get())
345 def __repr__(self): return 'wx.Point'+str(self.Get())
346 def __len__(self): return len(self.Get())
347 def __getitem__(self, index): return self.Get()[index]
348 def __setitem__(self, index, val):
349 if index == 0: self.x = val
350 elif index == 1: self.y = val
351 else: raise IndexError
352 def __nonzero__(self): return self.Get() != (0,0)
353 def __getinitargs__(self): return ()
354 def __getstate__(self): return self.Get()
355 def __setstate__(self, state): self.Set(*state)
359 //---------------------------------------------------------------------------
364 "A class for representing and manipulating rectangles. It has x, y, width and
365 height properties. In wxPython most palces that expect a wx.Rect can also
366 accept a (x,y,width,height) tuple.");
372 wxRect(int x=0, int y=0, int width=0, int height=0),
373 "Create a new Rect object.");
376 wxRect(const wxPoint& topLeft, const wxPoint& bottomRight),
377 "Create a new Rect object from Points representing two corners.",
381 wxRect(const wxPoint& pos, const wxSize& size),
382 "Create a new Rect from a position and size.",
393 int GetWidth() const;
394 void SetWidth(int w);
396 int GetHeight() const;
397 void SetHeight(int h);
399 wxPoint GetPosition() const;
400 void SetPosition( const wxPoint &p );
402 wxSize GetSize() const;
403 void SetSize( const wxSize &s );
407 int GetBottom() const;
408 int GetRight() const;
410 void SetLeft(int left);
411 void SetRight(int right);
412 void SetTop(int top);
413 void SetBottom(int bottom);
416 position = property(GetPosition, SetPosition)
417 size = property(GetSize, SetSize)
418 left = property(GetLeft, SetLeft)
419 right = property(GetRight, SetRight)
420 top = property(GetTop, SetTop)
421 bottom = property(GetBottom, SetBottom)
425 wxRect&, Inflate(wxCoord dx, wxCoord dy),
426 "Increase the rectangle size by dx in x direction and dy in y direction. Both\n"
427 "(or one of) parameters may be negative to decrease the rectangle size.");
430 wxRect&, Deflate(wxCoord dx, wxCoord dy),
431 "Decrease the rectangle size by dx in x direction and dy in y direction. Both\n"
432 "(or one of) parameters may be negative to increase the rectngle size. This\n"
433 "method is the opposite of Inflate.");
436 void, Offset(wxCoord dx, wxCoord dy),
437 "Moves the rectangle by the specified offset. If dx is positive, the rectangle\n"
438 "is moved to the right, if dy is positive, it is moved to the bottom, otherwise\n"
439 "it is moved to the left or top respectively.",
443 void, Offset(const wxPoint& pt),
444 "Same as OffsetXY but uses dx,dy from Point");
447 wxRect&, Intersect(const wxRect& rect),
448 "Return the intersectsion of this rectangle and rect.");
451 wxRect, operator+(const wxRect& rect) const,
452 "Add the properties of rect to this rectangle and return the result.");
455 wxRect&, operator+=(const wxRect& rect),
456 "Add the properties of rect to this rectangle, updating this rectangle.");
459 bool, operator==(const wxRect& rect) const,
460 "Test for equality.");
463 bool, operator!=(const wxRect& rect) const,
464 "Test for inequality.");
467 DocStr( Inside, "Return True if the point is (not strcitly) inside the rect.");
468 %name(InsideXY)bool Inside(int x, int y) const;
469 bool Inside(const wxPoint& pt) const;
472 bool, Intersects(const wxRect& rect) const,
473 "Returns True if the rectangles have a non empty intersection.");
476 int x, y, width, height;
480 DocStr(Set, "Set all rectangle properties.");
481 void Set(int x=0, int y=0, int width=0, int height=0) {
485 self->height = height;
489 "Get() -> (x,y,width,height)",
490 "Return the rectangle properties as a tuple.");
492 wxPyBeginBlockThreads();
493 PyObject* tup = PyTuple_New(4);
494 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
495 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
496 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
497 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
498 wxPyEndBlockThreads();
505 def __str__(self): return str(self.Get())
506 def __repr__(self): return 'wx.Rect'+str(self.Get())
507 def __len__(self): return len(self.Get())
508 def __getitem__(self, index): return self.Get()[index]
509 def __setitem__(self, index, val):
510 if index == 0: self.x = val
511 elif index == 1: self.y = val
512 elif index == 2: self.width = val
513 elif index == 3: self.height = val
514 else: raise IndexError
515 def __nonzero__(self): return self.Get() != (0,0,0,0)
516 def __getinitargs__(self): return ()
517 def __getstate__(self): return self.Get()
518 def __setstate__(self, state): self.Set(*state)
523 DocAStr(wxIntersectRect,
524 "IntersectRect(Rect r1, Rect r2) -> Rect",
525 "Calculate and return the intersection of r1 and r2.");
527 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
530 wxRect dest(0,0,0,0);
533 reg1.Intersect(reg2);
534 dest = reg1.GetBox();
536 if (dest != wxRect(0,0,0,0)) {
537 wxPyBeginBlockThreads();
538 wxRect* newRect = new wxRect(dest);
539 obj = wxPyConstructObject((void*)newRect, wxT("wxRect"), True);
540 wxPyEndBlockThreads();
548 //---------------------------------------------------------------------------
553 "wx.Point2Ds represent a point or a vector in a 2d coordinate system with floating point values.");
558 DocStr(wxPoint2D, "Create a w.Point2D object.");
559 wxPoint2D( double x=0.0 , double y=0.0 );
560 %name(Point2DCopy) wxPoint2D( const wxPoint2D &pt );
561 %name(Point2DFromPoint) wxPoint2D( const wxPoint &pt );
564 void, GetFloor( int *OUTPUT , int *OUTPUT ) const,
565 "GetFloor() -> (x,y)",
566 "Convert to integer");
569 void, GetRounded( int *OUTPUT , int *OUTPUT ) const,
570 "GetRounded() -> (x,y)",
571 "Convert to integer");
573 double GetVectorLength() const;
574 double GetVectorAngle() const ;
575 void SetVectorLength( double length );
576 void SetVectorAngle( double degrees );
578 // LinkError: void SetPolarCoordinates( double angle , double length );
579 // LinkError: void Normalize();
581 def SetPolarCoordinates(self, angle, length):
582 self.SetVectorLength(length)
583 self.SetVectorAngle(angle)
585 self.SetVectorLength(1.0)
588 double GetDistance( const wxPoint2D &pt ) const;
589 double GetDistanceSquare( const wxPoint2D &pt ) const;
590 double GetDotProduct( const wxPoint2D &vec ) const;
591 double GetCrossProduct( const wxPoint2D &vec ) const;
594 wxPoint2D, operator-(),
595 "the reflection of this point");
597 wxPoint2D& operator+=(const wxPoint2D& pt);
598 wxPoint2D& operator-=(const wxPoint2D& pt);
600 wxPoint2D& operator*=(const wxPoint2D& pt);
601 wxPoint2D& operator/=(const wxPoint2D& pt);
604 bool, operator==(const wxPoint2D& pt) const,
605 "Test for equality");
608 bool, operator!=(const wxPoint2D& pt) const,
609 "Test for inequality");
615 void Set( double x=0 , double y=0 ) {
622 "Return x and y properties as a tuple.");
624 wxPyBeginBlockThreads();
625 PyObject* tup = PyTuple_New(2);
626 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x));
627 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y));
628 wxPyEndBlockThreads();
635 def __str__(self): return str(self.Get())
636 def __repr__(self): return 'wx.Point2D'+str(self.Get())
637 def __len__(self): return len(self.Get())
638 def __getitem__(self, index): return self.Get()[index]
639 def __setitem__(self, index, val):
640 if index == 0: self.x = val
641 elif index == 1: self.y = val
642 else: raise IndexError
643 def __nonzero__(self): return self.Get() != (0.0, 0.0)
644 def __getinitargs__(self): return ()
645 def __getstate__(self): return self.Get()
646 def __setstate__(self, state): self.Set(*state)
652 //---------------------------------------------------------------------------
655 const wxPoint wxDefaultPosition;
656 const wxSize wxDefaultSize;
659 //---------------------------------------------------------------------------