]>
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 "pyistream.h" | |
20 | #include <wx/resource.h> | |
21 | #include <wx/tooltip.h> | |
22 | #include <wx/caret.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 | //---------------------------------------------------------------------- | |
53 | ||
54 | %{ | |
55 | // Put some wx default wxChar* values into wxStrings. | |
56 | DECLARE_DEF_STRING(FileSelectorPromptStr); | |
57 | DECLARE_DEF_STRING(FileSelectorDefaultWildcardStr); | |
58 | DECLARE_DEF_STRING(DirSelectorPromptStr); | |
59 | static const wxString wxPyEmptyString(wxT("")); | |
60 | %} | |
61 | ||
62 | //--------------------------------------------------------------------------- | |
63 | // Dialog Functions | |
64 | ||
65 | wxString wxFileSelector(const wxString& message = wxPyFileSelectorPromptStr, | |
66 | const wxString& default_path = wxPyEmptyString, | |
67 | const wxString& default_filename = wxPyEmptyString, | |
68 | const wxString& default_extension = wxPyEmptyString, | |
69 | const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr, | |
70 | int flags = 0, | |
71 | wxWindow *parent = NULL, | |
72 | int x = -1, int y = -1); | |
73 | ||
74 | // Ask for filename to load | |
75 | wxString wxLoadFileSelector(const wxString& what, | |
76 | const wxString& extension, | |
77 | const wxString& default_name = wxPyEmptyString, | |
78 | wxWindow *parent = NULL); | |
79 | ||
80 | // Ask for filename to save | |
81 | wxString wxSaveFileSelector(const wxString& what, | |
82 | const wxString& extension, | |
83 | const wxString& default_name = wxPyEmptyString, | |
84 | wxWindow *parent = NULL); | |
85 | ||
86 | ||
87 | wxString wxDirSelector(const wxString& message = wxPyDirSelectorPromptStr, | |
88 | const wxString& defaultPath = wxPyEmptyString, | |
89 | long style = wxDD_DEFAULT_STYLE, | |
90 | const wxPoint& pos = wxDefaultPosition, | |
91 | wxWindow *parent = NULL); | |
92 | ||
93 | wxString wxGetTextFromUser(const wxString& message, | |
94 | const wxString& caption = wxPyEmptyString, | |
95 | const wxString& default_value = wxPyEmptyString, | |
96 | wxWindow *parent = NULL, | |
97 | int x = -1, int y = -1, | |
98 | bool centre = TRUE); | |
99 | ||
100 | wxString wxGetPasswordFromUser(const wxString& message, | |
101 | const wxString& caption = wxPyEmptyString, | |
102 | const wxString& default_value = wxPyEmptyString, | |
103 | wxWindow *parent = NULL); | |
104 | ||
105 | ||
106 | // TODO: Need to custom wrap this one... | |
107 | // int wxGetMultipleChoice(char* message, char* caption, | |
108 | // int LCOUNT, char** choices, | |
109 | // int nsel, int *selection, | |
110 | // wxWindow *parent = NULL, int x = -1, int y = -1, | |
111 | // bool centre = TRUE, int width=150, int height=200); | |
112 | ||
113 | ||
114 | wxString wxGetSingleChoice(const wxString& message, const wxString& caption, | |
115 | int LCOUNT, wxString* choices, | |
116 | wxWindow *parent = NULL, | |
117 | int x = -1, int y = -1, | |
118 | bool centre = TRUE, | |
119 | int width=150, int height=200); | |
120 | ||
121 | int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption, | |
122 | int LCOUNT, wxString* choices, | |
123 | wxWindow *parent = NULL, | |
124 | int x = -1, int y = -1, | |
125 | bool centre = TRUE, | |
126 | int width=150, int height=200); | |
127 | ||
128 | ||
129 | int wxMessageBox(const wxString& message, | |
130 | const wxString& caption = wxPyEmptyString, | |
131 | int style = wxOK | wxCENTRE, | |
132 | wxWindow *parent = NULL, | |
133 | int x = -1, int y = -1); | |
134 | ||
135 | long wxGetNumberFromUser(const wxString& message, | |
136 | const wxString& prompt, | |
137 | const wxString& caption, | |
138 | long value, | |
139 | long min = 0, long max = 100, | |
140 | wxWindow *parent = NULL, | |
141 | const wxPoint& pos = wxDefaultPosition); | |
142 | ||
143 | //--------------------------------------------------------------------------- | |
144 | // GDI Functions | |
145 | ||
146 | bool wxColourDisplay(); | |
147 | ||
148 | int wxDisplayDepth(); | |
149 | int wxGetDisplayDepth(); | |
150 | ||
151 | void wxDisplaySize(int* OUTPUT, int* OUTPUT); | |
152 | wxSize wxGetDisplaySize(); | |
153 | ||
154 | void wxDisplaySizeMM(int* OUTPUT, int* OUTPUT); | |
155 | wxSize wxGetDisplaySizeMM(); | |
156 | ||
157 | void wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT); | |
158 | wxRect wxGetClientDisplayRect(); | |
159 | ||
160 | void wxSetCursor(wxCursor& cursor); | |
161 | ||
162 | //---------------------------------------------------------------------- | |
163 | // Miscellaneous functions | |
164 | ||
165 | void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR); | |
166 | wxWindow * wxGetActiveWindow(); | |
167 | ||
168 | wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt); | |
169 | wxWindow* wxFindWindowAtPoint(const wxPoint& pt); | |
170 | ||
171 | #ifdef __WXMSW__ | |
172 | bool wxCheckForInterrupt(wxWindow *wnd); | |
173 | void wxFlushEvents(); | |
174 | #endif | |
175 | ||
176 | wxWindow* wxGetTopLevelParent(wxWindow *win); | |
177 | ||
178 | //--------------------------------------------------------------------------- | |
179 | // Resource System | |
180 | ||
181 | bool wxResourceAddIdentifier(char* name, int value); | |
182 | void wxResourceClear(void); | |
183 | wxBitmap wxResourceCreateBitmap(char* resource); | |
184 | wxIcon wxResourceCreateIcon(char* resource); | |
185 | wxMenuBar * wxResourceCreateMenuBar(char* resource); | |
186 | int wxResourceGetIdentifier(char* name); | |
187 | bool wxResourceParseData(char* resource, wxResourceTable *table = NULL); | |
188 | bool wxResourceParseFile(char* filename, wxResourceTable *table = NULL); | |
189 | bool wxResourceParseString(char* resource, wxResourceTable *table = NULL); | |
190 | ||
191 | //--------------------------------------------------------------------------- | |
192 | // System Settings | |
193 | ||
194 | // possible values for wxSystemSettings::GetFont() parameter | |
195 | // | |
196 | enum wxSystemFont | |
197 | { | |
198 | wxSYS_OEM_FIXED_FONT = 10, | |
199 | wxSYS_ANSI_FIXED_FONT, | |
200 | wxSYS_ANSI_VAR_FONT, | |
201 | wxSYS_SYSTEM_FONT, | |
202 | wxSYS_DEVICE_DEFAULT_FONT, | |
203 | wxSYS_DEFAULT_PALETTE, | |
204 | wxSYS_SYSTEM_FIXED_FONT, | |
205 | wxSYS_DEFAULT_GUI_FONT | |
206 | }; | |
207 | ||
208 | // possible values for wxSystemSettings::GetColour() parameter | |
209 | // | |
210 | enum wxSystemColour | |
211 | { | |
212 | wxSYS_COLOUR_SCROLLBAR, | |
213 | wxSYS_COLOUR_BACKGROUND, | |
214 | wxSYS_COLOUR_DESKTOP = wxSYS_COLOUR_BACKGROUND, | |
215 | wxSYS_COLOUR_ACTIVECAPTION, | |
216 | wxSYS_COLOUR_INACTIVECAPTION, | |
217 | wxSYS_COLOUR_MENU, | |
218 | wxSYS_COLOUR_WINDOW, | |
219 | wxSYS_COLOUR_WINDOWFRAME, | |
220 | wxSYS_COLOUR_MENUTEXT, | |
221 | wxSYS_COLOUR_WINDOWTEXT, | |
222 | wxSYS_COLOUR_CAPTIONTEXT, | |
223 | wxSYS_COLOUR_ACTIVEBORDER, | |
224 | wxSYS_COLOUR_INACTIVEBORDER, | |
225 | wxSYS_COLOUR_APPWORKSPACE, | |
226 | wxSYS_COLOUR_HIGHLIGHT, | |
227 | wxSYS_COLOUR_HIGHLIGHTTEXT, | |
228 | wxSYS_COLOUR_BTNFACE, | |
229 | wxSYS_COLOUR_3DFACE = wxSYS_COLOUR_BTNFACE, | |
230 | wxSYS_COLOUR_BTNSHADOW, | |
231 | wxSYS_COLOUR_3DSHADOW = wxSYS_COLOUR_BTNSHADOW, | |
232 | wxSYS_COLOUR_GRAYTEXT, | |
233 | wxSYS_COLOUR_BTNTEXT, | |
234 | wxSYS_COLOUR_INACTIVECAPTIONTEXT, | |
235 | wxSYS_COLOUR_BTNHIGHLIGHT, | |
236 | wxSYS_COLOUR_BTNHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT, | |
237 | wxSYS_COLOUR_3DHIGHLIGHT = wxSYS_COLOUR_BTNHIGHLIGHT, | |
238 | wxSYS_COLOUR_3DHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT, | |
239 | wxSYS_COLOUR_3DDKSHADOW, | |
240 | wxSYS_COLOUR_3DLIGHT, | |
241 | wxSYS_COLOUR_INFOTEXT, | |
242 | wxSYS_COLOUR_INFOBK, | |
243 | wxSYS_COLOUR_LISTBOX, | |
244 | wxSYS_COLOUR_HOTLIGHT, | |
245 | wxSYS_COLOUR_GRADIENTACTIVECAPTION, | |
246 | wxSYS_COLOUR_GRADIENTINACTIVECAPTION, | |
247 | wxSYS_COLOUR_MENUHILIGHT, | |
248 | wxSYS_COLOUR_MENUBAR, | |
249 | ||
250 | wxSYS_COLOUR_MAX | |
251 | }; | |
252 | ||
253 | // possible values for wxSystemSettings::GetMetric() parameter | |
254 | // | |
255 | enum wxSystemMetric | |
256 | { | |
257 | wxSYS_MOUSE_BUTTONS = 1, | |
258 | wxSYS_BORDER_X, | |
259 | wxSYS_BORDER_Y, | |
260 | wxSYS_CURSOR_X, | |
261 | wxSYS_CURSOR_Y, | |
262 | wxSYS_DCLICK_X, | |
263 | wxSYS_DCLICK_Y, | |
264 | wxSYS_DRAG_X, | |
265 | wxSYS_DRAG_Y, | |
266 | wxSYS_EDGE_X, | |
267 | wxSYS_EDGE_Y, | |
268 | wxSYS_HSCROLL_ARROW_X, | |
269 | wxSYS_HSCROLL_ARROW_Y, | |
270 | wxSYS_HTHUMB_X, | |
271 | wxSYS_ICON_X, | |
272 | wxSYS_ICON_Y, | |
273 | wxSYS_ICONSPACING_X, | |
274 | wxSYS_ICONSPACING_Y, | |
275 | wxSYS_WINDOWMIN_X, | |
276 | wxSYS_WINDOWMIN_Y, | |
277 | wxSYS_SCREEN_X, | |
278 | wxSYS_SCREEN_Y, | |
279 | wxSYS_FRAMESIZE_X, | |
280 | wxSYS_FRAMESIZE_Y, | |
281 | wxSYS_SMALLICON_X, | |
282 | wxSYS_SMALLICON_Y, | |
283 | wxSYS_HSCROLL_Y, | |
284 | wxSYS_VSCROLL_X, | |
285 | wxSYS_VSCROLL_ARROW_X, | |
286 | wxSYS_VSCROLL_ARROW_Y, | |
287 | wxSYS_VTHUMB_Y, | |
288 | wxSYS_CAPTION_Y, | |
289 | wxSYS_MENU_Y, | |
290 | wxSYS_NETWORK_PRESENT, | |
291 | wxSYS_PENWINDOWS_PRESENT, | |
292 | wxSYS_SHOW_SOUNDS, | |
293 | wxSYS_SWAP_BUTTONS | |
294 | }; | |
295 | ||
296 | // possible values for wxSystemSettings::HasFeature() parameter | |
297 | enum wxSystemFeature | |
298 | { | |
299 | wxSYS_CAN_DRAW_FRAME_DECORATIONS = 1, | |
300 | wxSYS_CAN_ICONIZE_FRAME | |
301 | }; | |
302 | ||
303 | enum wxSystemScreenType | |
304 | { | |
305 | wxSYS_SCREEN_NONE = 0, // not yet defined | |
306 | ||
307 | wxSYS_SCREEN_TINY, // < | |
308 | wxSYS_SCREEN_PDA, // >= 320x240 | |
309 | wxSYS_SCREEN_SMALL, // >= 640x480 | |
310 | wxSYS_SCREEN_DESKTOP // >= 800x600 | |
311 | }; | |
312 | ||
313 | ||
314 | class wxSystemSettings { | |
315 | public: | |
316 | // get a standard system colour | |
317 | static wxColour GetColour(wxSystemColour index); | |
318 | ||
319 | // get a standard system font | |
320 | static wxFont GetFont(wxSystemFont index); | |
321 | ||
322 | // get a system-dependent metric | |
323 | static int GetMetric(wxSystemMetric index); | |
324 | ||
325 | // return true if the port has certain feature | |
326 | static bool HasFeature(wxSystemFeature index); | |
327 | ||
328 | // Get system screen design (desktop, pda, ..) used for | |
329 | // laying out various dialogs. | |
330 | static wxSystemScreenType GetScreenType(); | |
331 | ||
332 | // Override default. | |
333 | static void SetScreenType( wxSystemScreenType screen ); | |
334 | ||
335 | }; | |
336 | ||
337 | ||
338 | ||
339 | //--------------------------------------------------------------------------- | |
340 | // wxToolTip | |
341 | ||
342 | class wxToolTip : public wxObject { | |
343 | public: | |
344 | wxToolTip(const wxString &tip); | |
345 | ||
346 | void SetTip(const wxString& tip); | |
347 | wxString GetTip(); | |
348 | // *** Not in the "public" interface void SetWindow(wxWindow *win); | |
349 | wxWindow *GetWindow(); | |
350 | ||
351 | static void Enable(bool flag); | |
352 | static void SetDelay(long milliseconds); | |
353 | }; | |
354 | ||
355 | //---------------------------------------------------------------------- | |
356 | ||
357 | class wxCaret { | |
358 | public: | |
359 | wxCaret(wxWindow* window, const wxSize& size); | |
360 | ~wxCaret(); | |
361 | ||
362 | bool IsOk(); | |
363 | bool IsVisible(); | |
364 | %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT); | |
365 | wxPoint GetPosition(); | |
366 | %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT); | |
367 | wxSize GetSize(); | |
368 | wxWindow *GetWindow(); | |
369 | %name(MoveXY)void Move(int x, int y); | |
370 | void Move(const wxPoint& pt); | |
371 | %name(SetSizeWH) void SetSize(int width, int height); | |
372 | void SetSize(const wxSize& size); | |
373 | void Show(int show = TRUE); | |
374 | void Hide(); | |
375 | }; | |
376 | ||
377 | %inline %{ | |
378 | int wxCaret_GetBlinkTime() { | |
379 | return wxCaret::GetBlinkTime(); | |
380 | } | |
381 | ||
382 | void wxCaret_SetBlinkTime(int milliseconds) { | |
383 | wxCaret::SetBlinkTime(milliseconds); | |
384 | } | |
385 | %} | |
386 | ||
387 | //---------------------------------------------------------------------- | |
388 | ||
389 | class wxBusyCursor { | |
390 | public: | |
391 | wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR); | |
392 | ~wxBusyCursor(); | |
393 | }; | |
394 | ||
395 | //---------------------------------------------------------------------- | |
396 | ||
397 | class wxWindowDisabler { | |
398 | public: | |
399 | wxWindowDisabler(wxWindow *winToSkip = NULL); | |
400 | ~wxWindowDisabler(); | |
401 | }; | |
402 | ||
403 | //---------------------------------------------------------------------- | |
404 | ||
405 | bool wxSafeYield(wxWindow* win=NULL); | |
406 | void wxPostEvent(wxEvtHandler *dest, wxEvent& event); | |
407 | void wxWakeUpIdle(); | |
408 | ||
409 | ||
410 | #ifdef __WXMSW__ | |
411 | void wxWakeUpMainThread(); | |
412 | #endif | |
413 | ||
414 | void wxMutexGuiEnter(); | |
415 | void wxMutexGuiLeave(); | |
416 | ||
417 | ||
418 | class wxMutexGuiLocker { | |
419 | public: | |
420 | wxMutexGuiLocker(); | |
421 | ~wxMutexGuiLocker(); | |
422 | }; | |
423 | ||
424 | ||
425 | %inline %{ | |
426 | bool wxThread_IsMain() { | |
427 | #ifdef WXP_WITH_THREAD | |
428 | return wxThread::IsMain(); | |
429 | #else | |
430 | return TRUE; | |
431 | #endif | |
432 | } | |
433 | %} | |
434 | ||
435 | //---------------------------------------------------------------------- | |
436 | ||
437 | ||
438 | class wxTipProvider | |
439 | { | |
440 | public: | |
441 | // wxTipProvider(size_t currentTip); **** Abstract base class | |
442 | ~wxTipProvider(); | |
443 | ||
444 | virtual wxString GetTip() = 0; | |
445 | size_t GetCurrentTip(); | |
446 | ||
447 | }; | |
448 | ||
449 | ||
450 | // The C++ version of wxPyTipProvider | |
451 | %{ | |
452 | class wxPyTipProvider : public wxTipProvider { | |
453 | public: | |
454 | wxPyTipProvider(size_t currentTip) | |
455 | : wxTipProvider(currentTip) {} | |
456 | ||
457 | DEC_PYCALLBACK_STRING__pure(GetTip); | |
458 | ||
459 | PYPRIVATE; | |
460 | }; | |
461 | ||
462 | IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip); | |
463 | ||
464 | %} | |
465 | ||
466 | ||
467 | // Now let SWIG know about it | |
468 | class wxPyTipProvider : public wxTipProvider { | |
469 | public: | |
470 | wxPyTipProvider(size_t currentTip); | |
471 | ||
472 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
473 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyTipProvider)" | |
474 | }; | |
475 | ||
476 | ||
477 | ||
478 | bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE); | |
479 | %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip); | |
480 | ||
481 | ||
482 | //---------------------------------------------------------------------- | |
483 | ||
484 | %{ | |
485 | #include <wx/generic/dragimgg.h> | |
486 | %} | |
487 | ||
488 | %name (wxDragImage) class wxGenericDragImage : public wxObject | |
489 | { | |
490 | public: | |
491 | ||
492 | wxGenericDragImage(const wxBitmap& image, | |
493 | const wxCursor& cursor = wxNullCursor); | |
494 | %name(wxDragIcon)wxGenericDragImage(const wxIcon& image, | |
495 | const wxCursor& cursor = wxNullCursor); | |
496 | %name(wxDragString)wxGenericDragImage(const wxString& str, | |
497 | const wxCursor& cursor = wxNullCursor); | |
498 | %name(wxDragTreeItem)wxGenericDragImage(const wxTreeCtrl& treeCtrl, wxTreeItemId& id); | |
499 | %name(wxDragListItem)wxGenericDragImage(const wxListCtrl& listCtrl, long id); | |
500 | ||
501 | ~wxGenericDragImage(); | |
502 | ||
503 | void SetBackingBitmap(wxBitmap* bitmap); | |
504 | bool BeginDrag(const wxPoint& hotspot, wxWindow* window, | |
505 | bool fullScreen = FALSE, wxRect* rect = NULL); | |
506 | ||
507 | %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window, | |
508 | wxWindow* fullScreenRect); | |
509 | ||
510 | bool EndDrag(); | |
511 | bool Move(const wxPoint& pt); | |
512 | bool Show(); | |
513 | bool Hide(); | |
514 | ||
515 | wxRect GetImageRect(const wxPoint& pos) const; | |
516 | bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos, | |
517 | bool eraseOld, bool drawNew); | |
518 | }; | |
519 | ||
520 | ||
521 | //---------------------------------------------------------------------- | |
522 | ||
523 | class wxPyTimer : public wxObject { | |
524 | public: | |
525 | wxPyTimer(PyObject* notify); | |
526 | ~wxPyTimer(); | |
527 | int GetInterval(); | |
528 | bool IsOneShot(); | |
529 | bool IsRunning(); | |
530 | void SetOwner(wxEvtHandler *owner, int id = -1); | |
531 | void Start(int milliseconds=-1, int oneShot=FALSE); | |
532 | void Stop(); | |
533 | }; | |
534 | ||
535 | ||
536 | class wxStopWatch | |
537 | { | |
538 | public: | |
539 | // ctor starts the stop watch | |
540 | wxStopWatch(); | |
541 | ~wxStopWatch(); | |
542 | void Start(long t = 0); | |
543 | void Pause(); | |
544 | void Resume(); | |
545 | ||
546 | // get elapsed time since the last Start() or Pause() in milliseconds | |
547 | long Time() const; | |
548 | }; | |
549 | ||
550 | ||
551 | //---------------------------------------------------------------------- | |
552 | //---------------------------------------------------------------------- | |
553 | ||
554 | ||
555 | enum | |
556 | { | |
557 | wxLOG_FatalError, // program can't continue, abort immediately | |
558 | wxLOG_Error, // a serious error, user must be informed about it | |
559 | wxLOG_Warning, // user is normally informed about it but may be ignored | |
560 | wxLOG_Message, // normal message (i.e. normal output of a non GUI app) | |
561 | wxLOG_Info, // informational message (a.k.a. 'Verbose') | |
562 | wxLOG_Status, // informational: might go to the status line of GUI app | |
563 | wxLOG_Debug, // never shown to the user, disabled in release mode | |
564 | wxLOG_Trace, // trace messages are also only enabled in debug mode | |
565 | wxLOG_Progress, // used for progress indicator (not yet) | |
566 | wxLOG_User = 100 // user defined levels start here | |
567 | }; | |
568 | ||
569 | #define wxTRACE_MemAlloc "memalloc" // trace memory allocation (new/delete) | |
570 | #define wxTRACE_Messages "messages" // trace window messages/X callbacks | |
571 | #define wxTRACE_ResAlloc "resalloc" // trace GDI resource allocation | |
572 | #define wxTRACE_RefCount "refcount" // trace various ref counting operations | |
573 | ||
574 | #ifdef __WXMSW__ | |
575 | #define wxTRACE_OleCalls "ole" // OLE interface calls | |
576 | #endif | |
577 | ||
578 | enum { | |
579 | wxTraceMemAlloc, | |
580 | wxTraceMessages, | |
581 | wxTraceResAlloc, | |
582 | wxTraceRefCount, | |
583 | ||
584 | #ifdef __WXMSW__ | |
585 | wxTraceOleCalls, | |
586 | #endif | |
587 | }; | |
588 | ||
589 | ||
590 | ||
591 | class wxLog | |
592 | { | |
593 | public: | |
594 | wxLog(); | |
595 | ||
596 | static bool IsEnabled(); | |
597 | static bool EnableLogging(bool doIt = TRUE); | |
598 | static void OnLog(unsigned long level, const wxString& szString, int t=0); | |
599 | ||
600 | virtual void Flush(); | |
601 | bool HasPendingMessages() const; | |
602 | ||
603 | static void FlushActive(); | |
604 | static wxLog *GetActiveTarget(); | |
605 | static wxLog *SetActiveTarget(wxLog *pLogger); | |
606 | ||
607 | static void Suspend(); | |
608 | static void Resume(); | |
609 | ||
610 | static void SetVerbose(bool bVerbose = TRUE); | |
611 | ||
612 | static void DontCreateOnDemand(); | |
613 | static void SetTraceMask(long ulMask); | |
614 | static void AddTraceMask(const wxString& str); | |
615 | static void RemoveTraceMask(const wxString& str); | |
616 | static void ClearTraceMasks(); | |
617 | ||
618 | static void SetTimestamp(const wxString& ts); | |
619 | static const wxString& GetTimestamp(); | |
620 | ||
621 | bool GetVerbose() const; | |
622 | ||
623 | static unsigned long GetTraceMask(); | |
624 | static bool IsAllowedTraceMask(const wxString& mask); | |
625 | ||
626 | // static void TimeStamp(wxString *str); | |
627 | %addmethods { | |
628 | wxString TimeStamp() { | |
629 | wxString msg; | |
630 | wxLog::TimeStamp(&msg); | |
631 | return msg; | |
632 | } | |
633 | } | |
634 | ||
635 | }; | |
636 | ||
637 | ||
638 | class wxLogStderr : public wxLog | |
639 | { | |
640 | public: | |
641 | wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/); | |
642 | }; | |
643 | ||
644 | ||
645 | class wxLogTextCtrl : public wxLog | |
646 | { | |
647 | public: | |
648 | wxLogTextCtrl(wxTextCtrl *pTextCtrl); | |
649 | }; | |
650 | ||
651 | ||
652 | class wxLogGui : public wxLog | |
653 | { | |
654 | public: | |
655 | wxLogGui(); | |
656 | }; | |
657 | ||
658 | class wxLogWindow : public wxLog | |
659 | { | |
660 | public: | |
661 | wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL) | |
662 | const wxString& szTitle, // the title of the frame | |
663 | bool bShow = TRUE, // show window immediately? | |
664 | bool bPassToOld = TRUE); // pass log messages to the old target? | |
665 | ||
666 | void Show(bool bShow = TRUE); | |
667 | wxFrame *GetFrame() const; | |
668 | wxLog *GetOldLog() const; | |
669 | bool IsPassingMessages() const; | |
670 | void PassMessages(bool bDoPass); | |
671 | }; | |
672 | ||
673 | ||
674 | class wxLogChain : public wxLog | |
675 | { | |
676 | public: | |
677 | wxLogChain(wxLog *logger); | |
678 | void SetLog(wxLog *logger); | |
679 | void PassMessages(bool bDoPass); | |
680 | bool IsPassingMessages(); | |
681 | wxLog *GetOldLog(); | |
682 | }; | |
683 | ||
684 | ||
685 | unsigned long wxSysErrorCode(); | |
686 | const wxString wxSysErrorMsg(unsigned long nErrCode = 0); | |
687 | void wxLogFatalError(const wxString& msg); | |
688 | void wxLogError(const wxString& msg); | |
689 | void wxLogWarning(const wxString& msg); | |
690 | void wxLogMessage(const wxString& msg); | |
691 | void wxLogInfo(const wxString& msg); | |
692 | void wxLogVerbose(const wxString& msg); | |
693 | void wxLogStatus(const wxString& msg); | |
694 | %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const wxString& msg); | |
695 | void wxLogSysError(const wxString& msg); | |
696 | ||
697 | void wxLogTrace(const wxString& msg); | |
698 | %name(wxLogTraceMask)void wxLogTrace(const wxString& mask, const wxString& msg); | |
699 | ||
700 | void wxLogGeneric(unsigned long level, const wxString& msg); | |
701 | ||
702 | // wxLogFatalError helper: show the (fatal) error to the user in a safe way, | |
703 | // i.e. without using wxMessageBox() for example because it could crash | |
704 | void wxSafeShowMessage(const wxString& title, const wxString& text); | |
705 | ||
706 | ||
707 | ||
708 | // Suspress logging while an instance of this class exists | |
709 | class wxLogNull | |
710 | { | |
711 | public: | |
712 | wxLogNull(); | |
713 | ~wxLogNull(); | |
714 | }; | |
715 | ||
716 | ||
717 | ||
718 | ||
719 | %{ | |
720 | // A wxLog class that can be derived from in wxPython | |
721 | class wxPyLog : public wxLog { | |
722 | public: | |
723 | wxPyLog() : wxLog() {} | |
724 | ||
725 | virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t) { | |
726 | bool found; | |
727 | wxPyBeginBlockThreads(); | |
728 | if ((found = wxPyCBH_findCallback(m_myInst, "DoLog"))) { | |
729 | PyObject* s = wx2PyString(szString); | |
730 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iOi)", level, s, t)); | |
731 | Py_DECREF(s); | |
732 | } | |
733 | wxPyEndBlockThreads(); | |
734 | if (! found) | |
735 | wxLog::DoLog(level, szString, t); | |
736 | } | |
737 | ||
738 | virtual void DoLogString(const wxChar *szString, time_t t) { | |
739 | bool found; | |
740 | wxPyBeginBlockThreads(); | |
741 | if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString"))) { | |
742 | PyObject* s = wx2PyString(szString); | |
743 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", s, t)); | |
744 | Py_DECREF(s); | |
745 | } | |
746 | wxPyEndBlockThreads(); | |
747 | if (! found) | |
748 | wxLog::DoLogString(szString, t); | |
749 | } | |
750 | ||
751 | PYPRIVATE; | |
752 | }; | |
753 | %} | |
754 | ||
755 | // Now tell SWIG about it | |
756 | class wxPyLog : public wxLog { | |
757 | public: | |
758 | wxPyLog(); | |
759 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
760 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyLog)" | |
761 | %addmethods { void Destroy() { delete self; } } | |
762 | ||
763 | }; | |
764 | ||
765 | ||
766 | //---------------------------------------------------------------------- | |
767 | ||
768 | ||
769 | enum wxKillError | |
770 | { | |
771 | wxKILL_OK, // no error | |
772 | wxKILL_BAD_SIGNAL, // no such signal | |
773 | wxKILL_ACCESS_DENIED, // permission denied | |
774 | wxKILL_NO_PROCESS, // no such process | |
775 | wxKILL_ERROR // another, unspecified error | |
776 | }; | |
777 | ||
778 | enum wxSignal | |
779 | { | |
780 | wxSIGNONE = 0, // verify if the process exists under Unix | |
781 | wxSIGHUP, | |
782 | wxSIGINT, | |
783 | wxSIGQUIT, | |
784 | wxSIGILL, | |
785 | wxSIGTRAP, | |
786 | wxSIGABRT, | |
787 | wxSIGIOT = wxSIGABRT, // another name | |
788 | wxSIGEMT, | |
789 | wxSIGFPE, | |
790 | wxSIGKILL, | |
791 | wxSIGBUS, | |
792 | wxSIGSEGV, | |
793 | wxSIGSYS, | |
794 | wxSIGPIPE, | |
795 | wxSIGALRM, | |
796 | wxSIGTERM | |
797 | ||
798 | // further signals are different in meaning between different Unix systems | |
799 | }; | |
800 | ||
801 | ||
802 | ||
803 | enum { | |
804 | /* event type */ | |
805 | wxEVT_END_PROCESS | |
806 | }; | |
807 | ||
808 | ||
809 | ||
810 | class wxProcessEvent : public wxEvent { | |
811 | public: | |
812 | wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0); | |
813 | int GetPid(); | |
814 | int GetExitCode(); | |
815 | int m_pid, m_exitcode; | |
816 | }; | |
817 | ||
818 | ||
819 | ||
820 | ||
821 | %{ // C++ version of wxProcess derived class | |
822 | ||
823 | class wxPyProcess : public wxProcess { | |
824 | public: | |
825 | wxPyProcess(wxEvtHandler *parent = NULL, int id = -1) | |
826 | : wxProcess(parent, id) | |
827 | {} | |
828 | ||
829 | DEC_PYCALLBACK_VOID_INTINT(OnTerminate); | |
830 | ||
831 | PYPRIVATE; | |
832 | }; | |
833 | ||
834 | IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate); | |
835 | ||
836 | %} | |
837 | ||
838 | ||
839 | %name(wxProcess)class wxPyProcess : public wxEvtHandler { | |
840 | public: | |
841 | // kill the process with the given PID | |
842 | static wxKillError Kill(int pid, wxSignal sig = wxSIGTERM); | |
843 | ||
844 | // test if the given process exists | |
845 | static bool Exists(int pid); | |
846 | ||
847 | // this function replaces the standard popen() one: it launches a process | |
848 | // asynchronously and allows the caller to get the streams connected to its | |
849 | // std{in|out|err} | |
850 | // | |
851 | // on error NULL is returned, in any case the process object will be | |
852 | // deleted automatically when the process terminates and should *not* be | |
853 | // deleted by the caller | |
854 | static wxPyProcess *Open(const wxString& cmd, int flags = wxEXEC_ASYNC); | |
855 | ||
856 | ||
857 | ||
858 | wxPyProcess(wxEvtHandler *parent = NULL, int id = -1); | |
859 | %addmethods { void Destroy() { delete self; } } | |
860 | ||
861 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
862 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxProcess)" | |
863 | ||
864 | void base_OnTerminate(int pid, int status); | |
865 | ||
866 | void Redirect(); | |
867 | bool IsRedirected(); | |
868 | void Detach(); | |
869 | ||
870 | wxInputStream *GetInputStream(); | |
871 | wxInputStream *GetErrorStream(); | |
872 | wxOutputStream *GetOutputStream(); | |
873 | ||
874 | void CloseOutput(); | |
875 | ||
876 | // return TRUE if the child process stdout is not closed | |
877 | bool IsInputOpened() const; | |
878 | ||
879 | // return TRUE if any input is available on the child process stdout/err | |
880 | bool IsInputAvailable() const; | |
881 | bool IsErrorAvailable() const; | |
882 | }; | |
883 | ||
884 | ||
885 | enum | |
886 | { | |
887 | // execute the process asynchronously | |
888 | wxEXEC_ASYNC = 0, | |
889 | ||
890 | // execute it synchronously, i.e. wait until it finishes | |
891 | wxEXEC_SYNC = 1, | |
892 | ||
893 | // under Windows, don't hide the child even if it's IO is redirected (this | |
894 | // is done by default) | |
895 | wxEXEC_NOHIDE = 2, | |
896 | ||
897 | // under Unix, if the process is the group leader then killing -pid kills | |
898 | // all children as well as pid | |
899 | wxEXEC_MAKE_GROUP_LEADER = 4 | |
900 | }; | |
901 | ||
902 | ||
903 | long wxExecute(const wxString& command, | |
904 | int flags = wxEXEC_ASYNC, | |
905 | wxPyProcess *process = NULL); | |
906 | ||
907 | //---------------------------------------------------------------------- | |
908 | ||
909 | ||
910 | // Which joystick? Same as Windows ids so no conversion necessary. | |
911 | enum | |
912 | { | |
913 | wxJOYSTICK1, | |
914 | wxJOYSTICK2 | |
915 | }; | |
916 | ||
917 | // Which button is down? | |
918 | enum | |
919 | { | |
920 | wxJOY_BUTTON_ANY, | |
921 | wxJOY_BUTTON1, | |
922 | wxJOY_BUTTON2, | |
923 | wxJOY_BUTTON3, | |
924 | wxJOY_BUTTON4, | |
925 | }; | |
926 | ||
927 | ||
928 | %{ | |
929 | #if !wxUSE_JOYSTICK && !defined(__WXMSW__) | |
930 | // A C++ stub class for wxJoystick for platforms that don't have it. | |
931 | class wxJoystick : public wxObject { | |
932 | public: | |
933 | wxJoystick(int joystick = wxJOYSTICK1) { | |
934 | wxPyBeginBlockThreads(); | |
935 | PyErr_SetString(PyExc_NotImplementedError, "wxJoystick is not available on this platform."); | |
936 | wxPyEndBlockThreads(); | |
937 | } | |
938 | wxPoint GetPosition() { return wxPoint(-1,-1); } | |
939 | int GetZPosition() { return -1; } | |
940 | int GetButtonState() { return -1; } | |
941 | int GetPOVPosition() { return -1; } | |
942 | int GetPOVCTSPosition() { return -1; } | |
943 | int GetRudderPosition() { return -1; } | |
944 | int GetUPosition() { return -1; } | |
945 | int GetVPosition() { return -1; } | |
946 | int GetMovementThreshold() { return -1; } | |
947 | void SetMovementThreshold(int threshold) {} | |
948 | ||
949 | bool IsOk(void) { return FALSE; } | |
950 | int GetNumberJoysticks() { return -1; } | |
951 | int GetManufacturerId() { return -1; } | |
952 | int GetProductId() { return -1; } | |
953 | wxString GetProductName() { return ""; } | |
954 | int GetXMin() { return -1; } | |
955 | int GetYMin() { return -1; } | |
956 | int GetZMin() { return -1; } | |
957 | int GetXMax() { return -1; } | |
958 | int GetYMax() { return -1; } | |
959 | int GetZMax() { return -1; } | |
960 | int GetNumberButtons() { return -1; } | |
961 | int GetNumberAxes() { return -1; } | |
962 | int GetMaxButtons() { return -1; } | |
963 | int GetMaxAxes() { return -1; } | |
964 | int GetPollingMin() { return -1; } | |
965 | int GetPollingMax() { return -1; } | |
966 | int GetRudderMin() { return -1; } | |
967 | int GetRudderMax() { return -1; } | |
968 | int GetUMin() { return -1; } | |
969 | int GetUMax() { return -1; } | |
970 | int GetVMin() { return -1; } | |
971 | int GetVMax() { return -1; } | |
972 | ||
973 | bool HasRudder() { return FALSE; } | |
974 | bool HasZ() { return FALSE; } | |
975 | bool HasU() { return FALSE; } | |
976 | bool HasV() { return FALSE; } | |
977 | bool HasPOV() { return FALSE; } | |
978 | bool HasPOV4Dir() { return FALSE; } | |
979 | bool HasPOVCTS() { return FALSE; } | |
980 | ||
981 | bool SetCapture(wxWindow* win, int pollingFreq = 0) { return FALSE; } | |
982 | bool ReleaseCapture() { return FALSE; } | |
983 | }; | |
984 | #endif | |
985 | %} | |
986 | ||
987 | ||
988 | class wxJoystick : public wxObject { | |
989 | public: | |
990 | wxJoystick(int joystick = wxJOYSTICK1); | |
991 | ~wxJoystick(); | |
992 | ||
993 | wxPoint GetPosition(); | |
994 | int GetZPosition(); | |
995 | int GetButtonState(); | |
996 | int GetPOVPosition(); | |
997 | int GetPOVCTSPosition(); | |
998 | int GetRudderPosition(); | |
999 | int GetUPosition(); | |
1000 | int GetVPosition(); | |
1001 | int GetMovementThreshold(); | |
1002 | void SetMovementThreshold(int threshold) ; | |
1003 | ||
1004 | bool IsOk(void); | |
1005 | int GetNumberJoysticks(); | |
1006 | int GetManufacturerId(); | |
1007 | int GetProductId(); | |
1008 | wxString GetProductName(); | |
1009 | int GetXMin(); | |
1010 | int GetYMin(); | |
1011 | int GetZMin(); | |
1012 | int GetXMax(); | |
1013 | int GetYMax(); | |
1014 | int GetZMax(); | |
1015 | int GetNumberButtons(); | |
1016 | int GetNumberAxes(); | |
1017 | int GetMaxButtons(); | |
1018 | int GetMaxAxes(); | |
1019 | int GetPollingMin(); | |
1020 | int GetPollingMax(); | |
1021 | int GetRudderMin(); | |
1022 | int GetRudderMax(); | |
1023 | int GetUMin(); | |
1024 | int GetUMax(); | |
1025 | int GetVMin(); | |
1026 | int GetVMax(); | |
1027 | ||
1028 | bool HasRudder(); | |
1029 | bool HasZ(); | |
1030 | bool HasU(); | |
1031 | bool HasV(); | |
1032 | bool HasPOV(); | |
1033 | bool HasPOV4Dir(); | |
1034 | bool HasPOVCTS(); | |
1035 | ||
1036 | bool SetCapture(wxWindow* win, int pollingFreq = 0); | |
1037 | bool ReleaseCapture(); | |
1038 | }; | |
1039 | ||
1040 | //---------------------------------------------------------------------- | |
1041 | ||
1042 | %{ | |
1043 | #if !wxUSE_WAVE | |
1044 | // A C++ stub class for wxWave for platforms that don't have it. | |
1045 | class wxWave : public wxObject | |
1046 | { | |
1047 | public: | |
1048 | wxWave(const wxString& fileName, bool isResource = FALSE) { | |
1049 | wxPyBeginBlockThreads(); | |
1050 | PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform."); | |
1051 | wxPyEndBlockThreads(); | |
1052 | } | |
1053 | wxWave(int size, const wxByte* data) { | |
1054 | wxPyBeginBlockThreads(); | |
1055 | PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform."); | |
1056 | wxPyEndBlockThreads(); | |
1057 | } | |
1058 | ||
1059 | ~wxWave() {} | |
1060 | ||
1061 | bool IsOk() const { return FALSE; } | |
1062 | bool Play(bool async = TRUE, bool looped = FALSE) const { return FALSE; } | |
1063 | }; | |
1064 | ||
1065 | #endif | |
1066 | %} | |
1067 | ||
1068 | class wxWave : public wxObject | |
1069 | { | |
1070 | public: | |
1071 | wxWave(const wxString& fileName, bool isResource = FALSE); | |
1072 | ~wxWave(); | |
1073 | ||
1074 | bool IsOk() const; | |
1075 | bool Play(bool async = TRUE, bool looped = FALSE) const; | |
1076 | }; | |
1077 | ||
1078 | %new wxWave* wxWaveData(const wxString& data); | |
1079 | %{ // Implementations of some alternate "constructors" | |
1080 | wxWave* wxWaveData(const wxString& data) { | |
1081 | return new wxWave(data.Len(), (wxByte*)data.c_str()); | |
1082 | } | |
1083 | %} | |
1084 | ||
1085 | ||
1086 | //---------------------------------------------------------------------- | |
1087 | ||
1088 | enum wxMailcapStyle | |
1089 | { | |
1090 | wxMAILCAP_STANDARD = 1, | |
1091 | wxMAILCAP_NETSCAPE = 2, | |
1092 | wxMAILCAP_KDE = 4, | |
1093 | wxMAILCAP_GNOME = 8, | |
1094 | ||
1095 | wxMAILCAP_ALL = 15 | |
1096 | }; | |
1097 | ||
1098 | ||
1099 | ||
1100 | class wxFileTypeInfo | |
1101 | { | |
1102 | public: | |
1103 | // ctors | |
1104 | // a normal item | |
1105 | wxFileTypeInfo(const char* mimeType, | |
1106 | const char* openCmd, | |
1107 | const char* printCmd, | |
1108 | const char* desc); | |
1109 | ||
1110 | ||
1111 | // the array elements correspond to the parameters of the ctor above in | |
1112 | // the same order | |
1113 | %name(wxFileTypeInfoSequence)wxFileTypeInfo(const wxArrayString& sArray); | |
1114 | ||
1115 | // invalid item - use this to terminate the array passed to | |
1116 | // wxMimeTypesManager::AddFallbacks | |
1117 | %name(wxNullFileTypeInfo)wxFileTypeInfo(); | |
1118 | ||
1119 | ||
1120 | // test if this object can be used | |
1121 | bool IsValid() const; | |
1122 | ||
1123 | // setters | |
1124 | // set the icon info | |
1125 | void SetIcon(const wxString& iconFile, int iconIndex = 0); | |
1126 | ||
1127 | // set the short desc | |
1128 | void SetShortDesc(const wxString& shortDesc); | |
1129 | ||
1130 | // accessors | |
1131 | // get the MIME type | |
1132 | const wxString& GetMimeType() const; | |
1133 | // get the open command | |
1134 | const wxString& GetOpenCommand() const; | |
1135 | // get the print command | |
1136 | const wxString& GetPrintCommand() const; | |
1137 | // get the short description (only used under Win32 so far) | |
1138 | const wxString& GetShortDesc() const; | |
1139 | // get the long, user visible description | |
1140 | const wxString& GetDescription() const; | |
1141 | ||
1142 | ||
1143 | // get the array of all extensions | |
1144 | //const wxArrayString& GetExtensions() const; | |
1145 | %addmethods { | |
1146 | PyObject* GetExtensions() { | |
1147 | wxArrayString& arr = (wxArrayString&)self->GetExtensions(); | |
1148 | return wxArrayString2PyList_helper(arr); | |
1149 | } | |
1150 | } | |
1151 | ||
1152 | int GetExtensionsCount() const; | |
1153 | ||
1154 | // get the icon info | |
1155 | const wxString& GetIconFile() const; | |
1156 | int GetIconIndex() const; | |
1157 | }; | |
1158 | ||
1159 | ||
1160 | ||
1161 | ||
1162 | class wxFileType | |
1163 | { | |
1164 | public: | |
1165 | ||
1166 | // TODO: Make a wxPyMessageParameters with virtual GetParamValue... | |
1167 | ||
1168 | // An object of this class must be passed to Get{Open|Print}Command. The | |
1169 | // default implementation is trivial and doesn't know anything at all about | |
1170 | // parameters, only filename and MIME type are used (so it's probably ok for | |
1171 | // Windows where %{param} is not used anyhow) | |
1172 | class MessageParameters | |
1173 | { | |
1174 | public: | |
1175 | // ctors | |
1176 | MessageParameters(const wxString& filename=wxPyEmptyString, | |
1177 | const wxString& mimetype=wxPyEmptyString); | |
1178 | ||
1179 | // accessors (called by GetOpenCommand) | |
1180 | // filename | |
1181 | const wxString& GetFileName() const; | |
1182 | // mime type | |
1183 | const wxString& GetMimeType() const;; | |
1184 | ||
1185 | // override this function in derived class | |
1186 | virtual wxString GetParamValue(const wxString& name) const; | |
1187 | ||
1188 | // virtual dtor as in any base class | |
1189 | virtual ~MessageParameters(); | |
1190 | }; | |
1191 | ||
1192 | ||
1193 | // ctor from static data | |
1194 | wxFileType(const wxFileTypeInfo& ftInfo); | |
1195 | ||
1196 | // return the MIME type for this file type | |
1197 | %addmethods { | |
1198 | PyObject* GetMimeType() { | |
1199 | wxString str; | |
1200 | if (self->GetMimeType(&str)) { | |
1201 | #if wxUSE_UNICODE | |
1202 | return PyUnicode_FromUnicode(str.c_str(), str.Len()); | |
1203 | #else | |
1204 | return PyString_FromStringAndSize(str.c_str(), str.Len()); | |
1205 | #endif | |
1206 | } | |
1207 | else | |
1208 | RETURN_NONE(); | |
1209 | } | |
1210 | PyObject* GetMimeTypes() { | |
1211 | wxArrayString arr; | |
1212 | if (self->GetMimeTypes(arr)) | |
1213 | return wxArrayString2PyList_helper(arr); | |
1214 | else | |
1215 | RETURN_NONE(); | |
1216 | } | |
1217 | } | |
1218 | ||
1219 | ||
1220 | // Get all extensions associated with this file type | |
1221 | %addmethods { | |
1222 | PyObject* GetExtensions() { | |
1223 | wxArrayString arr; | |
1224 | if (self->GetExtensions(arr)) | |
1225 | return wxArrayString2PyList_helper(arr); | |
1226 | else | |
1227 | RETURN_NONE(); | |
1228 | } | |
1229 | } | |
1230 | ||
1231 | ||
1232 | %addmethods { | |
1233 | // Get the icon corresponding to this file type | |
1234 | %new wxIcon* GetIcon() { | |
1235 | wxIcon icon; | |
1236 | if (self->GetIcon(&icon)) | |
1237 | return new wxIcon(icon); | |
1238 | else | |
1239 | return NULL; | |
1240 | } | |
1241 | ||
1242 | // Get the icon corresponding to this file type, the name of the file | |
1243 | // where this icon resides, and its index in this file if applicable. | |
1244 | PyObject* GetIconInfo() { | |
1245 | wxIcon icon; | |
1246 | wxString iconFile; | |
1247 | int iconIndex; | |
1248 | if (self->GetIcon(&icon, &iconFile, &iconIndex)) { | |
1249 | wxPyBeginBlockThreads(); | |
1250 | PyObject* tuple = PyTuple_New(3); | |
1251 | PyTuple_SetItem(tuple, 0, wxPyConstructObject(new wxIcon(icon), | |
1252 | "wxIcon", TRUE)); | |
1253 | #if wxUSE_UNICODE | |
1254 | PyTuple_SetItem(tuple, 1, PyUnicode_FromUnicode(iconFile.c_str(), iconFile.Len())); | |
1255 | #else | |
1256 | PyTuple_SetItem(tuple, 1, PyString_FromStringAndSize(iconFile.c_str(), iconFile.Len())); | |
1257 | #endif | |
1258 | PyTuple_SetItem(tuple, 2, PyInt_FromLong(iconIndex)); | |
1259 | wxPyEndBlockThreads(); | |
1260 | return tuple; | |
1261 | } | |
1262 | else | |
1263 | RETURN_NONE(); | |
1264 | } | |
1265 | } | |
1266 | ||
1267 | %addmethods { | |
1268 | // get a brief file type description ("*.txt" => "text document") | |
1269 | PyObject* GetDescription() { | |
1270 | wxString str; | |
1271 | if (self->GetDescription(&str)) { | |
1272 | #if wxUSE_UNICODE | |
1273 | return PyUnicode_FromUnicode(str.c_str(), str.Len()); | |
1274 | #else | |
1275 | return PyString_FromStringAndSize(str.c_str(), str.Len()); | |
1276 | #endif | |
1277 | } else | |
1278 | RETURN_NONE(); | |
1279 | } | |
1280 | } | |
1281 | ||
1282 | ||
1283 | // get the command to open/execute the file of given type | |
1284 | %addmethods { | |
1285 | PyObject* GetOpenCommand(const wxString& filename, | |
1286 | const wxString& mimetype=wxPyEmptyString) { | |
1287 | wxString str; | |
1288 | if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype))) { | |
1289 | #if wxUSE_UNICODE | |
1290 | return PyUnicode_FromUnicode(str.c_str(), str.Len()); | |
1291 | #else | |
1292 | return PyString_FromStringAndSize(str.c_str(), str.Len()); | |
1293 | #endif | |
1294 | } else | |
1295 | RETURN_NONE(); | |
1296 | } | |
1297 | } | |
1298 | ||
1299 | ||
1300 | // get the command to print the file of given type | |
1301 | %addmethods { | |
1302 | PyObject* GetPrintCommand(const wxString& filename, | |
1303 | const wxString& mimetype=wxPyEmptyString) { | |
1304 | wxString str; | |
1305 | if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype))) { | |
1306 | #if wxUSE_UNICODE | |
1307 | return PyUnicode_FromUnicode(str.c_str(), str.Len()); | |
1308 | #else | |
1309 | return PyString_FromStringAndSize(str.c_str(), str.Len()); | |
1310 | #endif | |
1311 | } else | |
1312 | RETURN_NONE(); | |
1313 | } | |
1314 | } | |
1315 | ||
1316 | ||
1317 | // Get all commands defined for this file type | |
1318 | %addmethods { | |
1319 | PyObject* GetAllCommands(const wxString& filename, | |
1320 | const wxString& mimetype=wxPyEmptyString) { | |
1321 | wxArrayString verbs; | |
1322 | wxArrayString commands; | |
1323 | if (self->GetAllCommands(&verbs, &commands, | |
1324 | wxFileType::MessageParameters(filename, mimetype))) { | |
1325 | wxPyBeginBlockThreads(); | |
1326 | PyObject* tuple = PyTuple_New(2); | |
1327 | PyTuple_SetItem(tuple, 0, wxArrayString2PyList_helper(verbs)); | |
1328 | PyTuple_SetItem(tuple, 1, wxArrayString2PyList_helper(commands)); | |
1329 | wxPyEndBlockThreads(); | |
1330 | return tuple; | |
1331 | } | |
1332 | else | |
1333 | RETURN_NONE(); | |
1334 | } | |
1335 | } | |
1336 | ||
1337 | ||
1338 | // set an arbitrary command, ask confirmation if it already exists and | |
1339 | // overwriteprompt is TRUE | |
1340 | bool SetCommand(const wxString& cmd, const wxString& verb, | |
1341 | bool overwriteprompt = TRUE); | |
1342 | ||
1343 | bool SetDefaultIcon(const wxString& cmd = wxPyEmptyString, int index = 0); | |
1344 | ||
1345 | ||
1346 | // remove the association for this filetype from the system MIME database: | |
1347 | // notice that it will only work if the association is defined in the user | |
1348 | // file/registry part, we will never modify the system-wide settings | |
1349 | bool Unassociate(); | |
1350 | ||
1351 | // operations | |
1352 | // expand a string in the format of GetOpenCommand (which may contain | |
1353 | // '%s' and '%t' format specificators for the file name and mime type | |
1354 | // and %{param} constructions). | |
1355 | static wxString ExpandCommand(const wxString& command, | |
1356 | const MessageParameters& params); | |
1357 | ||
1358 | // dtor (not virtual, shouldn't be derived from) | |
1359 | ~wxFileType(); | |
1360 | ||
1361 | }; | |
1362 | ||
1363 | ||
1364 | ||
1365 | ||
1366 | class wxMimeTypesManager | |
1367 | { | |
1368 | public: | |
1369 | // static helper functions | |
1370 | // ----------------------- | |
1371 | ||
1372 | // check if the given MIME type is the same as the other one: the | |
1373 | // second argument may contain wildcards ('*'), but not the first. If | |
1374 | // the types are equal or if the mimeType matches wildcard the function | |
1375 | // returns TRUE, otherwise it returns FALSE | |
1376 | static bool IsOfType(const wxString& mimeType, const wxString& wildcard); | |
1377 | ||
1378 | // ctor | |
1379 | wxMimeTypesManager(); | |
1380 | ||
1381 | // loads data from standard files according to the mailcap styles | |
1382 | // specified: this is a bitwise OR of wxMailcapStyle values | |
1383 | // | |
1384 | // use the extraDir parameter if you want to look for files in another | |
1385 | // directory | |
1386 | void Initialize(int mailcapStyle = wxMAILCAP_STANDARD, | |
1387 | const wxString& extraDir = wxPyEmptyString); | |
1388 | ||
1389 | // and this function clears all the data from the manager | |
1390 | void ClearData(); | |
1391 | ||
1392 | // Database lookup: all functions return a pointer to wxFileType object | |
1393 | // whose methods may be used to query it for the information you're | |
1394 | // interested in. If the return value is !NULL, caller is responsible for | |
1395 | // deleting it. | |
1396 | // get file type from file extension | |
1397 | %new wxFileType *GetFileTypeFromExtension(const wxString& ext); | |
1398 | ||
1399 | // get file type from MIME type (in format <category>/<format>) | |
1400 | %new wxFileType *GetFileTypeFromMimeType(const wxString& mimeType); | |
1401 | ||
1402 | // other operations: return TRUE if there were no errors or FALSE if there | |
1403 | // were some unreckognized entries (the good entries are always read anyhow) | |
1404 | // | |
1405 | ||
1406 | // read in additional file (the standard ones are read automatically) | |
1407 | // in mailcap format (see mimetype.cpp for description) | |
1408 | // | |
1409 | // 'fallback' parameter may be set to TRUE to avoid overriding the | |
1410 | // settings from other, previously parsed, files by this one: normally, | |
1411 | // the files read most recently would override the older files, but with | |
1412 | // fallback == TRUE this won't happen | |
1413 | bool ReadMailcap(const wxString& filename, bool fallback = FALSE); | |
1414 | ||
1415 | // read in additional file in mime.types format | |
1416 | bool ReadMimeTypes(const wxString& filename); | |
1417 | ||
1418 | // enumerate all known MIME types | |
1419 | %addmethods { | |
1420 | PyObject* EnumAllFileTypes() { | |
1421 | wxArrayString arr; | |
1422 | self->EnumAllFileTypes(arr); | |
1423 | return wxArrayString2PyList_helper(arr); | |
1424 | } | |
1425 | } | |
1426 | ||
1427 | // these functions can be used to provide default values for some of the | |
1428 | // MIME types inside the program itself (you may also use | |
1429 | // ReadMailcap(filenameWithDefaultTypes, TRUE /* use as fallback */) to | |
1430 | // achieve the same goal, but this requires having this info in a file). | |
1431 | // | |
1432 | void AddFallback(const wxFileTypeInfo& ft); | |
1433 | ||
1434 | ||
1435 | // create or remove associations | |
1436 | ||
1437 | // create a new association using the fields of wxFileTypeInfo (at least | |
1438 | // the MIME type and the extension should be set) | |
1439 | // if the other fields are empty, the existing values should be left alone | |
1440 | %new wxFileType *Associate(const wxFileTypeInfo& ftInfo); | |
1441 | ||
1442 | // undo Associate() | |
1443 | bool Unassociate(wxFileType *ft) ; | |
1444 | ||
1445 | // dtor (not virtual, shouldn't be derived from) | |
1446 | ~wxMimeTypesManager(); | |
1447 | }; | |
1448 | ||
1449 | ||
1450 | %readonly | |
1451 | %{ | |
1452 | #if 0 | |
1453 | %} | |
1454 | extern wxMimeTypesManager* wxTheMimeTypesManager; | |
1455 | %{ | |
1456 | #endif | |
1457 | %} | |
1458 | %readwrite | |
1459 | ||
1460 | //---------------------------------------------------------------------- | |
1461 | ||
1462 | %{ | |
1463 | #include <wx/artprov.h> | |
1464 | ||
1465 | DECLARE_DEF_STRING(ART_OTHER); | |
1466 | ||
1467 | %} | |
1468 | ||
1469 | %pragma(python) code = " | |
1470 | # Art clients | |
1471 | wxART_TOOLBAR = 'wxART_TOOLBAR_C' | |
1472 | wxART_MENU = 'wxART_MENU_C' | |
1473 | wxART_FRAME_ICON = 'wxART_FRAME_ICON_C' | |
1474 | wxART_CMN_DIALOG = 'wxART_CMN_DIALOG_C' | |
1475 | wxART_HELP_BROWSER = 'wxART_HELP_BROWSER_C' | |
1476 | wxART_MESSAGE_BOX = 'wxART_MESSAGE_BOX_C' | |
1477 | wxART_OTHER = 'wxART_OTHER_C' | |
1478 | ||
1479 | # Art IDs | |
1480 | wxART_ADD_BOOKMARK = 'wxART_ADD_BOOKMARK' | |
1481 | wxART_DEL_BOOKMARK = 'wxART_DEL_BOOKMARK' | |
1482 | wxART_HELP_SIDE_PANEL = 'wxART_HELP_SIDE_PANEL' | |
1483 | wxART_HELP_SETTINGS = 'wxART_HELP_SETTINGS' | |
1484 | wxART_HELP_BOOK = 'wxART_HELP_BOOK' | |
1485 | wxART_HELP_FOLDER = 'wxART_HELP_FOLDER' | |
1486 | wxART_HELP_PAGE = 'wxART_HELP_PAGE' | |
1487 | wxART_GO_BACK = 'wxART_GO_BACK' | |
1488 | wxART_GO_FORWARD = 'wxART_GO_FORWARD' | |
1489 | wxART_GO_UP = 'wxART_GO_UP' | |
1490 | wxART_GO_DOWN = 'wxART_GO_DOWN' | |
1491 | wxART_GO_TO_PARENT = 'wxART_GO_TO_PARENT' | |
1492 | wxART_GO_HOME = 'wxART_GO_HOME' | |
1493 | wxART_FILE_OPEN = 'wxART_FILE_OPEN' | |
1494 | wxART_PRINT = 'wxART_PRINT' | |
1495 | wxART_HELP = 'wxART_HELP' | |
1496 | wxART_TIP = 'wxART_TIP' | |
1497 | wxART_REPORT_VIEW = 'wxART_REPORT_VIEW' | |
1498 | wxART_LIST_VIEW = 'wxART_LIST_VIEW' | |
1499 | wxART_NEW_DIR = 'wxART_NEW_DIR' | |
1500 | wxART_FOLDER = 'wxART_FOLDER' | |
1501 | wxART_GO_DIR_UP = 'wxART_GO_DIR_UP' | |
1502 | wxART_EXECUTABLE_FILE = 'wxART_EXECUTABLE_FILE' | |
1503 | wxART_NORMAL_FILE = 'wxART_NORMAL_FILE' | |
1504 | wxART_TICK_MARK = 'wxART_TICK_MARK' | |
1505 | wxART_CROSS_MARK = 'wxART_CROSS_MARK' | |
1506 | wxART_ERROR = 'wxART_ERROR' | |
1507 | wxART_QUESTION = 'wxART_QUESTION' | |
1508 | wxART_WARNING = 'wxART_WARNING' | |
1509 | wxART_INFORMATION = 'wxART_INFORMATION' | |
1510 | " | |
1511 | ||
1512 | %{ // Python aware wxArtProvider | |
1513 | class wxPyArtProvider : public wxArtProvider { | |
1514 | public: | |
1515 | ||
1516 | virtual wxBitmap CreateBitmap(const wxArtID& id, | |
1517 | const wxArtClient& client, | |
1518 | const wxSize& size) { | |
1519 | wxBitmap rval = wxNullBitmap; | |
1520 | wxPyBeginBlockThreads(); | |
1521 | if ((wxPyCBH_findCallback(m_myInst, "CreateBitmap"))) { | |
1522 | PyObject* so = wxPyConstructObject((void*)&size, "wxSize", 0); | |
1523 | PyObject* ro; | |
1524 | wxBitmap* ptr; | |
1525 | PyObject* s1, *s2; | |
1526 | s1 = wx2PyString(id); | |
1527 | s2 = wx2PyString(client); | |
1528 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOO)", s1, s2, so)); | |
1529 | Py_DECREF(so); | |
1530 | Py_DECREF(s1); | |
1531 | Py_DECREF(s2); | |
1532 | if (ro) { | |
1533 | if (!SWIG_GetPtrObj(ro, (void**)&ptr, "_wxBitmap_p")) | |
1534 | rval = *ptr; | |
1535 | Py_DECREF(ro); | |
1536 | } | |
1537 | } | |
1538 | wxPyEndBlockThreads(); | |
1539 | return rval; | |
1540 | } | |
1541 | ||
1542 | PYPRIVATE; | |
1543 | }; | |
1544 | %} | |
1545 | ||
1546 | // The one for SWIG to see | |
1547 | %name(wxArtProvider) class wxPyArtProvider : public wxObject | |
1548 | { | |
1549 | public: | |
1550 | wxPyArtProvider(); | |
1551 | ||
1552 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
1553 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxArtProvider)" | |
1554 | ||
1555 | // Add new provider to the top of providers stack. | |
1556 | static void PushProvider(wxPyArtProvider *provider); | |
1557 | ||
1558 | // Remove latest added provider and delete it. | |
1559 | static bool PopProvider(); | |
1560 | ||
1561 | // Remove provider. The provider must have been added previously! | |
1562 | // The provider is _not_ deleted. | |
1563 | static bool RemoveProvider(wxPyArtProvider *provider); | |
1564 | ||
1565 | // Query the providers for bitmap with given ID and return it. Return | |
1566 | // wxNullBitmap if no provider provides it. | |
1567 | static wxBitmap GetBitmap(const wxString& id, | |
1568 | const wxString& client = wxPyART_OTHER, | |
1569 | const wxSize& size = wxDefaultSize); | |
1570 | ||
1571 | // Query the providers for icon with given ID and return it. Return | |
1572 | // wxNullIcon if no provider provides it. | |
1573 | static wxIcon GetIcon(const wxString& id, | |
1574 | const wxString& client = wxPyART_OTHER, | |
1575 | const wxSize& size = wxDefaultSize); | |
1576 | ||
1577 | // Destroy caches & all providers | |
1578 | static void CleanUpProviders(); | |
1579 | }; | |
1580 | ||
1581 | ||
1582 | //---------------------------------------------------------------------- | |
1583 | ||
1584 | %{ | |
1585 | #include <wx/docview.h> | |
1586 | %} | |
1587 | ||
1588 | class wxFileHistory : public wxObject | |
1589 | { | |
1590 | public: | |
1591 | wxFileHistory(int maxFiles = 9); | |
1592 | ~wxFileHistory(); | |
1593 | ||
1594 | // Operations | |
1595 | void AddFileToHistory(const wxString& file); | |
1596 | void RemoveFileFromHistory(int i); | |
1597 | int GetMaxFiles() const; | |
1598 | void UseMenu(wxMenu *menu); | |
1599 | ||
1600 | // Remove menu from the list (MDI child may be closing) | |
1601 | void RemoveMenu(wxMenu *menu); | |
1602 | ||
1603 | void Load(wxConfigBase& config); | |
1604 | void Save(wxConfigBase& config); | |
1605 | ||
1606 | void AddFilesToMenu(); | |
1607 | %name(AddFilesToThisMenu)void AddFilesToMenu(wxMenu* menu); | |
1608 | ||
1609 | // Accessors | |
1610 | wxString GetHistoryFile(int i) const; | |
1611 | ||
1612 | // A synonym for GetNoHistoryFiles | |
1613 | int GetCount() const; | |
1614 | int GetNoHistoryFiles() const; | |
1615 | ||
1616 | }; | |
1617 | ||
1618 | //---------------------------------------------------------------------- | |
1619 | //---------------------------------------------------------------------- | |
1620 | ||
1621 | // %{ | |
1622 | // #if wxUSE_UNICODE | |
1623 | // #define ADD_STRING(dict, str) \ | |
1624 | // wxString tmp##str(str); \ | |
1625 | // PyDict_SetItemString(dict, #str, \ | |
1626 | // PyUnicode_FromUnicode(tmp##str.c_str(), tmp##str.Len())) | |
1627 | // #else | |
1628 | // #define ADD_STRING(dict, str) \ | |
1629 | // PyDict_SetItemString(d, #str, PyString_FromString(str)) | |
1630 | // #endif | |
1631 | // %} | |
1632 | ||
1633 | ||
1634 | %init %{ | |
1635 | wxPyPtrTypeMap_Add("wxDragImage", "wxGenericDragImage"); | |
1636 | wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess"); | |
1637 | wxPyPtrTypeMap_Add("wxArtProvider", "wxPyArtProvider"); | |
1638 | ||
1639 | %} | |
1640 | ||
1641 | //---------------------------------------------------------------------- | |
1642 |