PatternFindReplaceDlg.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * PatternFindReplaceDlg.h
  3. * -----------------------
  4. * Purpose: The find/replace dialog for pattern data.
  5. * Notes : (currently none)
  6. * Authors: Olivier Lapicque
  7. * OpenMPT Devs
  8. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  9. */
  10. #pragma once
  11. #include "openmpt/all/BuildSettings.hpp"
  12. #include "EffectInfo.h"
  13. #include "PatternCursor.h"
  14. OPENMPT_NAMESPACE_BEGIN
  15. /////////////////////////////////////////////////////////////////////////
  16. // Search/Replace
  17. struct FindReplace;
  18. class CFindReplaceTab: public CPropertyPage
  19. {
  20. protected:
  21. CComboBox m_cbnNote, m_cbnInstr, m_cbnVolCmd, m_cbnVolume, m_cbnCommand, m_cbnParam, m_cbnPCParam;
  22. CSoundFile &m_sndFile;
  23. FindReplace &m_settings;
  24. EffectInfo m_effectInfo;
  25. ModCommand m_initialValues;
  26. bool m_isReplaceTab;
  27. // Special ItemData values
  28. enum
  29. {
  30. kFindAny = INT_MAX - 1,
  31. kFindRange = INT_MAX - 2,
  32. kReplaceRelative = INT_MAX - 3,
  33. kReplaceMultiply = INT_MAX - 4,
  34. kReplaceNoteMinusOne = INT_MAX - 5,
  35. kReplaceNotePlusOne = INT_MAX - 6,
  36. kReplaceNoteMinusOctave = INT_MAX - 7,
  37. kReplaceNotePlusOctave = INT_MAX - 8,
  38. kReplaceInstrumentMinusOne = INT_MAX - 5,
  39. kReplaceInstrumentPlusOne = INT_MAX - 6,
  40. };
  41. public:
  42. CFindReplaceTab(UINT nIDD, bool isReplaceTab, CSoundFile &sf, FindReplace &settings, const ModCommand &initialValues)
  43. : CPropertyPage(nIDD)
  44. , m_sndFile(sf)
  45. , m_settings(settings)
  46. , m_effectInfo(sf)
  47. , m_initialValues(initialValues)
  48. , m_isReplaceTab(isReplaceTab)
  49. { }
  50. protected:
  51. BOOL OnInitDialog() override;
  52. void OnOK() override;
  53. void DoDataExchange(CDataExchange* pDX) override;
  54. bool IsPCEvent() const;
  55. void UpdateInstrumentList();
  56. void UpdateVolumeList();
  57. void UpdateParamList();
  58. // When a combobox is focussed, check the corresponding checkbox.
  59. void CheckOnChange(int nIDButton) { CheckDlgButton(nIDButton, BST_CHECKED); CheckReplace(nIDButton); };
  60. afx_msg void OnNoteChanged();
  61. afx_msg void OnInstrChanged();
  62. afx_msg void OnVolCmdChanged() { CheckOnChange(IDC_CHECK3); UpdateVolumeList(); };
  63. afx_msg void OnVolumeChanged();
  64. afx_msg void OnEffectChanged() { CheckOnChange(IDC_CHECK5); UpdateParamList(); };
  65. afx_msg void OnParamChanged();
  66. afx_msg void OnPCParamChanged();
  67. // When a checkbox is checked, also check "Replace By".
  68. afx_msg void OnCheckNote() { CheckReplace(IDC_CHECK1); };
  69. afx_msg void OnCheckInstr() { CheckReplace(IDC_CHECK2); };
  70. afx_msg void OnCheckVolCmd() { CheckReplace(IDC_CHECK3); };
  71. afx_msg void OnCheckVolume() { CheckReplace(IDC_CHECK4); };
  72. afx_msg void OnCheckEffect() { CheckReplace(IDC_CHECK5); };
  73. afx_msg void OnCheckParam() { CheckReplace(IDC_CHECK6); };
  74. // Check "Replace By"
  75. afx_msg void CheckReplace(int nIDButton) { if(m_isReplaceTab && IsDlgButtonChecked(nIDButton)) CheckDlgButton(IDC_CHECK7, BST_CHECKED); };
  76. afx_msg void OnCheckChannelSearch();
  77. void RelativeOrMultiplyPrompt(CComboBox &comboBox, FindReplace::ReplaceMode &action, int &value, int range, bool isHex);
  78. DECLARE_MESSAGE_MAP()
  79. };
  80. OPENMPT_NAMESPACE_END