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
)
32 CHistoryDlg::~CHistoryDlg()
36 void CHistoryDlg::DoDataExchange(CDataExchange
* pDX
)
38 CResizableStandAloneDialog::DoDataExchange(pDX
);
39 DDX_Control(pDX
, IDC_HISTORYLIST
, m_List
);
43 BEGIN_MESSAGE_MAP(CHistoryDlg
, CResizableStandAloneDialog
)
44 ON_BN_CLICKED(IDOK
, OnBnClickedOk
)
45 ON_LBN_DBLCLK(IDC_HISTORYLIST
, OnLbnDblclkHistorylist
)
50 void CHistoryDlg::OnBnClickedOk()
52 int pos
= m_List
.GetCurSel();
55 m_SelectedText
= m_history
->GetEntry(pos
);
58 m_SelectedText
.Empty();
62 BOOL
CHistoryDlg::OnInitDialog()
64 CResizableStandAloneDialog::OnInitDialog();
66 // calculate and set listbox width
67 CDC
* pDC
=m_List
.GetDC();
70 for (size_t i
= 0; i
< m_history
->GetCount(); ++i
)
72 CString sEntry
= m_history
->GetEntry(i
);
74 sEntry
.Replace('\n', ' ');
75 m_List
.AddString(sEntry
);
76 itemExtent
= pDC
->GetTextExtent(sEntry
);
77 horizExtent
= max(horizExtent
, itemExtent
.cx
+5);
79 m_List
.SetHorizontalExtent(horizExtent
);
82 AddAnchor(IDC_HISTORYLIST
, TOP_LEFT
, BOTTOM_RIGHT
);
83 AddAnchor(IDOK
, BOTTOM_RIGHT
);
84 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
85 EnableSaveRestore(_T("HistoryDlg"));
90 void CHistoryDlg::OnLbnDblclkHistorylist()
92 int pos
= m_List
.GetCurSel();
95 m_SelectedText
= m_history
->GetEntry(pos
);
99 m_SelectedText
.Empty();
102 BOOL
CHistoryDlg::PreTranslateMessage(MSG
* pMsg
)
104 if ((pMsg
->message
== WM_KEYDOWN
) && (pMsg
->wParam
== VK_DELETE
))
106 int pos
= m_List
.GetCurSel();
109 m_List
.DeleteString(pos
);
110 m_List
.SetCurSel(min(pos
, m_List
.GetCount() - 1));
111 m_history
->RemoveEntry(pos
);
117 return CResizableStandAloneDialog::PreTranslateMessage(pMsg
);