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