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