r413: no message
[ctsim.git] / src / ctsim.cpp
index 2595e76681fe41ee18a6c340d8c4db30ffea0d7d..190ad49e34a2649242725e45d386422864df0c1c 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ctsim.cpp,v 1.29 2001/01/13 10:14:06 kevin Exp $
+**  $Id: ctsim.cpp,v 1.31 2001/01/17 11:00:18 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
 #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
@@ -61,7 +65,7 @@
 #endif
 #endif
 
-static const char* rcsindent = "$Id: ctsim.cpp,v 1.29 2001/01/13 10:14:06 kevin Exp $";
+static const char* rcsindent = "$Id: ctsim.cpp,v 1.31 2001/01/17 11:00:18 kevin Exp $";
 
 struct option CTSimApp::ctsimOptions[] = 
 {
@@ -126,7 +130,15 @@ CTSimApp::OnInit()
   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);
@@ -141,17 +153,28 @@ CTSimApp::OnInit()
 
   setIconForFrame (m_pFrame);
 
+  if (! m_pFrame->getHelpController().Initialize("ctsim"))
+    ::wxMessageBox ("Cannot initialize the help system", "Error");
+
+  wxAcceleratorEntry accelEntries[3];
+  accelEntries[0].Set(wxACCEL_CTRL, WXK_F1, MAINMENU_HELP_TOPICS);
+  accelEntries[1].Set(wxACCEL_CTRL, (int) 'P', MAINMENU_FILE_CREATE_PHANTOM);
+  accelEntries[2].Set(wxACCEL_CTRL, (int) 'F', MAINMENU_FILE_CREATE_FILTER);
+  wxAcceleratorTable accelTable (2, accelEntries);
+  m_pFrame->SetAcceleratorTable (accelTable);
+
   return true;
 }
 
+
+#include "./ctsim.xpm"
 void
 CTSimApp::setIconForFrame(wxFrame* pFrame)
 {
-#if defined(__WXMSW__)
-  wxIcon iconApp (wxString("ICON_APP"), wxBITMAP_TYPE_ICO_RESOURCE);
+  wxIcon iconApp (ctsim16_xpm);
+
   if (iconApp.Ok())
     pFrame->SetIcon (iconApp);
-#endif
 }
 
 void
@@ -199,7 +222,7 @@ BEGIN_EVENT_TABLE(MainFrame, wxDocParentFrame)
 #endif
 
 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)
@@ -244,8 +267,8 @@ 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(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...");
   
   file_menu->AppendSeparator();
@@ -258,7 +281,7 @@ 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->Append(MAINMENU_HELP_TOPICS, "&Topics\tF1");
   help_menu->AppendSeparator();
   help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
   
@@ -377,9 +400,25 @@ CTSimApp::getCompatibleImages (const ImageFileDocument* pIFDoc, std::vector<Imag
 }
 
 void 
-MainFrame::OnHelpContents(wxCommandEvent& WXUNUSED(event) )
+MainFrame::OnHelpTopics (wxCommandEvent& event)
+{
+   showHelp (event.GetId());
+}
+
+void
+MainFrame::showHelp (int commandID)
 {
-  wxMessageBox("No help available, refer to man pages of command-line tools");
+  m_help.LoadFile();
+
+  switch (commandID) {
+  case MAINMENU_HELP_TOPICS:
+     m_help.DisplayContents();
+     break;
+
+  default:
+    *getLog() << "Unknown help command # " << commandID << "\n";
+    break;
+  }
 }
 
 void