Cleanup: Drop unnecessary method definitions
[TortoiseGit.git] / src / TortoiseProc / Settings / SettingsProgsDiff.cpp
blob70804b21de1ba0b4f6fba5aa2178c58661a0a71a
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2011 - TortoiseGit
4 // Copyright (C) 2003-2007,2011 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include "TortoiseProc.h"
22 #include "AppUtils.h"
23 #include "StringUtils.h"
24 #include ".\settingsprogsdiff.h"
27 IMPLEMENT_DYNAMIC(CSettingsProgsDiff, ISettingsPropPage)
28 CSettingsProgsDiff::CSettingsProgsDiff()
29 : ISettingsPropPage(CSettingsProgsDiff::IDD)
30 , m_dlgAdvDiff(_T("Diff"))
31 , m_iExtDiff(0)
32 , m_sDiffPath(_T(""))
33 , m_sDiffViewerPath(_T(""))
34 , m_iDiffViewer(0)
36 m_regDiffPath = CRegString(_T("Software\\TortoiseGit\\Diff"));
37 m_regDiffViewerPath = CRegString(_T("Software\\TortoiseGit\\DiffViewer"));
40 CSettingsProgsDiff::~CSettingsProgsDiff()
44 void CSettingsProgsDiff::DoDataExchange(CDataExchange* pDX)
46 ISettingsPropPage::DoDataExchange(pDX);
47 DDX_Text(pDX, IDC_EXTDIFF, m_sDiffPath);
48 DDX_Radio(pDX, IDC_EXTDIFF_OFF, m_iExtDiff);
49 DDX_Text(pDX, IDC_DIFFVIEWER, m_sDiffViewerPath);
50 DDX_Radio(pDX, IDC_DIFFVIEWER_OFF, m_iDiffViewer);
52 GetDlgItem(IDC_EXTDIFF)->EnableWindow(m_iExtDiff == 1);
53 GetDlgItem(IDC_EXTDIFFBROWSE)->EnableWindow(m_iExtDiff == 1);
54 GetDlgItem(IDC_DIFFVIEWER)->EnableWindow(m_iDiffViewer == 1);
55 GetDlgItem(IDC_DIFFVIEWERBROWSE)->EnableWindow(m_iDiffViewer == 1);
56 DDX_Control(pDX, IDC_EXTDIFF, m_cDiffEdit);
57 DDX_Control(pDX, IDC_DIFFVIEWER, m_cUnifiedDiffEdit);
61 BEGIN_MESSAGE_MAP(CSettingsProgsDiff, ISettingsPropPage)
62 ON_BN_CLICKED(IDC_EXTDIFF_OFF, OnBnClickedExtdiffOff)
63 ON_BN_CLICKED(IDC_EXTDIFF_ON, OnBnClickedExtdiffOn)
64 ON_BN_CLICKED(IDC_EXTDIFFBROWSE, OnBnClickedExtdiffbrowse)
65 ON_BN_CLICKED(IDC_EXTDIFFADVANCED, OnBnClickedExtdiffadvanced)
66 ON_EN_CHANGE(IDC_EXTDIFF, OnEnChangeExtdiff)
67 ON_BN_CLICKED(IDC_DIFFVIEWER_OFF, OnBnClickedDiffviewerOff)
68 ON_BN_CLICKED(IDC_DIFFVIEWER_ON, OnBnClickedDiffviewerOn)
69 ON_BN_CLICKED(IDC_DIFFVIEWERBROWSE, OnBnClickedDiffviewerbrowse)
70 ON_EN_CHANGE(IDC_DIFFVIEWER, OnEnChangeDiffviewer)
71 END_MESSAGE_MAP()
74 BOOL CSettingsProgsDiff::OnInitDialog()
76 EnableToolTips();
78 m_sDiffPath = m_regDiffPath;
79 m_iExtDiff = IsExternal(m_sDiffPath);
81 SHAutoComplete(::GetDlgItem(m_hWnd, IDC_EXTDIFF), SHACF_FILESYSTEM | SHACF_FILESYS_ONLY);
83 m_sDiffViewerPath = m_regDiffViewerPath;
84 m_iDiffViewer = IsExternal(m_sDiffViewerPath);
86 SHAutoComplete(::GetDlgItem(m_hWnd, IDC_DIFFVIEWER), SHACF_FILESYSTEM | SHACF_FILESYS_ONLY);
88 m_tooltips.Create(this);
89 m_tooltips.AddTool(IDC_EXTDIFF, IDS_SETTINGS_EXTDIFF_TT);
90 m_tooltips.AddTool(IDC_DIFFVIEWER, IDS_SETTINGS_DIFFVIEWER_TT);
92 UpdateData(FALSE);
93 return TRUE;
96 BOOL CSettingsProgsDiff::PreTranslateMessage(MSG* pMsg)
98 m_tooltips.RelayEvent(pMsg);
99 return ISettingsPropPage::PreTranslateMessage(pMsg);
102 BOOL CSettingsProgsDiff::OnApply()
104 UpdateData();
105 if (m_iExtDiff == 0 && !m_sDiffPath.IsEmpty() && m_sDiffPath.Left(1) != _T("#"))
107 m_sDiffPath = _T("#") + m_sDiffPath;
109 m_regDiffPath = m_sDiffPath;
111 m_dlgAdvDiff.SaveData();
113 if (m_iDiffViewer == 0 && !m_sDiffViewerPath.IsEmpty() && m_sDiffViewerPath.Left(1) != _T("#"))
114 m_sDiffViewerPath = _T("#") + m_sDiffViewerPath;
116 m_regDiffViewerPath = m_sDiffViewerPath;
118 SetModified(FALSE);
119 return ISettingsPropPage::OnApply();
122 void CSettingsProgsDiff::OnBnClickedExtdiffOff()
124 m_iExtDiff = 0;
125 SetModified();
126 GetDlgItem(IDC_EXTDIFF)->EnableWindow(false);
127 GetDlgItem(IDC_EXTDIFFBROWSE)->EnableWindow(false);
128 CheckProgComment();
131 void CSettingsProgsDiff::OnBnClickedExtdiffOn()
133 m_iExtDiff = 1;
134 SetModified();
135 GetDlgItem(IDC_EXTDIFF)->EnableWindow(true);
136 GetDlgItem(IDC_EXTDIFFBROWSE)->EnableWindow(true);
137 GetDlgItem(IDC_EXTDIFF)->SetFocus();
138 CheckProgComment();
141 void CSettingsProgsDiff::OnBnClickedExtdiffbrowse()
143 if (CAppUtils::FileOpenSave(m_sDiffPath, NULL, IDS_SETTINGS_SELECTDIFF, IDS_PROGRAMSFILEFILTER, true, m_hWnd))
145 UpdateData(FALSE);
146 SetModified();
150 void CSettingsProgsDiff::OnBnClickedExtdiffadvanced()
152 if (m_dlgAdvDiff.DoModal() == IDOK)
153 SetModified();
156 void CSettingsProgsDiff::OnEnChangeExtdiff()
158 SetModified();
161 void CSettingsProgsDiff::CheckProgComment()
163 UpdateData();
164 if (m_iExtDiff == 0 && !m_sDiffPath.IsEmpty() && m_sDiffPath.Left(1) != _T("#"))
165 m_sDiffPath = _T("#") + m_sDiffPath;
166 else if (m_iExtDiff == 1)
167 m_sDiffPath.TrimLeft('#');
168 if (m_iDiffViewer == 0 && !m_sDiffViewerPath.IsEmpty() && m_sDiffViewerPath.Left(1) != _T("#"))
169 m_sDiffViewerPath = _T("#") + m_sDiffViewerPath;
170 else if (m_iDiffViewer == 1)
171 m_sDiffViewerPath.TrimLeft('#');
172 UpdateData(FALSE);
175 void CSettingsProgsDiff::OnBnClickedDiffviewerOff()
177 m_iDiffViewer = 0;
178 SetModified();
179 GetDlgItem(IDC_DIFFVIEWER)->EnableWindow(FALSE);
180 GetDlgItem(IDC_DIFFVIEWERBROWSE)->EnableWindow(FALSE);
181 CheckProgComment();
184 void CSettingsProgsDiff::OnBnClickedDiffviewerOn()
186 m_iDiffViewer = 1;
187 SetModified();
188 GetDlgItem(IDC_DIFFVIEWER)->EnableWindow(TRUE);
189 GetDlgItem(IDC_DIFFVIEWERBROWSE)->EnableWindow(TRUE);
190 GetDlgItem(IDC_DIFFVIEWER)->SetFocus();
191 CheckProgComment();
194 void CSettingsProgsDiff::OnEnChangeDiffviewer()
196 SetModified();
199 void CSettingsProgsDiff::OnBnClickedDiffviewerbrowse()
201 if (CAppUtils::FileOpenSave(m_sDiffViewerPath, NULL, IDS_SETTINGS_SELECTDIFFVIEWER, IDS_PROGRAMSFILEFILTER, true, m_hWnd))
203 UpdateData(FALSE);
204 SetModified();