Fixed issue #1619: TortoiseGitMerge: Ribbon UI/toolbars can be toggled
[TortoiseGit.git] / src / TortoiseMerge / SetMainPage.cpp
blob1e7ef170bed40bbbd5e5fce3299240fb5919ed17
1 // TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2013 - TortoiseGit
4 // Copyright (C) 2006-2010, 2012 - 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 "TortoiseMerge.h"
22 #include "DirFileEnum.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_bFirstConflictOnLoad(FALSE)
37 , m_nTabSize(0)
38 , m_bIgnoreEOL(FALSE)
39 , m_bOnePane(FALSE)
40 , m_bViewLinenumbers(FALSE)
41 , m_bReloadNeeded(FALSE)
42 , m_bCaseInsensitive(FALSE)
43 , m_bUTF8Default(FALSE)
44 , m_bAutoAdd(TRUE)
45 , m_nMaxInline(3000)
46 , m_dwFontSize(0)
48 m_regBackup = CRegDWORD(_T("Software\\TortoiseGitMerge\\Backup"));
49 m_regFirstDiffOnLoad = CRegDWORD(_T("Software\\TortoiseGitMerge\\FirstDiffOnLoad"), TRUE);
50 m_regFirstConflictOnLoad = CRegDWORD(_T("Software\\TortoiseGitMerge\\FirstConflictOnLoad"), TRUE);
51 m_regTabSize = CRegDWORD(_T("Software\\TortoiseGitMerge\\TabSize"), 4);
52 m_regIgnoreEOL = CRegDWORD(_T("Software\\TortoiseGitMerge\\IgnoreEOL"), TRUE);
53 m_regOnePane = CRegDWORD(_T("Software\\TortoiseGitMerge\\OnePane"));
54 m_regViewLinenumbers = CRegDWORD(_T("Software\\TortoiseGitMerge\\ViewLinenumbers"), 1);
55 m_regFontName = CRegString(_T("Software\\TortoiseGitMerge\\LogFontName"), _T("Courier New"));
56 m_regFontSize = CRegDWORD(_T("Software\\TortoiseGitMerge\\LogFontSize"), 10);
57 m_regCaseInsensitive = CRegDWORD(_T("Software\\TortoiseGitMerge\\CaseInsensitive"), FALSE);
58 m_regUTF8Default = CRegDWORD(_T("Software\\TortoiseGitMerge\\UseUTF8"), FALSE);
59 m_regAutoAdd = CRegDWORD(_T("Software\\TortoiseGitMerge\\AutoAdd"), TRUE);
60 m_regMaxInline = CRegDWORD(_T("Software\\TortoiseGitMerge\\InlineDiffMaxLineLength"), 3000);
61 m_regUseRibbons = CRegDWORD(L"Software\\TortoiseGitMerge\\UseRibbons", TRUE);
63 m_bBackup = m_regBackup;
64 m_bFirstDiffOnLoad = m_regFirstDiffOnLoad;
65 m_bFirstConflictOnLoad = m_regFirstConflictOnLoad;
66 m_nTabSize = m_regTabSize;
67 m_bIgnoreEOL = m_regIgnoreEOL;
68 m_bOnePane = m_regOnePane;
69 m_bViewLinenumbers = m_regViewLinenumbers;
70 m_bCaseInsensitive = m_regCaseInsensitive;
71 m_bUTF8Default = m_regUTF8Default;
72 m_bAutoAdd = m_regAutoAdd;
73 m_nMaxInline = m_regMaxInline;
74 m_bUseRibbons = m_regUseRibbons;
77 CSetMainPage::~CSetMainPage()
81 void CSetMainPage::DoDataExchange(CDataExchange* pDX)
83 CPropertyPage::DoDataExchange(pDX);
84 DDX_Check(pDX, IDC_BACKUP, m_bBackup);
85 DDX_Check(pDX, IDC_FIRSTDIFFONLOAD, m_bFirstDiffOnLoad);
86 DDX_Check(pDX, IDC_FIRSTCONFLICTONLOAD, m_bFirstConflictOnLoad);
87 DDX_Text(pDX, IDC_TABSIZE, m_nTabSize);
88 DDV_MinMaxInt(pDX, m_nTabSize, 1, 1000);
89 DDX_Check(pDX, IDC_IGNORELF, m_bIgnoreEOL);
90 DDX_Check(pDX, IDC_ONEPANE, m_bOnePane);
91 DDX_Control(pDX, IDC_FONTSIZES, m_cFontSizes);
92 m_dwFontSize = (DWORD)m_cFontSizes.GetItemData(m_cFontSizes.GetCurSel());
93 if ((m_dwFontSize==0)||(m_dwFontSize == -1))
95 CString t;
96 m_cFontSizes.GetWindowText(t);
97 m_dwFontSize = _ttoi(t);
99 DDX_Control(pDX, IDC_FONTNAMES, m_cFontNames);
100 DDX_Check(pDX, IDC_LINENUMBERS, m_bViewLinenumbers);
101 DDX_Check(pDX, IDC_CASEINSENSITIVE, m_bCaseInsensitive);
102 DDX_Check(pDX, IDC_UTF8DEFAULT, m_bUTF8Default);
103 DDX_Check(pDX, IDC_AUTOADD, m_bAutoAdd);
104 DDX_Text(pDX, IDC_MAXINLINE, m_nMaxInline);
105 DDX_Check(pDX, IDC_USERIBBONS, m_bUseRibbons);
108 void CSetMainPage::SaveData()
110 m_regBackup = m_bBackup;
111 m_regFirstDiffOnLoad = m_bFirstDiffOnLoad;
112 m_regFirstConflictOnLoad = m_bFirstConflictOnLoad;
113 m_regTabSize = m_nTabSize;
114 m_regIgnoreEOL = m_bIgnoreEOL;
115 m_regOnePane = m_bOnePane;
116 m_regFontName = m_sFontName;
117 m_regFontSize = m_dwFontSize;
118 m_regViewLinenumbers = m_bViewLinenumbers;
119 m_regCaseInsensitive = m_bCaseInsensitive;
120 m_regUTF8Default = m_bUTF8Default;
121 m_regAutoAdd = m_bAutoAdd;
122 m_regMaxInline = m_nMaxInline;
123 m_regUseRibbons = m_bUseRibbons;
126 BOOL CSetMainPage::OnApply()
128 UpdateData();
129 if (m_cFontNames.GetSelFont())
130 m_sFontName = m_cFontNames.GetSelFont()->m_strName;
131 else
132 m_sFontName = m_regFontName;
133 SaveData();
134 SetModified(FALSE);
135 return CPropertyPage::OnApply();
138 BOOL CSetMainPage::OnInitDialog()
140 CMFCFontComboBox::m_bDrawUsingFont = true;
142 CPropertyPage::OnInitDialog();
144 m_bBackup = m_regBackup;
145 m_bFirstDiffOnLoad = m_regFirstDiffOnLoad;
146 m_bFirstConflictOnLoad = m_regFirstConflictOnLoad;
147 m_nTabSize = m_regTabSize;
148 m_bIgnoreEOL = m_regIgnoreEOL;
149 m_bOnePane = m_regOnePane;
150 m_sFontName = m_regFontName;
151 m_dwFontSize = m_regFontSize;
152 m_bViewLinenumbers = m_regViewLinenumbers;
153 m_bCaseInsensitive = m_regCaseInsensitive;
154 m_bUTF8Default = m_regUTF8Default;
155 m_bAutoAdd = m_regAutoAdd;
156 m_nMaxInline = m_regMaxInline;
157 m_bUseRibbons = m_regUseRibbons;
159 DialogEnableWindow(IDC_FIRSTCONFLICTONLOAD, m_bFirstDiffOnLoad);
161 CString temp;
162 int count = 0;
163 for (int i=6; i<32; i=i+2)
165 temp.Format(_T("%d"), i);
166 m_cFontSizes.AddString(temp);
167 m_cFontSizes.SetItemData(count++, i);
169 BOOL foundfont = FALSE;
170 for (int i=0; i<m_cFontSizes.GetCount(); i++)
172 if (m_cFontSizes.GetItemData(i) == m_dwFontSize)
174 m_cFontSizes.SetCurSel(i);
175 foundfont = TRUE;
178 if (!foundfont)
180 temp.Format(_T("%d"), m_dwFontSize);
181 m_cFontSizes.SetWindowText(temp);
183 m_cFontNames.Setup(DEVICE_FONTTYPE|RASTER_FONTTYPE|TRUETYPE_FONTTYPE, 1, FIXED_PITCH);
184 m_cFontNames.SelectFont(m_sFontName);
186 UpdateData(FALSE);
187 return TRUE; // return TRUE unless you set the focus to a control
188 // EXCEPTION: OCX Property Pages should return FALSE
191 BEGIN_MESSAGE_MAP(CSetMainPage, CPropertyPage)
192 ON_BN_CLICKED(IDC_BACKUP, &CSetMainPage::OnModified)
193 ON_BN_CLICKED(IDC_IGNORELF, &CSetMainPage::OnModifiedWithReload)
194 ON_BN_CLICKED(IDC_ONEPANE, &CSetMainPage::OnModified)
195 ON_BN_CLICKED(IDC_FIRSTDIFFONLOAD, &CSetMainPage::OnModified)
196 ON_BN_CLICKED(IDC_FIRSTCONFLICTONLOAD, &CSetMainPage::OnModified)
197 ON_BN_CLICKED(IDC_LINENUMBERS, &CSetMainPage::OnModified)
198 ON_EN_CHANGE(IDC_TABSIZE, &CSetMainPage::OnModified)
199 ON_CBN_SELCHANGE(IDC_FONTSIZES, &CSetMainPage::OnModified)
200 ON_CBN_SELCHANGE(IDC_FONTNAMES, &CSetMainPage::OnModified)
201 ON_BN_CLICKED(IDC_CASEINSENSITIVE, &CSetMainPage::OnModified)
202 ON_BN_CLICKED(IDC_UTF8DEFAULT, &CSetMainPage::OnModified)
203 ON_BN_CLICKED(IDC_AUTOADD, &CSetMainPage::OnModified)
204 ON_EN_CHANGE(IDC_MAXINLINE, &CSetMainPage::OnModifiedWithReload)
205 ON_BN_CLICKED(IDC_USERIBBONS, &CSetMainPage::OnModified)
206 END_MESSAGE_MAP()
209 // CSetMainPage message handlers
211 void CSetMainPage::OnModified()
213 UpdateData();
214 SetModified();
215 DialogEnableWindow(IDC_FIRSTCONFLICTONLOAD, m_bFirstDiffOnLoad);
218 void CSetMainPage::OnModifiedWithReload()
220 m_bReloadNeeded = TRUE;
221 SetModified();
224 void CSetMainPage::OnBnClickedWhitespace()
226 m_bReloadNeeded = TRUE;
227 SetModified();
230 BOOL CSetMainPage::DialogEnableWindow(UINT nID, BOOL bEnable)
232 CWnd * pwndDlgItem = GetDlgItem(nID);
233 if (pwndDlgItem == NULL)
234 return FALSE;
235 if (bEnable)
236 return pwndDlgItem->EnableWindow(bEnable);
237 if (GetFocus() == pwndDlgItem)
239 SendMessage(WM_NEXTDLGCTL, 0, FALSE);
241 return pwndDlgItem->EnableWindow(bEnable);