]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_evthandler.i
return false from IsDoubleBuffered() if the first top level parent is not double...
[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
d49bdf34 25 %pythonAppend wxEvtHandler "self._setOORInfo(self)"
d14a1e28
RD
26 wxEvtHandler();
27
b39c3fa0
RD
28 // Turn it back on again
29 %typemap(out) wxEvtHandler* { $result = wxPyMake_wxObject($1, $owner); }
30
d14a1e28
RD
31 wxEvtHandler* GetNextHandler();
32 wxEvtHandler* GetPreviousHandler();
33 void SetNextHandler(wxEvtHandler* handler);
34 void SetPreviousHandler(wxEvtHandler* handler);
35
36 bool GetEvtHandlerEnabled();
37 void SetEvtHandlerEnabled(bool enabled);
38
39
40 // process an event right now
41 bool ProcessEvent(wxEvent& event);
42
43 // add an event to be processed later
44 void AddPendingEvent(wxEvent& event);
45
46 // process all pending events
47 void ProcessPendingEvents();
48
49 %extend {
50 // Dynamic association of a member function handler with the event handler
51 void Connect( int id, int lastId, int eventType, PyObject* func) {
52 if (PyCallable_Check(func)) {
53 self->Connect(id, lastId, eventType,
54 (wxObjectEventFunction) &wxPyCallback::EventThunker,
55 new wxPyCallback(func));
56 }
57 else if (func == Py_None) {
58 self->Disconnect(id, lastId, eventType,
59 (wxObjectEventFunction)
60 &wxPyCallback::EventThunker);
61 }
62 else {
a51dff73
RD
63 wxPyBLOCK_THREADS(
64 PyErr_SetString(PyExc_TypeError, "Expected callable object or None."));
d14a1e28
RD
65 }
66 }
67
68 bool Disconnect(int id, int lastId = -1,
69 wxEventType eventType = wxEVT_NULL) {
70 return self->Disconnect(id, lastId, eventType,
71 (wxObjectEventFunction)
72 &wxPyCallback::EventThunker);
73 }
74 }
75
214c4fbe 76 %pythonAppend _setOORInfo "args[0].thisown = 0";
d14a1e28 77 %extend {
94fd5e4d 78 void _setOORInfo(PyObject* _self, bool incref=true) {
d14a1e28 79 if (_self && _self != Py_None) {
94fd5e4d 80 self->SetClientObject(new wxPyOORClientData(_self, incref));
d14a1e28
RD
81 }
82 else {
83 wxPyOORClientData* data = (wxPyOORClientData*)self->GetClientObject();
84 if (data) {
85 self->SetClientObject(NULL); // This will delete it too
86 }
87 }
88 }
89 }
90
91 %pythoncode {
92 def Bind(self, event, handler, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
93 """
94 Bind an event to an event handler.
95
04633c19
RD
96 :param event: One of the EVT_* objects that specifies the
97 type of event to bind,
98
99 :param handler: A callable object to be invoked when the
100 event is delivered to self. Pass None to
101 disconnect an event handler.
102
103 :param source: Sometimes the event originates from a
104 different window than self, but you still
105 want to catch it in self. (For example, a
106 button event delivered to a frame.) By
107 passing the source of the event, the event
108 handling system is able to differentiate
109 between the same event type from different
110 controls.
111
112 :param id: Used to spcify the event source by ID instead
113 of instance.
114
115 :param id2: Used when it is desirable to bind a handler
116 to a range of IDs, such as with EVT_MENU_RANGE.
d14a1e28
RD
117 """
118 if source is not None:
119 id = source.GetId()
120 event.Bind(self, id, id2, handler)
121
ded6ea23
RD
122 def Unbind(self, event, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
123 """
124 Disconencts the event handler binding for event from self.
125 Returns True if successful.
126 """
127 if source is not None:
128 id = source.GetId()
dce2bd22 129 return event.Unbind(self, id, id2)
d14a1e28
RD
130 }
131
42e2bbb9
RD
132 %property(EvtHandlerEnabled, GetEvtHandlerEnabled, SetEvtHandlerEnabled, doc="See `GetEvtHandlerEnabled` and `SetEvtHandlerEnabled`");
133 %property(NextHandler, GetNextHandler, SetNextHandler, doc="See `GetNextHandler` and `SetNextHandler`");
134 %property(PreviousHandler, GetPreviousHandler, SetPreviousHandler, doc="See `GetPreviousHandler` and `SetPreviousHandler`");
d14a1e28
RD
135
136};
137
138//---------------------------------------------------------------------------