]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/events.i
more updates
[wxWidgets.git] / utils / wxPython / src / events.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: events.i
3 // Purpose: SWIGgable Event classes for wxPython
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 5/24/98
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13
14 %module events
15
16 %{
17 #include "helpers.h"
18 #include <wx/spinbutt.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 %import misc.i
29
30 //---------------------------------------------------------------------------
31
32 class wxEvent {
33 public:
34 wxEvent(int id = 0);
35 ~wxEvent();
36
37 wxObject* GetEventObject();
38 wxEventType GetEventType();
39 int GetId();
40 bool GetSkipped();
41 long GetTimestamp();
42 void SetEventObject(wxObject* object);
43 void SetEventType(wxEventType typ);
44 void SetId(int id);
45 void SetTimestamp(long timeStamp);
46 void Skip(bool skip = TRUE);
47 };
48
49 //---------------------------------------------------------------------------
50
51 class wxSizeEvent : public wxEvent {
52 public:
53 wxSizeEvent(const wxSize& sz, int id = 0);
54 wxSize GetSize();
55 };
56
57 //---------------------------------------------------------------------------
58
59 class wxCloseEvent : public wxEvent {
60 public:
61 wxCloseEvent(int commandEventType = 0, int id = 0);
62
63 void SetLoggingOff(bool loggingOff);
64 bool GetLoggingOff();
65 void Veto(bool veto = TRUE);
66 bool CanVeto();
67 bool GetVeto();
68 void SetCanVeto(bool canVeto);
69 };
70
71 //---------------------------------------------------------------------------
72
73 class wxCommandEvent : public wxEvent {
74 public:
75 wxCommandEvent(int commandEventType = 0, int id = 0);
76
77 bool Checked();
78 long GetExtraLong();
79 int GetInt();
80 int GetSelection();
81 wxString GetString();
82 bool IsSelection();
83 };
84
85
86 //---------------------------------------------------------------------------
87
88 class wxScrollEvent: public wxCommandEvent {
89 public:
90 wxScrollEvent(int commandType = 0, int id = 0, int pos = 0,
91 int orientation = 0);
92
93 int GetOrientation();
94 int GetPosition();
95 };
96
97 //---------------------------------------------------------------------------
98
99 class wxScrollWinEvent: public wxEvent {
100 public:
101 wxScrollWinEvent(int commandType = 0, int pos = 0,
102 int orientation = 0);
103
104 int GetOrientation();
105 int GetPosition();
106 };
107
108 //---------------------------------------------------------------------------
109
110 class wxSpinEvent : public wxScrollEvent {
111 public:
112 wxSpinEvent(int commandType = 0, int id = 0);
113
114 };
115
116 //---------------------------------------------------------------------------
117
118 class wxMouseEvent: public wxEvent {
119 public:
120 wxMouseEvent(int mouseEventType = 0);
121
122 bool IsButton();
123 bool ButtonDown(int but = -1);
124 bool ButtonDClick(int but = -1);
125 bool ButtonUp(int but = -1);
126 bool Button(int but);
127 bool ButtonIsDown(int but);
128 bool ControlDown();
129 bool MetaDown();
130 bool AltDown();
131 bool ShiftDown();
132 bool LeftDown();
133 bool MiddleDown();
134 bool RightDown();
135 bool LeftUp();
136 bool MiddleUp();
137 bool RightUp();
138 bool LeftDClick();
139 bool MiddleDClick();
140 bool RightDClick();
141 bool LeftIsDown();
142 bool MiddleIsDown();
143 bool RightIsDown();
144 bool Dragging();
145 bool Moving();
146 bool Entering();
147 bool Leaving();
148 void Position(long *OUTPUT, long *OUTPUT);
149 wxPoint GetPosition();
150 wxPoint GetLogicalPosition(const wxDC& dc);
151 long GetX();
152 long GetY();
153 };
154
155 //---------------------------------------------------------------------------
156
157 class wxKeyEvent: public wxEvent {
158 public:
159 wxKeyEvent(int keyEventType);
160
161 bool ControlDown();
162 bool MetaDown();
163 bool AltDown();
164 bool ShiftDown();
165 long KeyCode();
166
167 long GetX();
168 long GetY();
169 wxPoint GetPosition();
170 %name(GetPositionTuple) void GetPosition(long* OUTPUT, long* OUTPUT);
171 };
172
173 //---------------------------------------------------------------------------
174
175 class wxNavigationKeyEvent : public wxCommandEvent {
176 public:
177 wxNavigationKeyEvent();
178
179 bool GetDirection();
180 void SetDirection(bool bForward);
181 bool IsWindowChange();
182 void SetWindowChange(bool bIs);
183 wxWindow* GetCurrentFocus();
184 void SetCurrentFocus(wxWindow *win);
185 };
186
187
188 //---------------------------------------------------------------------------
189
190 class wxMoveEvent: public wxEvent {
191 public:
192 wxMoveEvent(const wxPoint& pt, int id = 0);
193
194 wxPoint GetPosition();
195 };
196
197 //---------------------------------------------------------------------------
198
199 class wxPaintEvent: public wxEvent {
200 public:
201 wxPaintEvent(int id = 0);
202
203 };
204
205 //---------------------------------------------------------------------------
206
207 class wxEraseEvent: public wxEvent {
208 public:
209 wxEraseEvent(int id = 0, wxDC* dc = NULL);
210
211 wxDC *GetDC();
212 };
213
214 //---------------------------------------------------------------------------
215
216 class wxFocusEvent: public wxEvent {
217 public:
218 wxFocusEvent(WXTYPE eventType = 0, int id = 0);
219 };
220
221 //---------------------------------------------------------------------------
222
223 class wxActivateEvent: public wxEvent{
224 public:
225 wxActivateEvent(WXTYPE eventType = 0, int active = TRUE, int id = 0);
226 bool GetActive();
227 };
228
229 //---------------------------------------------------------------------------
230
231 class wxInitDialogEvent: public wxEvent {
232 public:
233 wxInitDialogEvent(int id = 0);
234 };
235
236 //---------------------------------------------------------------------------
237
238 class wxMenuEvent: public wxEvent {
239 public:
240 wxMenuEvent(WXTYPE id = 0, int id = 0);
241 int GetMenuId();
242 };
243
244 //---------------------------------------------------------------------------
245
246 class wxShowEvent: public wxEvent {
247 public:
248 wxShowEvent(int id = 0, int show = FALSE);
249 void SetShow(bool show);
250 bool GetShow();
251 };
252
253 //---------------------------------------------------------------------------
254
255 class wxIconizeEvent: public wxEvent {
256 public:
257 wxIconizeEvent(int id = 0);
258 };
259
260 //---------------------------------------------------------------------------
261
262 class wxMaximizeEvent: public wxEvent {
263 public:
264 wxMaximizeEvent(int id = 0);
265 };
266
267 //---------------------------------------------------------------------------
268
269 class wxJoystickEvent: public wxEvent {
270 public:
271 wxJoystickEvent(int type = wxEVT_NULL,
272 int state = 0,
273 int joystick = wxJOYSTICK1,
274 int change = 0);
275 wxPoint GetPosition();
276 int GetZPosition();
277 int GetButtonState();
278 int GetButtonChange();
279 int GetJoystick();
280 void SetJoystick(int stick);
281 void SetButtonState(int state);
282 void SetButtonChange(int change);
283 void SetPosition(const wxPoint& pos);
284 void SetZPosition(int zPos);
285 bool IsButton();
286 bool IsMove();
287 bool IsZMove();
288 bool ButtonDown(int but = wxJOY_BUTTON_ANY);
289 bool ButtonUp(int but = wxJOY_BUTTON_ANY);
290 bool ButtonIsDown(int but = wxJOY_BUTTON_ANY);
291 };
292
293 //---------------------------------------------------------------------------
294
295 class wxDropFilesEvent: public wxEvent {
296 public:
297 wxPoint GetPosition();
298 int GetNumberOfFiles();
299
300 %addmethods {
301 PyObject* GetFiles() {
302 int count = self->GetNumberOfFiles();
303 wxString* files = self->GetFiles();
304 PyObject* list = PyList_New(count);
305
306 if (!list) {
307 PyErr_SetString(PyExc_MemoryError, "Can't allocate list of files!");
308 return NULL;
309 }
310
311 for (int i=0; i<count; i++) {
312 PyList_SetItem(list, i, PyString_FromString((const char*)files[i]));
313 }
314 return list;
315 }
316 }
317 };
318
319 //---------------------------------------------------------------------------
320
321 class wxIdleEvent: public wxEvent {
322 public:
323 wxIdleEvent();
324 void RequestMore(bool needMore = TRUE);
325 bool MoreRequested();
326 };
327
328 //---------------------------------------------------------------------------
329
330 class wxUpdateUIEvent: public wxEvent {
331 public:
332 wxUpdateUIEvent(wxWindowID commandId = 0);
333 bool GetChecked();
334 bool GetEnabled();
335 wxString GetText();
336 bool GetSetText();
337 bool GetSetChecked();
338 bool GetSetEnabled();
339
340 void Check(bool check);
341 void Enable(bool enable);
342 void SetText(const wxString& text);
343 };
344
345 //---------------------------------------------------------------------------
346
347 class wxSysColourChangedEvent: public wxEvent {
348 public:
349 wxSysColourChangedEvent();
350 };
351
352 //---------------------------------------------------------------------------
353
354
355 class wxNotifyEvent : public wxCommandEvent {
356 public:
357 wxNotifyEvent(int commandType = wxEVT_NULL, int id = 0);
358 bool IsAllowed();
359 void Veto();
360 };
361
362
363 //---------------------------------------------------------------------------
364
365 class wxPaletteChangedEvent : public wxEvent {
366 public:
367 wxPaletteChangedEvent(wxWindowID id = 0);
368
369 void SetChangedWindow(wxWindow* win);
370 wxWindow* GetChangedWindow();
371
372 };
373
374 //---------------------------------------------------------------------------
375
376 class wxQueryNewPaletteEvent : public wxEvent {
377 public:
378 wxQueryNewPaletteEvent(wxWindowID id = 0);
379
380 void SetPaletteRealized(bool realized);
381 bool GetPaletteRealized();
382 };
383
384
385 //---------------------------------------------------------------------------
386
387 class wxWindowCreateEvent : public wxEvent {
388 public:
389 wxWindowCreateEvent(wxWindow *win = NULL);
390
391 wxWindow *GetWindow();
392 };
393
394 class wxWindowDestroyEvent : public wxEvent {
395 public:
396 wxWindowDestroyEvent(wxWindow *win = NULL);
397
398 wxWindow *GetWindow();
399 };
400
401
402 //---------------------------------------------------------------------------
403 //---------------------------------------------------------------------------
404 //---------------------------------------------------------------------------
405 // This one can be derived from in Python and passed through the event
406 // system without loosing anything so long as the Python data is saved with
407 // SetPyData...
408
409 %{
410 class wxPyEvent : public wxEvent {
411 DECLARE_DYNAMIC_CLASS(wxPyEvent)
412 public:
413 wxPyEvent(int id=0, PyObject* userData = Py_None)
414 : wxEvent(id) {
415 m_userData = userData;
416 Py_INCREF(m_userData);
417 }
418
419 ~wxPyEvent() {
420 bool doSave = wxPyRestoreThread();
421 Py_DECREF(m_userData);
422 wxPySaveThread(doSave);
423 }
424
425 void SetPyData(PyObject* userData) {
426 bool doSave = wxPyRestoreThread();
427 Py_DECREF(m_userData);
428 m_userData = userData;
429 Py_INCREF(m_userData);
430 wxPySaveThread(doSave);
431 }
432
433 PyObject* GetPyData() const {
434 Py_INCREF(m_userData);
435 return m_userData;
436 }
437
438 // This one is so the event object can be Cloned...
439 void CopyObject(wxObject& dest) const {
440 wxEvent::CopyObject(dest);
441 ((wxPyEvent*)&dest)->SetPyData(m_userData);
442 }
443
444 private:
445 PyObject* m_userData;
446 };
447
448 IMPLEMENT_DYNAMIC_CLASS(wxPyEvent, wxEvent)
449
450 %}
451
452
453 class wxPyEvent : public wxEvent {
454 public:
455 wxPyEvent(int id=0, PyObject* userData = Py_None);
456 ~wxPyEvent();
457
458 void SetPyData(PyObject* userData);
459 PyObject* GetPyData();
460 };
461
462 //---------------------------------------------------------------------------
463 // Same for this one except it is a wxCommandEvent and so will get passed up the
464 // containment heirarchy.
465
466 %{
467 class wxPyCommandEvent : public wxCommandEvent {
468 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent)
469 public:
470 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0, PyObject* userData = Py_None)
471 : wxCommandEvent(commandType, id) {
472 m_userData = userData;
473 Py_INCREF(m_userData);
474 }
475
476 ~wxPyCommandEvent() {
477 bool doSave = wxPyRestoreThread();
478 Py_DECREF(m_userData);
479 wxPySaveThread(doSave);
480 }
481
482 void SetPyData(PyObject* userData) {
483 bool doSave = wxPyRestoreThread();
484 Py_DECREF(m_userData);
485 m_userData = userData;
486 Py_INCREF(m_userData);
487 wxPySaveThread(doSave);
488 }
489
490 PyObject* GetPyData() const {
491 Py_INCREF(m_userData);
492 return m_userData;
493 }
494
495 // This one is so the event object can be Cloned...
496 void CopyObject(wxObject& dest) const {
497 wxCommandEvent::CopyObject(dest);
498 ((wxPyCommandEvent*)&dest)->SetPyData(m_userData);
499 }
500
501 private:
502 PyObject* m_userData;
503 };
504
505 IMPLEMENT_DYNAMIC_CLASS(wxPyCommandEvent, wxCommandEvent)
506
507 %}
508
509
510 class wxPyCommandEvent : public wxCommandEvent {
511 public:
512 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0, PyObject* userData = Py_None);
513 ~wxPyCommandEvent();
514
515 void SetPyData(PyObject* userData);
516 PyObject* GetPyData();
517 };
518
519
520 //---------------------------------------------------------------------------
521 //---------------------------------------------------------------------------
522