Update diff del rename ignore document.
[TortoiseGit.git] / src / TortoiseProc / RenameDlg.cpp
blobdc18378b7565be5e1fc2f713778e0eede80945cc
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "stdafx.h"
20 #include "TortoiseProc.h"
21 #include "MessageBox.h"
22 #include "TGitPath.h"
23 #include "RenameDlg.h"
24 #include ".\renamedlg.h"
25 #include "CommonResource.h"
27 IMPLEMENT_DYNAMIC(CRenameDlg, CResizableStandAloneDialog)
28 CRenameDlg::CRenameDlg(CWnd* pParent /*=NULL*/)
29 : CResizableStandAloneDialog(CRenameDlg::IDD, pParent)
30 , m_name(_T(""))
34 CRenameDlg::~CRenameDlg()
38 void CRenameDlg::DoDataExchange(CDataExchange* pDX)
40 CResizableStandAloneDialog::DoDataExchange(pDX);
41 DDX_Text(pDX, IDC_NAME, m_name);
45 BEGIN_MESSAGE_MAP(CRenameDlg, CResizableStandAloneDialog)
46 ON_WM_SIZING()
47 ON_EN_CHANGE(IDC_NAME, OnEnChangeName)
48 END_MESSAGE_MAP()
50 BOOL CRenameDlg::OnInitDialog()
52 CResizableStandAloneDialog::OnInitDialog();
54 SHAutoComplete(GetDlgItem(IDC_NAME)->m_hWnd, SHACF_DEFAULT);
56 if (!m_windowtitle.IsEmpty())
57 this->SetWindowText(m_windowtitle);
58 if (!m_label.IsEmpty())
59 SetDlgItemText(IDC_LABEL, m_label);
60 AddAnchor(IDC_LABEL, TOP_LEFT);
61 AddAnchor(IDC_NAME, TOP_LEFT, TOP_RIGHT);
62 AddAnchor(IDOK, BOTTOM_RIGHT);
63 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
64 if (hWndExplorer)
65 CenterWindow(CWnd::FromHandle(hWndExplorer));
66 EnableSaveRestore(_T("RenameDlg"));
67 GetDlgItem(IDOK)->EnableWindow(FALSE);
68 return TRUE;
71 void CRenameDlg::OnOK()
73 UpdateData();
74 m_name.Trim();
75 CTGitPath path(m_name);
76 if (!path.IsValidOnWindows())
78 if (CMessageBox::Show(GetSafeHwnd(), IDS_WARN_NOVALIDPATH, IDS_APPNAME, MB_ICONWARNING | MB_OKCANCEL)==IDCANCEL)
79 return;
81 CResizableDialog::OnOK();
84 void CRenameDlg::OnSizing(UINT fwSide, LPRECT pRect)
86 // don't allow the dialog to be changed in height
87 CRect rcWindowRect;
88 GetWindowRect(&rcWindowRect);
89 switch (fwSide)
91 case WMSZ_BOTTOM:
92 case WMSZ_BOTTOMLEFT:
93 case WMSZ_BOTTOMRIGHT:
94 pRect->bottom = pRect->top + rcWindowRect.Height();
95 break;
96 case WMSZ_TOP:
97 case WMSZ_TOPLEFT:
98 case WMSZ_TOPRIGHT:
99 pRect->top = pRect->bottom - rcWindowRect.Height();
100 break;
102 CResizableStandAloneDialog::OnSizing(fwSide, pRect);
105 void CRenameDlg::OnEnChangeName()
107 UpdateData();
108 GetDlgItem(IDOK)->EnableWindow(!m_name.IsEmpty());