]> git.saurik.com Git - wxWidgets.git/blob - src/os2/wave.cpp
check the radio buttons when they get focus (closes 777500)
[wxWidgets.git] / src / os2 / wave.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wave.cpp
3 // Purpose: wxWave class implementation: optional
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/17/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifndef WX_PRECOMP
16 #include "wx/wx.h"
17 #endif
18
19 #include "wx/file.h"
20 #include "wx/os2/wave.h"
21 #define INCL_32 /* force 32 bit compile */
22 #define INCL_GPIBITMAPS
23 #define INCL_DOSFILEMGR
24 #define INCL_WIN
25 #define INCL_GPI
26 #define INCL_PM
27 #include <os2.h>
28 #include <stdio.h>
29 #include <string.h>
30 #include <stdlib.h>
31 #include <os2medef.h>
32 #include <mmioos2.h>
33
34 wxWave::wxWave()
35 : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE)
36 {
37 }
38
39 wxWave::wxWave(const wxString& sFileName, bool isResource)
40 : m_waveData(NULL), m_waveLength(0), m_isResource(isResource)
41 {
42 Create(sFileName, isResource);
43 }
44
45 wxWave::wxWave(int size, const wxByte* data)
46 : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE)
47 {
48 Create(size, data);
49 }
50
51 wxWave::~wxWave()
52 {
53 Free();
54 }
55
56 bool wxWave::Create(const wxString& fileName, bool isResource)
57 {
58 Free();
59
60 if (isResource)
61 {
62 m_isResource = TRUE;
63 // TODO:
64 /*
65 HRSRC hresInfo;
66 #ifdef _UNICODE
67 hresInfo = ::FindResourceW((HMODULE) wxhInstance, fileName, wxT("WAVE"));
68 #else
69 hresInfo = ::FindResourceA((HMODULE) wxhInstance, fileName, wxT("WAVE"));
70 #endif
71 if (!hresInfo)
72 return FALSE;
73
74 HGLOBAL waveData = ::LoadResource((HMODULE) wxhInstance, hresInfo);
75
76 if (waveData)
77 {
78 m_waveData= (wxByte*)::LockResource(waveData);
79 m_waveLength = (int) ::SizeofResource((HMODULE) wxhInstance, hresInfo);
80 }
81
82 return (m_waveData ? TRUE : FALSE);
83 */
84 return FALSE;
85 }
86 else
87 {
88 m_isResource = FALSE;
89 #if wxUSE_FILE
90
91 wxFile fileWave;
92 if (!fileWave.Open(fileName, wxFile::read))
93 return FALSE;
94
95 m_waveLength = (int) fileWave.Length();
96 // TODO:
97 /*
98 m_waveData = (wxByte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength));
99 if (!m_waveData)
100 return FALSE;
101
102 fileWave.Read(m_waveData, m_waveLength);
103 */
104 return TRUE;
105 #else
106 return FALSE;
107 #endif //wxUSE_FILE
108 }
109 }
110
111 bool wxWave::Create(int size, const wxByte* data)
112 {
113 Free();
114 m_isResource = FALSE;
115 m_waveLength=size;
116 m_waveData = NULL; // (wxByte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength));
117 if (!m_waveData)
118 return FALSE;
119
120 for (int i=0; i<size; i++) m_waveData[i] = data[i];
121 return TRUE;
122 }
123
124 bool wxWave::Play(bool async, bool looped) const
125 {
126 if (!IsOk())
127 return FALSE;
128 // TODO:
129 /*
130 return ( ::PlaySound((LPCTSTR)m_waveData, NULL, SND_MEMORY |
131 SND_NODEFAULT | (async ? SND_ASYNC : SND_SYNC) | (looped ? (SND_LOOP | SND_ASYNC) : 0)) != 0 );
132 */
133 return FALSE;
134 }
135
136 bool wxWave::Free()
137 {
138 if (m_waveData)
139 {
140 // HGLOBAL waveData = ::GlobalHandle(m_waveData);
141
142 // TODO:
143 /*
144 if (waveData)
145 {
146 if (m_isResource)
147 ::FreeResource(waveData);
148 else
149 {
150 ::GlobalUnlock(waveData);
151 ::GlobalFree(waveData);
152 }
153
154 m_waveData = NULL;
155 m_waveLength = 0;
156 return TRUE;
157 }
158 */
159 }
160 return FALSE;
161 }
162