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 //---------------------------------------------------------------------------
115 //int x; // TODO: Can these be removed and just use width and height?
120 wxSize(int w=0, int h=0);
123 bool operator==(const wxSize& sz) const;
124 bool operator!=(const wxSize& sz) const;
126 wxSize operator+(const wxSize& sz);
127 wxSize operator-(const wxSize& sz);
129 void IncTo(const wxSize& sz);
130 void DecTo(const wxSize& sz);
132 void Set(int xx, int yy);
133 void SetWidth(int w);
134 void SetHeight(int h);
135 int GetWidth() const;
136 int GetHeight() const;
142 PyObject* asTuple() {
143 wxPyBeginBlockThreads();
144 PyObject* tup = PyTuple_New(2);
145 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
146 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
147 wxPyEndBlockThreads();
152 def __str__(self): return str(self.asTuple())
153 def __repr__(self): return 'wxSize'+str(self.asTuple())
154 def __len__(self): return len(self.asTuple())
155 def __getitem__(self, index): return self.asTuple()[index]
156 def __setitem__(self, index, val):
157 if index == 0: self.width = val
158 elif index == 1: self.height = val
159 else: raise IndexError
160 def __nonzero__(self): return self.asTuple() != (0,0)
161 def __getinitargs__(self): return ()
162 def __getstate__(self): return self.asTuple()
163 def __setstate__(self, state): self.Set(*state)
168 //---------------------------------------------------------------------------
178 wxRealPoint(double x=0.0, double y=0.0);
181 wxRealPoint operator+(const wxRealPoint& pt) const;
182 wxRealPoint operator-(const wxRealPoint& pt) const;
184 bool operator==(const wxRealPoint& pt) const;
185 bool operator!=(const wxRealPoint& pt) const;
188 void Set(double x, double y) {
192 PyObject* asTuple() {
193 wxPyBeginBlockThreads();
194 PyObject* tup = PyTuple_New(2);
195 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
196 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
197 wxPyEndBlockThreads();
203 def __str__(self): return str(self.asTuple())
204 def __repr__(self): return 'wxRealPoint'+str(self.asTuple())
205 def __len__(self): return len(self.asTuple())
206 def __getitem__(self, index): return self.asTuple()[index]
207 def __setitem__(self, index, val):
208 if index == 0: self.width = val
209 elif index == 1: self.height = val
210 else: raise IndexError
211 def __nonzero__(self): return self.asTuple() != (0.0, 0.0)
212 def __getinitargs__(self): return ()
213 def __getstate__(self): return self.asTuple()
214 def __setstate__(self, state): self.Set(*state)
218 //---------------------------------------------------------------------------
227 wxPoint(int x=0, int y=0);
230 bool operator==(const wxPoint& p) const;
231 bool operator!=(const wxPoint& p) const;
233 wxPoint operator+(const wxPoint& p) const;
234 wxPoint operator-(const wxPoint& p) const;
236 wxPoint& operator+=(const wxPoint& p);
237 wxPoint& operator-=(const wxPoint& p);
240 void Set(long x, long y) {
244 PyObject* asTuple() {
245 wxPyBeginBlockThreads();
246 PyObject* tup = PyTuple_New(2);
247 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
248 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
249 wxPyEndBlockThreads();
255 def __str__(self): return str(self.asTuple())
256 def __repr__(self): return 'wxPoint'+str(self.asTuple())
257 def __len__(self): return len(self.asTuple())
258 def __getitem__(self, index): return self.asTuple()[index]
259 def __setitem__(self, index, val):
260 if index == 0: self.x = val
261 elif index == 1: self.y = val
262 else: raise IndexError
263 def __nonzero__(self): return self.asTuple() != (0,0)
264 def __getinitargs__(self): return ()
265 def __getstate__(self): return self.asTuple()
266 def __setstate__(self, state): self.Set(*state)
270 //---------------------------------------------------------------------------
277 wxRect(int x=0, int y=0, int width=0, int height=0);
278 %name(RectPP) wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
279 %name(RectPS) wxRect(const wxPoint& pos, const wxSize& size);
288 int GetWidth() const;
289 void SetWidth(int w);
291 int GetHeight() const;
292 void SetHeight(int h);
294 wxPoint GetPosition() const;
295 void SetPosition( const wxPoint &p );
297 wxSize GetSize() const;
298 void SetSize( const wxSize &s );
302 int GetBottom() const;
303 int GetRight() const;
305 void SetLeft(int left);
306 void SetRight(int right);
307 void SetTop(int top);
308 void SetBottom(int bottom);
310 wxRect& Inflate(wxCoord dx, wxCoord dy);
311 wxRect& Deflate(wxCoord dx, wxCoord dy);
313 %name(OffsetXY)void Offset(wxCoord dx, wxCoord dy);
314 void Offset(const wxPoint& pt);
316 wxRect& Intersect(const wxRect& rect);
318 wxRect operator+(const wxRect& rect) const;
319 wxRect& operator+=(const wxRect& rect);
321 bool operator==(const wxRect& rect) const;
322 bool operator!=(const wxRect& rect) const { return !(*this == rect); }
324 // return TRUE if the point is (not strcitly) inside the rect
325 %name(InsideXY)bool Inside(int x, int y) const;
326 bool Inside(const wxPoint& pt) const;
328 // return TRUE if the rectangles have a non empty intersection
329 bool Intersects(const wxRect& rect) const;
331 int x, y, width, height;
335 void Set(int x=0, int y=0, int width=0, int height=0) {
339 self->height = height;
342 PyObject* asTuple() {
343 wxPyBeginBlockThreads();
344 PyObject* tup = PyTuple_New(4);
345 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
346 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
347 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
348 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
349 wxPyEndBlockThreads();
355 def __str__(self): return str(self.asTuple())
356 def __repr__(self): return 'wxRect'+str(self.asTuple())
357 def __len__(self): return len(self.asTuple())
358 def __getitem__(self, index): return self.asTuple()[index]
359 def __setitem__(self, index, val):
360 if index == 0: self.x = val
361 elif index == 1: self.y = val
362 elif index == 2: self.width = val
363 elif index == 3: self.height = val
364 else: raise IndexError
365 def __nonzero__(self): return self.asTuple() != (0,0,0,0)
366 def __getinitargs__(self): return ()
367 def __getstate__(self): return self.asTuple()
368 def __setstate__(self, state): self.Set(*state)
374 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
377 wxRect dest(0,0,0,0);
380 reg1.Intersect(reg2);
381 dest = reg1.GetBox();
383 if (dest != wxRect(0,0,0,0)) {
384 wxPyBeginBlockThreads();
385 wxRect* newRect = new wxRect(dest);
386 obj = wxPyConstructObject((void*)newRect, wxT("wxRect"), true);
387 wxPyEndBlockThreads();
395 //---------------------------------------------------------------------------
399 // wxPoint2Ds represent a point or a vector in a 2d coordinate system
404 wxPoint2D( double x=0.0 , double y=0.0 );
405 %name(Point2DCopy) wxPoint2D( const wxPoint2D &pt );
406 %name(Point2DFromPoint) wxPoint2D( const wxPoint &pt );
408 // two different conversions to integers, floor and rounding
409 void GetFloor( int *OUTPUT , int *OUTPUT ) const;
410 void GetRounded( int *OUTPUT , int *OUTPUT ) const;
412 double GetVectorLength() const;
413 double GetVectorAngle() const ;
414 void SetVectorLength( double length );
415 void SetVectorAngle( double degrees );
416 // LinkError: void SetPolarCoordinates( double angle , double length );
417 // LinkError: void Normalize();
419 def SetPolarCoordinates(self, angle, length):
420 self.SetVectorLength(length)
421 self.SetVectorAngle(angle)
423 self.SetVectorLength(1.0)
426 double GetDistance( const wxPoint2D &pt ) const;
427 double GetDistanceSquare( const wxPoint2D &pt ) const;
428 double GetDotProduct( const wxPoint2D &vec ) const;
429 double GetCrossProduct( const wxPoint2D &vec ) const;
431 // the reflection of this point
432 wxPoint2D operator-();
434 wxPoint2D& operator+=(const wxPoint2D& pt);
435 wxPoint2D& operator-=(const wxPoint2D& pt);
437 wxPoint2D& operator*=(const wxPoint2D& pt);
438 wxPoint2D& operator/=(const wxPoint2D& pt);
440 bool operator==(const wxPoint2D& pt) const;
441 bool operator!=(const wxPoint2D& pt) const;
449 void Set( double x=0 , double y=0 ) {
453 PyObject* asTuple() {
454 wxPyBeginBlockThreads();
455 PyObject* tup = PyTuple_New(2);
456 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x));
457 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y));
458 wxPyEndBlockThreads();
464 def __str__(self): return str(self.asTuple())
465 def __repr__(self): return 'wxPoint2D'+str(self.asTuple())
466 def __len__(self): return len(self.asTuple())
467 def __getitem__(self, index): return self.asTuple()[index]
468 def __setitem__(self, index, val):
469 if index == 0: self.m_x = val
470 elif index == 1: self.m_yt = val
471 else: raise IndexError
472 def __nonzero__(self): return self.asTuple() != (0.0, 0.0)
473 def __getinitargs__(self): return ()
474 def __getstate__(self): return self.asTuple()
475 def __setstate__(self, state): self.Set(*state)
481 //---------------------------------------------------------------------------
484 const wxPoint wxDefaultPosition;
485 const wxSize wxDefaultSize;
488 //---------------------------------------------------------------------------