]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/log.cpp
file I forgot to commit last time (wxCritSection)
[wxWidgets.git] / src / common / log.cpp
index 3fbaa26c99a269bef04556716885aa87c6ad9b40..f99580301def8e4d4a4d43bf8c7c2d8149312783 100644 (file)
@@ -52,6 +52,8 @@
 
 #ifdef  __WXMSW__
   #include  <windows.h>
+  // Redefines OutputDebugString if necessary
+  #include  "wx/msw/private.h"
 #else   //Unix
   #include  <signal.h>
 #endif  //Win/Unix
@@ -256,6 +258,8 @@ wxLog *wxLog::GetActiveTarget()
         // ask the application to create a log target for us
         if ( wxTheApp != NULL )
           ms_pLogger = wxTheApp->CreateLogTarget();
+        else
+          ms_pLogger = new wxLogStderr;
       #endif
 
       s_bInGetActiveTarget = FALSE;
@@ -385,6 +389,7 @@ void wxLogStderr::DoLogString(const char *szString)
 // wxLogStream implementation
 // ----------------------------------------------------------------------------
 
+#if wxUSE_STD_IOSTREAM
 wxLogStream::wxLogStream(ostream *ostr)
 {
   if ( ostr == NULL )
@@ -397,15 +402,17 @@ void wxLogStream::DoLogString(const char *szString)
 {
   (*m_ostr) << szString << endl << flush;
 }
+#endif
 
 #ifndef   wxUSE_NOGUI
+
 // ----------------------------------------------------------------------------
 // wxLogTextCtrl implementation
 // ----------------------------------------------------------------------------
-wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl *pTextCtrl)
-// @@@ TODO: in wxGTK wxTextCtrl doesn't derive from streambuf
 
-// Also, in DLL mode in wxMSW, can't use it.
+#if wxUSE_STD_IOSTREAM
+wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl *pTextCtrl)
+// DLL mode in wxMSW, can't use it.
 #if defined(NO_TEXT_WINDOW_STREAM)
 #else
              : wxLogStream(new ostream(pTextCtrl))
@@ -417,6 +424,7 @@ wxLogTextCtrl::~wxLogTextCtrl()
 {
   delete m_ostr;
 }
+#endif
 
 // ----------------------------------------------------------------------------
 // wxLogGui implementation
@@ -683,22 +691,19 @@ void wxLogFrame::OnSave(wxCommandEvent& WXUNUSED(event))
 
   // retrieve text and save it
   // -------------------------
-#ifdef __WXGTK__
-  // @@@@ TODO: no GetNumberOfLines and GetLineText in wxGTK yet
-  wxLogError(_("Sorry, this function is not implemented under GTK"));
-#else
   int nLines = m_pTextCtrl->GetNumberOfLines();
   for ( int nLine = 0; bOk && nLine < nLines; nLine++ ) {
     bOk = file.Write(m_pTextCtrl->GetLineText(nLine) + wxTextFile::GetEOL());
   }
-#endif //GTK
 
   if ( bOk )
     bOk = file.Close();
 
   if ( !bOk ) {
     wxLogError(_("Can't save log contents to file."));
-    return;
+  }
+  else {
+    wxLogStatus(this, _("Log saved to the file '%s'."), szFileName);
   }
 }
 
@@ -802,11 +807,11 @@ wxFrame *wxLogWindow::GetFrame() const
   return m_pLogFrame;
 }
 
-void wxLogWindow::OnFrameCreate(wxFrame *WXUNUSED(frame))
+void wxLogWindow::OnFrameCreate(wxFrame * WXUNUSED(frame))
 {
 }
 
-void wxLogWindow::OnFrameDelete(wxFrame *WXUNUSED(frame))
+void wxLogWindow::OnFrameDelete(wxFrame * WXUNUSED(frame))
 {
   m_pLogFrame = (wxLogFrame *)NULL;
 }
@@ -943,6 +948,12 @@ void Trap()
     DebugBreak();
   #elif defined(__WXSTUBS__)
     // TODO
+  #elif defined(__WXMAC__)
+  #if __powerc
+    Debugger();
+  #else
+    SysBreak();
+  #endif
   #else // Unix
     raise(SIGTRAP);
   #endif // Win/Unix