30 lines
639 B
C++
30 lines
639 B
C++
#include "LogControl.h"
|
|
#include <wx/datetime.h>
|
|
|
|
LogControl::LogControl(wxWindow* parent) : wxPanel(parent)
|
|
{
|
|
Init();
|
|
}
|
|
|
|
void LogControl::Init()
|
|
{
|
|
listBox_ = new wxListBox(this, wxID_ANY);
|
|
auto* topSizer = new wxBoxSizer(wxVERTICAL);
|
|
topSizer->Add(listBox_, 1, wxEXPAND);
|
|
SetSizer(topSizer);
|
|
Layout();
|
|
}
|
|
|
|
LogControl::~LogControl()
|
|
{
|
|
}
|
|
|
|
void LogControl::AddLog(const wxString& log)
|
|
{
|
|
std::lock_guard<std::mutex> lock(mutex_);
|
|
auto now = wxDateTime::UNow();
|
|
auto strTime = now.Format("%H:%M:%S.%l");
|
|
listBox_->Append(strTime + wxT(" ") + log);
|
|
listBox_->SetSelection(listBox_->GetCount() - 1);
|
|
}
|