X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fctsim.cpp;h=a2212e8e0cb3304e821fbe15901511de35f1ae58;hb=95f440605a411c94ff2563c91cb0f51acf78c518;hp=b8a1154e56a005e7e79820cb3b32375bef05a0f0;hpb=c6cda8844a491b71759e5dd5edba830d0b809cfd;p=ctsim.git diff --git a/src/ctsim.cpp b/src/ctsim.cpp index b8a1154..a2212e8 100644 --- a/src/ctsim.cpp +++ b/src/ctsim.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: ctsim.cpp,v 1.26 2001/01/06 15:33:15 kevin Exp $ +** $Id: ctsim.cpp,v 1.36 2001/01/18 23:34:01 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 @@ -25,6 +25,9 @@ ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ******************************************************************************/ +#ifdef MSVC +#define strdup _strdup +#endif // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" @@ -37,12 +40,17 @@ #include "wx/wx.h" #endif +#include "wx/image.h" +#include "wx/filesys.h" +#include "wx/fs_zip.h" + #if !wxUSE_DOC_VIEW_ARCHITECTURE #error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in setup.h! #endif #include "ct.h" #include "ctsim.h" +#include "ctsim-map.h" #include "docs.h" #include "views.h" #include "dialogs.h" @@ -61,9 +69,7 @@ #endif #endif -static const char* rcsindent = "$Id: ctsim.cpp,v 1.26 2001/01/06 15:33:15 kevin Exp $"; - -class CTSimApp* theApp = NULL; +static const char* rcsindent = "$Id: ctsim.cpp,v 1.36 2001/01/18 23:34:01 kevin Exp $"; struct option CTSimApp::ctsimOptions[] = { @@ -94,7 +100,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,14 +130,19 @@ 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 +#if wxUSE_GIF + wxImage::AddHandler(new wxGIFHandler); // Required for images in the online documentation +#endif + +#if wxUSE_STREAMS && wxUSE_ZIPSTREAM && wxUSE_ZLIB + wxFileSystem::AddHandler(new wxZipFSHandler); // Required for advanced HTML help +#endif + + // 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); @@ -142,10 +154,27 @@ CTSimApp::OnInit() wxString filename = argv [i - 1]; m_docManager->CreateDocument (filename, wxDOC_SILENT); } - + + setIconForFrame (m_pFrame); + + if (! m_pFrame->getHelpController().Initialize("ctsim")) + ::wxMessageBox ("Cannot initialize the help system", "Error"); + + return true; } + +#include "./ctsim.xpm" +void +CTSimApp::setIconForFrame(wxFrame* pFrame) +{ + wxIcon iconApp (ctsim16_xpm); + + if (iconApp.Ok()) + pFrame->SetIcon (iconApp); +} + void CTSimApp::usage(const char* program) { @@ -192,6 +221,7 @@ BEGIN_EVENT_TABLE(MainFrame, wxDocParentFrame) EVT_MENU(MAINMENU_HELP_ABOUT, MainFrame::OnAbout) EVT_MENU(MAINMENU_HELP_CONTENTS, MainFrame::OnHelpContents) +EVT_MENU(MAINMENU_HELP_TOPICS, MainFrame::OnHelpTopics) EVT_MENU(MAINMENU_FILE_CREATE_PHANTOM, MainFrame::OnCreatePhantom) EVT_MENU(MAINMENU_FILE_CREATE_FILTER, MainFrame::OnCreateFilter) EVT_MENU(MAINMENU_FILE_EXIT, MainFrame::OnExit) @@ -236,9 +266,9 @@ MainFrame::MainFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const //// Make a menubar wxMenu *file_menu = new wxMenu; - file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom..."); - file_menu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter..."); - file_menu->Append(wxID_OPEN, "&Open..."); + file_menu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...\tCtrl-P"); + file_menu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter...\tCtrl-F"); + file_menu->Append(wxID_OPEN, "&Open...\tCtrl-O"); file_menu->AppendSeparator(); file_menu->Append(MAINMENU_FILE_EXIT, "E&xit"); @@ -250,8 +280,8 @@ MainFrame::MainFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const m_pWindowMenu->UpdateUI (this); wxMenu* help_menu = new wxMenu; - help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents"); - help_menu->AppendSeparator(); + help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1"); + help_menu->Append(MAINMENU_HELP_TOPICS, "&Topics\tCtrl-T"); help_menu->Append(MAINMENU_HELP_ABOUT, "&About"); wxMenuBar* menu_bar = new wxMenuBar; @@ -278,6 +308,16 @@ MainFrame::MainFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const m_dDefaultFilterInputScale = 1.; m_dDefaultFilterOutputScale = 1.; + wxAcceleratorEntry accelEntries[14]; + accelEntries[0].Set (wxACCEL_CTRL, static_cast('O'), wxID_OPEN); + accelEntries[1].Set (wxACCEL_CTRL, static_cast('H'), MAINMENU_HELP_TOPICS); + accelEntries[2].Set (wxACCEL_CTRL, static_cast('P'), MAINMENU_FILE_CREATE_PHANTOM); + accelEntries[3].Set (wxACCEL_CTRL, static_cast('F'), MAINMENU_FILE_CREATE_FILTER); + accelEntries[4].Set (wxACCEL_NORMAL, WXK_F1, MAINMENU_HELP_CONTENTS); + for (i = 0; i < 10; i++) + accelEntries[i+4].Set (wxACCEL_CTRL, static_cast('0'+i), MAINMENU_WINDOW_BASE+i); + wxAcceleratorTable accelTable (16, accelEntries); + SetAcceleratorTable (accelTable); } void @@ -297,7 +337,7 @@ MainFrame::OnAbout(wxCommandEvent& WXUNUSED(event) ) } void -MainFrame::OnCreatePhantom(wxCommandEvent& WXUNUSED(event)) +MainFrame::OnCreatePhantom(wxCommandEvent& event) { DialogGetPhantom dialogPhantom (this, m_iDefaultPhantomID); int dialogReturn = dialogPhantom.ShowModal(); @@ -369,9 +409,34 @@ CTSimApp::getCompatibleImages (const ImageFileDocument* pIFDoc, std::vector(pNode->GetData()); wxString strFilename = pDoc->GetFilename(); + if (iPos < 10) { + strFilename += "\tCtrl-"; + strFilename += static_cast('0' + iPos); + } static_cast(m_apWindowMenuItems[iPos])->SetName (strFilename); m_apWindowMenuData[iPos] = pDoc; m_pWindowMenu->Enable (MAINMENU_WINDOW_BASE+iPos, true);