1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008,2011 - 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.
21 #include "TortoiseProc.h"
23 #include "HistoryDlg.h"
26 IMPLEMENT_DYNAMIC(CHistoryDlg
, CResizableStandAloneDialog
)
27 CHistoryDlg::CHistoryDlg(CWnd
* pParent
/*=NULL*/)
28 : CResizableStandAloneDialog(CHistoryDlg::IDD
, pParent
)
33 CHistoryDlg::~CHistoryDlg()
37 void CHistoryDlg::DoDataExchange(CDataExchange
* pDX
)
39 CResizableStandAloneDialog::DoDataExchange(pDX
);
40 DDX_Control(pDX
, IDC_HISTORYLIST
, m_List
);
44 BEGIN_MESSAGE_MAP(CHistoryDlg
, CResizableStandAloneDialog
)
45 ON_BN_CLICKED(IDOK
, OnBnClickedOk
)
46 ON_LBN_DBLCLK(IDC_HISTORYLIST
, OnLbnDblclkHistorylist
)
51 void CHistoryDlg::OnBnClickedOk()
53 int pos
= m_List
.GetCurSel();
56 m_SelectedText
= m_history
->GetEntry(pos
);
59 m_SelectedText
.Empty();
63 BOOL
CHistoryDlg::OnInitDialog()
65 CResizableStandAloneDialog::OnInitDialog();
67 // calculate and set listbox width
68 CDC
* pDC
=m_List
.GetDC();
71 for (size_t i
= 0; i
< m_history
->GetCount(); ++i
)
73 CString sEntry
= m_history
->GetEntry(i
);
75 sEntry
.Replace('\n', ' ');
76 m_List
.AddString(sEntry
);
77 itemExtent
= pDC
->GetTextExtent(sEntry
);
78 horizExtent
= max(horizExtent
, itemExtent
.cx
+5);
80 m_List
.SetHorizontalExtent(horizExtent
);
83 AddAnchor(IDC_HISTORYLIST
, TOP_LEFT
, BOTTOM_RIGHT
);
84 AddAnchor(IDOK
, BOTTOM_RIGHT
);
85 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
86 EnableSaveRestore(_T("HistoryDlg"));
91 void CHistoryDlg::OnLbnDblclkHistorylist()
93 int pos
= m_List
.GetCurSel();
96 m_SelectedText
= m_history
->GetEntry(pos
);
100 m_SelectedText
.Empty();
103 BOOL
CHistoryDlg::PreTranslateMessage(MSG
* pMsg
)
105 if ((pMsg
->message
== WM_KEYDOWN
) && (pMsg
->wParam
== VK_DELETE
))
107 int pos
= m_List
.GetCurSel();
110 m_List
.DeleteString(pos
);
111 m_List
.SetCurSel(min(pos
, m_List
.GetCount() - 1));
112 m_history
->RemoveEntry(pos
);
118 return CResizableStandAloneDialog::PreTranslateMessage(pMsg
);