Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
3.7 KiB

  1. // QuantizePage.cpp : Implementation of CQuantizePage
  2. #include "stdafx.h"
  3. #include "ToolProps.h"
  4. #include "QuantizePage.h"
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CQuantizePage
  7. CQuantizePage::CQuantizePage()
  8. {
  9. m_dwTitleID = IDS_TITLEQuantizePage;
  10. m_dwHelpFileID = IDS_HELPFILEQuantizePage;
  11. m_dwDocStringID = IDS_DOCSTRINGQuantizePage;
  12. m_pQuantize = NULL;
  13. }
  14. CQuantizePage::~CQuantizePage()
  15. {
  16. if (m_pQuantize)
  17. {
  18. m_pQuantize->Release();
  19. }
  20. }
  21. STDMETHODIMP CQuantizePage::SetObjects(ULONG cObjects,IUnknown **ppUnk)
  22. {
  23. if (cObjects < 1 || cObjects > 1)
  24. return E_UNEXPECTED;
  25. return ppUnk[0]->QueryInterface(IID_IDirectMusicQuantizeTool,(void **) &m_pQuantize);
  26. }
  27. STDMETHODIMP CQuantizePage::Apply(void)
  28. {
  29. m_pQuantize->SetStrength((DWORD) m_ctStrength.GetValue());
  30. m_pQuantize->SetResolution((DWORD) m_ctResolution.GetValue());
  31. m_pQuantize->SetType(m_ctType.GetValue());
  32. m_pQuantize->SetTimeUnit(m_ctTimeUnit.GetValue()+1);
  33. m_bDirty = FALSE;
  34. return S_OK;
  35. }
  36. void CQuantizePage::SetTimeUnitRange()
  37. {
  38. DWORD dwRes = m_ctTimeUnit.GetValue();
  39. if (dwRes < 1)
  40. {
  41. m_ctResolution.SetRange(0,1000);
  42. }
  43. else
  44. {
  45. m_ctResolution.SetRange(0,12);
  46. }
  47. }
  48. LRESULT CQuantizePage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  49. {
  50. if (m_pQuantize)
  51. {
  52. static char *pTypes[3] = { "Quantize Start Time","Quantize Duration","Quantize Start and Duration"};
  53. static char *pTimeUnit[DMUS_TIME_UNIT_COUNT-1] = {
  54. "Music Clicks","Grid", "Beat","Bar",
  55. "64th note triplets", "64th notes",
  56. "32nd note triplets",
  57. "32nd notes","16th note triplets","16th notes",
  58. "8th note triplets","8th notes","Quarter note triplets",
  59. "Quarter notes","Half note triplets","Half notes",
  60. "Whole note triplets", "Whole notes"
  61. };
  62. m_ctStrength.Init(GetDlgItem(IDC_STRENGTH),GetDlgItem(IDC_STRENGTH_DISPLAY),0,120,true);
  63. m_ctResolution.Init(GetDlgItem(IDC_RESOLUTION),GetDlgItem(IDC_RESOLUTION_DISPLAY),0,12,true);
  64. m_ctType.Init(GetDlgItem(IDC_TYPE),IDC_TYPE,pTypes,3);
  65. m_ctTimeUnit.Init(GetDlgItem(IDC_TIMEUNIT),IDC_TIMEUNIT,pTimeUnit,DMUS_TIME_UNIT_COUNT-1);
  66. DWORD dwValue;
  67. m_pQuantize->GetType(&dwValue);
  68. m_ctType.SetValue(dwValue);
  69. m_pQuantize->GetTimeUnit(&dwValue);
  70. m_ctTimeUnit.SetValue(dwValue-1);
  71. SetTimeUnitRange();
  72. m_pQuantize->GetStrength(&dwValue);
  73. m_ctStrength.SetValue((float)dwValue);
  74. m_pQuantize->GetResolution(&dwValue);
  75. m_ctResolution.SetValue((float)dwValue);
  76. }
  77. return 1;
  78. }
  79. LRESULT CQuantizePage::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  80. {
  81. LRESULT lr = m_ctStrength.MessageHandler(uMsg, wParam,lParam, bHandled);
  82. if (!bHandled)
  83. lr = m_ctResolution.MessageHandler(uMsg, wParam, lParam, bHandled);
  84. if (!bHandled)
  85. lr = m_ctType.MessageHandler(uMsg, wParam, lParam, bHandled);
  86. if (!bHandled)
  87. {
  88. lr = m_ctTimeUnit.MessageHandler(uMsg, wParam, lParam, bHandled);
  89. if (bHandled)
  90. {
  91. SetTimeUnitRange();
  92. }
  93. }
  94. if (bHandled)
  95. SetDirty(true);
  96. return lr;
  97. }
  98. LRESULT CQuantizePage::OnSlider(UINT uMsg, WPARAM wParam,LPARAM lParam, BOOL& bHandled)
  99. {
  100. LRESULT lr = m_ctStrength.MessageHandler(uMsg, wParam,lParam, bHandled);
  101. if (!bHandled)
  102. lr = m_ctResolution.MessageHandler(uMsg, wParam, lParam, bHandled);
  103. if (bHandled)
  104. SetDirty(true);
  105. return lr;
  106. }