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