]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_sound.i
Include wx/filedlg.h when not WX_PRECOMP.
[wxWidgets.git] / wxPython / src / _sound.i
CommitLineData
78862f24
RD
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{
de3ac0f5
RD
27 wxSOUND_SYNC,
28 wxSOUND_ASYNC,
29 wxSOUND_LOOP
78862f24
RD
30};
31
32
33
34%{
35#if !wxUSE_SOUND
0b0849b5
RD
36// A C++ stub class for wxSound for platforms that don't have it.
37
38enum wxSoundFlags
39{
40 wxSOUND_SYNC,
41 wxSOUND_ASYNC,
42 wxSOUND_LOOP
43};
44
78862f24
RD
45class wxSound : public wxObject
46{
47public:
48 wxSound() {
6e6b3557 49 wxPyBlock_t blocked = wxPyBeginBlockThreads();
78862f24
RD
50 PyErr_SetString(PyExc_NotImplementedError,
51 "wxSound is not available on this platform.");
da32eb53 52 wxPyEndBlockThreads(blocked);
78862f24 53 }
e0f0eaba 54 wxSound(const wxString&/*, bool*/) {
6e6b3557 55 wxPyBlock_t blocked = wxPyBeginBlockThreads();
78862f24
RD
56 PyErr_SetString(PyExc_NotImplementedError,
57 "wxSound is not available on this platform.");
da32eb53 58 wxPyEndBlockThreads(blocked);
78862f24
RD
59 }
60 wxSound(int, const wxByte*) {
6e6b3557 61 wxPyBlock_t blocked = wxPyBeginBlockThreads();
78862f24
RD
62 PyErr_SetString(PyExc_NotImplementedError,
63 "wxSound is not available on this platform.");
da32eb53 64 wxPyEndBlockThreads(blocked);
78862f24
RD
65 }
66
67 ~wxSound() {};
68
e0f0eaba 69 bool Create(const wxString&/*, bool*/) { return false; }
78862f24
RD
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
ab1f7d2a
RD
82MustHaveApp(wxSound);
83MustHaveApp(wxSound::Play);
84MustHaveApp(wxSound::Stop);
85
78862f24
RD
86class wxSound /*: public wxObject*/
87{
88public:
e0f0eaba
RD
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 }
1b8c7ba6
RD
96 %RenameCtor(SoundFromData, wxSound(PyObject* data))
97 {
68cc4013
RD
98 unsigned char* buffer; int size;
99 wxSound *sound = NULL;
100
6e6b3557 101 wxPyBlock_t blocked = wxPyBeginBlockThreads();
68cc4013
RD
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;
e0f0eaba
RD
108 }
109 }
110
78862f24
RD
111 ~wxSound();
112
78862f24
RD
113
114 // Create from resource or file
e0f0eaba 115 bool Create(const wxString& fileName/*, bool isResource = false*/);
e8e4a2a4 116
e8e4a2a4 117 %extend {
68cc4013
RD
118 bool CreateFromData(PyObject* data) {
119 %#ifndef __WXMAC__
120 unsigned char* buffer;
121 int size;
a72f4631 122 bool rv = false;
68cc4013 123
6e6b3557 124 wxPyBlock_t blocked = wxPyBeginBlockThreads();
68cc4013
RD
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
6e6b3557 132 wxPyBlock_t blocked = wxPyBeginBlockThreads();
e0f0eaba
RD
133 PyErr_SetString(PyExc_NotImplementedError,
134 "Create from data is not available on this platform.");
135 wxPyEndBlockThreads(blocked);
a72f4631 136 return false;
68cc4013 137 %#endif
e8e4a2a4
RD
138 }
139 }
e8e4a2a4 140
78862f24
RD
141 bool IsOk();
142
143 // Play the sound:
144 bool Play(unsigned flags = wxSOUND_ASYNC) const;
145
146 // Plays sound from filename:
1b8c7ba6 147 %Rename(PlaySound, static bool, Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC));
78862f24
RD
148
149 static void Stop();
78862f24
RD
150
151 %pythoncode { def __nonzero__(self): return self.IsOk() }
152};
153
154
155
156
157//---------------------------------------------------------------------------