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 //---------------------------------------------------------------------------
34 wxObject* GetEventObject();
35 wxEventType GetEventType();
39 void SetEventObject(wxObject* object);
40 void SetEventType(wxEventType typ);
42 void SetTimestamp(long timeStamp);
43 void Skip(bool skip = TRUE);
46 //---------------------------------------------------------------------------
48 class wxSizeEvent : public wxEvent {
53 //---------------------------------------------------------------------------
55 class wxCloseEvent : public wxEvent {
57 void SetLoggingOff(bool loggingOff);
59 void Veto(bool veto = TRUE);
62 void SetCanVeto(bool canVeto);
65 //---------------------------------------------------------------------------
67 class wxCommandEvent : public wxEvent {
78 //---------------------------------------------------------------------------
80 class wxScrollEvent: public wxCommandEvent {
86 //---------------------------------------------------------------------------
88 class wxScrollWinEvent: public wxEvent {
94 //---------------------------------------------------------------------------
96 class wxSpinEvent : public wxScrollEvent {
101 //---------------------------------------------------------------------------
103 class wxMouseEvent: public wxEvent {
106 bool ButtonDown(int but = -1);
107 bool ButtonDClick(int but = -1);
108 bool ButtonUp(int but = -1);
109 bool Button(int but);
110 bool ButtonIsDown(int but);
131 void Position(long *OUTPUT, long *OUTPUT);
132 wxPoint GetPosition();
133 wxPoint GetLogicalPosition(const wxDC& dc);
138 //---------------------------------------------------------------------------
140 class wxKeyEvent: public wxEvent {
150 //---------------------------------------------------------------------------
152 // class wxNavigationKeyEvent : public wxCommandEvent {
154 // wxNavigationKeyEvent();
156 // bool GetDirection();
157 // void SetDirection(bool bForward);
158 // bool IsWindowChange();
159 // void SetWindowChange(bool bIs);
160 // wxWindow* GetCurrentFocus();
161 // void SetCurrentFocus(wxWindow *win);
165 //---------------------------------------------------------------------------
167 class wxMoveEvent: public wxEvent {
169 wxPoint GetPosition();
172 //---------------------------------------------------------------------------
174 class wxPaintEvent: public wxEvent {
179 //---------------------------------------------------------------------------
181 class wxEraseEvent: public wxEvent {
186 //---------------------------------------------------------------------------
188 class wxFocusEvent: public wxEvent {
193 //---------------------------------------------------------------------------
195 class wxActivateEvent: public wxEvent{
200 //---------------------------------------------------------------------------
202 class wxInitDialogEvent: public wxEvent {
207 //---------------------------------------------------------------------------
209 class wxMenuEvent: public wxEvent {
214 //---------------------------------------------------------------------------
216 class wxShowEvent: public wxEvent {
218 void SetShow(bool show);
222 //---------------------------------------------------------------------------
224 class wxIconizeEvent: public wxEvent {
228 //---------------------------------------------------------------------------
230 class wxMaximizeEvent: public wxEvent {
235 //---------------------------------------------------------------------------
237 class wxJoystickEvent: public wxEvent {
239 wxPoint GetPosition();
241 int GetButtonState();
242 int GetButtonChange();
244 void SetJoystick(int stick);
245 void SetButtonState(int state);
246 void SetButtonChange(int change);
247 void SetPosition(const wxPoint& pos);
248 void SetZPosition(int zPos);
252 bool ButtonDown(int but = wxJOY_BUTTON_ANY);
253 bool ButtonUp(int but = wxJOY_BUTTON_ANY);
254 bool ButtonIsDown(int but = wxJOY_BUTTON_ANY);
257 //---------------------------------------------------------------------------
259 class wxDropFilesEvent: public wxEvent {
261 wxPoint GetPosition();
262 int GetNumberOfFiles();
265 PyObject* GetFiles() {
266 int count = self->GetNumberOfFiles();
267 wxString* files = self->GetFiles();
268 PyObject* list = PyList_New(count);
271 PyErr_SetString(PyExc_MemoryError, "Can't allocate list of files!");
275 for (int i=0; i<count; i++) {
276 PyList_SetItem(list, i, PyString_FromString((const char*)files[i]));
283 //---------------------------------------------------------------------------
285 class wxIdleEvent: public wxEvent {
287 void RequestMore(bool needMore = TRUE);
288 bool MoreRequested();
291 //---------------------------------------------------------------------------
293 class wxUpdateUIEvent: public wxEvent {
299 bool GetSetChecked();
300 bool GetSetEnabled();
302 void Check(bool check);
303 void Enable(bool enable);
304 void SetText(const wxString& text);
307 //---------------------------------------------------------------------------
309 class wxSysColourChangedEvent: public wxEvent {
314 //---------------------------------------------------------------------------
317 class wxNotifyEvent : public wxCommandEvent {
324 //---------------------------------------------------------------------------
325 //---------------------------------------------------------------------------
326 // This one can be derived from in Python and passed through the event
327 // system without loosing anything so long as the Python data is saved with
331 class wxPyEvent : public wxEvent {
332 DECLARE_DYNAMIC_CLASS(wxPyEvent)
334 wxPyEvent(int id=0, PyObject* userData = Py_None)
336 m_userData = userData;
337 Py_INCREF(m_userData);
341 bool doSave = wxPyRestoreThread();
342 Py_DECREF(m_userData);
343 wxPySaveThread(doSave);
346 void SetPyData(PyObject* userData) {
347 bool doSave = wxPyRestoreThread();
348 Py_DECREF(m_userData);
349 m_userData = userData;
350 Py_INCREF(m_userData);
351 wxPySaveThread(doSave);
354 PyObject* GetPyData() const {
355 Py_INCREF(m_userData);
359 // This one is so the event object can be Cloned...
360 void CopyObject(wxObject& dest) const {
361 wxEvent::CopyObject(dest);
362 ((wxPyEvent*)&dest)->SetPyData(m_userData);
366 PyObject* m_userData;
369 IMPLEMENT_DYNAMIC_CLASS(wxPyEvent, wxEvent)
374 class wxPyEvent : public wxEvent {
376 wxPyEvent(int id=0, PyObject* userData = Py_None);
379 void SetPyData(PyObject* userData);
380 PyObject* GetPyData();
383 //---------------------------------------------------------------------------
384 // Same for this one except it is a wxCommandEvent and so will get passed up the
385 // containment heirarchy.
388 class wxPyCommandEvent : public wxCommandEvent {
389 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent)
391 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0, PyObject* userData = Py_None)
392 : wxCommandEvent(commandType, id) {
393 m_userData = userData;
394 Py_INCREF(m_userData);
397 ~wxPyCommandEvent() {
398 bool doSave = wxPyRestoreThread();
399 Py_DECREF(m_userData);
400 wxPySaveThread(doSave);
403 void SetPyData(PyObject* userData) {
404 bool doSave = wxPyRestoreThread();
405 Py_DECREF(m_userData);
406 m_userData = userData;
407 Py_INCREF(m_userData);
408 wxPySaveThread(doSave);
411 PyObject* GetPyData() const {
412 Py_INCREF(m_userData);
416 // This one is so the event object can be Cloned...
417 void CopyObject(wxObject& dest) const {
418 wxCommandEvent::CopyObject(dest);
419 ((wxPyCommandEvent*)&dest)->SetPyData(m_userData);
423 PyObject* m_userData;
426 IMPLEMENT_DYNAMIC_CLASS(wxPyCommandEvent, wxCommandEvent)
431 class wxPyCommandEvent : public wxCommandEvent {
433 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0, PyObject* userData = Py_None);
436 void SetPyData(PyObject* userData);
437 PyObject* GetPyData();
441 //---------------------------------------------------------------------------
442 //---------------------------------------------------------------------------