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