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.
31 //---------------------------------------------------------------------------
36 class wxEvent : public wxObject {
38 // wxEvent(int id = 0); // *** This class is now an ABC
41 wxObject* GetEventObject();
42 wxEventType GetEventType();
46 void SetEventObject(wxObject* object);
47 void SetEventType(wxEventType typ);
49 void SetTimestamp(long timeStamp);
50 void Skip(bool skip = TRUE);
55 //---------------------------------------------------------------------------
57 class wxSizeEvent : public wxEvent {
59 wxSizeEvent(const wxSize& sz, int id = 0);
63 //---------------------------------------------------------------------------
65 class wxCloseEvent : public wxEvent {
67 wxCloseEvent(int commandEventType = 0, int id = 0);
69 void SetLoggingOff(bool loggingOff);
71 void Veto(bool veto = TRUE);
74 void SetCanVeto(bool canVeto);
77 //---------------------------------------------------------------------------
79 class wxCommandEvent : public wxEvent {
81 wxCommandEvent(int commandEventType = 0, int id = 0);
84 %name(Checked)bool IsChecked();
90 void SetString(const wxString& s);
91 void SetExtraLong(long extraLong);
95 PyObject* GetClientData() {
96 wxPyClientData* data = (wxPyClientData*)self->GetClientObject();
98 Py_INCREF(data->m_obj);
109 //---------------------------------------------------------------------------
111 class wxScrollEvent: public wxCommandEvent {
113 wxScrollEvent(int commandType = 0, int id = 0, int pos = 0,
114 int orientation = 0);
116 int GetOrientation();
120 //---------------------------------------------------------------------------
122 class wxScrollWinEvent: public wxEvent {
124 wxScrollWinEvent(int commandType = 0, int pos = 0,
125 int orientation = 0);
127 int GetOrientation();
131 //---------------------------------------------------------------------------
133 class wxSpinEvent : public wxScrollEvent {
135 wxSpinEvent(int commandType = 0, int id = 0);
139 //---------------------------------------------------------------------------
141 class wxMouseEvent: public wxEvent {
143 wxMouseEvent(int mouseEventType = 0);
146 bool ButtonDown(int but = -1);
147 bool ButtonDClick(int but = -1);
148 bool ButtonUp(int but = -1);
149 bool Button(int but);
150 bool ButtonIsDown(int but);
171 wxPoint GetPosition();
172 %name(GetPositionTuple)void GetPosition(long *OUTPUT, long *OUTPUT);
173 wxPoint GetLogicalPosition(const wxDC& dc);
177 int GetWheelRotation() const { return m_wheelRotation; }
178 int GetWheelDelta() const { return m_wheelDelta; }
179 int GetLinesPerAction() const { return m_linesPerAction; }
191 int m_linesPerAction;
194 //---------------------------------------------------------------------------
196 class wxMouseCaptureChangedEvent : public wxEvent
199 wxMouseCaptureChangedEvent(wxWindowID id = 0, wxWindow* gainedCapture = NULL);
200 wxWindow* GetCapturedWindow() const;
203 //---------------------------------------------------------------------------
205 class wxSetCursorEvent : public wxEvent
208 wxSetCursorEvent(wxCoord x = 0, wxCoord y = 0);
210 wxCoord GetX() const;
211 wxCoord GetY() const;
213 void SetCursor(const wxCursor& cursor);
214 const wxCursor& GetCursor() const;
215 bool HasCursor() const;
218 //---------------------------------------------------------------------------
220 class wxKeyEvent: public wxEvent {
222 wxKeyEvent(int keyEventType);
233 // get the raw key code (platform-dependent)
234 long GetRawKeyCode() const;
236 // get the raw key flags (platform-dependent)
237 long GetRawKeyFlags() const;
241 wxPoint GetPosition();
242 %name(GetPositionTuple) void GetPosition(long* OUTPUT, long* OUTPUT);
256 //---------------------------------------------------------------------------
258 class wxNavigationKeyEvent : public wxEvent {
260 wxNavigationKeyEvent();
263 void SetDirection(bool bForward);
264 bool IsWindowChange();
265 void SetWindowChange(bool bIs);
266 wxWindow* GetCurrentFocus();
267 void SetCurrentFocus(wxWindow *win);
271 //---------------------------------------------------------------------------
273 class wxMoveEvent: public wxEvent {
275 wxMoveEvent(const wxPoint& pt, int id = 0);
277 wxPoint GetPosition();
280 //---------------------------------------------------------------------------
282 class wxPaintEvent: public wxEvent {
284 wxPaintEvent(int id = 0);
288 //---------------------------------------------------------------------------
290 class wxEraseEvent: public wxEvent {
292 wxEraseEvent(int id = 0, wxDC* dc = NULL);
297 //---------------------------------------------------------------------------
299 class wxFocusEvent: public wxEvent {
301 wxFocusEvent(WXTYPE eventType = 0, int id = 0);
304 //---------------------------------------------------------------------------
306 // wxChildFocusEvent notifies the parent that a child has got the focus: unlike
307 // wxFocusEvent it is propgated upwards the window chain
308 class wxChildFocusEvent : public wxCommandEvent
311 wxChildFocusEvent(wxWindow *win = NULL);
312 wxWindow *GetWindow() const;
316 //---------------------------------------------------------------------------
318 class wxActivateEvent: public wxEvent{
320 wxActivateEvent(WXTYPE eventType = 0, int active = TRUE, int id = 0);
324 //---------------------------------------------------------------------------
326 class wxInitDialogEvent: public wxEvent {
328 wxInitDialogEvent(int id = 0);
331 //---------------------------------------------------------------------------
333 class wxMenuEvent: public wxEvent {
335 wxMenuEvent(WXTYPE id = 0, int id = 0);
340 //---------------------------------------------------------------------------
342 class wxShowEvent: public wxEvent {
344 wxShowEvent(int id = 0, int show = FALSE);
345 void SetShow(bool show);
349 //---------------------------------------------------------------------------
351 class wxIconizeEvent: public wxEvent {
353 wxIconizeEvent(int id = 0, bool iconized = TRUE);
357 //---------------------------------------------------------------------------
359 class wxMaximizeEvent: public wxEvent {
361 wxMaximizeEvent(int id = 0);
364 //---------------------------------------------------------------------------
366 class wxJoystickEvent: public wxEvent {
368 wxJoystickEvent(int type = wxEVT_NULL,
370 int joystick = wxJOYSTICK1,
372 wxPoint GetPosition();
374 int GetButtonState();
375 int GetButtonChange();
377 void SetJoystick(int stick);
378 void SetButtonState(int state);
379 void SetButtonChange(int change);
380 void SetPosition(const wxPoint& pos);
381 void SetZPosition(int zPos);
385 bool ButtonDown(int but = wxJOY_BUTTON_ANY);
386 bool ButtonUp(int but = wxJOY_BUTTON_ANY);
387 bool ButtonIsDown(int but = wxJOY_BUTTON_ANY);
390 //---------------------------------------------------------------------------
392 class wxDropFilesEvent: public wxEvent {
394 wxPoint GetPosition();
395 int GetNumberOfFiles();
398 PyObject* GetFiles() {
399 int count = self->GetNumberOfFiles();
400 wxString* files = self->GetFiles();
401 PyObject* list = PyList_New(count);
404 PyErr_SetString(PyExc_MemoryError, "Can't allocate list of files!");
408 for (int i=0; i<count; i++) {
410 PyList_SetItem(list, i, PyUnicode_FromUnicode(files[i], files[i].Len()));
412 PyList_SetItem(list, i, PyString_FromString((const char*)files[i]));
420 //---------------------------------------------------------------------------
422 class wxIdleEvent: public wxEvent {
425 void RequestMore(bool needMore = TRUE);
426 bool MoreRequested();
429 //---------------------------------------------------------------------------
431 class wxUpdateUIEvent: public wxEvent {
433 wxUpdateUIEvent(wxWindowID commandId = 0);
438 bool GetSetChecked();
439 bool GetSetEnabled();
441 void Check(bool check);
442 void Enable(bool enable);
443 void SetText(const wxString& text);
446 //---------------------------------------------------------------------------
448 class wxSysColourChangedEvent: public wxEvent {
450 wxSysColourChangedEvent();
453 //---------------------------------------------------------------------------
456 class wxNotifyEvent : public wxCommandEvent {
458 wxNotifyEvent(int commandType = wxEVT_NULL, int id = 0);
465 //---------------------------------------------------------------------------
467 class wxDisplayChangedEvent : public wxEvent
470 wxDisplayChangedEvent();
474 //---------------------------------------------------------------------------
476 class wxPaletteChangedEvent : public wxEvent {
478 wxPaletteChangedEvent(wxWindowID id = 0);
480 void SetChangedWindow(wxWindow* win);
481 wxWindow* GetChangedWindow();
485 //---------------------------------------------------------------------------
487 class wxQueryNewPaletteEvent : public wxEvent {
489 wxQueryNewPaletteEvent(wxWindowID id = 0);
491 void SetPaletteRealized(bool realized);
492 bool GetPaletteRealized();
496 //---------------------------------------------------------------------------
498 class wxWindowCreateEvent : public wxCommandEvent {
500 wxWindowCreateEvent(wxWindow *win = NULL);
502 wxWindow *GetWindow();
505 class wxWindowDestroyEvent : public wxCommandEvent {
507 wxWindowDestroyEvent(wxWindow *win = NULL);
509 wxWindow *GetWindow();
512 //---------------------------------------------------------------------------
514 class wxContextMenuEvent : public wxCommandEvent
517 wxContextMenuEvent(wxEventType type = wxEVT_NULL,
519 const wxPoint& pt = wxDefaultPosition);
520 const wxPoint& GetPosition();
521 void SetPosition(const wxPoint& pos);
524 //----------------------------------------------------------------------
526 class wxTimerEvent : public wxEvent
529 wxTimerEvent(int id = 0, int interval = 0);
533 //---------------------------------------------------------------------------
535 class wxTextUrlEvent : public wxCommandEvent
538 wxTextUrlEvent(int id, const wxMouseEvent& evtMouse,
539 long start, long end);
540 const wxMouseEvent& GetMouseEvent();
545 //---------------------------------------------------------------------------
546 //---------------------------------------------------------------------------
547 // These classes can be derived from in Python and passed through the event
548 // system without loosing anything. They do this by keeping a reference to
549 // themselves and some special case handling in wxPyCallback::EventThunker.
551 class wxPyEvent : public wxEvent {
556 %pragma(python) addtomethod = "__init__:self.SetSelf(self)"
558 void SetSelf(PyObject* self);
563 class wxPyCommandEvent : public wxCommandEvent {
565 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
568 %pragma(python) addtomethod = "__init__:self.SetSelf(self)"
570 void SetSelf(PyObject* self);
577 //---------------------------------------------------------------------------
578 //---------------------------------------------------------------------------