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