1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2009,2011-2013 - TortoiseGit
4 // Copyright (C) 2003-2008 - TortoiseSVN
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.
21 #include "TortoiseProc.h"
22 #include "MessageBox.h"
24 #include "RenameDlg.h"
27 IMPLEMENT_DYNAMIC(CRenameDlg
, CHorizontalResizableStandAloneDialog
)
28 CRenameDlg::CRenameDlg(CWnd
* pParent
/*=NULL*/)
29 : CHorizontalResizableStandAloneDialog(CRenameDlg::IDD
, pParent
)
34 CRenameDlg::~CRenameDlg()
38 void CRenameDlg::DoDataExchange(CDataExchange
* pDX
)
40 CHorizontalResizableStandAloneDialog::DoDataExchange(pDX
);
41 DDX_Text(pDX
, IDC_NAME
, m_name
);
45 BEGIN_MESSAGE_MAP(CRenameDlg
, CHorizontalResizableStandAloneDialog
)
47 ON_EN_CHANGE(IDC_NAME
, OnEnChangeName
)
50 BOOL
CRenameDlg::OnInitDialog()
52 CHorizontalResizableStandAloneDialog::OnInitDialog();
53 CAppUtils::MarkWindowAsUnpinnable(m_hWnd
);
55 SHAutoComplete(GetDlgItem(IDC_NAME
)->m_hWnd
, SHACF_DEFAULT
);
57 if (!m_windowtitle
.IsEmpty())
58 this->SetWindowText(m_windowtitle
);
59 if (!m_label
.IsEmpty())
60 SetDlgItemText(IDC_LABEL
, m_label
);
61 AddAnchor(IDC_LABEL
, TOP_LEFT
);
62 AddAnchor(IDC_NAME
, TOP_LEFT
, TOP_RIGHT
);
63 AddAnchor(IDOK
, BOTTOM_RIGHT
);
64 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
66 CenterWindow(CWnd::FromHandle(hWndExplorer
));
67 EnableSaveRestore(_T("RenameDlg"));
68 GetDlgItem(IDOK
)->EnableWindow(FALSE
);
72 void CRenameDlg::OnOK()
76 CTGitPath
path(m_name
);
77 if (!path
.IsValidOnWindows())
79 if (CMessageBox::Show(GetSafeHwnd(), IDS_WARN_NOVALIDPATH
, IDS_APPNAME
, MB_ICONWARNING
| MB_OKCANCEL
)==IDCANCEL
)
82 CHorizontalResizableStandAloneDialog::OnOK();
85 void CRenameDlg::OnEnChangeName()
88 GetDlgItem(IDOK
)->EnableWindow(!m_name
.IsEmpty());