optimize TGitCache for CLI operations
[TortoiseGit.git] / src / TortoiseMerge / SetMainPage.cpp
blob15416570ad692ac4c2b97b992872354652b394cd
1 // TortoiseMerge - a Diff/Patch program
3 // Copyright (C) 2006-2008 - 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 "DirFileEnum.h"
22 #include "version.h"
23 #include "AppUtils.h"
24 #include "PathUtils.h"
25 #include "SetMainPage.h"
26 #include ".\setmainpage.h"
29 // CSetMainPage dialog
31 IMPLEMENT_DYNAMIC(CSetMainPage, CPropertyPage)
32 CSetMainPage::CSetMainPage()
33 : CPropertyPage(CSetMainPage::IDD)
34 , m_bBackup(FALSE)
35 , m_bFirstDiffOnLoad(FALSE)
36 , m_nTabSize(0)
37 , m_bIgnoreEOL(FALSE)
38 , m_bOnePane(FALSE)
39 , m_bViewLinenumbers(FALSE)
40 , m_bStrikeout(FALSE)
41 , m_bReloadNeeded(FALSE)
42 , m_bDisplayBinDiff(TRUE)
43 , m_bCaseInsensitive(FALSE)
44 , m_bUTF8Default(FALSE)
46 m_regBackup = CRegDWORD(_T("Software\\TortoiseMerge\\Backup"));
47 m_regFirstDiffOnLoad = CRegDWORD(_T("Software\\TortoiseMerge\\FirstDiffOnLoad"), TRUE);
48 m_regTabSize = CRegDWORD(_T("Software\\TortoiseMerge\\TabSize"), 4);
49 m_regIgnoreEOL = CRegDWORD(_T("Software\\TortoiseMerge\\IgnoreEOL"), TRUE);
50 m_regOnePane = CRegDWORD(_T("Software\\TortoiseMerge\\OnePane"));
51 m_regIgnoreWS = CRegDWORD(_T("Software\\TortoiseMerge\\IgnoreWS"));
52 m_regViewLinenumbers = CRegDWORD(_T("Software\\TortoiseMerge\\ViewLinenumbers"), 1);
53 m_regStrikeout = CRegDWORD(_T("Software\\TortoiseMerge\\StrikeOut"), TRUE);
54 m_regFontName = CRegString(_T("Software\\TortoiseMerge\\LogFontName"), _T("Courier New"));
55 m_regFontSize = CRegDWORD(_T("Software\\TortoiseMerge\\LogFontSize"), 10);
56 m_regDisplayBinDiff = CRegDWORD(_T("Software\\TortoiseMerge\\DisplayBinDiff"), TRUE);
57 m_regCaseInsensitive = CRegDWORD(_T("Software\\TortoiseMerge\\CaseInsensitive"), FALSE);
58 m_regUTF8Default = CRegDWORD(_T("Software\\TortoiseMerge\\UseUTF8"), FALSE);
60 m_bBackup = m_regBackup;
61 m_bFirstDiffOnLoad = m_regFirstDiffOnLoad;
62 m_nTabSize = m_regTabSize;
63 m_bIgnoreEOL = m_regIgnoreEOL;
64 m_bOnePane = m_regOnePane;
65 m_nIgnoreWS = m_regIgnoreWS;
66 m_bViewLinenumbers = m_regViewLinenumbers;
67 m_bStrikeout = m_regStrikeout;
68 m_bDisplayBinDiff = m_regDisplayBinDiff;
69 m_bCaseInsensitive = m_regCaseInsensitive;
70 m_bUTF8Default = m_regUTF8Default;
73 CSetMainPage::~CSetMainPage()
77 void CSetMainPage::DoDataExchange(CDataExchange* pDX)
79 CPropertyPage::DoDataExchange(pDX);
80 DDX_Check(pDX, IDC_BACKUP, m_bBackup);
81 DDX_Check(pDX, IDC_FIRSTDIFFONLOAD, m_bFirstDiffOnLoad);
82 DDX_Text(pDX, IDC_TABSIZE, m_nTabSize);
83 DDV_MinMaxInt(pDX, m_nTabSize, 1, 1000);
84 DDX_Check(pDX, IDC_IGNORELF, m_bIgnoreEOL);
85 DDX_Check(pDX, IDC_ONEPANE, m_bOnePane);
86 DDX_Control(pDX, IDC_FONTSIZES, m_cFontSizes);
87 m_dwFontSize = (DWORD)m_cFontSizes.GetItemData(m_cFontSizes.GetCurSel());
88 if ((m_dwFontSize==0)||(m_dwFontSize == -1))
90 CString t;
91 m_cFontSizes.GetWindowText(t);
92 m_dwFontSize = _ttoi(t);
94 DDX_Control(pDX, IDC_FONTNAMES, m_cFontNames);
95 DDX_Check(pDX, IDC_LINENUMBERS, m_bViewLinenumbers);
96 DDX_Check(pDX, IDC_STRIKEOUT, m_bStrikeout);
97 DDX_Check(pDX, IDC_USEBDIFF, m_bDisplayBinDiff);
98 DDX_Check(pDX, IDC_CASEINSENSITIVE, m_bCaseInsensitive);
99 DDX_Check(pDX, IDC_UTF8DEFAULT, m_bUTF8Default);
102 void CSetMainPage::SaveData()
104 m_regBackup = m_bBackup;
105 m_regFirstDiffOnLoad = m_bFirstDiffOnLoad;
106 m_regTabSize = m_nTabSize;
107 m_regIgnoreEOL = m_bIgnoreEOL;
108 m_regOnePane = m_bOnePane;
109 m_regIgnoreWS = m_nIgnoreWS;
110 m_regFontName = m_sFontName;
111 m_regFontSize = m_dwFontSize;
112 m_regViewLinenumbers = m_bViewLinenumbers;
113 m_regStrikeout = m_bStrikeout;
114 m_regDisplayBinDiff = m_bDisplayBinDiff;
115 m_regCaseInsensitive = m_bCaseInsensitive;
116 m_regUTF8Default = m_bUTF8Default;
119 BOOL CSetMainPage::OnApply()
121 UpdateData();
122 if (m_cFontNames.GetSelFont())
123 m_sFontName = m_cFontNames.GetSelFont()->m_strName;
124 else
125 m_sFontName = m_regFontName;
126 SaveData();
127 SetModified(FALSE);
128 return CPropertyPage::OnApply();
131 BOOL CSetMainPage::OnInitDialog()
133 CMFCFontComboBox::m_bDrawUsingFont = true;
135 CPropertyPage::OnInitDialog();
137 m_bBackup = m_regBackup;
138 m_bFirstDiffOnLoad = m_regFirstDiffOnLoad;
139 m_nTabSize = m_regTabSize;
140 m_bIgnoreEOL = m_regIgnoreEOL;
141 m_bOnePane = m_regOnePane;
142 m_nIgnoreWS = m_regIgnoreWS;
143 m_bDisplayBinDiff = m_regDisplayBinDiff;
144 m_sFontName = m_regFontName;
145 m_dwFontSize = m_regFontSize;
146 m_bViewLinenumbers = m_regViewLinenumbers;
147 m_bStrikeout = m_regStrikeout;
148 m_bCaseInsensitive = m_regCaseInsensitive;
149 m_bUTF8Default = m_regUTF8Default;
151 UINT uRadio = IDC_WSCOMPARE;
152 switch (m_nIgnoreWS)
154 case 0:
155 uRadio = IDC_WSCOMPARE;
156 break;
157 case 1:
158 uRadio = IDC_WSIGNOREALL;
159 break;
160 case 2:
161 uRadio = IDC_WSIGNORECHANGED;
162 break;
163 default:
164 break;
167 CheckRadioButton(IDC_WSCOMPARE, IDC_WSIGNORECHANGED, uRadio);
169 CString temp;
170 int count = 0;
171 for (int i=6; i<32; i=i+2)
173 temp.Format(_T("%d"), i);
174 m_cFontSizes.AddString(temp);
175 m_cFontSizes.SetItemData(count++, i);
177 BOOL foundfont = FALSE;
178 for (int i=0; i<m_cFontSizes.GetCount(); i++)
180 if (m_cFontSizes.GetItemData(i) == m_dwFontSize)
182 m_cFontSizes.SetCurSel(i);
183 foundfont = TRUE;
186 if (!foundfont)
188 temp.Format(_T("%d"), m_dwFontSize);
189 m_cFontSizes.SetWindowText(temp);
191 m_cFontNames.Setup(DEVICE_FONTTYPE|RASTER_FONTTYPE|TRUETYPE_FONTTYPE, 1, FIXED_PITCH);
192 m_cFontNames.SelectFont(m_sFontName);
194 UpdateData(FALSE);
195 return TRUE; // return TRUE unless you set the focus to a control
196 // EXCEPTION: OCX Property Pages should return FALSE
199 BEGIN_MESSAGE_MAP(CSetMainPage, CPropertyPage)
200 ON_BN_CLICKED(IDC_BACKUP, &CSetMainPage::OnModified)
201 ON_BN_CLICKED(IDC_IGNORELF, &CSetMainPage::OnModifiedWithReload)
202 ON_BN_CLICKED(IDC_ONEPANE, &CSetMainPage::OnModified)
203 ON_BN_CLICKED(IDC_FIRSTDIFFONLOAD, &CSetMainPage::OnModified)
204 ON_BN_CLICKED(IDC_WSCOMPARE, &CSetMainPage::OnBnClickedWhitespace)
205 ON_BN_CLICKED(IDC_WSIGNORECHANGED, &CSetMainPage::OnBnClickedWhitespace)
206 ON_BN_CLICKED(IDC_WSIGNOREALL, &CSetMainPage::OnBnClickedWhitespace)
207 ON_BN_CLICKED(IDC_LINENUMBERS, &CSetMainPage::OnModified)
208 ON_BN_CLICKED(IDC_STRIKEOUT, &CSetMainPage::OnModified)
209 ON_EN_CHANGE(IDC_TABSIZE, &CSetMainPage::OnModified)
210 ON_CBN_SELCHANGE(IDC_FONTSIZES, &CSetMainPage::OnModified)
211 ON_CBN_SELCHANGE(IDC_FONTNAMES, &CSetMainPage::OnModified)
212 ON_BN_CLICKED(IDC_USEBDIFF, &CSetMainPage::OnModifiedWithReload)
213 ON_BN_CLICKED(IDC_CASEINSENSITIVE, &CSetMainPage::OnModified)
214 ON_BN_CLICKED(IDC_UTF8DEFAULT, &CSetMainPage::OnModified)
215 END_MESSAGE_MAP()
218 // CSetMainPage message handlers
220 void CSetMainPage::OnModified()
222 SetModified();
225 void CSetMainPage::OnModifiedWithReload()
227 m_bReloadNeeded = TRUE;
228 SetModified();
231 void CSetMainPage::OnBnClickedWhitespace()
233 m_bReloadNeeded = TRUE;
234 SetModified();
235 UINT uRadio = GetCheckedRadioButton(IDC_WSCOMPARE, IDC_WSIGNORECHANGED);
236 switch (uRadio)
238 case IDC_WSCOMPARE:
239 m_nIgnoreWS = 0;
240 break;
241 case IDC_WSIGNOREALL:
242 m_nIgnoreWS = 1;
243 break;
244 case IDC_WSIGNORECHANGED:
245 m_nIgnoreWS = 2;
246 break;
247 default:
248 break;