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