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 //---------------------------------------------------------------------------
33 enum Propagation_state
35 // don't propagate it at all
36 wxEVENT_PROPAGATE_NONE = 0,
38 // propagate it until it is processed
39 wxEVENT_PROPAGATE_MAX = INT_MAX
47 class wxEvent : public wxObject {
49 // wxEvent(int id = 0); // *** This class is now an ABC
52 wxObject* GetEventObject();
53 wxEventType GetEventType();
56 void SetEventObject(wxObject* object);
57 void SetEventType(wxEventType typ);
59 void SetTimestamp(long timeStamp);
61 bool IsCommandEvent() const;
63 // Can instruct event processor that we wish to ignore this event
64 // (treat as if the event table entry had not been found): this must be done
65 // to allow the event processing by the base classes (calling event.Skip()
66 // is the analog of calling the base class verstion of a virtual function)
67 void Skip(bool skip = TRUE);
68 bool GetSkipped() const;
70 // Determine if this event should be propagating to the parent window.
71 bool ShouldPropagate() const;
73 // Stop an event from propagating to its parent window, returns the old
74 // propagation level value
75 int StopPropagation();
77 // Resume the event propagation by restoring the propagation level
78 // (returned by StopPropagation())
79 void ResumePropagation(int propagationLevel);
84 //---------------------------------------------------------------------------
86 // Helper class to temporarily change an event not to propagate.
87 class wxPropagationDisabler
90 wxPropagationDisabler(wxEvent& event);
91 ~wxPropagationDisabler();
95 // Another one to temporarily lower propagation level.
99 wxPropagateOnce(wxEvent& event);
103 //---------------------------------------------------------------------------
105 class wxSizeEvent : public wxEvent {
107 wxSizeEvent(const wxSize& sz, int id = 0);
109 wxRect GetRect() const;
110 void SetRect(wxRect rect);
113 //---------------------------------------------------------------------------
115 class wxCloseEvent : public wxEvent {
117 wxCloseEvent(int commandEventType = 0, int id = 0);
119 void SetLoggingOff(bool loggingOff);
120 bool GetLoggingOff();
121 void Veto(bool veto = TRUE);
124 void SetCanVeto(bool canVeto);
127 //---------------------------------------------------------------------------
129 class wxCommandEvent : public wxEvent {
131 wxCommandEvent(int commandEventType = 0, int id = 0);
134 %name(Checked)bool IsChecked();
138 wxString GetString();
140 void SetString(const wxString& s);
141 void SetExtraLong(long extraLong);
145 PyObject* GetClientData() {
146 wxPyClientData* data = (wxPyClientData*)self->GetClientObject();
148 Py_INCREF(data->m_obj);
159 //---------------------------------------------------------------------------
161 class wxScrollEvent: public wxCommandEvent {
163 wxScrollEvent(int commandType = 0, int id = 0, int pos = 0,
164 int orientation = 0);
166 int GetOrientation();
170 //---------------------------------------------------------------------------
172 class wxScrollWinEvent: public wxEvent {
174 wxScrollWinEvent(int commandType = 0, int pos = 0,
175 int orientation = 0);
177 int GetOrientation();
181 //---------------------------------------------------------------------------
183 class wxSpinEvent : public wxScrollEvent {
185 wxSpinEvent(int commandType = 0, int id = 0);
189 //---------------------------------------------------------------------------
191 class wxMouseEvent: public wxEvent {
193 wxMouseEvent(int mouseEventType = 0);
196 bool ButtonDown(int but = -1);
197 bool ButtonDClick(int but = -1);
198 bool ButtonUp(int but = -1);
199 bool Button(int but);
200 bool ButtonIsDown(int but);
221 wxPoint GetPosition();
222 %name(GetPositionTuple)void GetPosition(long *OUTPUT, long *OUTPUT);
223 wxPoint GetLogicalPosition(const wxDC& dc);
227 int GetWheelRotation() const { return m_wheelRotation; }
228 int GetWheelDelta() const { return m_wheelDelta; }
229 int GetLinesPerAction() const { return m_linesPerAction; }
241 int m_linesPerAction;
244 //---------------------------------------------------------------------------
246 class wxMouseCaptureChangedEvent : public wxEvent
249 wxMouseCaptureChangedEvent(wxWindowID id = 0, wxWindow* gainedCapture = NULL);
250 wxWindow* GetCapturedWindow() const;
253 //---------------------------------------------------------------------------
255 class wxSetCursorEvent : public wxEvent
258 wxSetCursorEvent(wxCoord x = 0, wxCoord y = 0);
260 wxCoord GetX() const;
261 wxCoord GetY() const;
263 void SetCursor(const wxCursor& cursor);
264 const wxCursor& GetCursor() const;
265 bool HasCursor() const;
268 //---------------------------------------------------------------------------
270 class wxKeyEvent: public wxEvent {
272 wxKeyEvent(int keyEventType);
280 %pragma(python) addtoclass = "KeyCode = GetKeyCode"
283 // get the raw key code (platform-dependent)
284 long GetRawKeyCode() const;
286 // get the raw key flags (platform-dependent)
287 long GetRawKeyFlags() const;
291 wxPoint GetPosition();
292 %name(GetPositionTuple) void GetPosition(long* OUTPUT, long* OUTPUT);
306 //---------------------------------------------------------------------------
308 class wxNavigationKeyEvent : public wxEvent {
310 wxNavigationKeyEvent();
313 void SetDirection(bool bForward);
314 bool IsWindowChange();
315 void SetWindowChange(bool bIs);
316 wxWindow* GetCurrentFocus();
317 void SetCurrentFocus(wxWindow *win);
321 //---------------------------------------------------------------------------
323 class wxMoveEvent: public wxEvent {
325 wxMoveEvent(const wxPoint& pt, int id = 0);
326 wxPoint GetPosition();
327 wxRect GetRect() const;
328 void SetRect(wxRect rect);
331 //---------------------------------------------------------------------------
333 class wxPaintEvent: public wxEvent {
335 wxPaintEvent(int id = 0);
339 //---------------------------------------------------------------------------
341 class wxEraseEvent: public wxEvent {
343 wxEraseEvent(int id = 0, wxDC* dc = NULL);
348 //---------------------------------------------------------------------------
350 class wxFocusEvent: public wxEvent {
352 wxFocusEvent(int eventType = 0, int id = 0);
355 //---------------------------------------------------------------------------
357 // wxChildFocusEvent notifies the parent that a child has got the focus: unlike
358 // wxFocusEvent it is propgated upwards the window chain
359 class wxChildFocusEvent : public wxCommandEvent
362 wxChildFocusEvent(wxWindow *win = NULL);
363 wxWindow *GetWindow() const;
367 //---------------------------------------------------------------------------
369 class wxActivateEvent: public wxEvent{
371 wxActivateEvent(int eventType = 0, int active = TRUE, int id = 0);
375 //---------------------------------------------------------------------------
377 class wxInitDialogEvent: public wxEvent {
379 wxInitDialogEvent(int id = 0);
382 //---------------------------------------------------------------------------
384 class wxMenuEvent: public wxEvent {
386 wxMenuEvent(int id = 0, int winid = 0, wxMenu* menu = NULL);
389 wxMenu* GetMenu() const;
392 //---------------------------------------------------------------------------
394 class wxShowEvent: public wxEvent {
396 wxShowEvent(int id = 0, int show = FALSE);
397 void SetShow(bool show);
401 //---------------------------------------------------------------------------
403 class wxIconizeEvent: public wxEvent {
405 wxIconizeEvent(int id = 0, bool iconized = TRUE);
409 //---------------------------------------------------------------------------
411 class wxMaximizeEvent: public wxEvent {
413 wxMaximizeEvent(int id = 0);
416 //---------------------------------------------------------------------------
418 class wxJoystickEvent: public wxEvent {
420 wxJoystickEvent(int type = wxEVT_NULL,
422 int joystick = wxJOYSTICK1,
424 wxPoint GetPosition();
426 int GetButtonState();
427 int GetButtonChange();
429 void SetJoystick(int stick);
430 void SetButtonState(int state);
431 void SetButtonChange(int change);
432 void SetPosition(const wxPoint& pos);
433 void SetZPosition(int zPos);
437 bool ButtonDown(int but = wxJOY_BUTTON_ANY);
438 bool ButtonUp(int but = wxJOY_BUTTON_ANY);
439 bool ButtonIsDown(int but = wxJOY_BUTTON_ANY);
442 //---------------------------------------------------------------------------
444 class wxDropFilesEvent: public wxEvent {
446 wxPoint GetPosition();
447 int GetNumberOfFiles();
450 PyObject* GetFiles() {
451 int count = self->GetNumberOfFiles();
452 wxString* files = self->GetFiles();
453 PyObject* list = PyList_New(count);
456 PyErr_SetString(PyExc_MemoryError, "Can't allocate list of files!");
460 for (int i=0; i<count; i++) {
462 PyList_SetItem(list, i, PyUnicode_FromWideChar(files[i], files[i].Len()));
464 PyList_SetItem(list, i, PyString_FromString((const char*)files[i]));
472 //---------------------------------------------------------------------------
474 // Whether to always send idle events to windows, or
475 // to only send update events to those with the
476 // wxWS_EX_PROCESS_IDLE style.
480 // Send idle events to all windows
483 // Send idle events to windows that have
484 // the wxWS_EX_PROCESS_IDLE flag specified
485 wxIDLE_PROCESS_SPECIFIED
489 class wxIdleEvent: public wxEvent {
492 void RequestMore(bool needMore = TRUE);
493 bool MoreRequested();
495 // Specify how wxWindows will send idle events: to
496 // all windows, or only to those which specify that they
497 // will process the events.
498 static void SetMode(wxIdleMode mode) { sm_idleMode = mode; }
500 // Returns the idle event mode
501 static wxIdleMode GetMode() { return sm_idleMode ; }
503 // Can we send an idle event?
504 static bool CanSend(wxWindow* win) ;
508 //---------------------------------------------------------------------------
510 // Whether to always send update events to windows, or
511 // to only send update events to those with the
512 // wxWS_EX_PROCESS_UI_UPDATES style.
516 // Send UI update events to all windows
517 wxUPDATE_UI_PROCESS_ALL,
519 // Send UI update events to windows that have
520 // the wxWS_EX_PROCESS_UI_UPDATES flag specified
521 wxUPDATE_UI_PROCESS_SPECIFIED
525 class wxUpdateUIEvent: public wxEvent {
527 wxUpdateUIEvent(wxWindowID commandId = 0);
532 bool GetSetChecked();
533 bool GetSetEnabled();
535 void Check(bool check);
536 void Enable(bool enable);
537 void SetText(const wxString& text);
540 // Sets the interval between updates in milliseconds.
541 // Set to -1 to disable updates, or to 0 to update as frequently as possible.
542 static void SetUpdateInterval(long updateInterval);
544 // Returns the current interval between updates in milliseconds
545 static long GetUpdateInterval();
547 // Can we update this window?
548 static bool CanUpdate(wxWindow* win);
550 // Reset the update time to provide a delay until the next
551 // time we should update
552 static void ResetUpdateTime();
554 // Specify how wxWindows will send update events: to
555 // all windows, or only to those which specify that they
556 // will process the events.
557 static void SetMode(wxUpdateUIMode mode);
559 // Returns the UI update mode
560 static wxUpdateUIMode GetMode();
563 //---------------------------------------------------------------------------
565 class wxSysColourChangedEvent: public wxEvent {
567 wxSysColourChangedEvent();
570 //---------------------------------------------------------------------------
573 class wxNotifyEvent : public wxCommandEvent {
575 wxNotifyEvent(int commandType = wxEVT_NULL, int id = 0);
582 //---------------------------------------------------------------------------
584 class wxDisplayChangedEvent : public wxEvent
587 wxDisplayChangedEvent();
591 //---------------------------------------------------------------------------
593 class wxPaletteChangedEvent : public wxEvent {
595 wxPaletteChangedEvent(wxWindowID id = 0);
597 void SetChangedWindow(wxWindow* win);
598 wxWindow* GetChangedWindow();
602 //---------------------------------------------------------------------------
604 class wxQueryNewPaletteEvent : public wxEvent {
606 wxQueryNewPaletteEvent(wxWindowID id = 0);
608 void SetPaletteRealized(bool realized);
609 bool GetPaletteRealized();
613 //---------------------------------------------------------------------------
615 class wxWindowCreateEvent : public wxCommandEvent {
617 wxWindowCreateEvent(wxWindow *win = NULL);
619 wxWindow *GetWindow();
622 class wxWindowDestroyEvent : public wxCommandEvent {
624 wxWindowDestroyEvent(wxWindow *win = NULL);
626 wxWindow *GetWindow();
629 //---------------------------------------------------------------------------
631 class wxContextMenuEvent : public wxCommandEvent
634 wxContextMenuEvent(wxEventType type = wxEVT_NULL,
636 const wxPoint& pt = wxDefaultPosition);
637 const wxPoint& GetPosition();
638 void SetPosition(const wxPoint& pos);
641 //----------------------------------------------------------------------
643 class wxTimerEvent : public wxEvent
646 wxTimerEvent(int id = 0, int interval = 0);
650 //---------------------------------------------------------------------------
652 class wxTextUrlEvent : public wxCommandEvent
655 wxTextUrlEvent(int id, const wxMouseEvent& evtMouse,
656 long start, long end);
657 const wxMouseEvent& GetMouseEvent();
662 //---------------------------------------------------------------------------
663 //---------------------------------------------------------------------------
664 // These classes can be derived from in Python and passed through the event
665 // system without loosing anything. They do this by keeping a reference to
666 // themselves and some special case handling in wxPyCallback::EventThunker.
668 class wxPyEvent : public wxEvent {
670 wxPyEvent(int winid=0, wxEventType commandType = wxEVT_NULL );
673 %pragma(python) addtomethod = "__init__:self.SetSelf(self)"
675 void SetSelf(PyObject* self);
680 class wxPyCommandEvent : public wxCommandEvent {
682 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
685 %pragma(python) addtomethod = "__init__:self.SetSelf(self)"
687 void SetSelf(PyObject* self);
694 //---------------------------------------------------------------------------
695 //---------------------------------------------------------------------------