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.
20 #include "TortoiseMerge.h"
21 #include "DirFileEnum.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
)
35 , m_bFirstDiffOnLoad(FALSE
)
39 , m_bViewLinenumbers(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))
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()
122 if (m_cFontNames
.GetSelFont())
123 m_sFontName
= m_cFontNames
.GetSelFont()->m_strName
;
125 m_sFontName
= m_regFontName
;
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
;
155 uRadio
= IDC_WSCOMPARE
;
158 uRadio
= IDC_WSIGNOREALL
;
161 uRadio
= IDC_WSIGNORECHANGED
;
167 CheckRadioButton(IDC_WSCOMPARE
, IDC_WSIGNORECHANGED
, uRadio
);
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
);
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
);
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
)
218 // CSetMainPage message handlers
220 void CSetMainPage::OnModified()
225 void CSetMainPage::OnModifiedWithReload()
227 m_bReloadNeeded
= TRUE
;
231 void CSetMainPage::OnBnClickedWhitespace()
233 m_bReloadNeeded
= TRUE
;
235 UINT uRadio
= GetCheckedRadioButton(IDC_WSCOMPARE
, IDC_WSIGNORECHANGED
);
241 case IDC_WSIGNOREALL
:
244 case IDC_WSIGNORECHANGED
: