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.

126 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 < 2)
  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[4] = { "Quantize Off","Quantize Start Time","Quantize Duration",
  53. "Quantize Start and Duration"};
  54. static char *pTimeUnit[DMUS_TIME_UNIT_COUNT-1] = {
  55. "Music Clicks","Grid", "Beat","Bar",
  56. "64th note triplets", "64th notes",
  57. "32nd note triplets",
  58. "32nd notes","16th note triplets","16th notes",
  59. "8th note triplets","8th notes","Quarter note triplets",
  60. "Quarter notes","Half note triplets","Half notes",
  61. "Whole note triplets", "Whole notes"
  62. };
  63. m_ctStrength.Init(GetDlgItem(IDC_STRENGTH),GetDlgItem(IDC_STRENGTH_DISPLAY),0,120,true);
  64. m_ctResolution.Init(GetDlgItem(IDC_RESOLUTION),GetDlgItem(IDC_RESOLUTION_DISPLAY),0,12,true);
  65. m_ctType.Init(GetDlgItem(IDC_TYPE),IDC_TYPE,pTypes,4);
  66. m_ctTimeUnit.Init(GetDlgItem(IDC_TIMEUNIT),IDC_TIMEUNIT,pTimeUnit,DMUS_TIME_UNIT_COUNT-1);
  67. DWORD dwValue;
  68. m_pQuantize->GetType(&dwValue);
  69. m_ctType.SetValue(dwValue);
  70. m_pQuantize->GetTimeUnit(&dwValue);
  71. m_ctTimeUnit.SetValue(dwValue-1);
  72. SetTimeUnitRange();
  73. m_pQuantize->GetStrength(&dwValue);
  74. m_ctStrength.SetValue((float)dwValue);
  75. m_pQuantize->GetResolution(&dwValue);
  76. m_ctResolution.SetValue((float)dwValue);
  77. }
  78. return 1;
  79. }
  80. LRESULT CQuantizePage::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  81. {
  82. LRESULT lr = m_ctStrength.MessageHandler(uMsg, wParam,lParam, bHandled);
  83. if (!bHandled)
  84. lr = m_ctResolution.MessageHandler(uMsg, wParam, lParam, bHandled);
  85. if (!bHandled)
  86. lr = m_ctType.MessageHandler(uMsg, wParam, lParam, bHandled);
  87. if (!bHandled)
  88. {
  89. lr = m_ctTimeUnit.MessageHandler(uMsg, wParam, lParam, bHandled);
  90. if (bHandled)
  91. {
  92. SetTimeUnitRange();
  93. }
  94. }
  95. if (bHandled)
  96. SetDirty(true);
  97. return lr;
  98. }
  99. LRESULT CQuantizePage::OnSlider(UINT uMsg, WPARAM wParam,LPARAM lParam, BOOL& bHandled)
  100. {
  101. LRESULT lr = m_ctStrength.MessageHandler(uMsg, wParam,lParam, bHandled);
  102. if (!bHandled)
  103. lr = m_ctResolution.MessageHandler(uMsg, wParam, lParam, bHandled);
  104. if (bHandled)
  105. SetDirty(true);
  106. return lr;
  107. }