r147: *** empty log message ***
[ctsim.git] / src / ctsim.cpp
index 57b55491211eb2952625fac57cccd0e63305dbe6..0f7bc4e5490aabe4a5362b22cfebf97dd8a2c1b3 100644 (file)
@@ -1,11 +1,15 @@
 /*****************************************************************************
 ** FILE IDENTIFICATION
 **
-**   Name:          ctsim.cpp
-**   Purpose:       GUI shell for CT Simulation
+**   Name:          ctsim.h
+**   Purpose:       Header file for top-level routines of CTSim program
 **   Programmer:    Kevin Rosenberg
-**   Date Started:  June 2000
+**   Date Started:  July 2000
 **
+**  This is part of the CTSim program
+**  Copyright (C) 1983-2000 Kevin Rosenberg
+**
+**  $Id: ctsim.cpp,v 1.4 2000/07/13 07:01:59 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
 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ******************************************************************************/
 
-#include <ct.h>
-#include <iostream>
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif
+
+#if !wxUSE_DOC_VIEW_ARCHITECTURE
+#error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in setup.h!
+#endif
+
+#include "wx/docview.h"
+
+#include "ctsim.h"
+#include "docs.h"
+#include "views.h"
+
+IMPLEMENT_APP(CTSimApp)
+
+CTSimApp::CTSimApp(void)
+  : m_docManager(NULL), m_pFrame(NULL)
+{
+}
+
+bool
+CTSimApp::OnInit(void)
+{
+    m_docManager = new wxDocManager;
+    
+    (void) new wxDocTemplate (m_docManager, "ImageFile", "*.if", "", "if", "ImageFile doc", "ImageFile View", CLASSINFO(ImageFileDocument), CLASSINFO(ImageFileView));
+
+    (void) new wxDocTemplate (m_docManager, "ProjectionFile", "*.pj", "", "pj", "ProjectionFile doc", "ProjectionFile View", CLASSINFO(ProjectionFileDocument), CLASSINFO(ProjectionFileView));
+
+    //// Create the main frame window
+    m_pFrame = new MainFrame(m_docManager, (wxFrame *) NULL, -1, "CTSim", wxPoint(0, 0), wxSize(500, 400), wxDEFAULT_FRAME_STYLE);
+    
+    //// Make a menubar
+    wxMenu *file_menu = new wxMenu;
+    
+    //    file_menu->Append(wxID_NEW, "&New...");
+    file_menu->Append(wxID_OPEN, "&Open...");
+    
+    file_menu->AppendSeparator();
+    file_menu->Append(MAINMENU_FILE_EXIT, "E&xit");
+    
+    // A nice touch: a history of files visited. Use this menu.
+    m_docManager->FileHistoryUseMenu(file_menu);
+    
+    wxMenu *help_menu = new wxMenu;
+    help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
+    
+    wxMenuBar *menu_bar = new wxMenuBar;
+    
+    menu_bar->Append(file_menu, "&File");
+    menu_bar->Append(help_menu, "&Help");
+    
+    m_pFrame->SetMenuBar(menu_bar);
+    
+    m_pFrame->Centre(wxBOTH);
+    m_pFrame->Show(true);
+    
+    SetTopWindow (m_pFrame);
+    return true;
+}
 
 int
-main (int argc, char **argv)
+CTSimApp::OnExit(void)
 {
-  cout << "Hello, CTSim!" << endl;
+    delete m_docManager;
+    return 0;
+}
+
+
+// Top-level window for CTSim
 
-  return (0);
+IMPLEMENT_CLASS(MainFrame, wxDocParentFrame)
+BEGIN_EVENT_TABLE(MainFrame, wxDocParentFrame)
+    EVT_MENU(MAINMENU_HELP_ABOUT, MainFrame::OnAbout)
+    EVT_MENU(MAINMENU_FILE_EXIT, MainFrame::OnExit)
+END_EVENT_TABLE()
+
+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)
+{
+    CreateStatusBar();
+    SetStatusText ("Welcome to CTSim");
 }
+
+void 
+MainFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
+{
+    wxMessageBox("CTSim\nAuthor: Kevin Rosenberg <kevin@rosenberg.net>\nUsage: ctsim", "About CTSim", wxOK | wxICON_INFORMATION, this);
+}
+
+void 
+MainFrame::OnExit (wxCommandEvent& WXUNUSED(event) )
+{
+    Close(true);
+}
+