Merge the log window CreateGUIControls and LoadSettings methods. This allows the settings from the ini file to be applied when the controls are created rather than setting a default, and then changing the settings later. In particular word wrap is applied when the text control is created. This works around the crash at application start that users are reporting in issue 4196.
Also change the for loops in SysConf to use iterators to placate godisgovernment and billiard. :P git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7283 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
05719ac81a
commit
756c40163d
|
@ -36,11 +36,9 @@ SysConf::~SysConf()
|
||||||
|
|
||||||
void SysConf::Clear()
|
void SysConf::Clear()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_Entries.size() - 1; i++)
|
for (std::vector<SSysConfEntry>::const_iterator i = m_Entries.begin();
|
||||||
{
|
i < m_Entries.end() - 1; i++)
|
||||||
delete [] m_Entries[i].data;
|
delete [] i->data;
|
||||||
m_Entries[i].data = NULL;
|
|
||||||
}
|
|
||||||
m_Entries.clear();
|
m_Entries.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,9 +84,10 @@ bool SysConf::LoadFromFileInternal(FILE *f)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Last offset is an invalid entry. We ignore it throughout this class
|
// Last offset is an invalid entry. We ignore it throughout this class
|
||||||
for (size_t i = 0; i < m_Entries.size() - 1; i++)
|
for (std::vector<SSysConfEntry>::iterator i = m_Entries.begin();
|
||||||
|
i < m_Entries.end() - 1; i++)
|
||||||
{
|
{
|
||||||
SSysConfEntry& curEntry = m_Entries[i];
|
SSysConfEntry& curEntry = *i;
|
||||||
if (fseeko(f, curEntry.offset, SEEK_SET) != 0) return false;
|
if (fseeko(f, curEntry.offset, SEEK_SET) != 0) return false;
|
||||||
|
|
||||||
u8 description = 0;
|
u8 description = 0;
|
||||||
|
@ -144,22 +143,23 @@ bool SysConf::SaveToFile(const char *filename)
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (size_t i = 0; i < m_Entries.size() - 1; i++)
|
for (std::vector<SSysConfEntry>::iterator i = m_Entries.begin();
|
||||||
|
i < m_Entries.end() - 1; i++)
|
||||||
{
|
{
|
||||||
// Seek to after the name of this entry
|
// Seek to after the name of this entry
|
||||||
if (fseeko(f, m_Entries[i].offset + m_Entries[i].nameLength + 1, SEEK_SET) != 0) return false;
|
if (fseeko(f, i->offset + i->nameLength + 1, SEEK_SET) != 0) return false;
|
||||||
// We may have to write array length value...
|
// We may have to write array length value...
|
||||||
if (m_Entries[i].type == Type_BigArray)
|
if (i->type == Type_BigArray)
|
||||||
{
|
{
|
||||||
u16 tmpDataLength = Common::swap16(m_Entries[i].dataLength);
|
u16 tmpDataLength = Common::swap16(i->dataLength);
|
||||||
if (fwrite(&tmpDataLength, 2, 1, f) != 1) return false;
|
if (fwrite(&tmpDataLength, 2, 1, f) != 1) return false;
|
||||||
}
|
}
|
||||||
else if (m_Entries[i].type == Type_SmallArray)
|
else if (i->type == Type_SmallArray)
|
||||||
{
|
{
|
||||||
if (fwrite(&m_Entries[i].dataLength, 1, 1, f) != 1) return false;
|
if (fwrite(&i->dataLength, 1, 1, f) != 1) return false;
|
||||||
}
|
}
|
||||||
// Now write the actual data
|
// Now write the actual data
|
||||||
if (fwrite(m_Entries[i].data, m_Entries[i].dataLength, 1, f) != 1) return false;
|
if (fwrite(i->data, i->dataLength, 1, f) != 1) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
|
@ -93,19 +93,19 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t index = 0;
|
std::vector<SSysConfEntry>::iterator index = m_Entries.begin();
|
||||||
for (; index < m_Entries.size() - 1; index++)
|
for (; index < m_Entries.end() - 1; index++)
|
||||||
{
|
{
|
||||||
if (strcmp(m_Entries[index].name, sectionName) == 0)
|
if (strcmp(index->name, sectionName) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (index == m_Entries.size() - 1)
|
if (index == m_Entries.end() - 1)
|
||||||
{
|
{
|
||||||
PanicAlertT("Section %s not found in SYSCONF", sectionName);
|
PanicAlertT("Section %s not found in SYSCONF", sectionName);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_Entries[index].GetData<T>();
|
return index->GetData<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetArrayData(const char* sectionName, u8* dest, u16 destSize)
|
bool GetArrayData(const char* sectionName, u8* dest, u16 destSize)
|
||||||
|
@ -116,19 +116,19 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t index = 0;
|
std::vector<SSysConfEntry>::iterator index = m_Entries.begin();
|
||||||
for (; index < m_Entries.size() - 1; index++)
|
for (; index < m_Entries.end() - 1; index++)
|
||||||
{
|
{
|
||||||
if (strcmp(m_Entries[index].name, sectionName) == 0)
|
if (strcmp(index->name, sectionName) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (index == m_Entries.size() - 1)
|
if (index == m_Entries.end() - 1)
|
||||||
{
|
{
|
||||||
PanicAlertT("Section %s not found in SYSCONF", sectionName);
|
PanicAlertT("Section %s not found in SYSCONF", sectionName);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_Entries[index].GetArrayData(dest, destSize);
|
return index->GetArrayData(dest, destSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetArrayData(const char* sectionName, u8* buffer, u16 bufferSize)
|
bool SetArrayData(const char* sectionName, u8* buffer, u16 bufferSize)
|
||||||
|
@ -136,19 +136,19 @@ public:
|
||||||
if (!m_IsValid)
|
if (!m_IsValid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
size_t index = 0;
|
std::vector<SSysConfEntry>::iterator index = m_Entries.begin();
|
||||||
for (; index < m_Entries.size() - 1; index++)
|
for (; index < m_Entries.end() - 1; index++)
|
||||||
{
|
{
|
||||||
if (strcmp(m_Entries[index].name, sectionName) == 0)
|
if (strcmp(index->name, sectionName) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (index == m_Entries.size() - 1)
|
if (index == m_Entries.end() - 1)
|
||||||
{
|
{
|
||||||
PanicAlertT("Section %s not found in SYSCONF", sectionName);
|
PanicAlertT("Section %s not found in SYSCONF", sectionName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_Entries[index].SetArrayData(buffer, bufferSize);
|
return index->SetArrayData(buffer, bufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -157,19 +157,19 @@ public:
|
||||||
if (!m_IsValid)
|
if (!m_IsValid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
size_t index = 0;
|
std::vector<SSysConfEntry>::iterator index = m_Entries.begin();
|
||||||
for (; index < m_Entries.size() - 1; index++)
|
for (; index < m_Entries.end() - 1; index++)
|
||||||
{
|
{
|
||||||
if (strcmp(m_Entries[index].name, sectionName) == 0)
|
if (strcmp(index->name, sectionName) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (index == m_Entries.size() - 1)
|
if (index == m_Entries.end() - 1)
|
||||||
{
|
{
|
||||||
PanicAlertT("Section %s not found in SYSCONF", sectionName);
|
PanicAlertT("Section %s not found in SYSCONF", sectionName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(T*)m_Entries[index].data = newValue;
|
*(T*)index->data = newValue;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,43 +61,83 @@ CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_LogManager = LogManager::GetInstance();
|
m_LogManager = LogManager::GetInstance();
|
||||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
|
||||||
m_LogManager->addListener((LogTypes::LOG_TYPE)i, this);
|
|
||||||
m_fileLog = m_LogManager->getFileListener();
|
|
||||||
m_console = m_LogManager->getConsoleListener();
|
|
||||||
|
|
||||||
CreateGUIControls();
|
CreateGUIControls();
|
||||||
|
|
||||||
LoadSettings();
|
|
||||||
|
|
||||||
m_WrapLine->SetValue(m_bWrapLines);
|
|
||||||
ToggleWrapLine(m_bWrapLines);
|
|
||||||
|
|
||||||
m_LogTimer = new wxTimer(this, IDTM_UPDATELOG);
|
m_LogTimer = new wxTimer(this, IDTM_UPDATELOG);
|
||||||
m_LogTimer->Start(UPDATETIME);
|
m_LogTimer->Start(UPDATETIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLogWindow::CreateGUIControls()
|
void CLogWindow::CreateGUIControls()
|
||||||
{
|
{
|
||||||
|
IniFile ini;
|
||||||
|
ini.Load(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
||||||
|
|
||||||
|
ini.Get("LogWindow", "x", &x, Parent->GetSize().GetX() / 2);
|
||||||
|
ini.Get("LogWindow", "y", &y, Parent->GetSize().GetY());
|
||||||
|
ini.Get("LogWindow", "pos", &winpos, wxAUI_DOCK_RIGHT);
|
||||||
|
|
||||||
|
// Set up log listeners
|
||||||
|
int verbosity;
|
||||||
|
ini.Get("Options", "Verbosity", &verbosity, 0);
|
||||||
|
if (verbosity < 1) verbosity = 1;
|
||||||
|
if (verbosity > MAX_LOGLEVEL) verbosity = MAX_LOGLEVEL;
|
||||||
|
|
||||||
|
ini.Get("Options", "WriteToFile", &m_writeFile, false);
|
||||||
|
ini.Get("Options", "WriteToConsole", &m_writeConsole, true);
|
||||||
|
ini.Get("Options", "WriteToWindow", &m_writeWindow, true);
|
||||||
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||||
|
{
|
||||||
|
bool enable;
|
||||||
|
ini.Get("Logs", m_LogManager->getShortName((LogTypes::LOG_TYPE)i), &enable, true);
|
||||||
|
|
||||||
|
if (m_writeWindow && enable)
|
||||||
|
m_LogManager->addListener((LogTypes::LOG_TYPE)i, this);
|
||||||
|
else
|
||||||
|
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, this);
|
||||||
|
|
||||||
|
if (m_writeFile && enable)
|
||||||
|
m_LogManager->addListener((LogTypes::LOG_TYPE)i, m_LogManager->getFileListener());
|
||||||
|
else
|
||||||
|
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, m_LogManager->getFileListener());
|
||||||
|
|
||||||
|
if (m_writeConsole && enable)
|
||||||
|
m_LogManager->addListener((LogTypes::LOG_TYPE)i, m_LogManager->getConsoleListener());
|
||||||
|
else
|
||||||
|
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, m_LogManager->getConsoleListener());
|
||||||
|
m_LogManager->setLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)(verbosity));
|
||||||
|
}
|
||||||
|
|
||||||
// Font
|
// Font
|
||||||
m_FontChoice = new wxChoice(this, IDM_FONT,
|
m_FontChoice = new wxChoice(this, IDM_FONT,
|
||||||
wxDefaultPosition, wxDefaultSize, 0, NULL, 0, wxDefaultValidator);
|
wxDefaultPosition, wxDefaultSize, 0, NULL, 0, wxDefaultValidator);
|
||||||
m_FontChoice->Append(_("Default font"));
|
m_FontChoice->Append(_("Default font"));
|
||||||
m_FontChoice->Append(_("Monospaced font"));
|
m_FontChoice->Append(_("Monospaced font"));
|
||||||
m_FontChoice->Append(_("Selected font"));
|
m_FontChoice->Append(_("Selected font"));
|
||||||
m_FontChoice->SetSelection(0);
|
|
||||||
DefaultFont = GetFont();
|
DefaultFont = GetFont();
|
||||||
MonoSpaceFont.SetNativeFontInfoUserDesc(_T("lucida console windows-1252"));
|
MonoSpaceFont.SetNativeFontInfoUserDesc(_T("lucida console windows-1252"));
|
||||||
LogFont.push_back(DefaultFont);
|
LogFont.push_back(DefaultFont);
|
||||||
LogFont.push_back(MonoSpaceFont);
|
LogFont.push_back(MonoSpaceFont);
|
||||||
LogFont.push_back(DebuggerFont);
|
LogFont.push_back(DebuggerFont);
|
||||||
|
|
||||||
m_WrapLine = new wxCheckBox(this, IDM_WRAPLINE, _("Word Wrap"));
|
int font;
|
||||||
|
ini.Get("Options", "Font", &font, 0);
|
||||||
|
m_FontChoice->SetSelection(font);
|
||||||
|
|
||||||
// Log viewer and submit row
|
// Word wrap
|
||||||
m_Log = CreateTextCtrl(this, IDM_LOG, wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
|
bool wrap_lines;
|
||||||
|
ini.Get("Options", "WrapLines", &wrap_lines, false);
|
||||||
|
m_WrapLine = new wxCheckBox(this, IDM_WRAPLINE, _("Word Wrap"));
|
||||||
|
m_WrapLine->SetValue(wrap_lines);
|
||||||
|
|
||||||
|
// Log viewer
|
||||||
|
m_Log = CreateTextCtrl(this, IDM_LOG, wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY |
|
||||||
|
(wrap_lines ? wxTE_WORDWRAP : wxTE_DONTWRAP));
|
||||||
|
|
||||||
|
// submit row
|
||||||
m_cmdline = new wxTextCtrl(this, IDM_SUBMITCMD, wxEmptyString, wxDefaultPosition, wxDefaultSize,
|
m_cmdline = new wxTextCtrl(this, IDM_SUBMITCMD, wxEmptyString, wxDefaultPosition, wxDefaultSize,
|
||||||
wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
|
wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
|
||||||
|
|
||||||
// Sizers
|
// Sizers
|
||||||
wxBoxSizer *sTop = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer *sTop = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
@ -107,7 +147,7 @@ void CLogWindow::CreateGUIControls()
|
||||||
sTop->Add(m_WrapLine, 0, wxALIGN_CENTER_VERTICAL);
|
sTop->Add(m_WrapLine, 0, wxALIGN_CENTER_VERTICAL);
|
||||||
|
|
||||||
sBottom = new wxBoxSizer(wxVERTICAL);
|
sBottom = new wxBoxSizer(wxVERTICAL);
|
||||||
PopulateRight();
|
PopulateBottom();
|
||||||
|
|
||||||
wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL);
|
||||||
sMain->Add(sTop, 0, wxEXPAND);
|
sMain->Add(sTop, 0, wxEXPAND);
|
||||||
|
@ -157,57 +197,10 @@ void CLogWindow::SaveSettings()
|
||||||
ini.Set("LogWindow", "pos", winpos);
|
ini.Set("LogWindow", "pos", winpos);
|
||||||
}
|
}
|
||||||
ini.Set("Options", "Font", m_FontChoice->GetSelection());
|
ini.Set("Options", "Font", m_FontChoice->GetSelection());
|
||||||
ini.Set("Options", "WrapLines", m_bWrapLines);
|
ini.Set("Options", "WrapLines", m_WrapLine->IsChecked());
|
||||||
ini.Save(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
ini.Save(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLogWindow::LoadSettings()
|
|
||||||
{
|
|
||||||
IniFile ini;
|
|
||||||
ini.Load(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
|
||||||
|
|
||||||
ini.Get("LogWindow", "x", &x, Parent->GetSize().GetX() / 2);
|
|
||||||
ini.Get("LogWindow", "y", &y, Parent->GetSize().GetY());
|
|
||||||
ini.Get("LogWindow", "pos", &winpos, wxAUI_DOCK_RIGHT);
|
|
||||||
|
|
||||||
int verbosity,font;
|
|
||||||
ini.Get("Options", "Verbosity", &verbosity, 0);
|
|
||||||
if (verbosity < 1) verbosity = 1;
|
|
||||||
if (verbosity > MAX_LOGLEVEL) verbosity = MAX_LOGLEVEL;
|
|
||||||
|
|
||||||
ini.Get("Options", "Font", &font, 0);
|
|
||||||
m_FontChoice->SetSelection(font);
|
|
||||||
if (m_FontChoice->GetSelection() < (int)LogFont.size())
|
|
||||||
m_Log->SetDefaultStyle(wxTextAttr(wxNullColour, wxNullColour, LogFont[m_FontChoice->GetSelection()]));
|
|
||||||
|
|
||||||
ini.Get("Options", "WrapLines", &m_bWrapLines, false);
|
|
||||||
|
|
||||||
ini.Get("Options", "WriteToFile", &m_writeFile, false);
|
|
||||||
ini.Get("Options", "WriteToConsole", &m_writeConsole, true);
|
|
||||||
ini.Get("Options", "WriteToWindow", &m_writeWindow, true);
|
|
||||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
|
||||||
{
|
|
||||||
bool enable;
|
|
||||||
ini.Get("Logs", m_LogManager->getShortName((LogTypes::LOG_TYPE)i), &enable, true);
|
|
||||||
|
|
||||||
if (m_writeWindow && enable)
|
|
||||||
m_LogManager->addListener((LogTypes::LOG_TYPE)i, this);
|
|
||||||
else
|
|
||||||
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, this);
|
|
||||||
|
|
||||||
if (m_writeFile && enable)
|
|
||||||
m_LogManager->addListener((LogTypes::LOG_TYPE)i, m_fileLog);
|
|
||||||
else
|
|
||||||
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog);
|
|
||||||
|
|
||||||
if (m_writeConsole && enable)
|
|
||||||
m_LogManager->addListener((LogTypes::LOG_TYPE)i, m_console);
|
|
||||||
else
|
|
||||||
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, m_console);
|
|
||||||
m_LogManager->setLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)(verbosity));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CLogWindow::OnSubmit(wxCommandEvent& WXUNUSED (event))
|
void CLogWindow::OnSubmit(wxCommandEvent& WXUNUSED (event))
|
||||||
{
|
{
|
||||||
if (!m_cmdline) return;
|
if (!m_cmdline) return;
|
||||||
|
@ -225,16 +218,16 @@ void CLogWindow::OnClear(wxCommandEvent& WXUNUSED (event))
|
||||||
msgQueue.pop();
|
msgQueue.pop();
|
||||||
m_LogSection.Leave();
|
m_LogSection.Leave();
|
||||||
|
|
||||||
m_console->ClearScreen();
|
m_LogManager->getConsoleListener()->ClearScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLogWindow::UnPopulateRight()
|
void CLogWindow::UnPopulateBottom()
|
||||||
{
|
{
|
||||||
sBottom->Detach(m_Log);
|
sBottom->Detach(m_Log);
|
||||||
sBottom->Detach(m_cmdline);
|
sBottom->Detach(m_cmdline);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLogWindow::PopulateRight()
|
void CLogWindow::PopulateBottom()
|
||||||
{
|
{
|
||||||
sBottom->Add(m_Log, 1, wxEXPAND | wxSHRINK);
|
sBottom->Add(m_Log, 1, wxEXPAND | wxSHRINK);
|
||||||
sBottom->Add(m_cmdline, 0, wxEXPAND);
|
sBottom->Add(m_cmdline, 0, wxEXPAND);
|
||||||
|
@ -249,11 +242,9 @@ wxTextCtrl* CLogWindow::CreateTextCtrl(wxPanel* parent, wxWindowID id, long Styl
|
||||||
#else
|
#else
|
||||||
TC->SetBackgroundColour(*wxBLACK);
|
TC->SetBackgroundColour(*wxBLACK);
|
||||||
#endif
|
#endif
|
||||||
if (m_FontChoice)
|
if (m_FontChoice && m_FontChoice->GetSelection() < (int)LogFont.size())
|
||||||
{
|
TC->SetDefaultStyle(wxTextAttr(wxNullColour, wxNullColour, LogFont[m_FontChoice->GetSelection()]));
|
||||||
if (m_FontChoice->GetSelection() < (int)LogFont.size())
|
|
||||||
TC->SetDefaultStyle(wxTextAttr(wxNullColour, wxNullColour, LogFont[m_FontChoice->GetSelection()]));
|
|
||||||
}
|
|
||||||
return TC;
|
return TC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,17 +259,10 @@ void CLogWindow::OnFontChange(wxCommandEvent& event)
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
// When an option is changed, save the change
|
|
||||||
void CLogWindow::OnWrapLineCheck(wxCommandEvent& event)
|
void CLogWindow::OnWrapLineCheck(wxCommandEvent& event)
|
||||||
{
|
|
||||||
m_bWrapLines ^= true;
|
|
||||||
ToggleWrapLine(event.IsChecked());
|
|
||||||
SaveSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CLogWindow::ToggleWrapLine(bool word_wrap)
|
|
||||||
{
|
{
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
|
// Clear the old word wrap state and set the new
|
||||||
m_Log->SetWindowStyleFlag(m_Log->GetWindowStyleFlag() ^ (wxTE_WORDWRAP | wxTE_DONTWRAP));
|
m_Log->SetWindowStyleFlag(m_Log->GetWindowStyleFlag() ^ (wxTE_WORDWRAP | wxTE_DONTWRAP));
|
||||||
#else
|
#else
|
||||||
wxString Text;
|
wxString Text;
|
||||||
|
@ -287,10 +271,10 @@ void CLogWindow::ToggleWrapLine(bool word_wrap)
|
||||||
// loop through every letter with GetStyle and then reapply them letter by letter
|
// loop through every letter with GetStyle and then reapply them letter by letter
|
||||||
// Prevent m_Log access while it's being destroyed
|
// Prevent m_Log access while it's being destroyed
|
||||||
m_LogAccess = false;
|
m_LogAccess = false;
|
||||||
UnPopulateRight();
|
UnPopulateBottom();
|
||||||
Text = m_Log->GetValue();
|
Text = m_Log->GetValue();
|
||||||
m_Log->Destroy();
|
m_Log->Destroy();
|
||||||
if (word_wrap)
|
if (event.IsChecked())
|
||||||
m_Log = CreateTextCtrl(this, IDM_LOG,
|
m_Log = CreateTextCtrl(this, IDM_LOG,
|
||||||
wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_WORDWRAP);
|
wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_WORDWRAP);
|
||||||
else
|
else
|
||||||
|
@ -298,9 +282,10 @@ void CLogWindow::ToggleWrapLine(bool word_wrap)
|
||||||
wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
|
wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
|
||||||
m_Log->SetDefaultStyle(wxTextAttr(*wxWHITE));
|
m_Log->SetDefaultStyle(wxTextAttr(*wxWHITE));
|
||||||
m_Log->AppendText(Text);
|
m_Log->AppendText(Text);
|
||||||
PopulateRight();
|
PopulateBottom();
|
||||||
m_LogAccess = true;
|
m_LogAccess = true;
|
||||||
#endif
|
#endif
|
||||||
|
SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLogWindow::OnLogTimer(wxTimerEvent& WXUNUSED(event))
|
void CLogWindow::OnLogTimer(wxTimerEvent& WXUNUSED(event))
|
||||||
|
|
|
@ -53,7 +53,6 @@ public:
|
||||||
~CLogWindow();
|
~CLogWindow();
|
||||||
|
|
||||||
void SaveSettings();
|
void SaveSettings();
|
||||||
void LoadSettings();
|
|
||||||
void Log(LogTypes::LOG_LEVELS, const char *text);
|
void Log(LogTypes::LOG_LEVELS, const char *text);
|
||||||
|
|
||||||
int x, y, winpos;
|
int x, y, winpos;
|
||||||
|
@ -63,11 +62,9 @@ private:
|
||||||
wxFont DefaultFont, MonoSpaceFont;
|
wxFont DefaultFont, MonoSpaceFont;
|
||||||
std::vector<wxFont> LogFont;
|
std::vector<wxFont> LogFont;
|
||||||
wxTimer *m_LogTimer;
|
wxTimer *m_LogTimer;
|
||||||
FileLogListener *m_fileLog;
|
|
||||||
ConsoleListener *m_console;
|
|
||||||
LogManager *m_LogManager;
|
LogManager *m_LogManager;
|
||||||
std::queue<std::pair<u8, wxString> > msgQueue;
|
std::queue<std::pair<u8, wxString> > msgQueue;
|
||||||
bool m_writeFile, m_writeConsole, m_writeWindow, m_LogAccess, m_bWrapLines;
|
bool m_writeFile, m_writeConsole, m_writeWindow, m_LogAccess;
|
||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
wxBoxSizer *sBottom;
|
wxBoxSizer *sBottom;
|
||||||
|
@ -83,13 +80,13 @@ private:
|
||||||
|
|
||||||
wxTextCtrl * CreateTextCtrl(wxPanel* parent, wxWindowID id = wxID_ANY, long Style = NULL);
|
wxTextCtrl * CreateTextCtrl(wxPanel* parent, wxWindowID id = wxID_ANY, long Style = NULL);
|
||||||
void CreateGUIControls();
|
void CreateGUIControls();
|
||||||
void PopulateRight(); void UnPopulateRight();
|
void PopulateBottom();
|
||||||
|
void UnPopulateBottom();
|
||||||
void OnClose(wxCloseEvent& event);
|
void OnClose(wxCloseEvent& event);
|
||||||
void OnSize(wxSizeEvent& event);
|
void OnSize(wxSizeEvent& event);
|
||||||
void OnSubmit(wxCommandEvent& event);
|
void OnSubmit(wxCommandEvent& event);
|
||||||
void OnFontChange(wxCommandEvent& event);
|
void OnFontChange(wxCommandEvent& event);
|
||||||
void OnWrapLineCheck(wxCommandEvent& event);
|
void OnWrapLineCheck(wxCommandEvent& event);
|
||||||
void ToggleWrapLine(bool word_wrap);
|
|
||||||
void OnClear(wxCommandEvent& event);
|
void OnClear(wxCommandEvent& event);
|
||||||
void OnLogTimer(wxTimerEvent& WXUNUSED(event));
|
void OnLogTimer(wxTimerEvent& WXUNUSED(event));
|
||||||
void UpdateLog();
|
void UpdateLog();
|
||||||
|
|
Loading…
Reference in New Issue