// wxWindows
#ifndef WX_PRECOMP
- #include <wx/event.h>
- #include <wx/app.h>
- #include <wx/string.h>
- #include <wx/intl.h>
- #include <wx/menu.h>
- #include <wx/frame.h>
- #include <wx/msgdlg.h>
- #include <wx/filedlg.h>
- #include <wx/textctrl.h>
+ #include "wx/window.h"
+#ifdef __WXMSW__
+ #include "wx/msw/private.h"
+#endif
+ #include "wx/event.h"
+ #include "wx/app.h"
+ #include "wx/string.h"
+ #include "wx/intl.h"
+ #include "wx/menu.h"
+ #include "wx/frame.h"
+ #include "wx/msgdlg.h"
+ #include "wx/filedlg.h"
+ #include "wx/textctrl.h"
#endif //WX_PRECOMP
-#include <wx/file.h>
-#include <wx/textfile.h>
-#include <wx/utils.h>
-#include <wx/log.h>
+#include "wx/file.h"
+#include "wx/textfile.h"
+#include "wx/utils.h"
+#include "wx/log.h"
// other standard headers
#include <errno.h>
void wxLog::DoLog(wxLogLevel level, const wxChar *szString, time_t t)
{
- wxString str;
-
switch ( level ) {
case wxLOG_FatalError:
- DoLogString(str << _("Fatal error: ") << szString, t);
+ DoLogString(wxString(_("Fatal error: ")) + szString, t);
DoLogString(_("Program aborted."), t);
Flush();
abort();
break;
case wxLOG_Error:
- DoLogString(str << _("Error: ") << szString, t);
+ DoLogString(wxString(_("Error: ")) + szString, t);
break;
case wxLOG_Warning:
- DoLogString(str << _("Warning: ") << szString, t);
+ DoLogString(wxString(_("Warning: ")) + szString, t);
break;
case wxLOG_Info:
if ( GetVerbose() )
case wxLOG_Message:
- DoLogString(str + szString, t);
+ default: // log unknown log levels too
+ DoLogString(szString, t);
// fall through
case wxLOG_Status:
DoLogString(szString, t);
#endif
break;
-
- default:
- wxFAIL_MSG(_("unknown log level in wxLog::DoLog"));
}
}
-void wxLog::DoLogString(const wxChar *WXUNUSED(szString), time_t t)
+void wxLog::DoLogString(const wxChar *WXUNUSED(szString), time_t WXUNUSED(t))
{
wxFAIL_MSG(_T("DoLogString must be overriden if it's called."));
}
m_fp = fp;
}
-void wxLogStderr::DoLogString(const wxChar *szString, time_t t)
+void wxLogStderr::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
{
wxString str(szString);
str << _T('\n');
m_ostr = ostr;
}
-void wxLogStream::DoLogString(const wxChar *szString, time_t t)
+void wxLogStream::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
{
- (*m_ostr) << szString << endl << flush;
+ (*m_ostr) << wxConvCurrent->cWX2MB(szString) << endl << flush;
}
#endif // wxUSE_STD_IOSTREAM
break;
case wxLOG_Status:
+#if wxUSE_STATUSBAR
{
// find the top window and set it's status text if it has any
wxFrame *pFrame = gs_pFrame;
if ( pFrame != NULL )
pFrame->SetStatusText(szString);
}
+#endif // wxUSE_STATUSBAR
break;
case wxLOG_Trace:
m_aMessages.Add(szString);
m_aTimes.Add((long)t);
break;
-
- default:
- wxFAIL_MSG(_("unknown log level in wxLogGui::DoLog"));
}
}
// menu callbacks
void OnClose(wxCommandEvent& event);
void OnCloseWindow(wxCloseEvent& event);
+#if wxUSE_FILE
void OnSave (wxCommandEvent& event);
+#endif // wxUSE_FILE
void OnClear(wxCommandEvent& event);
void OnIdle(wxIdleEvent&);
BEGIN_EVENT_TABLE(wxLogFrame, wxFrame)
// wxLogWindow menu events
EVT_MENU(Menu_Close, wxLogFrame::OnClose)
+#if wxUSE_FILE
EVT_MENU(Menu_Save, wxLogFrame::OnSave)
+#endif // wxUSE_FILE
EVT_MENU(Menu_Clear, wxLogFrame::OnClear)
EVT_CLOSE(wxLogFrame::OnCloseWindow)
// create menu
wxMenuBar *pMenuBar = new wxMenuBar;
wxMenu *pMenu = new wxMenu;
+#if wxUSE_FILE
pMenu->Append(Menu_Save, _("&Save..."), _("Save log contents to file"));
+#endif // wxUSE_FILE
pMenu->Append(Menu_Clear, _("C&lear"), _("Clear the log contents"));
pMenu->AppendSeparator();
pMenu->Append(Menu_Close, _("&Close"), _("Close this window"));
pMenuBar->Append(pMenu, _("&Log"));
SetMenuBar(pMenuBar);
+#if wxUSE_STATUSBAR
// status bar for menu prompts
CreateStatusBar();
+#endif // wxUSE_STATUSBAR
m_log->OnFrameCreate(this);
}
DoClose();
}
+#if wxUSE_FILE
void wxLogFrame::OnSave(wxCommandEvent& WXUNUSED(event))
{
// get the file name
wxLogStatus(this, _("Log saved to the file '%s'."), szFileName);
}
}
+#endif // wxUSE_FILE
void wxLogFrame::OnClear(wxCommandEvent& WXUNUSED(event))
{
// wxLogWindow
// -----------
wxLogWindow::wxLogWindow(wxFrame *pParent,
- const wxChar *szTitle,
- bool bShow,
- bool bDoPass)
+ const wxChar *szTitle,
+ bool bShow,
+ bool bDoPass)
{
m_bPassMessages = bDoPass;
m_bHasMessages = TRUE;
}
-void wxLogWindow::DoLogString(const wxChar *szString, time_t t)
+void wxLogWindow::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
{
// put the text into our window
wxTextCtrl *pText = m_pLogFrame->TextCtrl();
#else // Unix
#if wxUSE_UNICODE
static wxChar s_szBuf[LOG_BUFFER_SIZE / 2];
- wxConv_libc.MB2WC(s_szBuf, strerror(nErrCode), WXSIZEOF(s_szBuf) -1);
+ wxConvCurrent->MB2WC(s_szBuf, strerror(nErrCode), WXSIZEOF(s_szBuf) -1);
return s_szBuf;
#else
return strerror(nErrCode);
}
// this function is called when an assert fails
-void wxOnAssert(const char *szFile, int nLine, const wxChar *szMsg)
+void wxOnAssert(const wxChar *szFile, int nLine, const wxChar *szMsg)
{
// this variable can be set to true to suppress "assert failure" messages
static bool s_bNoAsserts = FALSE;
wxSprintf(szBuf, _T("%s(%d): assert failed"), szFile, nLine);
#else // !VC++
// make the error message more clear for all the others
-#ifdef wxSprintf
wxSprintf(szBuf, _T("Assert failed in file %s at line %d"), szFile, nLine);
-#else
- wxSprintf(szBuf, _T("Assert failed in file %hs at line %d"), szFile, nLine);
-#endif
#endif // VC/!VC
if ( szMsg != NULL ) {