1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2007-2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
20 #include "TortoiseProc.h"
\r
21 #include "MessageBox.h"
\r
22 #include "SettingsTBlame.h"
\r
25 // CSettingsTBlame dialog
\r
27 IMPLEMENT_DYNAMIC(CSettingsTBlame, ISettingsPropPage)
\r
29 CSettingsTBlame::CSettingsTBlame()
\r
30 : ISettingsPropPage(CSettingsTBlame::IDD)
\r
32 , m_sFontName(_T(""))
\r
35 m_regNewLinesColor = CRegDWORD(_T("Software\\TortoiseSVN\\BlameNewColor"), RGB(255, 230, 230));
\r
36 m_regOldLinesColor = CRegDWORD(_T("Software\\TortoiseSVN\\BlameOldColor"), RGB(230, 230, 255));
\r
37 m_regFontName = CRegString(_T("Software\\TortoiseSVN\\BlameFontName"), _T("Courier New"));
\r
38 m_regFontSize = CRegDWORD(_T("Software\\TortoiseSVN\\BlameFontSize"), 10);
\r
39 m_regTabSize = CRegDWORD(_T("Software\\TortoiseSVN\\BlameTabSize"), 4);
\r
42 CSettingsTBlame::~CSettingsTBlame()
\r
46 void CSettingsTBlame::DoDataExchange(CDataExchange* pDX)
\r
48 ISettingsPropPage::DoDataExchange(pDX);
\r
49 DDX_Control(pDX, IDC_NEWLINESCOLOR, m_cNewLinesColor);
\r
50 DDX_Control(pDX, IDC_OLDLINESCOLOR, m_cOldLinesColor);
\r
51 DDX_Control(pDX, IDC_FONTSIZES, m_cFontSizes);
\r
52 m_dwFontSize = (DWORD)m_cFontSizes.GetItemData(m_cFontSizes.GetCurSel());
\r
53 if ((m_dwFontSize==0)||(m_dwFontSize == -1))
\r
56 m_cFontSizes.GetWindowText(t);
\r
57 m_dwFontSize = _ttoi(t);
\r
59 DDX_Control(pDX, IDC_FONTNAMES, m_cFontNames);
\r
60 DDX_Text(pDX, IDC_TABSIZE, m_dwTabSize);
\r
64 BEGIN_MESSAGE_MAP(CSettingsTBlame, ISettingsPropPage)
\r
65 ON_BN_CLICKED(IDC_RESTORE, OnBnClickedRestore)
\r
66 ON_CBN_SELCHANGE(IDC_FONTSIZES, OnChange)
\r
67 ON_CBN_SELCHANGE(IDC_FONTNAMES, OnChange)
\r
68 ON_EN_CHANGE(IDC_TABSIZE, OnChange)
\r
69 ON_BN_CLICKED(IDC_NEWLINESCOLOR, &CSettingsTBlame::OnBnClickedColor)
\r
70 ON_BN_CLICKED(IDC_OLDLINESCOLOR, &CSettingsTBlame::OnBnClickedColor)
\r
74 // CSettingsTBlame message handlers
\r
76 BOOL CSettingsTBlame::OnInitDialog()
\r
78 CMFCFontComboBox::m_bDrawUsingFont = true;
\r
80 ISettingsPropPage::OnInitDialog();
\r
82 m_cNewLinesColor.SetColor((DWORD)m_regNewLinesColor);
\r
83 m_cOldLinesColor.SetColor((DWORD)m_regOldLinesColor);
\r
85 CString sDefaultText, sCustomText;
\r
86 sDefaultText.LoadString(IDS_COLOURPICKER_DEFAULTTEXT);
\r
87 sCustomText.LoadString(IDS_COLOURPICKER_CUSTOMTEXT);
\r
88 m_cNewLinesColor.EnableAutomaticButton(sDefaultText, RGB(255, 230, 230));
\r
89 m_cNewLinesColor.EnableOtherButton(sCustomText);
\r
90 m_cOldLinesColor.EnableAutomaticButton(sDefaultText, RGB(230, 230, 255));
\r
91 m_cOldLinesColor.EnableOtherButton(sCustomText);
\r
93 m_dwTabSize = m_regTabSize;
\r
94 m_sFontName = m_regFontName;
\r
95 m_dwFontSize = m_regFontSize;
\r
98 for (int i=6; i<32; i=i+2)
\r
100 temp.Format(_T("%d"), i);
\r
101 m_cFontSizes.AddString(temp);
\r
102 m_cFontSizes.SetItemData(count++, i);
\r
104 BOOL foundfont = FALSE;
\r
105 for (int i=0; i<m_cFontSizes.GetCount(); i++)
\r
107 if (m_cFontSizes.GetItemData(i) == m_dwFontSize)
\r
109 m_cFontSizes.SetCurSel(i);
\r
115 temp.Format(_T("%d"), m_dwFontSize);
\r
116 m_cFontSizes.SetWindowText(temp);
\r
118 m_cFontNames.Setup(DEVICE_FONTTYPE|RASTER_FONTTYPE|TRUETYPE_FONTTYPE, 1, FIXED_PITCH);
\r
119 m_cFontNames.SelectFont(m_sFontName);
\r
125 void CSettingsTBlame::OnChange()
\r
130 void CSettingsTBlame::OnBnClickedRestore()
\r
132 m_cOldLinesColor.SetColor(RGB(230, 230, 255));
\r
133 m_cNewLinesColor.SetColor(RGB(255, 230, 230));
\r
137 BOOL CSettingsTBlame::OnApply()
\r
140 if (m_cFontNames.GetSelFont())
\r
141 m_sFontName = m_cFontNames.GetSelFont()->m_strName;
\r
143 m_sFontName = m_regFontName;
\r
145 Store ((m_cNewLinesColor.GetColor() == -1 ? m_cNewLinesColor.GetAutomaticColor() : m_cNewLinesColor.GetColor()), m_regNewLinesColor);
\r
146 Store ((m_cOldLinesColor.GetColor() == -1 ? m_cOldLinesColor.GetAutomaticColor() : m_cOldLinesColor.GetColor()), m_regOldLinesColor);
\r
147 Store ((LPCTSTR)m_sFontName, m_regFontName);
\r
148 Store (m_dwFontSize, m_regFontSize);
\r
149 Store (m_dwTabSize, m_regTabSize);
\r
151 SetModified(FALSE);
\r
152 return ISettingsPropPage::OnApply();
\r
155 void CSettingsTBlame::OnBnClickedColor()
\r