]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/events.i
added font encoding support
[wxWidgets.git] / utils / 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
30 //---------------------------------------------------------------------------
31
32 class wxEvent {
33 public:
34 wxObject* GetEventObject();
35 wxEventType GetEventType();
36 int GetId();
37 bool GetSkipped();
38 long GetTimestamp();
39 void SetEventObject(wxObject* object);
40 void SetEventType(wxEventType typ);
41 void SetId(int id);
42 void SetTimestamp(long timeStamp);
43 void Skip(bool skip = TRUE);
44 };
45
46 //---------------------------------------------------------------------------
47
48 class wxSizeEvent : public wxEvent {
49 public:
50 wxSize GetSize();
51 };
52
53 //---------------------------------------------------------------------------
54
55 class wxCloseEvent : public wxEvent {
56 public:
57 void SetLoggingOff(bool loggingOff);
58 bool GetLoggingOff();
59 void Veto(bool veto = TRUE);
60 bool CanVeto();
61 bool GetVeto();
62 void SetCanVeto(bool canVeto);
63 };
64
65 //---------------------------------------------------------------------------
66
67 class wxCommandEvent : public wxEvent {
68 public:
69 bool Checked();
70 long GetExtraLong();
71 int GetInt();
72 int GetSelection();
73 wxString GetString();
74 bool IsSelection();
75 };
76
77
78 //---------------------------------------------------------------------------
79
80 class wxScrollEvent: public wxCommandEvent {
81 public:
82 int GetOrientation();
83 int GetPosition();
84 };
85
86 //---------------------------------------------------------------------------
87
88 class wxScrollWinEvent: public wxEvent {
89 public:
90 int GetOrientation();
91 int GetPosition();
92 };
93
94 //---------------------------------------------------------------------------
95
96 class wxSpinEvent : public wxScrollEvent {
97 public:
98
99 };
100
101 //---------------------------------------------------------------------------
102
103 class wxMouseEvent: public wxEvent {
104 public:
105 bool IsButton();
106 bool ButtonDown(int but = -1);
107 bool ButtonDClick(int but = -1);
108 bool ButtonUp(int but = -1);
109 bool Button(int but);
110 bool ButtonIsDown(int but);
111 bool ControlDown();
112 bool MetaDown();
113 bool AltDown();
114 bool ShiftDown();
115 bool LeftDown();
116 bool MiddleDown();
117 bool RightDown();
118 bool LeftUp();
119 bool MiddleUp();
120 bool RightUp();
121 bool LeftDClick();
122 bool MiddleDClick();
123 bool RightDClick();
124 bool LeftIsDown();
125 bool MiddleIsDown();
126 bool RightIsDown();
127 bool Dragging();
128 bool Moving();
129 bool Entering();
130 bool Leaving();
131 void Position(long *OUTPUT, long *OUTPUT);
132 wxPoint GetPosition();
133 wxPoint GetLogicalPosition(const wxDC& dc);
134 long GetX();
135 long GetY();
136 };
137
138 //---------------------------------------------------------------------------
139
140 class wxKeyEvent: public wxEvent {
141 public:
142 bool ControlDown();
143 bool MetaDown();
144 bool AltDown();
145 bool ShiftDown();
146 long KeyCode();
147
148 };
149
150 //---------------------------------------------------------------------------
151
152 // class wxNavigationKeyEvent : public wxCommandEvent {
153 // public:
154 // wxNavigationKeyEvent();
155
156 // bool GetDirection();
157 // void SetDirection(bool bForward);
158 // bool IsWindowChange();
159 // void SetWindowChange(bool bIs);
160 // wxWindow* GetCurrentFocus();
161 // void SetCurrentFocus(wxWindow *win);
162 // };
163
164
165 //---------------------------------------------------------------------------
166
167 class wxMoveEvent: public wxEvent {
168 public:
169 wxPoint GetPosition();
170 };
171
172 //---------------------------------------------------------------------------
173
174 class wxPaintEvent: public wxEvent {
175 public:
176
177 };
178
179 //---------------------------------------------------------------------------
180
181 class wxEraseEvent: public wxEvent {
182 public:
183 wxDC *GetDC();
184 };
185
186 //---------------------------------------------------------------------------
187
188 class wxFocusEvent: public wxEvent {
189 public:
190
191 };
192
193 //---------------------------------------------------------------------------
194
195 class wxActivateEvent: public wxEvent{
196 public:
197 bool GetActive();
198 };
199
200 //---------------------------------------------------------------------------
201
202 class wxInitDialogEvent: public wxEvent {
203 public:
204
205 };
206
207 //---------------------------------------------------------------------------
208
209 class wxMenuEvent: public wxEvent {
210 public:
211 int GetMenuId();
212 };
213
214 //---------------------------------------------------------------------------
215
216 class wxShowEvent: public wxEvent {
217 public:
218 void SetShow(bool show);
219 bool GetShow();
220 };
221
222 //---------------------------------------------------------------------------
223
224 class wxIconizeEvent: public wxEvent {
225 public:
226 };
227
228 //---------------------------------------------------------------------------
229
230 class wxMaximizeEvent: public wxEvent {
231 public:
232
233 };
234
235 //---------------------------------------------------------------------------
236
237 class wxJoystickEvent: public wxEvent {
238 public:
239 wxPoint GetPosition();
240 int GetZPosition();
241 int GetButtonState();
242 int GetButtonChange();
243 int GetJoystick();
244 void SetJoystick(int stick);
245 void SetButtonState(int state);
246 void SetButtonChange(int change);
247 void SetPosition(const wxPoint& pos);
248 void SetZPosition(int zPos);
249 bool IsButton();
250 bool IsMove();
251 bool IsZMove();
252 bool ButtonDown(int but = wxJOY_BUTTON_ANY);
253 bool ButtonUp(int but = wxJOY_BUTTON_ANY);
254 bool ButtonIsDown(int but = wxJOY_BUTTON_ANY);
255 };
256
257 //---------------------------------------------------------------------------
258
259 class wxDropFilesEvent: public wxEvent {
260 public:
261 wxPoint GetPosition();
262 int GetNumberOfFiles();
263
264 %addmethods {
265 PyObject* GetFiles() {
266 int count = self->GetNumberOfFiles();
267 wxString* files = self->GetFiles();
268 PyObject* list = PyList_New(count);
269
270 if (!list) {
271 PyErr_SetString(PyExc_MemoryError, "Can't allocate list of files!");
272 return NULL;
273 }
274
275 for (int i=0; i<count; i++) {
276 PyList_SetItem(list, i, PyString_FromString((const char*)files[i]));
277 }
278 return list;
279 }
280 }
281 };
282
283 //---------------------------------------------------------------------------
284
285 class wxIdleEvent: public wxEvent {
286 public:
287 void RequestMore(bool needMore = TRUE);
288 bool MoreRequested();
289 };
290
291 //---------------------------------------------------------------------------
292
293 class wxUpdateUIEvent: public wxEvent {
294 public:
295 bool GetChecked();
296 bool GetEnabled();
297 wxString GetText();
298 bool GetSetText();
299 bool GetSetChecked();
300 bool GetSetEnabled();
301
302 void Check(bool check);
303 void Enable(bool enable);
304 void SetText(const wxString& text);
305 };
306
307 //---------------------------------------------------------------------------
308
309 class wxSysColourChangedEvent: public wxEvent {
310 public:
311
312 };
313
314 //---------------------------------------------------------------------------
315
316
317 class wxNotifyEvent : public wxCommandEvent {
318 public:
319 bool IsAllowed();
320 void Veto();
321 };
322
323
324 //---------------------------------------------------------------------------
325 //---------------------------------------------------------------------------
326 // This one can be derived from in Python and passed through the event
327 // system without loosing anything so long as the Python data is saved with
328 // SetPyData...
329
330 %{
331 class wxPyEvent : public wxEvent {
332 DECLARE_DYNAMIC_CLASS(wxPyEvent)
333 public:
334 wxPyEvent(int id=0, PyObject* userData = Py_None)
335 : wxEvent(id) {
336 m_userData = userData;
337 Py_INCREF(m_userData);
338 }
339
340 ~wxPyEvent() {
341 bool doSave = wxPyRestoreThread();
342 Py_DECREF(m_userData);
343 wxPySaveThread(doSave);
344 }
345
346 void SetPyData(PyObject* userData) {
347 bool doSave = wxPyRestoreThread();
348 Py_DECREF(m_userData);
349 m_userData = userData;
350 Py_INCREF(m_userData);
351 wxPySaveThread(doSave);
352 }
353
354 PyObject* GetPyData() const {
355 Py_INCREF(m_userData);
356 return m_userData;
357 }
358
359 // This one is so the event object can be Cloned...
360 void CopyObject(wxObject& dest) const {
361 wxEvent::CopyObject(dest);
362 ((wxPyEvent*)&dest)->SetPyData(m_userData);
363 }
364
365 private:
366 PyObject* m_userData;
367 };
368
369 IMPLEMENT_DYNAMIC_CLASS(wxPyEvent, wxEvent)
370
371 %}
372
373
374 class wxPyEvent : public wxEvent {
375 public:
376 wxPyEvent(int id=0, PyObject* userData = Py_None);
377 ~wxPyEvent();
378
379 void SetPyData(PyObject* userData);
380 PyObject* GetPyData();
381 };
382
383 //---------------------------------------------------------------------------
384 // Same for this one except it is a wxCommandEvent and so will get passed up the
385 // containment heirarchy.
386
387 %{
388 class wxPyCommandEvent : public wxCommandEvent {
389 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent)
390 public:
391 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0, PyObject* userData = Py_None)
392 : wxCommandEvent(commandType, id) {
393 m_userData = userData;
394 Py_INCREF(m_userData);
395 }
396
397 ~wxPyCommandEvent() {
398 bool doSave = wxPyRestoreThread();
399 Py_DECREF(m_userData);
400 wxPySaveThread(doSave);
401 }
402
403 void SetPyData(PyObject* userData) {
404 bool doSave = wxPyRestoreThread();
405 Py_DECREF(m_userData);
406 m_userData = userData;
407 Py_INCREF(m_userData);
408 wxPySaveThread(doSave);
409 }
410
411 PyObject* GetPyData() const {
412 Py_INCREF(m_userData);
413 return m_userData;
414 }
415
416 // This one is so the event object can be Cloned...
417 void CopyObject(wxObject& dest) const {
418 wxCommandEvent::CopyObject(dest);
419 ((wxPyCommandEvent*)&dest)->SetPyData(m_userData);
420 }
421
422 private:
423 PyObject* m_userData;
424 };
425
426 IMPLEMENT_DYNAMIC_CLASS(wxPyCommandEvent, wxCommandEvent)
427
428 %}
429
430
431 class wxPyCommandEvent : public wxCommandEvent {
432 public:
433 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0, PyObject* userData = Py_None);
434 ~wxPyCommandEvent();
435
436 void SetPyData(PyObject* userData);
437 PyObject* GetPyData();
438 };
439
440
441 //---------------------------------------------------------------------------
442 //---------------------------------------------------------------------------
443