]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_evthandler.i
reSWIGged
[wxWidgets.git] / wxPython / src / _evthandler.i
CommitLineData
d14a1e28
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: _evthandler.i
3// Purpose: SWIG interface for wxEventHandler
4//
5// Author: Robin Dunn
6//
7// Created: 9-Aug-2003
8// RCS-ID: $Id$
9// Copyright: (c) 2003 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13// Not a %module
14
15
16//---------------------------------------------------------------------------
17%newgroup
18
19// wxEvtHandler: the base class for all objects handling wxWindows events
20class wxEvtHandler : public wxObject {
21public:
b39c3fa0
RD
22 // turn off this typemap
23 %typemap(out) wxEvtHandler*;
24
d14a1e28
RD
25 wxEvtHandler();
26
b39c3fa0
RD
27 // Turn it back on again
28 %typemap(out) wxEvtHandler* { $result = wxPyMake_wxObject($1, $owner); }
29
d14a1e28
RD
30 wxEvtHandler* GetNextHandler();
31 wxEvtHandler* GetPreviousHandler();
32 void SetNextHandler(wxEvtHandler* handler);
33 void SetPreviousHandler(wxEvtHandler* handler);
34
35 bool GetEvtHandlerEnabled();
36 void SetEvtHandlerEnabled(bool enabled);
37
38
39 // process an event right now
40 bool ProcessEvent(wxEvent& event);
41
42 // add an event to be processed later
43 void AddPendingEvent(wxEvent& event);
44
45 // process all pending events
46 void ProcessPendingEvents();
47
48 %extend {
49 // Dynamic association of a member function handler with the event handler
50 void Connect( int id, int lastId, int eventType, PyObject* func) {
51 if (PyCallable_Check(func)) {
52 self->Connect(id, lastId, eventType,
53 (wxObjectEventFunction) &wxPyCallback::EventThunker,
54 new wxPyCallback(func));
55 }
56 else if (func == Py_None) {
57 self->Disconnect(id, lastId, eventType,
58 (wxObjectEventFunction)
59 &wxPyCallback::EventThunker);
60 }
61 else {
a51dff73
RD
62 wxPyBLOCK_THREADS(
63 PyErr_SetString(PyExc_TypeError, "Expected callable object or None."));
d14a1e28
RD
64 }
65 }
66
67 bool Disconnect(int id, int lastId = -1,
68 wxEventType eventType = wxEVT_NULL) {
69 return self->Disconnect(id, lastId, eventType,
70 (wxObjectEventFunction)
71 &wxPyCallback::EventThunker);
72 }
73 }
74
75 %extend {
94fd5e4d 76 void _setOORInfo(PyObject* _self, bool incref=true) {
d14a1e28 77 if (_self && _self != Py_None) {
94fd5e4d 78 self->SetClientObject(new wxPyOORClientData(_self, incref));
d14a1e28
RD
79 }
80 else {
81 wxPyOORClientData* data = (wxPyOORClientData*)self->GetClientObject();
82 if (data) {
83 self->SetClientObject(NULL); // This will delete it too
84 }
85 }
86 }
87 }
88
89 %pythoncode {
90 def Bind(self, event, handler, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
91 """
92 Bind an event to an event handler.
93
04633c19
RD
94 :param event: One of the EVT_* objects that specifies the
95 type of event to bind,
96
97 :param handler: A callable object to be invoked when the
98 event is delivered to self. Pass None to
99 disconnect an event handler.
100
101 :param source: Sometimes the event originates from a
102 different window than self, but you still
103 want to catch it in self. (For example, a
104 button event delivered to a frame.) By
105 passing the source of the event, the event
106 handling system is able to differentiate
107 between the same event type from different
108 controls.
109
110 :param id: Used to spcify the event source by ID instead
111 of instance.
112
113 :param id2: Used when it is desirable to bind a handler
114 to a range of IDs, such as with EVT_MENU_RANGE.
d14a1e28
RD
115 """
116 if source is not None:
117 id = source.GetId()
118 event.Bind(self, id, id2, handler)
119
ded6ea23
RD
120 def Unbind(self, event, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
121 """
122 Disconencts the event handler binding for event from self.
123 Returns True if successful.
124 """
125 if source is not None:
126 id = source.GetId()
dce2bd22 127 return event.Unbind(self, id, id2)
d14a1e28
RD
128 }
129
130
131};
132
133//---------------------------------------------------------------------------