OSDN Git Service

Setting dialog, remote list work.
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / Settings / SettingsTBlame.cpp
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2007-2008 - TortoiseSVN\r
4 \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
9 \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
14 \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
18 //\r
19 #include "stdafx.h"\r
20 #include "TortoiseProc.h"\r
21 #include "MessageBox.h"\r
22 #include "SettingsTBlame.h"\r
23 \r
24 \r
25 // CSettingsTBlame dialog\r
26 \r
27 //IMPLEMENT_DYNAMIC(CSettingsTBlame, ISettingsPropPage)\r
28 \r
29 CSettingsTBlame::CSettingsTBlame()\r
30         : ISettingsPropPage(CSettingsTBlame::IDD)\r
31         , m_dwFontSize(0)\r
32         , m_sFontName(_T(""))\r
33         , m_dwTabSize(4)\r
34 {\r
35         m_regNewLinesColor = CRegDWORD(_T("Software\\TortoiseGit\\BlameNewColor"), RGB(255, 230, 230));\r
36         m_regOldLinesColor = CRegDWORD(_T("Software\\TortoiseGit\\BlameOldColor"), RGB(230, 230, 255));\r
37         m_regFontName = CRegString(_T("Software\\TortoiseGit\\BlameFontName"), _T("Courier New"));\r
38         m_regFontSize = CRegDWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10);\r
39         m_regTabSize = CRegDWORD(_T("Software\\TortoiseGit\\BlameTabSize"), 4);\r
40 }\r
41 \r
42 CSettingsTBlame::~CSettingsTBlame()\r
43 {\r
44 }\r
45 \r
46 void CSettingsTBlame::DoDataExchange(CDataExchange* pDX)\r
47 {\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
54         {\r
55                 CString t;\r
56                 m_cFontSizes.GetWindowText(t);\r
57                 m_dwFontSize = _ttoi(t);\r
58         }\r
59         DDX_Control(pDX, IDC_FONTNAMES, m_cFontNames);\r
60         DDX_Text(pDX, IDC_TABSIZE, m_dwTabSize);\r
61 }\r
62 \r
63 \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
71 END_MESSAGE_MAP()\r
72 \r
73 \r
74 // CSettingsTBlame message handlers\r
75 \r
76 BOOL CSettingsTBlame::OnInitDialog()\r
77 {\r
78         CMFCFontComboBox::m_bDrawUsingFont = true;\r
79 \r
80         ISettingsPropPage::OnInitDialog();\r
81 \r
82         m_cNewLinesColor.SetColor((DWORD)m_regNewLinesColor);\r
83         m_cOldLinesColor.SetColor((DWORD)m_regOldLinesColor);\r
84 \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
92 \r
93         m_dwTabSize = m_regTabSize;\r
94         m_sFontName = m_regFontName;\r
95         m_dwFontSize = m_regFontSize;\r
96         int count = 0;\r
97         CString temp;\r
98         for (int i=6; i<32; i=i+2)\r
99         {\r
100                 temp.Format(_T("%d"), i);\r
101                 m_cFontSizes.AddString(temp);\r
102                 m_cFontSizes.SetItemData(count++, i);\r
103         }\r
104         BOOL foundfont = FALSE;\r
105         for (int i=0; i<m_cFontSizes.GetCount(); i++)\r
106         {\r
107                 if (m_cFontSizes.GetItemData(i) == m_dwFontSize)\r
108                 {\r
109                         m_cFontSizes.SetCurSel(i);\r
110                         foundfont = TRUE;\r
111                 }\r
112         }\r
113         if (!foundfont)\r
114         {\r
115                 temp.Format(_T("%d"), m_dwFontSize);\r
116                 m_cFontSizes.SetWindowText(temp);\r
117         }\r
118         m_cFontNames.Setup(DEVICE_FONTTYPE|RASTER_FONTTYPE|TRUETYPE_FONTTYPE, 1, FIXED_PITCH);\r
119         m_cFontNames.SelectFont(m_sFontName);\r
120 \r
121         UpdateData(FALSE);\r
122         return TRUE;\r
123 }\r
124 \r
125 void CSettingsTBlame::OnChange()\r
126 {\r
127         SetModified();\r
128 }\r
129 \r
130 void CSettingsTBlame::OnBnClickedRestore()\r
131 {\r
132         m_cOldLinesColor.SetColor(RGB(230, 230, 255));\r
133         m_cNewLinesColor.SetColor(RGB(255, 230, 230));\r
134         SetModified(TRUE);\r
135 }\r
136 \r
137 BOOL CSettingsTBlame::OnApply()\r
138 {\r
139         UpdateData();\r
140         if (m_cFontNames.GetSelFont())\r
141                 m_sFontName = m_cFontNames.GetSelFont()->m_strName;\r
142         else\r
143                 m_sFontName = m_regFontName;\r
144 \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
150 \r
151     SetModified(FALSE);\r
152         return ISettingsPropPage::OnApply();\r
153 }\r
154 \r
155 void CSettingsTBlame::OnBnClickedColor()\r
156 {\r
157         SetModified();\r
158 }\r