1 /////////////////////////////////////////////////////////////////////////////
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.)
9 // Created: 18-June-1999
11 // Copyright: (c) 1998 by Total Control Software
12 // Licence: wxWindows license
13 /////////////////////////////////////////////////////////////////////////////
19 #include "pyistream.h"
20 #include <wx/resource.h>
21 #include <wx/tooltip.h>
23 #include <wx/fontenum.h>
24 #include <wx/tipdlg.h>
25 #include <wx/process.h>
27 #if wxUSE_JOYSTICK || defined(__WXMSW__)
28 #include <wx/joystick.h>
31 #if wxUSE_WAVE || defined(__WXMSW__)
35 #include <wx/mimetype.h>
38 //----------------------------------------------------------------------
41 %include my_typemaps.i
43 // Import some definitions of other classes, etc.
53 //---------------------------------------------------------------------------
57 wxString wxFileSelector(const wxChar* message = wxFileSelectorPromptStr,
58 const wxChar* default_path = NULL,
59 const wxChar* default_filename = NULL,
60 const wxChar* default_extension = NULL,
61 const wxChar* wildcard = wxFileSelectorDefaultWildcardStr,
63 wxWindow *parent = NULL,
64 int x = -1, int y = -1);
66 wxString wxFileSelector(const char* message = wxFileSelectorPromptStr,
67 const char* default_path = NULL,
68 const char* default_filename = NULL,
69 const char* default_extension = NULL,
70 const char* wildcard = wxFileSelectorDefaultWildcardStr,
72 wxWindow *parent = NULL,
73 int x = -1, int y = -1);
76 wxString wxGetTextFromUser(const wxString& message,
77 const wxString& caption = wxEmptyString,
78 const wxString& default_value = wxEmptyString,
79 wxWindow *parent = NULL,
80 int x = -1, int y = -1,
83 wxString wxGetPasswordFromUser(const wxString& message,
84 const wxString& caption = wxEmptyString,
85 const wxString& default_value = wxEmptyString,
86 wxWindow *parent = NULL);
89 // TODO: Need to custom wrap this one...
90 // int wxGetMultipleChoice(char* message, char* caption,
91 // int LCOUNT, char** choices,
92 // int nsel, int *selection,
93 // wxWindow *parent = NULL, int x = -1, int y = -1,
94 // bool centre = TRUE, int width=150, int height=200);
97 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
98 int LCOUNT, wxString* choices,
99 wxWindow *parent = NULL,
100 int x = -1, int y = -1,
102 int width=150, int height=200);
104 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
105 int LCOUNT, wxString* choices,
106 wxWindow *parent = NULL,
107 int x = -1, int y = -1,
109 int width=150, int height=200);
112 int wxMessageBox(const wxString& message,
113 const wxString& caption = wxEmptyString,
114 int style = wxOK | wxCENTRE,
115 wxWindow *parent = NULL,
116 int x = -1, int y = -1);
118 long wxGetNumberFromUser(const wxString& message,
119 const wxString& prompt,
120 const wxString& caption,
122 long min = 0, long max = 100,
123 wxWindow *parent = NULL,
124 const wxPoint& pos = wxDefaultPosition);
126 //---------------------------------------------------------------------------
129 bool wxColourDisplay();
131 int wxDisplayDepth();
132 int wxGetDisplayDepth();
134 void wxDisplaySize(int* OUTPUT, int* OUTPUT);
135 wxSize wxGetDisplaySize();
137 void wxDisplaySizeMM(int* OUTPUT, int* OUTPUT);
138 wxSize wxGetDisplaySizeMM();
140 void wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT);
141 wxRect wxGetClientDisplayRect();
143 void wxSetCursor(wxCursor& cursor);
145 //----------------------------------------------------------------------
146 // Miscellaneous functions
148 wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL);
149 wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL);
151 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
152 wxWindow * wxGetActiveWindow();
154 wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
155 wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
158 bool wxCheckForInterrupt(wxWindow *wnd);
159 void wxFlushEvents();
162 //---------------------------------------------------------------------------
165 bool wxResourceAddIdentifier(char *name, int value);
166 void wxResourceClear(void);
167 wxBitmap wxResourceCreateBitmap(char *resource);
168 wxIcon wxResourceCreateIcon(char *resource);
169 wxMenuBar * wxResourceCreateMenuBar(char *resource);
170 int wxResourceGetIdentifier(char *name);
171 bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
172 bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
173 bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
175 //---------------------------------------------------------------------------
178 // possible values for wxSystemSettings::GetFont() parameter
182 wxSYS_OEM_FIXED_FONT = 10,
183 wxSYS_ANSI_FIXED_FONT,
186 wxSYS_DEVICE_DEFAULT_FONT,
187 wxSYS_DEFAULT_PALETTE,
188 wxSYS_SYSTEM_FIXED_FONT,
189 wxSYS_DEFAULT_GUI_FONT
192 // possible values for wxSystemSettings::GetColour() parameter
196 wxSYS_COLOUR_SCROLLBAR,
197 wxSYS_COLOUR_BACKGROUND,
198 wxSYS_COLOUR_DESKTOP = wxSYS_COLOUR_BACKGROUND,
199 wxSYS_COLOUR_ACTIVECAPTION,
200 wxSYS_COLOUR_INACTIVECAPTION,
203 wxSYS_COLOUR_WINDOWFRAME,
204 wxSYS_COLOUR_MENUTEXT,
205 wxSYS_COLOUR_WINDOWTEXT,
206 wxSYS_COLOUR_CAPTIONTEXT,
207 wxSYS_COLOUR_ACTIVEBORDER,
208 wxSYS_COLOUR_INACTIVEBORDER,
209 wxSYS_COLOUR_APPWORKSPACE,
210 wxSYS_COLOUR_HIGHLIGHT,
211 wxSYS_COLOUR_HIGHLIGHTTEXT,
212 wxSYS_COLOUR_BTNFACE,
213 wxSYS_COLOUR_3DFACE = wxSYS_COLOUR_BTNFACE,
214 wxSYS_COLOUR_BTNSHADOW,
215 wxSYS_COLOUR_3DSHADOW = wxSYS_COLOUR_BTNSHADOW,
216 wxSYS_COLOUR_GRAYTEXT,
217 wxSYS_COLOUR_BTNTEXT,
218 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
219 wxSYS_COLOUR_BTNHIGHLIGHT,
220 wxSYS_COLOUR_BTNHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
221 wxSYS_COLOUR_3DHIGHLIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
222 wxSYS_COLOUR_3DHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
223 wxSYS_COLOUR_3DDKSHADOW,
224 wxSYS_COLOUR_3DLIGHT,
225 wxSYS_COLOUR_INFOTEXT,
227 wxSYS_COLOUR_LISTBOX,
228 wxSYS_COLOUR_HOTLIGHT,
229 wxSYS_COLOUR_GRADIENTACTIVECAPTION,
230 wxSYS_COLOUR_GRADIENTINACTIVECAPTION,
231 wxSYS_COLOUR_MENUHILIGHT,
232 wxSYS_COLOUR_MENUBAR,
237 // possible values for wxSystemSettings::GetMetric() parameter
241 wxSYS_MOUSE_BUTTONS = 1,
252 wxSYS_HSCROLL_ARROW_X,
253 wxSYS_HSCROLL_ARROW_Y,
269 wxSYS_VSCROLL_ARROW_X,
270 wxSYS_VSCROLL_ARROW_Y,
274 wxSYS_NETWORK_PRESENT,
275 wxSYS_PENWINDOWS_PRESENT,
280 // possible values for wxSystemSettings::HasFeature() parameter
283 wxSYS_CAN_DRAW_FRAME_DECORATIONS = 1,
284 wxSYS_CAN_ICONIZE_FRAME
289 class wxSystemSettings {
291 // get a standard system colour
292 static wxColour GetColour(wxSystemColour index);
294 // get a standard system font
295 static wxFont GetFont(wxSystemFont index);
297 // get a system-dependent metric
298 static int GetMetric(wxSystemMetric index);
300 // return true if the port has certain feature
301 static bool HasFeature(wxSystemFeature index);
307 //---------------------------------------------------------------------------
310 class wxToolTip : public wxObject {
312 wxToolTip(const wxString &tip);
314 void SetTip(const wxString& tip);
316 // *** Not in the "public" interface void SetWindow(wxWindow *win);
317 wxWindow *GetWindow();
319 static void Enable(bool flag);
320 static void SetDelay(long milliseconds);
323 //----------------------------------------------------------------------
327 wxCaret(wxWindow* window, const wxSize& size);
332 %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT);
333 wxPoint GetPosition();
334 %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT);
336 wxWindow *GetWindow();
337 %name(MoveXY)void Move(int x, int y);
338 void Move(const wxPoint& pt);
339 %name(SetSizeWH) void SetSize(int width, int height);
340 void SetSize(const wxSize& size);
341 void Show(int show = TRUE);
346 int wxCaret_GetBlinkTime() {
347 return wxCaret::GetBlinkTime();
350 void wxCaret_SetBlinkTime(int milliseconds) {
351 wxCaret::SetBlinkTime(milliseconds);
355 //----------------------------------------------------------------------
358 class wxPyFontEnumerator : public wxFontEnumerator {
360 wxPyFontEnumerator() {}
361 ~wxPyFontEnumerator() {}
363 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
364 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
369 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
370 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
374 %name(wxFontEnumerator) class wxPyFontEnumerator {
376 wxPyFontEnumerator();
377 ~wxPyFontEnumerator();
378 void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref);
379 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxFontEnumerator, 0)"
381 bool EnumerateFacenames(
382 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
383 bool fixedWidthOnly = FALSE);
384 bool EnumerateEncodings(const char* facename = "");
386 //wxArrayString* GetEncodings();
387 //wxArrayString* GetFacenames();
389 PyObject* GetEncodings() {
390 wxArrayString* arr = self->GetEncodings();
391 return wxArrayString2PyList_helper(*arr);
394 PyObject* GetFacenames() {
395 wxArrayString* arr = self->GetFacenames();
396 return wxArrayString2PyList_helper(*arr);
401 //----------------------------------------------------------------------
405 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
409 //----------------------------------------------------------------------
411 class wxWindowDisabler {
413 wxWindowDisabler(wxWindow *winToSkip = NULL);
417 //----------------------------------------------------------------------
419 bool wxSafeYield(wxWindow* win=NULL);
420 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
425 void wxWakeUpMainThread();
428 void wxMutexGuiEnter();
429 void wxMutexGuiLeave();
432 class wxMutexGuiLocker {
440 bool wxThread_IsMain() {
441 #ifdef WXP_WITH_THREAD
442 return wxThread::IsMain();
449 //----------------------------------------------------------------------
455 // wxTipProvider(size_t currentTip); **** Abstract base class
458 virtual wxString GetTip() = 0;
459 size_t GetCurrentTip();
464 // The C++ version of wxPyTipProvider
466 class wxPyTipProvider : public wxTipProvider {
468 wxPyTipProvider(size_t currentTip)
469 : wxTipProvider(currentTip) {}
471 DEC_PYCALLBACK_STRING__pure(GetTip);
476 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
481 // Now let SWIG know about it
482 class wxPyTipProvider : public wxTipProvider {
484 wxPyTipProvider(size_t currentTip);
489 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
490 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
493 //----------------------------------------------------------------------
496 #include <wx/generic/dragimgg.h>
499 %name (wxDragImage) class wxGenericDragImage : public wxObject
503 wxGenericDragImage(const wxBitmap& image,
504 const wxCursor& cursor = wxNullCursor);
505 %name(wxDragIcon)wxGenericDragImage(const wxIcon& image,
506 const wxCursor& cursor = wxNullCursor);
507 %name(wxDragString)wxGenericDragImage(const wxString& str,
508 const wxCursor& cursor = wxNullCursor);
509 %name(wxDragTreeItem)wxGenericDragImage(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
510 %name(wxDragListItem)wxGenericDragImage(const wxListCtrl& listCtrl, long id);
512 ~wxGenericDragImage();
514 void SetBackingBitmap(wxBitmap* bitmap);
515 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
516 bool fullScreen = FALSE, wxRect* rect = NULL);
518 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
519 wxWindow* fullScreenRect);
522 bool Move(const wxPoint& pt);
526 wxRect GetImageRect(const wxPoint& pos) const;
527 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
528 bool eraseOld, bool drawNew);
532 //----------------------------------------------------------------------
534 class wxPyTimer : public wxObject {
536 wxPyTimer(PyObject* notify);
541 void SetOwner(wxEvtHandler *owner, int id = -1);
542 void Start(int milliseconds=-1, int oneShot=FALSE);
550 // ctor starts the stop watch
553 void Start(long t = 0);
557 // get elapsed time since the last Start() or Pause() in milliseconds
562 //----------------------------------------------------------------------
563 //----------------------------------------------------------------------
568 wxLOG_FatalError, // program can't continue, abort immediately
569 wxLOG_Error, // a serious error, user must be informed about it
570 wxLOG_Warning, // user is normally informed about it but may be ignored
571 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
572 wxLOG_Info, // informational message (a.k.a. 'Verbose')
573 wxLOG_Status, // informational: might go to the status line of GUI app
574 wxLOG_Debug, // never shown to the user, disabled in release mode
575 wxLOG_Trace, // trace messages are also only enabled in debug mode
576 wxLOG_Progress, // used for progress indicator (not yet)
577 wxLOG_User = 100 // user defined levels start here
586 static bool IsEnabled();
587 static bool EnableLogging(bool doIt = TRUE);
588 static void OnLog(wxLogLevel level, const wxString& szString, int t=0);
590 virtual void Flush();
591 bool HasPendingMessages() const;
593 static void FlushActive();
594 static wxLog *GetActiveTarget();
595 static wxLog *SetActiveTarget(wxLog *pLogger);
597 static void Suspend();
598 static void Resume();
600 void SetVerbose(bool bVerbose = TRUE);
602 static void DontCreateOnDemand();
603 static void SetTraceMask(wxTraceMask ulMask);
604 static void AddTraceMask(const wxString& str);
605 static void RemoveTraceMask(const wxString& str);
606 static void ClearTraceMasks();
608 static void SetTimestamp(const wxChar *ts);
609 static const wxChar *GetTimestamp();
611 bool GetVerbose() const { return m_bVerbose; }
613 static wxTraceMask GetTraceMask();
614 static bool IsAllowedTraceMask(const wxString& mask);
616 // static void TimeStamp(wxString *str);
618 wxString TimeStamp() {
620 wxLog::TimeStamp(&msg);
627 class wxLogStderr : public wxLog
630 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
634 class wxLogTextCtrl : public wxLog
637 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
641 class wxLogGui : public wxLog
647 class wxLogWindow : public wxLog
650 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
651 const wxString& szTitle, // the title of the frame
652 bool bShow = TRUE, // show window immediately?
653 bool bPassToOld = TRUE); // pass log messages to the old target?
655 void Show(bool bShow = TRUE);
656 wxFrame *GetFrame() const;
657 wxLog *GetOldLog() const;
658 bool IsPassingMessages() const;
659 void PassMessages(bool bDoPass);
671 class wxLogChain : public wxLog
674 wxLogChain(wxLog *logger);
675 void SetLog(wxLog *logger);
676 void PassMessages(bool bDoPass);
677 bool IsPassingMessages();
682 unsigned long wxSysErrorCode();
683 const wxString wxSysErrorMsg(unsigned long nErrCode = 0);
684 void wxLogFatalError(const wxString& szFormat);
685 void wxLogError(const wxString& szFormat);
686 void wxLogWarning(const wxString& szFormat);
687 void wxLogMessage(const wxString& szFormat);
688 void wxLogInfo(const wxString& szFormat);
689 void wxLogVerbose(const wxString& szFormat);
690 void wxLogStatus(const wxString& szFormat);
691 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const wxString& szFormat);
692 void wxLogSysError(const wxString& szFormat);
696 // A Log class that can be derived from in wxPython
697 class wxPyLog : public wxLog {
699 wxPyLog() : wxLog() {}
701 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t) {
703 wxPyBeginBlockThreads();
704 if ((found = wxPyCBH_findCallback(m_myInst, "DoLog")))
705 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(isi)", level, szString, t)); // TODO: unicode fix
706 wxPyEndBlockThreads();
708 wxLog::DoLog(level, szString, t);
711 virtual void DoLogString(const wxChar *szString, time_t t) {
713 wxPyBeginBlockThreads();
714 if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString")))
715 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(si)", szString, t)); // TODO: unicode fix
716 wxPyEndBlockThreads();
718 wxLog::DoLogString(szString, t);
725 // Now tell SWIG about it
726 class wxPyLog : public wxLog {
729 void _setCallbackInfo(PyObject* self, PyObject* _class);
730 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyLog)"
731 %addmethods { void Destroy() { delete self; } }
736 //----------------------------------------------------------------------
745 class wxProcessEvent : public wxEvent {
747 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
750 int m_pid, m_exitcode;
756 %{ // C++ version of wxProcess derived class
758 class wxPyProcess : public wxProcess {
760 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
761 : wxProcess(parent, id)
764 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
769 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
774 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
776 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
777 %addmethods { void Destroy() { delete self; } }
779 void _setCallbackInfo(PyObject* self, PyObject* _class);
780 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxProcess)"
782 void base_OnTerminate(int pid, int status);
788 wxInputStream *GetInputStream();
789 wxInputStream *GetErrorStream();
790 wxOutputStream *GetOutputStream();
797 long wxExecute(const wxString& command,
799 wxPyProcess *process = NULL);
801 //----------------------------------------------------------------------
804 #if !wxUSE_JOYSTICK && !defined(__WXMSW__)
805 // A C++ stub class for wxJoystick for platforms that don't have it.
806 class wxJoystick : public wxObject {
808 wxJoystick(int joystick = wxJOYSTICK1) {
809 wxPyBeginBlockThreads();
810 PyErr_SetString(PyExc_NotImplementedError, "wxJoystick is not available on this platform.");
811 wxPyEndBlockThreads();
813 wxPoint GetPosition() { return wxPoint(-1,-1); }
814 int GetZPosition() { return -1; }
815 int GetButtonState() { return -1; }
816 int GetPOVPosition() { return -1; }
817 int GetPOVCTSPosition() { return -1; }
818 int GetRudderPosition() { return -1; }
819 int GetUPosition() { return -1; }
820 int GetVPosition() { return -1; }
821 int GetMovementThreshold() { return -1; }
822 void SetMovementThreshold(int threshold) {}
824 bool IsOk(void) { return FALSE; }
825 int GetNumberJoysticks() { return -1; }
826 int GetManufacturerId() { return -1; }
827 int GetProductId() { return -1; }
828 wxString GetProductName() { return ""; }
829 int GetXMin() { return -1; }
830 int GetYMin() { return -1; }
831 int GetZMin() { return -1; }
832 int GetXMax() { return -1; }
833 int GetYMax() { return -1; }
834 int GetZMax() { return -1; }
835 int GetNumberButtons() { return -1; }
836 int GetNumberAxes() { return -1; }
837 int GetMaxButtons() { return -1; }
838 int GetMaxAxes() { return -1; }
839 int GetPollingMin() { return -1; }
840 int GetPollingMax() { return -1; }
841 int GetRudderMin() { return -1; }
842 int GetRudderMax() { return -1; }
843 int GetUMin() { return -1; }
844 int GetUMax() { return -1; }
845 int GetVMin() { return -1; }
846 int GetVMax() { return -1; }
848 bool HasRudder() { return FALSE; }
849 bool HasZ() { return FALSE; }
850 bool HasU() { return FALSE; }
851 bool HasV() { return FALSE; }
852 bool HasPOV() { return FALSE; }
853 bool HasPOV4Dir() { return FALSE; }
854 bool HasPOVCTS() { return FALSE; }
856 bool SetCapture(wxWindow* win, int pollingFreq = 0) { return FALSE; }
857 bool ReleaseCapture() { return FALSE; }
863 class wxJoystick : public wxObject {
865 wxJoystick(int joystick = wxJOYSTICK1);
868 wxPoint GetPosition();
870 int GetButtonState();
871 int GetPOVPosition();
872 int GetPOVCTSPosition();
873 int GetRudderPosition();
876 int GetMovementThreshold();
877 void SetMovementThreshold(int threshold) ;
880 int GetNumberJoysticks();
881 int GetManufacturerId();
883 wxString GetProductName();
890 int GetNumberButtons();
911 bool SetCapture(wxWindow* win, int pollingFreq = 0);
912 bool ReleaseCapture();
915 //----------------------------------------------------------------------
919 // A C++ stub class for wxWave for platforms that don't have it.
920 class wxWave : public wxObject
923 wxWave(const wxString& fileName, bool isResource = FALSE) {
924 wxPyBeginBlockThreads();
925 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
926 wxPyEndBlockThreads();
928 wxWave(int size, const wxByte* data) {
929 wxPyBeginBlockThreads();
930 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
931 wxPyEndBlockThreads();
936 bool IsOk() const { return FALSE; }
937 bool Play(bool async = TRUE, bool looped = FALSE) const { return FALSE; }
943 class wxWave : public wxObject
946 wxWave(const wxString& fileName, bool isResource = FALSE);
950 bool Play(bool async = TRUE, bool looped = FALSE) const;
953 %new wxWave* wxWaveData(const wxString& data);
954 %{ // Implementations of some alternate "constructors"
955 wxWave* wxWaveData(const wxString& data) {
956 return new wxWave(data.Len(), (wxByte*)data.c_str());
961 //----------------------------------------------------------------------
965 wxMAILCAP_STANDARD = 1,
966 wxMAILCAP_NETSCAPE = 2,
980 wxFileTypeInfo(const char *mimeType,
982 const char *printCmd,
986 // the array elements correspond to the parameters of the ctor above in
988 %name(wxFileTypeInfoSequence)wxFileTypeInfo(const wxArrayString& sArray);
990 // invalid item - use this to terminate the array passed to
991 // wxMimeTypesManager::AddFallbacks
992 %name(wxNullFileTypeInfo)wxFileTypeInfo();
995 // test if this object can be used
996 bool IsValid() const;
1000 void SetIcon(const wxString& iconFile, int iconIndex = 0);
1002 // set the short desc
1003 void SetShortDesc(const wxString& shortDesc);
1006 // get the MIME type
1007 const wxString& GetMimeType() const;
1008 // get the open command
1009 const wxString& GetOpenCommand() const;
1010 // get the print command
1011 const wxString& GetPrintCommand() const;
1012 // get the short description (only used under Win32 so far)
1013 const wxString& GetShortDesc() const;
1014 // get the long, user visible description
1015 const wxString& GetDescription() const;
1018 // get the array of all extensions
1019 //const wxArrayString& GetExtensions() const;
1021 PyObject* GetExtensions() {
1022 wxArrayString& arr = (wxArrayString&)self->GetExtensions();
1023 return wxArrayString2PyList_helper(arr);
1027 int GetExtensionsCount() const;
1029 // get the icon info
1030 const wxString& GetIconFile() const;
1031 int GetIconIndex() const;
1041 // TODO: Make a wxPyMessageParameters with virtual GetParamValue...
1043 // An object of this class must be passed to Get{Open|Print}Command. The
1044 // default implementation is trivial and doesn't know anything at all about
1045 // parameters, only filename and MIME type are used (so it's probably ok for
1046 // Windows where %{param} is not used anyhow)
1047 class MessageParameters
1051 MessageParameters(const wxString& filename=wxEmptyString,
1052 const wxString& mimetype=wxEmptyString);
1054 // accessors (called by GetOpenCommand)
1056 const wxString& GetFileName() const;
1058 const wxString& GetMimeType() const;;
1060 // override this function in derived class
1061 virtual wxString GetParamValue(const wxString& name) const;
1063 // virtual dtor as in any base class
1064 virtual ~MessageParameters();
1068 // ctor from static data
1069 wxFileType(const wxFileTypeInfo& ftInfo);
1071 // return the MIME type for this file type
1073 PyObject* GetMimeType() {
1075 if (self->GetMimeType(&str)) {
1077 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1079 return PyString_FromStringAndSize(str.c_str(), str.Len());
1085 PyObject* GetMimeTypes() {
1087 if (self->GetMimeTypes(arr))
1088 return wxArrayString2PyList_helper(arr);
1095 // Get all extensions associated with this file type
1097 PyObject* GetExtensions() {
1099 if (self->GetExtensions(arr))
1100 return wxArrayString2PyList_helper(arr);
1108 // Get the icon corresponding to this file type
1109 %new wxIcon* GetIcon() {
1111 if (self->GetIcon(&icon))
1112 return new wxIcon(icon);
1117 // Get the icon corresponding to this file type, the name of the file
1118 // where this icon resides, and its index in this file if applicable.
1119 PyObject* GetIconInfo() {
1123 if (self->GetIcon(&icon, &iconFile, &iconIndex)) {
1124 wxPyBeginBlockThreads();
1125 PyObject* tuple = PyTuple_New(3);
1126 PyTuple_SetItem(tuple, 0, wxPyConstructObject(new wxIcon(icon),
1129 PyTuple_SetItem(tuple, 1, PyUnicode_FromUnicode(iconFile.c_str(), iconFile.Len()));
1131 PyTuple_SetItem(tuple, 1, PyString_FromStringAndSize(iconFile.c_str(), iconFile.Len()));
1133 PyTuple_SetItem(tuple, 2, PyInt_FromLong(iconIndex));
1134 wxPyEndBlockThreads();
1143 // get a brief file type description ("*.txt" => "text document")
1144 PyObject* GetDescription() {
1146 if (self->GetDescription(&str)) {
1148 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1150 return PyString_FromStringAndSize(str.c_str(), str.Len());
1158 // get the command to open/execute the file of given type
1160 PyObject* GetOpenCommand(const wxString& filename,
1161 const wxString& mimetype=wxEmptyString) {
1163 if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1165 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1167 return PyString_FromStringAndSize(str.c_str(), str.Len());
1175 // get the command to print the file of given type
1177 PyObject* GetPrintCommand(const wxString& filename,
1178 const wxString& mimetype=wxEmptyString) {
1180 if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1182 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1184 return PyString_FromStringAndSize(str.c_str(), str.Len());
1192 // Get all commands defined for this file type
1194 PyObject* GetAllCommands(const wxString& filename,
1195 const wxString& mimetype=wxEmptyString) {
1196 wxArrayString verbs;
1197 wxArrayString commands;
1198 if (self->GetAllCommands(&verbs, &commands,
1199 wxFileType::MessageParameters(filename, mimetype))) {
1200 wxPyBeginBlockThreads();
1201 PyObject* tuple = PyTuple_New(2);
1202 PyTuple_SetItem(tuple, 0, wxArrayString2PyList_helper(verbs));
1203 PyTuple_SetItem(tuple, 1, wxArrayString2PyList_helper(commands));
1204 wxPyEndBlockThreads();
1213 // set an arbitrary command, ask confirmation if it already exists and
1214 // overwriteprompt is TRUE
1215 bool SetCommand(const wxString& cmd, const wxString& verb,
1216 bool overwriteprompt = TRUE);
1218 bool SetDefaultIcon(const wxString& cmd = wxEmptyString, int index = 0);
1221 // remove the association for this filetype from the system MIME database:
1222 // notice that it will only work if the association is defined in the user
1223 // file/registry part, we will never modify the system-wide settings
1227 // expand a string in the format of GetOpenCommand (which may contain
1228 // '%s' and '%t' format specificators for the file name and mime type
1229 // and %{param} constructions).
1230 static wxString ExpandCommand(const wxString& command,
1231 const MessageParameters& params);
1233 // dtor (not virtual, shouldn't be derived from)
1241 class wxMimeTypesManager
1244 // static helper functions
1245 // -----------------------
1247 // check if the given MIME type is the same as the other one: the
1248 // second argument may contain wildcards ('*'), but not the first. If
1249 // the types are equal or if the mimeType matches wildcard the function
1250 // returns TRUE, otherwise it returns FALSE
1251 static bool IsOfType(const wxString& mimeType, const wxString& wildcard);
1254 wxMimeTypesManager();
1256 // loads data from standard files according to the mailcap styles
1257 // specified: this is a bitwise OR of wxMailcapStyle values
1259 // use the extraDir parameter if you want to look for files in another
1261 void Initialize(int mailcapStyle = wxMAILCAP_STANDARD,
1262 const wxString& extraDir = wxEmptyString);
1264 // and this function clears all the data from the manager
1267 // Database lookup: all functions return a pointer to wxFileType object
1268 // whose methods may be used to query it for the information you're
1269 // interested in. If the return value is !NULL, caller is responsible for
1271 // get file type from file extension
1272 %new wxFileType *GetFileTypeFromExtension(const wxString& ext);
1274 // get file type from MIME type (in format <category>/<format>)
1275 %new wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
1277 // other operations: return TRUE if there were no errors or FALSE if there
1278 // were some unreckognized entries (the good entries are always read anyhow)
1281 // read in additional file (the standard ones are read automatically)
1282 // in mailcap format (see mimetype.cpp for description)
1284 // 'fallback' parameter may be set to TRUE to avoid overriding the
1285 // settings from other, previously parsed, files by this one: normally,
1286 // the files read most recently would override the older files, but with
1287 // fallback == TRUE this won't happen
1288 bool ReadMailcap(const wxString& filename, bool fallback = FALSE);
1290 // read in additional file in mime.types format
1291 bool ReadMimeTypes(const wxString& filename);
1293 // enumerate all known MIME types
1295 PyObject* EnumAllFileTypes() {
1297 self->EnumAllFileTypes(arr);
1298 return wxArrayString2PyList_helper(arr);
1302 // these functions can be used to provide default values for some of the
1303 // MIME types inside the program itself (you may also use
1304 // ReadMailcap(filenameWithDefaultTypes, TRUE /* use as fallback */) to
1305 // achieve the same goal, but this requires having this info in a file).
1307 void AddFallback(const wxFileTypeInfo& ft);
1310 // create or remove associations
1312 // create a new association using the fields of wxFileTypeInfo (at least
1313 // the MIME type and the extension should be set)
1314 // if the other fields are empty, the existing values should be left alone
1315 %new wxFileType *Associate(const wxFileTypeInfo& ftInfo);
1318 bool Unassociate(wxFileType *ft) ;
1320 // dtor (not virtual, shouldn't be derived from)
1321 ~wxMimeTypesManager();
1329 extern wxMimeTypesManager* wxTheMimeTypesManager;
1335 //----------------------------------------------------------------------
1338 #include <wx/docview.h>
1341 class wxFileHistory : public wxObject
1344 wxFileHistory(int maxFiles = 9);
1348 void AddFileToHistory(const wxString& file);
1349 void RemoveFileFromHistory(int i);
1350 int GetMaxFiles() const;
1351 void UseMenu(wxMenu *menu);
1353 // Remove menu from the list (MDI child may be closing)
1354 void RemoveMenu(wxMenu *menu);
1356 void Load(wxConfigBase& config);
1357 void Save(wxConfigBase& config);
1359 void AddFilesToMenu();
1360 %name(AddFilesToSingleMenu)void AddFilesToMenu(wxMenu* menu);
1363 wxString GetHistoryFile(int i) const;
1365 // A synonym for GetNoHistoryFiles
1366 int GetCount() const;
1367 int GetNoHistoryFiles() const;
1371 //----------------------------------------------------------------------
1372 //----------------------------------------------------------------------
1376 wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator");
1377 wxPyPtrTypeMap_Add("wxDragImage", "wxGenericDragImage");
1378 wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess");
1381 //----------------------------------------------------------------------