]> git.saurik.com Git - wxWidgets.git/blob - include/wx/sound.h
Inital fill in background, removed tabs, -1->wxID_ANY, TRUE->true, FALSE->false
[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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "soundbase.h"
17 #endif
18
19 #include "wx/defs.h"
20
21 #if wxUSE_SOUND
22
23 #include "wx/object.h"
24
25 // ----------------------------------------------------------------------------
26 // wxSoundBase: common wxSound code and interface
27 // ----------------------------------------------------------------------------
28
29 // Flags for wxSound::Play
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).
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
47
48 // Base class for wxSound implementations
49 class WXDLLIMPEXP_ADV wxSoundBase : public wxObject
50 {
51 public:
52 // Play the sound:
53 bool Play(unsigned flags = wxSOUND_ASYNC) const
54 {
55 wxASSERT_MSG( (flags & wxSOUND_LOOP) == 0 ||
56 (flags & wxSOUND_ASYNC) != 0,
57 _T("sound can only be looped asynchronously") );
58 return DoPlay(flags);
59 }
60 #if WXWIN_COMPATIBILITY_2_4
61 wxDEPRECATED( bool Play(bool async, bool looped = false) const );
62 #endif
63
64 // Plays sound from filename:
65 static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC);
66
67 protected:
68 virtual bool DoPlay(unsigned flags) const = 0;
69 };
70
71 // ----------------------------------------------------------------------------
72 // wxSound class implementation
73 // ----------------------------------------------------------------------------
74
75 #if defined(__WXMSW__)
76 #include "wx/msw/sound.h"
77 #elif defined(__WXMAC__)
78 #include "wx/mac/sound.h"
79 #elif defined(__WXPM__)
80 #include "wx/os2/sound.h"
81 #elif defined(__UNIX__)
82 #include "wx/unix/sound.h"
83 #endif
84
85 // ----------------------------------------------------------------------------
86 // wxSoundBase methods
87 // ----------------------------------------------------------------------------
88
89 inline 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
96 inline 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 }
103 #endif
104
105 #endif // wxUSE_SOUND
106
107 #endif // _WX_SOUND_H_BASE_