Commit | Line | Data |
---|---|---|
7bf85405 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: events.i | |
3 | // Purpose: SWIGgable Event classes for wxPython | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 5/24/98 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | ||
03e9bead RD |
14 | %module events |
15 | ||
16 | %{ | |
7bf85405 | 17 | #include "helpers.h" |
62bd0874 | 18 | #include <wx/spinbutt.h> |
7bf85405 RD |
19 | %} |
20 | ||
21 | //---------------------------------------------------------------------- | |
22 | ||
23 | %include typemaps.i | |
24 | %include my_typemaps.i | |
25 | ||
26 | // Import some definitions of other classes, etc. | |
27 | %import _defs.i | |
28 | %import misc.i | |
f6bcfd97 | 29 | %import gdi.i |
7bf85405 RD |
30 | |
31 | //--------------------------------------------------------------------------- | |
32 | ||
83b18bab RD |
33 | |
34 | int wxNewEventType(); | |
35 | ||
9416aa89 | 36 | class wxEvent : public wxObject { |
7bf85405 | 37 | public: |
1475671a RD |
38 | wxEvent(int id = 0); |
39 | ~wxEvent(); | |
40 | ||
7bf85405 RD |
41 | wxObject* GetEventObject(); |
42 | wxEventType GetEventType(); | |
43 | int GetId(); | |
44 | bool GetSkipped(); | |
45 | long GetTimestamp(); | |
46 | void SetEventObject(wxObject* object); | |
47 | void SetEventType(wxEventType typ); | |
48 | void SetId(int id); | |
49 | void SetTimestamp(long timeStamp); | |
50 | void Skip(bool skip = TRUE); | |
51 | }; | |
52 | ||
53 | //--------------------------------------------------------------------------- | |
54 | ||
55 | class wxSizeEvent : public wxEvent { | |
56 | public: | |
1475671a | 57 | wxSizeEvent(const wxSize& sz, int id = 0); |
7bf85405 RD |
58 | wxSize GetSize(); |
59 | }; | |
60 | ||
61 | //--------------------------------------------------------------------------- | |
62 | ||
63 | class wxCloseEvent : public wxEvent { | |
64 | public: | |
1475671a RD |
65 | wxCloseEvent(int commandEventType = 0, int id = 0); |
66 | ||
e980740a | 67 | void SetLoggingOff(bool loggingOff); |
7bf85405 RD |
68 | bool GetLoggingOff(); |
69 | void Veto(bool veto = TRUE); | |
e980740a | 70 | bool CanVeto(); |
7bf85405 | 71 | bool GetVeto(); |
b8b8dda7 | 72 | void SetCanVeto(bool canVeto); |
7bf85405 RD |
73 | }; |
74 | ||
75 | //--------------------------------------------------------------------------- | |
76 | ||
77 | class wxCommandEvent : public wxEvent { | |
78 | public: | |
1475671a RD |
79 | wxCommandEvent(int commandEventType = 0, int id = 0); |
80 | ||
3ca6a5f0 BP |
81 | bool IsChecked(); |
82 | %name(Checked)bool IsChecked(); | |
7bf85405 RD |
83 | long GetExtraLong(); |
84 | int GetInt(); | |
85 | int GetSelection(); | |
cf694132 | 86 | wxString GetString(); |
7bf85405 | 87 | bool IsSelection(); |
6999b0d8 RD |
88 | void SetString(const wxString& s); |
89 | void SetExtraLong(long extraLong); | |
90 | void SetInt(int i); | |
91 | ||
900d9886 RD |
92 | %addmethods { |
93 | PyObject* GetClientData() { | |
94 | wxPyClientData* data = (wxPyClientData*)self->GetClientObject(); | |
95 | if (data) { | |
96 | Py_INCREF(data->m_obj); | |
97 | return data->m_obj; | |
98 | } else { | |
99 | Py_INCREF(Py_None); | |
100 | return Py_None; | |
101 | } | |
102 | } | |
103 | } | |
7bf85405 RD |
104 | }; |
105 | ||
106 | ||
107 | //--------------------------------------------------------------------------- | |
108 | ||
109 | class wxScrollEvent: public wxCommandEvent { | |
110 | public: | |
1475671a RD |
111 | wxScrollEvent(int commandType = 0, int id = 0, int pos = 0, |
112 | int orientation = 0); | |
113 | ||
7bf85405 RD |
114 | int GetOrientation(); |
115 | int GetPosition(); | |
116 | }; | |
117 | ||
118 | //--------------------------------------------------------------------------- | |
119 | ||
d426c97e RD |
120 | class wxScrollWinEvent: public wxEvent { |
121 | public: | |
1475671a RD |
122 | wxScrollWinEvent(int commandType = 0, int pos = 0, |
123 | int orientation = 0); | |
124 | ||
d426c97e RD |
125 | int GetOrientation(); |
126 | int GetPosition(); | |
127 | }; | |
128 | ||
129 | //--------------------------------------------------------------------------- | |
130 | ||
62bd0874 RD |
131 | class wxSpinEvent : public wxScrollEvent { |
132 | public: | |
1475671a | 133 | wxSpinEvent(int commandType = 0, int id = 0); |
62bd0874 RD |
134 | |
135 | }; | |
136 | ||
137 | //--------------------------------------------------------------------------- | |
138 | ||
7bf85405 RD |
139 | class wxMouseEvent: public wxEvent { |
140 | public: | |
1475671a RD |
141 | wxMouseEvent(int mouseEventType = 0); |
142 | ||
7bf85405 RD |
143 | bool IsButton(); |
144 | bool ButtonDown(int but = -1); | |
145 | bool ButtonDClick(int but = -1); | |
146 | bool ButtonUp(int but = -1); | |
147 | bool Button(int but); | |
148 | bool ButtonIsDown(int but); | |
149 | bool ControlDown(); | |
150 | bool MetaDown(); | |
151 | bool AltDown(); | |
152 | bool ShiftDown(); | |
153 | bool LeftDown(); | |
154 | bool MiddleDown(); | |
155 | bool RightDown(); | |
156 | bool LeftUp(); | |
157 | bool MiddleUp(); | |
158 | bool RightUp(); | |
159 | bool LeftDClick(); | |
160 | bool MiddleDClick(); | |
161 | bool RightDClick(); | |
162 | bool LeftIsDown(); | |
163 | bool MiddleIsDown(); | |
164 | bool RightIsDown(); | |
165 | bool Dragging(); | |
166 | bool Moving(); | |
167 | bool Entering(); | |
168 | bool Leaving(); | |
7bf85405 | 169 | wxPoint GetPosition(); |
b1462dfa | 170 | %name(GetPositionTuple)void GetPosition(long *OUTPUT, long *OUTPUT); |
7bf85405 RD |
171 | wxPoint GetLogicalPosition(const wxDC& dc); |
172 | long GetX(); | |
173 | long GetY(); | |
c368d904 | 174 | |
d1679124 RD |
175 | int GetWheelRotation() const { return m_wheelRotation; } |
176 | int GetWheelDelta() const { return m_wheelDelta; } | |
177 | int GetLinesPerAction() const { return m_linesPerAction; } | |
178 | ||
c368d904 RD |
179 | long m_x, m_y; |
180 | bool m_leftDown; | |
181 | bool m_middleDown; | |
182 | bool m_rightDown; | |
183 | bool m_controlDown; | |
184 | bool m_shiftDown; | |
185 | bool m_altDown; | |
186 | bool m_metaDown; | |
d1679124 RD |
187 | int m_wheelRotation; |
188 | int m_wheelDelta; | |
189 | int m_linesPerAction; | |
7bf85405 RD |
190 | }; |
191 | ||
192 | //--------------------------------------------------------------------------- | |
193 | ||
194 | class wxKeyEvent: public wxEvent { | |
195 | public: | |
1475671a RD |
196 | wxKeyEvent(int keyEventType); |
197 | ||
7bf85405 RD |
198 | bool ControlDown(); |
199 | bool MetaDown(); | |
200 | bool AltDown(); | |
201 | bool ShiftDown(); | |
202 | long KeyCode(); | |
e980740a | 203 | |
f6bcfd97 BP |
204 | long GetKeyCode(); |
205 | bool HasModifiers(); | |
206 | ||
1475671a RD |
207 | long GetX(); |
208 | long GetY(); | |
209 | wxPoint GetPosition(); | |
210 | %name(GetPositionTuple) void GetPosition(long* OUTPUT, long* OUTPUT); | |
c368d904 RD |
211 | |
212 | long m_x, m_y; | |
213 | long m_keyCode; | |
214 | bool m_controlDown; | |
215 | bool m_shiftDown; | |
216 | bool m_altDown; | |
217 | bool m_metaDown; | |
218 | bool m_scanCode; | |
219 | ||
7bf85405 RD |
220 | }; |
221 | ||
2f90df85 RD |
222 | //--------------------------------------------------------------------------- |
223 | ||
eec92d76 | 224 | class wxNavigationKeyEvent : public wxEvent { |
1475671a RD |
225 | public: |
226 | wxNavigationKeyEvent(); | |
227 | ||
228 | bool GetDirection(); | |
229 | void SetDirection(bool bForward); | |
230 | bool IsWindowChange(); | |
231 | void SetWindowChange(bool bIs); | |
232 | wxWindow* GetCurrentFocus(); | |
233 | void SetCurrentFocus(wxWindow *win); | |
234 | }; | |
2f90df85 RD |
235 | |
236 | ||
7bf85405 RD |
237 | //--------------------------------------------------------------------------- |
238 | ||
239 | class wxMoveEvent: public wxEvent { | |
240 | public: | |
1475671a RD |
241 | wxMoveEvent(const wxPoint& pt, int id = 0); |
242 | ||
7bf85405 RD |
243 | wxPoint GetPosition(); |
244 | }; | |
245 | ||
246 | //--------------------------------------------------------------------------- | |
247 | ||
248 | class wxPaintEvent: public wxEvent { | |
249 | public: | |
1475671a | 250 | wxPaintEvent(int id = 0); |
7bf85405 RD |
251 | |
252 | }; | |
253 | ||
254 | //--------------------------------------------------------------------------- | |
255 | ||
256 | class wxEraseEvent: public wxEvent { | |
257 | public: | |
1475671a RD |
258 | wxEraseEvent(int id = 0, wxDC* dc = NULL); |
259 | ||
7bf85405 RD |
260 | wxDC *GetDC(); |
261 | }; | |
262 | ||
263 | //--------------------------------------------------------------------------- | |
264 | ||
265 | class wxFocusEvent: public wxEvent { | |
266 | public: | |
1475671a | 267 | wxFocusEvent(WXTYPE eventType = 0, int id = 0); |
7bf85405 RD |
268 | }; |
269 | ||
270 | //--------------------------------------------------------------------------- | |
271 | ||
272 | class wxActivateEvent: public wxEvent{ | |
273 | public: | |
1475671a | 274 | wxActivateEvent(WXTYPE eventType = 0, int active = TRUE, int id = 0); |
7bf85405 RD |
275 | bool GetActive(); |
276 | }; | |
277 | ||
278 | //--------------------------------------------------------------------------- | |
279 | ||
280 | class wxInitDialogEvent: public wxEvent { | |
281 | public: | |
1475671a | 282 | wxInitDialogEvent(int id = 0); |
7bf85405 RD |
283 | }; |
284 | ||
285 | //--------------------------------------------------------------------------- | |
286 | ||
287 | class wxMenuEvent: public wxEvent { | |
288 | public: | |
1475671a | 289 | wxMenuEvent(WXTYPE id = 0, int id = 0); |
7bf85405 RD |
290 | int GetMenuId(); |
291 | }; | |
292 | ||
293 | //--------------------------------------------------------------------------- | |
294 | ||
295 | class wxShowEvent: public wxEvent { | |
296 | public: | |
1475671a | 297 | wxShowEvent(int id = 0, int show = FALSE); |
7bf85405 RD |
298 | void SetShow(bool show); |
299 | bool GetShow(); | |
300 | }; | |
301 | ||
302 | //--------------------------------------------------------------------------- | |
303 | ||
304 | class wxIconizeEvent: public wxEvent { | |
305 | public: | |
d56cebe7 RD |
306 | wxIconizeEvent(int id = 0, bool iconized = TRUE); |
307 | bool Iconized(); | |
7bf85405 RD |
308 | }; |
309 | ||
310 | //--------------------------------------------------------------------------- | |
311 | ||
312 | class wxMaximizeEvent: public wxEvent { | |
313 | public: | |
1475671a | 314 | wxMaximizeEvent(int id = 0); |
7bf85405 RD |
315 | }; |
316 | ||
317 | //--------------------------------------------------------------------------- | |
318 | ||
319 | class wxJoystickEvent: public wxEvent { | |
320 | public: | |
1475671a RD |
321 | wxJoystickEvent(int type = wxEVT_NULL, |
322 | int state = 0, | |
323 | int joystick = wxJOYSTICK1, | |
324 | int change = 0); | |
7bf85405 RD |
325 | wxPoint GetPosition(); |
326 | int GetZPosition(); | |
327 | int GetButtonState(); | |
328 | int GetButtonChange(); | |
329 | int GetJoystick(); | |
330 | void SetJoystick(int stick); | |
331 | void SetButtonState(int state); | |
332 | void SetButtonChange(int change); | |
333 | void SetPosition(const wxPoint& pos); | |
334 | void SetZPosition(int zPos); | |
335 | bool IsButton(); | |
336 | bool IsMove(); | |
337 | bool IsZMove(); | |
338 | bool ButtonDown(int but = wxJOY_BUTTON_ANY); | |
339 | bool ButtonUp(int but = wxJOY_BUTTON_ANY); | |
340 | bool ButtonIsDown(int but = wxJOY_BUTTON_ANY); | |
341 | }; | |
342 | ||
343 | //--------------------------------------------------------------------------- | |
344 | ||
345 | class wxDropFilesEvent: public wxEvent { | |
346 | public: | |
347 | wxPoint GetPosition(); | |
348 | int GetNumberOfFiles(); | |
349 | ||
350 | %addmethods { | |
351 | PyObject* GetFiles() { | |
352 | int count = self->GetNumberOfFiles(); | |
353 | wxString* files = self->GetFiles(); | |
354 | PyObject* list = PyList_New(count); | |
355 | ||
356 | if (!list) { | |
357 | PyErr_SetString(PyExc_MemoryError, "Can't allocate list of files!"); | |
358 | return NULL; | |
359 | } | |
360 | ||
361 | for (int i=0; i<count; i++) { | |
362 | PyList_SetItem(list, i, PyString_FromString((const char*)files[i])); | |
363 | } | |
364 | return list; | |
365 | } | |
366 | } | |
367 | }; | |
368 | ||
369 | //--------------------------------------------------------------------------- | |
370 | ||
371 | class wxIdleEvent: public wxEvent { | |
372 | public: | |
1475671a | 373 | wxIdleEvent(); |
7bf85405 RD |
374 | void RequestMore(bool needMore = TRUE); |
375 | bool MoreRequested(); | |
376 | }; | |
377 | ||
378 | //--------------------------------------------------------------------------- | |
379 | ||
380 | class wxUpdateUIEvent: public wxEvent { | |
381 | public: | |
1475671a | 382 | wxUpdateUIEvent(wxWindowID commandId = 0); |
7bf85405 RD |
383 | bool GetChecked(); |
384 | bool GetEnabled(); | |
385 | wxString GetText(); | |
386 | bool GetSetText(); | |
387 | bool GetSetChecked(); | |
388 | bool GetSetEnabled(); | |
389 | ||
390 | void Check(bool check); | |
391 | void Enable(bool enable); | |
392 | void SetText(const wxString& text); | |
393 | }; | |
394 | ||
395 | //--------------------------------------------------------------------------- | |
396 | ||
397 | class wxSysColourChangedEvent: public wxEvent { | |
398 | public: | |
1475671a | 399 | wxSysColourChangedEvent(); |
7bf85405 RD |
400 | }; |
401 | ||
402 | //--------------------------------------------------------------------------- | |
403 | ||
2f90df85 RD |
404 | |
405 | class wxNotifyEvent : public wxCommandEvent { | |
cf694132 | 406 | public: |
1475671a | 407 | wxNotifyEvent(int commandType = wxEVT_NULL, int id = 0); |
2f90df85 | 408 | bool IsAllowed(); |
185d7c3e | 409 | void Allow(); |
2f90df85 RD |
410 | void Veto(); |
411 | }; | |
412 | ||
413 | ||
414 | //--------------------------------------------------------------------------- | |
1475671a RD |
415 | |
416 | class wxPaletteChangedEvent : public wxEvent { | |
417 | public: | |
418 | wxPaletteChangedEvent(wxWindowID id = 0); | |
419 | ||
420 | void SetChangedWindow(wxWindow* win); | |
421 | wxWindow* GetChangedWindow(); | |
422 | ||
423 | }; | |
424 | ||
425 | //--------------------------------------------------------------------------- | |
426 | ||
427 | class wxQueryNewPaletteEvent : public wxEvent { | |
428 | public: | |
429 | wxQueryNewPaletteEvent(wxWindowID id = 0); | |
430 | ||
431 | void SetPaletteRealized(bool realized); | |
432 | bool GetPaletteRealized(); | |
433 | }; | |
434 | ||
435 | ||
436 | //--------------------------------------------------------------------------- | |
437 | ||
f6bcfd97 | 438 | class wxWindowCreateEvent : public wxCommandEvent { |
1475671a RD |
439 | public: |
440 | wxWindowCreateEvent(wxWindow *win = NULL); | |
441 | ||
442 | wxWindow *GetWindow(); | |
443 | }; | |
444 | ||
f6bcfd97 | 445 | class wxWindowDestroyEvent : public wxCommandEvent { |
1475671a RD |
446 | public: |
447 | wxWindowDestroyEvent(wxWindow *win = NULL); | |
448 | ||
449 | wxWindow *GetWindow(); | |
450 | }; | |
451 | ||
f6bcfd97 BP |
452 | //--------------------------------------------------------------------------- |
453 | ||
454 | class wxTimerEvent : public wxEvent | |
455 | { | |
456 | public: | |
457 | wxTimerEvent(int id = 0, int interval = 0); | |
458 | int GetInterval(); | |
459 | }; | |
460 | ||
c7e7022c RD |
461 | //--------------------------------------------------------------------------- |
462 | ||
463 | class wxTextUrlEvent : public wxCommandEvent | |
464 | { | |
465 | public: | |
466 | wxTextUrlEvent(int id, const wxMouseEvent& evtMouse, | |
467 | long start, long end); | |
468 | const wxMouseEvent& GetMouseEvent(); | |
469 | long GetURLStart(); | |
470 | long GetURLEnd(); | |
471 | }; | |
1475671a RD |
472 | |
473 | //--------------------------------------------------------------------------- | |
474 | //--------------------------------------------------------------------------- | |
65dd82cb RD |
475 | // These classes can be derived from in Python and passed through the event |
476 | // system without loosing anything. They do this by keeping a reference to | |
477 | // themselves and some special case handling in wxPyCallback::EventThunker. | |
cf694132 | 478 | |
2f90df85 RD |
479 | class wxPyEvent : public wxEvent { |
480 | public: | |
65dd82cb | 481 | wxPyEvent(int id=0); |
2f90df85 RD |
482 | ~wxPyEvent(); |
483 | ||
65dd82cb RD |
484 | %pragma(python) addtomethod = "__init__:self.SetSelf(self)" |
485 | ||
486 | void SetSelf(PyObject* self); | |
487 | PyObject* GetSelf(); | |
2f90df85 RD |
488 | }; |
489 | ||
bb0054cd | 490 | |
2f90df85 | 491 | class wxPyCommandEvent : public wxCommandEvent { |
bb0054cd | 492 | public: |
65dd82cb RD |
493 | wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0); |
494 | ~wxPyCommandEvent(); | |
2f90df85 | 495 | |
65dd82cb | 496 | %pragma(python) addtomethod = "__init__:self.SetSelf(self)" |
2f90df85 | 497 | |
65dd82cb RD |
498 | void SetSelf(PyObject* self); |
499 | PyObject* GetSelf(); | |
2f90df85 RD |
500 | }; |
501 | ||
2f90df85 | 502 | |
bb0054cd | 503 | |
2f90df85 | 504 | |
bb0054cd RD |
505 | //--------------------------------------------------------------------------- |
506 | //--------------------------------------------------------------------------- | |
7bf85405 | 507 |