xref: /MusicPlayer2/MusicPlayer2/LyricEditDlg.h (revision 00e48540d1689baaa616c1d1b9aa46f588634187)
1 #pragma once
2 #include "Time.h"
3 #include "EditEx.h"
4 #include "BaseDialog.h"
5 #include "ScintillaEditView.h"
6 #include "Lyric.h"
7 
8 const int WM_FINDREPLACE = ::RegisterWindowMessage(FINDMSGSTRING);	//将FINDMSGSTRING注册为WM_FINDREPLACE消息
9 
10 // CLyricEditDlg 对话框
11 
12 class CLyricEditDlg : public CBaseDialog
13 {
14     DECLARE_DYNAMIC(CLyricEditDlg)
15 
16 public:
17     //定义操作时间标签的枚举
18     enum class TagOpreation
19     {
20         INSERT,		//插入
21         REPLACE,	//替换
22         DELETE_		//删除
23     };
24 
25     bool m_dlg_exist{ false };		//如果对话框存在,则为true
26 
27     CLyricEditDlg(CWnd* pParent = NULL);   // 标准构造函数
28     virtual ~CLyricEditDlg();
29 
30     // 对话框数据
31 #ifdef AFX_DESIGN_TIME
32     enum { IDD = IDD_LYRIC_EDIT_DIALOG };
33 #endif
34 
35 protected:
36     wstring m_lyric_string;		//歌词字符串
37     wstring m_lyric_path;		//歌词路径
38     wstring m_original_lyric_path;	//原来的歌词(当前播放歌曲对应的歌词)的路径
39     CodeType m_code_type;		//歌词编码
40     SongInfo m_current_edit_song;           // 启动歌词编辑的SongInfo
41     CLyrics::LyricType m_lyric_type{};
42     bool m_modified{ false };	//如果歌词已更改,则为true
43     bool m_lyric_saved{ false };	//如果执行过保存操作,则为true
44     bool m_inner_lyric{ false };
45 
46     //CToolTipCtrl m_Mytip;		//鼠标提示
47     CStatusBarCtrl m_status_bar;	//状态栏
48     CToolBar m_wndToolBar;		//工具栏
49 #define MARGIN theApp.DPI(8)
50 #define TOOLBAR_HEIGHT theApp.DPI(29)
51 #define STATUSBAR_HEIGHT theApp.DPI(20)
52 
53     CScintillaEditView* m_view{};
54 
55     CFindReplaceDialog* m_pFindDlg{};   //查找对话框
56     CFindReplaceDialog* m_pReplaceDlg{};    //替换对话框
57     wstring m_find_str;		//查找的字符串
58     wstring m_replace_str;	//替换的字符串
59     int m_find_index{ -1 };	//查找的字符串的索引
60     bool m_find_down{ true };		//是否向后查找
61     bool m_find_flag{ false };
62 
63     void OpreateTag(TagOpreation operation);
64     bool SaveLyric(wstring path, CodeType code_type);
65     void UpdateStatusbarInfo();			//更新状态栏信息
66     void StatusBarSetParts(int width);			//设置状态栏各部分的宽度
67     void OpenLyric(const wchar_t* path);		//打开一个歌词文件
68     bool SaveInquiry();
69     void SetLyricPathEditText();
70     CRect CalculateEditCtrlRect();
71     void SetToolbarCmdEnable();
72 
73     virtual CString GetDialogName() const override;
74     virtual bool InitializeControls() override;
75     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持
76 
77     DECLARE_MESSAGE_MAP()
78 public:
79     virtual BOOL OnInitDialog();
80     virtual void OnCancel();
81 public:
82     //afx_msg void OnBnClickedInsertTagButton();
83     //afx_msg void OnBnClickedReplaceTagButton();
84     //afx_msg void OnBnClickedDeleteTag();
85     //afx_msg void OnBnClickedSaveLyricButton();
86 //	afx_msg void OnBnClickedSaveAsButton5();
87     afx_msg void OnDestroy();
88     virtual BOOL PreTranslateMessage(MSG* pMsg);
89     afx_msg void OnClose();
90     //	afx_msg void OnBnClickedOpenLyricButton();
91     afx_msg void OnLyricOpen();
92     afx_msg void OnLyricSave();
93     afx_msg void OnLyricSaveAs();
94     afx_msg void OnLyricFind();
95     afx_msg void OnLyricReplace();
96 protected:
97     afx_msg LRESULT OnFindReplace(WPARAM wParam, LPARAM lParam);
98 public:
99     afx_msg void OnFindNext();
100     afx_msg void OnSize(UINT nType, int cx, int cy);
101     afx_msg void OnLeTranslateToSimplifiedChinese();
102     afx_msg void OnLeTranslateToTranditionalChinese();
103     afx_msg void OnLyricInsertTag();
104     afx_msg void OnLyricReplaceTag();
105     afx_msg void OnLyricDeleteTag();
106     afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult);
107     afx_msg void OnLryicMergeSameTimeTag();
108     afx_msg void OnLyricSwapTextAndTranslation();
109     afx_msg void OnLyricTimeTagForward();
110     afx_msg void OnLyricTimeTagDelay();
111     virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
112     afx_msg void OnSeekToCurLine();
113     afx_msg void OnInitMenu(CMenu* pMenu);
114     afx_msg void OnLyricAndTranslationInSameLine();
115     afx_msg void OnLyricAndTranslationInDifferentLine();
116 };
117