//------------------------------------------------------------------------ // // VisWrapperDlg.cpp // // Main Dialog. Please visit // http://www.ratajik.net/VisInterface for details // // ------------------------------------------------------------------- // * COPYRIGHT 2001, Greg Ratajik and Ratajik Software * // * All rights Reserved * // ------------------------------------------------------------------- // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // More information about this program can be found at: // http://www.ratajik.com/VisInterface // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //------------------------------------------------------------------------ #include "stdafx.h" #include "VisWrapper.h" #include "VisWrapperDlg.h" #include "VisDataRender.h" #include "About.h" #include #include #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif // // Names for all of the various Registry // entries. // const char *g_szRegVisPath = "sVisPath"; const char *g_szRegShowSpec = "bShowSpec"; const char *g_szRegShowWave = "bShowWave"; const char *g_szRegRandom = "bRandom"; //------------------------------------------------------------------------ // // Method: CVisWrapperDlg // // Description: The ctor // // Parms: N/A // // Return: N/A // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ CVisWrapperDlg::CVisWrapperDlg(CWnd* pParent /*=NULL*/) : CDialog(CVisWrapperDlg::IDD, pParent), m_pcVis(NULL), m_pvisRender(NULL), m_theRegistry(sRegProjectName, &m_bRegAvailable) { //{{AFX_DATA_INIT(CVisWrapperDlg) m_sPlugPath = _T(""); m_bShowSpec = FALSE; m_bShowWave = FALSE; //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } //------------------------------------------------------------------------ // // Method: ~CVisWrapperDlg // // Description: The dtor. Stop and Delete the render if it's up, // and clean up the list. // // Parms: N/A // // Return: N/A // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ CVisWrapperDlg::~CVisWrapperDlg( void ) { if(m_pvisRender) { m_pvisRender->StopRendering(); delete m_pvisRender, m_pvisRender = NULL; } m_listVis.RemoveAll(); } //------------------------------------------------------------------------ // // Method: DoDataExchange // // Description: // // Parms: N/A // // Return: N/A // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CVisWrapperDlg) DDX_Control(pDX, IDC_EF_PLUG_PATH, m_efPlugPath); DDX_Control(pDX, IDC_PB_BROWSE, m_pbBrowse); DDX_Control(pDX, IDC_PB_START, m_pbStart); DDX_Control(pDX, IDC_CK_SHOW_WAVE, m_ckShowWave); DDX_Control(pDX, IDC_CK_SHOW_SPEC, m_ckShowSpec); DDX_Control(pDX, IDC_CB_MODS, m_cbMods); DDX_Control(pDX, IDC_LB_PLUGS, m_lbPlugs); DDX_Control(pDX, IDC_RB_RANDOM, m_rbRandom); DDX_Control(pDX, IDC_RB_WAVE, m_rbWave); DDX_Text(pDX, IDC_EF_PLUG_PATH, m_sPlugPath); DDX_Check(pDX, IDC_CK_SHOW_SPEC, m_bShowSpec); DDX_Check(pDX, IDC_CK_SHOW_WAVE, m_bShowWave); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CVisWrapperDlg, CDialog) //{{AFX_MSG_MAP(CVisWrapperDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_WM_COPYDATA() ON_MESSAGE(WM_USER, OnUser) ON_MESSAGE(WM_VIS_ENDED, OnVisEnded) ON_BN_CLICKED(IDC_CONFIG, OnConfig) ON_BN_CLICKED(IDC_PB_BROWSE, OnPbBrowse) ON_EN_KILLFOCUS(IDC_EF_PLUG_PATH, OnKillfocusEfPlugPath) ON_LBN_SELCHANGE(IDC_LB_PLUGS, OnSelchangeLbPlugs) ON_BN_CLICKED(IDC_PB_START, OnPbStart) ON_WM_CLOSE() ON_WM_DESTROY() ON_BN_CLICKED(IDC_PB_STOP, OnPbStop) ON_BN_CLICKED(IDC_RB_RANDOM, OnRbRandom) ON_BN_CLICKED(IDC_RB_WAVE, OnRbWave) ON_BN_CLICKED(IDC_CK_SHOW_SPEC, OnCkShowSpec) ON_BN_CLICKED(IDC_CK_SHOW_WAVE, OnCkShowWave) //}}AFX_MSG_MAP END_MESSAGE_MAP() //------------------------------------------------------------------------ // // Method: OnUser // // Description: For some unknown reason, some Vis's MUST get a return on this // or they trap... (AVS!!!) // // Parms: // // Return: // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ LRESULT CVisWrapperDlg::OnUser(WPARAM wParam, LPARAM lParam) { return(0); } //------------------------------------------------------------------------ // // Method: OnInitDialog // // Description: Perform init stuff for the DLG. Added stuff includes // loading the registry and the list. // // Parms: N/A // // Return: bool // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ BOOL CVisWrapperDlg::OnInitDialog() { CDialog::OnInitDialog(); srand( (unsigned)time( NULL ) ); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon LoadRegistry(); // // If there's a valid plug path, init the // list with all the Vis DLL's available. // LoadList(); m_sLastPath = m_sPlugPath; return TRUE; } //------------------------------------------------------------------------ // // Method: OnSysCommand // // Description: // // Parms: // // Return: // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID, lParam); } } //------------------------------------------------------------------------ // // Method: OnPaint // // Description: // // Parms: // // Return: // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } //------------------------------------------------------------------------ // // Method: OnQueryDragIcon // // Description: // // Parms: // // Return: // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ HCURSOR CVisWrapperDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } //------------------------------------------------------------------------ // // Method: OnCopyData // // Description: Some Vis's expect Winamp to do things here. Easy to do, // if someone wants to fill it out, send me the code.. :) // (see FrontEnd.h for all the messages supported). // // Parms: // // Return: // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ BOOL CVisWrapperDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct) { return CDialog::OnCopyData(pWnd, pCopyDataStruct); } //------------------------------------------------------------------------ // // Method: OnConfig // // Description: Config the loaded vis. // // Parms: N/A // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::OnConfig() { if(m_pcVis) m_pcVis->Config(); else AfxMessageBox("Please Select a Vis"); } //------------------------------------------------------------------------ // // Method: OnPbBrowse // // Description: Call the shell browser to get the plug directory. // // Parms: N/A // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::OnPbBrowse() { // // Kill off the renderer if it's going // (we're going to change a pointer it's using here) // if(m_pvisRender) { m_pvisRender->StopRendering(); delete m_pvisRender, m_pvisRender = NULL; } UpdateData(true); // // Let the user select a Vis dir, using the currrent // dir as a starting point. // BrowseForDirectory(*this, "Browse for WinAmp Vis Plug-in", m_sPlugPath ); UpdateData(false); // // Only re-load the list if the path changes // (Might want to do a refresh button or something // in the future...) // if(m_sPlugPath != m_sLastPath) { m_sLastPath = m_sPlugPath; LoadList(); } } //------------------------------------------------------------------------ // // Method: OnKillfocusEfPlugpPath // // Description: See if the user typed something new in. If so, refresh // the list. // // Parms: N/A // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::OnKillfocusEfPlugPath() { UpdateData(true); if(m_sPlugPath != m_sLastPath) { m_sLastPath = m_sPlugPath; LoadList(); } } //------------------------------------------------------------------------ // // Method: LoadList // // Description: Based on what the user entered, load all valid DLL's in the // Vis list. // // Parms: N/A // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg :: LoadList() { // // We always want to start the Vis in the currernt // dir, so it can get it's option files, if needed. // _chdir(m_sPlugPath); // // Be nice and let the user know this make take a bit. // In the future, it would be nice to thread this. // CWaitCursor wait; m_lbPlugs.ResetContent(); // // Attempts to load the DLL list // LoadDLLList(); // // Loop through the list, display each in the list box. // for (POSITION posIt = m_listVis.GetHeadPosition(); posIt != NULL; m_listVis.GetNext(posIt)) { CVisInterface* pVis = m_listVis.GetAt(posIt); ASSERT(pVis != NULL); // Something bad is up if this is hit. if(pVis) { CString sVisName; pVis->VisName(sVisName); int nIndex = m_lbPlugs.AddString(sVisName); // // Later on, when the user selects this item, // use the dataptr attached to it to get the actual // vis to select. // m_lbPlugs.SetItemData(nIndex, (DWORD)pVis); if(m_lbPlugs.SetCurSel(0) != LB_ERR) { // // Microsoft sucks... // OnSelchangeLbPlugs(); } } } } //------------------------------------------------------------------------ // // Method: LoadDLLList // // Description: Load the DLL list from the cur directory. // This is currently excluding any dll that starts with // in_ and out_, as it increases the time to load, if you do // those in the normal WinAMP dir. Vis's are SUPPOSED to all // start with VIS_, but lots of people don't do that. // // Might want to do a future mod to allow the user to indicate // to look for VIS_ or not (so the load time would be faster). // // Parms: N/A // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::LoadDLLList() { m_listVis.RemoveAll(); CFileFind finder; BOOL bWorking = finder.FindFile("*.dll"); bool bLoad; // // Loop through each found DLL. If it's not in_ or a out_ // Plug-in, try to process it. // while (bWorking) { bWorking = finder.FindNextFile(); CString sFileName = finder.GetFileName(); bLoad = true; if(sFileName.GetLength() > 3) { CString sTest = sFileName.Left(3); if((!(sFileName.Left(3)).CompareNoCase("in_"))) bLoad = false; } if(sFileName.GetLength() > 4) { if((!(sFileName.Left(4)).CompareNoCase("out_"))) bLoad = false; } if(bLoad) { // // Load the Vis. If this failes (!isValid), delete it and don't add // to the list. Otherwise, load to the list (might want to use the new // Create() method to improve this... // CVisInterface *pNewVis = new CVisInterface(*this, finder.GetFilePath()); if(pNewVis) { if(pNewVis->isValid()) m_listVis += pNewVis; else delete pNewVis, pNewVis = NULL; } } } } //------------------------------------------------------------------------ // // Method: OnSelchangeLbPlugs // // Description: The user selected a plug-in from the list. Display // the list of mods for the plug in, defaulting to the // first one. // // Parms: // // Return: // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::OnSelchangeLbPlugs() { m_cbMods.ResetContent(); int nIndex = m_lbPlugs.GetCurSel(); if(-1 != nIndex) { // // This should have been set when we inserted the item. // CVisInterface* pVis = (CVisInterface *)m_lbPlugs.GetItemData(nIndex); if(pVis != NULL) { // // Load the Mod list. // for(int j = 0; j < 3; j++) { CString sModName; if(pVis->ModName(j, sModName )) { int nCBIndex = m_cbMods.AddString(sModName); m_cbMods.SetItemData(nCBIndex, j); } } m_cbMods.SetCurSel(0); } } } //------------------------------------------------------------------------ // // Method: SelectVisAndMod // // Description: Looking at the LB and CB, set the passed pointer = // to the mod (and do a select on it so the interface // is set up correctly). // // Parms: CVisInterface ** - The vis to set. // // Return: bool - TRUE = was able to set the passed vis. // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ bool CVisWrapperDlg::SelectVisAndMod(CVisInterface **ppSelectedVis) { bool bRet = false; int nPlugIndex = m_lbPlugs.GetCurSel(); if(-1 != nPlugIndex) { // // This should have been set when we inserted the item. // CVisInterface* pVis = (CVisInterface *)m_lbPlugs.GetItemData(nPlugIndex); int nModIndex = m_cbMods.GetCurSel(); if(nModIndex != CB_ERR) { int nModNbr = m_cbMods.GetItemData(nModIndex); ASSERT( nModNbr >= 0 && nModNbr < 3); // If this hits, something bad is happening (Only can have mods 0-2) // // Based on the selected Vis and mod, // Init the pVis. // if(pVis->SelectModule( nModNbr)) { *ppSelectedVis = pVis; bRet = true; } else *ppSelectedVis = NULL; } } if(bRet) return(bRet); else { // // Didn't work, so NULL the pointer out. // *ppSelectedVis = NULL; return(bRet); } } //------------------------------------------------------------------------ // // Method: OnPbStart // // Description: The user wants to start. If we can select the vis and // mod, go ahead and start the render thread. // // Parms: N/A // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::OnPbStart() { SelectVisAndMod(&m_pcVis); if(m_pcVis) { // // Might want to let the Data Loader do this in the future... // m_pcVis->SetWaveformStereo(); m_pcVis->SetSpectrumStereo(); m_pcVis->SetChannelStereo(); if(m_ckShowWave.GetCheck()) m_theReader.ShowWave(true); else m_theReader.ShowWave(false); if(m_ckShowSpec.GetCheck()) m_theReader.ShowSpec(true); else m_theReader.ShowSpec(false); if(m_rbRandom.GetCheck()) m_theReader.SetType(TYPE_RANDOM); else m_theReader.SetType(TYPE_WAVE); GreyControls(); // // This call will actually bring up the vis window. // m_pcVis->Init(); m_pvisRender = new CVisDataRender(NULL, m_pcVis, &m_theReader); m_pvisRender->StartRendering(); } else AfxMessageBox("Please Select a Vis and Mod to run."); } //------------------------------------------------------------------------ // // Method: OnClose // // Description: Save settings to the registry. // // Parms: N/A // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::OnClose() { SaveRegistry() ; CDialog::OnClose(); } //------------------------------------------------------------------------ // // Method: OnDestroy // // Description: Because of the way Vis's work, sometimes OnClose won't // be called... so save the reg. // // Parms: N/A // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::OnDestroy() { SaveRegistry(); CDialog::OnDestroy(); } //------------------------------------------------------------------------ // // Method: OnPbStop // // Description: User wants to stop rendering. Do so. // // Parms: N/A // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::OnPbStop() { if(m_pvisRender) { m_pvisRender->StopRendering(); delete m_pvisRender, m_pvisRender = NULL; } m_pcVis->Quit(); GreyControls(false); } //------------------------------------------------------------------------ // // Method: BrowsecallbackProc // // Description: Microsoft sucks... // // Parms: HWND - // UINT - // LPARAM - // LPARAM - The default path will be passed on INIT. // // Return: int // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ int CALLBACK BrowseCallbackProc( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData ) { switch (uMsg) { case BFFM_INITIALIZED: // // Set the initial path // ::SendMessage( hwnd, BFFM_SETSELECTION, TRUE, lpData ); break; } return 0; } //------------------------------------------------------------------------ // // Method: BrowseForDirectory // // Description: Using the Shell Dir browse, let the user browse to the // Vis plug dir, staring at the passed folder. // // As a side note, I'd just like to say this SHBrowseForFolder // thing is screwed up and generally sucks. Having to do a // stupid CALLBACK just to set the intial directory is CRAZY. // Is there some reason there just wasn't a nice simple param // for this? If anyone knows the goober that wrote this, please // let me know how to contact him, as I'd like to have a chat // with him :P // // Parms: CWnd& - Parent window // LPCSTR - Title to give the browser // CString&- The start folder, AND the return selected folder // // Return: bool - TRUE = worked. // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ bool CVisWrapperDlg::BrowseForDirectory(const CWnd& parent, LPCTSTR title, CString& folderName ) { TCHAR path[MAX_PATH]; LPTSTR pFolderName = folderName.GetBuffer(folderName.GetLength()); BROWSEINFO browse; browse.hwndOwner = parent.GetSafeHwnd(); browse.pidlRoot = NULL; browse.pszDisplayName = path; browse.lpszTitle = title; browse.ulFlags = BIF_RETURNONLYFSDIRS; browse.lpfn = BrowseCallbackProc; browse.lParam = (LPARAM)pFolderName; LPITEMIDLIST pidl = SHBrowseForFolder(&browse); folderName.ReleaseBuffer(); if (NULL != pidl) { if (SHGetPathFromIDList( pidl, path )) { folderName = path; return(true); } } return(false); } //------------------------------------------------------------------------ // // Method: OnRbRandom // // Description: Based on user selection, change the reader to display // random or wave data. // // Parms: N/A // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::OnRbRandom() { if(m_rbRandom.GetCheck()) m_theReader.SetType(TYPE_RANDOM); else m_theReader.SetType(TYPE_WAVE); } //------------------------------------------------------------------------ // // Method: OnRbWave // // Description: Based on user selection, change the reader to display // random or wave data. // // Parms: N/A // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::OnRbWave() { if(m_rbRandom.GetCheck()) m_theReader.SetType(TYPE_RANDOM); else m_theReader.SetType(TYPE_WAVE); } //------------------------------------------------------------------------ // // Method: OnCkShowSpec // // Description: Based on user selection, change the reader to create // or not create spec data. // // Parms: N/A // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::OnCkShowSpec() { if(m_ckShowSpec.GetCheck()) m_theReader.ShowSpec(true); else m_theReader.ShowSpec(false); } //------------------------------------------------------------------------ // // Method: OnCkShowWave // // Description: Based on user selection, change the reader to create // or not create spec data. // // Parms: N/A // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::OnCkShowWave() { if(m_ckShowWave.GetCheck()) m_theReader.ShowWave(true); else m_theReader.ShowWave(false); } //------------------------------------------------------------------------ // // Method: LoadRegistry // // Description: Load the last values the user was using, or set defaults. // // Parms: N/A // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::LoadRegistry() { if(!m_theRegistry.GetValue(g_szRegVisPath , m_sPlugPath)) { // // Set the default values, as we haven't ever // saved them in the reg. // m_sPlugPath = ""; m_bShowSpec = true; m_bShowWave = true; m_rbRandom.SetCheck(true); } else { m_theRegistry.GetValue(g_szRegShowSpec, (DWORD *)&m_bShowSpec); m_theRegistry.GetValue(g_szRegShowWave, (DWORD *)&m_bShowWave); bool bRandom = false; m_theRegistry.GetValue(g_szRegRandom, (DWORD *)&bRandom); if(bRandom) m_rbRandom.SetCheck(true); else m_rbWave.SetCheck(true); } UpdateData(false); } //------------------------------------------------------------------------ // // Method: SaveRegistry // // Description: Save the users data in the registry for the next time we // run. // // Parms: N/A // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisWrapperDlg::SaveRegistry() { UpdateData(true); m_theRegistry.SetValue(g_szRegVisPath , m_sPlugPath); m_theRegistry.SetValue(g_szRegShowSpec, m_bShowSpec); m_theRegistry.SetValue(g_szRegShowWave, m_bShowWave); if(m_rbRandom.GetCheck()) m_theRegistry.SetValue(g_szRegRandom, 1); else m_theRegistry.SetValue(g_szRegRandom, 0); } //------------------------------------------------------------------------ // // Method: OnCommand // // Description: Handle if the user closes from the system menu. // // Parms: // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ BOOL CVisWrapperDlg::OnCommand(WPARAM wParam, LPARAM lParam) { if(IDCANCEL == wParam) { OnClose(); } return CDialog::OnCommand(wParam, lParam); } CVisWrapperDlg::GreyControls(bool bGrey /* TRUE */) { m_pbBrowse.EnableWindow(!bGrey); m_pbStart.EnableWindow(!bGrey); m_lbPlugs.EnableWindow(!bGrey); m_cbMods.EnableWindow(!bGrey); m_efPlugPath.EnableWindow(!bGrey); } //------------------------------------------------------------------------ // // Method: OnVisEnded // // Description: Called when the Vis ended. // // Parms: // // Return: // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ LRESULT CVisWrapperDlg::OnVisEnded(WPARAM wParam, LPARAM lParam) { if(m_pvisRender) { m_pvisRender->StopRendering(); delete m_pvisRender, m_pvisRender = NULL; } GreyControls(false); return(0); }