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