1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface for wxEventHandler
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
19 // wxEvtHandler: the base class for all objects handling wxWindows events
20 class wxEvtHandler : public wxObject {
24 wxEvtHandler* GetNextHandler();
25 wxEvtHandler* GetPreviousHandler();
26 void SetNextHandler(wxEvtHandler* handler);
27 void SetPreviousHandler(wxEvtHandler* handler);
29 bool GetEvtHandlerEnabled();
30 void SetEvtHandlerEnabled(bool enabled);
33 // process an event right now
34 bool ProcessEvent(wxEvent& event);
36 // add an event to be processed later
37 void AddPendingEvent(wxEvent& event);
39 // process all pending events
40 void ProcessPendingEvents();
43 // Dynamic association of a member function handler with the event handler
44 void Connect( int id, int lastId, int eventType, PyObject* func) {
45 if (PyCallable_Check(func)) {
46 self->Connect(id, lastId, eventType,
47 (wxObjectEventFunction) &wxPyCallback::EventThunker,
48 new wxPyCallback(func));
50 else if (func == Py_None) {
51 self->Disconnect(id, lastId, eventType,
52 (wxObjectEventFunction)
53 &wxPyCallback::EventThunker);
56 PyErr_SetString(PyExc_TypeError, "Expected callable object or None.");
60 bool Disconnect(int id, int lastId = -1,
61 wxEventType eventType = wxEVT_NULL) {
62 return self->Disconnect(id, lastId, eventType,
63 (wxObjectEventFunction)
64 &wxPyCallback::EventThunker);
69 void _setOORInfo(PyObject* _self) {
70 if (_self && _self != Py_None) {
71 self->SetClientObject(new wxPyOORClientData(_self));
74 wxPyOORClientData* data = (wxPyOORClientData*)self->GetClientObject();
76 self->SetClientObject(NULL); // This will delete it too
83 def Bind(self, event, handler, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
85 Bind an event to an event handler.
87 event One of the EVT_* objects that specifies the
88 type of event to bind,
90 handler A callable object to be invoked when the event
91 is delivered to self. Pass None to disconnect an
94 source Sometimes the event originates from a different window
95 than self, but you still want to catch it in self. (For
96 example, a button event delivered to a frame.) By
97 passing the source of the event, the event handling
98 system is able to differentiate between the same event
99 type from different controls.
101 id,id2 Used for menu IDs or for event types that require a
104 if source is not None:
106 event.Bind(self, id, id2, handler)
113 //---------------------------------------------------------------------------