]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/misc.i
wxPython 2.0b9, first phase (win32)
[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 wxNewId();
197 void wxRegisterId(long id);
198 %name(NewId) long wxNewId();
199 %name(RegisterId) void wxRegisterId(long id);
200
201 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
202 void wxBell();
203 void wxDisplaySize(int *OUTPUT, int *OUTPUT);
204 void wxEndBusyCursor();
205 long wxExecute(const wxString& command, bool sync = FALSE);
206 wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL);
207 wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL);
208 #ifdef __WXMSW__
209 wxWindow * wxGetActiveWindow();
210 long wxGetElapsedTime(bool resetTimer = TRUE);
211 long wxGetFreeMemory();
212 #endif
213 void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
214 bool wxIsBusy();
215 wxString wxNow();
216 #ifdef __WXMSW__
217 bool wxShell(const wxString& command = wxPyEmptyStr);
218 void wxStartTimer();
219 int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
220 #endif
221
222 bool wxYield();
223 bool wxSafeYield();
224
225 %inline %{
226 char* wxGetResource(char *section, char *entry, char *file = NULL) {
227 char * retval;
228 wxGetResource(section, entry, &retval, file);
229 return retval;
230 }
231 %}
232
233 //---------------------------------------------------------------------------
234 // Resource System
235
236 bool wxResourceAddIdentifier(char *name, int value);
237 void wxResourceClear(void);
238 wxBitmap wxResourceCreateBitmap(char *resource);
239 wxIcon wxResourceCreateIcon(char *resource);
240 wxMenuBar * wxResourceCreateMenuBar(char *resource);
241 int wxResourceGetIdentifier(char *name);
242 bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
243 bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
244 bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
245
246
247
248 //----------------------------------------------------------------------
249
250 class wxPyTimer {
251 public:
252 wxPyTimer(PyObject* notify);
253 ~wxPyTimer();
254 int Interval();
255 void Start(int milliseconds=-1, int oneShot=FALSE);
256 void Stop();
257 };
258
259 //---------------------------------------------------------------------------
260
261 enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
262 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
263 enum wxRelationship { wxUnconstrained = 0,
264 wxAsIs,
265 wxPercentOf,
266 wxAbove,
267 wxBelow,
268 wxLeftOf,
269 wxRightOf,
270 wxSameAs,
271 wxAbsolute };
272
273
274 class wxIndividualLayoutConstraint {
275 public:
276 // wxIndividualLayoutConstraint();
277 // ~wxIndividualLayoutConstraint();
278
279 void Above(wxWindow *otherWin, int margin=0);
280 void Absolute(int value);
281 void AsIs();
282 void Below(wxWindow *otherWin, int margin=0);
283 void Unconstrained();
284 void LeftOf(wxWindow *otherWin, int margin=0);
285 void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
286 void RightOf(wxWindow *otherWin, int margin=0);
287 void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
288 void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
289 };
290
291
292 class wxLayoutConstraints {
293 public:
294 wxLayoutConstraints();
295
296 %readonly
297 wxIndividualLayoutConstraint bottom;
298 wxIndividualLayoutConstraint centreX;
299 wxIndividualLayoutConstraint centreY;
300 wxIndividualLayoutConstraint height;
301 wxIndividualLayoutConstraint left;
302 wxIndividualLayoutConstraint right;
303 wxIndividualLayoutConstraint top;
304 wxIndividualLayoutConstraint width;
305 %readwrite
306 }
307
308
309 //---------------------------------------------------------------------------
310 // Regions, etc.
311
312 enum wxRegionContain {
313 wxOutRegion, wxPartRegion, wxInRegion
314 };
315
316
317 class wxRegion {
318 public:
319 wxRegion();
320 ~wxRegion();
321
322 void Clear();
323 wxRegionContain Contains(long x, long y);
324 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
325 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
326
327 wxRect GetBox();
328 bool Intersect(const wxRect& rect);
329 #ifdef __WXMSW__
330 bool IsEmpty();
331 #endif
332 bool Subtract(const wxRect& rect);
333 bool Union(const wxRect& rect);
334 bool Xor(const wxRect& rect);
335 };
336
337
338
339 class wxRegionIterator {
340 public:
341 wxRegionIterator(const wxRegion& region);
342 ~wxRegionIterator();
343
344 long GetX();
345 long GetY();
346 long GetW();
347 long GetWidth();
348 long GetH();
349 long GetHeight();
350 wxRect GetRect();
351 bool HaveRects();
352 void Reset();
353
354 %addmethods {
355 void Next() {
356 (*self) ++;
357 }
358 };
359 };
360
361
362
363 //---------------------------------------------------------------------------
364 // Accelerator Entry and Table
365
366 class wxAcceleratorEntry {
367 public:
368 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
369 //~wxAcceleratorEntry(); *** ?
370
371 void Set(int flags, int keyCode, int Cmd);
372 int GetFlags();
373 int GetKeyCode();
374 int GetCommand();
375 };
376
377
378 class wxAcceleratorTable {
379 public:
380 // Can also accept a list of 3-tuples
381 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* LIST);
382 // ~wxAcceleratorEntry(); *** ?
383
384 };
385
386 //---------------------------------------------------------------------------
387 // wxToolTip
388
389 class wxToolTip {
390 public:
391 wxToolTip(const wxString &tip);
392
393 void SetTip(const wxString& tip);
394 wxString GetTip();
395 // *** Not in the "public" interface void SetWindow(wxWindow *win);
396 wxWindow *GetWindow();
397 };
398
399
400 %inline %{
401 void wxToolTip_Enable(bool flag) {
402 wxToolTip::Enable(flag);
403 }
404
405 void wxToolTip_SetDelay(long milliseconds) {
406 wxToolTip::SetDelay(milliseconds);
407 }
408 %}
409
410 //---------------------------------------------------------------------------
411 /////////////////////////////////////////////////////////////////////////////
412 //
413 // $Log$
414 // Revision 1.14 1999/04/30 03:29:19 RD
415 // wxPython 2.0b9, first phase (win32)
416 // Added gobs of stuff, see wxPython/README.txt for details
417 //
418 // Revision 1.13.4.1 1999/03/27 23:29:15 RD
419 //
420 // wxPython 2.0b8
421 // Python thread support
422 // various minor additions
423 // various minor fixes
424 //
425 // Revision 1.13 1999/02/25 07:08:34 RD
426 //
427 // wxPython version 2.0b5
428 //
429 // Revision 1.12 1999/02/20 10:02:37 RD
430 //
431 // Changes needed to enable wxGTK compatibility.
432 //
433 // Revision 1.11 1999/02/20 09:03:01 RD
434 // Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
435 // window handle. If you can get the window handle into the python code,
436 // it should just work... More news on this later.
437 //
438 // Added wxImageList, wxToolTip.
439 //
440 // Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
441 // wxRegConfig class.
442 //
443 // As usual, some bug fixes, tweaks, etc.
444 //
445 // Revision 1.10 1999/01/30 07:30:14 RD
446 //
447 // Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
448 //
449 // Various cleanup, tweaks, minor additions, etc. to maintain
450 // compatibility with the current wxWindows.
451 //
452 // Revision 1.9 1998/12/16 22:10:55 RD
453 //
454 // Tweaks needed to be able to build wxPython with wxGTK.
455 //
456 // Revision 1.8 1998/12/15 20:41:22 RD
457 // Changed the import semantics from "from wxPython import *" to "from
458 // wxPython.wx import *" This is for people who are worried about
459 // namespace pollution, they can use "from wxPython import wx" and then
460 // prefix all the wxPython identifiers with "wx."
461 //
462 // Added wxTaskbarIcon for wxMSW.
463 //
464 // Made the events work for wxGrid.
465 //
466 // Added wxConfig.
467 //
468 // Added wxMiniFrame for wxGTK, (untested.)
469 //
470 // Changed many of the args and return values that were pointers to gdi
471 // objects to references to reflect changes in the wxWindows API.
472 //
473 // Other assorted fixes and additions.
474 //
475 // Revision 1.7 1998/11/25 08:45:27 RD
476 //
477 // Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
478 // Added events for wxGrid
479 // Other various fixes and additions
480 //
481 // Revision 1.6 1998/11/15 23:03:46 RD
482 // Removing some ifdef's for wxGTK
483 //
484 // Revision 1.5 1998/10/20 06:43:59 RD
485 // New wxTreeCtrl wrappers (untested)
486 // some changes in helpers
487 // etc.
488 //
489 // Revision 1.4 1998/08/18 19:48:19 RD
490 // more wxGTK compatibility things.
491 //
492 // It builds now but there are serious runtime problems...
493 //
494 // Revision 1.3 1998/08/16 04:31:10 RD
495 // More wxGTK work.
496 //
497 // Revision 1.2 1998/08/15 07:36:41 RD
498 // - Moved the header in the .i files out of the code that gets put into
499 // the .cpp files. It caused CVS conflicts because of the RCS ID being
500 // different each time.
501 //
502 // - A few minor fixes.
503 //
504 // Revision 1.1 1998/08/09 08:25:51 RD
505 // Initial version
506 //
507 //
508
509