]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/src/_sound.i
Change wxSound ctor wrappings so sound can be loaded from data
[wxWidgets.git] / wxPython / src / _sound.i
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: _sound.i
3// Purpose: SWIG interface stuff for wxSound
4//
5// Author: Robin Dunn
6//
7// Created: 18-June-1999
8// RCS-ID: $Id$
9// Copyright: (c) 2003 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13// Not a %module
14
15
16//---------------------------------------------------------------------------
17%newgroup
18
19%{
20#include <wx/sound.h>
21%}
22
23//---------------------------------------------------------------------------
24
25enum wxSoundFlags
26{
27 wxSOUND_SYNC = 0,
28 wxSOUND_ASYNC = 1,
29 wxSOUND_LOOP = 2
30};
31
32
33
34%{
35#if !wxUSE_SOUND
36// A C++ stub class for wxWave for platforms that don't have it.
37class wxSound : public wxObject
38{
39public:
40 wxSound() {
41 bool blocked = wxPyBeginBlockThreads();
42 PyErr_SetString(PyExc_NotImplementedError,
43 "wxSound is not available on this platform.");
44 wxPyEndBlockThreads(blocked);
45 }
46 wxSound(const wxString&/*, bool*/) {
47 bool blocked = wxPyBeginBlockThreads();
48 PyErr_SetString(PyExc_NotImplementedError,
49 "wxSound is not available on this platform.");
50 wxPyEndBlockThreads(blocked);
51 }
52 wxSound(int, const wxByte*) {
53 bool blocked = wxPyBeginBlockThreads();
54 PyErr_SetString(PyExc_NotImplementedError,
55 "wxSound is not available on this platform.");
56 wxPyEndBlockThreads(blocked);
57 }
58
59 ~wxSound() {};
60
61 bool Create(const wxString&/*, bool*/) { return false; }
62 bool Create(int, const wxByte*) { return false; };
63 bool IsOk() { return false; };
64 bool Play(unsigned) const { return false; }
65 static bool Play(const wxString&, unsigned) { return false; }
66 static void Stop() {}
67};
68
69#endif
70%}
71
72
73
74class wxSound /*: public wxObject*/
75{
76public:
77 %extend {
78 wxSound(const wxString& fileName = wxPyEmptyString /*, bool isResource = false*/) {
79 if (fileName.Length() == 0)
80 return new wxSound;
81 else
82 return new wxSound(fileName);
83 }
84 %name(SoundFromData) wxSound(const wxMemoryBuffer& data) {
85 return new wxSound((int)data.GetDataLen(), (wxByte*)data.GetData());
86 }
87 }
88
89 ~wxSound();
90
91 %nokwargs Create;
92 %nokwargs Play;
93
94 // Create from resource or file
95 bool Create(const wxString& fileName/*, bool isResource = false*/);
96
97 %extend {
98 bool CreateFromData(const wxMemoryBuffer& data) {
99 %#ifndef __WXMAC__
100 return self->Create((int)data.GetDataLen(), (wxByte*)data.GetData());
101 %#else
102 bool blocked = wxPyBeginBlockThreads();
103 PyErr_SetString(PyExc_NotImplementedError,
104 "Create from data is not available on this platform.");
105 wxPyEndBlockThreads(blocked);
106 return False;
107 %#endif
108 }
109 }
110
111 bool IsOk();
112
113 // Play the sound:
114 bool Play(unsigned flags = wxSOUND_ASYNC) const;
115
116 // Plays sound from filename:
117 %name(PlaySound) static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC);
118
119#ifndef __WXMAC__
120 static void Stop();
121#else
122 %extend {
123 static void Stop()
124 { wxPyRaiseNotImplemented(); }
125 }
126#endif
127
128 %pythoncode { def __nonzero__(self): return self.IsOk() }
129};
130
131
132
133
134//---------------------------------------------------------------------------