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