X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fctsim.cpp;h=32873df061766e66a6cfdaa188beca6478315486;hp=a2212e8e0cb3304e821fbe15901511de35f1ae58;hb=100160988c5bd211bdbc4c6d7340426d8c6408c8;hpb=d73b389e1a794abd8946acfbb209e4827e31f8ca diff --git a/src/ctsim.cpp b/src/ctsim.cpp index a2212e8..32873df 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.36 2001/01/18 23:34:01 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 @@ -69,7 +69,7 @@ #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.37 2001/01/19 22:53:57 kevin Exp $"; struct option CTSimApp::ctsimOptions[] = { @@ -100,7 +100,7 @@ CTSimApp::OnInit() #ifdef HAVE_SETPRIORITY setpriority (PRIO_PROCESS, 0, 15); // set to low scheduling priority #endif - + g_bRunningWXWindows = true; // process options while (1) { @@ -135,16 +135,16 @@ CTSimApp::OnInit() 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); @@ -154,13 +154,13 @@ 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; } @@ -170,7 +170,7 @@ void CTSimApp::setIconForFrame(wxFrame* pFrame) { wxIcon iconApp (ctsim16_xpm); - + if (iconApp.Ok()) pFrame->SetIcon (iconApp); } @@ -315,27 +315,11 @@ MainFrame::MainFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const 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); + accelEntries[i+4].Set (wxACCEL_CTRL, static_cast('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 \nUsage: ctsim [files-to-open..] [--help]"; - - wxMessageBox(msg, "About CTSim", wxOK | wxICON_INFORMATION, this); -} - void MainFrame::OnCreatePhantom(wxCommandEvent& event) { @@ -411,28 +395,28 @@ CTSimApp::getCompatibleImages (const ImageFileDocument* pIFDoc, std::vector(pNode->GetData()); wxString strFilename = pDoc->GetFilename(); - if (iPos < 10) { - strFilename += "\tCtrl-"; - strFilename += static_cast('0' + iPos); - } + 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); @@ -547,3 +531,125 @@ void MainFrame::OnWindowMenu19 (wxCommandEvent& event) { 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 \nUsage: ctsim [files-to-open..] [--help]"; + + wxMessageBox(msg, "About CTSim", wxOK | wxICON_INFORMATION, this); + } +} +