r399: *** empty log message ***
[ctsim.git] / src / ctsim.cpp
index fb835ad8b5a9afdaf9d62489d3a9a628be796c69..2595e76681fe41ee18a6c340d8c4db30ffea0d7d 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ctsim.cpp,v 1.25 2001/01/02 16:02:13 kevin Exp $
+**  $Id: ctsim.cpp,v 1.29 2001/01/13 10:14:06 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -61,9 +61,7 @@
 #endif
 #endif
 
-static const char* rcsindent = "$Id: ctsim.cpp,v 1.25 2001/01/02 16:02:13 kevin Exp $";
-
-class CTSimApp* theApp = NULL;
+static const char* rcsindent = "$Id: ctsim.cpp,v 1.29 2001/01/13 10:14:06 kevin Exp $";
 
 struct option CTSimApp::ctsimOptions[] = 
 {
@@ -94,7 +92,8 @@ CTSimApp::OnInit()
 #ifdef HAVE_SETPRIORITY
   setpriority (PRIO_PROCESS, 0, 15);  // set to low scheduling priority
 #endif
-  
+
+  g_bRunningWXWindows = true;
   // process options
   while (1) {
     int c = getopt_long (argc, argv, "", ctsimOptions, NULL);
@@ -123,16 +122,13 @@ CTSimApp::OnInit()
   m_docManager = new wxDocManager;
   
   new wxDocTemplate (m_docManager, "ImageFile", "*.if", "", "if", "ImageFile doc", "ImageFile View", CLASSINFO(ImageFileDocument), CLASSINFO(ImageFileView));
-  
   new wxDocTemplate (m_docManager, "ProjectionFile", "*.pj", "", "pj", "ProjectionFile doc", "ProjectionFile View", CLASSINFO(ProjectionFileDocument), CLASSINFO(ProjectionFileView));
-  
   new wxDocTemplate (m_docManager, "PhantomFile", "*.phm", "", "phm", "Phantom doc", "Phantom View", CLASSINFO(PhantomDocument), CLASSINFO(PhantomView));
-  
   new wxDocTemplate (m_docManager, "PlotFile", "*.plt", "", "plt", "Plot doc", "Plot View", CLASSINFO(PlotFileDocument), CLASSINFO(PlotFileView));
   
   //// Create the main frame window
   m_pFrame = new MainFrame(m_docManager, (wxFrame *) NULL, -1, "CTSim", wxPoint(0, 0), wxSize(500, 400), wxDEFAULT_FRAME_STYLE);
-  
+
   SetTopWindow (m_pFrame);
   m_pFrame->Centre(wxBOTH);
   
@@ -142,10 +138,22 @@ CTSimApp::OnInit()
     wxString filename = argv [i - 1];
     m_docManager->CreateDocument (filename, wxDOC_SILENT);
   }
-  
+
+  setIconForFrame (m_pFrame);
+
   return true;
 }
 
+void
+CTSimApp::setIconForFrame(wxFrame* pFrame)
+{
+#if defined(__WXMSW__)
+  wxIcon iconApp (wxString("ICON_APP"), wxBITMAP_TYPE_ICO_RESOURCE);
+  if (iconApp.Ok())
+    pFrame->SetIcon (iconApp);
+#endif
+}
+
 void
 CTSimApp::usage(const char* program)
 {
@@ -180,9 +188,16 @@ CTSimApp::getUntitledFilename()
 
 // Top-level window for CTSim
 
+#if CTSIM_MDI
+IMPLEMENT_CLASS(MainFrame, wxMDIParentFrame)
+
+BEGIN_EVENT_TABLE(MainFrame, wxMDIParentFrame)
+#else
 IMPLEMENT_CLASS(MainFrame, wxDocParentFrame)
 
 BEGIN_EVENT_TABLE(MainFrame, wxDocParentFrame)
+#endif
+
 EVT_MENU(MAINMENU_HELP_ABOUT, MainFrame::OnAbout)
 EVT_MENU(MAINMENU_HELP_CONTENTS, MainFrame::OnHelpContents)
 EVT_MENU(MAINMENU_FILE_CREATE_PHANTOM, MainFrame::OnCreatePhantom)
@@ -213,8 +228,13 @@ END_EVENT_TABLE()
 
 
 
+#if CTSIM_MDI
+MainFrame::MainFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long type)
+: wxMDIParentFrame(NULL,  id, title, pos, size, type), m_pLog(NULL)
+#else
 MainFrame::MainFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long type)
 : wxDocParentFrame(manager, frame, id, title, pos, size, type), m_pLog(NULL)
+#endif
 {
   m_pLog = new wxTextCtrl (this, -1, "Log Window\n", wxPoint(0, 250), wxSize(100,50), wxTE_MULTILINE | wxTE_READONLY);
   wxLog::SetActiveTarget(new wxLogTextCtrl(m_pLog));
@@ -232,7 +252,7 @@ MainFrame::MainFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const
   file_menu->Append(MAINMENU_FILE_EXIT, "E&xit");
   
   //  history of files visited
-  m_docManager->FileHistoryUseMenu(file_menu);
+  theApp->getDocManager()->FileHistoryUseMenu(file_menu);
   
   m_pWindowMenu = new wxMenu;
   m_pWindowMenu->UpdateUI (this);
@@ -372,7 +392,7 @@ void
 MainFrame::OnUpdateUI (wxUpdateUIEvent& rEvent)
 {
   int iPos = 0;
-  wxList& rListDocs = m_docManager->GetDocuments();
+  wxList& rListDocs = theApp->getDocManager()->GetDocuments();
   wxNode* pNode = rListDocs.GetFirst();
   while (iPos < MAX_WINDOW_MENUITEMS && pNode != NULL) {
     wxDocument* pDoc = static_cast<wxDocument*>(pNode->GetData());