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 //---------------------------------------------------------------------------
116 //int x; // TODO: Can these be removed and just use width and height?
121 wxSize(int w=0, int h=0);
124 bool operator==(const wxSize& sz) const;
125 bool operator!=(const wxSize& sz) const;
127 wxSize operator+(const wxSize& sz);
128 wxSize operator-(const wxSize& sz);
130 void IncTo(const wxSize& sz);
131 void DecTo(const wxSize& sz);
133 void Set(int xx, int yy);
134 void SetWidth(int w);
135 void SetHeight(int h);
136 int GetWidth() const;
137 int GetHeight() const;
143 PyObject* asTuple() {
144 wxPyBeginBlockThreads();
145 PyObject* tup = PyTuple_New(2);
146 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
147 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
148 wxPyEndBlockThreads();
153 def __str__(self): return str(self.asTuple())
154 def __repr__(self): return 'wxSize'+str(self.asTuple())
155 def __len__(self): return len(self.asTuple())
156 def __getitem__(self, index): return self.asTuple()[index]
157 def __setitem__(self, index, val):
158 if index == 0: self.width = val
159 elif index == 1: self.height = val
160 else: raise IndexError
161 def __nonzero__(self): return self.asTuple() != (0,0)
162 def __getinitargs__(self): return ()
163 def __getstate__(self): return self.asTuple()
164 def __setstate__(self, state): self.Set(*state)
169 //---------------------------------------------------------------------------
171 %noautorepr wxRealPoint;
179 wxRealPoint(double x=0.0, double y=0.0);
182 wxRealPoint operator+(const wxRealPoint& pt) const;
183 wxRealPoint operator-(const wxRealPoint& pt) const;
185 bool operator==(const wxRealPoint& pt) const;
186 bool operator!=(const wxRealPoint& pt) const;
189 void Set(double x, double y) {
193 PyObject* asTuple() {
194 wxPyBeginBlockThreads();
195 PyObject* tup = PyTuple_New(2);
196 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
197 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
198 wxPyEndBlockThreads();
204 def __str__(self): return str(self.asTuple())
205 def __repr__(self): return 'wxRealPoint'+str(self.asTuple())
206 def __len__(self): return len(self.asTuple())
207 def __getitem__(self, index): return self.asTuple()[index]
208 def __setitem__(self, index, val):
209 if index == 0: self.width = val
210 elif index == 1: self.height = val
211 else: raise IndexError
212 def __nonzero__(self): return self.asTuple() != (0.0, 0.0)
213 def __getinitargs__(self): return ()
214 def __getstate__(self): return self.asTuple()
215 def __setstate__(self, state): self.Set(*state)
219 //---------------------------------------------------------------------------
228 wxPoint(int x=0, int y=0);
231 bool operator==(const wxPoint& p) const;
232 bool operator!=(const wxPoint& p) const;
234 wxPoint operator+(const wxPoint& p) const;
235 wxPoint operator-(const wxPoint& p) const;
237 wxPoint& operator+=(const wxPoint& p);
238 wxPoint& operator-=(const wxPoint& p);
241 void Set(long x, long y) {
245 PyObject* asTuple() {
246 wxPyBeginBlockThreads();
247 PyObject* tup = PyTuple_New(2);
248 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
249 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
250 wxPyEndBlockThreads();
256 def __str__(self): return str(self.asTuple())
257 def __repr__(self): return 'wxPoint'+str(self.asTuple())
258 def __len__(self): return len(self.asTuple())
259 def __getitem__(self, index): return self.asTuple()[index]
260 def __setitem__(self, index, val):
261 if index == 0: self.x = val
262 elif index == 1: self.y = val
263 else: raise IndexError
264 def __nonzero__(self): return self.asTuple() != (0,0)
265 def __getinitargs__(self): return ()
266 def __getstate__(self): return self.asTuple()
267 def __setstate__(self, state): self.Set(*state)
271 //---------------------------------------------------------------------------
278 wxRect(int x=0, int y=0, int width=0, int height=0);
279 %name(RectPP) wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
280 %name(RectPS) wxRect(const wxPoint& pos, const wxSize& size);
289 int GetWidth() const;
290 void SetWidth(int w);
292 int GetHeight() const;
293 void SetHeight(int h);
295 wxPoint GetPosition() const;
296 void SetPosition( const wxPoint &p );
298 wxSize GetSize() const;
299 void SetSize( const wxSize &s );
303 int GetBottom() const;
304 int GetRight() const;
306 void SetLeft(int left);
307 void SetRight(int right);
308 void SetTop(int top);
309 void SetBottom(int bottom);
311 wxRect& Inflate(wxCoord dx, wxCoord dy);
312 wxRect& Deflate(wxCoord dx, wxCoord dy);
314 %name(OffsetXY)void Offset(wxCoord dx, wxCoord dy);
315 void Offset(const wxPoint& pt);
317 wxRect& Intersect(const wxRect& rect);
319 wxRect operator+(const wxRect& rect) const;
320 wxRect& operator+=(const wxRect& rect);
322 bool operator==(const wxRect& rect) const;
323 bool operator!=(const wxRect& rect) const { return !(*this == rect); }
325 // return TRUE if the point is (not strcitly) inside the rect
326 %name(InsideXY)bool Inside(int x, int y) const;
327 bool Inside(const wxPoint& pt) const;
329 // return TRUE if the rectangles have a non empty intersection
330 bool Intersects(const wxRect& rect) const;
332 int x, y, width, height;
336 void Set(int x=0, int y=0, int width=0, int height=0) {
340 self->height = height;
343 PyObject* asTuple() {
344 wxPyBeginBlockThreads();
345 PyObject* tup = PyTuple_New(4);
346 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
347 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
348 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
349 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
350 wxPyEndBlockThreads();
356 def __str__(self): return str(self.asTuple())
357 def __repr__(self): return 'wxRect'+str(self.asTuple())
358 def __len__(self): return len(self.asTuple())
359 def __getitem__(self, index): return self.asTuple()[index]
360 def __setitem__(self, index, val):
361 if index == 0: self.x = val
362 elif index == 1: self.y = val
363 elif index == 2: self.width = val
364 elif index == 3: self.height = val
365 else: raise IndexError
366 def __nonzero__(self): return self.asTuple() != (0,0,0,0)
367 def __getinitargs__(self): return ()
368 def __getstate__(self): return self.asTuple()
369 def __setstate__(self, state): self.Set(*state)
375 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
378 wxRect dest(0,0,0,0);
381 reg1.Intersect(reg2);
382 dest = reg1.GetBox();
384 if (dest != wxRect(0,0,0,0)) {
385 wxPyBeginBlockThreads();
386 wxRect* newRect = new wxRect(dest);
387 obj = wxPyConstructObject((void*)newRect, wxT("wxRect"), true);
388 wxPyEndBlockThreads();
396 //---------------------------------------------------------------------------
398 %noautorepr wxPoint2D;
400 // wxPoint2Ds represent a point or a vector in a 2d coordinate system
405 wxPoint2D( double x=0.0 , double y=0.0 );
406 %name(Point2DCopy) wxPoint2D( const wxPoint2D &pt );
407 %name(Point2DFromPoint) wxPoint2D( const wxPoint &pt );
409 // two different conversions to integers, floor and rounding
410 void GetFloor( int *OUTPUT , int *OUTPUT ) const;
411 void GetRounded( int *OUTPUT , int *OUTPUT ) const;
413 double GetVectorLength() const;
414 double GetVectorAngle() const ;
415 void SetVectorLength( double length );
416 void SetVectorAngle( double degrees );
417 // LinkError: void SetPolarCoordinates( double angle , double length );
418 // LinkError: void Normalize();
420 def SetPolarCoordinates(self, angle, length):
421 self.SetVectorLength(length)
422 self.SetVectorAngle(angle)
424 self.SetVectorLength(1.0)
427 double GetDistance( const wxPoint2D &pt ) const;
428 double GetDistanceSquare( const wxPoint2D &pt ) const;
429 double GetDotProduct( const wxPoint2D &vec ) const;
430 double GetCrossProduct( const wxPoint2D &vec ) const;
432 // the reflection of this point
433 wxPoint2D operator-();
435 wxPoint2D& operator+=(const wxPoint2D& pt);
436 wxPoint2D& operator-=(const wxPoint2D& pt);
438 wxPoint2D& operator*=(const wxPoint2D& pt);
439 wxPoint2D& operator/=(const wxPoint2D& pt);
441 bool operator==(const wxPoint2D& pt) const;
442 bool operator!=(const wxPoint2D& pt) const;
450 void Set( double x=0 , double y=0 ) {
454 PyObject* asTuple() {
455 wxPyBeginBlockThreads();
456 PyObject* tup = PyTuple_New(2);
457 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x));
458 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y));
459 wxPyEndBlockThreads();
465 def __str__(self): return str(self.asTuple())
466 def __repr__(self): return 'wxPoint2D'+str(self.asTuple())
467 def __len__(self): return len(self.asTuple())
468 def __getitem__(self, index): return self.asTuple()[index]
469 def __setitem__(self, index, val):
470 if index == 0: self.m_x = val
471 elif index == 1: self.m_yt = val
472 else: raise IndexError
473 def __nonzero__(self): return self.asTuple() != (0.0, 0.0)
474 def __getinitargs__(self): return ()
475 def __getstate__(self): return self.asTuple()
476 def __setstate__(self, state): self.Set(*state)
482 //---------------------------------------------------------------------------
485 const wxPoint wxDefaultPosition;
486 const wxSize wxDefaultSize;
489 //---------------------------------------------------------------------------