-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestOutputLog.cpp
More file actions
104 lines (87 loc) · 2.26 KB
/
TestOutputLog.cpp
File metadata and controls
104 lines (87 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "sdk_precomp.h"
#ifndef CB_PRECOMP
#include "cbeditor.h"
#include "editormanager.h"
#include "manager.h"
#include <wx/arrstr.h>
#include <wx/filename.h>
#include <wx/listctrl.h>
#endif
#include "cbstyledtextctrl.h"
#include "TestOutputLog.h"
namespace
{
const int ID_List = wxNewId();
};
BEGIN_EVENT_TABLE(TestOutputLog, wxEvtHandler)
//
END_EVENT_TABLE()
TestOutputLog::TestOutputLog(const wxArrayString &titles, wxArrayInt &widths)
: ListCtrlLogger(titles, widths)
{
//ctor
}
TestOutputLog::~TestOutputLog()
{
//dtor
Disconnect(ID_List, -1, wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
(wxObjectEventFunction)(wxEventFunction)(wxCommandEventFunction)&TestOutputLog::OnDoubleClick);
}
// TODO : use Getter instead of protected 'control'
wxWindow *TestOutputLog::CreateControl(wxWindow *parent)
{
ListCtrlLogger::CreateControl(parent);
control->SetId(ID_List);
Connect(ID_List, -1, wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
(wxObjectEventFunction)(wxEventFunction)(wxCommandEventFunction)&TestOutputLog::OnDoubleClick);
Manager::Get()->GetAppWindow()->PushEventHandler(this);
return control;
}
void TestOutputLog::DestroyControls()
{
if (!Manager::Get()->IsAppShuttingDown())
{
Manager::Get()->GetAppWindow()->RemoveEventHandler(this);
}
}
void TestOutputLog::OnDoubleClick(wxCommandEvent & /*event*/)
{
// go to the relevant file/line
if (control->GetSelectedItemCount() == 0)
{
return;
}
// find selected item index
const int index = control->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
SyncEditor(index);
} // end of OnDoubleClick
void TestOutputLog::SyncEditor(int selected)
{
wxFileName Filename(control->GetItemText(selected));
wxString filePath = Filename.GetFullPath();
wxListItem li;
li.m_itemId = selected;
li.m_col = 1;
li.m_mask = wxLIST_MASK_TEXT;
control->GetItem(li);
long line = 0;
li.m_text.ToLong(&line);
cbEditor *editor = Manager::Get()->GetEditorManager()->Open(filePath);
if (!line || !editor)
{
return;
}
line -= 1;
editor->Activate();
editor->GotoLine(line);
if (cbStyledTextCtrl *Control = editor->GetControl())
{
Control->EnsureVisible(line);
}
}
void TestOutputLog::Fit()
{
int columns = control->GetColumnCount();
for (int ii = 0; ii < columns; ++ii)
control->SetColumnWidth(ii, wxLIST_AUTOSIZE);
}