+
+//----------------------------------------------------------------------
+
+%{
+#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;
+};
+
+%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 char* mimeType,
+ const char* openCmd,
+ const char* printCmd,
+ const char* 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_FromUnicode(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() {
+ wxIcon icon;
+ if (self->GetIcon(&icon))
+ return new wxIcon(icon);
+ 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() {
+ wxIcon icon;
+ wxString iconFile;
+ int iconIndex;
+ if (self->GetIcon(&icon, &iconFile, &iconIndex)) {
+ wxPyBeginBlockThreads();
+ PyObject* tuple = PyTuple_New(3);
+ PyTuple_SetItem(tuple, 0, wxPyConstructObject(new wxIcon(icon),
+ "wxIcon", TRUE));
+#if wxUSE_UNICODE
+ PyTuple_SetItem(tuple, 1, PyUnicode_FromUnicode(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_FromUnicode(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_FromUnicode(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_FromUnicode(str.c_str(), str.Len());
+#else
+ return PyString_FromStringAndSize(str.c_str(), str.Len());