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