]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/_extras.py
Now uses proper wxUSE_xxx flags
[wxWidgets.git] / utils / wxPython / src / _extras.py
CommitLineData
7bf85405
RD
1#----------------------------------------------------------------------------
2# Name: _extra.py
3# Purpose: This file is appended to the shadow class file generated
4# by SWIG. We add some unSWIGable things here.
5#
6# Author: Robin Dunn
7#
8# Created: 6/30/97
9# RCS-ID: $Id$
10# Copyright: (c) 1998 by Total Control Software
11# Licence: wxWindows license
12#----------------------------------------------------------------------------
13
14import sys
15
16#----------------------------------------------------------------------
17# This gives this module's dictionary to the C++ extension code...
18
19_wxSetDictionary(vars())
20
21
22#----------------------------------------------------------------------
23#----------------------------------------------------------------------
24# Helper function to link python methods to wxWindows virtual
25# functions by name.
26
27def _checkForCallback(obj, name, event, theID=-1):
28 try: cb = getattr(obj, name)
29 except: pass
30 else: obj.Connect(theID, -1, event, cb)
31
bb0054cd
RD
32## def _checkClassCallback(obj, name):
33## try: cb = getattr(obj, name)
34## except: pass
35## else: obj._addCallback(name, cb)
36
37
7bf85405
RD
38def _StdWindowCallbacks(win):
39 _checkForCallback(win, "OnChar", wxEVT_CHAR)
40 _checkForCallback(win, "OnSize", wxEVT_SIZE)
41 _checkForCallback(win, "OnEraseBackground", wxEVT_ERASE_BACKGROUND)
42 _checkForCallback(win, "OnSysColourChanged", wxEVT_SYS_COLOUR_CHANGED)
43 _checkForCallback(win, "OnInitDialog", wxEVT_INIT_DIALOG)
7bf85405 44 _checkForCallback(win, "OnPaint", wxEVT_PAINT)
cf694132
RD
45 _checkForCallback(win, "OnIdle", wxEVT_IDLE)
46
7bf85405
RD
47
48def _StdFrameCallbacks(win):
49 _StdWindowCallbacks(win)
50 _checkForCallback(win, "OnActivate", wxEVT_ACTIVATE)
51 _checkForCallback(win, "OnMenuHighlight", wxEVT_MENU_HIGHLIGHT)
52 _checkForCallback(win, "OnCloseWindow", wxEVT_CLOSE_WINDOW)
53
54
9c039d08
RD
55def _StdDialogCallbacks(win):
56 _StdWindowCallbacks(win)
57 _checkForCallback(win, "OnOk", wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK)
58 _checkForCallback(win, "OnApply", wxEVT_COMMAND_BUTTON_CLICKED, wxID_APPLY)
59 _checkForCallback(win, "OnCancel", wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL)
60 _checkForCallback(win, "OnCloseWindow", wxEVT_CLOSE_WINDOW)
61 _checkForCallback(win, "OnCharHook", wxEVT_CHAR_HOOK)
62
63
cf694132 64def _StdOnScrollCallbacks(win):
7bf85405
RD
65 try: cb = getattr(win, "OnScroll")
66 except: pass
67 else: EVT_SCROLL(win, cb)
68
69
70
71#----------------------------------------------------------------------
72#----------------------------------------------------------------------
73# functions that look and act like the C++ Macros of the same name
74
75
76# Miscellaneous
77def EVT_SIZE(win, func):
78 win.Connect(-1, -1, wxEVT_SIZE, func)
79
80def EVT_MOVE(win, func):
81 win.Connect(-1, -1, wxEVT_MOVE, func)
82
83def EVT_CLOSE(win, func):
84 win.Connect(-1, -1, wxEVT_CLOSE_WINDOW, func)
85
86def EVT_PAINT(win, func):
87 win.Connect(-1, -1, wxEVT_PAINT, func)
88
89def EVT_ERASE_BACKGROUND(win, func):
90 win.Connect(-1, -1, wxEVT_ERASE_BACKGROUND, func)
91
92def EVT_CHAR(win, func):
93 win.Connect(-1, -1, wxEVT_CHAR, func)
94
95def EVT_CHAR_HOOK(win, func):
96 win.Connect(-1, -1, wxEVT_CHAR_HOOK, func)
97
98def EVT_MENU_HIGHLIGHT(win, id, func):
99 win.Connect(id, -1, wxEVT_MENU_HIGHLIGHT, func)
100
101def EVT_MENU_HIGHLIGHT_ALL(win, func):
102 win.Connect(-1, -1, wxEVT_MENU_HIGHLIGHT, func)
103
104def EVT_SET_FOCUS(win, func):
105 win.Connect(-1, -1, wxEVT_SET_FOCUS, func)
106
107def EVT_KILL_FOCUS(win, func):
108 win.Connect(-1, -1, wxEVT_KILL_FOCUS, func)
109
110def EVT_ACTIVATE(win, func):
111 win.Connect(-1, -1, wxEVT_ACTIVATE, func)
112
113def EVT_ACTIVATE_APP(win, func):
114 win.Connect(-1, -1, wxEVT_ACTIVATE_APP, func)
115
116def EVT_END_SESSION(win, func):
117 win.Connect(-1, -1, wxEVT_END_SESSION, func)
118
119def EVT_QUERY_END_SESSION(win, func):
120 win.Connect(-1, -1, wxEVT_QUERY_END_SESSION, func)
121
122def EVT_DROP_FILES(win, func):
123 win.Connect(-1, -1, wxEVT_DROP_FILES, func)
124
125def EVT_INIT_DIALOG(win, func):
126 win.Connect(-1, -1, wxEVT_INIT_DIALOG, func)
127
128def EVT_SYS_COLOUR_CHANGED(win, func):
129 win.Connect(-1, -1, wxEVT_SYS_COLOUR_CHANGED, func)
130
131def EVT_SHOW(win, func):
132 win.Connect(-1, -1, wxEVT_SHOW, func)
133
134def EVT_MAXIMIZE(win, func):
135 win.Connect(-1, -1, wxEVT_MAXIMIZE, func)
136
137def EVT_ICONIZE(win, func):
138 win.Connect(-1, -1, wxEVT_ICONIZE, func)
139
140def EVT_NAVIGATION_KEY(win, func):
141 win.Connect(-1, -1, wxEVT_NAVIGATION_KEY, func)
142
cf694132
RD
143def EVT_IDLE(win, func):
144 win.Connect(-1, -1, wxEVT_IDLE, func)
145
bb0054cd
RD
146def EVT_UPDATE_UI(win, id, func):
147 win.Connect(id, -1, wxEVT_UPDATE_UI, func)
148
7bf85405
RD
149
150# Mouse Events
151def EVT_LEFT_DOWN(win, func):
152 win.Connect(-1, -1, wxEVT_LEFT_DOWN, func)
153
154def EVT_LEFT_UP(win, func):
155 win.Connect(-1, -1, wxEVT_LEFT_UP, func)
156
157def EVT_MIDDLE_DOWN(win, func):
158 win.Connect(-1, -1, wxEVT_MIDDLE_DOWN, func)
159
160def EVT_MIDDLE_UP(win, func):
161 win.Connect(-1, -1, wxEVT_MIDDLE_UP, func)
162
163def EVT_RIGHT_DOWN(win, func):
164 win.Connect(-1, -1, wxEVT_RIGHT_DOWN, func)
165
166def EVT_RIGHT_UP(win, func):
167 win.Connect(-1, -1, wxEVT_RIGHT_UP, func)
168
169def EVT_MOTION(win, func):
170 win.Connect(-1, -1, wxEVT_MOTION, func)
171
172def EVT_LEFT_DCLICK(win, func):
173 win.Connect(-1, -1, wxEVT_LEFT_DCLICK, func)
174
175def EVT_MIDDLE_DCLICK(win, func):
176 win.Connect(-1, -1, wxEVT_MIDDLE_DCLICK, func)
177
178def EVT_RIGHT_DCLICK(win, func):
179 win.Connect(-1, -1, wxEVT_RIGHT_DCLICK, func)
180
181def EVT_LEAVE_WINDOW(win, func):
182 win.Connect(-1, -1, wxEVT_LEAVE_WINDOW, func)
183
184def EVT_ENTER_WINDOW(win, func):
185 win.Connect(-1, -1, wxEVT_ENTER_WINDOW, func)
186
187
188# all mouse events
189def EVT_MOUSE_EVENTS(win, func):
190 win.Connect(-1, -1, wxEVT_LEFT_DOWN, func)
191 win.Connect(-1, -1, wxEVT_LEFT_UP, func)
192 win.Connect(-1, -1, wxEVT_MIDDLE_DOWN, func)
193 win.Connect(-1, -1, wxEVT_MIDDLE_UP, func)
194 win.Connect(-1, -1, wxEVT_RIGHT_DOWN, func)
195 win.Connect(-1, -1, wxEVT_RIGHT_UP, func)
196 win.Connect(-1, -1, wxEVT_MOTION, func)
197 win.Connect(-1, -1, wxEVT_LEFT_DCLICK, func)
198 win.Connect(-1, -1, wxEVT_MIDDLE_DCLICK, func)
199 win.Connect(-1, -1, wxEVT_RIGHT_DCLICK, func)
200 win.Connect(-1, -1, wxEVT_LEAVE_WINDOW, func)
201 win.Connect(-1, -1, wxEVT_ENTER_WINDOW, func)
202
203# EVT_COMMAND
204def EVT_COMMAND(win, id, cmd, func):
205 win.Connect(id, -1, cmd, func)
206
207def EVT_COMMAND_RANGE(win, id1, id2, cmd, func):
208 win.Connect(id1, id2, cmd, func)
209
210# Scrolling
211def EVT_SCROLL(win, func):
212 win.Connect(-1, -1, wxEVT_SCROLL_TOP, func)
213 win.Connect(-1, -1, wxEVT_SCROLL_BOTTOM, func)
214 win.Connect(-1, -1, wxEVT_SCROLL_LINEUP, func)
215 win.Connect(-1, -1, wxEVT_SCROLL_LINEDOWN, func)
216 win.Connect(-1, -1, wxEVT_SCROLL_PAGEUP, func)
217 win.Connect(-1, -1, wxEVT_SCROLL_PAGEDOWN, func)
218 win.Connect(-1, -1, wxEVT_SCROLL_THUMBTRACK,func)
219
220def EVT_SCROLL_TOP(win, func):
221 win.Connect(-1, -1, wxEVT_SCROLL_TOP, func)
222
223def EVT_SCROLL_BOTTOM(win, func):
224 win.Connect(-1, -1, wxEVT_SCROLL_BOTTOM, func)
225
226def EVT_SCROLL_LINEUP(win, func):
227 win.Connect(-1, -1, wxEVT_SCROLL_LINEUP, func)
228
229def EVT_SCROLL_LINEDOWN(win, func):
230 win.Connect(-1, -1, wxEVT_SCROLL_LINEDOWN, func)
231
232def EVT_SCROLL_PAGEUP(win, func):
233 win.Connect(-1, -1, wxEVT_SCROLL_PAGEUP, func)
234
235def EVT_SCROLL_PAGEDOWN(win, func):
236 win.Connect(-1, -1, wxEVT_SCROLL_PAGEDOWN, func)
237
238def EVT_SCROLL_THUMBTRACK(win, func):
239 win.Connect(-1, -1, wxEVT_SCROLL_THUMBTRACK, func)
240
241
242
243# Scrolling, with an id
244def EVT_COMMAND_SCROLL(win, id, func):
245 win.Connect(id, -1, wxEVT_SCROLL_TOP, func)
246 win.Connect(id, -1, wxEVT_SCROLL_BOTTOM, func)
247 win.Connect(id, -1, wxEVT_SCROLL_LINEUP, func)
248 win.Connect(id, -1, wxEVT_SCROLL_LINEDOWN, func)
249 win.Connect(id, -1, wxEVT_SCROLL_PAGEUP, func)
250 win.Connect(id, -1, wxEVT_SCROLL_PAGEDOWN, func)
251 win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK,func)
252
253def EVT_COMMAND_SCROLL_TOP(win, id, func):
254 win.Connect(id, -1, wxEVT_SCROLL_TOP, func)
255
256def EVT_COMMAND_SCROLL_BOTTOM(win, id, func):
257 win.Connect(id, -1, wxEVT_SCROLL_BOTTOM, func)
258
259def EVT_COMMAND_SCROLL_LINEUP(win, id, func):
260 win.Connect(id, -1, wxEVT_SCROLL_LINEUP, func)
261
262def EVT_COMMAND_SCROLL_LINEDOWN(win, id, func):
263 win.Connect(id, -1, wxEVT_SCROLL_LINEDOWN, func)
264
265def EVT_COMMAND_SCROLL_PAGEUP(win, id, func):
266 win.Connect(id, -1, wxEVT_SCROLL_PAGEUP, func)
267
268def EVT_COMMAND_SCROLL_PAGEDOWN(win, id, func):
269 win.Connect(id, -1, wxEVT_SCROLL_PAGEDOWN, func)
270
271def EVT_COMMAND_SCROLL_THUMBTRACK(win, id, func):
272 win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK, func)
273
274
275# Convenience commands
276def EVT_BUTTON(win, id, func):
277 win.Connect(id, -1, wxEVT_COMMAND_BUTTON_CLICKED, func)
278
279def EVT_CHECKBOX(win, id, func):
280 win.Connect(id, -1, wxEVT_COMMAND_CHECKBOX_CLICKED, func)
281
282def EVT_CHOICE(win, id, func):
283 win.Connect(id, -1, wxEVT_COMMAND_CHOICE_SELECTED, func)
284
285def EVT_LISTBOX(win, id, func):
286 win.Connect(id, -1, wxEVT_COMMAND_LISTBOX_SELECTED, func)
287
288def EVT_LISTBOX_DCLICK(win, id, func):
289 win.Connect(id, -1, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, func)
290
291def EVT_TEXT(win, id, func):
292 win.Connect(id, -1, wxEVT_COMMAND_TEXT_UPDATED, func)
293
294def EVT_TEXT_ENTER(win, id, func):
295 win.Connect(id, -1, wxEVT_COMMAND_TEXT_ENTER, func)
296
297def EVT_MENU(win, id, func):
298 win.Connect(id, -1, wxEVT_COMMAND_MENU_SELECTED, func)
299
300def EVT_MENU_RANGE(win, id1, id2, func):
301 win.Connect(id1, id2, wxEVT_COMMAND_MENU_SELECTED, func)
302
303def EVT_SLIDER(win, id, func):
304 win.Connect(id, -1, wxEVT_COMMAND_SLIDER_UPDATED, func)
305
306def EVT_RADIOBOX(win, id, func):
307 win.Connect(id, -1, wxEVT_COMMAND_RADIOBOX_SELECTED, func)
308
309def EVT_RADIOBUTTON(win, id, func):
310 win.Connect(id, -1, wxEVT_COMMAND_RADIOBUTTON_SELECTED, func)
311
312def EVT_VLBOX(win, id, func):
313 win.Connect(id, -1, wxEVT_COMMAND_VLBOX_SELECTED, func)
314
315def EVT_COMBOBOX(win, id, func):
316 win.Connect(id, -1, wxEVT_COMMAND_COMBOBOX_SELECTED, func)
317
318def EVT_TOOL(win, id, func):
319 win.Connect(id, -1, wxEVT_COMMAND_TOOL_CLICKED, func)
320
321def EVT_TOOL_RCLICKED(win, id, func):
322 win.Connect(id, -1, wxEVT_COMMAND_TOOL_RCLICKED, func)
323
324def EVT_TOOL_ENTER(win, id, func):
325 win.Connect(id, -1, wxEVT_COMMAND_TOOL_ENTER, func)
326
327def EVT_CHECKLISTBOX(win, id, func):
328 win.Connect(id, -1, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, func)
329
330
331# Generic command events
332
333def EVT_COMMAND_LEFT_CLICK(win, id, func):
334 win.Connect(id, -1, wxEVT_COMMAND_LEFT_CLICK, func)
335
336def EVT_COMMAND_LEFT_DCLICK(win, id, func):
337 win.Connect(id, -1, wxEVT_COMMAND_LEFT_DCLICK, func)
338
339def EVT_COMMAND_RIGHT_CLICK(win, id, func):
340 win.Connect(id, -1, wxEVT_COMMAND_RIGHT_CLICK, func)
341
342def EVT_COMMAND_RIGHT_DCLICK(win, id, func):
343 win.Connect(id, -1, wxEVT_COMMAND_RIGHT_DCLICK, func)
344
345def EVT_COMMAND_SET_FOCUS(win, id, func):
346 win.Connect(id, -1, wxEVT_COMMAND_SET_FOCUS, func)
347
348def EVT_COMMAND_KILL_FOCUS(win, id, func):
349 win.Connect(id, -1, wxEVT_COMMAND_KILL_FOCUS, func)
350
351def EVT_COMMAND_ENTER(win, id, func):
352 win.Connect(id, -1, wxEVT_COMMAND_ENTER, func)
353
354
d5c9047a 355# wxNotebook events
7bf85405
RD
356def EVT_NOTEBOOK_PAGE_CHANGED(win, id, func):
357 win.Connect(id, -1, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, func)
358
359def EVT_NOTEBOOK_PAGE_CHANGING(win, id, func):
360 win.Connect(id, -1, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, func)
361
362
b639c3c5 363# wxTreeCtrl events
d5c9047a 364def EVT_TREE_BEGIN_DRAG(win, id, func):
4d1d77e8 365 win.Connect(id, -1, wxEVT_COMMAND_TREE_BEGIN_DRAG, func)
d5c9047a
RD
366
367def EVT_TREE_BEGIN_RDRAG(win, id, func):
4d1d77e8 368 win.Connect(id, -1, wxEVT_COMMAND_TREE_BEGIN_RDRAG, func)
d5c9047a
RD
369
370def EVT_TREE_BEGIN_LABEL_EDIT(win, id, func):
4d1d77e8 371 win.Connect(id, -1, wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, func)
d5c9047a
RD
372
373def EVT_TREE_END_LABEL_EDIT(win, id, func):
4d1d77e8 374 win.Connect(id, -1, wxEVT_COMMAND_TREE_END_LABEL_EDIT, func)
d5c9047a
RD
375
376def EVT_TREE_GET_INFO(win, id, func):
4d1d77e8 377 win.Connect(id, -1, wxEVT_COMMAND_TREE_GET_INFO, func)
d5c9047a
RD
378
379def EVT_TREE_SET_INFO(win, id, func):
4d1d77e8 380 win.Connect(id, -1, wxEVT_COMMAND_TREE_SET_INFO, func)
d5c9047a
RD
381
382def EVT_TREE_ITEM_EXPANDED(win, id, func):
4d1d77e8 383 win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_EXPANDED, func)
d5c9047a
RD
384
385def EVT_TREE_ITEM_EXPANDING(win, id, func):
4d1d77e8 386 win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_EXPANDING, func)
d5c9047a
RD
387
388def EVT_TREE_ITEM_COLLAPSED(win, id, func):
4d1d77e8 389 win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_COLLAPSED, func)
d5c9047a
RD
390
391def EVT_TREE_ITEM_COLLAPSING(win, id, func):
4d1d77e8 392 win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_COLLAPSING, func)
d5c9047a
RD
393
394def EVT_TREE_SEL_CHANGED(win, id, func):
4d1d77e8 395 win.Connect(id, -1, wxEVT_COMMAND_TREE_SEL_CHANGED, func)
d5c9047a
RD
396
397def EVT_TREE_SEL_CHANGING(win, id, func):
4d1d77e8 398 win.Connect(id, -1, wxEVT_COMMAND_TREE_SEL_CHANGING, func)
d5c9047a
RD
399
400def EVT_TREE_KEY_DOWN(win, id, func):
4d1d77e8 401 win.Connect(id, -1, wxEVT_COMMAND_TREE_KEY_DOWN, func)
d5c9047a
RD
402
403def EVT_TREE_DELETE_ITEM(win, id, func):
4d1d77e8 404 win.Connect(id, -1, wxEVT_COMMAND_TREE_DELETE_ITEM, func)
d5c9047a
RD
405
406
b639c3c5 407# wxSpinButton
62bd0874
RD
408def EVT_SPIN_UP(win, id, func):
409 win.Connect(id, -1, wxEVT_SCROLL_LINEUP, func)
410
411def EVT_SPIN_DOWN(win, id, func):
412 win.Connect(id, -1,wxEVT_SCROLL_LINEDOWN, func)
413
414def EVT_SPIN(win, id, func):
415 win.Connect(id, -1, wxEVT_SCROLL_TOP, func)
416 win.Connect(id, -1, wxEVT_SCROLL_BOTTOM, func)
417 win.Connect(id, -1, wxEVT_SCROLL_LINEUP, func)
418 win.Connect(id, -1, wxEVT_SCROLL_LINEDOWN, func)
419 win.Connect(id, -1, wxEVT_SCROLL_PAGEUP, func)
420 win.Connect(id, -1, wxEVT_SCROLL_PAGEDOWN, func)
421 win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK,func)
422
423
7bf85405 424
b639c3c5
RD
425
426# wxTaskBarIcon
427def EVT_TASKBAR_MOVE(win, func):
428 win.Connect(-1, -1, wxEVT_TASKBAR_MOVE, func)
429
430def EVT_TASKBAR_LEFT_DOWN(win, func):
431 win.Connect(-1, -1, wxEVT_TASKBAR_LEFT_DOWN, func)
432
433def EVT_TASKBAR_LEFT_UP(win, func):
434 win.Connect(-1, -1, wxEVT_TASKBAR_LEFT_UP, func)
435
436def EVT_TASKBAR_RIGHT_DOWN(win, func):
437 win.Connect(-1, -1, wxEVT_TASKBAR_RIGHT_DOWN, func)
438
439def EVT_TASKBAR_RIGHT_UP(win, func):
440 win.Connect(-1, -1, wxEVT_TASKBAR_RIGHT_UP, func)
441
442def EVT_TASKBAR_LEFT_DCLICK(win, func):
443 win.Connect(-1, -1, wxEVT_TASKBAR_LEFT_DCLICK, func)
444
445def EVT_TASKBAR_RIGHT_DCLICK(win, func):
446 win.Connect(-1, -1, wxEVT_TASKBAR_RIGHT_DCLICK, func)
447
448
449# wxGrid
450def EVT_GRID_SELECT_CELL(win, fn):
451 win.Connect(-1, -1, wxEVT_GRID_SELECT_CELL, fn)
452
453def EVT_GRID_CREATE_CELL(win, fn):
454 win.Connect(-1, -1, wxEVT_GRID_CREATE_CELL, fn)
455
456def EVT_GRID_CHANGE_LABELS(win, fn):
457 win.Connect(-1, -1, wxEVT_GRID_CHANGE_LABELS, fn)
458
459def EVT_GRID_CHANGE_SEL_LABEL(win, fn):
460 win.Connect(-1, -1, wxEVT_GRID_CHANGE_SEL_LABEL, fn)
461
462def EVT_GRID_CELL_CHANGE(win, fn):
463 win.Connect(-1, -1, wxEVT_GRID_CELL_CHANGE, fn)
464
465def EVT_GRID_CELL_LCLICK(win, fn):
466 win.Connect(-1, -1, wxEVT_GRID_CELL_LCLICK, fn)
467
468def EVT_GRID_CELL_RCLICK(win, fn):
469 win.Connect(-1, -1, wxEVT_GRID_CELL_RCLICK, fn)
470
471def EVT_GRID_LABEL_LCLICK(win, fn):
472 win.Connect(-1, -1, wxEVT_GRID_LABEL_LCLICK, fn)
473
474def EVT_GRID_LABEL_RCLICK(win, fn):
475 win.Connect(-1, -1, wxEVT_GRID_LABEL_RCLICK, fn)
476
477
08127323
RD
478# wxSashWindow
479def EVT_SASH_DRAGGED(win, id, func):
480 win.Connect(id, -1, wxEVT_SASH_DRAGGED, func)
481
482def EVT_SASH_DRAGGED_RANGE(win, id1, id2, func):
483 win.Connect(id1, id2, wxEVT_SASH_DRAGGED, func)
484
485def EVT_QUERY_LAYOUT_INFO(win, func):
486 win.Connect(-1, -1, wxEVT_EVT_QUERY_LAYOUT_INFO, func)
487
488def EVT_CALCULATE_LAYOUT(win, func):
489 win.Connect(-1, -1, wxEVT_EVT_CALCULATE_LAYOUT, func)
490
491
73c5ed36
RD
492# wxListCtrl
493def EVT_LIST_BEGIN_DRAG(win, id, func):
494 win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_DRAG, func)
495
496def EVT_LIST_BEGIN_RDRAG(win, id, func):
497 win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_RDRAG, func)
498
499def EVT_LIST_BEGIN_LABEL_EDIT(win, id, func):
500 win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, func)
501
502def EVT_LIST_END_LABEL_EDIT(win, id, func):
503 win.Connect(id, -1, wxEVT_COMMAND_LIST_END_LABEL_EDIT, func)
504
505def EVT_LIST_DELETE_ITEM(win, id, func):
506 win.Connect(id, -1, wxEVT_COMMAND_LIST_DELETE_ITEM, func)
507
508def EVT_LIST_DELETE_ALL_ITEMS(win, id, func):
509 win.Connect(id, -1, wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, func)
510
511def EVT_LIST_GET_INFO(win, id, func):
512 win.Connect(id, -1, wxEVT_COMMAND_LIST_GET_INFO, func)
513
514def EVT_LIST_SET_INFO(win, id, func):
515 win.Connect(id, -1, wxEVT_COMMAND_LIST_SET_INFO, func)
516
517def EVT_LIST_ITEM_SELECTED(win, id, func):
518 win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_SELECTED, func)
519
bb0054cd
RD
520def EVT_LIST_ITEM_ACTIVATED(win, id, func):
521 win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_ACTIVATED, func)
522
73c5ed36
RD
523def EVT_LIST_ITEM_DESELECTED(win, id, func):
524 win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_DESELECTED, func)
525
526def EVT_LIST_KEY_DOWN(win, id, func):
527 win.Connect(id, -1, wxEVT_COMMAND_LIST_KEY_DOWN, func)
528
529def EVT_LIST_INSERT_ITEM(win, id, func):
530 win.Connect(id, -1, wxEVT_COMMAND_LIST_INSERT_ITEM, func)
531
532def EVT_LIST_COL_CLICK(win, id, func):
533 win.Connect(id, -1, wxEVT_COMMAND_LIST_COL_CLICK, func)
b639c3c5 534
bb0054cd
RD
535#wxSplitterWindow
536def EVT_SPLITTER_SASH_POS_CHANGING(win, id, func):
537 win.Connect(id, -1, wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING, func)
538
539def EVT_SPLITTER_SASH_POS_CHANGED(win, id, func):
540 win.Connect(id, -1, wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED, func)
541
542def EVT_SPLITTER_UNSPLIT(win, id, func):
543 win.Connect(id, -1, wxEVT_COMMAND_SPLITTER_UNSPLIT, func)
544
545def EVT_SPLITTER_DOUBLECLICKED(win, id, func):
546 win.Connect(id, -1, wxEVT_COMMAND_SPLITTER_DOUBLECLICKED, func)
547
b639c3c5 548
9c039d08 549#----------------------------------------------------------------------
7bf85405
RD
550
551class wxTimer(wxPyTimer):
552 def __init__(self):
553 wxPyTimer.__init__(self, self.Notify) # derived class must provide
554 # Notify(self) method.
555
556#----------------------------------------------------------------------
557# Some wxWin methods can take "NULL" as parameters, but the shadow classes
558# expect an object with the SWIG pointer as a 'this' member. This class
559# and instance fools the shadow into passing the NULL pointer.
560
561class NullObj:
562 this = 'NULL' # SWIG converts this to (void*)0
563
564NULL = NullObj()
565
566
567#----------------------------------------------------------------------
568# aliases
569
b639c3c5 570wxColor = wxColour
7bf85405
RD
571wxNamedColor = wxNamedColour
572
573wxPyDefaultPosition.Set(-1,-1)
574wxPyDefaultSize.Set(-1,-1)
08127323 575
f2cb3be9
HH
576# aliases so that C++ documentation applies:
577wxDefaultPosition = wxPyDefaultPosition
08127323
RD
578wxDefaultSize = wxPyDefaultSize
579
af309447
RD
580
581# This is to cover up a bug in SWIG. We are redefining
582# the shadow class that is generated for wxAcceleratorTable
583# because SWIG incorrectly uses "arg0.this"
584class wxAcceleratorTable(wxAcceleratorTablePtr):
585 def __init__(self,arg0) :
586 self.this = miscc.new_wxAcceleratorTable(arg0)
587 self.thisown = 1
588
7bf85405
RD
589#----------------------------------------------------------------------
590
cf694132
RD
591## class wxPyStdOutWindow:
592## def __init__(self, title = "wxPython: stdout/stderr"):
593## self.frame = None
594## self.title = title
595
596## def write(self, str):
597## if not self.frame:
598## self.frame = wxFrame(NULL, -1, self.title)
599## self.text = wxTextCtrl(self.frame, -1, "", wxPoint(0,0), wxDefaultSize,
600## wxTE_MULTILINE|wxTE_READONLY)
601## self.frame.SetSize(wxSize(450, 300))
602## self.frame.Show(true)
603## EVT_CLOSE(self.frame, self.OnCloseWindow)
604## self.text.AppendText(str)
7bf85405 605
cf694132
RD
606## def OnCloseWindow(self, event):
607## wxBell()
608## self.frame.Destroy()
609## self.frame = None
610## self.text = None
7bf85405 611
7bf85405 612
cf694132
RD
613## def close(self):
614## if self.frame:
615## self.frame.Close(true)
7bf85405 616
fb5e0af0 617_defRedirect = (wxPlatform == '__WXMSW__')
7bf85405
RD
618
619#----------------------------------------------------------------------
620# The main application class. Derive from this and implement an OnInit
621# method that creates a frame and then calls self.SetTopWindow(frame)
622
623class wxApp(wxPyApp):
624 error = 'wxApp.error'
625
626 def __init__(self, redirect=_defRedirect, filename=None):
627 wxPyApp.__init__(self)
628 self.stdioWin = None
629 self.saveStdio = (sys.stdout, sys.stderr)
630 if redirect:
631 self.RedirectStdio(filename)
632
633 # this initializes wxWindows and then calls our OnInit
634 _wxStart(self.OnInit)
635
636
637 def __del__(self):
638 try:
639 self.RestoreStdio()
640 except:
641 pass
642
643 def RedirectStdio(self, filename):
644 if filename:
645 sys.stdout = sys.stderr = open(filename, 'a')
646 else:
cf694132
RD
647 #raise self.error, 'wxPyStdOutWindow not yet implemented.'
648 self.stdioWin = sys.stdout = sys.stderr = wxPyStdOutWindow()
7bf85405
RD
649
650 def RestoreStdio(self):
651 sys.stdout, sys.stderr = self.saveStdio
652 if self.stdioWin != None:
cf694132 653 self.stdioWin.close()
7bf85405
RD
654
655
656#----------------------------------------------------------------------------