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