OSDN Git Service

Modify the "Go to" dialog. (#1779)
authorJun Tajima <56220423+tjmprm77@users.noreply.github.com>
Sun, 26 Mar 2023 04:53:33 +0000 (13:53 +0900)
committerGitHub <noreply@github.com>
Sun, 26 Mar 2023 04:53:33 +0000 (13:53 +0900)
- Disable the "Middle" radio button when doing 2-way file comparisons.

Src/MergeEditView.cpp
Src/WMGotoDlg.cpp
Src/WMGotoDlg.h

index 7c58add..2690570 100644 (file)
@@ -3029,6 +3029,7 @@ void CMergeEditView::OnWMGoto()
        dlg.m_strParam = strutils::to_str(nRealLine + 1);
        dlg.m_nFile = (pDoc->m_nBuffers < 3) ? (m_nThisPane == 1 ? 2 : 0) : m_nThisPane;
        dlg.m_nGotoWhat = 0;
+       dlg.m_nFiles = pDoc->m_nBuffers;
 
        if (dlg.DoModal() == IDOK)
        {
index 2144043..144d617 100644 (file)
@@ -35,6 +35,7 @@ public:
        // ClassWizard generated virtual function overrides
        //{{AFX_VIRTUAL(WMGotoDlg)
        protected:
+       virtual BOOL OnInitDialog() override;
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
        //}}AFX_VIRTUAL
 
@@ -62,6 +63,21 @@ WMGotoDlg::Impl::Impl(WMGotoDlg *p, CWnd* pParent /*= nullptr*/)
 {
 }
 
+/**
+ * @brief Initialize the dialog.
+ * @return Always TRUE.
+ */
+BOOL WMGotoDlg::Impl::OnInitDialog()
+{
+       LangTranslateDialog(m_hWnd);
+       CDialog::OnInitDialog();
+
+       if (m_p->m_nFiles < 3)
+               EnableDlgItem(IDC_WMGOTO_FILEMIDDLE, false);
+
+       return TRUE;
+}
+
 void WMGotoDlg::Impl::DoDataExchange(CDataExchange* pDX)
 {
        CTrDialog::DoDataExchange(pDX);
@@ -85,7 +101,7 @@ END_MESSAGE_MAP()
 
 
 WMGotoDlg::WMGotoDlg()
-       : m_pimpl(new WMGotoDlg::Impl(this)), m_nFile(-1), m_nGotoWhat(-1) {}
+       : m_pimpl(new WMGotoDlg::Impl(this)), m_nFile(-1), m_nGotoWhat(-1), m_nFiles(-1) {}
 WMGotoDlg::~WMGotoDlg() = default;
 int WMGotoDlg::DoModal() { return static_cast<int>(m_pimpl->DoModal()); }
 
index 9e7133e..bb9d68b 100644 (file)
@@ -21,6 +21,7 @@ public:
        String m_strParam;   /**< Line/difference number. */
        int m_nFile;         /**< Target file number. */
        int m_nGotoWhat;     /**< Goto line or difference? */
+       int m_nFiles;        /**< Number of files being compared. */
 private:
        WMGotoDlg(const WMGotoDlg &) = delete;
        WMGotoDlg & operator=(const WMGotoDlg &) = delete;