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