]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sound.h
Fixed to work with the new wxMacControl system.
[wxWidgets.git] / include / wx / sound.h
CommitLineData
e9e23cb5
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/sound.h
3// Purpose: wxSoundBase class
4// Author: Vaclav Slavik
5// Modified by:
6// Created: 2004/02/01
7// RCS-ID: $Id$
8// Copyright: (c) 2004, Vaclav Slavik
65571936 9// Licence: wxWindows licence
e9e23cb5
VS
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_SOUND_H_BASE_
13#define _WX_SOUND_H_BASE_
14
15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16#pragma interface "soundbase.h"
17#endif
18
cad1a197
VS
19#include "wx/defs.h"
20
21#if wxUSE_SOUND
22
e9e23cb5
VS
23#include "wx/object.h"
24
25// ----------------------------------------------------------------------------
26// wxSoundBase: common wxSound code and interface
27// ----------------------------------------------------------------------------
28
29// Flags for wxSound::Play
96303362
VS
30#if WXWIN_COMPATIBILITY_2_4 || defined(__BORLANDC__)
31 // NB: We can't use enum because there would be ambiguity between the
32 // two Play() prototypes when called without explicit parameters.
33 // We can't use enum with Borland's compiler either, because it's
34 // broken and keeps reporting nonexistent ambiguities between
35 // Play(unsigned) and static Play(const wxString&, unsigned).
cad1a197
VS
36 #define wxSOUND_SYNC ((unsigned)0)
37 #define wxSOUND_ASYNC ((unsigned)1)
38 #define wxSOUND_LOOP ((unsigned)2)
39#else
40 enum wxSoundFlags
41 {
42 wxSOUND_SYNC = 0,
43 wxSOUND_ASYNC = 1,
44 wxSOUND_LOOP = 2
45 };
46#endif
e9e23cb5 47
cad1a197 48// Base class for wxSound implementations
65cf3a4b 49class WXDLLIMPEXP_ADV wxSoundBase : public wxObject
e9e23cb5
VS
50{
51public:
52 // Play the sound:
cad1a197 53 bool Play(unsigned flags = wxSOUND_ASYNC) const
e9e23cb5 54 {
cad1a197
VS
55 wxASSERT_MSG( (flags & wxSOUND_LOOP) == 0 ||
56 (flags & wxSOUND_ASYNC) != 0,
57 _T("sound can only be looped asynchronously") );
e9e23cb5
VS
58 return DoPlay(flags);
59 }
60#if WXWIN_COMPATIBILITY_2_4
cad1a197 61 wxDEPRECATED( bool Play(bool async, bool looped = false) const );
e9e23cb5
VS
62#endif
63
cad1a197
VS
64 // Plays sound from filename:
65 static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC);
66
e9e23cb5 67protected:
cad1a197 68 virtual bool DoPlay(unsigned flags) const = 0;
e9e23cb5 69};
e9e23cb5
VS
70
71// ----------------------------------------------------------------------------
72// wxSound class implementation
73// ----------------------------------------------------------------------------
74
75#if defined(__WXMSW__)
cad1a197 76 #include "wx/msw/sound.h"
e9e23cb5 77#elif defined(__WXMAC__)
cad1a197 78 #include "wx/mac/sound.h"
e9e23cb5 79#elif defined(__WXPM__)
cad1a197 80 #include "wx/os2/sound.h"
00f6001f
VS
81#elif defined(__UNIX__)
82 #include "wx/unix/sound.h"
e9e23cb5
VS
83#endif
84
cad1a197
VS
85// ----------------------------------------------------------------------------
86// wxSoundBase methods
87// ----------------------------------------------------------------------------
88
89inline bool wxSoundBase::Play(const wxString& filename, unsigned flags)
90{
91 wxSound snd(filename);
92 return snd.IsOk() ? snd.Play(flags) : false;
93}
94
95#if WXWIN_COMPATIBILITY_2_4
96inline bool wxSoundBase::Play(bool async, bool looped) const
97{
98 unsigned flags = 0;
99 if (async) flags |= wxSOUND_ASYNC;
100 if (looped) flags |= wxSOUND_LOOP | wxSOUND_ASYNC;
101 return DoPlay(flags);
102}
e9e23cb5
VS
103#endif
104
cad1a197
VS
105#endif // wxUSE_SOUND
106
e9e23cb5 107#endif // _WX_SOUND_H_BASE_