** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ctsim.cpp,v 1.31 2001/01/17 11:00:18 kevin Exp $
+** $Id: ctsim.cpp,v 1.37 2001/01/19 22:53:57 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
******************************************************************************/
+#ifdef MSVC
+#define strdup _strdup
+#endif
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#include "ct.h"
#include "ctsim.h"
+#include "ctsim-map.h"
#include "docs.h"
#include "views.h"
#include "dialogs.h"
#endif
#endif
-static const char* rcsindent = "$Id: ctsim.cpp,v 1.31 2001/01/17 11:00:18 kevin Exp $";
+static const char* rcsindent = "$Id: ctsim.cpp,v 1.37 2001/01/19 22:53:57 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"))
::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;
}
CTSimApp::setIconForFrame(wxFrame* pFrame)
{
wxIcon iconApp (ctsim16_xpm);
-
+
if (iconApp.Ok())
pFrame->SetIcon (iconApp);
}
#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)
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->Append(wxID_OPEN, "&Open...\tCtrl-O");
file_menu->AppendSeparator();
file_menu->Append(MAINMENU_FILE_EXIT, "E&xit");
m_pWindowMenu->UpdateUI (this);
wxMenu* help_menu = new wxMenu;
- help_menu->Append(MAINMENU_HELP_TOPICS, "&Topics\tF1");
- 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;
m_dDefaultFilterInputScale = 1.;
m_dDefaultFilterOutputScale = 1.;
+ wxAcceleratorEntry accelEntries[14];
+ accelEntries[0].Set (wxACCEL_CTRL, static_cast<int>('O'), wxID_OPEN);
+ accelEntries[1].Set (wxACCEL_CTRL, static_cast<int>('H'), MAINMENU_HELP_TOPICS);
+ accelEntries[2].Set (wxACCEL_CTRL, static_cast<int>('P'), MAINMENU_FILE_CREATE_PHANTOM);
+ 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);
+ 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& WXUNUSED(event))
+MainFrame::OnCreatePhantom(wxCommandEvent& event)
{
DialogGetPhantom dialogPhantom (this, m_iDefaultPhantomID);
int dialogReturn = dialogPhantom.ShowModal();
void
MainFrame::OnHelpTopics (wxCommandEvent& event)
{
- showHelp (event.GetId());
+ showHelp (event.GetId());
+}
+
+void
+MainFrame::OnHelpContents (wxCommandEvent& event)
+{
+ showHelp (event.GetId());
}
void
MainFrame::showHelp (int commandID)
{
m_help.LoadFile();
-
+
switch (commandID) {
+ case MAINMENU_HELP_CONTENTS:
+ m_help.DisplayContents ();
+ break;
case MAINMENU_HELP_TOPICS:
- m_help.DisplayContents();
- break;
-
+ m_help.DisplaySection (introduction);
+ break;
+
default:
*getLog() << "Unknown help command # " << commandID << "\n";
break;
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);
+ }
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);
+ virtual ~BitmapDialog();
+};
+
+BitmapDialog::BitmapDialog (wxBitmap* pBitmap)
+: wxDialog(theApp->getMainFrame(), -1, wxString("About"), wxDefaultPosition, wxDefaultSize, wxDIALOG_MODAL)
+{
+ 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) )
+{
+ //
+ // wxImage image;
+ // if (wxFile::image.LoadFile ("/splash.png")) {
+ wxBitmap bmp (splash);
+ if (bmp.Ok()) {
+ BitmapDialog dlg (&bmp);
+ 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);
+ }
+}
+