]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/tex2rtf/src/tex2rtf.cpp
Moved wxGLCanvas to more normal positions
[wxWidgets.git] / utils / tex2rtf / src / tex2rtf.cpp
index d99f91343994965869c7d2351d82525d4d8b8c4f..5b1bf16c6735dfc74228e43cc74ef7965e39162d 100644 (file)
@@ -29,7 +29,7 @@
 #include <wx/timer.h>
 #endif
 
-#ifdef NO_GUI
+#if defined(NO_GUI) || defined(__UNIX__)
 #if wxUSE_IOSTREAMH
 #include <iostream.h>
 #include <fstream.h>
@@ -59,7 +59,10 @@ bool OkToClose = TRUE;
 int passNumber = 1;
 
 #ifndef NO_GUI
+
+#if wxUSE_HELP
 wxHelpController *HelpInstance = NULL;
+#endif // wxUSE_HELP
 
 #ifdef __WXMSW__
 static char *ipc_buffer = NULL;
@@ -101,6 +104,9 @@ bool Go(void);
 void ShowOptions(void);
 
 #ifdef NO_GUI
+
+extern char *wxBuffer; // we must init it, otherwise tex2rtf will crash
+
 int main(int argc, char **argv)
 #else
 wxMenuBar *menuBar = NULL;
@@ -125,7 +131,7 @@ bool MyApp::OnInit()
   RefName = new char[300];
 
   int n = 1;
-  
+
   // Read input/output files
   if (argc > 1)
   {
@@ -146,12 +152,16 @@ bool MyApp::OnInit()
   }
 
 #ifdef NO_GUI
+  wxBuffer = new char[1500];
+  // this is done in wxApp, but NO_GUI version doesn't call it :-(
+
   if (!InputFile || !OutputFile)
   {
     cout << "Tex2RTF: input or output file is missing.\n";
     ShowOptions();
     exit(1);
   }
+
 #endif
   if (InputFile)
   {
@@ -321,16 +331,18 @@ bool MyApp::OnInit()
     frame->textWindow = new wxTextCtrl(frame, -1, "", wxPoint(-1, -1), wxSize(-1, -1), wxTE_READONLY|wxTE_MULTILINE);
 
     (*frame->textWindow) << "Welcome to Julian Smart's LaTeX to RTF converter.\n";
-//    ShowOptions();    
+//    ShowOptions();
 
+#if wxUSE_HELP
     HelpInstance = new wxHelpController();
     HelpInstance->Initialize("tex2rtf");
+#endif // wxUSE_HELP
 
     /*
      * Read macro/initialisation file
      *
      */
-   
+
     wxString path;
     if ((path = TexPathList.FindValidPath(MacroFile)) != "")
       ReadCustomMacros((char*) (const char*) path);
@@ -345,7 +357,7 @@ bool MyApp::OnInit()
     else if (convertMode == TEX_XLP) strcat(buf, "XLP");
       strcat(buf, " mode.");
     frame->SetStatusText(buf, 1);
-  
+
     frame->Show(TRUE);
     return TRUE;
   }
@@ -356,7 +368,7 @@ bool MyApp::OnInit()
      * Read macro/initialisation file
      *
      */
-   
+
     wxString path;
     if ((path = TexPathList.FindValidPath(MacroFile)) != "")
       ReadCustomMacros((char*) (const char*) path);
@@ -374,10 +386,12 @@ bool MyApp::OnInit()
   // Return the main frame window
   return TRUE;
 #else
+  delete[] wxBuffer;
   return FALSE;
 #endif
 }
 
+#ifndef NO_GUI
 int MyApp::OnExit()
 {
   wxNode *node = CustomMacroList.First();
@@ -401,7 +415,10 @@ int MyApp::OnExit()
   delete TheTex2RTFServer;
   wxDDECleanUp();
 #endif
+
+#if wxUSE_HELP
   delete HelpInstance;
+#endif // wxUSE_HELP
 
   // TODO: this simulates zero-memory leaks!
   // Otherwise there are just too many...
@@ -411,7 +428,7 @@ int MyApp::OnExit()
 
   return 0;
 }
-
+#endif
 void ShowOptions(void)
 {
     char buf[100];
@@ -601,8 +618,10 @@ void MyFrame::OnModeXLP(wxCommandEvent& event)
 
 void MyFrame::OnHelp(wxCommandEvent& event)
 {
+#if wxUSE_HELP
       HelpInstance->LoadFile();
       HelpInstance->DisplayContents();
+#endif // wxUSE_HELP
 }
 
 void MyFrame::OnAbout(wxCommandEvent& event)
@@ -647,12 +666,12 @@ void ChooseOutputFile(bool force)
   char extensionBuf[10];
   char wildBuf[10];
   strcpy(wildBuf, "*.");
-  char *path = NULL;
+  wxString path;
   if (OutputFile)
     path = wxPathOnly(OutputFile);
   else if (InputFile)
     path = wxPathOnly(InputFile);
-    
+
   switch (convertMode)
   {
     case TEX_RTF:
@@ -727,7 +746,7 @@ bool Go(void)
       if(strlen( sName) > 5)
         sName[5] = '\0';  // that should do!
   }
-  
+
   sprintf(ContentsName, "%s.con", FileRoot);
   sprintf(TmpContentsName, "%s.cn1", FileRoot);
   sprintf(TmpFrameContentsName, "%s.frc", FileRoot);
@@ -747,7 +766,7 @@ bool Go(void)
 
   if (wxFileExists(RefName))
     ReadTexReferences(RefName);
-    
+
   bool success = FALSE;
 
   if (InputFile && OutputFile)
@@ -936,7 +955,7 @@ wxConnectionBase *Tex2RTFServer::OnAcceptConnection(const wxString& topic)
   {
     if (!ipc_buffer)
       ipc_buffer = new char[1000];
-      
+
     return new Tex2RTFConnection(ipc_buffer, 4000);
   }
   else
@@ -946,7 +965,7 @@ wxConnectionBase *Tex2RTFServer::OnAcceptConnection(const wxString& topic)
  /*
   * Connection
   */
-  
+
 Tex2RTFConnection::Tex2RTFConnection(char *buf, int size):wxDDEConnection(buf, size)
 {
 }
@@ -1026,8 +1045,7 @@ bool Tex2RTFConnection::OnExecute(const wxString& topic, char *data, int size, i
     }
     else if (strcmp(firstArg, "EXIT") == 0)
     {
-      if (frame && frame->OnClose())
-        delete frame;
+      if (frame) frame->Close();
     }
     else if (strcmp(firstArg, "MINIMIZE") == 0 || strcmp(firstArg, "ICONIZE") == 0)
     {
@@ -1074,3 +1092,14 @@ char *Tex2RTFConnection::OnRequest(const wxString& topic, const wxString& item,
 
 #endif
 
+#ifndef NO_GUI
+#ifndef __WXGTK__
+//void wxObject::Dump(ostream& str)
+//{
+//  if (GetClassInfo() && GetClassInfo()->GetClassName())
+//    str << GetClassInfo()->GetClassName();
+//  else
+//    str << "unknown object class";
+//}
+#endif
+#endif