+
+#if CAN_SAVE_FILES
+
+// 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 = true; // suppress warning about it being possible uninitialized
+ 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 // CAN_SAVE_FILES
+
+#endif // !(wxUSE_LOGGUI || wxUSE_LOGWINDOW)
+
+#if wxUSE_LOG && wxUSE_TEXTCTRL
+
+// ----------------------------------------------------------------------------
+// wxLogTextCtrl implementation
+// ----------------------------------------------------------------------------
+
+wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl *pTextCtrl)
+{
+ m_pTextCtrl = pTextCtrl;
+}
+
+void wxLogTextCtrl::DoLogText(const wxString& msg)
+{
+ m_pTextCtrl->AppendText(msg + wxS('\n'));
+}
+
+#endif // wxUSE_LOG && wxUSE_TEXTCTRL