1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
20 #include "TortoiseProc.h"
\r
21 #include "InputDlg.h"
\r
22 #include "Registry.h"
\r
25 IMPLEMENT_DYNAMIC(CInputDlg, CResizableStandAloneDialog)
\r
26 CInputDlg::CInputDlg(CWnd* pParent /*=NULL*/)
\r
27 : CResizableStandAloneDialog(CInputDlg::IDD, pParent)
\r
28 , m_sInputText(_T(""))
\r
29 , m_pProjectProperties(NULL)
\r
31 , m_bUseLogWidth(true)
\r
35 CInputDlg::~CInputDlg()
\r
39 void CInputDlg::DoDataExchange(CDataExchange* pDX)
\r
41 CResizableStandAloneDialog::DoDataExchange(pDX);
\r
42 DDX_Control(pDX, IDC_INPUTTEXT, m_cInput);
\r
43 DDX_Check(pDX, IDC_CHECKBOX, m_iCheck);
\r
47 BEGIN_MESSAGE_MAP(CInputDlg, CResizableStandAloneDialog)
\r
48 ON_EN_CHANGE(IDC_INPUTTEXT, OnEnChangeLogmessage)
\r
51 BOOL CInputDlg::OnInitDialog()
\r
53 CResizableStandAloneDialog::OnInitDialog();
\r
55 if (m_pProjectProperties)
\r
56 m_cInput.Init(*m_pProjectProperties);
\r
60 m_cInput.SetFont((CString)CRegString(_T("Software\\TortoiseGit\\LogFontName"), _T("Courier New")), (DWORD)CRegDWORD(_T("Software\\TortoiseGit\\LogFontSize"), 8));
\r
62 if (m_pProjectProperties)
\r
64 if (m_pProjectProperties->nLogWidthMarker)
\r
66 m_cInput.Call(SCI_SETWRAPMODE, SC_WRAP_NONE);
\r
67 m_cInput.Call(SCI_SETEDGEMODE, EDGE_LINE);
\r
68 m_cInput.Call(SCI_SETEDGECOLUMN, m_pProjectProperties->nLogWidthMarker);
\r
72 m_cInput.Call(SCI_SETEDGEMODE, EDGE_NONE);
\r
73 m_cInput.Call(SCI_SETWRAPMODE, SC_WRAP_WORD);
\r
75 m_cInput.SetText(m_pProjectProperties->sLogTemplate);
\r
77 if (!m_sInputText.IsEmpty())
\r
79 m_cInput.SetText(m_sInputText);
\r
81 if (!m_sHintText.IsEmpty())
\r
83 SetDlgItemText(IDC_HINTTEXT, m_sHintText);
\r
85 if (!m_sTitle.IsEmpty())
\r
87 this->SetWindowText(m_sTitle);
\r
89 if (!m_sCheckText.IsEmpty())
\r
91 SetDlgItemText(IDC_CHECKBOX, m_sCheckText);
\r
92 GetDlgItem(IDC_CHECKBOX)->ShowWindow(SW_SHOW);
\r
96 GetDlgItem(IDC_CHECKBOX)->ShowWindow(SW_HIDE);
\r
99 AddAnchor(IDC_HINTTEXT, TOP_LEFT, TOP_RIGHT);
\r
100 AddAnchor(IDC_INPUTTEXT, TOP_LEFT, BOTTOM_RIGHT);
\r
101 AddAnchor(IDC_CHECKBOX, BOTTOM_LEFT, BOTTOM_RIGHT);
\r
102 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
\r
103 AddAnchor(IDOK, BOTTOM_RIGHT);
\r
104 EnableSaveRestore(_T("InputDlg"));
\r
106 CenterWindow(CWnd::FromHandle(hWndExplorer));
\r
107 GetDlgItem(IDC_INPUTTEXT)->SetFocus();
\r
108 // clear the selection
\r
109 m_cInput.Call(SCI_SETSEL, (WPARAM)-1, (LPARAM)-1);
\r
113 void CInputDlg::OnOK()
\r
116 m_sInputText = m_cInput.GetText();
\r
117 CResizableDialog::OnOK();
\r
120 BOOL CInputDlg::PreTranslateMessage(MSG* pMsg)
\r
122 if (pMsg->message == WM_KEYDOWN)
\r
124 switch (pMsg->wParam)
\r
128 if (GetAsyncKeyState(VK_CONTROL)&0x8000)
\r
130 if ( GetDlgItem(IDOK)->IsWindowEnabled() )
\r
132 PostMessage(WM_COMMAND, IDOK);
\r
140 return CResizableStandAloneDialog::PreTranslateMessage(pMsg);
\r
143 void CInputDlg::OnEnChangeLogmessage()
\r
145 CString sTemp = m_cInput.GetText();
\r
146 if ((!m_bUseLogWidth)||((m_pProjectProperties==NULL)||(sTemp.GetLength() >= m_pProjectProperties->nMinLogSize)))
\r
148 DialogEnableWindow(IDOK, TRUE);
\r
152 DialogEnableWindow(IDOK, FALSE);
\r