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