+
+#if wxUSE_FILE && wxUSE_FILEDLG
+
+// pass an uninitialized file object, the function will ask the user for the
+// filename and try to open it, returns TRUE on success (file was opened),
+// FALSE if file couldn't be opened/created and -1 if the file selection
+// dialog was cancelled
+static int OpenLogFile(wxFile& file, wxString *pFilename)
+{
+ // get the file name
+ // -----------------
+ wxString filename = wxSaveFileSelector(wxT("log"), wxT("txt"), wxT("log.txt"));
+ if ( !filename ) {
+ // cancelled
+ return -1;
+ }
+
+ // open file
+ // ---------
+ bool bOk = FALSE;
+ if ( wxFile::Exists(filename) ) {
+ bool bAppend = FALSE;
+ wxString strMsg;
+ strMsg.Printf(_("Append log to file '%s' (choosing [No] will overwrite it)?"),
+ filename.c_str());
+ switch ( wxMessageBox(strMsg, _("Question"),
+ wxICON_QUESTION | wxYES_NO | wxCANCEL) ) {
+ case wxYES:
+ bAppend = TRUE;
+ break;
+
+ case wxNO:
+ bAppend = FALSE;
+ break;
+
+ case wxCANCEL:
+ return -1;
+
+ default:
+ wxFAIL_MSG(_("invalid message box return value"));
+ }
+
+ if ( bAppend ) {
+ bOk = file.Open(filename, wxFile::write_append);
+ }
+ else {
+ bOk = file.Create(filename, TRUE /* overwrite */);
+ }
+ }
+ else {
+ bOk = file.Create(filename);
+ }
+
+ if ( pFilename )
+ *pFilename = filename;
+
+ return bOk;
+}
+
+#endif // wxUSE_FILE
+
+#endif // !(wxUSE_LOGGUI || wxUSE_LOGWINDOW)
+
+#if wxUSE_TEXTCTRL
+
+// ----------------------------------------------------------------------------
+// wxLogTextCtrl implementation
+// ----------------------------------------------------------------------------
+
+wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl *pTextCtrl)
+{
+ m_pTextCtrl = pTextCtrl;
+}
+
+void wxLogTextCtrl::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
+{
+ wxString msg;
+ TimeStamp(&msg);
+
+#if defined(__WXMAC__)
+ // VZ: this is a bug in wxMac, it *must* accept '\n' as new line, the
+ // translation must be done in wxTextCtrl, not here! (FIXME)
+ msg << szString << wxT('\r');
+#else
+ msg << szString << wxT('\n');
+#endif
+
+ m_pTextCtrl->AppendText(msg);
+}
+
+#endif // wxUSE_TEXTCTRL
+