]>
Commit | Line | Data |
---|---|---|
bb0054cd RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: misc2.i | |
3 | // Purpose: Definitions of miscelaneous functions and classes that need | |
4 | // to know about wxWindow. (So they can't be in misc.i or an | |
5 | // import loop will happen.) | |
6 | // | |
7 | // Author: Robin Dunn | |
8 | // | |
9 | // Created: 18-June-1999 | |
10 | // RCS-ID: $Id$ | |
11 | // Copyright: (c) 1998 by Total Control Software | |
12 | // Licence: wxWindows license | |
13 | ///////////////////////////////////////////////////////////////////////////// | |
14 | ||
15 | %module misc2 | |
16 | ||
17 | %{ | |
18 | #include "helpers.h" | |
19 | #include <wx/resource.h> | |
20 | #include <wx/tooltip.h> | |
f0261a72 RD |
21 | #include <wx/caret.h> |
22 | #include <wx/fontenum.h> | |
f6bcfd97 | 23 | #include <wx/tipdlg.h> |
c368d904 | 24 | #include <wx/process.h> |
493f1553 RD |
25 | |
26 | #if wxUSE_JOYSTICK || defined(__WXMSW__) | |
185d7c3e | 27 | #include <wx/joystick.h> |
4662be59 | 28 | #endif |
493f1553 RD |
29 | |
30 | #if wxUSE_WAVE || defined(__WXMSW__) | |
31 | #include <wx/wave.h> | |
32 | #endif | |
b37c7e1d RD |
33 | |
34 | #include <wx/mimetype.h> | |
bb0054cd RD |
35 | %} |
36 | ||
37 | //---------------------------------------------------------------------- | |
38 | ||
39 | %include typemaps.i | |
40 | %include my_typemaps.i | |
41 | ||
42 | // Import some definitions of other classes, etc. | |
43 | %import _defs.i | |
44 | %import windows.i | |
f0261a72 | 45 | %import misc.i |
06c0fba4 | 46 | %import gdi.i |
b1462dfa | 47 | %import events.i |
c368d904 | 48 | %import streams.i |
7dbce44a | 49 | %import utils.i |
06c0fba4 | 50 | |
b68dc582 RD |
51 | %{ |
52 | static wxString wxPyEmptyStr(""); | |
53 | %} | |
54 | ||
06c0fba4 RD |
55 | //--------------------------------------------------------------------------- |
56 | // Dialog Functions | |
57 | ||
58 | wxString wxFileSelector(char* message, | |
59 | char* default_path = NULL, | |
60 | char* default_filename = NULL, | |
61 | char* default_extension = NULL, | |
62 | char* wildcard = "*.*", | |
63 | int flags = 0, | |
64 | wxWindow *parent = NULL, | |
65 | int x = -1, int y = -1); | |
66 | ||
67 | wxString wxGetTextFromUser(const wxString& message, | |
68 | const wxString& caption = wxPyEmptyStr, | |
69 | const wxString& default_value = wxPyEmptyStr, | |
70 | wxWindow *parent = NULL, | |
71 | int x = -1, int y = -1, | |
72 | bool centre = TRUE); | |
73 | ||
1b62f00d RD |
74 | wxString wxGetPasswordFromUser(const wxString& message, |
75 | const wxString& caption = wxPyEmptyStr, | |
76 | const wxString& default_value = wxPyEmptyStr, | |
77 | wxWindow *parent = NULL); | |
78 | ||
06c0fba4 RD |
79 | |
80 | // TODO: Need to custom wrap this one... | |
81 | // int wxGetMultipleChoice(char* message, char* caption, | |
eec92d76 | 82 | // int LCOUNT, char** choices, |
06c0fba4 RD |
83 | // int nsel, int *selection, |
84 | // wxWindow *parent = NULL, int x = -1, int y = -1, | |
85 | // bool centre = TRUE, int width=150, int height=200); | |
86 | ||
87 | ||
88 | wxString wxGetSingleChoice(const wxString& message, const wxString& caption, | |
eec92d76 | 89 | int LCOUNT, wxString* choices, |
06c0fba4 RD |
90 | wxWindow *parent = NULL, |
91 | int x = -1, int y = -1, | |
92 | bool centre = TRUE, | |
93 | int width=150, int height=200); | |
94 | ||
95 | int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption, | |
eec92d76 | 96 | int LCOUNT, wxString* choices, |
06c0fba4 RD |
97 | wxWindow *parent = NULL, |
98 | int x = -1, int y = -1, | |
99 | bool centre = TRUE, | |
100 | int width=150, int height=200); | |
101 | ||
102 | ||
103 | int wxMessageBox(const wxString& message, | |
104 | const wxString& caption = wxPyEmptyStr, | |
105 | int style = wxOK | wxCENTRE, | |
106 | wxWindow *parent = NULL, | |
107 | int x = -1, int y = -1); | |
108 | ||
109 | long wxGetNumberFromUser(const wxString& message, | |
110 | const wxString& prompt, | |
111 | const wxString& caption, | |
112 | long value, | |
113 | long min = 0, long max = 100, | |
114 | wxWindow *parent = NULL, | |
b68dc582 | 115 | const wxPoint& pos = wxDefaultPosition); |
06c0fba4 RD |
116 | |
117 | //--------------------------------------------------------------------------- | |
118 | // GDI Functions | |
119 | ||
120 | bool wxColourDisplay(); | |
1e7ecb7b | 121 | |
06c0fba4 | 122 | int wxDisplayDepth(); |
1e7ecb7b RD |
123 | int wxGetDisplayDepth(); |
124 | ||
ec5d7799 | 125 | void wxDisplaySize(int* OUTPUT, int* OUTPUT); |
1e7ecb7b | 126 | wxSize wxGetDisplaySize(); |
1b62f00d | 127 | |
ec5d7799 | 128 | void wxDisplaySizeMM(int* OUTPUT, int* OUTPUT); |
1e7ecb7b RD |
129 | wxSize wxGetDisplaySizeMM(); |
130 | ||
ec5d7799 RD |
131 | void wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT); |
132 | wxRect wxGetClientDisplayRect(); | |
133 | ||
06c0fba4 | 134 | void wxSetCursor(wxCursor& cursor); |
bb0054cd RD |
135 | |
136 | //---------------------------------------------------------------------- | |
06c0fba4 | 137 | // Miscellaneous functions |
bb0054cd RD |
138 | |
139 | wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL); | |
140 | wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL); | |
141 | ||
06c0fba4 RD |
142 | void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR); |
143 | wxWindow * wxGetActiveWindow(); | |
144 | ||
493f1553 RD |
145 | wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt); |
146 | wxWindow* wxFindWindowAtPoint(const wxPoint& pt); | |
4dfaa61e RD |
147 | |
148 | #ifdef __WXMSW__ | |
493f1553 | 149 | bool wxCheckForInterrupt(wxWindow *wnd); |
4dfaa61e RD |
150 | void wxFlushEvents(); |
151 | #endif | |
06c0fba4 RD |
152 | |
153 | //--------------------------------------------------------------------------- | |
154 | // Resource System | |
155 | ||
156 | bool wxResourceAddIdentifier(char *name, int value); | |
157 | void wxResourceClear(void); | |
158 | wxBitmap wxResourceCreateBitmap(char *resource); | |
159 | wxIcon wxResourceCreateIcon(char *resource); | |
160 | wxMenuBar * wxResourceCreateMenuBar(char *resource); | |
161 | int wxResourceGetIdentifier(char *name); | |
162 | bool wxResourceParseData(char *resource, wxResourceTable *table = NULL); | |
163 | bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL); | |
164 | bool wxResourceParseString(char *resource, wxResourceTable *table = NULL); | |
bb0054cd | 165 | |
06c0fba4 RD |
166 | //--------------------------------------------------------------------------- |
167 | // System Settings | |
168 | ||
b5a5d647 RD |
169 | // possible values for wxSystemSettings::GetFont() parameter |
170 | // | |
171 | enum wxSystemFont | |
172 | { | |
173 | wxSYS_OEM_FIXED_FONT = 10, | |
06c0fba4 RD |
174 | wxSYS_ANSI_FIXED_FONT, |
175 | wxSYS_ANSI_VAR_FONT, | |
176 | wxSYS_SYSTEM_FONT, | |
177 | wxSYS_DEVICE_DEFAULT_FONT, | |
178 | wxSYS_DEFAULT_PALETTE, | |
179 | wxSYS_SYSTEM_FIXED_FONT, | |
b5a5d647 RD |
180 | wxSYS_DEFAULT_GUI_FONT |
181 | }; | |
06c0fba4 | 182 | |
b5a5d647 RD |
183 | // possible values for wxSystemSettings::GetColour() parameter |
184 | // | |
185 | enum wxSystemColour | |
186 | { | |
06c0fba4 RD |
187 | wxSYS_COLOUR_SCROLLBAR, |
188 | wxSYS_COLOUR_BACKGROUND, | |
189 | wxSYS_COLOUR_ACTIVECAPTION, | |
190 | wxSYS_COLOUR_INACTIVECAPTION, | |
191 | wxSYS_COLOUR_MENU, | |
192 | wxSYS_COLOUR_WINDOW, | |
193 | wxSYS_COLOUR_WINDOWFRAME, | |
194 | wxSYS_COLOUR_MENUTEXT, | |
195 | wxSYS_COLOUR_WINDOWTEXT, | |
196 | wxSYS_COLOUR_CAPTIONTEXT, | |
197 | wxSYS_COLOUR_ACTIVEBORDER, | |
198 | wxSYS_COLOUR_INACTIVEBORDER, | |
199 | wxSYS_COLOUR_APPWORKSPACE, | |
200 | wxSYS_COLOUR_HIGHLIGHT, | |
201 | wxSYS_COLOUR_HIGHLIGHTTEXT, | |
202 | wxSYS_COLOUR_BTNFACE, | |
203 | wxSYS_COLOUR_BTNSHADOW, | |
204 | wxSYS_COLOUR_GRAYTEXT, | |
205 | wxSYS_COLOUR_BTNTEXT, | |
206 | wxSYS_COLOUR_INACTIVECAPTIONTEXT, | |
207 | wxSYS_COLOUR_BTNHIGHLIGHT, | |
06c0fba4 RD |
208 | wxSYS_COLOUR_3DDKSHADOW, |
209 | wxSYS_COLOUR_3DLIGHT, | |
210 | wxSYS_COLOUR_INFOTEXT, | |
211 | wxSYS_COLOUR_INFOBK, | |
b5a5d647 RD |
212 | wxSYS_COLOUR_LISTBOX, |
213 | ||
214 | wxSYS_COLOUR_DESKTOP = wxSYS_COLOUR_BACKGROUND, | |
215 | wxSYS_COLOUR_3DFACE = wxSYS_COLOUR_BTNFACE, | |
216 | wxSYS_COLOUR_3DSHADOW = wxSYS_COLOUR_BTNSHADOW, | |
217 | wxSYS_COLOUR_3DHIGHLIGHT = wxSYS_COLOUR_BTNHIGHLIGHT, | |
218 | wxSYS_COLOUR_3DHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT, | |
219 | wxSYS_COLOUR_BTNHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT | |
220 | }; | |
06c0fba4 | 221 | |
b5a5d647 RD |
222 | // possible values for wxSystemSettings::GetMetric() parameter |
223 | // | |
224 | enum wxSystemMetric | |
225 | { | |
226 | wxSYS_MOUSE_BUTTONS = 1, | |
06c0fba4 RD |
227 | wxSYS_BORDER_X, |
228 | wxSYS_BORDER_Y, | |
229 | wxSYS_CURSOR_X, | |
230 | wxSYS_CURSOR_Y, | |
231 | wxSYS_DCLICK_X, | |
232 | wxSYS_DCLICK_Y, | |
233 | wxSYS_DRAG_X, | |
234 | wxSYS_DRAG_Y, | |
235 | wxSYS_EDGE_X, | |
236 | wxSYS_EDGE_Y, | |
237 | wxSYS_HSCROLL_ARROW_X, | |
238 | wxSYS_HSCROLL_ARROW_Y, | |
239 | wxSYS_HTHUMB_X, | |
240 | wxSYS_ICON_X, | |
241 | wxSYS_ICON_Y, | |
242 | wxSYS_ICONSPACING_X, | |
243 | wxSYS_ICONSPACING_Y, | |
244 | wxSYS_WINDOWMIN_X, | |
245 | wxSYS_WINDOWMIN_Y, | |
246 | wxSYS_SCREEN_X, | |
247 | wxSYS_SCREEN_Y, | |
248 | wxSYS_FRAMESIZE_X, | |
249 | wxSYS_FRAMESIZE_Y, | |
250 | wxSYS_SMALLICON_X, | |
251 | wxSYS_SMALLICON_Y, | |
252 | wxSYS_HSCROLL_Y, | |
253 | wxSYS_VSCROLL_X, | |
254 | wxSYS_VSCROLL_ARROW_X, | |
255 | wxSYS_VSCROLL_ARROW_Y, | |
256 | wxSYS_VTHUMB_Y, | |
257 | wxSYS_CAPTION_Y, | |
258 | wxSYS_MENU_Y, | |
259 | wxSYS_NETWORK_PRESENT, | |
260 | wxSYS_PENWINDOWS_PRESENT, | |
261 | wxSYS_SHOW_SOUNDS, | |
b5a5d647 | 262 | wxSYS_SWAP_BUTTONS |
06c0fba4 RD |
263 | }; |
264 | ||
b5a5d647 RD |
265 | // possible values for wxSystemSettings::HasFeature() parameter |
266 | enum wxSystemFeature | |
267 | { | |
268 | wxSYS_CAN_DRAW_FRAME_DECORATIONS = 1, | |
269 | wxSYS_CAN_ICONIZE_FRAME | |
270 | }; | |
06c0fba4 RD |
271 | |
272 | ||
06c0fba4 | 273 | |
b5a5d647 RD |
274 | class wxSystemSettings { |
275 | public: | |
276 | // get a standard system colour | |
277 | static wxColour GetColour(wxSystemColour index); | |
278 | ||
279 | // get a standard system font | |
280 | static wxFont GetFont(wxSystemFont index); | |
281 | ||
282 | // get a system-dependent metric | |
283 | static int GetMetric(wxSystemMetric index); | |
284 | ||
285 | // return true if the port has certain feature | |
286 | static bool HasFeature(wxSystemFeature index); | |
287 | ||
b5a5d647 | 288 | }; |
06c0fba4 | 289 | |
06c0fba4 | 290 | |
bb0054cd RD |
291 | |
292 | //--------------------------------------------------------------------------- | |
293 | // wxToolTip | |
294 | ||
9416aa89 | 295 | class wxToolTip : public wxObject { |
bb0054cd RD |
296 | public: |
297 | wxToolTip(const wxString &tip); | |
298 | ||
299 | void SetTip(const wxString& tip); | |
300 | wxString GetTip(); | |
301 | // *** Not in the "public" interface void SetWindow(wxWindow *win); | |
302 | wxWindow *GetWindow(); | |
bb0054cd | 303 | |
edf2f43e RD |
304 | static void Enable(bool flag); |
305 | static void SetDelay(long milliseconds); | |
306 | }; | |
bb0054cd RD |
307 | |
308 | //---------------------------------------------------------------------- | |
f0261a72 RD |
309 | |
310 | class wxCaret { | |
311 | public: | |
312 | wxCaret(wxWindow* window, const wxSize& size); | |
313 | ~wxCaret(); | |
314 | ||
315 | bool IsOk(); | |
316 | bool IsVisible(); | |
317 | %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT); | |
318 | wxPoint GetPosition(); | |
319 | %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT); | |
320 | wxSize GetSize(); | |
321 | wxWindow *GetWindow(); | |
322 | %name(MoveXY)void Move(int x, int y); | |
323 | void Move(const wxPoint& pt); | |
a1df7a95 RD |
324 | %name(SetSizeWH) void SetSize(int width, int height); |
325 | void SetSize(const wxSize& size); | |
f0261a72 RD |
326 | void Show(int show = TRUE); |
327 | void Hide(); | |
f0261a72 RD |
328 | }; |
329 | ||
330 | %inline %{ | |
331 | int wxCaret_GetBlinkTime() { | |
332 | return wxCaret::GetBlinkTime(); | |
333 | } | |
334 | ||
335 | void wxCaret_SetBlinkTime(int milliseconds) { | |
336 | wxCaret::SetBlinkTime(milliseconds); | |
337 | } | |
338 | %} | |
339 | ||
bb0054cd | 340 | //---------------------------------------------------------------------- |
f0261a72 RD |
341 | |
342 | %{ | |
343 | class wxPyFontEnumerator : public wxFontEnumerator { | |
344 | public: | |
345 | wxPyFontEnumerator() {} | |
346 | ~wxPyFontEnumerator() {} | |
347 | ||
b1462dfa | 348 | DEC_PYCALLBACK_BOOL_STRING(OnFacename); |
f0261a72 RD |
349 | DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding); |
350 | ||
351 | PYPRIVATE; | |
352 | }; | |
353 | ||
b1462dfa | 354 | IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename); |
f0261a72 RD |
355 | IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding); |
356 | ||
357 | %} | |
358 | ||
359 | %name(wxFontEnumerator) class wxPyFontEnumerator { | |
360 | public: | |
b1462dfa RD |
361 | wxPyFontEnumerator(); |
362 | ~wxPyFontEnumerator(); | |
8af26133 RD |
363 | void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref); |
364 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxFontEnumerator, 0)" | |
f0261a72 | 365 | |
b1462dfa RD |
366 | bool EnumerateFacenames( |
367 | wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all | |
368 | bool fixedWidthOnly = FALSE); | |
369 | bool EnumerateEncodings(const char* facename = ""); | |
65dd82cb RD |
370 | |
371 | //wxArrayString* GetEncodings(); | |
372 | //wxArrayString* GetFacenames(); | |
373 | %addmethods { | |
374 | PyObject* GetEncodings() { | |
375 | wxArrayString* arr = self->GetEncodings(); | |
8af26133 | 376 | return wxArrayString2PyList_helper(*arr); |
65dd82cb RD |
377 | } |
378 | ||
379 | PyObject* GetFacenames() { | |
380 | wxArrayString* arr = self->GetFacenames(); | |
8af26133 | 381 | return wxArrayString2PyList_helper(*arr); |
65dd82cb RD |
382 | } |
383 | } | |
f0261a72 | 384 | }; |
2abc0a0f RD |
385 | |
386 | //---------------------------------------------------------------------- | |
387 | ||
388 | class wxBusyCursor { | |
389 | public: | |
390 | wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR); | |
391 | ~wxBusyCursor(); | |
392 | }; | |
393 | ||
b1462dfa | 394 | //---------------------------------------------------------------------- |
2abc0a0f | 395 | |
c368d904 RD |
396 | class wxWindowDisabler { |
397 | public: | |
398 | wxWindowDisabler(wxWindow *winToSkip = NULL); | |
399 | ~wxWindowDisabler(); | |
400 | }; | |
401 | ||
402 | //---------------------------------------------------------------------- | |
403 | ||
6e18ca6c | 404 | bool wxSafeYield(wxWindow* win=NULL); |
b1462dfa | 405 | void wxPostEvent(wxEvtHandler *dest, wxEvent& event); |
694759cf | 406 | void wxWakeUpIdle(); |
2abc0a0f | 407 | |
6e18ca6c | 408 | |
4662be59 | 409 | #ifdef __WXMSW__ |
6e18ca6c | 410 | void wxWakeUpMainThread(); |
4662be59 RD |
411 | #endif |
412 | ||
6e18ca6c RD |
413 | void wxMutexGuiEnter(); |
414 | void wxMutexGuiLeave(); | |
415 | ||
416 | ||
417 | class wxMutexGuiLocker { | |
418 | public: | |
419 | wxMutexGuiLocker(); | |
420 | ~wxMutexGuiLocker(); | |
421 | }; | |
422 | ||
423 | ||
424 | %inline %{ | |
425 | bool wxThread_IsMain() { | |
00ca6262 | 426 | #ifdef WXP_WITH_THREAD |
6e18ca6c | 427 | return wxThread::IsMain(); |
00ca6262 RD |
428 | #else |
429 | return TRUE; | |
430 | #endif | |
6e18ca6c RD |
431 | } |
432 | %} | |
c368d904 | 433 | |
2abc0a0f | 434 | //---------------------------------------------------------------------- |
f6bcfd97 BP |
435 | |
436 | ||
437 | class wxTipProvider | |
438 | { | |
439 | public: | |
440 | // wxTipProvider(size_t currentTip); **** Abstract base class | |
441 | ~wxTipProvider(); | |
442 | ||
443 | virtual wxString GetTip() = 0; | |
444 | size_t GetCurrentTip(); | |
445 | ||
446 | }; | |
447 | ||
448 | ||
449 | // The C++ version of wxPyTipProvider | |
450 | %{ | |
451 | class wxPyTipProvider : public wxTipProvider { | |
452 | public: | |
453 | wxPyTipProvider(size_t currentTip) | |
454 | : wxTipProvider(currentTip) {} | |
455 | ||
456 | DEC_PYCALLBACK_STRING__pure(GetTip); | |
457 | ||
458 | PYPRIVATE; | |
459 | }; | |
460 | ||
461 | IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip); | |
462 | ||
463 | %} | |
464 | ||
465 | ||
466 | // Now let SWIG know about it | |
467 | class wxPyTipProvider : public wxTipProvider { | |
468 | public: | |
469 | wxPyTipProvider(size_t currentTip); | |
470 | }; | |
471 | ||
472 | ||
473 | ||
474 | bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE); | |
475 | %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip); | |
476 | ||
477 | ||
478 | //---------------------------------------------------------------------- | |
479 | ||
480 | %{ | |
481 | #include <wx/generic/dragimgg.h> | |
f6bcfd97 BP |
482 | %} |
483 | ||
9416aa89 | 484 | %name (wxDragImage) class wxGenericDragImage : public wxObject |
f6bcfd97 BP |
485 | { |
486 | public: | |
487 | ||
488 | wxGenericDragImage(const wxBitmap& image, | |
10e07c70 | 489 | const wxCursor& cursor = wxNullCursor); |
cdf14688 RD |
490 | %name(wxDragIcon)wxGenericDragImage(const wxIcon& image, |
491 | const wxCursor& cursor = wxNullCursor); | |
492 | %name(wxDragString)wxGenericDragImage(const wxString& str, | |
493 | const wxCursor& cursor = wxNullCursor); | |
494 | %name(wxDragTreeItem)wxGenericDragImage(const wxTreeCtrl& treeCtrl, wxTreeItemId& id); | |
495 | %name(wxDragListItem)wxGenericDragImage(const wxListCtrl& listCtrl, long id); | |
496 | ||
f6bcfd97 BP |
497 | ~wxGenericDragImage(); |
498 | ||
10e07c70 | 499 | void SetBackingBitmap(wxBitmap* bitmap); |
f6bcfd97 BP |
500 | bool BeginDrag(const wxPoint& hotspot, wxWindow* window, |
501 | bool fullScreen = FALSE, wxRect* rect = NULL); | |
502 | ||
503 | %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window, | |
504 | wxWindow* fullScreenRect); | |
505 | ||
506 | bool EndDrag(); | |
507 | bool Move(const wxPoint& pt); | |
508 | bool Show(); | |
509 | bool Hide(); | |
510 | ||
511 | wxRect GetImageRect(const wxPoint& pos) const; | |
512 | bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos, | |
513 | bool eraseOld, bool drawNew); | |
514 | }; | |
515 | ||
516 | ||
f6bcfd97 BP |
517 | //---------------------------------------------------------------------- |
518 | ||
9416aa89 | 519 | class wxPyTimer : public wxObject { |
f6bcfd97 BP |
520 | public: |
521 | wxPyTimer(PyObject* notify); | |
522 | ~wxPyTimer(); | |
523 | int GetInterval(); | |
524 | bool IsOneShot(); | |
525 | bool IsRunning(); | |
526 | void SetOwner(wxEvtHandler *owner, int id = -1); | |
527 | void Start(int milliseconds=-1, int oneShot=FALSE); | |
528 | void Stop(); | |
529 | }; | |
530 | ||
b37c7e1d RD |
531 | |
532 | class wxStopWatch | |
533 | { | |
534 | public: | |
535 | // ctor starts the stop watch | |
536 | wxStopWatch(); | |
68320e40 | 537 | ~wxStopWatch(); |
b37c7e1d RD |
538 | void Start(long t = 0); |
539 | void Pause(); | |
540 | void Resume(); | |
541 | ||
542 | // get elapsed time since the last Start() or Pause() in milliseconds | |
543 | long Time() const; | |
544 | }; | |
545 | ||
546 | ||
f6bcfd97 BP |
547 | //---------------------------------------------------------------------- |
548 | //---------------------------------------------------------------------- | |
549 | ||
550 | ||
551 | enum | |
552 | { | |
553 | wxLOG_FatalError, // program can't continue, abort immediately | |
554 | wxLOG_Error, // a serious error, user must be informed about it | |
555 | wxLOG_Warning, // user is normally informed about it but may be ignored | |
556 | wxLOG_Message, // normal message (i.e. normal output of a non GUI app) | |
557 | wxLOG_Info, // informational message (a.k.a. 'Verbose') | |
558 | wxLOG_Status, // informational: might go to the status line of GUI app | |
559 | wxLOG_Debug, // never shown to the user, disabled in release mode | |
560 | wxLOG_Trace, // trace messages are also only enabled in debug mode | |
561 | wxLOG_Progress, // used for progress indicator (not yet) | |
562 | wxLOG_User = 100 // user defined levels start here | |
563 | }; | |
564 | ||
565 | ||
566 | class wxLog | |
567 | { | |
568 | public: | |
569 | wxLog(); | |
570 | ||
571 | static bool IsEnabled(); | |
572 | static bool EnableLogging(bool doIt = TRUE); | |
573 | static void OnLog(wxLogLevel level, const char *szString, int t=0); | |
574 | ||
575 | virtual void Flush(); | |
576 | bool HasPendingMessages() const; | |
577 | ||
578 | static void FlushActive(); | |
579 | static wxLog *GetActiveTarget(); | |
580 | static wxLog *SetActiveTarget(wxLog *pLogger); | |
581 | ||
582 | static void Suspend(); | |
583 | static void Resume(); | |
584 | ||
585 | void SetVerbose(bool bVerbose = TRUE); | |
586 | ||
587 | static void DontCreateOnDemand(); | |
588 | static void SetTraceMask(wxTraceMask ulMask); | |
589 | static void AddTraceMask(const wxString& str); | |
590 | static void RemoveTraceMask(const wxString& str); | |
76bfdc78 RD |
591 | static void ClearTraceMasks(); |
592 | ||
593 | static void SetTimestamp(const wxChar *ts); | |
594 | static const wxChar *GetTimestamp(); | |
f6bcfd97 BP |
595 | |
596 | bool GetVerbose() const { return m_bVerbose; } | |
597 | ||
598 | static wxTraceMask GetTraceMask(); | |
599 | static bool IsAllowedTraceMask(const char *mask); | |
600 | ||
76bfdc78 RD |
601 | // static void TimeStamp(wxString *str); |
602 | %addmethods { | |
603 | wxString TimeStamp() { | |
604 | wxString msg; | |
605 | wxLog::TimeStamp(&msg); | |
606 | return msg; | |
607 | } | |
608 | } | |
f6bcfd97 BP |
609 | }; |
610 | ||
611 | ||
612 | class wxLogStderr : public wxLog | |
613 | { | |
614 | public: | |
615 | wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/); | |
616 | }; | |
617 | ||
618 | ||
619 | class wxLogTextCtrl : public wxLog | |
620 | { | |
621 | public: | |
622 | wxLogTextCtrl(wxTextCtrl *pTextCtrl); | |
623 | }; | |
624 | ||
625 | ||
626 | class wxLogGui : public wxLog | |
627 | { | |
628 | public: | |
629 | wxLogGui(); | |
630 | }; | |
631 | ||
632 | class wxLogWindow : public wxLog | |
633 | { | |
634 | public: | |
635 | wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL) | |
636 | const char *szTitle, // the title of the frame | |
637 | bool bShow = TRUE, // show window immediately? | |
638 | bool bPassToOld = TRUE); // pass log messages to the old target? | |
639 | ||
640 | void Show(bool bShow = TRUE); | |
641 | wxFrame *GetFrame() const; | |
642 | wxLog *GetOldLog() const; | |
643 | bool IsPassingMessages() const; | |
644 | void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; } | |
645 | }; | |
646 | ||
647 | ||
648 | class wxLogNull | |
649 | { | |
650 | public: | |
651 | wxLogNull(); | |
652 | ~wxLogNull(); | |
653 | }; | |
654 | ||
655 | ||
76bfdc78 RD |
656 | class wxLogChain : public wxLog |
657 | { | |
658 | public: | |
659 | wxLogChain(wxLog *logger); | |
660 | void SetLog(wxLog *logger); | |
661 | void PassMessages(bool bDoPass); | |
662 | bool IsPassingMessages(); | |
663 | wxLog *GetOldLog(); | |
664 | }; | |
665 | ||
666 | ||
f6bcfd97 BP |
667 | unsigned long wxSysErrorCode(); |
668 | const char* wxSysErrorMsg(unsigned long nErrCode = 0); | |
669 | void wxLogFatalError(const char *szFormat); | |
670 | void wxLogError(const char *szFormat); | |
671 | void wxLogWarning(const char *szFormat); | |
672 | void wxLogMessage(const char *szFormat); | |
673 | void wxLogInfo(const char *szFormat); | |
674 | void wxLogVerbose(const char *szFormat); | |
675 | void wxLogStatus(const char *szFormat); | |
676 | %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const char *szFormat); | |
677 | void wxLogSysError(const char *szFormat); | |
678 | ||
679 | ||
76bfdc78 RD |
680 | %{ |
681 | // A Log class that can be derived from in wxPython | |
682 | class wxPyLog : public wxLog { | |
683 | public: | |
684 | wxPyLog() : wxLog() {} | |
685 | ||
686 | virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t) { | |
687 | bool found; | |
4268f798 | 688 | wxPyBeginBlockThreads(); |
76bfdc78 RD |
689 | if ((found = wxPyCBH_findCallback(m_myInst, "DoLog"))) |
690 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(isi)", level, szString, t)); | |
4268f798 | 691 | wxPyEndBlockThreads(); |
76bfdc78 RD |
692 | if (! found) |
693 | wxLog::DoLog(level, szString, t); | |
694 | } | |
695 | ||
696 | virtual void DoLogString(const wxChar *szString, time_t t) { | |
697 | bool found; | |
4268f798 | 698 | wxPyBeginBlockThreads(); |
76bfdc78 RD |
699 | if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString"))) |
700 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(si)", szString, t)); | |
4268f798 | 701 | wxPyEndBlockThreads(); |
76bfdc78 RD |
702 | if (! found) |
703 | wxLog::DoLogString(szString, t); | |
704 | } | |
705 | ||
706 | PYPRIVATE; | |
707 | }; | |
708 | %} | |
709 | ||
710 | // Now tell SWIG about it | |
711 | class wxPyLog : public wxLog { | |
712 | public: | |
713 | wxPyLog(); | |
0122b7e3 RD |
714 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
715 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyLog)" | |
76bfdc78 RD |
716 | %addmethods { void Destroy() { delete self; } } |
717 | ||
718 | }; | |
719 | ||
c368d904 RD |
720 | |
721 | //---------------------------------------------------------------------- | |
722 | ||
1b62f00d RD |
723 | |
724 | enum { | |
725 | /* event type */ | |
726 | wxEVT_END_PROCESS | |
727 | }; | |
728 | ||
729 | ||
c368d904 RD |
730 | class wxProcessEvent : public wxEvent { |
731 | public: | |
732 | wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0); | |
733 | int GetPid(); | |
734 | int GetExitCode(); | |
735 | int m_pid, m_exitcode; | |
736 | }; | |
737 | ||
738 | ||
739 | ||
740 | ||
741 | %{ // C++ version of wxProcess derived class | |
742 | ||
743 | class wxPyProcess : public wxProcess { | |
744 | public: | |
745 | wxPyProcess(wxEvtHandler *parent = NULL, int id = -1) | |
746 | : wxProcess(parent, id) | |
747 | {} | |
748 | ||
749 | DEC_PYCALLBACK_VOID_INTINT(OnTerminate); | |
750 | ||
751 | PYPRIVATE; | |
752 | }; | |
753 | ||
754 | IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate); | |
19a97bd6 | 755 | |
c368d904 RD |
756 | %} |
757 | ||
758 | ||
759 | %name(wxProcess)class wxPyProcess : public wxEvtHandler { | |
760 | public: | |
761 | wxPyProcess(wxEvtHandler *parent = NULL, int id = -1); | |
762 | %addmethods { void Destroy() { delete self; } } | |
763 | ||
0122b7e3 RD |
764 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
765 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxProcess)" | |
c368d904 RD |
766 | |
767 | void base_OnTerminate(int pid, int status); | |
768 | ||
769 | void Redirect(); | |
770 | bool IsRedirected(); | |
771 | void Detach(); | |
772 | ||
773 | wxInputStream *GetInputStream(); | |
774 | wxInputStream *GetErrorStream(); | |
775 | wxOutputStream *GetOutputStream(); | |
776 | ||
777 | void CloseOutput(); | |
778 | }; | |
779 | ||
780 | ||
781 | ||
782 | long wxExecute(const wxString& command, | |
783 | int sync = FALSE, | |
784 | wxPyProcess *process = NULL); | |
785 | ||
185d7c3e RD |
786 | //---------------------------------------------------------------------- |
787 | ||
493f1553 RD |
788 | %{ |
789 | #if !wxUSE_JOYSTICK && !defined(__WXMSW__) | |
790 | // A C++ stub class for wxJoystick for platforms that don't have it. | |
791 | class wxJoystick : public wxObject { | |
792 | public: | |
793 | wxJoystick(int joystick = wxJOYSTICK1) { | |
4268f798 | 794 | wxPyBeginBlockThreads(); |
493f1553 | 795 | PyErr_SetString(PyExc_NotImplementedError, "wxJoystick is not available on this platform."); |
4268f798 | 796 | wxPyEndBlockThreads(); |
493f1553 RD |
797 | } |
798 | wxPoint GetPosition() { return wxPoint(-1,-1); } | |
799 | int GetZPosition() { return -1; } | |
800 | int GetButtonState() { return -1; } | |
801 | int GetPOVPosition() { return -1; } | |
802 | int GetPOVCTSPosition() { return -1; } | |
803 | int GetRudderPosition() { return -1; } | |
804 | int GetUPosition() { return -1; } | |
805 | int GetVPosition() { return -1; } | |
806 | int GetMovementThreshold() { return -1; } | |
d56cebe7 | 807 | void SetMovementThreshold(int threshold) {} |
493f1553 RD |
808 | |
809 | bool IsOk(void) { return FALSE; } | |
810 | int GetNumberJoysticks() { return -1; } | |
811 | int GetManufacturerId() { return -1; } | |
812 | int GetProductId() { return -1; } | |
813 | wxString GetProductName() { return ""; } | |
814 | int GetXMin() { return -1; } | |
815 | int GetYMin() { return -1; } | |
816 | int GetZMin() { return -1; } | |
817 | int GetXMax() { return -1; } | |
818 | int GetYMax() { return -1; } | |
819 | int GetZMax() { return -1; } | |
820 | int GetNumberButtons() { return -1; } | |
821 | int GetNumberAxes() { return -1; } | |
822 | int GetMaxButtons() { return -1; } | |
823 | int GetMaxAxes() { return -1; } | |
824 | int GetPollingMin() { return -1; } | |
825 | int GetPollingMax() { return -1; } | |
826 | int GetRudderMin() { return -1; } | |
827 | int GetRudderMax() { return -1; } | |
828 | int GetUMin() { return -1; } | |
829 | int GetUMax() { return -1; } | |
830 | int GetVMin() { return -1; } | |
831 | int GetVMax() { return -1; } | |
832 | ||
833 | bool HasRudder() { return FALSE; } | |
834 | bool HasZ() { return FALSE; } | |
835 | bool HasU() { return FALSE; } | |
836 | bool HasV() { return FALSE; } | |
837 | bool HasPOV() { return FALSE; } | |
838 | bool HasPOV4Dir() { return FALSE; } | |
839 | bool HasPOVCTS() { return FALSE; } | |
840 | ||
841 | bool SetCapture(wxWindow* win, int pollingFreq = 0) { return FALSE; } | |
842 | bool ReleaseCapture() { return FALSE; } | |
843 | }; | |
844 | #endif | |
845 | %} | |
846 | ||
847 | ||
9416aa89 | 848 | class wxJoystick : public wxObject { |
185d7c3e RD |
849 | public: |
850 | wxJoystick(int joystick = wxJOYSTICK1); | |
ac346f50 RD |
851 | ~wxJoystick(); |
852 | ||
185d7c3e RD |
853 | wxPoint GetPosition(); |
854 | int GetZPosition(); | |
855 | int GetButtonState(); | |
856 | int GetPOVPosition(); | |
857 | int GetPOVCTSPosition(); | |
858 | int GetRudderPosition(); | |
859 | int GetUPosition(); | |
860 | int GetVPosition(); | |
861 | int GetMovementThreshold(); | |
862 | void SetMovementThreshold(int threshold) ; | |
863 | ||
864 | bool IsOk(void); | |
865 | int GetNumberJoysticks(); | |
866 | int GetManufacturerId(); | |
867 | int GetProductId(); | |
868 | wxString GetProductName(); | |
869 | int GetXMin(); | |
870 | int GetYMin(); | |
871 | int GetZMin(); | |
872 | int GetXMax(); | |
873 | int GetYMax(); | |
874 | int GetZMax(); | |
875 | int GetNumberButtons(); | |
876 | int GetNumberAxes(); | |
877 | int GetMaxButtons(); | |
878 | int GetMaxAxes(); | |
879 | int GetPollingMin(); | |
880 | int GetPollingMax(); | |
881 | int GetRudderMin(); | |
882 | int GetRudderMax(); | |
883 | int GetUMin(); | |
884 | int GetUMax(); | |
885 | int GetVMin(); | |
886 | int GetVMax(); | |
887 | ||
888 | bool HasRudder(); | |
889 | bool HasZ(); | |
890 | bool HasU(); | |
891 | bool HasV(); | |
892 | bool HasPOV(); | |
893 | bool HasPOV4Dir(); | |
894 | bool HasPOVCTS(); | |
895 | ||
896 | bool SetCapture(wxWindow* win, int pollingFreq = 0); | |
897 | bool ReleaseCapture(); | |
898 | }; | |
493f1553 RD |
899 | |
900 | //---------------------------------------------------------------------- | |
901 | ||
902 | %{ | |
0adbc166 | 903 | #if !wxUSE_WAVE |
493f1553 RD |
904 | // A C++ stub class for wxWave for platforms that don't have it. |
905 | class wxWave : public wxObject | |
906 | { | |
907 | public: | |
908 | wxWave(const wxString& fileName, bool isResource = FALSE) { | |
4268f798 | 909 | wxPyBeginBlockThreads(); |
493f1553 | 910 | PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform."); |
4268f798 | 911 | wxPyEndBlockThreads(); |
493f1553 RD |
912 | } |
913 | wxWave(int size, const wxByte* data) { | |
4268f798 | 914 | wxPyBeginBlockThreads(); |
493f1553 | 915 | PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform."); |
4268f798 | 916 | wxPyEndBlockThreads(); |
493f1553 RD |
917 | } |
918 | ||
919 | ~wxWave() {} | |
920 | ||
921 | bool IsOk() const { return FALSE; } | |
922 | bool Play(bool async = TRUE, bool looped = FALSE) const { return FALSE; } | |
923 | }; | |
924 | ||
2cd2fac8 | 925 | #endif |
493f1553 RD |
926 | %} |
927 | ||
928 | class wxWave : public wxObject | |
929 | { | |
930 | public: | |
931 | wxWave(const wxString& fileName, bool isResource = FALSE); | |
932 | ~wxWave(); | |
933 | ||
934 | bool IsOk() const; | |
935 | bool Play(bool async = TRUE, bool looped = FALSE) const; | |
936 | }; | |
937 | ||
938 | %new wxWave* wxWaveData(const wxString& data); | |
939 | %{ // Implementations of some alternate "constructors" | |
940 | wxWave* wxWaveData(const wxString& data) { | |
941 | return new wxWave(data.Len(), (wxByte*)data.c_str()); | |
942 | } | |
943 | %} | |
185d7c3e | 944 | |
4f3449b4 | 945 | |
b37c7e1d RD |
946 | //---------------------------------------------------------------------- |
947 | ||
948 | enum wxMailcapStyle | |
949 | { | |
950 | wxMAILCAP_STANDARD = 1, | |
951 | wxMAILCAP_NETSCAPE = 2, | |
952 | wxMAILCAP_KDE = 4, | |
953 | wxMAILCAP_GNOME = 8, | |
954 | ||
955 | wxMAILCAP_ALL = 15 | |
956 | }; | |
957 | ||
958 | ||
959 | ||
960 | class wxFileTypeInfo | |
961 | { | |
962 | public: | |
963 | // ctors | |
964 | // a normal item | |
965 | wxFileTypeInfo(const char *mimeType, | |
966 | const char *openCmd, | |
967 | const char *printCmd, | |
968 | const char *desc); | |
969 | ||
970 | ||
971 | // the array elements correspond to the parameters of the ctor above in | |
972 | // the same order | |
973 | %name(wxFileTypeInfoSequence)wxFileTypeInfo(const wxArrayString& sArray); | |
974 | ||
975 | // invalid item - use this to terminate the array passed to | |
976 | // wxMimeTypesManager::AddFallbacks | |
977 | %name(wxNullFileTypeInfo)wxFileTypeInfo(); | |
978 | ||
979 | ||
980 | // test if this object can be used | |
981 | bool IsValid() const; | |
982 | ||
983 | // setters | |
984 | // set the icon info | |
985 | void SetIcon(const wxString& iconFile, int iconIndex = 0); | |
986 | ||
987 | // set the short desc | |
988 | void SetShortDesc(const wxString& shortDesc); | |
989 | ||
990 | // accessors | |
991 | // get the MIME type | |
992 | const wxString& GetMimeType() const; | |
993 | // get the open command | |
994 | const wxString& GetOpenCommand() const; | |
995 | // get the print command | |
996 | const wxString& GetPrintCommand() const; | |
997 | // get the short description (only used under Win32 so far) | |
998 | const wxString& GetShortDesc() const; | |
999 | // get the long, user visible description | |
1000 | const wxString& GetDescription() const; | |
1001 | ||
1002 | ||
1003 | // get the array of all extensions | |
1004 | //const wxArrayString& GetExtensions() const; | |
1005 | %addmethods { | |
1006 | PyObject* GetExtensions() { | |
1007 | wxArrayString& arr = (wxArrayString&)self->GetExtensions(); | |
1008 | return wxArrayString2PyList_helper(arr); | |
1009 | } | |
1010 | } | |
1011 | ||
1012 | int GetExtensionsCount() const; | |
1013 | ||
1014 | // get the icon info | |
1015 | const wxString& GetIconFile() const; | |
1016 | int GetIconIndex() const; | |
1017 | }; | |
1018 | ||
1019 | ||
1020 | ||
1021 | ||
1022 | class wxFileType | |
1023 | { | |
1024 | public: | |
1025 | ||
1026 | // TODO: Make a wxPyMessageParameters with virtual GetParamValue... | |
1027 | ||
1028 | // An object of this class must be passed to Get{Open|Print}Command. The | |
1029 | // default implementation is trivial and doesn't know anything at all about | |
1030 | // parameters, only filename and MIME type are used (so it's probably ok for | |
1031 | // Windows where %{param} is not used anyhow) | |
1032 | class MessageParameters | |
1033 | { | |
1034 | public: | |
1035 | // ctors | |
1036 | MessageParameters(const wxString& filename=wxPyEmptyStr, | |
1037 | const wxString& mimetype=wxPyEmptyStr); | |
1038 | ||
1039 | // accessors (called by GetOpenCommand) | |
1040 | // filename | |
1041 | const wxString& GetFileName() const; | |
1042 | // mime type | |
1043 | const wxString& GetMimeType() const;; | |
1044 | ||
1045 | // override this function in derived class | |
1046 | virtual wxString GetParamValue(const wxString& name) const; | |
1047 | ||
1048 | // virtual dtor as in any base class | |
1049 | virtual ~MessageParameters(); | |
1050 | }; | |
1051 | ||
1052 | ||
1053 | // ctor from static data | |
1054 | wxFileType(const wxFileTypeInfo& ftInfo); | |
1055 | ||
1056 | // return the MIME type for this file type | |
1057 | %addmethods { | |
1058 | PyObject* GetMimeType() { | |
1059 | wxString str; | |
1060 | if (self->GetMimeType(&str)) | |
1061 | return PyString_FromString(str.c_str()); | |
1062 | else | |
1063 | RETURN_NONE(); | |
1064 | } | |
1065 | PyObject* GetMimeTypes() { | |
1066 | wxArrayString arr; | |
1067 | if (self->GetMimeTypes(arr)) | |
1068 | return wxArrayString2PyList_helper(arr); | |
1069 | else | |
1070 | RETURN_NONE(); | |
1071 | } | |
1072 | } | |
1073 | ||
1074 | ||
1075 | // Get all extensions associated with this file type | |
1076 | %addmethods { | |
1077 | PyObject* GetExtensions() { | |
1078 | wxArrayString arr; | |
1079 | if (self->GetExtensions(arr)) | |
1080 | return wxArrayString2PyList_helper(arr); | |
1081 | else | |
1082 | RETURN_NONE(); | |
1083 | } | |
1084 | } | |
1085 | ||
1086 | ||
1087 | %addmethods { | |
1088 | // Get the icon corresponding to this file type | |
1089 | %new wxIcon* GetIcon() { | |
1090 | wxIcon icon; | |
1091 | if (self->GetIcon(&icon)) | |
1092 | return new wxIcon(icon); | |
1093 | else | |
1094 | return NULL; | |
1095 | } | |
1096 | ||
1097 | // Get the icon corresponding to this file type, the name of the file | |
1098 | // where this icon resides, and its index in this file if applicable. | |
1099 | PyObject* GetIconInfo() { | |
1100 | wxIcon icon; | |
1101 | wxString iconFile; | |
1102 | int iconIndex; | |
1103 | if (self->GetIcon(&icon, &iconFile, &iconIndex)) { | |
4268f798 | 1104 | wxPyBeginBlockThreads(); |
b37c7e1d RD |
1105 | PyObject* tuple = PyTuple_New(3); |
1106 | PyTuple_SetItem(tuple, 0, wxPyConstructObject(new wxIcon(icon), | |
1107 | "wxIcon", TRUE)); | |
1108 | PyTuple_SetItem(tuple, 1, PyString_FromString(iconFile.c_str())); | |
1109 | PyTuple_SetItem(tuple, 2, PyInt_FromLong(iconIndex)); | |
4268f798 | 1110 | wxPyEndBlockThreads(); |
b37c7e1d RD |
1111 | return tuple; |
1112 | } | |
1113 | else | |
1114 | RETURN_NONE(); | |
1115 | } | |
1116 | } | |
1117 | ||
1118 | %addmethods { | |
1119 | // get a brief file type description ("*.txt" => "text document") | |
1120 | PyObject* GetDescription() { | |
1121 | wxString str; | |
1122 | if (self->GetDescription(&str)) | |
1123 | return PyString_FromString(str.c_str()); | |
1124 | else | |
1125 | RETURN_NONE(); | |
1126 | } | |
1127 | } | |
1128 | ||
1129 | ||
1130 | // get the command to open/execute the file of given type | |
1131 | %addmethods { | |
1132 | PyObject* GetOpenCommand(const wxString& filename, | |
1133 | const wxString& mimetype=wxPyEmptyStr) { | |
1134 | wxString str; | |
1135 | if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype))) | |
1136 | return PyString_FromString(str.c_str()); | |
1137 | else | |
1138 | RETURN_NONE(); | |
1139 | } | |
1140 | } | |
1141 | ||
1142 | ||
1143 | // get the command to print the file of given type | |
1144 | %addmethods { | |
1145 | PyObject* GetPrintCommand(const wxString& filename, | |
1146 | const wxString& mimetype=wxPyEmptyStr) { | |
1147 | wxString str; | |
1148 | if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype))) | |
1149 | return PyString_FromString(str.c_str()); | |
1150 | else | |
1151 | RETURN_NONE(); | |
1152 | } | |
1153 | } | |
1154 | ||
1155 | ||
1156 | // Get all commands defined for this file type | |
1157 | %addmethods { | |
1158 | PyObject* GetAllCommands(const wxString& filename, | |
1159 | const wxString& mimetype=wxPyEmptyStr) { | |
1160 | wxArrayString verbs; | |
1161 | wxArrayString commands; | |
1162 | if (self->GetAllCommands(&verbs, &commands, | |
1163 | wxFileType::MessageParameters(filename, mimetype))) { | |
4268f798 | 1164 | wxPyBeginBlockThreads(); |
b37c7e1d RD |
1165 | PyObject* tuple = PyTuple_New(2); |
1166 | PyTuple_SetItem(tuple, 0, wxArrayString2PyList_helper(verbs)); | |
1167 | PyTuple_SetItem(tuple, 1, wxArrayString2PyList_helper(commands)); | |
4268f798 | 1168 | wxPyEndBlockThreads(); |
b37c7e1d RD |
1169 | return tuple; |
1170 | } | |
1171 | else | |
1172 | RETURN_NONE(); | |
1173 | } | |
1174 | } | |
1175 | ||
1176 | ||
1177 | // set an arbitrary command, ask confirmation if it already exists and | |
1178 | // overwriteprompt is TRUE | |
1179 | bool SetCommand(const wxString& cmd, const wxString& verb, | |
1180 | bool overwriteprompt = TRUE); | |
1181 | ||
1182 | bool SetDefaultIcon(const wxString& cmd = wxEmptyString, int index = 0); | |
1183 | ||
1184 | ||
1185 | // remove the association for this filetype from the system MIME database: | |
1186 | // notice that it will only work if the association is defined in the user | |
1187 | // file/registry part, we will never modify the system-wide settings | |
1188 | bool Unassociate(); | |
1189 | ||
1190 | // operations | |
1191 | // expand a string in the format of GetOpenCommand (which may contain | |
1192 | // '%s' and '%t' format specificators for the file name and mime type | |
1193 | // and %{param} constructions). | |
1194 | static wxString ExpandCommand(const wxString& command, | |
1195 | const MessageParameters& params); | |
1196 | ||
1197 | // dtor (not virtual, shouldn't be derived from) | |
1198 | ~wxFileType(); | |
1199 | ||
1200 | }; | |
1201 | ||
1202 | ||
1203 | ||
1204 | ||
1205 | class wxMimeTypesManager | |
1206 | { | |
1207 | public: | |
1208 | // static helper functions | |
1209 | // ----------------------- | |
1210 | ||
1211 | // check if the given MIME type is the same as the other one: the | |
1212 | // second argument may contain wildcards ('*'), but not the first. If | |
1213 | // the types are equal or if the mimeType matches wildcard the function | |
1214 | // returns TRUE, otherwise it returns FALSE | |
1215 | static bool IsOfType(const wxString& mimeType, const wxString& wildcard); | |
1216 | ||
1217 | // ctor | |
1218 | wxMimeTypesManager(); | |
1219 | ||
1220 | // loads data from standard files according to the mailcap styles | |
1221 | // specified: this is a bitwise OR of wxMailcapStyle values | |
1222 | // | |
1223 | // use the extraDir parameter if you want to look for files in another | |
1224 | // directory | |
1225 | void Initialize(int mailcapStyle = wxMAILCAP_STANDARD, | |
1226 | const wxString& extraDir = wxEmptyString); | |
1227 | ||
1228 | // and this function clears all the data from the manager | |
1229 | void ClearData(); | |
1230 | ||
1231 | // Database lookup: all functions return a pointer to wxFileType object | |
1232 | // whose methods may be used to query it for the information you're | |
1233 | // interested in. If the return value is !NULL, caller is responsible for | |
1234 | // deleting it. | |
1235 | // get file type from file extension | |
1236 | %new wxFileType *GetFileTypeFromExtension(const wxString& ext); | |
1237 | ||
1238 | // get file type from MIME type (in format <category>/<format>) | |
1239 | %new wxFileType *GetFileTypeFromMimeType(const wxString& mimeType); | |
1240 | ||
1241 | // other operations: return TRUE if there were no errors or FALSE if there | |
1242 | // were some unreckognized entries (the good entries are always read anyhow) | |
1243 | // | |
1244 | ||
1245 | // read in additional file (the standard ones are read automatically) | |
1246 | // in mailcap format (see mimetype.cpp for description) | |
1247 | // | |
1248 | // 'fallback' parameter may be set to TRUE to avoid overriding the | |
1249 | // settings from other, previously parsed, files by this one: normally, | |
1250 | // the files read most recently would override the older files, but with | |
1251 | // fallback == TRUE this won't happen | |
1252 | bool ReadMailcap(const wxString& filename, bool fallback = FALSE); | |
1253 | ||
1254 | // read in additional file in mime.types format | |
1255 | bool ReadMimeTypes(const wxString& filename); | |
1256 | ||
1257 | // enumerate all known MIME types | |
1258 | %addmethods { | |
1259 | PyObject* EnumAllFileTypes() { | |
1260 | wxArrayString arr; | |
1261 | self->EnumAllFileTypes(arr); | |
1262 | return wxArrayString2PyList_helper(arr); | |
1263 | } | |
1264 | } | |
1265 | ||
1266 | // these functions can be used to provide default values for some of the | |
1267 | // MIME types inside the program itself (you may also use | |
1268 | // ReadMailcap(filenameWithDefaultTypes, TRUE /* use as fallback */) to | |
1269 | // achieve the same goal, but this requires having this info in a file). | |
1270 | // | |
1271 | void AddFallback(const wxFileTypeInfo& ft); | |
1272 | ||
1273 | ||
1274 | // create or remove associations | |
1275 | ||
1276 | // create a new association using the fields of wxFileTypeInfo (at least | |
1277 | // the MIME type and the extension should be set) | |
1278 | // if the other fields are empty, the existing values should be left alone | |
1279 | %new wxFileType *Associate(const wxFileTypeInfo& ftInfo); | |
1280 | ||
1281 | // undo Associate() | |
1282 | bool Unassociate(wxFileType *ft) ; | |
1283 | ||
1284 | // dtor (not virtual, shouldn't be derived from) | |
1285 | ~wxMimeTypesManager(); | |
1286 | }; | |
1287 | ||
1288 | ||
1289 | %readonly | |
1290 | %{ | |
1291 | #if 0 | |
1292 | %} | |
1293 | extern wxMimeTypesManager* wxTheMimeTypesManager; | |
1294 | %{ | |
1295 | #endif | |
1296 | %} | |
1297 | %readwrite | |
1298 | ||
7dbce44a RD |
1299 | //---------------------------------------------------------------------- |
1300 | ||
1301 | %{ | |
1302 | #include <wx/docview.h> | |
1303 | %} | |
1304 | ||
1305 | class wxFileHistory : public wxObject | |
1306 | { | |
1307 | public: | |
1308 | wxFileHistory(int maxFiles = 9); | |
1309 | ~wxFileHistory(); | |
1310 | ||
1311 | // Operations | |
1312 | void AddFileToHistory(const wxString& file); | |
1313 | void RemoveFileFromHistory(int i); | |
1314 | int GetMaxFiles() const; | |
1315 | void UseMenu(wxMenu *menu); | |
1316 | ||
1317 | // Remove menu from the list (MDI child may be closing) | |
1318 | void RemoveMenu(wxMenu *menu); | |
1319 | ||
1320 | void Load(wxConfigBase& config); | |
1321 | void Save(wxConfigBase& config); | |
1322 | ||
1323 | void AddFilesToMenu(); | |
1324 | %name(AddFilesToSingleMenu)void AddFilesToMenu(wxMenu* menu); | |
1325 | ||
1326 | // Accessors | |
1327 | wxString GetHistoryFile(int i) const; | |
1328 | ||
1329 | // A synonym for GetNoHistoryFiles | |
1330 | int GetCount() const; | |
1331 | int GetNoHistoryFiles() const; | |
1332 | ||
1333 | }; | |
1334 | ||
4f3449b4 | 1335 | //---------------------------------------------------------------------- |
f0261a72 | 1336 | //---------------------------------------------------------------------- |
9416aa89 | 1337 | |
493f1553 | 1338 | |
9416aa89 RD |
1339 | %init %{ |
1340 | wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator"); | |
1341 | wxPyPtrTypeMap_Add("wxDragImage", "wxGenericDragImage"); | |
1342 | wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess"); | |
1343 | %} | |
1344 | ||
f0261a72 RD |
1345 | //---------------------------------------------------------------------- |
1346 |