+
+ %pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()"
+};
+
+//----------------------------------------------------------------------
+
+%{
+#if !wxUSE_WAVE
+// A C++ stub class for wxWave for platforms that don't have it.
+class wxWave : public wxObject
+{
+public:
+ wxWave(const wxString& fileName, bool isResource = FALSE) {
+ wxPyBeginBlockThreads();
+ PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
+ wxPyEndBlockThreads();
+ }
+ wxWave(int size, const wxByte* data) {
+ wxPyBeginBlockThreads();
+ PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
+ wxPyEndBlockThreads();
+ }
+
+ ~wxWave() {}
+
+ bool IsOk() const { return FALSE; }
+ bool Play(bool async = TRUE, bool looped = FALSE) const { return FALSE; }
+};
+
+#endif
+%}
+
+class wxWave : public wxObject
+{
+public:
+ wxWave(const wxString& fileName, bool isResource = FALSE);
+ ~wxWave();
+
+ bool IsOk() const;
+ bool Play(bool async = TRUE, bool looped = FALSE) const;
+
+ %pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()"
+};
+
+%new wxWave* wxWaveData(const wxString& data);
+%{ // Implementations of some alternate "constructors"
+ wxWave* wxWaveData(const wxString& data) {
+ return new wxWave(data.Len(), (wxByte*)data.c_str());
+ }
+%}
+
+
+//----------------------------------------------------------------------
+
+enum wxMailcapStyle
+{
+ wxMAILCAP_STANDARD = 1,
+ wxMAILCAP_NETSCAPE = 2,
+ wxMAILCAP_KDE = 4,
+ wxMAILCAP_GNOME = 8,
+
+ wxMAILCAP_ALL = 15
+};
+
+
+
+class wxFileTypeInfo
+{
+public:
+ // ctors
+ // a normal item
+ wxFileTypeInfo(const wxString& mimeType,
+ const wxString& openCmd,
+ const wxString& printCmd,
+ const wxString& desc);
+
+
+ // the array elements correspond to the parameters of the ctor above in
+ // the same order
+ %name(wxFileTypeInfoSequence)wxFileTypeInfo(const wxArrayString& sArray);
+
+ // invalid item - use this to terminate the array passed to
+ // wxMimeTypesManager::AddFallbacks
+ %name(wxNullFileTypeInfo)wxFileTypeInfo();
+
+
+ // test if this object can be used
+ bool IsValid() const;
+
+ // setters
+ // set the icon info
+ void SetIcon(const wxString& iconFile, int iconIndex = 0);
+
+ // set the short desc
+ void SetShortDesc(const wxString& shortDesc);
+
+ // accessors
+ // get the MIME type
+ const wxString& GetMimeType() const;
+ // get the open command
+ const wxString& GetOpenCommand() const;
+ // get the print command
+ const wxString& GetPrintCommand() const;
+ // get the short description (only used under Win32 so far)
+ const wxString& GetShortDesc() const;
+ // get the long, user visible description
+ const wxString& GetDescription() const;
+
+
+ // get the array of all extensions
+ //const wxArrayString& GetExtensions() const;
+ %addmethods {
+ PyObject* GetExtensions() {
+ wxArrayString& arr = (wxArrayString&)self->GetExtensions();
+ return wxArrayString2PyList_helper(arr);
+ }
+ }
+
+ int GetExtensionsCount() const;
+
+ // get the icon info
+ const wxString& GetIconFile() const;
+ int GetIconIndex() const;
+};
+
+
+
+
+class wxFileType
+{
+public:
+
+ // TODO: Make a wxPyMessageParameters with virtual GetParamValue...
+
+ // An object of this class must be passed to Get{Open|Print}Command. The
+ // default implementation is trivial and doesn't know anything at all about
+ // parameters, only filename and MIME type are used (so it's probably ok for
+ // Windows where %{param} is not used anyhow)
+ class MessageParameters
+ {
+ public:
+ // ctors
+ MessageParameters(const wxString& filename=wxPyEmptyString,
+ const wxString& mimetype=wxPyEmptyString);
+
+ // accessors (called by GetOpenCommand)
+ // filename
+ const wxString& GetFileName() const;
+ // mime type
+ const wxString& GetMimeType() const;;
+
+ // override this function in derived class
+ virtual wxString GetParamValue(const wxString& name) const;
+
+ // virtual dtor as in any base class
+ virtual ~MessageParameters();
+ };
+
+
+ // ctor from static data
+ wxFileType(const wxFileTypeInfo& ftInfo);
+
+ // return the MIME type for this file type
+ %addmethods {
+ PyObject* GetMimeType() {
+ wxString str;
+ if (self->GetMimeType(&str)) {
+#if wxUSE_UNICODE
+ return PyUnicode_FromWideChar(str.c_str(), str.Len());
+#else
+ return PyString_FromStringAndSize(str.c_str(), str.Len());
+#endif
+ }
+ else
+ RETURN_NONE();
+ }
+ PyObject* GetMimeTypes() {
+ wxArrayString arr;
+ if (self->GetMimeTypes(arr))
+ return wxArrayString2PyList_helper(arr);
+ else
+ RETURN_NONE();
+ }
+ }
+
+
+ // Get all extensions associated with this file type
+ %addmethods {
+ PyObject* GetExtensions() {
+ wxArrayString arr;
+ if (self->GetExtensions(arr))
+ return wxArrayString2PyList_helper(arr);
+ else
+ RETURN_NONE();
+ }
+ }
+
+
+ %addmethods {
+ // Get the icon corresponding to this file type
+ %new wxIcon* GetIcon() {
+ wxIconLocation loc;
+ if (self->GetIcon(&loc))
+ return new wxIcon(loc);
+ else
+ return NULL;
+ }
+
+ // Get the icon corresponding to this file type, the name of the file
+ // where this icon resides, and its index in this file if applicable.
+ PyObject* GetIconInfo() {
+ wxIconLocation loc;
+ if (self->GetIcon(&loc)) {
+ wxString iconFile = loc.GetFileName();
+ int iconIndex = -1;
+#ifdef __WXMSW__
+ iconIndex = loc.GetIndex();
+#endif
+ // Make a tuple and put the values in it
+ wxPyBeginBlockThreads();
+ PyObject* tuple = PyTuple_New(3);
+ PyTuple_SetItem(tuple, 0,
+ wxPyConstructObject(new wxIcon(loc), wxT("wxIcon"), TRUE));
+#if wxUSE_UNICODE
+ PyTuple_SetItem(tuple, 1, PyUnicode_FromWideChar(iconFile.c_str(), iconFile.Len()));
+#else
+ PyTuple_SetItem(tuple, 1, PyString_FromStringAndSize(iconFile.c_str(), iconFile.Len()));
+#endif
+ PyTuple_SetItem(tuple, 2, PyInt_FromLong(iconIndex));
+ wxPyEndBlockThreads();
+ return tuple;
+ }
+ else
+ RETURN_NONE();
+ }
+ }
+
+ %addmethods {
+ // get a brief file type description ("*.txt" => "text document")
+ PyObject* GetDescription() {
+ wxString str;
+ if (self->GetDescription(&str)) {
+#if wxUSE_UNICODE
+ return PyUnicode_FromWideChar(str.c_str(), str.Len());
+#else
+ return PyString_FromStringAndSize(str.c_str(), str.Len());
+#endif
+ } else
+ RETURN_NONE();
+ }
+ }
+
+
+ // get the command to open/execute the file of given type
+ %addmethods {
+ PyObject* GetOpenCommand(const wxString& filename,
+ const wxString& mimetype=wxPyEmptyString) {
+ wxString str;
+ if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
+#if wxUSE_UNICODE
+ return PyUnicode_FromWideChar(str.c_str(), str.Len());
+#else
+ return PyString_FromStringAndSize(str.c_str(), str.Len());
+#endif
+ } else
+ RETURN_NONE();
+ }
+ }
+
+
+ // get the command to print the file of given type
+ %addmethods {
+ PyObject* GetPrintCommand(const wxString& filename,
+ const wxString& mimetype=wxPyEmptyString) {
+ wxString str;
+ if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
+#if wxUSE_UNICODE
+ return PyUnicode_FromWideChar(str.c_str(), str.Len());
+#else
+ return PyString_FromStringAndSize(str.c_str(), str.Len());
+#endif
+ } else
+ RETURN_NONE();
+ }
+ }
+
+
+ // Get all commands defined for this file type
+ %addmethods {
+ PyObject* GetAllCommands(const wxString& filename,
+ const wxString& mimetype=wxPyEmptyString) {
+ wxArrayString verbs;
+ wxArrayString commands;
+ if (self->GetAllCommands(&verbs, &commands,
+ wxFileType::MessageParameters(filename, mimetype))) {
+ wxPyBeginBlockThreads();
+ PyObject* tuple = PyTuple_New(2);
+ PyTuple_SetItem(tuple, 0, wxArrayString2PyList_helper(verbs));
+ PyTuple_SetItem(tuple, 1, wxArrayString2PyList_helper(commands));
+ wxPyEndBlockThreads();
+ return tuple;
+ }
+ else
+ RETURN_NONE();
+ }
+ }
+
+
+ // set an arbitrary command, ask confirmation if it already exists and
+ // overwriteprompt is TRUE
+ bool SetCommand(const wxString& cmd, const wxString& verb,
+ bool overwriteprompt = TRUE);
+
+ bool SetDefaultIcon(const wxString& cmd = wxPyEmptyString, int index = 0);
+
+
+ // remove the association for this filetype from the system MIME database:
+ // notice that it will only work if the association is defined in the user
+ // file/registry part, we will never modify the system-wide settings
+ bool Unassociate();
+
+ // operations
+ // expand a string in the format of GetOpenCommand (which may contain
+ // '%s' and '%t' format specificators for the file name and mime type
+ // and %{param} constructions).
+ static wxString ExpandCommand(const wxString& command,
+ const MessageParameters& params);
+
+ // dtor (not virtual, shouldn't be derived from)
+ ~wxFileType();
+