2
* This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3
* http://www.gnu.org/licenses/lgpl-3.0.html
6
* $Id: searchresultslog.cpp 9203 2013-07-08 23:07:22Z fuscated $
7
* $HeadURL: http://svn.code.sf.net/p/codeblocks/code/branches/release-16.xx/src/sdk/searchresultslog.cpp $
10
#include "sdk_precomp.h"
13
#include <wx/arrstr.h>
14
#include <wx/filename.h>
15
#include <wx/listctrl.h>
17
#include "editormanager.h"
20
#include "cbstyledtextctrl.h"
22
#include "searchresultslog.h"
26
const int ID_List = wxNewId();
29
BEGIN_EVENT_TABLE(cbSearchResultsLog, wxEvtHandler)
33
cbSearchResultsLog::cbSearchResultsLog(const wxArrayString& titles_in, wxArrayInt& widths_in)
34
: ListCtrlLogger(titles_in, widths_in)
39
cbSearchResultsLog::~cbSearchResultsLog()
44
wxWindow* cbSearchResultsLog::CreateControl(wxWindow* parent)
46
ListCtrlLogger::CreateControl(parent);
47
control->SetId(ID_List);
48
Connect(ID_List, -1, wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
49
(wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction)
50
&cbSearchResultsLog::OnDoubleClick);
51
Manager::Get()->GetAppWindow()->PushEventHandler(this);
55
void cbSearchResultsLog::FocusEntry(size_t index)
57
if (index < (size_t)control->GetItemCount())
59
control->SetItemState(index, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
60
control->EnsureVisible(index);
65
void cbSearchResultsLog::SyncEditor(int selIndex)
67
wxFileName filename(control->GetItemText(selIndex));
69
if (!filename.IsAbsolute())
70
filename.MakeAbsolute(m_Base);
71
file = filename.GetFullPath();
74
li.m_itemId = selIndex;
76
li.m_mask = wxLIST_MASK_TEXT;
79
li.m_text.ToLong(&line);
80
cbEditor* ed = Manager::Get()->GetEditorManager()->Open(file);
88
if (cbStyledTextCtrl* ctrl = ed->GetControl()) {
89
ctrl->EnsureVisible(line);
93
void cbSearchResultsLog::OnDoubleClick(cb_unused wxCommandEvent& event)
95
// go to the relevant file/line
96
if (control->GetSelectedItemCount() == 0)
99
// find selected item index
100
int index = control->GetNextItem(-1,
102
wxLIST_STATE_SELECTED);
105
} // end of OnDoubleClick