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