2 * @file DirSelectFilesDlg.cpp
4 * @brief Implementation of the DirSelectFilesDlg dialog.
8 #include "DirSelectFilesDlg.h"
15 class DirSelectFilesDlg::Impl : public CTrDialog
19 explicit Impl(DirSelectFilesDlg *p, CWnd* pParent = nullptr); // standard constructor
22 //{{AFX_DATA(DirSelectFilesDlg)
23 enum { IDD = IDD_SELECT_FILES_OR_FOLDERS };
27 // ClassWizard generated virtual function overrides
28 //{{AFX_VIRTUAL(DirSelectFilesDlg)
30 virtual BOOL OnInitDialog() override;
31 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
37 // Generated message map functions
38 //{{AFX_MSG(DirSelectFilesDlg)
39 // NOTE: the ClassWizard will add member functions here
40 afx_msg void OnBnClicked(UINT id);
41 afx_msg void OnBnClickedResetButton();
46 void UpdateButtonCaptions();
47 DirSelectFilesDlg *m_p;
50 /////////////////////////////////////////////////////////////////////////////
51 // DirSelectFilesDlg dialog
56 DirSelectFilesDlg::Impl::Impl(DirSelectFilesDlg *p, CWnd* pParent /*= nullptr*/)
57 : CTrDialog(DirSelectFilesDlg::Impl::IDD, pParent), m_p(p)
61 void DirSelectFilesDlg::Impl::DoDataExchange(CDataExchange* pDX)
63 CTrDialog::DoDataExchange(pDX);
64 //{{AFX_DATA_MAP(DirSelectFilesDlg)
68 BEGIN_MESSAGE_MAP(DirSelectFilesDlg::Impl, CTrDialog)
69 //{{AFX_MSG_MAP(DirSelectFilesDlg::Impl)
70 // NOTE: the ClassWizard will add message map macros here
71 ON_CONTROL_RANGE(BN_CLICKED, IDC_LEFT1, IDC_LEFT1 + 3 * 3, OnBnClicked)
72 ON_BN_CLICKED(IDC_RESET, OnBnClickedResetButton)
76 /////////////////////////////////////////////////////////////////////////////
77 // DirSelectFilesDlg message handlers
79 BOOL DirSelectFilesDlg::Impl::OnInitDialog()
82 LangTranslateDialog(m_hWnd);
83 CDialog::OnInitDialog();
84 for (int i = 0; i < 3; ++i)
87 SetDlgItemText(IDC_FIRST + i, m_p->m_pdi[i]->diffFileInfo[0].GetFile());
88 for (int j = 0; j < 3; ++j)
89 GetDlgItem(IDC_LEFT1 + i * 3 + j)->ShowWindow(m_p->m_pdi[i] && m_p->m_pdi[i]->diffcode.exists(j));
94 void DirSelectFilesDlg::Impl::OnBnClicked(UINT id)
96 std::vector<int>& selectedButtons = m_p->m_selectedButtons;
98 GetDlgItemText(id, text);
100 selectedButtons.erase(std::find(selectedButtons.begin(), selectedButtons.end(), static_cast<int>(id - IDC_LEFT1)));
102 selectedButtons.push_back(id - IDC_LEFT1);
103 if (selectedButtons.size() > 3)
104 selectedButtons.erase(selectedButtons.begin());
105 UpdateButtonCaptions();
108 void DirSelectFilesDlg::Impl::OnBnClickedResetButton()
110 m_p->m_selectedButtons.clear();
111 UpdateButtonCaptions();
114 void DirSelectFilesDlg::Impl::UpdateButtonCaptions()
116 for (int i = 0; i < 9; ++i)
118 SetDlgItemText(IDC_LEFT1 + i, _T(""));
121 for (int i: m_p->m_selectedButtons)
123 SetDlgItemText(IDC_LEFT1 + i, strutils::to_str(c));
128 DirSelectFilesDlg::DirSelectFilesDlg() : m_pimpl(new DirSelectFilesDlg::Impl(this)) {}
129 DirSelectFilesDlg::~DirSelectFilesDlg() {}
130 int DirSelectFilesDlg::DoModal() { return static_cast<int>(m_pimpl->DoModal()); }