]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_sound.i
wxPageSetupDialog no longer derives from wxDialog
[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
36// A C++ stub class for wxWave for platforms that don't have it.
37class wxSound : public wxObject
38{
39public:
40 wxSound() {
da32eb53 41 bool blocked = wxPyBeginBlockThreads();
78862f24
RD
42 PyErr_SetString(PyExc_NotImplementedError,
43 "wxSound is not available on this platform.");
da32eb53 44 wxPyEndBlockThreads(blocked);
78862f24 45 }
e0f0eaba 46 wxSound(const wxString&/*, bool*/) {
da32eb53 47 bool blocked = wxPyBeginBlockThreads();
78862f24
RD
48 PyErr_SetString(PyExc_NotImplementedError,
49 "wxSound is not available on this platform.");
da32eb53 50 wxPyEndBlockThreads(blocked);
78862f24
RD
51 }
52 wxSound(int, const wxByte*) {
da32eb53 53 bool blocked = wxPyBeginBlockThreads();
78862f24
RD
54 PyErr_SetString(PyExc_NotImplementedError,
55 "wxSound is not available on this platform.");
da32eb53 56 wxPyEndBlockThreads(blocked);
78862f24
RD
57 }
58
59 ~wxSound() {};
60
e0f0eaba 61 bool Create(const wxString&/*, bool*/) { return false; }
78862f24
RD
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
ab1f7d2a
RD
74MustHaveApp(wxSound);
75MustHaveApp(wxSound::Play);
76MustHaveApp(wxSound::Stop);
77
78862f24
RD
78class wxSound /*: public wxObject*/
79{
80public:
e0f0eaba
RD
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 }
68cc4013
RD
88 %name(SoundFromData) wxSound(PyObject* data) {
89 unsigned char* buffer; int size;
90 wxSound *sound = NULL;
91
92 bool blocked = wxPyBeginBlockThreads();
93 if (!PyArg_Parse(data, "t#", &buffer, &size))
94 goto done;
95 sound = new wxSound(size, buffer);
96 done:
97 wxPyEndBlockThreads(blocked);
98 return sound;
e0f0eaba
RD
99 }
100 }
101
78862f24
RD
102 ~wxSound();
103
78862f24
RD
104
105 // Create from resource or file
e0f0eaba 106 bool Create(const wxString& fileName/*, bool isResource = false*/);
e8e4a2a4 107
e8e4a2a4 108 %extend {
68cc4013
RD
109 bool CreateFromData(PyObject* data) {
110 %#ifndef __WXMAC__
111 unsigned char* buffer;
112 int size;
a72f4631 113 bool rv = false;
68cc4013
RD
114
115 bool blocked = wxPyBeginBlockThreads();
116 if (!PyArg_Parse(data, "t#", &buffer, &size))
117 goto done;
118 rv = self->Create(size, buffer);
119 done:
120 wxPyEndBlockThreads(blocked);
121 return rv;
122 %#else
e0f0eaba
RD
123 bool blocked = wxPyBeginBlockThreads();
124 PyErr_SetString(PyExc_NotImplementedError,
125 "Create from data is not available on this platform.");
126 wxPyEndBlockThreads(blocked);
a72f4631 127 return false;
68cc4013 128 %#endif
e8e4a2a4
RD
129 }
130 }
e8e4a2a4 131
78862f24
RD
132 bool IsOk();
133
134 // Play the sound:
135 bool Play(unsigned flags = wxSOUND_ASYNC) const;
136
137 // Plays sound from filename:
e0f0eaba 138 %name(PlaySound) static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC);
78862f24 139
e8e4a2a4 140#ifndef __WXMAC__
78862f24 141 static void Stop();
e8e4a2a4
RD
142#else
143 %extend {
bb5919e4
RD
144 static void Stop()
145 { wxPyRaiseNotImplemented(); }
e8e4a2a4
RD
146 }
147#endif
78862f24
RD
148
149 %pythoncode { def __nonzero__(self): return self.IsOk() }
150};
151
152
153
154
155//---------------------------------------------------------------------------