OSDN Git Service

Enable GDI+
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / RevisionRangeDlg.cpp
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-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 "RevisionRangeDlg.h"\r
22 \r
23 \r
24 IMPLEMENT_DYNAMIC(CRevisionRangeDlg, CStandAloneDialog)\r
25 \r
26 CRevisionRangeDlg::CRevisionRangeDlg(CWnd* pParent /*=NULL*/)\r
27         : CStandAloneDialog(CRevisionRangeDlg::IDD, pParent)\r
28         , m_bAllowWCRevs(true)\r
29         , m_StartRev(_T("HEAD"))\r
30         , m_EndRev(_T("HEAD"))\r
31 {\r
32 }\r
33 \r
34 CRevisionRangeDlg::~CRevisionRangeDlg()\r
35 {\r
36 }\r
37 \r
38 void CRevisionRangeDlg::DoDataExchange(CDataExchange* pDX)\r
39 {\r
40         CStandAloneDialog::DoDataExchange(pDX);\r
41         DDX_Text(pDX, IDC_REVNUM, m_sStartRevision);\r
42         DDX_Text(pDX, IDC_REVNUM2, m_sEndRevision);\r
43 }\r
44 \r
45 \r
46 BEGIN_MESSAGE_MAP(CRevisionRangeDlg, CStandAloneDialog)\r
47         ON_EN_CHANGE(IDC_REVNUM, OnEnChangeRevnum)\r
48         ON_EN_CHANGE(IDC_REVNUM2, OnEnChangeRevnum2)\r
49 END_MESSAGE_MAP()\r
50 \r
51 BOOL CRevisionRangeDlg::OnInitDialog()\r
52 {\r
53         CStandAloneDialog::OnInitDialog();\r
54 \r
55         if (m_StartRev.IsHead())\r
56         {\r
57                 CheckRadioButton(IDC_NEWEST, IDC_REVISION_N, IDC_NEWEST);\r
58         }\r
59         else\r
60         {\r
61                 CheckRadioButton(IDC_NEWEST, IDC_REVISION_N, IDC_REVISION_N);\r
62                 CString sRev;\r
63                 if (m_StartRev.IsDate())\r
64                         sRev = m_StartRev.GetDateString();\r
65                 else\r
66                         sRev.Format(_T("%ld"), (LONG)(m_StartRev));\r
67                 SetDlgItemText(IDC_REVNUM, sRev);\r
68         }\r
69         if (m_EndRev.IsHead())\r
70         {\r
71                 CheckRadioButton(IDC_NEWEST2, IDC_REVISION_N2, IDC_NEWEST2);\r
72         }\r
73         else\r
74         {\r
75                 CheckRadioButton(IDC_NEWEST2, IDC_REVISION_N2, IDC_REVISION_N2);\r
76                 CString sRev;\r
77                 if (m_EndRev.IsDate())\r
78                         sRev = m_EndRev.GetDateString();\r
79                 else\r
80                         sRev.Format(_T("%ld"), (LONG)(m_EndRev));\r
81                 SetDlgItemText(IDC_REVNUM2, sRev);\r
82         }\r
83 \r
84         if ((m_pParentWnd==NULL)&&(hWndExplorer))\r
85                 CenterWindow(CWnd::FromHandle(hWndExplorer));\r
86         GetDlgItem(IDC_REVNUM)->SetFocus();\r
87         return FALSE;\r
88 }\r
89 \r
90 void CRevisionRangeDlg::OnOK()\r
91 {\r
92         if (!UpdateData(TRUE))\r
93                 return; // don't dismiss dialog (error message already shown by MFC framework)\r
94 \r
95         m_StartRev = SVNRev(m_sStartRevision);\r
96         if (GetCheckedRadioButton(IDC_NEWEST, IDC_REVISION_N) == IDC_NEWEST)\r
97         {\r
98                 m_StartRev = SVNRev(_T("HEAD"));\r
99                 m_sStartRevision = _T("HEAD");\r
100         }\r
101         if ((!m_StartRev.IsValid())||((!m_bAllowWCRevs)&&(m_StartRev.IsPrev() || m_StartRev.IsCommitted() || m_StartRev.IsBase())))\r
102         {\r
103                 ShowBalloon(IDC_REVNUM, m_bAllowWCRevs ? IDS_ERR_INVALIDREV : IDS_ERR_INVALIDREVNOWC);\r
104                 return;\r
105         }\r
106 \r
107         m_EndRev = SVNRev(m_sEndRevision);\r
108         if (GetCheckedRadioButton(IDC_NEWEST2, IDC_REVISION_N2) == IDC_NEWEST2)\r
109         {\r
110                 m_EndRev = SVNRev(_T("HEAD"));\r
111                 m_sEndRevision = _T("HEAD");\r
112         }\r
113         if ((!m_EndRev.IsValid())||((!m_bAllowWCRevs)&&(m_EndRev.IsPrev() || m_EndRev.IsCommitted() || m_EndRev.IsBase())))\r
114         {\r
115                 ShowBalloon(IDC_REVNUM2, m_bAllowWCRevs ? IDS_ERR_INVALIDREV : IDS_ERR_INVALIDREVNOWC);\r
116                 return;\r
117         }\r
118 \r
119         UpdateData(FALSE);\r
120 \r
121         CStandAloneDialog::OnOK();\r
122 }\r
123 \r
124 void CRevisionRangeDlg::OnEnChangeRevnum()\r
125 {\r
126         CString sText;\r
127         GetDlgItemText(IDC_REVNUM, sText);\r
128         if (sText.IsEmpty())\r
129         {\r
130                 CheckRadioButton(IDC_NEWEST, IDC_REVISION_N, IDC_NEWEST);\r
131         }\r
132         else\r
133         {\r
134                 CheckRadioButton(IDC_NEWEST, IDC_REVISION_N, IDC_REVISION_N);\r
135         }\r
136 }\r
137 \r
138 void CRevisionRangeDlg::OnEnChangeRevnum2()\r
139 {\r
140         CString sText;\r
141         GetDlgItemText(IDC_REVNUM2, sText);\r
142         if (sText.IsEmpty())\r
143         {\r
144                 CheckRadioButton(IDC_NEWEST2, IDC_REVISION_N2, IDC_NEWEST2);\r
145         }\r
146         else\r
147         {\r
148                 CheckRadioButton(IDC_NEWEST2, IDC_REVISION_N2, IDC_REVISION_N2);\r
149         }\r
150 }\r