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

  1. // InsertDist.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "tracker.h"
  6. #include "InsertDist.h"
  7. #include "isSynth.h"
  8. #include "isFilter.h"
  9. #include "isDistortion.h"
  10.  
  11.  
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CInsertDist dialog
  20.  
  21. #define FloatIntMAX 1024
  22. #define uFloatToInt(a) ((a)*1024)
  23. #define sFloatToInt(a) ((a)*1024+1024)
  24.  
  25. #define uIntToFloat(a) ((a)/1024.0f)
  26. #define sIntToFloat(a) (((a)-1024)/1024.0f)
  27.  
  28. CInsertDist::CInsertDist(CWnd* pParent /*=NULL*/)
  29.     : CInsertBaseDlg(CInsertDist::IDD, pParent)
  30. {
  31.     //{{AFX_DATA_INIT(CInsertDist)
  32.         // NOTE: the ClassWizard will add member initialization here
  33.     //}}AFX_DATA_INIT
  34. }
  35.  
  36.  
  37. void CInsertDist::DoDataExchange(CDataExchange* pDX)
  38. {
  39.     CInsertBaseDlg::DoDataExchange(pDX);
  40.     //{{AFX_DATA_MAP(CInsertDist)
  41.     DDX_Control(pDX, IDC_SLIDER_DISTAMOUNT, m_amountslider);
  42.     DDX_Control(pDX, IDC_STATIC_AMOUNTVAL, m_distamount);
  43.     //}}AFX_DATA_MAP
  44. }
  45.  
  46.  
  47. BEGIN_MESSAGE_MAP(CInsertDist, CInsertBaseDlg)
  48.     //{{AFX_MSG_MAP(CInsertDist)
  49.     ON_BN_CLICKED(IDC_RADIO_DISTHARD, OnRadio)
  50.     ON_BN_CLICKED(IDC_RADIO_DISTSOFT, OnRadio)
  51.     ON_BN_CLICKED(IDC_RADIO_DISTSIN, OnRadio)
  52.     ON_WM_HSCROLL()
  53.     //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55.  
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CInsertDist message handlers
  58. void CInsertDist::UpdateInsertData()
  59. {
  60.     SetCntrlData();    
  61.     m_amountslider.SetRange(0,FloatIntMAX*64);
  62.     m_amountslider.SetPos(0);
  63.     SetCntrlData();
  64. }
  65. void CInsertDist::SetCntrlData(void)
  66. {
  67.     isDistortion *dist;
  68.  
  69.     dist = (isDistortion *)insert;
  70.     CheckDlgButton(IDC_RADIO_DISTHARD,0);
  71.     CheckDlgButton(IDC_RADIO_DISTSOFT,0);
  72.     CheckDlgButton(IDC_RADIO_DISTSIN,0);
  73.     switch (dist->mode)
  74.     {
  75.         case HARD:
  76.             CheckDlgButton(IDC_RADIO_DISTHARD,1);
  77.             break;
  78.         case SOFT: 
  79.             CheckDlgButton(IDC_RADIO_DISTSOFT,1);
  80.             break;
  81.         case SIN:
  82.             CheckDlgButton(IDC_RADIO_DISTSIN,1);
  83.             break;
  84.     }
  85.     m_amountslider.SetPos (uFloatToInt (dist->dist));
  86.     char buffer[128];
  87.     sprintf (buffer,"%5.4f",dist->dist);
  88.     m_distamount.SetWindowText(buffer);
  89.  
  90. //    instrument->Update();
  91.     
  92. }
  93. void CInsertDist::ReadCntrlData(void)
  94. {
  95.     int am;
  96.     isDistortion *dist;
  97.     dist = (isDistortion *)insert;
  98.     am = m_amountslider.GetPos ();
  99.     dist->dist = uIntToFloat (am);    
  100.     
  101.     if (IsDlgButtonChecked(IDC_RADIO_DISTHARD))
  102.         dist->mode = HARD;
  103.     else
  104.         if (IsDlgButtonChecked(IDC_RADIO_DISTSOFT))
  105.             dist->mode = SOFT;
  106.         else
  107.             if (IsDlgButtonChecked(IDC_RADIO_DISTSIN))
  108.                 dist->mode = SIN;
  109.             else
  110.                 dist->mode = HARD;
  111.     SetCntrlData();                
  112. }
  113.  
  114. void CInsertDist::OnRadio() 
  115. {
  116.     // TODO: Add your control notification handler code here
  117.     ReadCntrlData ();    
  118. }
  119.  
  120. void CInsertDist::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
  121. {
  122.     // TODO: Add your message handler code here and/or call default
  123.     ReadCntrlData();
  124.     CInsertBaseDlg::OnHScroll(nSBCode, nPos, pScrollBar);
  125. }
  126.