From: Włodzimierz Skiba Date: Tue, 20 Jul 2004 19:11:34 +0000 (+0000) Subject: wxUSE_LOG fixes. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f07941fc73d4f263a33e767263c4da507ba9bc54 wxUSE_LOG fixes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28338 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/artprov/arttest.cpp b/samples/artprov/arttest.cpp index 4c991b0258..186fd43003 100644 --- a/samples/artprov/arttest.cpp +++ b/samples/artprov/arttest.cpp @@ -47,7 +47,9 @@ private: // event handlers (these functions should _not_ be virtual) void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); +#if wxUSE_LOG void OnLogs(wxCommandEvent& event); +#endif // wxUSE_LOG void OnBrowser(wxCommandEvent& event); void OnPlugProvider(wxCommandEvent& event); @@ -73,7 +75,9 @@ enum BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(ID_Quit, MyFrame::OnQuit) +#if wxUSE_LOG EVT_MENU(ID_Logs, MyFrame::OnLogs) +#endif // wxUSE_LOG EVT_MENU(wxID_ABOUT, MyFrame::OnAbout) EVT_MENU(ID_Browser, MyFrame::OnBrowser) EVT_MENU(ID_PlugProvider, MyFrame::OnPlugProvider) @@ -155,7 +159,9 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, menuFile->AppendCheckItem(ID_PlugProvider, _T("&Plug-in art provider"), _T("Enable custom art provider")); menuFile->AppendSeparator(); +#if wxUSE_LOG menuFile->Append(ID_Logs, _T("&Logging test"), _T("Show some logging output")); +#endif // wxUSE_LOG menuFile->Append(ID_Browser, _T("&Resources browser"), _T("Browse all available icons")); menuFile->AppendSeparator(); @@ -179,6 +185,7 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) Close(true); } +#if wxUSE_LOG void MyFrame::OnLogs(wxCommandEvent& WXUNUSED(event)) { wxLogMessage(_T("Some information.")); @@ -188,6 +195,7 @@ void MyFrame::OnLogs(wxCommandEvent& WXUNUSED(event)) wxLog::GetActiveTarget()->Flush(); wxLogMessage(_T("Check/uncheck 'File/Plug-in art provider' and try again.")); } +#endif // wxUSE_LOG void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { diff --git a/samples/db/dbtest.cpp b/samples/db/dbtest.cpp index 016c724886..7869c17438 100644 --- a/samples/db/dbtest.cpp +++ b/samples/db/dbtest.cpp @@ -839,13 +839,17 @@ DatabaseDemoFrame::DatabaseDemoFrame(wxFrame *frame, const wxString& title, pEditorDlg = NULL; pParamDlg = NULL; +#if wxUSE_LOG delete wxLog::SetActiveTarget(new wxLogStderr); +#endif // wxUSE_LOG } // DatabaseDemoFrame constructor DatabaseDemoFrame::~DatabaseDemoFrame() { +#if wxUSE_LOG delete wxLog::SetActiveTarget(NULL); +#endif // wxUSE_LOG } // DatabaseDemoFrame destructor diff --git a/samples/dialup/nettest.cpp b/samples/dialup/nettest.cpp index 775527ec30..2c0034e022 100644 --- a/samples/dialup/nettest.cpp +++ b/samples/dialup/nettest.cpp @@ -170,7 +170,9 @@ bool MyApp::OnInit() { wxLogError(wxT("The sample can't run on this system.")); +#if wxUSE_LOG wxLog::GetActiveTarget()->Flush(); +#endif // wxUSE_LOG // do it here, OnExit() won't be called delete m_dial; diff --git a/samples/grid/griddemo.cpp b/samples/grid/griddemo.cpp index 3fcd79e0ff..2857b714fc 100644 --- a/samples/grid/griddemo.cpp +++ b/samples/grid/griddemo.cpp @@ -135,9 +135,6 @@ GridFrame::GridFrame() wxDefaultPosition, wxDefaultSize ) { - int gridW = 600, gridH = 300; - int logW = gridW, logH = 100; - wxMenu *fileMenu = new wxMenu; fileMenu->Append( ID_VTABLE, _T("&Virtual table test\tCtrl-V")); fileMenu->Append( ID_BUGS_TABLE, _T("&Bugs table test\tCtrl-B")); @@ -234,6 +231,10 @@ GridFrame::GridFrame() wxPoint( 0, 0 ), wxSize( 400, 300 ) ); +#if wxUSE_LOG + int gridW = 600, gridH = 300; + int logW = gridW, logH = 100; + logWin = new wxTextCtrl( this, wxID_ANY, wxEmptyString, @@ -244,6 +245,7 @@ GridFrame::GridFrame() logger = new wxLogTextCtrl( logWin ); m_logOld = logger->SetActiveTarget( logger ); logger->SetTimestamp( NULL ); +#endif // wxUSE_LOG // this will create a grid and, by default, an associated grid // table for strings @@ -340,9 +342,11 @@ GridFrame::GridFrame() 1, wxEXPAND ); +#if wxUSE_LOG topSizer->Add( logWin, 0, wxEXPAND ); +#endif // wxUSE_LOG SetSizer( topSizer ); @@ -355,7 +359,9 @@ GridFrame::GridFrame() GridFrame::~GridFrame() { +#if wxUSE_LOG delete wxLog::SetActiveTarget(m_logOld); +#endif // wxUSE_LOG } diff --git a/samples/grid/griddemo.h b/samples/grid/griddemo.h index b10c0b0956..49629b633d 100644 --- a/samples/grid/griddemo.h +++ b/samples/grid/griddemo.h @@ -24,8 +24,10 @@ public: class GridFrame : public wxFrame { wxGrid *grid; +#if wxUSE_LOG wxTextCtrl *logWin; wxLogTextCtrl *logger; +#endif // wxUSE_LOG wxString logBuf; void SetDefaults(); @@ -148,7 +150,9 @@ public: ID_TESTFUNC }; +#if wxUSE_LOG wxLog *m_logOld; +#endif // wxUSE_LOG // add the cells to selection when using commands from select menu? bool m_addToSel; diff --git a/samples/notebook/notebook.cpp b/samples/notebook/notebook.cpp index d10150e17c..f5ed8758e1 100644 --- a/samples/notebook/notebook.cpp +++ b/samples/notebook/notebook.cpp @@ -275,10 +275,12 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, m_btnExit = new wxButton( m_panel, wxID_OK, wxT("&Exit") ); m_btnExit->SetDefault(); +#if wxUSE_LOG m_text = new wxTextCtrl(m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY); m_logTargetOld = wxLog::SetActiveTarget( new wxLogTextCtrl(m_text) ); +#endif // wxUSE_LOG // Set sizers m_sizerFrame = new wxBoxSizer(wxVERTICAL); @@ -308,7 +310,9 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, m_sizerFrame->Add(m_sizerTop, 1, wxEXPAND); +#if wxUSE_LOG m_sizerFrame->Add(m_text, 0, wxEXPAND); +#endif // wxUSE_LOG ReInitNotebook(); m_notebook->CreateInitialPages(); @@ -324,7 +328,9 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, MyFrame::~MyFrame() { +#if wxUSE_LOG delete wxLog::SetActiveTarget(m_logTargetOld); +#endif // wxUSE_LOG if (m_imageList) { @@ -530,7 +536,9 @@ void MyFrame::OnNotebook(wxNotebookEvent& event) wxLogMessage(wxT("Notebook event #%d: %s (%d)"), s_numNotebookEvents++, str.c_str(), eventType); +#if wxUSE_LOG m_text->SetInsertionPointEnd(); +#endif // wxUSE_LOG event.Skip(); } diff --git a/samples/notebook/notebook.h b/samples/notebook/notebook.h index a503874494..8a5bcc7ffb 100644 --- a/samples/notebook/notebook.h +++ b/samples/notebook/notebook.h @@ -117,9 +117,10 @@ private: MyNotebook *m_notebook; +#if wxUSE_LOG // Log window wxTextCtrl *m_text; - +#endif // wxUSE_LOG // Sizers