** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ctsim.cpp,v 1.35 2001/01/18 21:30:22 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
#endif
#endif
-static const char* rcsindent = "$Id: ctsim.cpp,v 1.35 2001/01/18 21:30:22 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");
-
-
+
+
return true;
}
CTSimApp::setIconForFrame(wxFrame* pFrame)
{
wxIcon iconApp (ctsim16_xpm);
-
+
if (iconApp.Ok())
pFrame->SetIcon (iconApp);
}
m_dDefaultFilterInputScale = 1.;
m_dDefaultFilterOutputScale = 1.;
-}
-
-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);
+ 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
void
MainFrame::OnHelpTopics (wxCommandEvent& event)
{
- showHelp (event.GetId());
+ showHelp (event.GetId());
}
void
MainFrame::OnHelpContents (wxCommandEvent& event)
{
- showHelp (event.GetId());
+ showHelp (event.GetId());
}
void
MainFrame::showHelp (int commandID)
{
m_help.LoadFile();
-
+
switch (commandID) {
case MAINMENU_HELP_CONTENTS:
- m_help.DisplayContents ();
- break;
+ m_help.DisplayContents ();
+ break;
case MAINMENU_HELP_TOPICS:
- m_help.DisplaySection (introduction);
- 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);
+ }
+}
+