]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/misc.i
minimal now works in Unicode mode
[wxWidgets.git] / utils / wxPython / src / misc.i
CommitLineData
7bf85405
RD
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
03e9bead 13%module misc
7bf85405 14
03e9bead 15%{
7bf85405
RD
16#include "helpers.h"
17#include <wx/resource.h>
af309447 18#include <wx/tooltip.h>
7bf85405
RD
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
33class wxSize {
34public:
af309447
RD
35 long x;
36 long y;
7bf85405
RD
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);
af309447
RD
43 long GetX();
44 long GetY();
7bf85405
RD
45 %name(GetWidth) long GetX();
46 %name(GetHeight)long GetY();
47
48 %addmethods {
af309447 49 PyObject* asTuple() {
7bf85405
RD
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 }
af309447
RD
56 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
57 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
58
7bf85405
RD
59};
60
61//---------------------------------------------------------------------------
62
63class wxRealPoint {
64public:
65 double x;
66 double y;
67 wxRealPoint(double x=0.0, double y=0.0);
68 ~wxRealPoint();
69};
70
71class wxPoint {
72public:
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 }
af309447 83 PyObject* asTuple() {
7bf85405
RD
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 }
af309447
RD
90 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
91 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
7bf85405
RD
92};
93
94//---------------------------------------------------------------------------
95
96class wxRect {
97public:
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;
af309447
RD
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())"
7bf85405
RD
134};
135
136
137
138//---------------------------------------------------------------------------
139// Dialog Functions
140
08127323 141wxString wxFileSelector(char* message,
7bf85405
RD
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
150wxString 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
165wxString 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
172int 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
180int 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
189bool wxColourDisplay();
190int wxDisplayDepth();
b8b8dda7 191void wxSetCursor(wxCursor& cursor);
7bf85405
RD
192
193//---------------------------------------------------------------------------
194// Miscellaneous functions
195
196long NewId();
197void RegisterId(long id);
198void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
199void wxBell();
200void wxDisplaySize(int *OUTPUT, int *OUTPUT);
201void wxEndBusyCursor();
202long wxExecute(const wxString& command, bool sync = FALSE);
203wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL);
204wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL);
714e6a9e 205#ifdef __WXMSW__
7bf85405
RD
206wxWindow * wxGetActiveWindow();
207long wxGetElapsedTime(bool resetTimer = TRUE);
208long wxGetFreeMemory();
fb5e0af0 209#endif
7bf85405
RD
210void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
211bool wxIsBusy();
212wxString wxNow();
714e6a9e 213#ifdef __WXMSW__
fb5e0af0 214bool wxShell(const wxString& command = wxPyEmptyStr);
7bf85405 215void wxStartTimer();
fb5e0af0 216int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
714e6a9e 217#endif
fb5e0af0 218
7bf85405
RD
219bool wxYield();
220
7bf85405
RD
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
232bool wxResourceAddIdentifier(char *name, int value);
233void wxResourceClear(void);
d5c9047a
RD
234wxBitmap wxResourceCreateBitmap(char *resource);
235wxIcon wxResourceCreateIcon(char *resource);
7bf85405
RD
236wxMenuBar * wxResourceCreateMenuBar(char *resource);
237int wxResourceGetIdentifier(char *name);
238bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
239bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
240bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
241
242
243
244//----------------------------------------------------------------------
245
246class wxPyTimer {
247public:
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
257enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
258 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
259enum wxRelationship { wxUnconstrained = 0,
260 wxAsIs,
261 wxPercentOf,
262 wxAbove,
263 wxBelow,
264 wxLeftOf,
265 wxRightOf,
266 wxSameAs,
267 wxAbsolute };
268
269
270class wxIndividualLayoutConstraint {
271public:
272// wxIndividualLayoutConstraint();
273// ~wxIndividualLayoutConstraint();
274
275 void Above(wxWindow *otherWin, int margin=0);
276 void Absolute(int value);
08127323 277 void AsIs();
7bf85405 278 void Below(wxWindow *otherWin, int margin=0);
08127323 279 void Unconstrained();
7bf85405
RD
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
288class wxLayoutConstraints {
289public:
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
b639c3c5
RD
305//---------------------------------------------------------------------------
306// Regions, etc.
307
308enum wxRegionContain {
309 wxOutRegion, wxPartRegion, wxInRegion
310};
311
312
313class wxRegion {
314public:
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);
105e45b9 325#ifdef __WXMSW__
b639c3c5 326 bool IsEmpty();
105e45b9 327#endif
b639c3c5
RD
328 bool Subtract(const wxRect& rect);
329 bool Union(const wxRect& rect);
330 bool Xor(const wxRect& rect);
331};
332
333
334
335class wxRegionIterator {
336public:
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
7bf85405
RD
359//---------------------------------------------------------------------------
360// Accelerator Entry and Table
361
362class wxAcceleratorEntry {
363public:
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
374class wxAcceleratorTable {
375public:
376 // Can also accept a list of 3-tuples
377 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* LIST);
378 // ~wxAcceleratorEntry(); *** ?
379
380};
faf3cb35 381
af309447
RD
382//---------------------------------------------------------------------------
383// wxToolTip
384
385class wxToolTip {
386public:
387 wxToolTip(const wxString &tip);
388
389 void SetTip(const wxString& tip);
390 wxString GetTip();
0699c864 391 // *** Not in the "public" interface void SetWindow(wxWindow *win);
af309447
RD
392 wxWindow *GetWindow();
393};
394
395
396%inline %{
397 void wxToolTip_Enable(bool flag) {
398 wxToolTip::Enable(flag);
399 }
400
401 void wxToolTip_SetDelay(long milliseconds) {
402 wxToolTip::SetDelay(milliseconds);
403 }
404%}
405
7bf85405
RD
406//---------------------------------------------------------------------------
407/////////////////////////////////////////////////////////////////////////////
408//
409// $Log$
0699c864
RD
410// Revision 1.13 1999/02/25 07:08:34 RD
411// wxPython version 2.0b5
412//
b57bdb5a 413// Revision 1.12 1999/02/20 10:02:37 RD
0699c864 414//
b57bdb5a
RD
415// Changes needed to enable wxGTK compatibility.
416//
af309447
RD
417// Revision 1.11 1999/02/20 09:03:01 RD
418// Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
419// window handle. If you can get the window handle into the python code,
420// it should just work... More news on this later.
421//
422// Added wxImageList, wxToolTip.
423//
424// Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
425// wxRegConfig class.
426//
427// As usual, some bug fixes, tweaks, etc.
428//
08127323 429// Revision 1.10 1999/01/30 07:30:14 RD
af309447 430//
08127323
RD
431// Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
432//
433// Various cleanup, tweaks, minor additions, etc. to maintain
434// compatibility with the current wxWindows.
435//
105e45b9 436// Revision 1.9 1998/12/16 22:10:55 RD
08127323 437//
105e45b9
RD
438// Tweaks needed to be able to build wxPython with wxGTK.
439//
b8b8dda7
RD
440// Revision 1.8 1998/12/15 20:41:22 RD
441// Changed the import semantics from "from wxPython import *" to "from
442// wxPython.wx import *" This is for people who are worried about
443// namespace pollution, they can use "from wxPython import wx" and then
444// prefix all the wxPython identifiers with "wx."
445//
446// Added wxTaskbarIcon for wxMSW.
447//
448// Made the events work for wxGrid.
449//
450// Added wxConfig.
451//
452// Added wxMiniFrame for wxGTK, (untested.)
453//
454// Changed many of the args and return values that were pointers to gdi
455// objects to references to reflect changes in the wxWindows API.
456//
457// Other assorted fixes and additions.
458//
b639c3c5 459// Revision 1.7 1998/11/25 08:45:27 RD
b8b8dda7 460//
b639c3c5
RD
461// Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
462// Added events for wxGrid
463// Other various fixes and additions
464//
faf3cb35
RD
465// Revision 1.6 1998/11/15 23:03:46 RD
466// Removing some ifdef's for wxGTK
467//
d5c9047a
RD
468// Revision 1.5 1998/10/20 06:43:59 RD
469// New wxTreeCtrl wrappers (untested)
470// some changes in helpers
471// etc.
472//
fb5e0af0
RD
473// Revision 1.4 1998/08/18 19:48:19 RD
474// more wxGTK compatibility things.
475//
476// It builds now but there are serious runtime problems...
477//
714e6a9e
RD
478// Revision 1.3 1998/08/16 04:31:10 RD
479// More wxGTK work.
480//
03e9bead
RD
481// Revision 1.2 1998/08/15 07:36:41 RD
482// - Moved the header in the .i files out of the code that gets put into
483// the .cpp files. It caused CVS conflicts because of the RCS ID being
484// different each time.
485//
486// - A few minor fixes.
487//
7bf85405
RD
488// Revision 1.1 1998/08/09 08:25:51 RD
489// Initial version
490//
491//
492
493