]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/misc.i
Changes needed to enable wxGTK compatibility.
[wxWidgets.git] / utils / wxPython / src / misc.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: misc.i
3 // Purpose: Definitions of miscelaneous functions and classes
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 7/3/97
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 %module misc
14
15 %{
16 #include "helpers.h"
17 #include <wx/resource.h>
18 #include <wx/tooltip.h>
19 %}
20
21 //----------------------------------------------------------------------
22
23 %include typemaps.i
24 %include my_typemaps.i
25
26 // Import some definitions of other classes, etc.
27 %import _defs.i
28
29 //---------------------------------------------------------------------------
30
31
32
33 class wxSize {
34 public:
35 long x;
36 long y;
37 %name(width) long x;
38 %name(height)long y;
39
40 wxSize(long w=0, long h=0);
41 ~wxSize();
42 void Set(long w, long h);
43 long GetX();
44 long GetY();
45 %name(GetWidth) long GetX();
46 %name(GetHeight)long GetY();
47
48 %addmethods {
49 PyObject* asTuple() {
50 PyObject* tup = PyTuple_New(2);
51 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
52 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
53 return tup;
54 }
55 }
56 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
57 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
58
59 };
60
61 //---------------------------------------------------------------------------
62
63 class wxRealPoint {
64 public:
65 double x;
66 double y;
67 wxRealPoint(double x=0.0, double y=0.0);
68 ~wxRealPoint();
69 };
70
71 class wxPoint {
72 public:
73 long x;
74 long y;
75 wxPoint(long x=0, long y=0);
76 ~wxPoint();
77
78 %addmethods {
79 void Set(long x, long y) {
80 self->x = x;
81 self->y = y;
82 }
83 PyObject* asTuple() {
84 PyObject* tup = PyTuple_New(2);
85 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
86 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
87 return tup;
88 }
89 }
90 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
91 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
92 };
93
94 //---------------------------------------------------------------------------
95
96 class wxRect {
97 public:
98 wxRect(long x=0, long y=0, long w=0, long h=0);
99 // TODO: do this one too... wxRect(const wxPoint& pos, const wxSize& size);
100 ~wxRect();
101
102 long GetX();
103 void SetX(long X);
104 long GetY();
105 void SetY(long Y);
106 long GetWidth();
107 void SetWidth(long w);
108 long GetHeight();
109 void SetHeight(long h);
110
111
112 wxPoint GetPosition();
113 wxSize GetSize();
114
115 long GetLeft();
116 long GetTop();
117 long GetBottom();
118 long GetRight();
119
120 long x, y, width, height;
121
122 %addmethods {
123 PyObject* asTuple() {
124 PyObject* tup = PyTuple_New(4);
125 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
126 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
127 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->width));
128 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->height));
129 return tup;
130 }
131 }
132 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
133 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
134 };
135
136
137
138 //---------------------------------------------------------------------------
139 // Dialog Functions
140
141 wxString wxFileSelector(char* message,
142 char* default_path = NULL,
143 char* default_filename = NULL,
144 char* default_extension = NULL,
145 char* wildcard = "*.*",
146 int flags = 0,
147 wxWindow *parent = NULL,
148 int x = -1, int y = -1);
149
150 wxString wxGetTextFromUser(const wxString& message,
151 const wxString& caption = wxPyEmptyStr,
152 const wxString& default_value = wxPyEmptyStr,
153 wxWindow *parent = NULL,
154 int x = -1, int y = -1,
155 bool centre = TRUE);
156
157 // TODO: Need to custom wrap this one...
158 // int wxGetMultipleChoice(char* message, char* caption,
159 // int LCOUNT, char** LIST,
160 // int nsel, int *selection,
161 // wxWindow *parent = NULL, int x = -1, int y = -1,
162 // bool centre = TRUE, int width=150, int height=200);
163
164
165 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
166 int LCOUNT, wxString* LIST,
167 wxWindow *parent = NULL,
168 int x = -1, int y = -1,
169 bool centre = TRUE,
170 int width=150, int height=200);
171
172 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
173 int LCOUNT, wxString* LIST,
174 wxWindow *parent = NULL,
175 int x = -1, int y = -1,
176 bool centre = TRUE,
177 int width=150, int height=200);
178
179
180 int wxMessageBox(const wxString& message,
181 const wxString& caption = wxPyEmptyStr,
182 int style = wxOK | wxCENTRE,
183 wxWindow *parent = NULL,
184 int x = -1, int y = -1);
185
186 //---------------------------------------------------------------------------
187 // GDI Functions
188
189 bool wxColourDisplay();
190 int wxDisplayDepth();
191 void wxSetCursor(wxCursor& cursor);
192
193 //---------------------------------------------------------------------------
194 // Miscellaneous functions
195
196 long NewId();
197 void RegisterId(long id);
198 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
199 void wxBell();
200 void wxDisplaySize(int *OUTPUT, int *OUTPUT);
201 void wxEndBusyCursor();
202 long wxExecute(const wxString& command, bool sync = FALSE);
203 wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL);
204 wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL);
205 #ifdef __WXMSW__
206 wxWindow * wxGetActiveWindow();
207 long wxGetElapsedTime(bool resetTimer = TRUE);
208 long wxGetFreeMemory();
209 #endif
210 void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
211 bool wxIsBusy();
212 wxString wxNow();
213 #ifdef __WXMSW__
214 bool wxShell(const wxString& command = wxPyEmptyStr);
215 void wxStartTimer();
216 int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
217 #endif
218
219 bool wxYield();
220
221 %inline %{
222 char* wxGetResource(char *section, char *entry, char *file = NULL) {
223 char * retval;
224 wxGetResource(section, entry, &retval, file);
225 return retval;
226 }
227 %}
228
229 //---------------------------------------------------------------------------
230 // Resource System
231
232 bool wxResourceAddIdentifier(char *name, int value);
233 void wxResourceClear(void);
234 wxBitmap wxResourceCreateBitmap(char *resource);
235 wxIcon wxResourceCreateIcon(char *resource);
236 wxMenuBar * wxResourceCreateMenuBar(char *resource);
237 int wxResourceGetIdentifier(char *name);
238 bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
239 bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
240 bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
241
242
243
244 //----------------------------------------------------------------------
245
246 class wxPyTimer {
247 public:
248 wxPyTimer(PyObject* notify);
249 ~wxPyTimer();
250 int Interval();
251 void Start(int milliseconds=-1, int oneShot=FALSE);
252 void Stop();
253 };
254
255 //---------------------------------------------------------------------------
256
257 enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
258 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
259 enum wxRelationship { wxUnconstrained = 0,
260 wxAsIs,
261 wxPercentOf,
262 wxAbove,
263 wxBelow,
264 wxLeftOf,
265 wxRightOf,
266 wxSameAs,
267 wxAbsolute };
268
269
270 class wxIndividualLayoutConstraint {
271 public:
272 // wxIndividualLayoutConstraint();
273 // ~wxIndividualLayoutConstraint();
274
275 void Above(wxWindow *otherWin, int margin=0);
276 void Absolute(int value);
277 void AsIs();
278 void Below(wxWindow *otherWin, int margin=0);
279 void Unconstrained();
280 void LeftOf(wxWindow *otherWin, int margin=0);
281 void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
282 void RightOf(wxWindow *otherWin, int margin=0);
283 void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
284 void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
285 };
286
287
288 class wxLayoutConstraints {
289 public:
290 wxLayoutConstraints();
291
292 %readonly
293 wxIndividualLayoutConstraint bottom;
294 wxIndividualLayoutConstraint centreX;
295 wxIndividualLayoutConstraint centreY;
296 wxIndividualLayoutConstraint height;
297 wxIndividualLayoutConstraint left;
298 wxIndividualLayoutConstraint right;
299 wxIndividualLayoutConstraint top;
300 wxIndividualLayoutConstraint width;
301 %readwrite
302 }
303
304
305 //---------------------------------------------------------------------------
306 // Regions, etc.
307
308 enum wxRegionContain {
309 wxOutRegion, wxPartRegion, wxInRegion
310 };
311
312
313 class wxRegion {
314 public:
315 wxRegion();
316 ~wxRegion();
317
318 void Clear();
319 wxRegionContain Contains(long x, long y);
320 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
321 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
322
323 wxRect GetBox();
324 bool Intersect(const wxRect& rect);
325 #ifdef __WXMSW__
326 bool IsEmpty();
327 #endif
328 bool Subtract(const wxRect& rect);
329 bool Union(const wxRect& rect);
330 bool Xor(const wxRect& rect);
331 };
332
333
334
335 class wxRegionIterator {
336 public:
337 wxRegionIterator(const wxRegion& region);
338 ~wxRegionIterator();
339
340 long GetX();
341 long GetY();
342 long GetW();
343 long GetWidth();
344 long GetH();
345 long GetHeight();
346 wxRect GetRect();
347 bool HaveRects();
348 void Reset();
349
350 %addmethods {
351 void Next() {
352 (*self) ++;
353 }
354 };
355 };
356
357
358
359 //---------------------------------------------------------------------------
360 // Accelerator Entry and Table
361
362 class wxAcceleratorEntry {
363 public:
364 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
365 //~wxAcceleratorEntry(); *** ?
366
367 void Set(int flags, int keyCode, int Cmd);
368 int GetFlags();
369 int GetKeyCode();
370 int GetCommand();
371 };
372
373
374 class wxAcceleratorTable {
375 public:
376 // Can also accept a list of 3-tuples
377 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* LIST);
378 // ~wxAcceleratorEntry(); *** ?
379
380 };
381
382 //---------------------------------------------------------------------------
383 // wxToolTip
384
385 class wxToolTip {
386 public:
387 wxToolTip(const wxString &tip);
388
389 void SetTip(const wxString& tip);
390 wxString GetTip();
391 #ifndef __WXGTK__
392 void SetWindow(wxWindow *win);
393 #endif
394 wxWindow *GetWindow();
395 };
396
397
398 %inline %{
399 void wxToolTip_Enable(bool flag) {
400 wxToolTip::Enable(flag);
401 }
402
403 void wxToolTip_SetDelay(long milliseconds) {
404 wxToolTip::SetDelay(milliseconds);
405 }
406 %}
407
408 //---------------------------------------------------------------------------
409 /////////////////////////////////////////////////////////////////////////////
410 //
411 // $Log$
412 // Revision 1.12 1999/02/20 10:02:37 RD
413 // Changes needed to enable wxGTK compatibility.
414 //
415 // Revision 1.11 1999/02/20 09:03:01 RD
416 // Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
417 // window handle. If you can get the window handle into the python code,
418 // it should just work... More news on this later.
419 //
420 // Added wxImageList, wxToolTip.
421 //
422 // Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
423 // wxRegConfig class.
424 //
425 // As usual, some bug fixes, tweaks, etc.
426 //
427 // Revision 1.10 1999/01/30 07:30:14 RD
428 //
429 // Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
430 //
431 // Various cleanup, tweaks, minor additions, etc. to maintain
432 // compatibility with the current wxWindows.
433 //
434 // Revision 1.9 1998/12/16 22:10:55 RD
435 //
436 // Tweaks needed to be able to build wxPython with wxGTK.
437 //
438 // Revision 1.8 1998/12/15 20:41:22 RD
439 // Changed the import semantics from "from wxPython import *" to "from
440 // wxPython.wx import *" This is for people who are worried about
441 // namespace pollution, they can use "from wxPython import wx" and then
442 // prefix all the wxPython identifiers with "wx."
443 //
444 // Added wxTaskbarIcon for wxMSW.
445 //
446 // Made the events work for wxGrid.
447 //
448 // Added wxConfig.
449 //
450 // Added wxMiniFrame for wxGTK, (untested.)
451 //
452 // Changed many of the args and return values that were pointers to gdi
453 // objects to references to reflect changes in the wxWindows API.
454 //
455 // Other assorted fixes and additions.
456 //
457 // Revision 1.7 1998/11/25 08:45:27 RD
458 //
459 // Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
460 // Added events for wxGrid
461 // Other various fixes and additions
462 //
463 // Revision 1.6 1998/11/15 23:03:46 RD
464 // Removing some ifdef's for wxGTK
465 //
466 // Revision 1.5 1998/10/20 06:43:59 RD
467 // New wxTreeCtrl wrappers (untested)
468 // some changes in helpers
469 // etc.
470 //
471 // Revision 1.4 1998/08/18 19:48:19 RD
472 // more wxGTK compatibility things.
473 //
474 // It builds now but there are serious runtime problems...
475 //
476 // Revision 1.3 1998/08/16 04:31:10 RD
477 // More wxGTK work.
478 //
479 // Revision 1.2 1998/08/15 07:36:41 RD
480 // - Moved the header in the .i files out of the code that gets put into
481 // the .cpp files. It caused CVS conflicts because of the RCS ID being
482 // different each time.
483 //
484 // - A few minor fixes.
485 //
486 // Revision 1.1 1998/08/09 08:25:51 RD
487 // Initial version
488 //
489 //
490
491