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
This commit is contained in:
Robin Dunn
2004-05-07 21:35:35 +00:00
parent d68a6b6dbb
commit e0f0eaba3d

View File

@@ -43,7 +43,7 @@ public:
"wxSound is not available on this platform."); "wxSound is not available on this platform.");
wxPyEndBlockThreads(blocked); wxPyEndBlockThreads(blocked);
} }
wxSound(const wxString&, bool) { wxSound(const wxString&/*, bool*/) {
bool blocked = wxPyBeginBlockThreads(); bool blocked = wxPyBeginBlockThreads();
PyErr_SetString(PyExc_NotImplementedError, PyErr_SetString(PyExc_NotImplementedError,
"wxSound is not available on this platform."); "wxSound is not available on this platform.");
@@ -58,7 +58,7 @@ public:
~wxSound() {}; ~wxSound() {};
bool Create(const wxString&, bool) { return false; } bool Create(const wxString&/*, bool*/) { return false; }
bool Create(int, const wxByte*) { return false; }; bool Create(int, const wxByte*) { return false; };
bool IsOk() { return false; }; bool IsOk() { return false; };
bool Play(unsigned) const { return false; } bool Play(unsigned) const { return false; }
@@ -74,32 +74,39 @@ public:
class wxSound /*: public wxObject*/ class wxSound /*: public wxObject*/
{ {
public: public:
%nokwargs wxSound; %extend {
wxSound(); wxSound(const wxString& fileName = wxPyEmptyString /*, bool isResource = false*/) {
wxSound(const wxString& fileName, bool isResource = false); if (fileName.Length() == 0)
wxSound(int size, const wxByte* data); return new wxSound;
else
return new wxSound(fileName);
}
%name(SoundFromData) wxSound(const wxMemoryBuffer& data) {
return new wxSound((int)data.GetDataLen(), (wxByte*)data.GetData());
}
}
~wxSound(); ~wxSound();
%nokwargs Create; %nokwargs Create;
%nokwargs Play; %nokwargs Play;
// Create from resource or file // 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 { %extend {
bool Create(int size, const wxByte* data) { bool CreateFromData(const wxMemoryBuffer& data) {
bool blocked = wxPyBeginBlockThreads(); %#ifndef __WXMAC__
PyErr_SetString(PyExc_NotImplementedError, return self->Create((int)data.GetDataLen(), (wxByte*)data.GetData());
"Create from data is not available on this platform."); %#else
wxPyEndBlockThreads(blocked); bool blocked = wxPyBeginBlockThreads();
return False; PyErr_SetString(PyExc_NotImplementedError,
"Create from data is not available on this platform.");
wxPyEndBlockThreads(blocked);
return False;
%#endif
} }
} }
#endif
bool IsOk(); bool IsOk();
@@ -107,7 +114,7 @@ public:
bool Play(unsigned flags = wxSOUND_ASYNC) const; bool Play(unsigned flags = wxSOUND_ASYNC) const;
// Plays sound from filename: // 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__ #ifndef __WXMAC__
static void Stop(); static void Stop();