]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_sound.i
wxCheckListBox doesn't require wxUSE_OWNER_DRAWN when using WXUNIVERSAL
[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 wxWave for platforms that don't have it.
37 class wxSound : public wxObject
38 {
39 public:
40 wxSound() {
41 wxPyBlock_t 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 wxPyBlock_t 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 wxPyBlock_t 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
74 MustHaveApp(wxSound);
75 MustHaveApp(wxSound::Play);
76 MustHaveApp(wxSound::Stop);
77
78 class wxSound /*: public wxObject*/
79 {
80 public:
81 %extend {
82 wxSound(const wxString& fileName = wxPyEmptyString /*, bool isResource = false*/) {
83 if (fileName.Length() == 0)
84 return new wxSound;
85 else
86 return new wxSound(fileName);
87 }
88 %RenameCtor(SoundFromData, wxSound(PyObject* data))
89 {
90 unsigned char* buffer; int size;
91 wxSound *sound = NULL;
92
93 wxPyBlock_t blocked = wxPyBeginBlockThreads();
94 if (!PyArg_Parse(data, "t#", &buffer, &size))
95 goto done;
96 sound = new wxSound(size, buffer);
97 done:
98 wxPyEndBlockThreads(blocked);
99 return sound;
100 }
101 }
102
103 ~wxSound();
104
105
106 // Create from resource or file
107 bool Create(const wxString& fileName/*, bool isResource = false*/);
108
109 %extend {
110 bool CreateFromData(PyObject* data) {
111 %#ifndef __WXMAC__
112 unsigned char* buffer;
113 int size;
114 bool rv = false;
115
116 wxPyBlock_t blocked = wxPyBeginBlockThreads();
117 if (!PyArg_Parse(data, "t#", &buffer, &size))
118 goto done;
119 rv = self->Create(size, buffer);
120 done:
121 wxPyEndBlockThreads(blocked);
122 return rv;
123 %#else
124 wxPyBlock_t blocked = wxPyBeginBlockThreads();
125 PyErr_SetString(PyExc_NotImplementedError,
126 "Create from data is not available on this platform.");
127 wxPyEndBlockThreads(blocked);
128 return false;
129 %#endif
130 }
131 }
132
133 bool IsOk();
134
135 // Play the sound:
136 bool Play(unsigned flags = wxSOUND_ASYNC) const;
137
138 // Plays sound from filename:
139 %Rename(PlaySound, static bool, Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC));
140
141 static void Stop();
142
143 %pythoncode { def __nonzero__(self): return self.IsOk() }
144 };
145
146
147
148
149 //---------------------------------------------------------------------------