1
0

dlg_misc.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. /*
  2. * dlg_misc.h
  3. * ----------
  4. * Purpose: Implementation for various OpenMPT dialogs.
  5. * Notes : (currently none)
  6. * Authors: OpenMPT Devs
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #pragma once
  10. #include "openmpt/all/BuildSettings.hpp"
  11. #include "CDecimalSupport.h"
  12. #include "ResizableDialog.h"
  13. OPENMPT_NAMESPACE_BEGIN
  14. class Version;
  15. class CSoundFile;
  16. class CModDoc;
  17. class CDLSBank;
  18. class CModTypeDlg: public CDialog
  19. {
  20. protected:
  21. CComboBox m_TypeBox, m_ChannelsBox, m_TempoModeBox, m_PlugMixBox;
  22. CButton m_CheckBox1, m_CheckBox2, m_CheckBox3, m_CheckBox4, m_CheckBox5, m_CheckBoxPT1x, m_CheckBoxFt2VolRamp, m_CheckBoxAmigaLimits;
  23. HICON m_warnIcon = nullptr;
  24. CSoundFile &sndFile;
  25. public:
  26. TempoSwing m_tempoSwing;
  27. PlayBehaviourSet m_playBehaviour;
  28. CHANNELINDEX m_nChannels = 0;
  29. MODTYPE m_nType = MOD_TYPE_NONE;
  30. bool initialized = false;
  31. public:
  32. CModTypeDlg(CSoundFile &sf, CWnd *parent) : CDialog(IDD_MODDOC_MODTYPE, parent), sndFile(sf) { }
  33. bool VerifyData();
  34. void UpdateDialog();
  35. void OnPTModeChanged();
  36. void OnTempoModeChanged();
  37. void OnTempoSwing();
  38. void OnLegacyPlaybackSettings();
  39. void OnDefaultBehaviour();
  40. protected:
  41. void UpdateChannelCBox();
  42. CString FormatVersionNumber(Version version);
  43. protected:
  44. //{{AFX_VIRTUAL(CModTypeDlg)
  45. void DoDataExchange(CDataExchange* pDX) override;
  46. BOOL OnInitDialog() override;
  47. void OnOK() override;
  48. //}}AFX_VIRTUAL
  49. BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
  50. DECLARE_MESSAGE_MAP()
  51. };
  52. class CLegacyPlaybackSettingsDlg : public ResizableDialog
  53. {
  54. protected:
  55. CCheckListBox m_CheckList;
  56. PlayBehaviourSet m_playBehaviour;
  57. MODTYPE m_modType;
  58. public:
  59. CLegacyPlaybackSettingsDlg(CWnd *parent, PlayBehaviourSet &playBehaviour, MODTYPE modType)
  60. : ResizableDialog{IDD_LEGACY_PLAYBACK, parent}
  61. , m_playBehaviour{playBehaviour}
  62. , m_modType{modType}
  63. {
  64. }
  65. PlayBehaviourSet GetPlayBehaviour() const { return m_playBehaviour; }
  66. protected:
  67. void DoDataExchange(CDataExchange* pDX) override;
  68. BOOL OnInitDialog() override;
  69. afx_msg void OnSelectDefaults();
  70. afx_msg void UpdateSelectDefaults();
  71. afx_msg void OnFilterStringChanged();
  72. DECLARE_MESSAGE_MAP()
  73. };
  74. class CRemoveChannelsDlg: public CDialog
  75. {
  76. public:
  77. CSoundFile &sndFile;
  78. std::vector<bool> m_bKeepMask;
  79. CHANNELINDEX m_nRemove;
  80. CListBox m_RemChansList;
  81. bool m_ShowCancel;
  82. public:
  83. CRemoveChannelsDlg(CSoundFile &sf, CHANNELINDEX toRemove, bool showCancel = true, CWnd *parent = nullptr)
  84. : CDialog{IDD_REMOVECHANNELS, parent}
  85. , sndFile{sf}
  86. , m_bKeepMask(sf.GetNumChannels(), true)
  87. , m_nRemove{toRemove}
  88. , m_ShowCancel{showCancel}
  89. {
  90. }
  91. protected:
  92. //{{AFX_VIRTUAL(CRemoveChannelsDlg)
  93. void DoDataExchange(CDataExchange *pDX) override;
  94. BOOL OnInitDialog() override;
  95. void OnOK() override;
  96. //}}AFX_VIRTUAL
  97. //{{AFX_MSG(CRemoveChannelsDlg)
  98. afx_msg void OnChannelChanged();
  99. //}}AFX_MSG
  100. DECLARE_MESSAGE_MAP();
  101. };
  102. class InfoDialog : protected ResizableDialog
  103. {
  104. private:
  105. mpt::winstring m_caption, m_content;
  106. public:
  107. InfoDialog(CWnd *parent = nullptr);
  108. void SetCaption(mpt::winstring caption);
  109. void SetContent(mpt::winstring content);
  110. using ResizableDialog::DoModal;
  111. protected:
  112. BOOL OnInitDialog() override;
  113. };
  114. ////////////////////////////////////////////////////////////////////////
  115. // Sound Banks
  116. class CSoundBankProperties : public InfoDialog
  117. {
  118. public:
  119. CSoundBankProperties(const CDLSBank &bank, CWnd *parent = nullptr);
  120. };
  121. /////////////////////////////////////////////////////////////////////////
  122. // Keyboard control
  123. enum
  124. {
  125. KBDNOTIFY_MOUSEMOVE=0,
  126. KBDNOTIFY_LBUTTONDOWN,
  127. KBDNOTIFY_LBUTTONUP,
  128. };
  129. class CKeyboardControl: public CWnd
  130. {
  131. public:
  132. enum
  133. {
  134. KEYFLAG_NORMAL = 0x00,
  135. KEYFLAG_REDDOT = 0x01,
  136. KEYFLAG_BRIGHTDOT = 0x02,
  137. };
  138. protected:
  139. CWnd *m_parent = nullptr;
  140. CFont m_font;
  141. int m_nOctaves = 1;
  142. int m_nSelection = -1;
  143. bool m_mouseCapture = false, m_cursorNotify = false;
  144. bool m_mouseDown = false;
  145. uint8 KeyFlags[NOTE_MAX]; // 10 octaves max
  146. SAMPLEINDEX m_sampleNum[NOTE_MAX];
  147. public:
  148. CKeyboardControl() = default;
  149. public:
  150. void Init(CWnd *parent, int octaves = 1, bool cursorNotify = false);
  151. void SetFlags(UINT key, uint8 flags) { if (key < NOTE_MAX) KeyFlags[key] = flags; }
  152. uint8 GetFlags(UINT key) const { return (key < NOTE_MAX) ? KeyFlags[key] : 0; }
  153. void SetSample(UINT key, SAMPLEINDEX sample) { if (key < NOTE_MAX) m_sampleNum[key] = sample; }
  154. SAMPLEINDEX GetSample(UINT key) const { return (key < NOTE_MAX) ? m_sampleNum[key] : 0; }
  155. protected:
  156. void DrawKey(CPaintDC &dc, const CRect rect, int key, bool black) const;
  157. afx_msg void OnDestroy();
  158. afx_msg void OnPaint();
  159. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  160. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  161. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  162. DECLARE_MESSAGE_MAP()
  163. };
  164. /////////////////////////////////////////////////////////////////////////
  165. // Sample Map
  166. class CSampleMapDlg: public CDialog
  167. {
  168. protected:
  169. enum MouseAction
  170. {
  171. mouseUnknown, // Didn't mouse-down yet
  172. mouseSet, // Set selected sample
  173. mouseUnset, // Unset (revert to original keymap)
  174. mouseZero, // Set to zero
  175. };
  176. CKeyboardControl m_Keyboard;
  177. CComboBox m_CbnSample;
  178. CSliderCtrl m_SbOctave;
  179. CSoundFile &sndFile;
  180. INSTRUMENTINDEX m_nInstrument;
  181. SAMPLEINDEX KeyboardMap[NOTE_MAX];
  182. MouseAction mouseAction;
  183. public:
  184. CSampleMapDlg(CSoundFile &sf, INSTRUMENTINDEX nInstr, CWnd *parent=NULL) : CDialog(IDD_EDITSAMPLEMAP, parent), sndFile(sf), mouseAction(mouseUnknown)
  185. { m_nInstrument = nInstr; }
  186. protected:
  187. void DoDataExchange(CDataExchange* pDX) override;
  188. BOOL OnInitDialog() override;
  189. void OnOK() override;
  190. afx_msg void OnUpdateSamples();
  191. afx_msg void OnUpdateKeyboard();
  192. afx_msg void OnUpdateOctave();
  193. afx_msg void OnHScroll(UINT, UINT, CScrollBar *);
  194. afx_msg LRESULT OnKeyboardNotify(WPARAM, LPARAM);
  195. DECLARE_MESSAGE_MAP()
  196. };
  197. /////////////////////////////////////////////////////////////////////////
  198. // Edit history dialog
  199. class CEditHistoryDlg: public ResizableDialog
  200. {
  201. protected:
  202. CModDoc &m_modDoc;
  203. public:
  204. CEditHistoryDlg(CWnd *parent, CModDoc &modDoc)
  205. : ResizableDialog(IDD_EDITHISTORY, parent), m_modDoc(modDoc) {}
  206. protected:
  207. BOOL OnInitDialog() override;
  208. afx_msg void OnClearHistory();
  209. DECLARE_MESSAGE_MAP()
  210. };
  211. /////////////////////////////////////////////////////////////////////////
  212. // Generic input dialog
  213. class CInputDlg: public CDialog
  214. {
  215. protected:
  216. CNumberEdit m_edit;
  217. CSpinButtonCtrl m_spin;
  218. CString m_description;
  219. double m_minValueDbl = 0.0, m_maxValueDbl = 0.0;
  220. int32 m_minValueInt = 0, m_maxValueInt = 0;
  221. int32 m_maxLength = 0;
  222. public:
  223. int32 resultAsInt = 0;
  224. double resultAsDouble = 0.0;
  225. CString resultAsString;
  226. public:
  227. // Initialize text input box
  228. CInputDlg(CWnd *parent, const TCHAR *desc, const TCHAR *defaultString, int32 maxLength = -1) : CDialog(IDD_INPUT, parent)
  229. , m_description(desc)
  230. , m_maxLength(maxLength)
  231. , resultAsString(defaultString)
  232. { }
  233. // Initialize numeric input box (float)
  234. CInputDlg(CWnd *parent, const TCHAR *desc, double minVal, double maxVal, double defaultNumber) : CDialog(IDD_INPUT, parent)
  235. , m_description(desc)
  236. , m_minValueDbl(minVal), m_maxValueDbl(maxVal)
  237. , resultAsDouble(defaultNumber)
  238. { }
  239. CInputDlg(CWnd *parent, const TCHAR *desc, float minVal, float maxVal, float defaultNumber) : CDialog(IDD_INPUT, parent)
  240. , m_description(desc)
  241. , m_minValueDbl(minVal), m_maxValueDbl(maxVal)
  242. , resultAsDouble(defaultNumber)
  243. { }
  244. // Initialize numeric input box (int)
  245. CInputDlg(CWnd *parent, const TCHAR *desc, int32 minVal, int32 maxVal, int32 defaultNumber) : CDialog(IDD_INPUT, parent)
  246. , m_description(desc)
  247. , m_minValueInt(minVal), m_maxValueInt(maxVal)
  248. , resultAsInt(defaultNumber)
  249. { }
  250. protected:
  251. void DoDataExchange(CDataExchange *pDX) override;
  252. BOOL OnInitDialog() override;
  253. void OnOK() override;
  254. };
  255. /////////////////////////////////////////////////////////////////////////
  256. // Messagebox with 'don't show again'-option.
  257. // Enums for message entries. See dlg_misc.cpp for the array of entries.
  258. enum enMsgBoxHidableMessage
  259. {
  260. ModSaveHint = 0,
  261. ItCompatibilityExportTip = 1,
  262. ConfirmSignUnsignWhenPlaying = 2,
  263. XMCompatibilityExportTip = 3,
  264. CompatExportDefaultWarning = 4,
  265. enMsgBoxHidableMessage_count
  266. };
  267. void MsgBoxHidable(enMsgBoxHidableMessage enMsg);
  268. OPENMPT_NAMESPACE_END