Applied initial patches for wx2.8 compatibility
[ctsim.git] / src / docs.cpp
index 0f07a5223507874b56fc5c7c59a20838a512f942..028c8214fe24841e2700209bbd4c6f670620d534 100644 (file)
@@ -51,12 +51,12 @@ IMPLEMENT_DYNAMIC_CLASS(ImageFileDocument, wxDocument)
 
 bool ImageFileDocument::OnSaveDocument(const wxString& filename)
 {
-  if (! m_pImageFile->fileWrite (filename)) {
-    *theApp->getLog() << "Unable to write image file " << filename << "\n";
+  if (! m_pImageFile->fileWrite (filename.mb_str(wxConvUTF8))) {
+    *theApp->getLog() << _T("Unable to write image file ") << filename << _T("\n");
     return false;
   }
   if (theApp->getVerboseLogging())
-    *theApp->getLog() << "Wrote image file " << filename << "\n";
+    *theApp->getLog() << _T("Wrote image file ") << filename << _T("\n");
   Modify(false);
   return true;
 }
@@ -66,14 +66,14 @@ bool ImageFileDocument::OnOpenDocument(const wxString& filename)
   if (! OnSaveModified())
     return false;
 
-  if (! m_pImageFile->fileRead (filename.c_str())) {
-    *theApp->getLog() << "Unable to read image file " << filename << "\n";
+  if (! m_pImageFile->fileRead (filename.mb_str(wxConvUTF8))) {
+    *theApp->getLog() << _T("Unable to read image file ") << filename << _T("\n");
     m_bBadFileOpen = true;
     return false;
   }
 
-  if (theApp->getVerboseLogging() && filename != "")
-    *theApp->getLog() << "Read image file " << filename << "\n";
+  if (theApp->getVerboseLogging() && filename != _T(""))
+    *theApp->getLog() << _T("Read image file ") << filename << _T("\n");
 
   SetFilename(filename, true);
   Modify(false);
@@ -106,13 +106,13 @@ bool
 ImageFileDocument::Revert ()
 {
   if (IsModified()) {
-    wxString msg ("Revert to saved ");
+    wxString msg (_T("Revert to saved "));
     msg += GetFilename();
-    msg += "?";
-    wxMessageDialog dialog (getView()->getFrame(), msg, "Are you sure?", wxYES_NO | wxNO_DEFAULT);
+    msg += _T("?");
+    wxMessageDialog dialog (getView()->getFrame(), msg, _T("Are you sure?"), wxYES_NO | wxNO_DEFAULT);
     if (dialog.ShowModal() == wxID_YES) {
       if (theApp->getVerboseLogging())
-        *theApp->getLog() << "Reverting to saved " << GetFilename() << "\n";
+        *theApp->getLog() << _T("Reverting to saved ") << GetFilename() << _T("\n");
       Modify (false);
       OnOpenDocument (GetFilename());
     }
@@ -177,7 +177,7 @@ BackgroundProcessingDocument::cancelRunningTasks()
 
   while (m_vecpBackgroundSupervisors.size() > 0) {
      ::wxYield();
-     ::wxUsleep(50);
+     ::wxMilliSleep(50);
   }
 #endif
 }
@@ -190,12 +190,12 @@ IMPLEMENT_DYNAMIC_CLASS(ProjectionFileDocument, BackgroundProcessingDocument)
 bool
 ProjectionFileDocument::OnSaveDocument(const wxString& filename)
 {
-  if (! m_pProjectionFile->write (filename.c_str())) {
-    *theApp->getLog() << "Unable to write projection file " << filename << "\n";
+  if (! m_pProjectionFile->write (filename.mb_str(wxConvUTF8))) {
+    *theApp->getLog() << _T("Unable to write projection file ") << filename << _T("\n");
     return false;
   }
   if (theApp->getVerboseLogging())
-    *theApp->getLog() << "Wrote projection file " << filename << "\n";
+    *theApp->getLog() << _T("Wrote projection file ") << filename << _T("\n");
   Modify(false);
   return true;
 }
@@ -213,15 +213,15 @@ ProjectionFileDocument::OnOpenDocument(const wxString& filename)
   if (! OnSaveModified())
     return false;
 
-  if (! m_pProjectionFile->read (filename.c_str())) {
-    *theApp->getLog() << "Unable to read projection file " << filename << "\n";
+  if (! m_pProjectionFile->read (filename.mb_str(wxConvUTF8))) {
+    *theApp->getLog() << _T("Unable to read projection file ") << filename << _T("\n");
     m_bBadFileOpen = true;
     return false;
   }
   m_bBadFileOpen = false;
 
-  if (theApp->getVerboseLogging() && filename != "")
-    *theApp->getLog() << "Read projection file " << filename << "\n";
+  if (theApp->getVerboseLogging() && filename != _T(""))
+    *theApp->getLog() << _T("Read projection file ") << filename << _T("\n");
 
   SetFilename(filename, true);
   Modify(false);
@@ -276,17 +276,17 @@ PhantomFileDocument::OnOpenDocument(const wxString& constFilename)
   wxString filename (constFilename);
 
   if (wxFile::Exists (filename)) {
-    m_phantom.createFromFile (filename);
+    m_phantom.createFromFile (filename.mb_str(wxConvUTF8));
     if (theApp->getVerboseLogging())
-      *theApp->getLog() << "Read phantom file " << filename << "\n";
+      *theApp->getLog() << _T("Read phantom file ") << filename << _T("\n");
   } else {
-    filename.Replace (".phm", "");
-    m_phantom.createFromPhantom (filename);
+    filename.Replace (_T(".phm"), _T(""));
+    m_phantom.createFromPhantom (filename.mb_str(wxConvUTF8));
   }
   m_namePhantom = filename;
   SetFilename (filename, true);
   if (m_phantom.fail()) {
-    *theApp->getLog() << "Failure creating phantom " << filename << "\n";
+    *theApp->getLog() << _T("Failure creating phantom ") << filename << _T("\n");
     m_bBadFileOpen = true;
     return false;
   }
@@ -301,12 +301,12 @@ PhantomFileDocument::OnOpenDocument(const wxString& constFilename)
 bool
 PhantomFileDocument::OnSaveDocument(const wxString& filename)
 {
-  if (! m_phantom.fileWrite (filename.c_str())) {
-    *theApp->getLog() << "Unable to write phantom file " << filename << "\n";
+  if (! m_phantom.fileWrite (filename.mb_str(wxConvUTF8))) {
+    *theApp->getLog() << _T("Unable to write phantom file ") << filename << _T("\n");
     return false;
   }
   if (theApp->getVerboseLogging())
-    *theApp->getLog() << "Wrote phantom file " << filename << "\n";
+    *theApp->getLog() << _T("Wrote phantom file ") << filename << _T("\n");
   Modify(false);
   return true;
 }
@@ -346,12 +346,12 @@ bool
 PlotFileDocument::OnSaveDocument(const wxString& filename)
 {
   m_namePlot = filename.c_str();
-  if (! m_plot.fileWrite (filename)) {
-    *theApp->getLog() << "Unable to write plot file " << filename << "\n";
+  if (! m_plot.fileWrite (filename.mb_str(wxConvUTF8))) {
+    *theApp->getLog() << _T("Unable to write plot file ") << filename << _T("\n");
     return false;
   }
   if (theApp->getVerboseLogging())
-    *theApp->getLog() << "Wrote plot file " << filename << "\n";
+    *theApp->getLog() << _T("Wrote plot file ") << filename << _T("\n");
   Modify(false);
   return true;
 }
@@ -362,15 +362,15 @@ PlotFileDocument::OnOpenDocument(const wxString& filename)
   if (! OnSaveModified())
     return false;
 
-  if (! m_plot.fileRead (filename.c_str())) {
-    *theApp->getLog() << "Unable to read plot file " << filename << "\n";
+  if (! m_plot.fileRead (filename.mb_str(wxConvUTF8))) {
+    *theApp->getLog() << _T("Unable to read plot file ") << filename << _T("\n");
     m_bBadFileOpen = true;
     return false;
   }
   m_bBadFileOpen = false;
 
-  if (theApp->getVerboseLogging() && filename != "")
-    *theApp->getLog() << "Read plot file " << filename << "\n";
+  if (theApp->getVerboseLogging() && filename != _T(""))
+    *theApp->getLog() << _T("Read plot file ") << filename << _T("\n");
 
   SetFilename (filename, true);
   m_namePlot = filename.c_str();