0f7bc4e5490aabe4a5362b22cfebf97dd8a2c1b3
[ctsim.git] / src / ctsim.cpp
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          ctsim.h
5 **   Purpose:       Header file for top-level routines of CTSim program
6 **   Programmer:    Kevin Rosenberg
7 **   Date Started:  July 2000
8 **
9 **  This is part of the CTSim program
10 **  Copyright (C) 1983-2000 Kevin Rosenberg
11 **
12 **  $Id: ctsim.cpp,v 1.4 2000/07/13 07:01:59 kevin Exp $
13 **
14 **  This program is free software; you can redistribute it and/or modify
15 **  it under the terms of the GNU General Public License (version 2) as
16 **  published by the Free Software Foundation.
17 **
18 **  This program is distributed in the hope that it will be useful,
19 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 **  GNU General Public License for more details.
22 **
23 **  You should have received a copy of the GNU General Public License
24 **  along with this program; if not, write to the Free Software
25 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 ******************************************************************************/
27
28 // For compilers that support precompilation, includes "wx/wx.h".
29 #include "wx/wxprec.h"
30
31 #ifdef __BORLANDC__
32 #pragma hdrstop
33 #endif
34
35 #ifndef WX_PRECOMP
36 #include "wx/wx.h"
37 #endif
38
39 #if !wxUSE_DOC_VIEW_ARCHITECTURE
40 #error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in setup.h!
41 #endif
42
43 #include "wx/docview.h"
44
45 #include "ctsim.h"
46 #include "docs.h"
47 #include "views.h"
48
49 IMPLEMENT_APP(CTSimApp)
50
51 CTSimApp::CTSimApp(void)
52   : m_docManager(NULL), m_pFrame(NULL)
53 {
54 }
55
56 bool
57 CTSimApp::OnInit(void)
58 {
59     m_docManager = new wxDocManager;
60     
61     (void) new wxDocTemplate (m_docManager, "ImageFile", "*.if", "", "if", "ImageFile doc", "ImageFile View", CLASSINFO(ImageFileDocument), CLASSINFO(ImageFileView));
62
63     (void) new wxDocTemplate (m_docManager, "ProjectionFile", "*.pj", "", "pj", "ProjectionFile doc", "ProjectionFile View", CLASSINFO(ProjectionFileDocument), CLASSINFO(ProjectionFileView));
64
65     //// Create the main frame window
66     m_pFrame = new MainFrame(m_docManager, (wxFrame *) NULL, -1, "CTSim", wxPoint(0, 0), wxSize(500, 400), wxDEFAULT_FRAME_STYLE);
67     
68     //// Make a menubar
69     wxMenu *file_menu = new wxMenu;
70     
71     //    file_menu->Append(wxID_NEW, "&New...");
72     file_menu->Append(wxID_OPEN, "&Open...");
73     
74     file_menu->AppendSeparator();
75     file_menu->Append(MAINMENU_FILE_EXIT, "E&xit");
76     
77     // A nice touch: a history of files visited. Use this menu.
78     m_docManager->FileHistoryUseMenu(file_menu);
79     
80     wxMenu *help_menu = new wxMenu;
81     help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
82     
83     wxMenuBar *menu_bar = new wxMenuBar;
84     
85     menu_bar->Append(file_menu, "&File");
86     menu_bar->Append(help_menu, "&Help");
87     
88     m_pFrame->SetMenuBar(menu_bar);
89     
90     m_pFrame->Centre(wxBOTH);
91     m_pFrame->Show(true);
92     
93     SetTopWindow (m_pFrame);
94     return true;
95 }
96
97 int
98 CTSimApp::OnExit(void)
99 {
100     delete m_docManager;
101     return 0;
102 }
103
104
105 // Top-level window for CTSim
106
107 IMPLEMENT_CLASS(MainFrame, wxDocParentFrame)
108 BEGIN_EVENT_TABLE(MainFrame, wxDocParentFrame)
109     EVT_MENU(MAINMENU_HELP_ABOUT, MainFrame::OnAbout)
110     EVT_MENU(MAINMENU_FILE_EXIT, MainFrame::OnExit)
111 END_EVENT_TABLE()
112
113 MainFrame::MainFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long type)
114  : wxDocParentFrame(manager, frame, id, title, pos, size, type)
115 {
116     CreateStatusBar();
117     SetStatusText ("Welcome to CTSim");
118 }
119
120 void 
121 MainFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
122 {
123     wxMessageBox("CTSim\nAuthor: Kevin Rosenberg <kevin@rosenberg.net>\nUsage: ctsim", "About CTSim", wxOK | wxICON_INFORMATION, this);
124 }
125
126 void 
127 MainFrame::OnExit (wxCommandEvent& WXUNUSED(event) )
128 {
129     Close(true);
130 }
131