]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/events.i
Reorganized listctrl demo a bit so I can test a bug report
[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
83b18bab
RD
33
34int wxNewEventType();
35
9416aa89 36class wxEvent : public wxObject {
7bf85405 37public:
ebf4302c 38 // wxEvent(int id = 0); // *** This class is now an ABC
1475671a
RD
39 ~wxEvent();
40
7bf85405
RD
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);
07b2e1cd
RD
51
52 wxEvent *Clone();
7bf85405
RD
53};
54
55//---------------------------------------------------------------------------
56
57class wxSizeEvent : public wxEvent {
58public:
1475671a 59 wxSizeEvent(const wxSize& sz, int id = 0);
7bf85405
RD
60 wxSize GetSize();
61};
62
63//---------------------------------------------------------------------------
64
65class wxCloseEvent : public wxEvent {
66public:
1475671a
RD
67 wxCloseEvent(int commandEventType = 0, int id = 0);
68
e980740a 69 void SetLoggingOff(bool loggingOff);
7bf85405
RD
70 bool GetLoggingOff();
71 void Veto(bool veto = TRUE);
e980740a 72 bool CanVeto();
7bf85405 73 bool GetVeto();
b8b8dda7 74 void SetCanVeto(bool canVeto);
7bf85405
RD
75};
76
77//---------------------------------------------------------------------------
78
79class wxCommandEvent : public wxEvent {
80public:
1475671a
RD
81 wxCommandEvent(int commandEventType = 0, int id = 0);
82
3ca6a5f0
BP
83 bool IsChecked();
84 %name(Checked)bool IsChecked();
7bf85405
RD
85 long GetExtraLong();
86 int GetInt();
87 int GetSelection();
cf694132 88 wxString GetString();
7bf85405 89 bool IsSelection();
6999b0d8
RD
90 void SetString(const wxString& s);
91 void SetExtraLong(long extraLong);
92 void SetInt(int i);
93
900d9886
RD
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 }
7bf85405
RD
106};
107
108
109//---------------------------------------------------------------------------
110
111class wxScrollEvent: public wxCommandEvent {
112public:
1475671a
RD
113 wxScrollEvent(int commandType = 0, int id = 0, int pos = 0,
114 int orientation = 0);
115
7bf85405
RD
116 int GetOrientation();
117 int GetPosition();
118};
119
120//---------------------------------------------------------------------------
121
d426c97e
RD
122class wxScrollWinEvent: public wxEvent {
123public:
1475671a
RD
124 wxScrollWinEvent(int commandType = 0, int pos = 0,
125 int orientation = 0);
126
d426c97e
RD
127 int GetOrientation();
128 int GetPosition();
129};
130
131//---------------------------------------------------------------------------
132
62bd0874
RD
133class wxSpinEvent : public wxScrollEvent {
134public:
1475671a 135 wxSpinEvent(int commandType = 0, int id = 0);
62bd0874
RD
136
137};
138
139//---------------------------------------------------------------------------
140
7bf85405
RD
141class wxMouseEvent: public wxEvent {
142public:
1475671a
RD
143 wxMouseEvent(int mouseEventType = 0);
144
7bf85405
RD
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();
7bf85405 171 wxPoint GetPosition();
b1462dfa 172 %name(GetPositionTuple)void GetPosition(long *OUTPUT, long *OUTPUT);
7bf85405
RD
173 wxPoint GetLogicalPosition(const wxDC& dc);
174 long GetX();
175 long GetY();
c368d904 176
d1679124
RD
177 int GetWheelRotation() const { return m_wheelRotation; }
178 int GetWheelDelta() const { return m_wheelDelta; }
179 int GetLinesPerAction() const { return m_linesPerAction; }
180
c368d904
RD
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;
d1679124
RD
189 int m_wheelRotation;
190 int m_wheelDelta;
191 int m_linesPerAction;
7bf85405
RD
192};
193
194//---------------------------------------------------------------------------
195
6d26dc89
RD
196class wxMouseCaptureChangedEvent : public wxEvent
197{
198public:
199 wxMouseCaptureChangedEvent(wxWindowID id = 0, wxWindow* gainedCapture = NULL);
200 wxWindow* GetCapturedWindow() const;
201};
202
203//---------------------------------------------------------------------------
204
203c2f9a
RD
205class wxSetCursorEvent : public wxEvent
206{
207public:
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
7bf85405
RD
220class wxKeyEvent: public wxEvent {
221public:
1475671a
RD
222 wxKeyEvent(int keyEventType);
223
7bf85405
RD
224 bool ControlDown();
225 bool MetaDown();
226 bool AltDown();
227 bool ShiftDown();
228 long KeyCode();
e980740a 229
f6bcfd97
BP
230 long GetKeyCode();
231 bool HasModifiers();
232
db0ff83e
RD
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
1475671a
RD
239 long GetX();
240 long GetY();
241 wxPoint GetPosition();
242 %name(GetPositionTuple) void GetPosition(long* OUTPUT, long* OUTPUT);
c368d904 243
db0ff83e
RD
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;
c368d904 253
7bf85405
RD
254};
255
2f90df85
RD
256//---------------------------------------------------------------------------
257
eec92d76 258class wxNavigationKeyEvent : public wxEvent {
1475671a
RD
259public:
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};
2f90df85
RD
269
270
7bf85405
RD
271//---------------------------------------------------------------------------
272
273class wxMoveEvent: public wxEvent {
274public:
1475671a
RD
275 wxMoveEvent(const wxPoint& pt, int id = 0);
276
7bf85405
RD
277 wxPoint GetPosition();
278};
279
280//---------------------------------------------------------------------------
281
282class wxPaintEvent: public wxEvent {
283public:
1475671a 284 wxPaintEvent(int id = 0);
7bf85405
RD
285
286};
287
288//---------------------------------------------------------------------------
289
290class wxEraseEvent: public wxEvent {
291public:
1475671a
RD
292 wxEraseEvent(int id = 0, wxDC* dc = NULL);
293
7bf85405
RD
294 wxDC *GetDC();
295};
296
297//---------------------------------------------------------------------------
298
299class wxFocusEvent: public wxEvent {
300public:
1475671a 301 wxFocusEvent(WXTYPE eventType = 0, int id = 0);
7bf85405
RD
302};
303
7b7ac0ab
RD
304//---------------------------------------------------------------------------
305
306// wxChildFocusEvent notifies the parent that a child has got the focus: unlike
307// wxFocusEvent it is propgated upwards the window chain
308class wxChildFocusEvent : public wxCommandEvent
309{
310public:
311 wxChildFocusEvent(wxWindow *win = NULL);
312 wxWindow *GetWindow() const;
313};
314
315
7bf85405
RD
316//---------------------------------------------------------------------------
317
318class wxActivateEvent: public wxEvent{
319public:
1475671a 320 wxActivateEvent(WXTYPE eventType = 0, int active = TRUE, int id = 0);
7bf85405
RD
321 bool GetActive();
322};
323
324//---------------------------------------------------------------------------
325
326class wxInitDialogEvent: public wxEvent {
327public:
1475671a 328 wxInitDialogEvent(int id = 0);
7bf85405
RD
329};
330
331//---------------------------------------------------------------------------
332
333class wxMenuEvent: public wxEvent {
334public:
1475671a 335 wxMenuEvent(WXTYPE id = 0, int id = 0);
7bf85405 336 int GetMenuId();
afb810d9 337 bool IsPopup();
7bf85405
RD
338};
339
340//---------------------------------------------------------------------------
341
342class wxShowEvent: public wxEvent {
343public:
1475671a 344 wxShowEvent(int id = 0, int show = FALSE);
7bf85405
RD
345 void SetShow(bool show);
346 bool GetShow();
347};
348
349//---------------------------------------------------------------------------
350
351class wxIconizeEvent: public wxEvent {
352public:
d56cebe7
RD
353 wxIconizeEvent(int id = 0, bool iconized = TRUE);
354 bool Iconized();
7bf85405
RD
355};
356
357//---------------------------------------------------------------------------
358
359class wxMaximizeEvent: public wxEvent {
360public:
1475671a 361 wxMaximizeEvent(int id = 0);
7bf85405
RD
362};
363
364//---------------------------------------------------------------------------
365
366class wxJoystickEvent: public wxEvent {
367public:
1475671a
RD
368 wxJoystickEvent(int type = wxEVT_NULL,
369 int state = 0,
370 int joystick = wxJOYSTICK1,
371 int change = 0);
7bf85405
RD
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
392class wxDropFilesEvent: public wxEvent {
393public:
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++) {
c8bc7bb8
RD
409#if wxUSE_UNICODE
410 PyList_SetItem(list, i, PyUnicode_FromUnicode(files[i], files[i].Len()));
411#else
7bf85405 412 PyList_SetItem(list, i, PyString_FromString((const char*)files[i]));
c8bc7bb8 413#endif
7bf85405
RD
414 }
415 return list;
416 }
417 }
418};
419
420//---------------------------------------------------------------------------
421
422class wxIdleEvent: public wxEvent {
423public:
1475671a 424 wxIdleEvent();
7bf85405
RD
425 void RequestMore(bool needMore = TRUE);
426 bool MoreRequested();
427};
428
429//---------------------------------------------------------------------------
430
431class wxUpdateUIEvent: public wxEvent {
432public:
1475671a 433 wxUpdateUIEvent(wxWindowID commandId = 0);
7bf85405
RD
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
448class wxSysColourChangedEvent: public wxEvent {
449public:
1475671a 450 wxSysColourChangedEvent();
7bf85405
RD
451};
452
453//---------------------------------------------------------------------------
454
2f90df85
RD
455
456class wxNotifyEvent : public wxCommandEvent {
cf694132 457public:
1475671a 458 wxNotifyEvent(int commandType = wxEVT_NULL, int id = 0);
2f90df85 459 bool IsAllowed();
185d7c3e 460 void Allow();
2f90df85
RD
461 void Veto();
462};
463
464
be43cc44
RD
465//---------------------------------------------------------------------------
466
467class wxDisplayChangedEvent : public wxEvent
468{
469public:
470 wxDisplayChangedEvent();
471};
472
473
2f90df85 474//---------------------------------------------------------------------------
1475671a
RD
475
476class wxPaletteChangedEvent : public wxEvent {
477public:
478 wxPaletteChangedEvent(wxWindowID id = 0);
479
480 void SetChangedWindow(wxWindow* win);
481 wxWindow* GetChangedWindow();
482
483};
484
485//---------------------------------------------------------------------------
486
487class wxQueryNewPaletteEvent : public wxEvent {
488public:
489 wxQueryNewPaletteEvent(wxWindowID id = 0);
490
491 void SetPaletteRealized(bool realized);
492 bool GetPaletteRealized();
493};
494
495
496//---------------------------------------------------------------------------
497
f6bcfd97 498class wxWindowCreateEvent : public wxCommandEvent {
1475671a
RD
499public:
500 wxWindowCreateEvent(wxWindow *win = NULL);
501
502 wxWindow *GetWindow();
503};
504
f6bcfd97 505class wxWindowDestroyEvent : public wxCommandEvent {
1475671a
RD
506public:
507 wxWindowDestroyEvent(wxWindow *win = NULL);
508
509 wxWindow *GetWindow();
510};
511
f6bcfd97
BP
512//---------------------------------------------------------------------------
513
bd5dfc07
RD
514class wxContextMenuEvent : public wxCommandEvent
515{
516public:
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
f6bcfd97
BP
526class wxTimerEvent : public wxEvent
527{
528public:
529 wxTimerEvent(int id = 0, int interval = 0);
530 int GetInterval();
531};
532
c7e7022c
RD
533//---------------------------------------------------------------------------
534
535class wxTextUrlEvent : public wxCommandEvent
536{
537public:
538 wxTextUrlEvent(int id, const wxMouseEvent& evtMouse,
539 long start, long end);
540 const wxMouseEvent& GetMouseEvent();
541 long GetURLStart();
542 long GetURLEnd();
543};
1475671a
RD
544
545//---------------------------------------------------------------------------
546//---------------------------------------------------------------------------
65dd82cb
RD
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.
cf694132 550
2f90df85
RD
551class wxPyEvent : public wxEvent {
552public:
65dd82cb 553 wxPyEvent(int id=0);
2f90df85
RD
554 ~wxPyEvent();
555
65dd82cb
RD
556 %pragma(python) addtomethod = "__init__:self.SetSelf(self)"
557
558 void SetSelf(PyObject* self);
559 PyObject* GetSelf();
2f90df85
RD
560};
561
bb0054cd 562
2f90df85 563class wxPyCommandEvent : public wxCommandEvent {
bb0054cd 564public:
65dd82cb
RD
565 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
566 ~wxPyCommandEvent();
2f90df85 567
65dd82cb 568 %pragma(python) addtomethod = "__init__:self.SetSelf(self)"
2f90df85 569
65dd82cb
RD
570 void SetSelf(PyObject* self);
571 PyObject* GetSelf();
2f90df85
RD
572};
573
2f90df85 574
bb0054cd 575
2f90df85 576
bb0054cd
RD
577//---------------------------------------------------------------------------
578//---------------------------------------------------------------------------
7bf85405 579