]> git.saurik.com Git - wxWidgets.git/blob - include/wx/sound.h
Add lambda-friendly wxDialog::ShowWindowModalThenDo().
[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 // Copyright: (c) 2004, Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_SOUND_H_BASE_
12 #define _WX_SOUND_H_BASE_
13
14 #include "wx/defs.h"
15
16 #if wxUSE_SOUND
17
18 #include "wx/object.h"
19
20 // ----------------------------------------------------------------------------
21 // wxSoundBase: common wxSound code and interface
22 // ----------------------------------------------------------------------------
23
24 // Flags for wxSound::Play
25
26 // NB: We can't use enum with some compilers, because they keep reporting
27 // nonexistent ambiguities between Play(unsigned) and static Play(const
28 // wxString&, unsigned).
29 #define wxSOUND_SYNC ((unsigned)0)
30 #define wxSOUND_ASYNC ((unsigned)1)
31 #define wxSOUND_LOOP ((unsigned)2)
32
33 // Base class for wxSound implementations
34 class WXDLLIMPEXP_ADV wxSoundBase : public wxObject
35 {
36 public:
37 // Play the sound:
38 bool Play(unsigned flags = wxSOUND_ASYNC) const
39 {
40 wxASSERT_MSG( (flags & wxSOUND_LOOP) == 0 ||
41 (flags & wxSOUND_ASYNC) != 0,
42 wxT("sound can only be looped asynchronously") );
43 return DoPlay(flags);
44 }
45
46 // Plays sound from filename:
47 static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC);
48
49 protected:
50 virtual bool DoPlay(unsigned flags) const = 0;
51 };
52
53 // ----------------------------------------------------------------------------
54 // wxSound class implementation
55 // ----------------------------------------------------------------------------
56
57 #if defined(__WINDOWS__)
58 #include "wx/msw/sound.h"
59 #elif defined(__WXCOCOA__)
60 #include "wx/cocoa/sound.h"
61 #elif defined(__WXMAC__)
62 #include "wx/osx/sound.h"
63 #elif defined(__WXPM__)
64 #include "wx/os2/sound.h"
65 #elif defined(__UNIX__)
66 #include "wx/unix/sound.h"
67 #endif
68
69 // ----------------------------------------------------------------------------
70 // wxSoundBase methods
71 // ----------------------------------------------------------------------------
72
73 inline bool wxSoundBase::Play(const wxString& filename, unsigned flags)
74 {
75 wxSound snd(filename);
76 return snd.IsOk() ? snd.Play(flags) : false;
77 }
78
79 #endif // wxUSE_SOUND
80
81 #endif // _WX_SOUND_H_BASE_