]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sound.h
Use DeafultAttributes instead of hard coded defaults
[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
9905656a
WS
30#if WXWIN_COMPATIBILITY_2_4 || \
31 defined(__BORLANDC__) || \
32 defined(__VISUALC__) || \
33 defined(__DMC__)
96303362
VS
34 // NB: We can't use enum because there would be ambiguity between the
35 // two Play() prototypes when called without explicit parameters.
9905656a
WS
36 // We can't use enum with some compilers either, because they
37 // keep reporting nonexistent ambiguities between
96303362 38 // Play(unsigned) and static Play(const wxString&, unsigned).
cad1a197
VS
39 #define wxSOUND_SYNC ((unsigned)0)
40 #define wxSOUND_ASYNC ((unsigned)1)
41 #define wxSOUND_LOOP ((unsigned)2)
42#else
43 enum wxSoundFlags
44 {
45 wxSOUND_SYNC = 0,
46 wxSOUND_ASYNC = 1,
47 wxSOUND_LOOP = 2
48 };
49#endif
e9e23cb5 50
cad1a197 51// Base class for wxSound implementations
65cf3a4b 52class WXDLLIMPEXP_ADV wxSoundBase : public wxObject
e9e23cb5
VS
53{
54public:
55 // Play the sound:
cad1a197 56 bool Play(unsigned flags = wxSOUND_ASYNC) const
e9e23cb5 57 {
cad1a197
VS
58 wxASSERT_MSG( (flags & wxSOUND_LOOP) == 0 ||
59 (flags & wxSOUND_ASYNC) != 0,
60 _T("sound can only be looped asynchronously") );
e9e23cb5
VS
61 return DoPlay(flags);
62 }
63#if WXWIN_COMPATIBILITY_2_4
cad1a197 64 wxDEPRECATED( bool Play(bool async, bool looped = false) const );
e9e23cb5
VS
65#endif
66
cad1a197
VS
67 // Plays sound from filename:
68 static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC);
69
e9e23cb5 70protected:
cad1a197 71 virtual bool DoPlay(unsigned flags) const = 0;
e9e23cb5 72};
e9e23cb5
VS
73
74// ----------------------------------------------------------------------------
75// wxSound class implementation
76// ----------------------------------------------------------------------------
77
78#if defined(__WXMSW__)
cad1a197 79 #include "wx/msw/sound.h"
e9e23cb5 80#elif defined(__WXMAC__)
cad1a197 81 #include "wx/mac/sound.h"
e9e23cb5 82#elif defined(__WXPM__)
cad1a197 83 #include "wx/os2/sound.h"
00f6001f
VS
84#elif defined(__UNIX__)
85 #include "wx/unix/sound.h"
e9e23cb5
VS
86#endif
87
cad1a197
VS
88// ----------------------------------------------------------------------------
89// wxSoundBase methods
90// ----------------------------------------------------------------------------
91
92inline bool wxSoundBase::Play(const wxString& filename, unsigned flags)
93{
94 wxSound snd(filename);
95 return snd.IsOk() ? snd.Play(flags) : false;
96}
97
98#if WXWIN_COMPATIBILITY_2_4
99inline bool wxSoundBase::Play(bool async, bool looped) const
100{
101 unsigned flags = 0;
102 if (async) flags |= wxSOUND_ASYNC;
103 if (looped) flags |= wxSOUND_LOOP | wxSOUND_ASYNC;
104 return DoPlay(flags);
105}
e9e23cb5
VS
106#endif
107
cad1a197
VS
108#endif // wxUSE_SOUND
109
e9e23cb5 110#endif // _WX_SOUND_H_BASE_