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
123 %pythoncode { x = width; y = height }
126 wxSize(int w=0, int h=0),
127 "Creates a size object.");
132 bool, operator==(const wxSize& sz),
133 "Test for equality of wx.Size objects.");
136 bool, operator!=(const wxSize& sz),
137 "Test for inequality.");
140 wxSize, operator+(const wxSize& sz),
141 "Add sz's proprties to this and return the result.");
144 wxSize, operator-(const wxSize& sz),
145 "Subtract sz's properties from this and return the result.");
148 void, IncTo(const wxSize& sz),
149 "Increments this object so that both of its dimensions are not less\n"
150 "than the corresponding dimensions of the size.");
153 void, DecTo(const wxSize& sz),
154 "Decrements this object so that both of its dimensions are not greater\n"
155 "than the corresponding dimensions of the size.");
158 void, Set(int w, int h),
159 "Set both width and height.");
161 void SetWidth(int w);
162 void SetHeight(int h);
163 int GetWidth() const;
164 int GetHeight() const;
171 "Get() -> (width,height)",
172 "Returns the width and height properties as a tuple.");
174 wxPyBeginBlockThreads();
175 PyObject* tup = PyTuple_New(2);
176 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
177 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
178 wxPyEndBlockThreads();
184 def __str__(self): return str(self.Get())
185 def __repr__(self): return 'wx.Size'+str(self.Get())
186 def __len__(self): return len(self.Get())
187 def __getitem__(self, index): return self.Get()[index]
188 def __setitem__(self, index, val):
189 if index == 0: self.width = val
190 elif index == 1: self.height = val
191 else: raise IndexError
192 def __nonzero__(self): return self.Get() != (0,0)
193 def __getinitargs__(self): return ()
194 def __getstate__(self): return self.Get()
195 def __setstate__(self, state): self.Set(*state)
200 //---------------------------------------------------------------------------
204 "A data structure for representing a point or position with floating point x
205 and y properties. In wxPython most places that expect a wx.RealPoint can also
206 accept a (x,y) tuple.");
214 wxRealPoint(double x=0.0, double y=0.0),
215 "Create a wx.RealPoint object");
220 bool, operator==(const wxRealPoint& pt),
221 "Test for equality of wx.RealPoint objects.");
224 bool, operator!=(const wxRealPoint& pt),
225 "Test for inequality of wx.RealPoint objects.");
229 wxRealPoint, operator+(const wxRealPoint& pt),
230 "Add pt's proprties to this and return the result.");
233 wxRealPoint, operator-(const wxRealPoint& pt),
234 "Subtract pt's proprties from this and return the result");
238 DocStr(Set, "Set both the x and y properties");
239 void Set(double x, double y) {
246 "Return the x and y properties as a tuple. ");
248 wxPyBeginBlockThreads();
249 PyObject* tup = PyTuple_New(2);
250 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
251 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
252 wxPyEndBlockThreads();
259 def __str__(self): return str(self.Get())
260 def __repr__(self): return 'wx.RealPoint'+str(self.Get())
261 def __len__(self): return len(self.Get())
262 def __getitem__(self, index): return self.Get()[index]
263 def __setitem__(self, index, val):
264 if index == 0: self.x = val
265 elif index == 1: self.y = val
266 else: raise IndexError
267 def __nonzero__(self): return self.Get() != (0.0, 0.0)
268 def __getinitargs__(self): return ()
269 def __getstate__(self): return self.Get()
270 def __setstate__(self, state): self.Set(*state)
275 //---------------------------------------------------------------------------
280 "A data structure for representing a point or position with integer x and y
281 properties. Most places in wxPython that expect a wx.Point can also accept a
290 wxPoint(int x=0, int y=0),
291 "Create a wx.Point object");
297 bool, operator==(const wxPoint& pt),
298 "Test for equality of wx.Point objects.");
301 bool, operator!=(const wxPoint& pt),
302 "Test for inequality of wx.Point objects.");
306 wxPoint, operator+(const wxPoint& pt),
307 "Add pt's proprties to this and return the result.");
310 wxPoint, operator-(const wxPoint& pt),
311 "Subtract pt's proprties from this and return the result");
315 wxPoint&, operator+=(const wxPoint& pt),
316 "Add pt to this object.");
319 wxPoint&, operator-=(const wxPoint& pt),
320 "Subtract pt from this object.");
324 DocStr(Set, "Set both the x and y properties");
325 void Set(long x, long y) {
332 "Return the x and y properties as a tuple. ");
334 wxPyBeginBlockThreads();
335 PyObject* tup = PyTuple_New(2);
336 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
337 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
338 wxPyEndBlockThreads();
345 def __str__(self): return str(self.Get())
346 def __repr__(self): return 'wx.Point'+str(self.Get())
347 def __len__(self): return len(self.Get())
348 def __getitem__(self, index): return self.Get()[index]
349 def __setitem__(self, index, val):
350 if index == 0: self.x = val
351 elif index == 1: self.y = val
352 else: raise IndexError
353 def __nonzero__(self): return self.Get() != (0,0)
354 def __getinitargs__(self): return ()
355 def __getstate__(self): return self.Get()
356 def __setstate__(self, state): self.Set(*state)
360 //---------------------------------------------------------------------------
365 "A class for representing and manipulating rectangles. It has x, y, width and
366 height properties. In wxPython most palces that expect a wx.Rect can also
367 accept a (x,y,width,height) tuple.");
373 wxRect(int x=0, int y=0, int width=0, int height=0),
374 "Create a new Rect object.");
377 wxRect(const wxPoint& topLeft, const wxPoint& bottomRight),
378 "Create a new Rect object from Points representing two corners.",
382 wxRect(const wxPoint& pos, const wxSize& size),
383 "Create a new Rect from a position and size.",
394 int GetWidth() const;
395 void SetWidth(int w);
397 int GetHeight() const;
398 void SetHeight(int h);
400 wxPoint GetPosition() const;
401 void SetPosition( const wxPoint &p );
403 wxSize GetSize() const;
404 void SetSize( const wxSize &s );
406 wxPoint GetTopLeft() const;
407 void SetTopLeft(const wxPoint &p);
408 wxPoint GetBottomRight() const;
409 void SetBottomRight(const wxPoint &p);
411 // wxPoint GetLeftTop() const;
412 // void SetLeftTop(const wxPoint &p);
413 // wxPoint GetRightBottom() const;
414 // void SetRightBottom(const wxPoint &p);
418 int GetBottom() const;
419 int GetRight() const;
421 void SetLeft(int left);
422 void SetRight(int right);
423 void SetTop(int top);
424 void SetBottom(int bottom);
427 position = property(GetPosition, SetPosition)
428 size = property(GetSize, SetSize)
429 left = property(GetLeft, SetLeft)
430 right = property(GetRight, SetRight)
431 top = property(GetTop, SetTop)
432 bottom = property(GetBottom, SetBottom)
436 wxRect&, Inflate(wxCoord dx, wxCoord dy),
437 "Increase the rectangle size by dx in x direction and dy in y direction. Both\n"
438 "(or one of) parameters may be negative to decrease the rectangle size.");
441 wxRect&, Deflate(wxCoord dx, wxCoord dy),
442 "Decrease the rectangle size by dx in x direction and dy in y direction. Both\n"
443 "(or one of) parameters may be negative to increase the rectngle size. This\n"
444 "method is the opposite of Inflate.");
447 void, Offset(wxCoord dx, wxCoord dy),
448 "Moves the rectangle by the specified offset. If dx is positive, the rectangle\n"
449 "is moved to the right, if dy is positive, it is moved to the bottom, otherwise\n"
450 "it is moved to the left or top respectively.",
454 void, Offset(const wxPoint& pt),
455 "Same as OffsetXY but uses dx,dy from Point");
458 wxRect&, Intersect(const wxRect& rect),
459 "Return the intersectsion of this rectangle and rect.");
462 wxRect, operator+(const wxRect& rect) const,
463 "Add the properties of rect to this rectangle and return the result.");
466 wxRect&, operator+=(const wxRect& rect),
467 "Add the properties of rect to this rectangle, updating this rectangle.");
470 bool, operator==(const wxRect& rect) const,
471 "Test for equality.");
474 bool, operator!=(const wxRect& rect) const,
475 "Test for inequality.");
478 DocStr( Inside, "Return True if the point is (not strcitly) inside the rect.");
479 %name(InsideXY)bool Inside(int x, int y) const;
480 bool Inside(const wxPoint& pt) const;
483 bool, Intersects(const wxRect& rect) const,
484 "Returns True if the rectangles have a non empty intersection.");
487 int x, y, width, height;
491 DocStr(Set, "Set all rectangle properties.");
492 void Set(int x=0, int y=0, int width=0, int height=0) {
496 self->height = height;
500 "Get() -> (x,y,width,height)",
501 "Return the rectangle properties as a tuple.");
503 wxPyBeginBlockThreads();
504 PyObject* tup = PyTuple_New(4);
505 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
506 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
507 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
508 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
509 wxPyEndBlockThreads();
516 def __str__(self): return str(self.Get())
517 def __repr__(self): return 'wx.Rect'+str(self.Get())
518 def __len__(self): return len(self.Get())
519 def __getitem__(self, index): return self.Get()[index]
520 def __setitem__(self, index, val):
521 if index == 0: self.x = val
522 elif index == 1: self.y = val
523 elif index == 2: self.width = val
524 elif index == 3: self.height = val
525 else: raise IndexError
526 def __nonzero__(self): return self.Get() != (0,0,0,0)
527 def __getinitargs__(self): return ()
528 def __getstate__(self): return self.Get()
529 def __setstate__(self, state): self.Set(*state)
534 DocAStr(wxIntersectRect,
535 "IntersectRect(Rect r1, Rect r2) -> Rect",
536 "Calculate and return the intersection of r1 and r2.");
538 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
541 wxRect dest(0,0,0,0);
544 reg1.Intersect(reg2);
545 dest = reg1.GetBox();
547 if (dest != wxRect(0,0,0,0)) {
548 wxPyBeginBlockThreads();
549 wxRect* newRect = new wxRect(dest);
550 obj = wxPyConstructObject((void*)newRect, wxT("wxRect"), True);
551 wxPyEndBlockThreads();
559 //---------------------------------------------------------------------------
564 "wx.Point2Ds represent a point or a vector in a 2d coordinate system with floating point values.");
569 DocStr(wxPoint2D, "Create a w.Point2D object.");
570 wxPoint2D( double x=0.0 , double y=0.0 );
571 %name(Point2DCopy) wxPoint2D( const wxPoint2D &pt );
572 %name(Point2DFromPoint) wxPoint2D( const wxPoint &pt );
575 void, GetFloor( int *OUTPUT , int *OUTPUT ) const,
576 "GetFloor() -> (x,y)",
577 "Convert to integer");
580 void, GetRounded( int *OUTPUT , int *OUTPUT ) const,
581 "GetRounded() -> (x,y)",
582 "Convert to integer");
584 double GetVectorLength() const;
585 double GetVectorAngle() const ;
586 void SetVectorLength( double length );
587 void SetVectorAngle( double degrees );
589 // LinkError: void SetPolarCoordinates( double angle , double length );
590 // LinkError: void Normalize();
592 def SetPolarCoordinates(self, angle, length):
593 self.SetVectorLength(length)
594 self.SetVectorAngle(angle)
596 self.SetVectorLength(1.0)
599 double GetDistance( const wxPoint2D &pt ) const;
600 double GetDistanceSquare( const wxPoint2D &pt ) const;
601 double GetDotProduct( const wxPoint2D &vec ) const;
602 double GetCrossProduct( const wxPoint2D &vec ) const;
605 wxPoint2D, operator-(),
606 "the reflection of this point");
608 wxPoint2D& operator+=(const wxPoint2D& pt);
609 wxPoint2D& operator-=(const wxPoint2D& pt);
611 wxPoint2D& operator*=(const wxPoint2D& pt);
612 wxPoint2D& operator/=(const wxPoint2D& pt);
615 bool, operator==(const wxPoint2D& pt) const,
616 "Test for equality");
619 bool, operator!=(const wxPoint2D& pt) const,
620 "Test for inequality");
626 void Set( double x=0 , double y=0 ) {
633 "Return x and y properties as a tuple.");
635 wxPyBeginBlockThreads();
636 PyObject* tup = PyTuple_New(2);
637 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x));
638 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y));
639 wxPyEndBlockThreads();
646 def __str__(self): return str(self.Get())
647 def __repr__(self): return 'wx.Point2D'+str(self.Get())
648 def __len__(self): return len(self.Get())
649 def __getitem__(self, index): return self.Get()[index]
650 def __setitem__(self, index, val):
651 if index == 0: self.x = val
652 elif index == 1: self.y = val
653 else: raise IndexError
654 def __nonzero__(self): return self.Get() != (0.0, 0.0)
655 def __getinitargs__(self): return ()
656 def __getstate__(self): return self.Get()
657 def __setstate__(self, state): self.Set(*state)
663 //---------------------------------------------------------------------------
666 const wxPoint wxDefaultPosition;
667 const wxSize wxDefaultSize;
670 //---------------------------------------------------------------------------