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