OSDN Git Service

be923f00c3af0ba32bdaf4bca6055adc01392163
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / RenameDlg.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 "MessageBox.h"\r
22 #include "TGitPath.h"\r
23 #include "RenameDlg.h"\r
24 #include ".\renamedlg.h"\r
25 \r
26 \r
27 IMPLEMENT_DYNAMIC(CRenameDlg, CResizableStandAloneDialog)\r
28 CRenameDlg::CRenameDlg(CWnd* pParent /*=NULL*/)\r
29         : CResizableStandAloneDialog(CRenameDlg::IDD, pParent)\r
30         , m_name(_T(""))\r
31 {\r
32 }\r
33 \r
34 CRenameDlg::~CRenameDlg()\r
35 {\r
36 }\r
37 \r
38 void CRenameDlg::DoDataExchange(CDataExchange* pDX)\r
39 {\r
40         CResizableStandAloneDialog::DoDataExchange(pDX);\r
41         DDX_Text(pDX, IDC_NAME, m_name);\r
42 }\r
43 \r
44 \r
45 BEGIN_MESSAGE_MAP(CRenameDlg, CResizableStandAloneDialog)\r
46         ON_WM_SIZING()\r
47         ON_EN_CHANGE(IDC_NAME, OnEnChangeName)\r
48 END_MESSAGE_MAP()\r
49 \r
50 BOOL CRenameDlg::OnInitDialog()\r
51 {\r
52         CResizableStandAloneDialog::OnInitDialog();\r
53 \r
54         SHAutoComplete(GetDlgItem(IDC_NAME)->m_hWnd, SHACF_DEFAULT);\r
55 \r
56         if (!m_windowtitle.IsEmpty())\r
57                 this->SetWindowText(m_windowtitle);\r
58         if (!m_label.IsEmpty())\r
59                 SetDlgItemText(IDC_LABEL, m_label);\r
60         AddAnchor(IDC_LABEL, TOP_LEFT);\r
61         AddAnchor(IDC_NAME, TOP_LEFT, TOP_RIGHT);\r
62         AddAnchor(IDOK, BOTTOM_RIGHT);\r
63         AddAnchor(IDCANCEL, BOTTOM_RIGHT);\r
64         if (hWndExplorer)\r
65                 CenterWindow(CWnd::FromHandle(hWndExplorer));\r
66         EnableSaveRestore(_T("RenameDlg"));\r
67         GetDlgItem(IDOK)->EnableWindow(FALSE);\r
68         return TRUE;\r
69 }\r
70 \r
71 void CRenameDlg::OnOK()\r
72 {\r
73         UpdateData();\r
74         m_name.Trim();\r
75         CTGitPath path(m_name);\r
76         if (!path.IsValidOnWindows())\r
77         {\r
78                 if (CMessageBox::Show(GetSafeHwnd(), IDS_WARN_NOVALIDPATH, IDS_APPNAME, MB_ICONWARNING | MB_OKCANCEL)==IDCANCEL)\r
79                         return;\r
80         }\r
81         CResizableDialog::OnOK();\r
82 }\r
83 \r
84 void CRenameDlg::OnSizing(UINT fwSide, LPRECT pRect)\r
85 {\r
86         // don't allow the dialog to be changed in height\r
87         CRect rcWindowRect;\r
88         GetWindowRect(&rcWindowRect);\r
89         switch (fwSide)\r
90         {\r
91         case WMSZ_BOTTOM:\r
92         case WMSZ_BOTTOMLEFT:\r
93         case WMSZ_BOTTOMRIGHT:\r
94                 pRect->bottom = pRect->top + rcWindowRect.Height();\r
95                 break;\r
96         case WMSZ_TOP:\r
97         case WMSZ_TOPLEFT:\r
98         case WMSZ_TOPRIGHT:\r
99                 pRect->top = pRect->bottom - rcWindowRect.Height();\r
100                 break;\r
101         }\r
102         CResizableStandAloneDialog::OnSizing(fwSide, pRect);\r
103 }\r
104 \r
105 void CRenameDlg::OnEnChangeName()\r
106 {\r
107         UpdateData();\r
108         GetDlgItem(IDOK)->EnableWindow(!m_name.IsEmpty());\r
109 }\r