16
15
EVT_MENU(XRCID("ID_COPYTOCLIPBOARD"), CStatusView::OnCopy)
18
class CFastTextCtrl : public wxTextCtrl
21
CFastTextCtrl(wxWindow* parent)
22
: wxTextCtrl(parent, -1, _T(""), wxDefaultPosition, wxDefaultSize,
23
wxNO_BORDER | wxVSCROLL | wxTE_MULTILINE |
24
wxTE_READONLY | wxTE_RICH | wxTE_RICH2 | wxTE_NOHIDESEL |
29
// wxTextCtrl::Remove is somewhat slow, this is a faster version
30
virtual void Remove(long from, long to)
32
DoSetSelection(from, to, false);
34
m_updatesCount = -2; // suppress any update event
36
::SendMessage((HWND)GetHandle(), EM_REPLACESEL, 0, (LPARAM)_T(""));
40
DECLARE_EVENT_TABLE();
42
void OnText(wxCommandEvent& event)
45
// Having this event handler prevents the event from propagating up the
46
// window hierarchy which saves a few CPU cycles.
50
void OnNavigationKey(wxNavigationKeyEvent& event)
52
wxWindow* parent = GetParent();
53
event.SetEventObject(parent);
54
parent->ProcessEvent(event);
57
void OnKeyDown(wxKeyEvent& event)
59
if (event.GetKeyCode() != WXK_TAB)
65
wxWindow* parent = GetParent();
67
wxNavigationKeyEvent navEvent;
68
navEvent.SetEventObject(parent);
69
navEvent.SetDirection(!event.ShiftDown());
70
navEvent.SetFromTab(true);
71
navEvent.ResumePropagation(1);
72
parent->ProcessEvent(navEvent);
77
BEGIN_EVENT_TABLE(CFastTextCtrl, wxTextCtrl)
78
EVT_TEXT(wxID_ANY, CFastTextCtrl::OnText)
80
EVT_NAVIGATION_KEY(CFastTextCtrl::OnNavigationKey)
82
EVT_KEY_DOWN(CFastTextCtrl::OnKeyDown)
19
87
CStatusView::CStatusView(wxWindow* parent, wxWindowID id)
20
88
: wxWindow(parent, id, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER)
23
m_pTextCtrl = new wxTextCtrl(this, -1, _T(""), wxDefaultPosition, wxDefaultSize,
24
wxNO_BORDER | wxVSCROLL | wxTE_MULTILINE |
25
wxTE_READONLY | wxTE_RICH | wxTE_RICH2 | wxTE_NOHIDESEL | wxTE_LINEWRAP);
91
m_pTextCtrl = new CFastTextCtrl(this);
26
92
m_pTextCtrl->SetFont(GetFont());
28
94
m_pTextCtrl->Connect(wxID_ANY, wxEVT_CONTEXT_MENU, wxContextMenuEventHandler(CStatusView::OnContextMenu), 0, this);
43
m_pTextCtrl->SetSize(GetClientSize());
111
wxSize s = GetClientSize();
112
m_pTextCtrl->SetSize(0, 0, s.GetWidth(), s.GetHeight());
47
116
void CStatusView::AddToLog(CLogmsgNotification *pNotification)
49
AddToLog(pNotification->msgType, pNotification->msg);
118
AddToLog(pNotification->msgType, pNotification->msg, wxDateTime::Now());
52
void CStatusView::AddToLog(enum MessageType messagetype, wxString message)
121
void CStatusView::AddToLog(enum MessageType messagetype, const wxString& message, const wxDateTime& time)
126
line.messagetype = messagetype;
127
line.message = message;
130
m_hiddenLines.push_back(line);
131
if (m_hiddenLines.size() > MAX_LINECOUNT)
132
m_hiddenLines.pop_front();
136
const int messageLength = message.Length();
139
wxWindowUpdateLocker *pLock = 0;
142
prefix.Alloc(25 + messageLength);
57
145
prefix = _T("\n");
147
if (m_showTimestamps)
149
if (time != m_lastTime)
152
m_lastTimeString = time.Format(_T("%H:%M:%S\t"));
154
prefix += m_lastTimeString;
59
157
if (m_nLineCount == MAX_LINECOUNT)
61
#if wxMAJOR_VERSION > 2 || wxMINOR_VERSION > 6
62
wxWindowUpdateLocker lock(m_pTextCtrl);
64
m_pTextCtrl->Freeze();
160
pLock = new wxWindowUpdateLocker(m_pTextCtrl);
66
162
m_pTextCtrl->Remove(0, m_lineLengths.front() + 1);
67
163
m_lineLengths.pop_front();
68
#if !(wxMAJOR_VERSION > 2 || wxMINOR_VERSION > 6)
104
195
m_lineLengths.push_back(lineLength);
106
m_pTextCtrl->AppendText(prefix + message);
198
m_pTextCtrl->AppendText(prefix);
109
205
void CStatusView::InitDefAttr()
207
m_showTimestamps = COptions::Get()->GetOptionVal(OPTION_MESSAGELOG_TIMESTAMP) != 0;
208
m_lastTime = wxDateTime::Now();
209
m_lastTimeString = m_lastTime.Format(_T("%H:%M:%S\t"));
111
211
// Measure withs of all types
112
212
wxClientDC dc(this);
214
int timestampWidth = 0;
215
if (m_showTimestamps)
219
dc.GetTextExtent(_T("88:88:88"), &width, &height);
220
timestampWidth = width;
114
223
int maxWidth = 0;
115
224
wxCoord width = 0;
116
225
wxCoord height = 0;
135
244
dc.SetMapMode(wxMM_LOMETRIC);
137
maxWidth = dc.DeviceToLogicalX(maxWidth) + 20;
246
maxWidth = dc.DeviceToLogicalX(maxWidth) + 20;
247
if (timestampWidth != 0)
249
timestampWidth = dc.DeviceToLogicalX(timestampWidth) + 20;
250
maxWidth += timestampWidth;
138
252
wxArrayInt array;
253
if (timestampWidth != 0)
254
array.Add(timestampWidth);
139
255
array.Add(maxWidth);
140
256
wxTextAttr defAttr;
141
257
defAttr.SetTabs(array);
142
258
defAttr.SetLeftIndent(0, maxWidth);
144
defAttr.SetBackgroundColour(dc.GetTextBackground());
146
260
for (int i = 0; i < MessageTypeCount; i++)
148
262
m_attributeCache[i].attr = defAttr;
175
289
m_attributeCache[i].prefix = _("Status:");
176
m_attributeCache[i].attr.SetTextColour(wxColour(0, 0, 0));
290
m_attributeCache[i].attr.SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
179
293
m_attributeCache[i].prefix += _T("\t");
180
294
m_attributeCache[i].len = m_attributeCache[i].prefix.Length();
183
#if wxMAJOR_VERSION > 2 || wxMINOR_VERSION > 6
184
297
m_rtl = wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft;
188
300
void CStatusView::OnContextMenu(wxContextMenuEvent& event)