]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/events.i
fixed crash in OnSize() handler
[wxWidgets.git] / wxPython / src / events.i
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 %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 }
104 };
105
106
107 //---------------------------------------------------------------------------
108
109 class wxScrollEvent: public wxCommandEvent {
110 public:
111 wxScrollEvent(int commandType = 0, int id = 0, int pos = 0,
112 int orientation = 0);
113
114 int GetOrientation();
115 int GetPosition();
116 };
117
118 //---------------------------------------------------------------------------
119
120 class wxScrollWinEvent: public wxEvent {
121 public:
122 wxScrollWinEvent(int commandType = 0, int pos = 0,
123 int orientation = 0);
124
125 int GetOrientation();
126 int GetPosition();
127 };
128
129 //---------------------------------------------------------------------------
130
131 class wxSpinEvent : public wxScrollEvent {
132 public:
133 wxSpinEvent(int commandType = 0, int id = 0);
134
135 };
136
137 //---------------------------------------------------------------------------
138
139 class wxMouseEvent: public wxEvent {
140 public:
141 wxMouseEvent(int mouseEventType = 0);
142
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();
169 wxPoint GetPosition();
170 %name(GetPositionTuple)void GetPosition(long *OUTPUT, long *OUTPUT);
171 wxPoint GetLogicalPosition(const wxDC& dc);
172 long GetX();
173 long GetY();
174
175 int GetWheelRotation() const { return m_wheelRotation; }
176 int GetWheelDelta() const { return m_wheelDelta; }
177 int GetLinesPerAction() const { return m_linesPerAction; }
178
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;
187 int m_wheelRotation;
188 int m_wheelDelta;
189 int m_linesPerAction;
190 };
191
192 //---------------------------------------------------------------------------
193
194 class wxKeyEvent: public wxEvent {
195 public:
196 wxKeyEvent(int keyEventType);
197
198 bool ControlDown();
199 bool MetaDown();
200 bool AltDown();
201 bool ShiftDown();
202 long KeyCode();
203
204 long GetKeyCode();
205 bool HasModifiers();
206
207 long GetX();
208 long GetY();
209 wxPoint GetPosition();
210 %name(GetPositionTuple) void GetPosition(long* OUTPUT, long* OUTPUT);
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
220 };
221
222 //---------------------------------------------------------------------------
223
224 class wxNavigationKeyEvent : public wxEvent {
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 };
235
236
237 //---------------------------------------------------------------------------
238
239 class wxMoveEvent: public wxEvent {
240 public:
241 wxMoveEvent(const wxPoint& pt, int id = 0);
242
243 wxPoint GetPosition();
244 };
245
246 //---------------------------------------------------------------------------
247
248 class wxPaintEvent: public wxEvent {
249 public:
250 wxPaintEvent(int id = 0);
251
252 };
253
254 //---------------------------------------------------------------------------
255
256 class wxEraseEvent: public wxEvent {
257 public:
258 wxEraseEvent(int id = 0, wxDC* dc = NULL);
259
260 wxDC *GetDC();
261 };
262
263 //---------------------------------------------------------------------------
264
265 class wxFocusEvent: public wxEvent {
266 public:
267 wxFocusEvent(WXTYPE eventType = 0, int id = 0);
268 };
269
270 //---------------------------------------------------------------------------
271
272 class wxActivateEvent: public wxEvent{
273 public:
274 wxActivateEvent(WXTYPE eventType = 0, int active = TRUE, int id = 0);
275 bool GetActive();
276 };
277
278 //---------------------------------------------------------------------------
279
280 class wxInitDialogEvent: public wxEvent {
281 public:
282 wxInitDialogEvent(int id = 0);
283 };
284
285 //---------------------------------------------------------------------------
286
287 class wxMenuEvent: public wxEvent {
288 public:
289 wxMenuEvent(WXTYPE id = 0, int id = 0);
290 int GetMenuId();
291 };
292
293 //---------------------------------------------------------------------------
294
295 class wxShowEvent: public wxEvent {
296 public:
297 wxShowEvent(int id = 0, int show = FALSE);
298 void SetShow(bool show);
299 bool GetShow();
300 };
301
302 //---------------------------------------------------------------------------
303
304 class wxIconizeEvent: public wxEvent {
305 public:
306 wxIconizeEvent(int id = 0, bool iconized = TRUE);
307 bool Iconized();
308 };
309
310 //---------------------------------------------------------------------------
311
312 class wxMaximizeEvent: public wxEvent {
313 public:
314 wxMaximizeEvent(int id = 0);
315 };
316
317 //---------------------------------------------------------------------------
318
319 class wxJoystickEvent: public wxEvent {
320 public:
321 wxJoystickEvent(int type = wxEVT_NULL,
322 int state = 0,
323 int joystick = wxJOYSTICK1,
324 int change = 0);
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:
373 wxIdleEvent();
374 void RequestMore(bool needMore = TRUE);
375 bool MoreRequested();
376 };
377
378 //---------------------------------------------------------------------------
379
380 class wxUpdateUIEvent: public wxEvent {
381 public:
382 wxUpdateUIEvent(wxWindowID commandId = 0);
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:
399 wxSysColourChangedEvent();
400 };
401
402 //---------------------------------------------------------------------------
403
404
405 class wxNotifyEvent : public wxCommandEvent {
406 public:
407 wxNotifyEvent(int commandType = wxEVT_NULL, int id = 0);
408 bool IsAllowed();
409 void Allow();
410 void Veto();
411 };
412
413
414 //---------------------------------------------------------------------------
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
438 class wxWindowCreateEvent : public wxCommandEvent {
439 public:
440 wxWindowCreateEvent(wxWindow *win = NULL);
441
442 wxWindow *GetWindow();
443 };
444
445 class wxWindowDestroyEvent : public wxCommandEvent {
446 public:
447 wxWindowDestroyEvent(wxWindow *win = NULL);
448
449 wxWindow *GetWindow();
450 };
451
452 //---------------------------------------------------------------------------
453
454 class wxTimerEvent : public wxEvent
455 {
456 public:
457 wxTimerEvent(int id = 0, int interval = 0);
458 int GetInterval();
459 };
460
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 };
472
473 //---------------------------------------------------------------------------
474 //---------------------------------------------------------------------------
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.
478
479 class wxPyEvent : public wxEvent {
480 public:
481 wxPyEvent(int id=0);
482 ~wxPyEvent();
483
484 %pragma(python) addtomethod = "__init__:self.SetSelf(self)"
485
486 void SetSelf(PyObject* self);
487 PyObject* GetSelf();
488 };
489
490
491 class wxPyCommandEvent : public wxCommandEvent {
492 public:
493 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
494 ~wxPyCommandEvent();
495
496 %pragma(python) addtomethod = "__init__:self.SetSelf(self)"
497
498 void SetSelf(PyObject* self);
499 PyObject* GetSelf();
500 };
501
502
503
504
505 //---------------------------------------------------------------------------
506 //---------------------------------------------------------------------------
507