From: Robin Dunn Date: Fri, 7 May 2004 21:35:35 +0000 (+0000) Subject: Change wxSound ctor wrappings so sound can be loaded from data X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e0f0eaba3d19f3e2d7783373a9cfc677bb9e107a Change wxSound ctor wrappings so sound can be loaded from data git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27147 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/wxPython/src/_sound.i b/wxPython/src/_sound.i index e120cf52a8..8f9f560a5f 100644 --- a/wxPython/src/_sound.i +++ b/wxPython/src/_sound.i @@ -43,7 +43,7 @@ public: "wxSound is not available on this platform."); wxPyEndBlockThreads(blocked); } - wxSound(const wxString&, bool) { + wxSound(const wxString&/*, bool*/) { bool blocked = wxPyBeginBlockThreads(); PyErr_SetString(PyExc_NotImplementedError, "wxSound is not available on this platform."); @@ -58,7 +58,7 @@ public: ~wxSound() {}; - bool Create(const wxString&, bool) { return false; } + bool Create(const wxString&/*, bool*/) { return false; } bool Create(int, const wxByte*) { return false; }; bool IsOk() { return false; }; bool Play(unsigned) const { return false; } @@ -74,32 +74,39 @@ public: class wxSound /*: public wxObject*/ { public: - %nokwargs wxSound; - wxSound(); - wxSound(const wxString& fileName, bool isResource = false); - wxSound(int size, const wxByte* data); + %extend { + wxSound(const wxString& fileName = wxPyEmptyString /*, bool isResource = false*/) { + if (fileName.Length() == 0) + return new wxSound; + else + return new wxSound(fileName); + } + %name(SoundFromData) wxSound(const wxMemoryBuffer& data) { + return new wxSound((int)data.GetDataLen(), (wxByte*)data.GetData()); + } + } + ~wxSound(); %nokwargs Create; %nokwargs Play; // Create from resource or file - bool Create(const wxString& fileName, bool isResource = false); + bool Create(const wxString& fileName/*, bool isResource = false*/); -#ifndef __WXMAC__ - // Create from data - bool Create(int size, const wxByte* data); -#else %extend { - bool Create(int size, const wxByte* data) { - bool blocked = wxPyBeginBlockThreads(); - PyErr_SetString(PyExc_NotImplementedError, - "Create from data is not available on this platform."); - wxPyEndBlockThreads(blocked); - return False; + bool CreateFromData(const wxMemoryBuffer& data) { + %#ifndef __WXMAC__ + return self->Create((int)data.GetDataLen(), (wxByte*)data.GetData()); + %#else + bool blocked = wxPyBeginBlockThreads(); + PyErr_SetString(PyExc_NotImplementedError, + "Create from data is not available on this platform."); + wxPyEndBlockThreads(blocked); + return False; + %#endif } } -#endif bool IsOk(); @@ -107,7 +114,7 @@ public: bool Play(unsigned flags = wxSOUND_ASYNC) const; // Plays sound from filename: - %name(PlaySound)static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC); + %name(PlaySound) static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC); #ifndef __WXMAC__ static void Stop();