]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/events.i
Corrected a return type
[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 enum Propagation_state
34 {
35 // don't propagate it at all
36 wxEVENT_PROPAGATE_NONE = 0,
37
38 // propagate it until it is processed
39 wxEVENT_PROPAGATE_MAX = INT_MAX
40 };
41
42
43 int wxNewEventType();
44
45
46
47 class wxEvent : public wxObject {
48 public:
49 // wxEvent(int id = 0); // *** This class is now an ABC
50 ~wxEvent();
51
52 wxObject* GetEventObject();
53 wxEventType GetEventType();
54 int GetId();
55 long GetTimestamp();
56 void SetEventObject(wxObject* object);
57 void SetEventType(wxEventType typ);
58 void SetId(int id);
59 void SetTimestamp(long timeStamp);
60
61 bool IsCommandEvent() const;
62
63 // Can instruct event processor that we wish to ignore this event
64 // (treat as if the event table entry had not been found): this must be done
65 // to allow the event processing by the base classes (calling event.Skip()
66 // is the analog of calling the base class verstion of a virtual function)
67 void Skip(bool skip = TRUE);
68 bool GetSkipped() const;
69
70 // Determine if this event should be propagating to the parent window.
71 bool ShouldPropagate() const;
72
73 // Stop an event from propagating to its parent window, returns the old
74 // propagation level value
75 int StopPropagation();
76
77 // Resume the event propagation by restoring the propagation level
78 // (returned by StopPropagation())
79 void ResumePropagation(int propagationLevel);
80
81 wxEvent *Clone();
82 };
83
84 //---------------------------------------------------------------------------
85
86 // Helper class to temporarily change an event not to propagate.
87 class wxPropagationDisabler
88 {
89 public:
90 wxPropagationDisabler(wxEvent& event);
91 ~wxPropagationDisabler();
92 };
93
94
95 // Another one to temporarily lower propagation level.
96 class wxPropagateOnce
97 {
98 public:
99 wxPropagateOnce(wxEvent& event);
100 ~wxPropagateOnce();
101 };
102
103 //---------------------------------------------------------------------------
104
105 class wxSizeEvent : public wxEvent {
106 public:
107 wxSizeEvent(const wxSize& sz, int id = 0);
108 wxSize GetSize();
109 wxRect GetRect() const;
110 void SetRect(wxRect rect);
111 };
112
113 //---------------------------------------------------------------------------
114
115 class wxCloseEvent : public wxEvent {
116 public:
117 wxCloseEvent(int commandEventType = 0, int id = 0);
118
119 void SetLoggingOff(bool loggingOff);
120 bool GetLoggingOff();
121 void Veto(bool veto = TRUE);
122 bool CanVeto();
123 bool GetVeto();
124 void SetCanVeto(bool canVeto);
125 };
126
127 //---------------------------------------------------------------------------
128
129 class wxCommandEvent : public wxEvent {
130 public:
131 wxCommandEvent(int commandEventType = 0, int id = 0);
132
133 bool IsChecked();
134 %name(Checked)bool IsChecked();
135 long GetExtraLong();
136 int GetInt();
137 int GetSelection();
138 wxString GetString();
139 bool IsSelection();
140 void SetString(const wxString& s);
141 void SetExtraLong(long extraLong);
142 void SetInt(int i);
143
144 %addmethods {
145 PyObject* GetClientData() {
146 wxPyClientData* data = (wxPyClientData*)self->GetClientObject();
147 if (data) {
148 Py_INCREF(data->m_obj);
149 return data->m_obj;
150 } else {
151 Py_INCREF(Py_None);
152 return Py_None;
153 }
154 }
155 }
156 };
157
158
159 //---------------------------------------------------------------------------
160
161 class wxScrollEvent: public wxCommandEvent {
162 public:
163 wxScrollEvent(int commandType = 0, int id = 0, int pos = 0,
164 int orientation = 0);
165
166 int GetOrientation();
167 int GetPosition();
168 };
169
170 //---------------------------------------------------------------------------
171
172 class wxScrollWinEvent: public wxEvent {
173 public:
174 wxScrollWinEvent(int commandType = 0, int pos = 0,
175 int orientation = 0);
176
177 int GetOrientation();
178 int GetPosition();
179 };
180
181 //---------------------------------------------------------------------------
182
183 class wxSpinEvent : public wxScrollEvent {
184 public:
185 wxSpinEvent(int commandType = 0, int id = 0);
186
187 };
188
189 //---------------------------------------------------------------------------
190
191 class wxMouseEvent: public wxEvent {
192 public:
193 wxMouseEvent(int mouseEventType = 0);
194
195 bool IsButton();
196 bool ButtonDown(int but = -1);
197 bool ButtonDClick(int but = -1);
198 bool ButtonUp(int but = -1);
199 bool Button(int but);
200 bool ButtonIsDown(int but);
201 bool ControlDown();
202 bool MetaDown();
203 bool AltDown();
204 bool ShiftDown();
205 bool LeftDown();
206 bool MiddleDown();
207 bool RightDown();
208 bool LeftUp();
209 bool MiddleUp();
210 bool RightUp();
211 bool LeftDClick();
212 bool MiddleDClick();
213 bool RightDClick();
214 bool LeftIsDown();
215 bool MiddleIsDown();
216 bool RightIsDown();
217 bool Dragging();
218 bool Moving();
219 bool Entering();
220 bool Leaving();
221 wxPoint GetPosition();
222 %name(GetPositionTuple)void GetPosition(long *OUTPUT, long *OUTPUT);
223 wxPoint GetLogicalPosition(const wxDC& dc);
224 long GetX();
225 long GetY();
226
227 int GetWheelRotation() const { return m_wheelRotation; }
228 int GetWheelDelta() const { return m_wheelDelta; }
229 int GetLinesPerAction() const { return m_linesPerAction; }
230
231 long m_x, m_y;
232 bool m_leftDown;
233 bool m_middleDown;
234 bool m_rightDown;
235 bool m_controlDown;
236 bool m_shiftDown;
237 bool m_altDown;
238 bool m_metaDown;
239 int m_wheelRotation;
240 int m_wheelDelta;
241 int m_linesPerAction;
242 };
243
244 //---------------------------------------------------------------------------
245
246 class wxMouseCaptureChangedEvent : public wxEvent
247 {
248 public:
249 wxMouseCaptureChangedEvent(wxWindowID id = 0, wxWindow* gainedCapture = NULL);
250 wxWindow* GetCapturedWindow() const;
251 };
252
253 //---------------------------------------------------------------------------
254
255 class wxSetCursorEvent : public wxEvent
256 {
257 public:
258 wxSetCursorEvent(wxCoord x = 0, wxCoord y = 0);
259
260 wxCoord GetX() const;
261 wxCoord GetY() const;
262
263 void SetCursor(const wxCursor& cursor);
264 const wxCursor& GetCursor() const;
265 bool HasCursor() const;
266 };
267
268 //---------------------------------------------------------------------------
269
270 class wxKeyEvent: public wxEvent {
271 public:
272 wxKeyEvent(int keyEventType);
273
274 bool ControlDown();
275 bool MetaDown();
276 bool AltDown();
277 bool ShiftDown();
278
279 long GetKeyCode();
280 %pragma(python) addtoclass = "KeyCode = GetKeyCode"
281 bool HasModifiers();
282
283 // get the raw key code (platform-dependent)
284 long GetRawKeyCode() const;
285
286 // get the raw key flags (platform-dependent)
287 long GetRawKeyFlags() const;
288
289 long GetX();
290 long GetY();
291 wxPoint GetPosition();
292 %name(GetPositionTuple) void GetPosition(long* OUTPUT, long* OUTPUT);
293
294 long m_x, m_y;
295 long m_keyCode;
296 bool m_controlDown;
297 bool m_shiftDown;
298 bool m_altDown;
299 bool m_metaDown;
300 bool m_scanCode;
301 long m_rawCode;
302 long m_rawFlags;
303
304 };
305
306 //---------------------------------------------------------------------------
307
308 class wxNavigationKeyEvent : public wxEvent {
309 public:
310 wxNavigationKeyEvent();
311
312 bool GetDirection();
313 void SetDirection(bool bForward);
314 bool IsWindowChange();
315 void SetWindowChange(bool bIs);
316 wxWindow* GetCurrentFocus();
317 void SetCurrentFocus(wxWindow *win);
318 };
319
320
321 //---------------------------------------------------------------------------
322
323 class wxMoveEvent: public wxEvent {
324 public:
325 wxMoveEvent(const wxPoint& pt, int id = 0);
326 wxPoint GetPosition();
327 wxRect GetRect() const;
328 void SetRect(wxRect rect);
329 };
330
331 //---------------------------------------------------------------------------
332
333 class wxPaintEvent: public wxEvent {
334 public:
335 wxPaintEvent(int id = 0);
336
337 };
338
339 //---------------------------------------------------------------------------
340
341 class wxEraseEvent: public wxEvent {
342 public:
343 wxEraseEvent(int id = 0, wxDC* dc = NULL);
344
345 wxDC *GetDC();
346 };
347
348 //---------------------------------------------------------------------------
349
350 class wxFocusEvent: public wxEvent {
351 public:
352 wxFocusEvent(int eventType = 0, int id = 0);
353 };
354
355 //---------------------------------------------------------------------------
356
357 // wxChildFocusEvent notifies the parent that a child has got the focus: unlike
358 // wxFocusEvent it is propgated upwards the window chain
359 class wxChildFocusEvent : public wxCommandEvent
360 {
361 public:
362 wxChildFocusEvent(wxWindow *win = NULL);
363 wxWindow *GetWindow() const;
364 };
365
366
367 //---------------------------------------------------------------------------
368
369 class wxActivateEvent: public wxEvent{
370 public:
371 wxActivateEvent(int eventType = 0, int active = TRUE, int id = 0);
372 bool GetActive();
373 };
374
375 //---------------------------------------------------------------------------
376
377 class wxInitDialogEvent: public wxEvent {
378 public:
379 wxInitDialogEvent(int id = 0);
380 };
381
382 //---------------------------------------------------------------------------
383
384 class wxMenuEvent: public wxEvent {
385 public:
386 wxMenuEvent(int id = 0, int winid = 0, wxMenu* menu = NULL);
387 int GetMenuId();
388 bool IsPopup();
389 wxMenu* GetMenu() const;
390 };
391
392 //---------------------------------------------------------------------------
393
394 class wxShowEvent: public wxEvent {
395 public:
396 wxShowEvent(int id = 0, int show = FALSE);
397 void SetShow(bool show);
398 bool GetShow();
399 };
400
401 //---------------------------------------------------------------------------
402
403 class wxIconizeEvent: public wxEvent {
404 public:
405 wxIconizeEvent(int id = 0, bool iconized = TRUE);
406 bool Iconized();
407 };
408
409 //---------------------------------------------------------------------------
410
411 class wxMaximizeEvent: public wxEvent {
412 public:
413 wxMaximizeEvent(int id = 0);
414 };
415
416 //---------------------------------------------------------------------------
417
418 class wxJoystickEvent: public wxEvent {
419 public:
420 wxJoystickEvent(int type = wxEVT_NULL,
421 int state = 0,
422 int joystick = wxJOYSTICK1,
423 int change = 0);
424 wxPoint GetPosition();
425 int GetZPosition();
426 int GetButtonState();
427 int GetButtonChange();
428 int GetJoystick();
429 void SetJoystick(int stick);
430 void SetButtonState(int state);
431 void SetButtonChange(int change);
432 void SetPosition(const wxPoint& pos);
433 void SetZPosition(int zPos);
434 bool IsButton();
435 bool IsMove();
436 bool IsZMove();
437 bool ButtonDown(int but = wxJOY_BUTTON_ANY);
438 bool ButtonUp(int but = wxJOY_BUTTON_ANY);
439 bool ButtonIsDown(int but = wxJOY_BUTTON_ANY);
440 };
441
442 //---------------------------------------------------------------------------
443
444 class wxDropFilesEvent: public wxEvent {
445 public:
446 wxPoint GetPosition();
447 int GetNumberOfFiles();
448
449 %addmethods {
450 PyObject* GetFiles() {
451 int count = self->GetNumberOfFiles();
452 wxString* files = self->GetFiles();
453 PyObject* list = PyList_New(count);
454
455 if (!list) {
456 PyErr_SetString(PyExc_MemoryError, "Can't allocate list of files!");
457 return NULL;
458 }
459
460 for (int i=0; i<count; i++) {
461 #if wxUSE_UNICODE
462 PyList_SetItem(list, i, PyUnicode_FromWideChar(files[i], files[i].Len()));
463 #else
464 PyList_SetItem(list, i, PyString_FromString((const char*)files[i]));
465 #endif
466 }
467 return list;
468 }
469 }
470 };
471
472 //---------------------------------------------------------------------------
473
474 // Whether to always send idle events to windows, or
475 // to only send update events to those with the
476 // wxWS_EX_PROCESS_IDLE style.
477
478 enum wxIdleMode
479 {
480 // Send idle events to all windows
481 wxIDLE_PROCESS_ALL,
482
483 // Send idle events to windows that have
484 // the wxWS_EX_PROCESS_IDLE flag specified
485 wxIDLE_PROCESS_SPECIFIED
486 };
487
488
489 class wxIdleEvent: public wxEvent {
490 public:
491 wxIdleEvent();
492 void RequestMore(bool needMore = TRUE);
493 bool MoreRequested();
494
495 // Specify how wxWindows will send idle events: to
496 // all windows, or only to those which specify that they
497 // will process the events.
498 static void SetMode(wxIdleMode mode) { sm_idleMode = mode; }
499
500 // Returns the idle event mode
501 static wxIdleMode GetMode() { return sm_idleMode ; }
502
503 // Can we send an idle event?
504 static bool CanSend(wxWindow* win) ;
505
506 };
507
508 //---------------------------------------------------------------------------
509
510 // Whether to always send update events to windows, or
511 // to only send update events to those with the
512 // wxWS_EX_PROCESS_UI_UPDATES style.
513
514 enum wxUpdateUIMode
515 {
516 // Send UI update events to all windows
517 wxUPDATE_UI_PROCESS_ALL,
518
519 // Send UI update events to windows that have
520 // the wxWS_EX_PROCESS_UI_UPDATES flag specified
521 wxUPDATE_UI_PROCESS_SPECIFIED
522 };
523
524
525 class wxUpdateUIEvent: public wxEvent {
526 public:
527 wxUpdateUIEvent(wxWindowID commandId = 0);
528 bool GetChecked();
529 bool GetEnabled();
530 wxString GetText();
531 bool GetSetText();
532 bool GetSetChecked();
533 bool GetSetEnabled();
534
535 void Check(bool check);
536 void Enable(bool enable);
537 void SetText(const wxString& text);
538
539
540 // Sets the interval between updates in milliseconds.
541 // Set to -1 to disable updates, or to 0 to update as frequently as possible.
542 static void SetUpdateInterval(long updateInterval);
543
544 // Returns the current interval between updates in milliseconds
545 static long GetUpdateInterval();
546
547 // Can we update this window?
548 static bool CanUpdate(wxWindow* win);
549
550 // Reset the update time to provide a delay until the next
551 // time we should update
552 static void ResetUpdateTime();
553
554 // Specify how wxWindows will send update events: to
555 // all windows, or only to those which specify that they
556 // will process the events.
557 static void SetMode(wxUpdateUIMode mode);
558
559 // Returns the UI update mode
560 static wxUpdateUIMode GetMode();
561 };
562
563 //---------------------------------------------------------------------------
564
565 class wxSysColourChangedEvent: public wxEvent {
566 public:
567 wxSysColourChangedEvent();
568 };
569
570 //---------------------------------------------------------------------------
571
572
573 class wxNotifyEvent : public wxCommandEvent {
574 public:
575 wxNotifyEvent(int commandType = wxEVT_NULL, int id = 0);
576 bool IsAllowed();
577 void Allow();
578 void Veto();
579 };
580
581
582 //---------------------------------------------------------------------------
583
584 class wxDisplayChangedEvent : public wxEvent
585 {
586 public:
587 wxDisplayChangedEvent();
588 };
589
590
591 //---------------------------------------------------------------------------
592
593 class wxPaletteChangedEvent : public wxEvent {
594 public:
595 wxPaletteChangedEvent(wxWindowID id = 0);
596
597 void SetChangedWindow(wxWindow* win);
598 wxWindow* GetChangedWindow();
599
600 };
601
602 //---------------------------------------------------------------------------
603
604 class wxQueryNewPaletteEvent : public wxEvent {
605 public:
606 wxQueryNewPaletteEvent(wxWindowID id = 0);
607
608 void SetPaletteRealized(bool realized);
609 bool GetPaletteRealized();
610 };
611
612
613 //---------------------------------------------------------------------------
614
615 class wxWindowCreateEvent : public wxCommandEvent {
616 public:
617 wxWindowCreateEvent(wxWindow *win = NULL);
618
619 wxWindow *GetWindow();
620 };
621
622 class wxWindowDestroyEvent : public wxCommandEvent {
623 public:
624 wxWindowDestroyEvent(wxWindow *win = NULL);
625
626 wxWindow *GetWindow();
627 };
628
629 //---------------------------------------------------------------------------
630
631 class wxContextMenuEvent : public wxCommandEvent
632 {
633 public:
634 wxContextMenuEvent(wxEventType type = wxEVT_NULL,
635 wxWindowID id = 0,
636 const wxPoint& pt = wxDefaultPosition);
637 const wxPoint& GetPosition();
638 void SetPosition(const wxPoint& pos);
639 };
640
641 //----------------------------------------------------------------------
642
643 class wxTimerEvent : public wxEvent
644 {
645 public:
646 wxTimerEvent(int id = 0, int interval = 0);
647 int GetInterval();
648 };
649
650 //---------------------------------------------------------------------------
651
652 class wxTextUrlEvent : public wxCommandEvent
653 {
654 public:
655 wxTextUrlEvent(int id, const wxMouseEvent& evtMouse,
656 long start, long end);
657 const wxMouseEvent& GetMouseEvent();
658 long GetURLStart();
659 long GetURLEnd();
660 };
661
662 //---------------------------------------------------------------------------
663 //---------------------------------------------------------------------------
664 // These classes can be derived from in Python and passed through the event
665 // system without loosing anything. They do this by keeping a reference to
666 // themselves and some special case handling in wxPyCallback::EventThunker.
667
668 class wxPyEvent : public wxEvent {
669 public:
670 wxPyEvent(int winid=0, wxEventType commandType = wxEVT_NULL );
671 ~wxPyEvent();
672
673 %pragma(python) addtomethod = "__init__:self.SetSelf(self)"
674
675 void SetSelf(PyObject* self);
676 PyObject* GetSelf();
677 };
678
679
680 class wxPyCommandEvent : public wxCommandEvent {
681 public:
682 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
683 ~wxPyCommandEvent();
684
685 %pragma(python) addtomethod = "__init__:self.SetSelf(self)"
686
687 void SetSelf(PyObject* self);
688 PyObject* GetSelf();
689 };
690
691
692
693
694 //---------------------------------------------------------------------------
695 //---------------------------------------------------------------------------
696