From 5402fa67af014159054a5c8c3ba8bf629b4054ad Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Thu, 19 Mar 2009 02:29:50 +0000 Subject: [PATCH] logwindow: cmdline now gets enter key event, no need for the submit button. some code which is supposed to color the textctrl, but it mysteriously doesn't. fun git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2682 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/LogWindow.cpp | 35 ++++++++++++++++++++----- Source/Core/DolphinWX/Src/LogWindow.h | 4 +-- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Source/Core/DolphinWX/Src/LogWindow.cpp b/Source/Core/DolphinWX/Src/LogWindow.cpp index 743f4c4b81..701f31a039 100644 --- a/Source/Core/DolphinWX/Src/LogWindow.cpp +++ b/Source/Core/DolphinWX/Src/LogWindow.cpp @@ -26,10 +26,11 @@ #include "LogWindow.h" #include "Console.h" +// milliseconds between msgQueue flushes to wxTextCtrl #define UPDATETIME 100 BEGIN_EVENT_TABLE(CLogWindow, wxDialog) - EVT_BUTTON(IDM_SUBMITCMD, CLogWindow::OnSubmit) + EVT_TEXT_ENTER(IDM_SUBMITCMD, CLogWindow::OnSubmit) EVT_BUTTON(IDM_CLEARLOG, CLogWindow::OnClear) EVT_BUTTON(IDM_TOGGLEALL, CLogWindow::OnToggleAll) EVT_RADIOBOX(IDM_VERBOSITY, CLogWindow::OnOptionsCheck) @@ -90,14 +91,14 @@ void CLogWindow::CreateGUIControls() // Right side: Log viewer and submit row m_log = new wxTextCtrl(this, IDM_LOG, wxEmptyString, wxDefaultPosition, wxDefaultSize, - wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP); + wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP); //m_log->SetFont(DebuggerFont); - m_cmdline = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition); + m_cmdline = new wxTextCtrl(this, IDM_SUBMITCMD, wxEmptyString, wxDefaultPosition, wxDefaultSize, + wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB); //m_cmdline->SetFont(DebuggerFont); sRightBottom->Add(m_cmdline, 1, wxEXPAND); - sRightBottom->Add(new wxButton(this, IDM_SUBMITCMD, wxT("Submit"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT)); sRight->Add(m_log, 1, wxEXPAND | wxSHRINK); sRight->Add(sRightBottom, 0, wxEXPAND); @@ -340,7 +341,29 @@ void CLogWindow::UpdateLog() m_logTimer->Stop(); for (unsigned int i = 0; i < msgQueue.size(); i++) { - m_log->AppendText(msgQueue.front()); + switch (msgQueue.front().first) + { + // AGGH why is this not working + case ERROR_LEVEL: // red + m_log->SetDefaultStyle(wxTextAttr(wxColour(255, 0, 0), wxColour(0, 0, 0))); + break; + case WARNING_LEVEL: // yellow + m_log->SetDefaultStyle(wxTextAttr(wxColour(255, 255, 0), wxColour(0, 0, 0))); + break; + case NOTICE_LEVEL: // green + m_log->SetDefaultStyle(wxTextAttr(wxColour(0, 255, 0), wxColour(0, 0, 0))); + break; + case INFO_LEVEL: // cyan + m_log->SetDefaultStyle(wxTextAttr(wxColour(0, 255, 255), wxColour(0, 0, 0))); + break; + case DEBUG_LEVEL: // light gray + m_log->SetDefaultStyle(wxTextAttr(wxColour(211, 211, 211), wxColour(0, 0, 0))); + break; + default: // white + m_log->SetDefaultStyle(wxTextAttr(wxColour(255, 255, 255), wxColour(0, 0, 0))); + break; + } + m_log->AppendText(msgQueue.front().second); msgQueue.pop(); } m_logTimer->Start(UPDATETIME); @@ -353,5 +376,5 @@ void CLogWindow::Log(LogTypes::LOG_LEVELS level, const char *text) if (msgQueue.size() >= 100) msgQueue.pop(); - msgQueue.push(wxString::FromAscii(text)); + msgQueue.push(std::pair((u8)level, wxString::FromAscii(text))); } diff --git a/Source/Core/DolphinWX/Src/LogWindow.h b/Source/Core/DolphinWX/Src/LogWindow.h index 7c4b4547a7..f0cf279c34 100644 --- a/Source/Core/DolphinWX/Src/LogWindow.h +++ b/Source/Core/DolphinWX/Src/LogWindow.h @@ -32,7 +32,7 @@ enum IDM_WRITECONSOLE, IDTM_UPDATELOG, IDM_VERBOSITY, - IDM_SUBMITCMD = 300, + IDM_SUBMITCMD }; class wxTextCtrl; @@ -60,7 +60,7 @@ private: FileLogListener *m_fileLog; ConsoleListener *m_console; LogManager *m_logManager; - std::queue msgQueue; + std::queue> msgQueue; DECLARE_EVENT_TABLE()