1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
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 #include "TortoiseProc.h"
25 IMPLEMENT_DYNAMIC(CInputDlg
, CResizableStandAloneDialog
)
26 CInputDlg::CInputDlg(CWnd
* pParent
/*=NULL*/)
27 : CResizableStandAloneDialog(CInputDlg::IDD
, pParent
)
28 , m_sInputText(_T(""))
29 , m_pProjectProperties(NULL
)
31 , m_bUseLogWidth(true)
35 CInputDlg::~CInputDlg()
39 void CInputDlg::DoDataExchange(CDataExchange
* pDX
)
41 CResizableStandAloneDialog::DoDataExchange(pDX
);
42 DDX_Control(pDX
, IDC_INPUTTEXT
, m_cInput
);
43 DDX_Check(pDX
, IDC_CHECKBOX
, m_iCheck
);
47 BEGIN_MESSAGE_MAP(CInputDlg
, CResizableStandAloneDialog
)
48 ON_EN_CHANGE(IDC_INPUTTEXT
, OnEnChangeLogmessage
)
51 BOOL
CInputDlg::OnInitDialog()
53 CResizableStandAloneDialog::OnInitDialog();
55 if (m_pProjectProperties
)
56 m_cInput
.Init(*m_pProjectProperties
);
60 m_cInput
.SetFont((CString
)CRegString(_T("Software\\TortoiseGit\\LogFontName"), _T("Courier New")), (DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\LogFontSize"), 8));
62 if (m_pProjectProperties
)
64 if (m_pProjectProperties
->nLogWidthMarker
)
66 m_cInput
.Call(SCI_SETWRAPMODE
, SC_WRAP_NONE
);
67 m_cInput
.Call(SCI_SETEDGEMODE
, EDGE_LINE
);
68 m_cInput
.Call(SCI_SETEDGECOLUMN
, m_pProjectProperties
->nLogWidthMarker
);
72 m_cInput
.Call(SCI_SETEDGEMODE
, EDGE_NONE
);
73 m_cInput
.Call(SCI_SETWRAPMODE
, SC_WRAP_WORD
);
75 m_cInput
.SetText(m_pProjectProperties
->sLogTemplate
);
77 if (!m_sInputText
.IsEmpty())
79 m_cInput
.SetText(m_sInputText
);
81 if (!m_sHintText
.IsEmpty())
83 SetDlgItemText(IDC_HINTTEXT
, m_sHintText
);
85 if (!m_sTitle
.IsEmpty())
87 this->SetWindowText(m_sTitle
);
89 if (!m_sCheckText
.IsEmpty())
91 SetDlgItemText(IDC_CHECKBOX
, m_sCheckText
);
92 GetDlgItem(IDC_CHECKBOX
)->ShowWindow(SW_SHOW
);
96 GetDlgItem(IDC_CHECKBOX
)->ShowWindow(SW_HIDE
);
99 AddAnchor(IDC_HINTTEXT
, TOP_LEFT
, TOP_RIGHT
);
100 AddAnchor(IDC_INPUTTEXT
, TOP_LEFT
, BOTTOM_RIGHT
);
101 AddAnchor(IDC_CHECKBOX
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
102 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
103 AddAnchor(IDOK
, BOTTOM_RIGHT
);
105 AdjustControlSize(IDC_CHECKBOX
);
107 EnableSaveRestore(_T("InputDlg"));
109 CenterWindow(CWnd::FromHandle(hWndExplorer
));
110 GetDlgItem(IDC_INPUTTEXT
)->SetFocus();
111 // clear the selection
112 m_cInput
.Call(SCI_SETSEL
, (WPARAM
)-1, (LPARAM
)-1);
116 void CInputDlg::OnOK()
119 m_sInputText
= m_cInput
.GetText();
120 CResizableDialog::OnOK();
123 BOOL
CInputDlg::PreTranslateMessage(MSG
* pMsg
)
125 if (pMsg
->message
== WM_KEYDOWN
)
127 switch (pMsg
->wParam
)
131 if (GetAsyncKeyState(VK_CONTROL
)&0x8000)
133 if ( GetDlgItem(IDOK
)->IsWindowEnabled() )
135 PostMessage(WM_COMMAND
, IDOK
);
143 return CResizableStandAloneDialog::PreTranslateMessage(pMsg
);
146 void CInputDlg::OnEnChangeLogmessage()
148 CString sTemp
= m_cInput
.GetText();
149 if ((!m_bUseLogWidth
)||((m_pProjectProperties
==NULL
)||(sTemp
.GetLength() >= m_pProjectProperties
->nMinLogSize
)))
151 DialogEnableWindow(IDOK
, TRUE
);
155 DialogEnableWindow(IDOK
, FALSE
);