X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0e320a79f187558effb04d92020b470372bbe456..0d5b4bc274158c9d8bf30b97cd2228489a60ba69:/src/os2/wave.cpp diff --git a/src/os2/wave.cpp b/src/os2/wave.cpp index c25681858c..87320e0d63 100644 --- a/src/os2/wave.cpp +++ b/src/os2/wave.cpp @@ -1,21 +1,35 @@ ///////////////////////////////////////////////////////////////////////////// // Name: wave.cpp // Purpose: wxWave class implementation: optional -// Author: AUTHOR +// Author: David Webster // Modified by: -// Created: ??/??/98 +// Created: 10/17/99 // RCS-ID: $Id$ -// Copyright: (c) AUTHOR -// Licence: wxWindows licence +// Copyright: (c) David Webster +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "wave.h" +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifndef WX_PRECOMP +#include "wx/wx.h" #endif -#include "wx/object.h" -#include "wx/string.h" -#include "wx/stubs/wave.h" +#include "wx/file.h" +#include "wx/os2/wave.h" +#define INCL_32 /* force 32 bit compile */ +#define INCL_GPIBITMAPS +#define INCL_DOSFILEMGR +#define INCL_WIN +#define INCL_GPI +#define INCL_PM +#include +#include +#include +#include +#include +#include wxWave::wxWave() : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE) @@ -23,39 +37,126 @@ wxWave::wxWave() } wxWave::wxWave(const wxString& sFileName, bool isResource) - : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE) + : m_waveData(NULL), m_waveLength(0), m_isResource(isResource) { - Create(sFileName, isResource); + Create(sFileName, isResource); } +wxWave::wxWave(int size, const wxByte* data) + : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE) +{ + Create(size, data); +} wxWave::~wxWave() { - Free(); + Free(); } bool wxWave::Create(const wxString& fileName, bool isResource) { - Free(); + Free(); - // TODO + if (isResource) + { + m_isResource = TRUE; +// TODO: +/* + HRSRC hresInfo; +#ifdef _UNICODE + hresInfo = ::FindResourceW((HMODULE) wxhInstance, fileName, wxT("WAVE")); +#else + hresInfo = ::FindResourceA((HMODULE) wxhInstance, fileName, wxT("WAVE")); +#endif + if (!hresInfo) + return FALSE; + HGLOBAL waveData = ::LoadResource((HMODULE) wxhInstance, hresInfo); + + if (waveData) + { + m_waveData= (wxByte*)::LockResource(waveData); + m_waveLength = (int) ::SizeofResource((HMODULE) wxhInstance, hresInfo); + } + + return (m_waveData ? TRUE : FALSE); +*/ return FALSE; -} + } + else + { + m_isResource = FALSE; +#if wxUSE_FILE -bool wxWave::Play(bool async, bool looped) const -{ - if (!IsOk()) + wxFile fileWave; + if (!fileWave.Open(fileName, wxFile::read)) + return FALSE; + + m_waveLength = (int) fileWave.Length(); +// TODO: +/* + m_waveData = (wxByte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength)); + if (!m_waveData) return FALSE; - // TODO + fileWave.Read(m_waveData, m_waveLength); +*/ + return TRUE; +#else return FALSE; +#endif //wxUSE_FILE + } } -bool wxWave::Free() +bool wxWave::Create(int size, const wxByte* data) +{ + Free(); + m_isResource = FALSE; + m_waveLength=size; + m_waveData = NULL; // (wxByte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength)); + if (!m_waveData) + return FALSE; + + for (int i=0; i