** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ctsim.cpp,v 1.36 2001/01/18 23:34:01 kevin Exp $
+** $Id: ctsim.cpp,v 1.38 2001/01/20 02:25:45 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
#endif
#endif
-static const char* rcsindent = "$Id: ctsim.cpp,v 1.36 2001/01/18 23:34:01 kevin Exp $";
+static const char* rcsindent = "$Id: ctsim.cpp,v 1.38 2001/01/20 02:25:45 kevin Exp $";
struct option CTSimApp::ctsimOptions[] =
{
#ifdef HAVE_SETPRIORITY
setpriority (PRIO_PROCESS, 0, 15); // set to low scheduling priority
#endif
-
+
g_bRunningWXWindows = true;
// process options
while (1) {
new wxDocTemplate (m_docManager, "PlotFile", "*.plt", "", "plt", "Plot doc", "Plot View", CLASSINFO(PlotFileDocument), CLASSINFO(PlotFileView));
#if wxUSE_GIF
- wxImage::AddHandler(new wxGIFHandler); // Required for images in the online documentation
+ 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
+ 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);
m_pFrame->Centre(wxBOTH);
wxString filename = argv [i - 1];
m_docManager->CreateDocument (filename, wxDOC_SILENT);
}
-
+
setIconForFrame (m_pFrame);
-
- if (! m_pFrame->getHelpController().Initialize("ctsim"))
+
+#ifdef CTSIM_WINHELP
+ if (! m_pFrame->getWinHelpController().Initialize("ctsim"))
::wxMessageBox ("Cannot initialize the help system", "Error");
-
-
+#endif
+ if (! m_pFrame->getHtmlHelpController().Initialize(::wxGetCwd() + "/ctsim"))
+ ::wxMessageBox ("Cannot initialize the help system", "Error");
+
return true;
}
CTSimApp::setIconForFrame(wxFrame* pFrame)
{
wxIcon iconApp (ctsim16_xpm);
-
+
if (iconApp.Ok())
pFrame->SetIcon (iconApp);
}
EVT_MENU(MAINMENU_HELP_ABOUT, MainFrame::OnAbout)
EVT_MENU(MAINMENU_HELP_CONTENTS, MainFrame::OnHelpContents)
EVT_MENU(MAINMENU_HELP_TOPICS, MainFrame::OnHelpTopics)
+#if defined(CTSIM_WINHELP) && (defined(DEBUG) || defined(_DEBUG))
+EVT_MENU(MAINMENU_HELP_SECONDARY, MainFrame::OnHelpSecondary)
+#endif
EVT_MENU(MAINMENU_FILE_CREATE_PHANTOM, MainFrame::OnCreatePhantom)
EVT_MENU(MAINMENU_FILE_CREATE_FILTER, MainFrame::OnCreateFilter)
EVT_MENU(MAINMENU_FILE_EXIT, MainFrame::OnExit)
wxMenu* help_menu = new wxMenu;
help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1");
help_menu->Append(MAINMENU_HELP_TOPICS, "&Topics\tCtrl-T");
+#if defined(CTSIM_WINHELP) && (defined(DEBUG) || defined(_DEBUG))
+ help_menu->Append(MAINMENU_HELP_SECONDARY, "&Secondary Help");
+#endif
help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
wxMenuBar* menu_bar = new wxMenuBar;
accelEntries[3].Set (wxACCEL_CTRL, static_cast<int>('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<int>('0'+i), MAINMENU_WINDOW_BASE+i);
+ accelEntries[i+4].Set (wxACCEL_CTRL, static_cast<int>('0'+i), MAINMENU_WINDOW_BASE+i);
wxAcceleratorTable accelTable (16, accelEntries);
SetAcceleratorTable (accelTable);
}
-void
-MainFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
-{
- wxString msg = "CTSim\nThe Open Source Computed Tomography Simulator\n";
-#ifdef CTSIMVERSION
- msg += "Version ";
- msg += CTSIMVERSION;
- msg += "\n\n";
-#elif defined(VERSION)
- msg << "Version: " << VERSION << "\n\n";
-#endif
- msg += "Author: Kevin Rosenberg <kevin@rosenberg.net>\nUsage: ctsim [files-to-open..] [--help]";
-
- wxMessageBox(msg, "About CTSim", wxOK | wxICON_INFORMATION, this);
-}
-
void
MainFrame::OnCreatePhantom(wxCommandEvent& event)
{
void
MainFrame::OnHelpTopics (wxCommandEvent& event)
{
- showHelp (event.GetId());
+ showHelp (event.GetId());
}
void
MainFrame::OnHelpContents (wxCommandEvent& event)
{
- showHelp (event.GetId());
+ showHelp (event.GetId());
}
+#if defined(CTSIM_WINHELP) && (defined(DEBUG) || defined(_DEBUG))
void
-MainFrame::showHelp (int commandID)
+MainFrame::OnHelpSecondary (wxCommandEvent& event)
{
- m_help.LoadFile();
+ m_htmlHelp.DisplayContents();
+}
+#endif
+void
+MainFrame::showHelp (int commandID)
+{
+#ifdef CTSIM_WINHELP
+ m_winHelp.LoadFile();
+#else
+ m_htmlHelp.LoadFile();
+#endif
+
switch (commandID) {
+
case MAINMENU_HELP_CONTENTS:
- m_help.DisplayContents ();
- break;
+#ifdef CTSIM_WINHELP
+ m_winHelp.DisplayContents ();
+#else
+ m_htmlHelp.DisplayContents ();
+#endif
+ break;
+
case MAINMENU_HELP_TOPICS:
- m_help.DisplaySection (introduction);
- break;
+#ifdef CTSIM_WINHELP
+ m_winHelp.DisplaySection (introduction);
+#else
+ m_htmlHelp.DisplayIndex();
+#endif
+ break;
default:
*getLog() << "Unknown help command # " << commandID << "\n";
while (iPos < MAX_WINDOW_MENUITEMS && pNode != NULL) {
wxDocument* pDoc = static_cast<wxDocument*>(pNode->GetData());
wxString strFilename = pDoc->GetFilename();
- if (iPos < 10) {
- strFilename += "\tCtrl-";
- strFilename += static_cast<char>('0' + iPos);
- }
+ if (iPos < 10) {
+ strFilename += "\tCtrl-";
+ strFilename += static_cast<char>('0' + iPos);
+ }
static_cast<wxMenuItemBase*>(m_apWindowMenuItems[iPos])->SetName (strFilename);
m_apWindowMenuData[iPos] = pDoc;
m_pWindowMenu->Enable (MAINMENU_WINDOW_BASE+iPos, true);
{ DoWindowMenu (19, event); }
+class BitmapControl : public wxPanel
+{
+private:
+ DECLARE_DYNAMIC_CLASS (BitmapControl)
+ DECLARE_EVENT_TABLE ()
+ wxBitmap* m_pBitmap;
+
+public:
+ BitmapControl (wxBitmap* pBitmap, wxWindow *parent, wxWindowID id = -1,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxSTATIC_BORDER,
+ const wxValidator& validator = wxDefaultValidator,
+ const wxString& name = "BitmapCtrl");
+
+
+ virtual ~BitmapControl();
+
+ virtual wxSize GetBestSize() const;
+
+ wxBitmap* getBitmap()
+ { return m_pBitmap; }
+
+ void OnPaint(wxPaintEvent& event);
+};
+
+
+BEGIN_EVENT_TABLE(BitmapControl, wxPanel)
+EVT_PAINT(BitmapControl::OnPaint)
+END_EVENT_TABLE()
+
+IMPLEMENT_CLASS(BitmapControl, wxPanel)
+
+
+BitmapControl::BitmapControl (wxBitmap* pBitmap, wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
+ long style, const wxValidator& validator, const wxString& name)
+ : m_pBitmap(pBitmap)
+{
+ Create(parent, id, pos, size, style, name);
+
+ SetSize (GetBestSize());
+}
+
+wxSize
+BitmapControl::GetBestSize () const
+{
+ if (m_pBitmap)
+ return wxSize (m_pBitmap->GetWidth(), m_pBitmap->GetHeight());
+ else
+ return wxSize(0,0);
+}
+
+BitmapControl::~BitmapControl()
+{}
+
+void
+BitmapControl::OnPaint (wxPaintEvent& event)
+{
+ wxPaintDC dc(this);
+ if (m_pBitmap)
+ dc.DrawBitmap (*m_pBitmap, 0, 0);
+}
+
+
+class BitmapDialog : public wxDialog {
+private:
+ BitmapControl* m_pBitmapCtrl;
+
+public:
+ BitmapDialog (wxBitmap* pBitmap, char const* pszTitle);
+ virtual ~BitmapDialog();
+};
+
+BitmapDialog::BitmapDialog (wxBitmap* pBitmap, char const* pszTitle)
+: wxDialog(theApp->getMainFrame(), -1, wxString(pszTitle), wxDefaultPosition, wxDefaultSize, wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE)
+{
+ wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
+
+ pTopSizer->Add (new BitmapControl (pBitmap, this), 0, wxALIGN_CENTER | wxALL, 5);
+
+ wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
+ wxButton* pButtonOk = new wxButton (this, wxID_OK, "Ok");
+ pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
+
+ pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
+
+ SetAutoLayout (true);
+ SetSizer (pTopSizer);
+ pTopSizer->Fit (this);
+ pTopSizer->SetSizeHints (this);
+}
+
+BitmapDialog::~BitmapDialog()
+{}
+
+
+#include "./splash.xpm"
+void
+MainFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
+{
+ wxBitmap bmp (splash);
+ if (bmp.Ok()) {
+ BitmapDialog dlg (&bmp, "About CTSim");
+ dlg.Show(true);
+ } else {
+ wxString msg = "CTSim\nThe Open Source Computed Tomography Simulator\n";
+#ifdef CTSIMVERSION
+ msg += "Version ";
+ msg += CTSIMVERSION;
+ msg += "\n\n";
+#elif defined(VERSION)
+ msg << "Version: " << VERSION << "\n\n";
+#endif
+ msg += "Author: Kevin Rosenberg <kevin@rosenberg.net>\nUsage: ctsim [files-to-open..] [--help]";
+
+ wxMessageBox(msg, "About CTSim", wxOK | wxICON_INFORMATION, this);
+ }
+}
+