]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_sound.i
wxSscanf() and friends are now Unicode+ANSI friendly wrappers instead of defines...
[wxWidgets.git] / wxPython / src / _sound.i
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
25 enum wxSoundFlags
26 {
27 wxSOUND_SYNC,
28 wxSOUND_ASYNC,
29 wxSOUND_LOOP
30 };
31
32
33
34 %{
35 #if !wxUSE_SOUND
36 // A C++ stub class for wxSound for platforms that don't have it.
37
38 enum wxSoundFlags
39 {
40 wxSOUND_SYNC,
41 wxSOUND_ASYNC,
42 wxSOUND_LOOP
43 };
44
45 class wxSound : public wxObject
46 {
47 public:
48 wxSound() {
49 wxPyBlock_t blocked = wxPyBeginBlockThreads();
50 PyErr_SetString(PyExc_NotImplementedError,
51 "wxSound is not available on this platform.");
52 wxPyEndBlockThreads(blocked);
53 }
54 wxSound(const wxString&/*, bool*/) {
55 wxPyBlock_t blocked = wxPyBeginBlockThreads();
56 PyErr_SetString(PyExc_NotImplementedError,
57 "wxSound is not available on this platform.");
58 wxPyEndBlockThreads(blocked);
59 }
60 wxSound(int, const wxByte*) {
61 wxPyBlock_t blocked = wxPyBeginBlockThreads();
62 PyErr_SetString(PyExc_NotImplementedError,
63 "wxSound is not available on this platform.");
64 wxPyEndBlockThreads(blocked);
65 }
66
67 ~wxSound() {};
68
69 bool Create(const wxString&/*, bool*/) { return false; }
70 bool Create(int, const wxByte*) { return false; };
71 bool IsOk() { return false; };
72 bool Play(unsigned) const { return false; }
73 static bool Play(const wxString&, unsigned) { return false; }
74 static void Stop() {}
75 };
76
77 #endif
78 %}
79
80
81
82 MustHaveApp(wxSound);
83 MustHaveApp(wxSound::Play);
84 MustHaveApp(wxSound::Stop);
85
86 class wxSound /*: public wxObject*/
87 {
88 public:
89 %extend {
90 wxSound(const wxString& fileName = wxPyEmptyString /*, bool isResource = false*/) {
91 if (fileName.Length() == 0)
92 return new wxSound;
93 else
94 return new wxSound(fileName);
95 }
96 %RenameCtor(SoundFromData, wxSound(PyObject* data))
97 {
98 unsigned char* buffer; int size;
99 wxSound *sound = NULL;
100
101 wxPyBlock_t blocked = wxPyBeginBlockThreads();
102 if (!PyArg_Parse(data, "t#", &buffer, &size))
103 goto done;
104 sound = new wxSound(size, buffer);
105 done:
106 wxPyEndBlockThreads(blocked);
107 return sound;
108 }
109 }
110
111 ~wxSound();
112
113
114 // Create from resource or file
115 bool Create(const wxString& fileName/*, bool isResource = false*/);
116
117 %extend {
118 bool CreateFromData(PyObject* data) {
119 %#ifndef __WXMAC__
120 unsigned char* buffer;
121 int size;
122 bool rv = false;
123
124 wxPyBlock_t blocked = wxPyBeginBlockThreads();
125 if (!PyArg_Parse(data, "t#", &buffer, &size))
126 goto done;
127 rv = self->Create(size, buffer);
128 done:
129 wxPyEndBlockThreads(blocked);
130 return rv;
131 %#else
132 wxPyBlock_t blocked = wxPyBeginBlockThreads();
133 PyErr_SetString(PyExc_NotImplementedError,
134 "Create from data is not available on this platform.");
135 wxPyEndBlockThreads(blocked);
136 return false;
137 %#endif
138 }
139 }
140
141 bool IsOk();
142
143 // Play the sound:
144 bool Play(unsigned flags = wxSOUND_ASYNC) const;
145
146 // Plays sound from filename:
147 %Rename(PlaySound, static bool, Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC));
148
149 static void Stop();
150
151 %pythoncode { def __nonzero__(self): return self.IsOk() }
152 };
153
154
155
156
157 //---------------------------------------------------------------------------