1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIGgable Event classes for wxPython
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
18 #include <wx/spinbutt.h>
21 //----------------------------------------------------------------------
24 %include my_typemaps.i
26 // Import some definitions of other classes, etc.
30 //---------------------------------------------------------------------------
37 wxObject* GetEventObject();
38 wxEventType GetEventType();
42 void SetEventObject(wxObject* object);
43 void SetEventType(wxEventType typ);
45 void SetTimestamp(long timeStamp);
46 void Skip(bool skip = TRUE);
49 //---------------------------------------------------------------------------
51 class wxSizeEvent : public wxEvent {
53 wxSizeEvent(const wxSize& sz, int id = 0);
57 //---------------------------------------------------------------------------
59 class wxCloseEvent : public wxEvent {
61 wxCloseEvent(int commandEventType = 0, int id = 0);
63 void SetLoggingOff(bool loggingOff);
65 void Veto(bool veto = TRUE);
68 void SetCanVeto(bool canVeto);
71 //---------------------------------------------------------------------------
73 class wxCommandEvent : public wxEvent {
75 wxCommandEvent(int commandEventType = 0, int id = 0);
86 //---------------------------------------------------------------------------
88 class wxScrollEvent: public wxCommandEvent {
90 wxScrollEvent(int commandType = 0, int id = 0, int pos = 0,
97 //---------------------------------------------------------------------------
99 class wxScrollWinEvent: public wxEvent {
101 wxScrollWinEvent(int commandType = 0, int pos = 0,
102 int orientation = 0);
104 int GetOrientation();
108 //---------------------------------------------------------------------------
110 class wxSpinEvent : public wxScrollEvent {
112 wxSpinEvent(int commandType = 0, int id = 0);
116 //---------------------------------------------------------------------------
118 class wxMouseEvent: public wxEvent {
120 wxMouseEvent(int mouseEventType = 0);
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);
148 void Position(long *OUTPUT, long *OUTPUT);
149 wxPoint GetPosition();
150 wxPoint GetLogicalPosition(const wxDC& dc);
155 //---------------------------------------------------------------------------
157 class wxKeyEvent: public wxEvent {
159 wxKeyEvent(int keyEventType);
169 wxPoint GetPosition();
170 %name(GetPositionTuple) void GetPosition(long* OUTPUT, long* OUTPUT);
173 //---------------------------------------------------------------------------
175 class wxNavigationKeyEvent : public wxCommandEvent {
177 wxNavigationKeyEvent();
180 void SetDirection(bool bForward);
181 bool IsWindowChange();
182 void SetWindowChange(bool bIs);
183 wxWindow* GetCurrentFocus();
184 void SetCurrentFocus(wxWindow *win);
188 //---------------------------------------------------------------------------
190 class wxMoveEvent: public wxEvent {
192 wxMoveEvent(const wxPoint& pt, int id = 0);
194 wxPoint GetPosition();
197 //---------------------------------------------------------------------------
199 class wxPaintEvent: public wxEvent {
201 wxPaintEvent(int id = 0);
205 //---------------------------------------------------------------------------
207 class wxEraseEvent: public wxEvent {
209 wxEraseEvent(int id = 0, wxDC* dc = NULL);
214 //---------------------------------------------------------------------------
216 class wxFocusEvent: public wxEvent {
218 wxFocusEvent(WXTYPE eventType = 0, int id = 0);
221 //---------------------------------------------------------------------------
223 class wxActivateEvent: public wxEvent{
225 wxActivateEvent(WXTYPE eventType = 0, int active = TRUE, int id = 0);
229 //---------------------------------------------------------------------------
231 class wxInitDialogEvent: public wxEvent {
233 wxInitDialogEvent(int id = 0);
236 //---------------------------------------------------------------------------
238 class wxMenuEvent: public wxEvent {
240 wxMenuEvent(WXTYPE id = 0, int id = 0);
244 //---------------------------------------------------------------------------
246 class wxShowEvent: public wxEvent {
248 wxShowEvent(int id = 0, int show = FALSE);
249 void SetShow(bool show);
253 //---------------------------------------------------------------------------
255 class wxIconizeEvent: public wxEvent {
257 wxIconizeEvent(int id = 0);
260 //---------------------------------------------------------------------------
262 class wxMaximizeEvent: public wxEvent {
264 wxMaximizeEvent(int id = 0);
267 //---------------------------------------------------------------------------
269 class wxJoystickEvent: public wxEvent {
271 wxJoystickEvent(int type = wxEVT_NULL,
273 int joystick = wxJOYSTICK1,
275 wxPoint GetPosition();
277 int GetButtonState();
278 int GetButtonChange();
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);
288 bool ButtonDown(int but = wxJOY_BUTTON_ANY);
289 bool ButtonUp(int but = wxJOY_BUTTON_ANY);
290 bool ButtonIsDown(int but = wxJOY_BUTTON_ANY);
293 //---------------------------------------------------------------------------
295 class wxDropFilesEvent: public wxEvent {
297 wxPoint GetPosition();
298 int GetNumberOfFiles();
301 PyObject* GetFiles() {
302 int count = self->GetNumberOfFiles();
303 wxString* files = self->GetFiles();
304 PyObject* list = PyList_New(count);
307 PyErr_SetString(PyExc_MemoryError, "Can't allocate list of files!");
311 for (int i=0; i<count; i++) {
312 PyList_SetItem(list, i, PyString_FromString((const char*)files[i]));
319 //---------------------------------------------------------------------------
321 class wxIdleEvent: public wxEvent {
324 void RequestMore(bool needMore = TRUE);
325 bool MoreRequested();
328 //---------------------------------------------------------------------------
330 class wxUpdateUIEvent: public wxEvent {
332 wxUpdateUIEvent(wxWindowID commandId = 0);
337 bool GetSetChecked();
338 bool GetSetEnabled();
340 void Check(bool check);
341 void Enable(bool enable);
342 void SetText(const wxString& text);
345 //---------------------------------------------------------------------------
347 class wxSysColourChangedEvent: public wxEvent {
349 wxSysColourChangedEvent();
352 //---------------------------------------------------------------------------
355 class wxNotifyEvent : public wxCommandEvent {
357 wxNotifyEvent(int commandType = wxEVT_NULL, int id = 0);
363 //---------------------------------------------------------------------------
365 class wxPaletteChangedEvent : public wxEvent {
367 wxPaletteChangedEvent(wxWindowID id = 0);
369 void SetChangedWindow(wxWindow* win);
370 wxWindow* GetChangedWindow();
374 //---------------------------------------------------------------------------
376 class wxQueryNewPaletteEvent : public wxEvent {
378 wxQueryNewPaletteEvent(wxWindowID id = 0);
380 void SetPaletteRealized(bool realized);
381 bool GetPaletteRealized();
385 //---------------------------------------------------------------------------
387 class wxWindowCreateEvent : public wxEvent {
389 wxWindowCreateEvent(wxWindow *win = NULL);
391 wxWindow *GetWindow();
394 class wxWindowDestroyEvent : public wxEvent {
396 wxWindowDestroyEvent(wxWindow *win = NULL);
398 wxWindow *GetWindow();
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
410 class wxPyEvent : public wxEvent {
411 DECLARE_DYNAMIC_CLASS(wxPyEvent)
413 wxPyEvent(int id=0, PyObject* userData = Py_None)
415 m_userData = userData;
416 Py_INCREF(m_userData);
420 bool doSave = wxPyRestoreThread();
421 Py_DECREF(m_userData);
422 wxPySaveThread(doSave);
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);
433 PyObject* GetPyData() const {
434 Py_INCREF(m_userData);
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);
445 PyObject* m_userData;
448 IMPLEMENT_DYNAMIC_CLASS(wxPyEvent, wxEvent)
453 class wxPyEvent : public wxEvent {
455 wxPyEvent(int id=0, PyObject* userData = Py_None);
458 void SetPyData(PyObject* userData);
459 PyObject* GetPyData();
462 //---------------------------------------------------------------------------
463 // Same for this one except it is a wxCommandEvent and so will get passed up the
464 // containment heirarchy.
467 class wxPyCommandEvent : public wxCommandEvent {
468 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent)
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);
476 ~wxPyCommandEvent() {
477 bool doSave = wxPyRestoreThread();
478 Py_DECREF(m_userData);
479 wxPySaveThread(doSave);
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);
490 PyObject* GetPyData() const {
491 Py_INCREF(m_userData);
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);
502 PyObject* m_userData;
505 IMPLEMENT_DYNAMIC_CLASS(wxPyCommandEvent, wxCommandEvent)
510 class wxPyCommandEvent : public wxCommandEvent {
512 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0, PyObject* userData = Py_None);
515 void SetPyData(PyObject* userData);
516 PyObject* GetPyData();
520 //---------------------------------------------------------------------------
521 //---------------------------------------------------------------------------