+
+#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, wxWindow *parent)
+{
+ // get the file name
+ // -----------------
+ wxString filename = wxSaveFileSelector(wxT("log"), wxT("txt"), wxT("log.txt"), parent);
+ if ( !filename ) {
+ // cancelled
+ return -1;
+ }
+
+ // open file
+ // ---------
+ bool bOk wxDUMMY_INITIALIZE(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_LOG && wxUSE_TEXTCTRL
+
+// ----------------------------------------------------------------------------
+// wxLogTextCtrl implementation
+// ----------------------------------------------------------------------------
+
+wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl *pTextCtrl)
+{
+ m_pTextCtrl = pTextCtrl;
+}
+
+void wxLogTextCtrl::DoLogString(const wxString& szString, time_t WXUNUSED(t))
+{
+ wxString msg;
+ TimeStamp(&msg);
+
+ msg << szString << wxT('\n');
+ m_pTextCtrl->AppendText(msg);
+}
+
+#endif // wxUSE_LOG && wxUSE_TEXTCTRL