]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_sound.i
Removed calls to wx.InitAllImageHandlers.
[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{
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() {
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
74class wxSound /*: public wxObject*/
75{
76public:
e0f0eaba
RD
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 }
68cc4013
RD
84 %name(SoundFromData) wxSound(PyObject* data) {
85 unsigned char* buffer; int size;
86 wxSound *sound = NULL;
87
88 bool blocked = wxPyBeginBlockThreads();
89 if (!PyArg_Parse(data, "t#", &buffer, &size))
90 goto done;
91 sound = new wxSound(size, buffer);
92 done:
93 wxPyEndBlockThreads(blocked);
94 return sound;
e0f0eaba
RD
95 }
96 }
97
78862f24
RD
98 ~wxSound();
99
78862f24
RD
100
101 // Create from resource or file
e0f0eaba 102 bool Create(const wxString& fileName/*, bool isResource = false*/);
e8e4a2a4 103
e8e4a2a4 104 %extend {
68cc4013
RD
105 bool CreateFromData(PyObject* data) {
106 %#ifndef __WXMAC__
107 unsigned char* buffer;
108 int size;
109 bool rv = False;
110
111 bool blocked = wxPyBeginBlockThreads();
112 if (!PyArg_Parse(data, "t#", &buffer, &size))
113 goto done;
114 rv = self->Create(size, buffer);
115 done:
116 wxPyEndBlockThreads(blocked);
117 return rv;
118 %#else
e0f0eaba
RD
119 bool blocked = wxPyBeginBlockThreads();
120 PyErr_SetString(PyExc_NotImplementedError,
121 "Create from data is not available on this platform.");
122 wxPyEndBlockThreads(blocked);
123 return False;
68cc4013 124 %#endif
e8e4a2a4
RD
125 }
126 }
e8e4a2a4 127
78862f24
RD
128 bool IsOk();
129
130 // Play the sound:
131 bool Play(unsigned flags = wxSOUND_ASYNC) const;
132
133 // Plays sound from filename:
e0f0eaba 134 %name(PlaySound) static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC);
78862f24 135
e8e4a2a4 136#ifndef __WXMAC__
78862f24 137 static void Stop();
e8e4a2a4
RD
138#else
139 %extend {
bb5919e4
RD
140 static void Stop()
141 { wxPyRaiseNotImplemented(); }
e8e4a2a4
RD
142 }
143#endif
78862f24
RD
144
145 %pythoncode { def __nonzero__(self): return self.IsOk() }
146};
147
148
149
150
151//---------------------------------------------------------------------------