Apply backgroundcolors.patch
[TortoiseGit.git] / src / TortoiseMerge / RegexFilterDlg.cpp
blobf1fc4bafb0b07cf13c82d8325c6fb3acd7e02275
1 // TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2013-2014, 2016, 2020 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "stdafx.h"
20 #include "TortoiseMerge.h"
21 #include "RegexFilterDlg.h"
22 #include <afxdialogex.h>
23 #include <regex>
26 // CRegexFilterDlg dialog
28 IMPLEMENT_DYNAMIC(CRegexFilterDlg, CStandAloneDialog)
30 CRegexFilterDlg::CRegexFilterDlg(CWnd* pParent /*=nullptr*/)
31 : CStandAloneDialog(CRegexFilterDlg::IDD, pParent)
35 CRegexFilterDlg::~CRegexFilterDlg()
39 void CRegexFilterDlg::DoDataExchange(CDataExchange* pDX)
41 CStandAloneDialog::DoDataExchange(pDX);
42 DDX_Text(pDX, IDC_NAME, m_sName);
43 DDX_Text(pDX, IDC_REGEX, m_sRegex);
44 DDX_Text(pDX, IDC_REPLACE, m_sReplace);
48 BEGIN_MESSAGE_MAP(CRegexFilterDlg, CStandAloneDialog)
49 END_MESSAGE_MAP()
52 // CRegexFilterDlg message handlers
55 BOOL CRegexFilterDlg::OnInitDialog()
57 CStandAloneDialog::OnInitDialog();
59 UpdateData(FALSE);
61 GetDlgItem(IDC_NAME)->SetFocus();
62 return FALSE; // return TRUE unless you set the focus to a control
63 // EXCEPTION: OCX Property Pages should return FALSE
66 void CRegexFilterDlg::OnOK()
68 UpdateData();
70 try
72 std::wregex r1 = std::wregex(m_sRegex);
73 UNREFERENCED_PARAMETER(r1);
75 catch (std::exception&)
77 ShowEditBalloon(IDC_REGEX, IDS_ERR_INVALIDREGEX, IDS_ERR_ERROR);
78 return;
81 __super::OnOK();
84 void CRegexFilterDlg::ShowEditBalloon(UINT nIdControl, UINT nIdText, UINT nIdTitle, int nIcon)
86 CString text = CString(MAKEINTRESOURCE(nIdText));
87 CString title = CString(MAKEINTRESOURCE(nIdTitle));
88 EDITBALLOONTIP bt;
89 bt.cbStruct = sizeof(bt);
90 bt.pszText = text;
91 bt.pszTitle = title;
92 bt.ttiIcon = nIcon;
93 SendDlgItemMessage(nIdControl, EM_SHOWBALLOONTIP, 0, reinterpret_cast<LPARAM>(&bt));