diff options
Diffstat (limited to 'src/log_dialog.cpp')
| -rw-r--r-- | src/log_dialog.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
| diff --git a/src/log_dialog.cpp b/src/log_dialog.cpp new file mode 100644 index 0000000..3f0a8ad --- /dev/null +++ b/src/log_dialog.cpp | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | #include "log_dialog.h" | ||
| 2 | |||
| 3 | #include "logger.h" | ||
| 4 | |||
| 5 | wxDEFINE_EVENT(LOG_MESSAGE, wxCommandEvent); | ||
| 6 | |||
| 7 | LogDialog::LogDialog(wxWindow* parent) | ||
| 8 | : wxDialog(parent, wxID_ANY, "Debug Log", wxDefaultPosition, wxDefaultSize, | ||
| 9 | wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { | ||
| 10 | SetSize(FromDIP(wxSize{512, 280})); | ||
| 11 | |||
| 12 | text_area_ = | ||
| 13 | new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, | ||
| 14 | wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP); | ||
| 15 | text_area_->SetValue(TrackerReadPastLog()); | ||
| 16 | |||
| 17 | wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL); | ||
| 18 | top_sizer->Add(text_area_, | ||
| 19 | wxSizerFlags().DoubleBorder().Expand().Proportion(1)); | ||
| 20 | |||
| 21 | SetSizer(top_sizer); | ||
| 22 | |||
| 23 | Bind(LOG_MESSAGE, &LogDialog::OnLogMessage, this); | ||
| 24 | } | ||
| 25 | |||
| 26 | void LogDialog::LogMessage(const std::string& message) { | ||
| 27 | wxCommandEvent* event = new wxCommandEvent(LOG_MESSAGE); | ||
| 28 | event->SetString(message); | ||
| 29 | QueueEvent(event); | ||
| 30 | } | ||
| 31 | |||
| 32 | void LogDialog::OnLogMessage(wxCommandEvent& event) { | ||
| 33 | if (!text_area_->IsEmpty()) { | ||
| 34 | text_area_->AppendText("\n"); | ||
| 35 | } | ||
| 36 | text_area_->AppendText(event.GetString()); | ||
| 37 | } | ||
