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_pProjectProperties(NULL
)
30 , m_bUseLogWidth(true)
34 CInputDlg::~CInputDlg()
38 void CInputDlg::DoDataExchange(CDataExchange
* pDX
)
40 CResizableStandAloneDialog::DoDataExchange(pDX
);
41 DDX_Control(pDX
, IDC_INPUTTEXT
, m_cInput
);
42 DDX_Check(pDX
, IDC_CHECKBOX
, m_iCheck
);
46 BEGIN_MESSAGE_MAP(CInputDlg
, CResizableStandAloneDialog
)
47 ON_EN_CHANGE(IDC_INPUTTEXT
, OnEnChangeLogmessage
)
50 BOOL
CInputDlg::OnInitDialog()
52 CResizableStandAloneDialog::OnInitDialog();
54 if (m_pProjectProperties
)
55 m_cInput
.Init(*m_pProjectProperties
);
59 m_cInput
.SetFont((CString
)CRegString(_T("Software\\TortoiseGit\\LogFontName"), _T("Courier New")), (DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\LogFontSize"), 8));
61 if (m_pProjectProperties
)
63 if (m_pProjectProperties
->nLogWidthMarker
)
65 m_cInput
.Call(SCI_SETWRAPMODE
, SC_WRAP_NONE
);
66 m_cInput
.Call(SCI_SETEDGEMODE
, EDGE_LINE
);
67 m_cInput
.Call(SCI_SETEDGECOLUMN
, m_pProjectProperties
->nLogWidthMarker
);
71 m_cInput
.Call(SCI_SETEDGEMODE
, EDGE_NONE
);
72 m_cInput
.Call(SCI_SETWRAPMODE
, SC_WRAP_WORD
);
74 //m_cInput.SetText(m_pProjectProperties->sLogTemplate);
76 if (!m_sInputText
.IsEmpty())
78 m_cInput
.SetText(m_sInputText
);
80 if (!m_sHintText
.IsEmpty())
82 SetDlgItemText(IDC_HINTTEXT
, m_sHintText
);
84 if (!m_sTitle
.IsEmpty())
86 this->SetWindowText(m_sTitle
);
88 if (!m_sCheckText
.IsEmpty())
90 SetDlgItemText(IDC_CHECKBOX
, m_sCheckText
);
91 GetDlgItem(IDC_CHECKBOX
)->ShowWindow(SW_SHOW
);
95 GetDlgItem(IDC_CHECKBOX
)->ShowWindow(SW_HIDE
);
98 AddAnchor(IDC_HINTTEXT
, TOP_LEFT
, TOP_RIGHT
);
99 AddAnchor(IDC_INPUTTEXT
, TOP_LEFT
, BOTTOM_RIGHT
);
100 AddAnchor(IDC_CHECKBOX
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
101 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
102 AddAnchor(IDOK
, BOTTOM_RIGHT
);
104 AdjustControlSize(IDC_CHECKBOX
);
106 EnableSaveRestore(_T("InputDlg"));
108 CenterWindow(CWnd::FromHandle(hWndExplorer
));
109 GetDlgItem(IDC_INPUTTEXT
)->SetFocus();
110 // clear the selection
111 m_cInput
.Call(SCI_SETSEL
, (WPARAM
)-1, (LPARAM
)-1);
115 void CInputDlg::OnOK()
118 m_sInputText
= m_cInput
.GetText();
119 CResizableDialog::OnOK();
122 BOOL
CInputDlg::PreTranslateMessage(MSG
* pMsg
)
124 if (pMsg
->message
== WM_KEYDOWN
)
126 switch (pMsg
->wParam
)
130 if (GetAsyncKeyState(VK_CONTROL
)&0x8000)
132 if ( GetDlgItem(IDOK
)->IsWindowEnabled() )
134 PostMessage(WM_COMMAND
, IDOK
);
142 return CResizableStandAloneDialog::PreTranslateMessage(pMsg
);
145 void CInputDlg::OnEnChangeLogmessage()
147 CString sTemp
= m_cInput
.GetText();
148 if ((!m_bUseLogWidth
)||((m_pProjectProperties
==NULL
)||(sTemp
.GetLength() >= m_pProjectProperties
->nMinLogSize
)))
150 DialogEnableWindow(IDOK
, TRUE
);
154 DialogEnableWindow(IDOK
, FALSE
);