1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Definitions of miscelaneous functions and classes
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
17 #include <wx/resource.h>
18 #include <wx/tooltip.h>
19 #include <wx/busyinfo.h>
22 //----------------------------------------------------------------------
25 %include my_typemaps.i
27 // Import some definitions of other classes, etc.
31 //---------------------------------------------------------------------------
38 wxString GetClassName() {
39 return self->GetClassInfo()->GetClassName();
48 //---------------------------------------------------------------------------
57 wxSize(long w=0, long h=0);
59 void Set(long w, long h);
64 void SetWidth(long w);
65 void SetHeight(long h);
69 PyObject* tup = PyTuple_New(2);
70 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
71 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
75 int __cmp__(const wxSize* sz) {
77 if (*self == *sz) return 0;
82 %pragma(python) addtoclass = "
83 def __str__(self): return str(self.asTuple())
84 def __repr__(self): return str(self.asTuple())
85 def __len__(self): return len(self.asTuple())
86 def __getitem__(self, index): return self.asTuple()[index]
87 def __setitem__(self, index, val):
88 if index == 0: self.width = val
89 elif index == 1: self.height = val
90 else: raise IndexError
95 //---------------------------------------------------------------------------
101 wxRealPoint(double x=0.0, double y=0.0);
105 void Set(double x, double y) {
109 PyObject* asTuple() {
110 PyObject* tup = PyTuple_New(2);
111 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
112 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
116 wxRealPoint __add__(const wxRealPoint* p) {
117 if (! p) return *self;
121 wxRealPoint __sub__(const wxRealPoint* p) {
122 if (! p) return *self;
126 int __cmp__(const wxRealPoint* p) {
128 if (*self == *p) return 0;
132 %pragma(python) addtoclass = "
133 def __str__(self): return str(self.asTuple())
134 def __repr__(self): return str(self.asTuple())
135 def __len__(self): return len(self.asTuple())
136 def __getitem__(self, index): return self.asTuple()[index]
137 def __setitem__(self, index, val):
138 if index == 0: self.width = val
139 elif index == 1: self.height = val
140 else: raise IndexError
149 wxPoint(long x=0, long y=0);
153 void Set(long x, long y) {
157 PyObject* asTuple() {
158 PyObject* tup = PyTuple_New(2);
159 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
160 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
164 wxPoint __add__(const wxPoint* p) {
165 if (! p) return *self;
169 wxPoint __sub__(const wxPoint* p) {
170 if (! p) return *self;
174 int __cmp__(const wxPoint* p) {
176 if (*self == *p) return 0;
180 %pragma(python) addtoclass = "
181 def __str__(self): return str(self.asTuple())
182 def __repr__(self): return str(self.asTuple())
183 def __len__(self): return len(self.asTuple())
184 def __getitem__(self, index): return self.asTuple()[index]
185 def __setitem__(self, index, val):
186 if index == 0: self.x = val
187 elif index == 1: self.y = val
188 else: raise IndexError
192 //---------------------------------------------------------------------------
196 wxRect(int x=0, int y=0, int w=0, int h=0);
197 // TODO: do this one too... wxRect(const wxPoint& pos, const wxSize& size);
205 void SetWidth(int w);
207 void SetHeight(int h);
210 wxPoint GetPosition();
218 void SetLeft(int left);
219 void SetRight(int right);
220 void SetTop(int top);
221 void SetBottom(int bottom);
223 void Inflate(int dx, int dy);
224 bool Inside(int cx, int cy);
226 int x, y, width, height;
229 PyObject* asTuple() {
230 PyObject* tup = PyTuple_New(4);
231 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
232 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
233 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
234 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
238 wxRect __add__(const wxRect* rect) {
239 if (! rect) return *self;
240 return *self + *rect;
243 int __cmp__(const wxRect* rect) {
244 if (! rect) return 1;
245 if (*self == *rect) return 0;
250 %pragma(python) addtoclass = "
251 def __str__(self): return str(self.asTuple())
252 def __repr__(self): return str(self.asTuple())
253 def __len__(self): return len(self.asTuple())
254 def __getitem__(self, index): return self.asTuple()[index]
255 def __setitem__(self, index, val):
256 if index == 0: self.x = val
257 elif index == 1: self.y = val
258 elif index == 2: self.width = val
259 elif index == 3: self.height = val
260 else: raise IndexError
262 # override the __getattr__ made by SWIG
263 def __getattr__(self, name):
265 'x' : miscc.wxRect_x_get,
266 'y' : miscc.wxRect_y_get,
267 'width' : miscc.wxRect_width_get,
268 'height' : miscc.wxRect_height_get,
269 'top' : miscc.wxRect_GetTop,
270 'bottom' : miscc.wxRect_GetBottom,
271 'left' : miscc.wxRect_GetLeft,
272 'right' : miscc.wxRect_GetRight,
277 raise AttributeError,name
280 # and also the __setattr__
281 def __setattr__(self, name, value):
283 'x' : miscc.wxRect_x_set,
284 'y' : miscc.wxRect_y_set,
285 'width' : miscc.wxRect_width_set,
286 'height' : miscc.wxRect_height_set,
287 'top' : miscc.wxRect_SetTop,
288 'bottom' : miscc.wxRect_SetBottom,
289 'left' : miscc.wxRect_SetLeft,
290 'right' : miscc.wxRect_SetRight,
295 self.__dict__[name] = value
304 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
307 wxRect dest(0,0,0,0);
310 reg1.Intersect(reg2);
311 dest = reg1.GetBox();
313 if (dest != wxRect(0,0,0,0)) {
314 wxPyBeginBlockThreads();
315 wxRect* newRect = new wxRect(dest);
316 obj = wxPyConstructObject((void*)newRect, "wxRect");
317 PyObject* one = PyInt_FromLong(1);
318 PyObject_SetAttrString(obj, "thisown", one);
320 wxPyEndBlockThreads();
329 //---------------------------------------------------------------------------
330 // Miscellaneous functions
333 void wxRegisterId(long id);
334 %name(NewId) long wxNewId();
335 %name(RegisterId) void wxRegisterId(long id);
336 long wxGetCurrentId();
339 void wxEndBusyCursor();
341 long wxGetElapsedTime(bool resetTimer = TRUE);
343 long wxGetFreeMemory();
345 void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
348 bool wxShell(const wxString& command = wxEmptyString);
350 int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
351 wxString wxGetOsDescription();
353 void wxSleep(int secs);
354 void wxUsleep(unsigned long milliseconds);
356 bool wxYieldIfNeeded();
357 void wxEnableTopLevelWindows(bool enable);
360 wxString wxGetResource(const wxString& section, const wxString& entry,
361 const wxString& file = wxEmptyString) {
363 wxGetResource(section, entry, &retval, file);
368 wxString wxStripMenuCodes(const wxString& in);
371 wxString wxGetEmailAddress();
372 wxString wxGetHostName();
373 wxString wxGetFullHostName();
374 wxString wxGetUserId();
375 wxString wxGetUserName();
376 wxString wxGetHomeDir();
377 wxString wxGetUserHome(const char* user = "");
380 // When wxApp gets the virtual method magic then enable this.
381 // bool wxHandleFatalExceptions(bool doIt = TRUE);
383 //----------------------------------------------------------------------
385 enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
386 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
387 enum wxRelationship { wxUnconstrained = 0,
398 class wxIndividualLayoutConstraint : public wxObject {
400 // wxIndividualLayoutConstraint();
401 // ~wxIndividualLayoutConstraint();
403 void Above(wxWindow *otherWin, int margin=0);
404 void Absolute(int value);
406 void Below(wxWindow *otherWin, int margin=0);
407 void Unconstrained();
408 void LeftOf(wxWindow *otherWin, int margin=0);
409 void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
410 void RightOf(wxWindow *otherWin, int margin=0);
411 void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
412 void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
416 class wxLayoutConstraints : public wxObject {
418 wxLayoutConstraints();
421 wxIndividualLayoutConstraint bottom;
422 wxIndividualLayoutConstraint centreX;
423 wxIndividualLayoutConstraint centreY;
424 wxIndividualLayoutConstraint height;
425 wxIndividualLayoutConstraint left;
426 wxIndividualLayoutConstraint right;
427 wxIndividualLayoutConstraint top;
428 wxIndividualLayoutConstraint width;
434 //---------------------------------------------------------------------------
435 // Accelerator Entry and Table
437 class wxAcceleratorEntry {
439 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
440 ~wxAcceleratorEntry();
442 void Set(int flags, int keyCode, int Cmd);
449 class wxAcceleratorTable : public wxObject {
451 // Can also accept a list of 3-tuples
452 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* choices);
453 ~wxAcceleratorTable();
457 wxAcceleratorEntry *wxGetAccelFromString(const wxString& label);
461 #if 0 // we want to use the definition from the header, not the
462 // one SWIG will generate.
464 extern wxAcceleratorTable wxNullAcceleratorTable;
470 //---------------------------------------------------------------------------
472 class wxBusyInfo : public wxObject {
474 wxBusyInfo(const wxString& message);
478 //---------------------------------------------------------------------------