1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2017 - TortoiseGit
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 // ResetDlg.cpp : implementation file
23 #include "TortoiseProc.h"
26 #include "FileDiffDlg.h"
31 IMPLEMENT_DYNAMIC(CResetDlg
, CHorizontalResizableStandAloneDialog
)
33 CResetDlg::CResetDlg(CWnd
* pParent
/*=nullptr*/)
34 : CHorizontalResizableStandAloneDialog(CResetDlg::IDD
, pParent
)
35 , CChooseVersion(this)
40 CResetDlg::~CResetDlg()
44 void CResetDlg::DoDataExchange(CDataExchange
* pDX
)
46 CDialog::DoDataExchange(pDX
);
50 BEGIN_MESSAGE_MAP(CResetDlg
, CHorizontalResizableStandAloneDialog
)
52 ON_BN_CLICKED(IDC_SHOW_MODIFIED_FILES
, &CResetDlg::OnBnClickedShowModifiedFiles
)
56 // CResetDlg message handlers
57 BOOL
CResetDlg::OnInitDialog()
59 CHorizontalResizableStandAloneDialog::OnInitDialog();
60 CAppUtils::MarkWindowAsUnpinnable(m_hWnd
);
62 AdjustControlSize(IDC_RADIO_BRANCH
);
63 AdjustControlSize(IDC_RADIO_TAGS
);
64 AdjustControlSize(IDC_RADIO_VERSION
);
65 AdjustControlSize(IDC_RADIO_RESET_SOFT
);
66 AdjustControlSize(IDC_RADIO_RESET_MIXED
);
67 AdjustControlSize(IDC_RADIO_RESET_HARD
);
69 AddAnchor(IDC_SHOW_MODIFIED_FILES
, TOP_LEFT
, TOP_RIGHT
);
70 AddAnchor(IDC_GROUP_RESET_TYPE
, TOP_LEFT
, TOP_RIGHT
);
71 AddAnchor(IDOK
, BOTTOM_RIGHT
);
72 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
73 AddAnchor(IDHELP
, BOTTOM_RIGHT
);
75 CHOOSE_VERSION_ADDANCHOR
;
76 this->AddOthersToAnchor();
78 EnableSaveRestore(L
"ResetDlg");
81 CString currentBranch
= g_Git
.GetCurrentBranch();
82 resetTo
.Format(IDS_PROC_RESETBRANCH
, (LPCTSTR
)currentBranch
);
83 GetDlgItem(IDC_GROUP_BASEON
)->SetWindowTextW(resetTo
);
85 if (GitAdminDir::IsBareRepo(g_Git
.m_CurrentDir
))
88 DialogEnableWindow(IDC_RADIO_RESET_MIXED
, FALSE
);
89 DialogEnableWindow(IDC_RADIO_RESET_HARD
, FALSE
);
91 this->CheckRadioButton(IDC_RADIO_RESET_SOFT
,IDC_RADIO_RESET_HARD
,IDC_RADIO_RESET_SOFT
+m_ResetType
);
94 SetDefaultChoose(IDC_RADIO_BRANCH
);
95 GetDlgItem(IDC_RADIO_RESET_SOFT
+ m_ResetType
)->SetFocus();
100 void CResetDlg::OnBnClickedChooseRadioHost()
102 OnBnClickedChooseRadio();
105 void CResetDlg::OnBnClickedShow()
107 OnBnClickedChooseVersion();
110 void CResetDlg::OnVersionChanged()
117 void CResetDlg::OnOK()
119 this->UpdateData(TRUE
);
121 m_ResetToVersion
= m_VersionName
;
122 m_ResetType
=this->GetCheckedRadioButton(IDC_RADIO_RESET_SOFT
,IDC_RADIO_RESET_HARD
)-IDC_RADIO_RESET_SOFT
;
123 return CHorizontalResizableStandAloneDialog::OnOK();
126 void CResetDlg::OnBnClickedShowModifiedFiles()
130 dlg
.m_strRev1
= L
"HEAD";
131 dlg
.m_strRev2
= GIT_REV_ZERO
;
136 void CResetDlg::OnDestroy()
138 WaitForFinishLoading();
139 __super::OnDestroy();