home *** CD-ROM | disk | FTP | other *** search
/ Large Pack of OldSkool DOS MOD Trackers / beaversweeper_v101.zip / src / ModulatorMain.cpp < prev    next >
C/C++ Source or Header  |  2003-01-06  |  5KB  |  191 lines

  1. // ModulatorMain.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "tracker.h"
  6. #include "ModulatorMain.h"
  7. #include "modenvelope.h"
  8. #include "modlfo.h"
  9. #include "modcontroller.h"
  10. #include "modulatornew.h"
  11. #include "instrEditor.h"
  12.  
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CModulatorMain dialog
  21.  
  22.  
  23. CModulatorMain::CModulatorMain(CWnd* pParent /*=NULL*/)
  24.     : CVoiceBaseDlg(CModulatorMain::IDD, pParent)
  25. {
  26.     //{{AFX_DATA_INIT(CModulatorMain)
  27.     //}}AFX_DATA_INIT
  28. }
  29.  
  30.  
  31. void CModulatorMain::DoDataExchange(CDataExchange* pDX)
  32. {
  33.     CVoiceBaseDlg::DoDataExchange(pDX);
  34.     //{{AFX_DATA_MAP(CModulatorMain)
  35.     DDX_Control(pDX, IDC_STATIC_MODWIN, m_modwin);
  36.     DDX_Control(pDX, IDC_LIST_MODLIST, m_modlist);
  37.     //}}AFX_DATA_MAP
  38. }
  39.  
  40.  
  41. BEGIN_MESSAGE_MAP(CModulatorMain, CVoiceBaseDlg)
  42.     //{{AFX_MSG_MAP(CModulatorMain)
  43.     ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_MODULATORTYPES, OnSelchangeTabModulatortypes)
  44.     ON_BN_CLICKED(IDC_BUTTON_NEWMODULATOR, OnButtonNewmodulator)
  45.     ON_LBN_SELCHANGE(IDC_LIST_MODLIST, OnSelchangeListModlist)
  46.     ON_BN_CLICKED(IDC_BUTTON_DELMODULATOR, OnButtonDelmodulator)
  47.     //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CModulatorMain message handlers
  52. static char *modnames[]=
  53. {
  54.   "unused",
  55.   "ENVELOPE",
  56.   "LFO",
  57.   "CONTROLLER",
  58.   NULL,    
  59. };
  60.  
  61. BOOL CModulatorMain::OnInitDialog() 
  62. {
  63.     CVoiceBaseDlg::OnInitDialog();
  64.  
  65.   CRect wrect;
  66.   enved = (CModulateBaseDlg *)new CModEnvelope();
  67.   lfoed = (CModulateBaseDlg *)new CModLfo();
  68.   cntred = (CModulateBaseDlg *)new CModController();
  69.  
  70.   enved->Create(MAKEINTRESOURCE(IDD_DIALOG_MODULATEENVELOPE),&m_modwin);
  71.   lfoed->Create(MAKEINTRESOURCE(IDD_DIALOG_MODULATORLFO),&m_modwin);
  72.   cntred->Create(MAKEINTRESOURCE(IDD_DIALOG_MODULATORCONTR),&m_modwin);
  73.   
  74.   current = enved;
  75.  
  76.   current->UpdateWindow();
  77.   current->ShowWindow(SW_HIDE);
  78.   current->GetClientRect(&wrect);
  79.   current->MoveWindow(4,20,wrect.Width(),wrect.Height());
  80.   curselmod=0;
  81.   
  82.     return TRUE;  // return TRUE unless you set the focus to a control
  83.                   // EXCEPTION: OCX Property Pages should return FALSE
  84. }
  85.  
  86. void CModulatorMain::OnSelchangeTabModulatortypes(NMHDR* pNMHDR, LRESULT* pResult) 
  87. {
  88.     // TODO: Add your control notification handler code here
  89. //  int wt=m_modulators.GetCurSel();
  90. //  SetCurrentTab (wt);
  91.     
  92.     *pResult = 0;
  93. }
  94.  
  95. void CModulatorMain::OnButtonNewmodulator() 
  96. {
  97.     // TODO: Add your control notification handler code here
  98.   CModulatorNew modnew;
  99.  
  100.   switch (modnew.DoModal())
  101.   {
  102.   case IDC_BUTTON_MODNEWENV :
  103.     voice->AddModulator(is_ENVELOPE);
  104.     break;
  105.   case IDC_BUTTON_MODNEWLFO :
  106.     voice->AddModulator(is_LFO);
  107.     break;
  108.   case IDC_BUTTON_MODNEWCNTR :
  109.     voice->AddModulator(is_CONTROLLER);
  110.     break;
  111.   }
  112.     UpdateVoiceData ();
  113.     ownerDlg->FillVolModCombo();
  114.  
  115.   
  116.     
  117. }
  118. void CModulatorMain::SetCurrentTab()
  119. {
  120.     CRect wrect;
  121.     //int tab;
  122.     isModulator *mod;  
  123.     mod = voice->GetModulator(curselmod);
  124.     //tab = mod->GetType();
  125.  
  126.     //m_modulators.SetCurSel (tab);
  127.     current->ShowWindow(SW_HIDE);
  128.  
  129.     switch (mod->GetType())
  130.     {
  131.         case is_ENVELOPE :
  132.             current = enved;
  133.             m_modwin.SetWindowText("Envelope");
  134.             break;
  135.         case is_LFO :
  136.             current = lfoed;
  137.             m_modwin.SetWindowText("Lfo");
  138.             break;
  139.         case is_CONTROLLER :
  140.             current = cntred;
  141.             m_modwin.SetWindowText("Controller");
  142.             break;
  143.     }
  144.     current->UpdateWindow();
  145.     current->ShowWindow(SW_SHOW);
  146.     current->GetClientRect(&wrect);
  147.     current->MoveWindow(4,20,wrect.Width(),wrect.Height());
  148.     current->SetVoice (voice->GetModulator(curselmod),voice,instrument,synth);
  149.     current->UpdateModulateData();  
  150. }
  151.  
  152. void CModulatorMain::UpdateVoiceData()
  153. {
  154.     int i;
  155.     isModulator *mod;
  156.     m_modlist.ResetContent();
  157.     for (i=0;i<voice->GetNrOfModulators();i++)
  158.     {
  159.         mod = voice->GetModulator(i);
  160.         m_modlist.InsertString(i,modnames[mod->GetType()]);
  161.         m_modlist.SetItemData(i,mod->GetType());
  162.  
  163.     //m_modlist.InsertItem (0,"envelope");
  164.     }
  165.     curselmod=0;
  166.     current->SetVoice (voice->GetModulator(curselmod),voice,instrument,synth);
  167.     current->UpdateModulateData();  
  168.     m_modlist.SetCurSel(curselmod);
  169.     SetCurrentTab();
  170.   
  171.   
  172.   
  173. }
  174.  
  175.  
  176. void CModulatorMain::OnSelchangeListModlist() 
  177. {
  178.     // TODO: Add your control notification handler code here
  179.     
  180.     curselmod = m_modlist.GetCurSel ();
  181.     
  182.     SetCurrentTab();
  183. }
  184.  
  185. void CModulatorMain::OnButtonDelmodulator() 
  186. {
  187.     // TODO: Add your control notification handler code here
  188.     voice->DelModulator();
  189.     UpdateVoiceData ();
  190. }
  191.