From f94dfb3897b96c8884210f9dc0a2cf225ab12898 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 25 Nov 2000 23:13:06 +0000 Subject: [PATCH] applied (part of) Alexey Leko's patch git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8819 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/log.cpp | 3 +++ src/generic/logg.cpp | 22 +++++++++++++++++++--- src/msw/control.cpp | 1 + src/msw/font.cpp | 1 + src/msw/gdiimage.cpp | 1 + src/msw/icon.cpp | 1 + 6 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/common/log.cpp b/src/common/log.cpp index e7669a12e9..18428e6d0c 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -50,6 +50,8 @@ #include "wx/log.h" #include "wx/thread.h" +#if wxUSE_LOG + // other standard headers #include #include @@ -790,3 +792,4 @@ void wxOnAssert(const wxChar *szFile, int nLine, const wxChar *szMsg) #endif //WXDEBUG +#endif //wxUSE_LOG diff --git a/src/generic/logg.cpp b/src/generic/logg.cpp index d52e34447d..0891c8de9a 100644 --- a/src/generic/logg.cpp +++ b/src/generic/logg.cpp @@ -50,6 +50,8 @@ #include "wx/textfile.h" #include "wx/statline.h" +#if wxUSE_LOG + #ifdef __WXMSW__ // for OutputDebugString() #include "wx/msw/private.h" @@ -60,7 +62,6 @@ #define wxUSE_LOG_DIALOG 1 #if wxUSE_LOG_DIALOG - #include "wx/datetime.h" #include "wx/listctrl.h" #include "wx/imaglist.h" #include "wx/image.h" @@ -74,6 +75,20 @@ #if wxUSE_LOG_DIALOG +// this function is a wrapper around strftime(3) +// allows to exclude the usage of wxDateTime +static wxString TimeStamp(const wxChar *format, time_t t) +{ + wxChar buf[4096]; + if ( !wxStrftime(buf, WXSIZEOF(buf), format, localtime(&t)) ) + { + // buffer is too small? + wxFAIL_MSG(_T("strftime() failed")); + } + return wxString(buf); +} + + class wxLogDialog : public wxDialog { public: @@ -861,7 +876,7 @@ void wxLogDialog::CreateDetailsControls() m_listctrl->InsertItem(n, m_messages[n]); m_listctrl->SetItem(n, 1, - wxDateTime((time_t)m_times[n]).Format(fmt)); + TimeStamp(fmt, (time_t)m_times[n])); } // let the columns size themselves @@ -917,7 +932,7 @@ void wxLogDialog::OnSave(wxCommandEvent& WXUNUSED(event)) for ( size_t n = 0; ok && (n < count); n++ ) { wxString line; - line << wxDateTime((time_t)m_times[n]).Format(fmt) + line << TimeStamp(fmt, (time_t)m_times[n]) << _T(": ") << m_messages[n] << wxTextFile::GetEOL(); @@ -1056,3 +1071,4 @@ static int OpenLogFile(wxFile& file, wxString *pFilename) #endif // wxUSE_FILE +#endif // wxUSE_LOG diff --git a/src/msw/control.cpp b/src/msw/control.cpp index 656d3f45c2..1bea290c7e 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -24,6 +24,7 @@ #include "wx/event.h" #include "wx/app.h" #include "wx/dcclient.h" +#include "wx/log.h" #endif #include "wx/control.h" diff --git a/src/msw/font.cpp b/src/msw/font.cpp index 472b616884..acb3be04c5 100644 --- a/src/msw/font.cpp +++ b/src/msw/font.cpp @@ -35,6 +35,7 @@ #include "wx/utils.h" #include "wx/app.h" #include "wx/font.h" + #include "wx/log.h" #endif // WX_PRECOMP #include "wx/msw/private.h" diff --git a/src/msw/gdiimage.cpp b/src/msw/gdiimage.cpp index d880396fdb..4123b7d4f6 100644 --- a/src/msw/gdiimage.cpp +++ b/src/msw/gdiimage.cpp @@ -30,6 +30,7 @@ #ifndef WX_PRECOMP #include "wx/string.h" + #include "wx/log.h" #endif // WX_PRECOMP #include "wx/msw/private.h" diff --git a/src/msw/icon.cpp b/src/msw/icon.cpp index a7e1fcad9d..fa2c11ffaf 100644 --- a/src/msw/icon.cpp +++ b/src/msw/icon.cpp @@ -35,6 +35,7 @@ #include "wx/app.h" #include "wx/icon.h" #include "wx/bitmap.h" + #include "wx/log.h" #endif #include "wx/msw/private.h" -- 2.45.2