]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/events.i
find available samples, demos and contribs at runtime
[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); // *** This class is now an ABC
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 wxMouseCaptureChangedEvent : public wxEvent
197 {
198 public:
199 wxMouseCaptureChangedEvent(wxWindowID id = 0, wxWindow* gainedCapture = NULL);
200 wxWindow* GetCapturedWindow() const;
201 };
202
203 //---------------------------------------------------------------------------
204
205 class wxSetCursorEvent : public wxEvent
206 {
207 public:
208 wxSetCursorEvent(wxCoord x = 0, wxCoord y = 0);
209
210 wxCoord GetX() const;
211 wxCoord GetY() const;
212
213 void SetCursor(const wxCursor& cursor);
214 const wxCursor& GetCursor() const;
215 bool HasCursor() const;
216 };
217
218 //---------------------------------------------------------------------------
219
220 class wxKeyEvent: public wxEvent {
221 public:
222 wxKeyEvent(int keyEventType);
223
224 bool ControlDown();
225 bool MetaDown();
226 bool AltDown();
227 bool ShiftDown();
228
229 long GetKeyCode();
230 %pragma(python) addtoclass = "KeyCode = GetKeyCode"
231 bool HasModifiers();
232
233 // get the raw key code (platform-dependent)
234 long GetRawKeyCode() const;
235
236 // get the raw key flags (platform-dependent)
237 long GetRawKeyFlags() const;
238
239 long GetX();
240 long GetY();
241 wxPoint GetPosition();
242 %name(GetPositionTuple) void GetPosition(long* OUTPUT, long* OUTPUT);
243
244 long m_x, m_y;
245 long m_keyCode;
246 bool m_controlDown;
247 bool m_shiftDown;
248 bool m_altDown;
249 bool m_metaDown;
250 bool m_scanCode;
251 long m_rawCode;
252 long m_rawFlags;
253
254 };
255
256 //---------------------------------------------------------------------------
257
258 class wxNavigationKeyEvent : public wxEvent {
259 public:
260 wxNavigationKeyEvent();
261
262 bool GetDirection();
263 void SetDirection(bool bForward);
264 bool IsWindowChange();
265 void SetWindowChange(bool bIs);
266 wxWindow* GetCurrentFocus();
267 void SetCurrentFocus(wxWindow *win);
268 };
269
270
271 //---------------------------------------------------------------------------
272
273 class wxMoveEvent: public wxEvent {
274 public:
275 wxMoveEvent(const wxPoint& pt, int id = 0);
276
277 wxPoint GetPosition();
278 };
279
280 //---------------------------------------------------------------------------
281
282 class wxPaintEvent: public wxEvent {
283 public:
284 wxPaintEvent(int id = 0);
285
286 };
287
288 //---------------------------------------------------------------------------
289
290 class wxEraseEvent: public wxEvent {
291 public:
292 wxEraseEvent(int id = 0, wxDC* dc = NULL);
293
294 wxDC *GetDC();
295 };
296
297 //---------------------------------------------------------------------------
298
299 class wxFocusEvent: public wxEvent {
300 public:
301 wxFocusEvent(WXTYPE eventType = 0, int id = 0);
302 };
303
304 //---------------------------------------------------------------------------
305
306 // wxChildFocusEvent notifies the parent that a child has got the focus: unlike
307 // wxFocusEvent it is propgated upwards the window chain
308 class wxChildFocusEvent : public wxCommandEvent
309 {
310 public:
311 wxChildFocusEvent(wxWindow *win = NULL);
312 wxWindow *GetWindow() const;
313 };
314
315
316 //---------------------------------------------------------------------------
317
318 class wxActivateEvent: public wxEvent{
319 public:
320 wxActivateEvent(WXTYPE eventType = 0, int active = TRUE, int id = 0);
321 bool GetActive();
322 };
323
324 //---------------------------------------------------------------------------
325
326 class wxInitDialogEvent: public wxEvent {
327 public:
328 wxInitDialogEvent(int id = 0);
329 };
330
331 //---------------------------------------------------------------------------
332
333 class wxMenuEvent: public wxEvent {
334 public:
335 wxMenuEvent(WXTYPE id = 0, int id = 0);
336 int GetMenuId();
337 bool IsPopup();
338 };
339
340 //---------------------------------------------------------------------------
341
342 class wxShowEvent: public wxEvent {
343 public:
344 wxShowEvent(int id = 0, int show = FALSE);
345 void SetShow(bool show);
346 bool GetShow();
347 };
348
349 //---------------------------------------------------------------------------
350
351 class wxIconizeEvent: public wxEvent {
352 public:
353 wxIconizeEvent(int id = 0, bool iconized = TRUE);
354 bool Iconized();
355 };
356
357 //---------------------------------------------------------------------------
358
359 class wxMaximizeEvent: public wxEvent {
360 public:
361 wxMaximizeEvent(int id = 0);
362 };
363
364 //---------------------------------------------------------------------------
365
366 class wxJoystickEvent: public wxEvent {
367 public:
368 wxJoystickEvent(int type = wxEVT_NULL,
369 int state = 0,
370 int joystick = wxJOYSTICK1,
371 int change = 0);
372 wxPoint GetPosition();
373 int GetZPosition();
374 int GetButtonState();
375 int GetButtonChange();
376 int GetJoystick();
377 void SetJoystick(int stick);
378 void SetButtonState(int state);
379 void SetButtonChange(int change);
380 void SetPosition(const wxPoint& pos);
381 void SetZPosition(int zPos);
382 bool IsButton();
383 bool IsMove();
384 bool IsZMove();
385 bool ButtonDown(int but = wxJOY_BUTTON_ANY);
386 bool ButtonUp(int but = wxJOY_BUTTON_ANY);
387 bool ButtonIsDown(int but = wxJOY_BUTTON_ANY);
388 };
389
390 //---------------------------------------------------------------------------
391
392 class wxDropFilesEvent: public wxEvent {
393 public:
394 wxPoint GetPosition();
395 int GetNumberOfFiles();
396
397 %addmethods {
398 PyObject* GetFiles() {
399 int count = self->GetNumberOfFiles();
400 wxString* files = self->GetFiles();
401 PyObject* list = PyList_New(count);
402
403 if (!list) {
404 PyErr_SetString(PyExc_MemoryError, "Can't allocate list of files!");
405 return NULL;
406 }
407
408 for (int i=0; i<count; i++) {
409 #if wxUSE_UNICODE
410 PyList_SetItem(list, i, PyUnicode_FromWideChar(files[i], files[i].Len()));
411 #else
412 PyList_SetItem(list, i, PyString_FromString((const char*)files[i]));
413 #endif
414 }
415 return list;
416 }
417 }
418 };
419
420 //---------------------------------------------------------------------------
421
422 class wxIdleEvent: public wxEvent {
423 public:
424 wxIdleEvent();
425 void RequestMore(bool needMore = TRUE);
426 bool MoreRequested();
427 };
428
429 //---------------------------------------------------------------------------
430
431 class wxUpdateUIEvent: public wxEvent {
432 public:
433 wxUpdateUIEvent(wxWindowID commandId = 0);
434 bool GetChecked();
435 bool GetEnabled();
436 wxString GetText();
437 bool GetSetText();
438 bool GetSetChecked();
439 bool GetSetEnabled();
440
441 void Check(bool check);
442 void Enable(bool enable);
443 void SetText(const wxString& text);
444 };
445
446 //---------------------------------------------------------------------------
447
448 class wxSysColourChangedEvent: public wxEvent {
449 public:
450 wxSysColourChangedEvent();
451 };
452
453 //---------------------------------------------------------------------------
454
455
456 class wxNotifyEvent : public wxCommandEvent {
457 public:
458 wxNotifyEvent(int commandType = wxEVT_NULL, int id = 0);
459 bool IsAllowed();
460 void Allow();
461 void Veto();
462 };
463
464
465 //---------------------------------------------------------------------------
466
467 class wxDisplayChangedEvent : public wxEvent
468 {
469 public:
470 wxDisplayChangedEvent();
471 };
472
473
474 //---------------------------------------------------------------------------
475
476 class wxPaletteChangedEvent : public wxEvent {
477 public:
478 wxPaletteChangedEvent(wxWindowID id = 0);
479
480 void SetChangedWindow(wxWindow* win);
481 wxWindow* GetChangedWindow();
482
483 };
484
485 //---------------------------------------------------------------------------
486
487 class wxQueryNewPaletteEvent : public wxEvent {
488 public:
489 wxQueryNewPaletteEvent(wxWindowID id = 0);
490
491 void SetPaletteRealized(bool realized);
492 bool GetPaletteRealized();
493 };
494
495
496 //---------------------------------------------------------------------------
497
498 class wxWindowCreateEvent : public wxCommandEvent {
499 public:
500 wxWindowCreateEvent(wxWindow *win = NULL);
501
502 wxWindow *GetWindow();
503 };
504
505 class wxWindowDestroyEvent : public wxCommandEvent {
506 public:
507 wxWindowDestroyEvent(wxWindow *win = NULL);
508
509 wxWindow *GetWindow();
510 };
511
512 //---------------------------------------------------------------------------
513
514 class wxContextMenuEvent : public wxCommandEvent
515 {
516 public:
517 wxContextMenuEvent(wxEventType type = wxEVT_NULL,
518 wxWindowID id = 0,
519 const wxPoint& pt = wxDefaultPosition);
520 const wxPoint& GetPosition();
521 void SetPosition(const wxPoint& pos);
522 };
523
524 //----------------------------------------------------------------------
525
526 class wxTimerEvent : public wxEvent
527 {
528 public:
529 wxTimerEvent(int id = 0, int interval = 0);
530 int GetInterval();
531 };
532
533 //---------------------------------------------------------------------------
534
535 class wxTextUrlEvent : public wxCommandEvent
536 {
537 public:
538 wxTextUrlEvent(int id, const wxMouseEvent& evtMouse,
539 long start, long end);
540 const wxMouseEvent& GetMouseEvent();
541 long GetURLStart();
542 long GetURLEnd();
543 };
544
545 //---------------------------------------------------------------------------
546 //---------------------------------------------------------------------------
547 // These classes can be derived from in Python and passed through the event
548 // system without loosing anything. They do this by keeping a reference to
549 // themselves and some special case handling in wxPyCallback::EventThunker.
550
551 class wxPyEvent : public wxEvent {
552 public:
553 wxPyEvent(int id=0);
554 ~wxPyEvent();
555
556 %pragma(python) addtomethod = "__init__:self.SetSelf(self)"
557
558 void SetSelf(PyObject* self);
559 PyObject* GetSelf();
560 };
561
562
563 class wxPyCommandEvent : public wxCommandEvent {
564 public:
565 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
566 ~wxPyCommandEvent();
567
568 %pragma(python) addtomethod = "__init__:self.SetSelf(self)"
569
570 void SetSelf(PyObject* self);
571 PyObject* GetSelf();
572 };
573
574
575
576
577 //---------------------------------------------------------------------------
578 //---------------------------------------------------------------------------
579