Fixed issue #1586: Cannot set initial focus to Checkout dialog, merge dialog and...
[TortoiseGit.git] / src / TortoiseProc / MergeDlg.cpp
blobee4927d9d260b176ee27cb8c90f500f428938b2e
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2013 - 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.
20 // MergeDlg.cpp : implementation file
23 #include "stdafx.h"
25 #include "Git.h"
26 #include "TortoiseProc.h"
27 #include "MergeDlg.h"
28 #include "AppUtils.h"
30 #include "Messagebox.h"
31 // CMergeDlg dialog
33 IMPLEMENT_DYNAMIC(CMergeDlg, CResizableStandAloneDialog)
35 CMergeDlg::CMergeDlg(CWnd* pParent /*=NULL*/)
36 : CResizableStandAloneDialog(CMergeDlg::IDD, pParent),
37 CChooseVersion(this)
39 m_pDefaultText = MAKEINTRESOURCE(IDS_PROC_AUTOGENERATEDBYGIT);
40 m_bNoFF=false;
41 m_bSquash=false;
42 m_bNoCommit=false;
45 CMergeDlg::~CMergeDlg()
49 void CMergeDlg::DoDataExchange(CDataExchange* pDX)
51 CDialog::DoDataExchange(pDX);
53 CHOOSE_VERSION_DDX;
55 DDX_Check(pDX,IDC_CHECK_NOFF,this->m_bNoFF);
56 DDX_Check(pDX,IDC_CHECK_SQUASH,this->m_bSquash);
57 DDX_Check(pDX,IDC_CHECK_NOCOMMIT,this->m_bNoCommit);
58 DDX_Control(pDX, IDC_LOGMESSAGE, m_cLogMessage);
62 BEGIN_MESSAGE_MAP(CMergeDlg, CResizableStandAloneDialog)
63 CHOOSE_VERSION_EVENT
64 ON_BN_CLICKED(IDOK, &CMergeDlg::OnBnClickedOk)
65 ON_WM_DESTROY()
66 END_MESSAGE_MAP()
69 BOOL CMergeDlg::OnInitDialog()
71 CResizableStandAloneDialog::OnInitDialog();
72 CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
74 CHOOSE_VERSION_ADDANCHOR;
76 AddAnchor(IDC_GROUP_OPTION, TOP_LEFT, TOP_RIGHT);
77 AddAnchor(IDC_STATIC_MERGE_MESSAGE,TOP_LEFT,BOTTOM_RIGHT);
78 AddAnchor(IDC_LOGMESSAGE,TOP_LEFT,BOTTOM_RIGHT);
80 AddAnchor(IDOK,BOTTOM_RIGHT);
81 AddAnchor(IDCANCEL,BOTTOM_RIGHT);
82 AddAnchor(IDHELP, BOTTOM_RIGHT);
84 this->AddOthersToAnchor();
86 AdjustControlSize(IDC_RADIO_BRANCH);
87 AdjustControlSize(IDC_RADIO_TAGS);
88 AdjustControlSize(IDC_RADIO_VERSION);
89 AdjustControlSize(IDC_CHECK_SQUASH);
90 AdjustControlSize(IDC_CHECK_NOFF);
91 AdjustControlSize(IDC_CHECK_NOCOMMIT);
93 CheckRadioButton(IDC_RADIO_BRANCH,IDC_RADIO_VERSION,IDC_RADIO_BRANCH);
94 this->SetDefaultChoose(IDC_RADIO_BRANCH);
96 CString sWindowTitle;
97 GetWindowText(sWindowTitle);
98 CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle);
100 Init();
102 m_ProjectProperties.ReadProps(CTGitPath(g_Git.m_CurrentDir));
104 m_cLogMessage.Init(m_ProjectProperties);
105 m_cLogMessage.SetFont((CString)CRegString(_T("Software\\TortoiseGit\\LogFontName"), _T("Courier New")), (DWORD)CRegDWORD(_T("Software\\TortoiseGit\\LogFontSize"), 8));
106 m_cLogMessage.RegisterContextMenuHandler(this);
108 m_cLogMessage.SetText(m_pDefaultText);
110 EnableSaveRestore(_T("MergeDlg"));
111 GetDlgItem(IDOK)->SetFocus();
113 return FALSE;
116 // CMergeDlg message handlers
119 void CMergeDlg::OnBnClickedOk()
121 this->UpdateData(TRUE);
123 this->UpdateRevsionName();
125 this->m_strLogMesage = m_cLogMessage.GetText() ;
126 if( m_strLogMesage == CString(this->m_pDefaultText) )
128 m_strLogMesage.Empty();
131 OnOK();
134 void CMergeDlg::OnDestroy()
136 WaitForFinishLoading();
137 __super::OnDestroy();