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 winid = 0, wxEventType commandType = wxEVT_NULL); // *** This class is now an ABC
52 void SetEventType(wxEventType typ);
53 wxEventType GetEventType() const;
54 wxObject *GetEventObject() const;
55 void SetEventObject(wxObject *obj);
56 long GetTimestamp() const;
57 void SetTimestamp(long ts = 0);
62 bool IsCommandEvent() const;
64 // Can instruct event processor that we wish to ignore this event
65 // (treat as if the event table entry had not been found): this must be done
66 // to allow the event processing by the base classes (calling event.Skip()
67 // is the analog of calling the base class verstion of a virtual function)
68 void Skip(bool skip = TRUE);
69 bool GetSkipped() const;
71 // Determine if this event should be propagating to the parent window.
72 bool ShouldPropagate() const;
74 // Stop an event from propagating to its parent window, returns the old
75 // propagation level value
76 int StopPropagation();
78 // Resume the event propagation by restoring the propagation level
79 // (returned by StopPropagation())
80 void ResumePropagation(int propagationLevel);
82 // this function is used to create a copy of the event polymorphically and
83 // all derived classes must implement it because otherwise wxPostEvent()
84 // for them wouldn't work (it needs to do a copy of the event)
85 virtual wxEvent *Clone() /* =0*/;
88 //---------------------------------------------------------------------------
90 // Helper class to temporarily change an event not to propagate.
91 class wxPropagationDisabler
94 wxPropagationDisabler(wxEvent& event);
95 ~wxPropagationDisabler();
99 // Another one to temporarily lower propagation level.
100 class wxPropagateOnce
103 wxPropagateOnce(wxEvent& event);
107 //---------------------------------------------------------------------------
109 class wxSizeEvent : public wxEvent {
111 wxSizeEvent(const wxSize& sz, int id = 0);
113 wxRect GetRect() const;
114 void SetRect(wxRect rect);
117 //---------------------------------------------------------------------------
119 class wxCloseEvent : public wxEvent {
121 wxCloseEvent(int commandEventType = 0, int id = 0);
123 void SetLoggingOff(bool loggingOff);
124 bool GetLoggingOff();
125 void Veto(bool veto = TRUE);
128 void SetCanVeto(bool canVeto);
131 //---------------------------------------------------------------------------
133 class wxCommandEvent : public wxEvent {
135 wxCommandEvent(int commandEventType = 0, int id = 0);
138 %name(Checked)bool IsChecked();
142 wxString GetString();
144 void SetString(const wxString& s);
145 void SetExtraLong(long extraLong);
149 PyObject* GetClientData() {
150 wxPyClientData* data = (wxPyClientData*)self->GetClientObject();
152 Py_INCREF(data->m_obj);
163 //---------------------------------------------------------------------------
165 class wxScrollEvent: public wxCommandEvent {
167 wxScrollEvent(int commandType = 0, int id = 0, int pos = 0,
168 int orientation = 0);
170 int GetOrientation();
174 //---------------------------------------------------------------------------
176 class wxScrollWinEvent: public wxEvent {
178 wxScrollWinEvent(int commandType = 0, int pos = 0,
179 int orientation = 0);
181 int GetOrientation();
185 //---------------------------------------------------------------------------
187 class wxSpinEvent : public wxScrollEvent {
189 wxSpinEvent(int commandType = 0, int id = 0);
193 //---------------------------------------------------------------------------
195 class wxMouseEvent: public wxEvent {
197 wxMouseEvent(int mouseEventType = 0);
200 bool ButtonDown(int but = -1);
201 bool ButtonDClick(int but = -1);
202 bool ButtonUp(int but = -1);
203 bool Button(int but);
204 bool ButtonIsDown(int but);
225 wxPoint GetPosition();
226 %name(GetPositionTuple)void GetPosition(long *OUTPUT, long *OUTPUT);
227 wxPoint GetLogicalPosition(const wxDC& dc);
231 int GetWheelRotation() const { return m_wheelRotation; }
232 int GetWheelDelta() const { return m_wheelDelta; }
233 int GetLinesPerAction() const { return m_linesPerAction; }
245 int m_linesPerAction;
248 //---------------------------------------------------------------------------
250 class wxMouseCaptureChangedEvent : public wxEvent
253 wxMouseCaptureChangedEvent(wxWindowID id = 0, wxWindow* gainedCapture = NULL);
254 wxWindow* GetCapturedWindow() const;
257 //---------------------------------------------------------------------------
259 class wxSetCursorEvent : public wxEvent
262 wxSetCursorEvent(wxCoord x = 0, wxCoord y = 0);
264 wxCoord GetX() const;
265 wxCoord GetY() const;
267 void SetCursor(const wxCursor& cursor);
268 const wxCursor& GetCursor() const;
269 bool HasCursor() const;
272 //---------------------------------------------------------------------------
274 class wxKeyEvent: public wxEvent {
276 wxKeyEvent(int keyEventType);
284 %pragma(python) addtoclass = "KeyCode = GetKeyCode"
287 // get the raw key code (platform-dependent)
288 long GetRawKeyCode() const;
290 // get the raw key flags (platform-dependent)
291 long GetRawKeyFlags() const;
295 wxPoint GetPosition();
296 %name(GetPositionTuple) void GetPosition(long* OUTPUT, long* OUTPUT);
310 //---------------------------------------------------------------------------
312 class wxNavigationKeyEvent : public wxEvent {
314 wxNavigationKeyEvent();
317 void SetDirection(bool bForward);
318 bool IsWindowChange();
319 void SetWindowChange(bool bIs);
320 wxWindow* GetCurrentFocus();
321 void SetCurrentFocus(wxWindow *win);
325 //---------------------------------------------------------------------------
327 class wxMoveEvent: public wxEvent {
329 wxMoveEvent(const wxPoint& pt, int id = 0);
330 wxPoint GetPosition();
331 wxRect GetRect() const;
332 void SetRect(wxRect rect);
335 //---------------------------------------------------------------------------
337 class wxPaintEvent: public wxEvent {
339 wxPaintEvent(int id = 0);
343 //---------------------------------------------------------------------------
345 class wxEraseEvent: public wxEvent {
347 wxEraseEvent(int id = 0, wxDC* dc = NULL);
352 //---------------------------------------------------------------------------
354 class wxFocusEvent: public wxEvent {
356 wxFocusEvent(int eventType = 0, int id = 0);
359 //---------------------------------------------------------------------------
361 // wxChildFocusEvent notifies the parent that a child has got the focus: unlike
362 // wxFocusEvent it is propgated upwards the window chain
363 class wxChildFocusEvent : public wxCommandEvent
366 wxChildFocusEvent(wxWindow *win = NULL);
367 wxWindow *GetWindow() const;
371 //---------------------------------------------------------------------------
373 class wxActivateEvent: public wxEvent{
375 wxActivateEvent(int eventType = 0, int active = TRUE, int id = 0);
379 //---------------------------------------------------------------------------
381 class wxInitDialogEvent: public wxEvent {
383 wxInitDialogEvent(int id = 0);
386 //---------------------------------------------------------------------------
388 class wxMenuEvent: public wxEvent {
390 wxMenuEvent(int id = 0, int winid = 0, wxMenu* menu = NULL);
393 wxMenu* GetMenu() const;
396 //---------------------------------------------------------------------------
398 class wxShowEvent: public wxEvent {
400 wxShowEvent(int id = 0, int show = FALSE);
401 void SetShow(bool show);
405 //---------------------------------------------------------------------------
407 class wxIconizeEvent: public wxEvent {
409 wxIconizeEvent(int id = 0, bool iconized = TRUE);
413 //---------------------------------------------------------------------------
415 class wxMaximizeEvent: public wxEvent {
417 wxMaximizeEvent(int id = 0);
420 //---------------------------------------------------------------------------
422 class wxJoystickEvent: public wxEvent {
424 wxJoystickEvent(int type = wxEVT_NULL,
426 int joystick = wxJOYSTICK1,
428 wxPoint GetPosition();
430 int GetButtonState();
431 int GetButtonChange();
433 void SetJoystick(int stick);
434 void SetButtonState(int state);
435 void SetButtonChange(int change);
436 void SetPosition(const wxPoint& pos);
437 void SetZPosition(int zPos);
441 bool ButtonDown(int but = wxJOY_BUTTON_ANY);
442 bool ButtonUp(int but = wxJOY_BUTTON_ANY);
443 bool ButtonIsDown(int but = wxJOY_BUTTON_ANY);
446 //---------------------------------------------------------------------------
448 class wxDropFilesEvent: public wxEvent {
450 wxPoint GetPosition();
451 int GetNumberOfFiles();
454 PyObject* GetFiles() {
455 int count = self->GetNumberOfFiles();
456 wxString* files = self->GetFiles();
457 PyObject* list = PyList_New(count);
460 PyErr_SetString(PyExc_MemoryError, "Can't allocate list of files!");
464 for (int i=0; i<count; i++) {
466 PyList_SetItem(list, i, PyUnicode_FromWideChar(files[i], files[i].Len()));
468 PyList_SetItem(list, i, PyString_FromString((const char*)files[i]));
476 //---------------------------------------------------------------------------
478 // Whether to always send idle events to windows, or
479 // to only send update events to those with the
480 // wxWS_EX_PROCESS_IDLE style.
484 // Send idle events to all windows
487 // Send idle events to windows that have
488 // the wxWS_EX_PROCESS_IDLE flag specified
489 wxIDLE_PROCESS_SPECIFIED
493 class wxIdleEvent: public wxEvent {
496 void RequestMore(bool needMore = TRUE);
497 bool MoreRequested();
499 // Specify how wxWindows will send idle events: to
500 // all windows, or only to those which specify that they
501 // will process the events.
502 static void SetMode(wxIdleMode mode) { sm_idleMode = mode; }
504 // Returns the idle event mode
505 static wxIdleMode GetMode() { return sm_idleMode ; }
507 // Can we send an idle event?
508 static bool CanSend(wxWindow* win) ;
512 //---------------------------------------------------------------------------
514 // Whether to always send update events to windows, or
515 // to only send update events to those with the
516 // wxWS_EX_PROCESS_UI_UPDATES style.
520 // Send UI update events to all windows
521 wxUPDATE_UI_PROCESS_ALL,
523 // Send UI update events to windows that have
524 // the wxWS_EX_PROCESS_UI_UPDATES flag specified
525 wxUPDATE_UI_PROCESS_SPECIFIED
529 class wxUpdateUIEvent: public wxEvent {
531 wxUpdateUIEvent(wxWindowID commandId = 0);
536 bool GetSetChecked();
537 bool GetSetEnabled();
539 void Check(bool check);
540 void Enable(bool enable);
541 void SetText(const wxString& text);
544 // Sets the interval between updates in milliseconds.
545 // Set to -1 to disable updates, or to 0 to update as frequently as possible.
546 static void SetUpdateInterval(long updateInterval);
548 // Returns the current interval between updates in milliseconds
549 static long GetUpdateInterval();
551 // Can we update this window?
552 static bool CanUpdate(wxWindow* win);
554 // Reset the update time to provide a delay until the next
555 // time we should update
556 static void ResetUpdateTime();
558 // Specify how wxWindows will send update events: to
559 // all windows, or only to those which specify that they
560 // will process the events.
561 static void SetMode(wxUpdateUIMode mode);
563 // Returns the UI update mode
564 static wxUpdateUIMode GetMode();
567 //---------------------------------------------------------------------------
569 class wxSysColourChangedEvent: public wxEvent {
571 wxSysColourChangedEvent();
574 //---------------------------------------------------------------------------
577 class wxNotifyEvent : public wxCommandEvent {
579 wxNotifyEvent(int commandType = wxEVT_NULL, int id = 0);
586 //---------------------------------------------------------------------------
588 class wxDisplayChangedEvent : public wxEvent
591 wxDisplayChangedEvent();
595 //---------------------------------------------------------------------------
597 class wxPaletteChangedEvent : public wxEvent {
599 wxPaletteChangedEvent(wxWindowID id = 0);
601 void SetChangedWindow(wxWindow* win);
602 wxWindow* GetChangedWindow();
606 //---------------------------------------------------------------------------
608 class wxQueryNewPaletteEvent : public wxEvent {
610 wxQueryNewPaletteEvent(wxWindowID id = 0);
612 void SetPaletteRealized(bool realized);
613 bool GetPaletteRealized();
617 //---------------------------------------------------------------------------
619 class wxWindowCreateEvent : public wxCommandEvent {
621 wxWindowCreateEvent(wxWindow *win = NULL);
623 wxWindow *GetWindow();
626 class wxWindowDestroyEvent : public wxCommandEvent {
628 wxWindowDestroyEvent(wxWindow *win = NULL);
630 wxWindow *GetWindow();
633 //---------------------------------------------------------------------------
635 class wxContextMenuEvent : public wxCommandEvent
638 wxContextMenuEvent(wxEventType type = wxEVT_NULL,
640 const wxPoint& pt = wxDefaultPosition);
641 const wxPoint& GetPosition();
642 void SetPosition(const wxPoint& pos);
645 //----------------------------------------------------------------------
647 class wxTimerEvent : public wxEvent
650 wxTimerEvent(int id = 0, int interval = 0);
654 //---------------------------------------------------------------------------
656 class wxTextUrlEvent : public wxCommandEvent
659 wxTextUrlEvent(int id, const wxMouseEvent& evtMouse,
660 long start, long end);
661 const wxMouseEvent& GetMouseEvent();
666 //---------------------------------------------------------------------------
667 //---------------------------------------------------------------------------
668 // These classes can be derived from in Python and passed through the event
669 // system without loosing anything. They do this by keeping a reference to
670 // themselves and some special case handling in wxPyCallback::EventThunker.
672 class wxPyEvent : public wxEvent {
674 wxPyEvent(int winid=0, wxEventType commandType = wxEVT_NULL );
677 %pragma(python) addtomethod = "__init__:self.SetSelf(self)"
679 void SetSelf(PyObject* self);
684 class wxPyCommandEvent : public wxCommandEvent {
686 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
689 %pragma(python) addtomethod = "__init__:self.SetSelf(self)"
691 void SetSelf(PyObject* self);
698 //---------------------------------------------------------------------------
699 //---------------------------------------------------------------------------