1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2012, 2014-2018 - 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"
27 IMPLEMENT_DYNAMIC(CInputDlg
, CResizableStandAloneDialog
)
28 CInputDlg::CInputDlg(CWnd
* pParent
/*=nullptr*/)
29 : CResizableStandAloneDialog(CInputDlg::IDD
, pParent
)
30 , m_pProjectProperties(nullptr)
32 , m_bUseLogWidth(true)
36 CInputDlg::~CInputDlg()
40 void CInputDlg::DoDataExchange(CDataExchange
* pDX
)
42 CResizableStandAloneDialog::DoDataExchange(pDX
);
43 DDX_Control(pDX
, IDC_INPUTTEXT
, m_cInput
);
44 DDX_Check(pDX
, IDC_CHECKBOX
, m_iCheck
);
48 BEGIN_MESSAGE_MAP(CInputDlg
, CResizableStandAloneDialog
)
49 ON_EN_CHANGE(IDC_INPUTTEXT
, OnEnChangeLogmessage
)
50 ON_WM_SYSCOLORCHANGE()
53 BOOL
CInputDlg::OnInitDialog()
55 CResizableStandAloneDialog::OnInitDialog();
57 if (m_pProjectProperties
)
58 m_cInput
.Init(*m_pProjectProperties
);
62 m_cInput
.SetFont(CAppUtils::GetLogFontName(), CAppUtils::GetLogFontSize());
64 if (!m_sInputText
.IsEmpty())
66 m_cInput
.SetText(m_sInputText
);
68 if (!m_sHintText
.IsEmpty())
70 SetDlgItemText(IDC_HINTTEXT
, m_sHintText
);
72 if (!m_sTitle
.IsEmpty())
74 this->SetWindowText(m_sTitle
);
76 if (!m_sCheckText
.IsEmpty())
78 SetDlgItemText(IDC_CHECKBOX
, m_sCheckText
);
79 GetDlgItem(IDC_CHECKBOX
)->ShowWindow(SW_SHOW
);
83 GetDlgItem(IDC_CHECKBOX
)->ShowWindow(SW_HIDE
);
86 AdjustControlSize(IDC_CHECKBOX
);
88 AddAnchor(IDC_HINTTEXT
, TOP_LEFT
, TOP_RIGHT
);
89 AddAnchor(IDC_INPUTTEXT
, TOP_LEFT
, BOTTOM_RIGHT
);
90 AddAnchor(IDC_CHECKBOX
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
91 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
92 AddAnchor(IDOK
, BOTTOM_RIGHT
);
94 EnableSaveRestore(L
"InputDlg");
95 if (GetExplorerHWND())
96 CenterWindow(CWnd::FromHandle(GetExplorerHWND()));
97 GetDlgItem(IDC_INPUTTEXT
)->SetFocus();
98 // clear the selection
99 m_cInput
.Call(SCI_SETSEL
, (WPARAM
)-1, (LPARAM
)-1);
103 void CInputDlg::OnOK()
106 m_sInputText
= m_cInput
.GetText();
107 CResizableDialog::OnOK();
110 BOOL
CInputDlg::PreTranslateMessage(MSG
* pMsg
)
112 if (pMsg
->message
== WM_KEYDOWN
)
114 switch (pMsg
->wParam
)
118 if (GetAsyncKeyState(VK_CONTROL
)&0x8000)
120 if ( GetDlgItem(IDOK
)->IsWindowEnabled() )
121 PostMessage(WM_COMMAND
, IDOK
);
128 return CResizableStandAloneDialog::PreTranslateMessage(pMsg
);
131 void CInputDlg::OnEnChangeLogmessage()
133 CString sTemp
= m_cInput
.GetText();
134 if (!m_bUseLogWidth
|| !m_pProjectProperties
|| sTemp
.GetLength() >= m_pProjectProperties
->nMinLogSize
)
135 DialogEnableWindow(IDOK
, TRUE
);
137 DialogEnableWindow(IDOK
, FALSE
);
140 void CInputDlg::OnSysColorChange()
142 __super::OnSysColorChange();
143 m_cInput
.SetColors(true);
144 m_cInput
.SetFont(CAppUtils::GetLogFontName(), CAppUtils::GetLogFontSize());