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 //---------------------------------------------------------------------------
33 // Put some wx default wxChar* values into wxStrings.
34 static const wxString wxPyEmptyString(wxT(""));
36 //---------------------------------------------------------------------------
43 wxString GetClassName() {
44 return self->GetClassInfo()->GetClassName();
53 //---------------------------------------------------------------------------
62 wxSize(long w=0, long h=0);
64 void Set(long w, long h);
69 void SetWidth(long w);
70 void SetHeight(long h);
74 PyObject* tup = PyTuple_New(2);
75 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
76 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
80 int __cmp__(const wxSize* sz) {
82 if (*self == *sz) return 0;
87 %pragma(python) addtoclass = "
88 def __str__(self): return str(self.asTuple())
89 def __repr__(self): return str(self.asTuple())
90 def __len__(self): return len(self.asTuple())
91 def __getitem__(self, index): return self.asTuple()[index]
92 def __setitem__(self, index, val):
93 if index == 0: self.width = val
94 elif index == 1: self.height = val
95 else: raise IndexError
100 //---------------------------------------------------------------------------
106 wxRealPoint(double x=0.0, double y=0.0);
110 void Set(double x, double y) {
114 PyObject* asTuple() {
115 PyObject* tup = PyTuple_New(2);
116 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
117 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
121 wxRealPoint __add__(const wxRealPoint* p) {
122 if (! p) return *self;
126 wxRealPoint __sub__(const wxRealPoint* p) {
127 if (! p) return *self;
131 int __cmp__(const wxRealPoint* p) {
133 if (*self == *p) return 0;
137 %pragma(python) addtoclass = "
138 def __str__(self): return str(self.asTuple())
139 def __repr__(self): return str(self.asTuple())
140 def __len__(self): return len(self.asTuple())
141 def __getitem__(self, index): return self.asTuple()[index]
142 def __setitem__(self, index, val):
143 if index == 0: self.width = val
144 elif index == 1: self.height = val
145 else: raise IndexError
154 wxPoint(long x=0, long y=0);
158 void Set(long x, long y) {
162 PyObject* asTuple() {
163 PyObject* tup = PyTuple_New(2);
164 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
165 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
169 wxPoint __add__(const wxPoint* p) {
170 if (! p) return *self;
174 wxPoint __sub__(const wxPoint* p) {
175 if (! p) return *self;
179 int __cmp__(const wxPoint* p) {
181 if (*self == *p) return 0;
185 %pragma(python) addtoclass = "
186 def __str__(self): return str(self.asTuple())
187 def __repr__(self): return str(self.asTuple())
188 def __len__(self): return len(self.asTuple())
189 def __getitem__(self, index): return self.asTuple()[index]
190 def __setitem__(self, index, val):
191 if index == 0: self.x = val
192 elif index == 1: self.y = val
193 else: raise IndexError
197 //---------------------------------------------------------------------------
201 wxRect(int x=0, int y=0, int w=0, int h=0);
202 // TODO: do this one too... wxRect(const wxPoint& pos, const wxSize& size);
210 void SetWidth(int w);
212 void SetHeight(int h);
215 wxPoint GetPosition();
223 void SetLeft(int left);
224 void SetRight(int right);
225 void SetTop(int top);
226 void SetBottom(int bottom);
228 void Inflate(int dx, int dy);
229 bool Inside(int cx, int cy);
231 int x, y, width, height;
234 PyObject* asTuple() {
235 PyObject* tup = PyTuple_New(4);
236 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
237 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
238 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
239 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
243 wxRect __add__(const wxRect* rect) {
244 if (! rect) return *self;
245 return *self + *rect;
248 int __cmp__(const wxRect* rect) {
249 if (! rect) return 1;
250 if (*self == *rect) return 0;
255 %pragma(python) addtoclass = "
256 def __str__(self): return str(self.asTuple())
257 def __repr__(self): return 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 elif index == 2: self.width = val
264 elif index == 3: self.height = val
265 else: raise IndexError
267 # override the __getattr__ made by SWIG
268 def __getattr__(self, name):
270 'x' : miscc.wxRect_x_get,
271 'y' : miscc.wxRect_y_get,
272 'width' : miscc.wxRect_width_get,
273 'height' : miscc.wxRect_height_get,
274 'top' : miscc.wxRect_GetTop,
275 'bottom' : miscc.wxRect_GetBottom,
276 'left' : miscc.wxRect_GetLeft,
277 'right' : miscc.wxRect_GetRight,
282 raise AttributeError,name
285 # and also the __setattr__
286 def __setattr__(self, name, value):
288 'x' : miscc.wxRect_x_set,
289 'y' : miscc.wxRect_y_set,
290 'width' : miscc.wxRect_width_set,
291 'height' : miscc.wxRect_height_set,
292 'top' : miscc.wxRect_SetTop,
293 'bottom' : miscc.wxRect_SetBottom,
294 'left' : miscc.wxRect_SetLeft,
295 'right' : miscc.wxRect_SetRight,
300 self.__dict__[name] = value
309 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
312 wxRect dest(0,0,0,0);
315 reg1.Intersect(reg2);
316 dest = reg1.GetBox();
318 if (dest != wxRect(0,0,0,0)) {
319 wxPyBeginBlockThreads();
320 wxRect* newRect = new wxRect(dest);
321 obj = wxPyConstructObject((void*)newRect, "wxRect");
322 PyObject* one = PyInt_FromLong(1);
323 PyObject_SetAttrString(obj, "thisown", one);
325 wxPyEndBlockThreads();
334 //---------------------------------------------------------------------------
335 // Miscellaneous functions
338 void wxRegisterId(long id);
339 %name(NewId) long wxNewId();
340 %name(RegisterId) void wxRegisterId(long id);
341 long wxGetCurrentId();
344 void wxEndBusyCursor();
346 long wxGetElapsedTime(bool resetTimer = TRUE);
348 long wxGetFreeMemory();
350 void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
353 bool wxShell(const wxString& command = wxPyEmptyString);
355 int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
356 wxString wxGetOsDescription();
358 void wxSleep(int secs);
359 void wxUsleep(unsigned long milliseconds);
361 bool wxYieldIfNeeded();
362 void wxEnableTopLevelWindows(bool enable);
365 wxString wxGetResource(const wxString& section, const wxString& entry,
366 const wxString& file = wxPyEmptyString) {
368 wxGetResource(section, entry, &retval, file);
373 wxString wxStripMenuCodes(const wxString& in);
376 wxString wxGetEmailAddress();
377 wxString wxGetHostName();
378 wxString wxGetFullHostName();
379 wxString wxGetUserId();
380 wxString wxGetUserName();
381 wxString wxGetHomeDir();
382 wxString wxGetUserHome(const wxString& user = wxPyEmptyString);
385 // When wxApp gets the virtual method magic then enable this.
386 // bool wxHandleFatalExceptions(bool doIt = TRUE);
388 //----------------------------------------------------------------------
390 enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
391 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
392 enum wxRelationship { wxUnconstrained = 0,
403 class wxIndividualLayoutConstraint : public wxObject {
405 // wxIndividualLayoutConstraint();
406 // ~wxIndividualLayoutConstraint();
408 void Above(wxWindow *otherWin, int margin=0);
409 void Absolute(int value);
411 void Below(wxWindow *otherWin, int margin=0);
412 void Unconstrained();
413 void LeftOf(wxWindow *otherWin, int margin=0);
414 void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
415 void RightOf(wxWindow *otherWin, int margin=0);
416 void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
417 void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
421 class wxLayoutConstraints : public wxObject {
423 wxLayoutConstraints();
426 wxIndividualLayoutConstraint bottom;
427 wxIndividualLayoutConstraint centreX;
428 wxIndividualLayoutConstraint centreY;
429 wxIndividualLayoutConstraint height;
430 wxIndividualLayoutConstraint left;
431 wxIndividualLayoutConstraint right;
432 wxIndividualLayoutConstraint top;
433 wxIndividualLayoutConstraint width;
439 //---------------------------------------------------------------------------
440 // Accelerator Entry and Table
442 class wxAcceleratorEntry {
444 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
445 ~wxAcceleratorEntry();
447 void Set(int flags, int keyCode, int Cmd);
454 class wxAcceleratorTable : public wxObject {
456 // Can also accept a list of 3-tuples
457 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* choices);
458 ~wxAcceleratorTable();
462 wxAcceleratorEntry *wxGetAccelFromString(const wxString& label);
466 #if 0 // we want to use the definition from the header, not the
467 // one SWIG will generate.
469 extern wxAcceleratorTable wxNullAcceleratorTable;
475 //---------------------------------------------------------------------------
477 class wxBusyInfo : public wxObject {
479 wxBusyInfo(const wxString& message);
484 //---------------------------------------------------------------------------