]> git.saurik.com Git - wxWidgets.git/blob - include/wx/sound.h
build fix
[wxWidgets.git] / include / wx / sound.h
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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_SOUND_H_BASE_
13 #define _WX_SOUND_H_BASE_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_SOUND
18
19 #include "wx/object.h"
20
21 // ----------------------------------------------------------------------------
22 // wxSoundBase: common wxSound code and interface
23 // ----------------------------------------------------------------------------
24
25 // Flags for wxSound::Play
26
27 // NB: We can't use enum because there would be ambiguity between the
28 // two Play() prototypes when called without explicit parameters
29 // if WXWIN_COMPATIBILITY_2_4.
30 // We can't use enum with some compilers either, because they
31 // keep reporting nonexistent ambiguities between
32 // Play(unsigned) and static Play(const wxString&, unsigned).
33 #define wxSOUND_SYNC ((unsigned)0)
34 #define wxSOUND_ASYNC ((unsigned)1)
35 #define wxSOUND_LOOP ((unsigned)2)
36
37 // Base class for wxSound implementations
38 class WXDLLIMPEXP_ADV wxSoundBase : public wxObject
39 {
40 public:
41 // Play the sound:
42 bool Play(unsigned flags = wxSOUND_ASYNC) const
43 {
44 wxASSERT_MSG( (flags & wxSOUND_LOOP) == 0 ||
45 (flags & wxSOUND_ASYNC) != 0,
46 _T("sound can only be looped asynchronously") );
47 return DoPlay(flags);
48 }
49 #if WXWIN_COMPATIBILITY_2_4
50 wxDEPRECATED( bool Play(bool async, bool looped = false) const );
51 #endif
52
53 // Plays sound from filename:
54 static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC);
55
56 protected:
57 virtual bool DoPlay(unsigned flags) const = 0;
58 };
59
60 // ----------------------------------------------------------------------------
61 // wxSound class implementation
62 // ----------------------------------------------------------------------------
63
64 #if defined(__WXMSW__)
65 #include "wx/msw/sound.h"
66 #elif defined(__WXCOCOA__)
67 #include "wx/cocoa/sound.h"
68 #elif defined(__WXMAC__)
69 #include "wx/mac/sound.h"
70 #elif defined(__WXPM__)
71 #include "wx/os2/sound.h"
72 #elif defined(__UNIX__)
73 #include "wx/unix/sound.h"
74 #endif
75
76 // ----------------------------------------------------------------------------
77 // wxSoundBase methods
78 // ----------------------------------------------------------------------------
79
80 inline bool wxSoundBase::Play(const wxString& filename, unsigned flags)
81 {
82 wxSound snd(filename);
83 return snd.IsOk() ? snd.Play(flags) : false;
84 }
85
86 #if WXWIN_COMPATIBILITY_2_4
87 inline bool wxSoundBase::Play(bool async, bool looped) const
88 {
89 unsigned flags = 0;
90 if (async) flags |= wxSOUND_ASYNC;
91 if (looped) flags |= wxSOUND_LOOP | wxSOUND_ASYNC;
92 return DoPlay(flags);
93 }
94 #endif
95
96 #endif // wxUSE_SOUND
97
98 #endif // _WX_SOUND_H_BASE_