]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/events.i
fix text scrolling in GTK2 (patch 703988)
[wxWidgets.git] / wxPython / src / events.i
CommitLineData
7bf85405
RD
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
03e9bead
RD
14%module events
15
16%{
7bf85405 17#include "helpers.h"
62bd0874 18#include <wx/spinbutt.h>
7bf85405
RD
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
f6bcfd97 29%import gdi.i
7bf85405
RD
30
31//---------------------------------------------------------------------------
32
3ef86e32
RD
33enum 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
83b18bab
RD
42
43int wxNewEventType();
44
3ef86e32
RD
45
46
9416aa89 47class wxEvent : public wxObject {
7bf85405 48public:
ebf4302c 49 // wxEvent(int id = 0); // *** This class is now an ABC
1475671a
RD
50 ~wxEvent();
51
7bf85405
RD
52 wxObject* GetEventObject();
53 wxEventType GetEventType();
54 int GetId();
7bf85405
RD
55 long GetTimestamp();
56 void SetEventObject(wxObject* object);
57 void SetEventType(wxEventType typ);
58 void SetId(int id);
59 void SetTimestamp(long timeStamp);
3ef86e32
RD
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)
7bf85405 67 void Skip(bool skip = TRUE);
3ef86e32
RD
68 bool GetSkipped() const;
69
70 // Determine if this event should be propagating to the parent window.
71 bool ShouldPropagate() const;
07b2e1cd 72
3ef86e32
RD
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.
87class wxPropagationDisabler
88{
89public:
90 wxPropagationDisabler(wxEvent& event);
91 ~wxPropagationDisabler();
92};
93
94
95// Another one to temporarily lower propagation level.
96class wxPropagateOnce
97{
98public:
99 wxPropagateOnce(wxEvent& event);
100 ~wxPropagateOnce();
7bf85405
RD
101};
102
103//---------------------------------------------------------------------------
104
105class wxSizeEvent : public wxEvent {
106public:
1475671a 107 wxSizeEvent(const wxSize& sz, int id = 0);
7bf85405 108 wxSize GetSize();
3ef86e32
RD
109 wxRect GetRect() const;
110 void SetRect(wxRect rect);
7bf85405
RD
111};
112
113//---------------------------------------------------------------------------
114
115class wxCloseEvent : public wxEvent {
116public:
1475671a
RD
117 wxCloseEvent(int commandEventType = 0, int id = 0);
118
e980740a 119 void SetLoggingOff(bool loggingOff);
7bf85405
RD
120 bool GetLoggingOff();
121 void Veto(bool veto = TRUE);
e980740a 122 bool CanVeto();
7bf85405 123 bool GetVeto();
b8b8dda7 124 void SetCanVeto(bool canVeto);
7bf85405
RD
125};
126
127//---------------------------------------------------------------------------
128
129class wxCommandEvent : public wxEvent {
130public:
1475671a
RD
131 wxCommandEvent(int commandEventType = 0, int id = 0);
132
3ca6a5f0
BP
133 bool IsChecked();
134 %name(Checked)bool IsChecked();
7bf85405
RD
135 long GetExtraLong();
136 int GetInt();
137 int GetSelection();
cf694132 138 wxString GetString();
7bf85405 139 bool IsSelection();
6999b0d8
RD
140 void SetString(const wxString& s);
141 void SetExtraLong(long extraLong);
142 void SetInt(int i);
143
900d9886
RD
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 }
7bf85405
RD
156};
157
158
159//---------------------------------------------------------------------------
160
161class wxScrollEvent: public wxCommandEvent {
162public:
1475671a
RD
163 wxScrollEvent(int commandType = 0, int id = 0, int pos = 0,
164 int orientation = 0);
165
7bf85405
RD
166 int GetOrientation();
167 int GetPosition();
168};
169
170//---------------------------------------------------------------------------
171
d426c97e
RD
172class wxScrollWinEvent: public wxEvent {
173public:
1475671a
RD
174 wxScrollWinEvent(int commandType = 0, int pos = 0,
175 int orientation = 0);
176
d426c97e
RD
177 int GetOrientation();
178 int GetPosition();
179};
180
181//---------------------------------------------------------------------------
182
62bd0874
RD
183class wxSpinEvent : public wxScrollEvent {
184public:
1475671a 185 wxSpinEvent(int commandType = 0, int id = 0);
62bd0874
RD
186
187};
188
189//---------------------------------------------------------------------------
190
7bf85405
RD
191class wxMouseEvent: public wxEvent {
192public:
1475671a
RD
193 wxMouseEvent(int mouseEventType = 0);
194
7bf85405
RD
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();
7bf85405 221 wxPoint GetPosition();
b1462dfa 222 %name(GetPositionTuple)void GetPosition(long *OUTPUT, long *OUTPUT);
7bf85405
RD
223 wxPoint GetLogicalPosition(const wxDC& dc);
224 long GetX();
225 long GetY();
c368d904 226
d1679124
RD
227 int GetWheelRotation() const { return m_wheelRotation; }
228 int GetWheelDelta() const { return m_wheelDelta; }
229 int GetLinesPerAction() const { return m_linesPerAction; }
230
c368d904
RD
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;
d1679124
RD
239 int m_wheelRotation;
240 int m_wheelDelta;
241 int m_linesPerAction;
7bf85405
RD
242};
243
244//---------------------------------------------------------------------------
245
6d26dc89
RD
246class wxMouseCaptureChangedEvent : public wxEvent
247{
248public:
249 wxMouseCaptureChangedEvent(wxWindowID id = 0, wxWindow* gainedCapture = NULL);
250 wxWindow* GetCapturedWindow() const;
251};
252
253//---------------------------------------------------------------------------
254
203c2f9a
RD
255class wxSetCursorEvent : public wxEvent
256{
257public:
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
7bf85405
RD
270class wxKeyEvent: public wxEvent {
271public:
1475671a
RD
272 wxKeyEvent(int keyEventType);
273
7bf85405
RD
274 bool ControlDown();
275 bool MetaDown();
276 bool AltDown();
277 bool ShiftDown();
e980740a 278
f6bcfd97 279 long GetKeyCode();
1e4a197e 280 %pragma(python) addtoclass = "KeyCode = GetKeyCode"
f6bcfd97
BP
281 bool HasModifiers();
282
db0ff83e
RD
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
1475671a
RD
289 long GetX();
290 long GetY();
291 wxPoint GetPosition();
292 %name(GetPositionTuple) void GetPosition(long* OUTPUT, long* OUTPUT);
c368d904 293
db0ff83e
RD
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;
c368d904 303
7bf85405
RD
304};
305
2f90df85
RD
306//---------------------------------------------------------------------------
307
eec92d76 308class wxNavigationKeyEvent : public wxEvent {
1475671a
RD
309public:
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};
2f90df85
RD
319
320
7bf85405
RD
321//---------------------------------------------------------------------------
322
323class wxMoveEvent: public wxEvent {
324public:
1475671a 325 wxMoveEvent(const wxPoint& pt, int id = 0);
7bf85405 326 wxPoint GetPosition();
3ef86e32
RD
327 wxRect GetRect() const;
328 void SetRect(wxRect rect);
7bf85405
RD
329};
330
331//---------------------------------------------------------------------------
332
333class wxPaintEvent: public wxEvent {
334public:
1475671a 335 wxPaintEvent(int id = 0);
7bf85405
RD
336
337};
338
339//---------------------------------------------------------------------------
340
341class wxEraseEvent: public wxEvent {
342public:
1475671a
RD
343 wxEraseEvent(int id = 0, wxDC* dc = NULL);
344
7bf85405
RD
345 wxDC *GetDC();
346};
347
348//---------------------------------------------------------------------------
349
350class wxFocusEvent: public wxEvent {
351public:
3ef86e32 352 wxFocusEvent(int eventType = 0, int id = 0);
7bf85405
RD
353};
354
7b7ac0ab
RD
355//---------------------------------------------------------------------------
356
357// wxChildFocusEvent notifies the parent that a child has got the focus: unlike
358// wxFocusEvent it is propgated upwards the window chain
359class wxChildFocusEvent : public wxCommandEvent
360{
361public:
362 wxChildFocusEvent(wxWindow *win = NULL);
363 wxWindow *GetWindow() const;
364};
365
366
7bf85405
RD
367//---------------------------------------------------------------------------
368
369class wxActivateEvent: public wxEvent{
370public:
3ef86e32 371 wxActivateEvent(int eventType = 0, int active = TRUE, int id = 0);
7bf85405
RD
372 bool GetActive();
373};
374
375//---------------------------------------------------------------------------
376
377class wxInitDialogEvent: public wxEvent {
378public:
1475671a 379 wxInitDialogEvent(int id = 0);
7bf85405
RD
380};
381
382//---------------------------------------------------------------------------
383
384class wxMenuEvent: public wxEvent {
385public:
3ef86e32 386 wxMenuEvent(int id = 0, int winid = 0, wxMenu* menu = NULL);
7bf85405 387 int GetMenuId();
afb810d9 388 bool IsPopup();
3ef86e32 389 wxMenu* GetMenu() const;
7bf85405
RD
390};
391
392//---------------------------------------------------------------------------
393
394class wxShowEvent: public wxEvent {
395public:
1475671a 396 wxShowEvent(int id = 0, int show = FALSE);
7bf85405
RD
397 void SetShow(bool show);
398 bool GetShow();
399};
400
401//---------------------------------------------------------------------------
402
403class wxIconizeEvent: public wxEvent {
404public:
d56cebe7
RD
405 wxIconizeEvent(int id = 0, bool iconized = TRUE);
406 bool Iconized();
7bf85405
RD
407};
408
409//---------------------------------------------------------------------------
410
411class wxMaximizeEvent: public wxEvent {
412public:
1475671a 413 wxMaximizeEvent(int id = 0);
7bf85405
RD
414};
415
416//---------------------------------------------------------------------------
417
418class wxJoystickEvent: public wxEvent {
419public:
1475671a
RD
420 wxJoystickEvent(int type = wxEVT_NULL,
421 int state = 0,
422 int joystick = wxJOYSTICK1,
423 int change = 0);
7bf85405
RD
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
444class wxDropFilesEvent: public wxEvent {
445public:
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++) {
c8bc7bb8 461#if wxUSE_UNICODE
1e4a197e 462 PyList_SetItem(list, i, PyUnicode_FromWideChar(files[i], files[i].Len()));
c8bc7bb8 463#else
7bf85405 464 PyList_SetItem(list, i, PyString_FromString((const char*)files[i]));
c8bc7bb8 465#endif
7bf85405
RD
466 }
467 return list;
468 }
469 }
470};
471
472//---------------------------------------------------------------------------
473
3ef86e32
RD
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
478enum 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
7bf85405
RD
489class wxIdleEvent: public wxEvent {
490public:
1475671a 491 wxIdleEvent();
7bf85405
RD
492 void RequestMore(bool needMore = TRUE);
493 bool MoreRequested();
3ef86e32
RD
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
7bf85405
RD
506};
507
508//---------------------------------------------------------------------------
509
3ef86e32
RD
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
514enum 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
7bf85405
RD
525class wxUpdateUIEvent: public wxEvent {
526public:
1475671a 527 wxUpdateUIEvent(wxWindowID commandId = 0);
7bf85405
RD
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);
3ef86e32
RD
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();
7bf85405
RD
561};
562
563//---------------------------------------------------------------------------
564
565class wxSysColourChangedEvent: public wxEvent {
566public:
1475671a 567 wxSysColourChangedEvent();
7bf85405
RD
568};
569
570//---------------------------------------------------------------------------
571
2f90df85
RD
572
573class wxNotifyEvent : public wxCommandEvent {
cf694132 574public:
1475671a 575 wxNotifyEvent(int commandType = wxEVT_NULL, int id = 0);
2f90df85 576 bool IsAllowed();
185d7c3e 577 void Allow();
2f90df85
RD
578 void Veto();
579};
580
581
be43cc44
RD
582//---------------------------------------------------------------------------
583
584class wxDisplayChangedEvent : public wxEvent
585{
586public:
587 wxDisplayChangedEvent();
588};
589
590
2f90df85 591//---------------------------------------------------------------------------
1475671a
RD
592
593class wxPaletteChangedEvent : public wxEvent {
594public:
595 wxPaletteChangedEvent(wxWindowID id = 0);
596
597 void SetChangedWindow(wxWindow* win);
598 wxWindow* GetChangedWindow();
599
600};
601
602//---------------------------------------------------------------------------
603
604class wxQueryNewPaletteEvent : public wxEvent {
605public:
606 wxQueryNewPaletteEvent(wxWindowID id = 0);
607
608 void SetPaletteRealized(bool realized);
609 bool GetPaletteRealized();
610};
611
612
613//---------------------------------------------------------------------------
614
f6bcfd97 615class wxWindowCreateEvent : public wxCommandEvent {
1475671a
RD
616public:
617 wxWindowCreateEvent(wxWindow *win = NULL);
618
619 wxWindow *GetWindow();
620};
621
f6bcfd97 622class wxWindowDestroyEvent : public wxCommandEvent {
1475671a
RD
623public:
624 wxWindowDestroyEvent(wxWindow *win = NULL);
625
626 wxWindow *GetWindow();
627};
628
f6bcfd97
BP
629//---------------------------------------------------------------------------
630
bd5dfc07
RD
631class wxContextMenuEvent : public wxCommandEvent
632{
633public:
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
f6bcfd97
BP
643class wxTimerEvent : public wxEvent
644{
645public:
646 wxTimerEvent(int id = 0, int interval = 0);
647 int GetInterval();
648};
649
c7e7022c
RD
650//---------------------------------------------------------------------------
651
652class wxTextUrlEvent : public wxCommandEvent
653{
654public:
655 wxTextUrlEvent(int id, const wxMouseEvent& evtMouse,
656 long start, long end);
657 const wxMouseEvent& GetMouseEvent();
658 long GetURLStart();
659 long GetURLEnd();
660};
1475671a
RD
661
662//---------------------------------------------------------------------------
663//---------------------------------------------------------------------------
65dd82cb
RD
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.
cf694132 667
2f90df85
RD
668class wxPyEvent : public wxEvent {
669public:
3ef86e32 670 wxPyEvent(int winid=0, wxEventType commandType = wxEVT_NULL );
2f90df85
RD
671 ~wxPyEvent();
672
65dd82cb
RD
673 %pragma(python) addtomethod = "__init__:self.SetSelf(self)"
674
675 void SetSelf(PyObject* self);
676 PyObject* GetSelf();
2f90df85
RD
677};
678
bb0054cd 679
2f90df85 680class wxPyCommandEvent : public wxCommandEvent {
bb0054cd 681public:
65dd82cb
RD
682 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
683 ~wxPyCommandEvent();
2f90df85 684
65dd82cb 685 %pragma(python) addtomethod = "__init__:self.SetSelf(self)"
2f90df85 686
65dd82cb
RD
687 void SetSelf(PyObject* self);
688 PyObject* GetSelf();
2f90df85
RD
689};
690
2f90df85 691
bb0054cd 692
2f90df85 693
bb0054cd
RD
694//---------------------------------------------------------------------------
695//---------------------------------------------------------------------------
7bf85405 696