From f42d26252dc3edb93647fefc73224d24f3c7700f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 9 Jun 1998 17:35:25 +0000 Subject: [PATCH] wxLogWindow is now not a top-level frame, so it doesn't prevent the app from being closed git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@80 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/log.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/common/log.cpp b/src/common/log.cpp index 083eca4523..34b2cf0e9b 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -527,6 +527,10 @@ END_EVENT_TABLE() wxLogFrame::wxLogFrame(const char *szTitle) : wxFrame(NULL, -1, szTitle) { + // we don't want to be a top-level frame because it would prevent the + // application termination when all other frames are closed + wxTopLevelWindows.DeleteObject(this); + // @@ kludge: wxSIMPLE_BORDER is simply to prevent wxWindows from creating // a rich edit control instead of a normal one we want m_pTextCtrl = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, @@ -608,8 +612,10 @@ void wxLogFrame::OnSave(wxCommandEvent& event) // retrieve text and save it // ------------------------- +#ifdef __GTK__ // @@@@ TODO: no GetNumberOfLines and GetLineText in wxGTK yet -#ifndef __GTK__ + wxLogError("Sorry, this function is not implemented under GTK"); +#else int nLines = m_pTextCtrl->GetNumberOfLines(); for ( int nLine = 0; bOk && nLine < nLines; nLine++ ) { bOk = file.Write(m_pTextCtrl->GetLineText(nLine) + wxTextFile::GetEOL()); @@ -630,10 +636,13 @@ void wxLogFrame::OnClear(wxCommandEvent& event) m_pTextCtrl->Clear(); } -wxLogWindow::wxLogWindow(const wxTString& strTitle) +wxLogWindow::wxLogWindow(const wxTString& strTitle, bool bShow) { m_pOldLog = wxLog::GetActiveTarget(); m_pLogFrame = new wxLogFrame(strTitle); + + if ( bShow ) + m_pLogFrame->Show(TRUE); } void wxLogWindow::Show(bool bShow) @@ -662,8 +671,10 @@ void wxLogWindow::DoLogString(const char *szString) wxTextCtrl *pText = m_pLogFrame->TextCtrl(); // remove selection (WriteText is in fact ReplaceSelection) - long nLen = pText->GetLastPosition(); - pText->SetSelection(nLen, nLen); + #ifdef __WINDOWS__ + long nLen = pText->GetLastPosition(); + pText->SetSelection(nLen, nLen); + #endif // Windows pText->WriteText(szString); pText->WriteText("\n"); // "\n" ok here (_not_ "\r\n")