Fixed issue #1279: Nothing seen in Repository Browser without config core.bare=false
[TortoiseGit.git] / src / TortoiseProc / Settings / SettingsTBlame.cpp
blobc0dd569b163edbd7a59f6e90a20fce33e82d66b0
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2008 - TortoiseSVN
4 // Copyright (C) 2011 - TortoiseGit
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 "MessageBox.h"
23 #include "SettingsTBlame.h"
26 // CSettingsTBlame dialog
28 //IMPLEMENT_DYNAMIC(CSettingsTBlame, ISettingsPropPage)
30 CSettingsTBlame::CSettingsTBlame()
31 : ISettingsPropPage(CSettingsTBlame::IDD)
32 , m_dwFontSize(0)
33 , m_sFontName(_T(""))
34 , m_dwTabSize(4)
35 , m_bFollowRenames(0)
37 m_regNewLinesColor = CRegDWORD(_T("Software\\TortoiseGit\\BlameNewColor"), RGB(255, 230, 230));
38 m_regOldLinesColor = CRegDWORD(_T("Software\\TortoiseGit\\BlameOldColor"), RGB(230, 230, 255));
39 m_regFontName = CRegString(_T("Software\\TortoiseGit\\BlameFontName"), _T("Courier New"));
40 m_regFontSize = CRegDWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10);
41 m_regTabSize = CRegDWORD(_T("Software\\TortoiseGit\\BlameTabSize"), 4);
42 m_regFollowRenames = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseGitBlame\\Workspace\\FollowRenames"), 0);
45 CSettingsTBlame::~CSettingsTBlame()
49 void CSettingsTBlame::DoDataExchange(CDataExchange* pDX)
51 ISettingsPropPage::DoDataExchange(pDX);
52 DDX_Control(pDX, IDC_NEWLINESCOLOR, m_cNewLinesColor);
53 DDX_Control(pDX, IDC_OLDLINESCOLOR, m_cOldLinesColor);
54 DDX_Control(pDX, IDC_FONTSIZES, m_cFontSizes);
55 m_dwFontSize = (DWORD)m_cFontSizes.GetItemData(m_cFontSizes.GetCurSel());
56 if ((m_dwFontSize==0)||(m_dwFontSize == -1))
58 CString t;
59 m_cFontSizes.GetWindowText(t);
60 m_dwFontSize = _ttoi(t);
62 DDX_Control(pDX, IDC_FONTNAMES, m_cFontNames);
63 DDX_Text(pDX, IDC_TABSIZE, m_dwTabSize);
64 DDX_Check(pDX, IDC_FOLLOWRENAMES, m_bFollowRenames);
68 BEGIN_MESSAGE_MAP(CSettingsTBlame, ISettingsPropPage)
69 ON_BN_CLICKED(IDC_RESTORE, OnBnClickedRestore)
70 ON_CBN_SELCHANGE(IDC_FONTSIZES, OnChange)
71 ON_CBN_SELCHANGE(IDC_FONTNAMES, OnChange)
72 ON_EN_CHANGE(IDC_TABSIZE, OnChange)
73 ON_BN_CLICKED(IDC_FOLLOWRENAMES, OnChange)
74 ON_BN_CLICKED(IDC_NEWLINESCOLOR, &CSettingsTBlame::OnBnClickedColor)
75 ON_BN_CLICKED(IDC_OLDLINESCOLOR, &CSettingsTBlame::OnBnClickedColor)
76 END_MESSAGE_MAP()
79 // CSettingsTBlame message handlers
81 BOOL CSettingsTBlame::OnInitDialog()
83 CMFCFontComboBox::m_bDrawUsingFont = true;
85 ISettingsPropPage::OnInitDialog();
87 m_cNewLinesColor.SetColor((DWORD)m_regNewLinesColor);
88 m_cOldLinesColor.SetColor((DWORD)m_regOldLinesColor);
90 CString sDefaultText, sCustomText;
91 sDefaultText.LoadString(IDS_COLOURPICKER_DEFAULTTEXT);
92 sCustomText.LoadString(IDS_COLOURPICKER_CUSTOMTEXT);
93 m_cNewLinesColor.EnableAutomaticButton(sDefaultText, RGB(255, 230, 230));
94 m_cNewLinesColor.EnableOtherButton(sCustomText);
95 m_cOldLinesColor.EnableAutomaticButton(sDefaultText, RGB(230, 230, 255));
96 m_cOldLinesColor.EnableOtherButton(sCustomText);
98 m_dwTabSize = m_regTabSize;
99 m_sFontName = m_regFontName;
100 m_dwFontSize = m_regFontSize;
101 m_bFollowRenames = m_regFollowRenames;
102 int count = 0;
103 CString temp;
104 for (int i=6; i<32; i=i+2)
106 temp.Format(_T("%d"), i);
107 m_cFontSizes.AddString(temp);
108 m_cFontSizes.SetItemData(count++, i);
110 BOOL foundfont = FALSE;
111 for (int i=0; i<m_cFontSizes.GetCount(); i++)
113 if (m_cFontSizes.GetItemData(i) == m_dwFontSize)
115 m_cFontSizes.SetCurSel(i);
116 foundfont = TRUE;
119 if (!foundfont)
121 temp.Format(_T("%d"), m_dwFontSize);
122 m_cFontSizes.SetWindowText(temp);
124 m_cFontNames.Setup(DEVICE_FONTTYPE|RASTER_FONTTYPE|TRUETYPE_FONTTYPE, 1, FIXED_PITCH);
125 m_cFontNames.SelectFont(m_sFontName);
127 UpdateData(FALSE);
128 return TRUE;
131 void CSettingsTBlame::OnChange()
133 SetModified();
136 void CSettingsTBlame::OnBnClickedRestore()
138 m_cOldLinesColor.SetColor(RGB(230, 230, 255));
139 m_cNewLinesColor.SetColor(RGB(255, 230, 230));
140 SetModified(TRUE);
143 BOOL CSettingsTBlame::OnApply()
145 UpdateData();
146 if (m_cFontNames.GetSelFont())
147 m_sFontName = m_cFontNames.GetSelFont()->m_strName;
148 else
149 m_sFontName = m_regFontName;
151 Store ((m_cNewLinesColor.GetColor() == -1 ? m_cNewLinesColor.GetAutomaticColor() : m_cNewLinesColor.GetColor()), m_regNewLinesColor);
152 Store ((m_cOldLinesColor.GetColor() == -1 ? m_cOldLinesColor.GetAutomaticColor() : m_cOldLinesColor.GetColor()), m_regOldLinesColor);
153 Store ((LPCTSTR)m_sFontName, m_regFontName);
154 Store (m_dwFontSize, m_regFontSize);
155 Store (m_dwTabSize, m_regTabSize);
156 Store (m_bFollowRenames, m_regFollowRenames);
158 SetModified(FALSE);
159 return ISettingsPropPage::OnApply();
162 void CSettingsTBlame::OnBnClickedColor()
164 SetModified();