X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fviews.cpp;h=8053e7e710c07e517345aed8f9cb23c57537f29f;hp=4e970c173bd2bb43a6739d96d5c419797c6ba51f;hb=a18f7b9629e21da7c33abc59718b5ab150f3e3d1;hpb=91fb88e205c5bc7b771faf601db8489a9278c1ab diff --git a/src/views.cpp b/src/views.cpp index 4e970c1..8053e7e 100644 --- a/src/views.cpp +++ b/src/views.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: views.cpp,v 1.74 2001/01/26 21:33:06 kevin Exp $ +** $Id: views.cpp,v 1.75 2001/01/26 23:23:00 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,21 +69,13 @@ END_EVENT_TABLE() ImageFileCanvas::ImageFileCanvas (ImageFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style) -: wxScrolledWindow(frame, -1, pos, size, style) +: wxScrolledWindow(frame, -1, pos, size, style), m_pView(v), m_xCursor(-1), m_yCursor(-1) { - m_pView = v; - m_xCursor = -1; - m_yCursor = -1; } ImageFileCanvas::~ImageFileCanvas() { - if (m_pView) { - wxMenu* pMenu = m_pView->getFileMenu(); - theApp->getDocManager()->FileHistoryRemoveMenu (pMenu); - m_pView->canvasClosed(); - m_pView = NULL; - } + m_pView = NULL; } void @@ -232,14 +224,14 @@ EVT_MENU(IFMENU_PLOT_HISTOGRAM, ImageFileView::OnPlotHistogram) END_EVENT_TABLE() ImageFileView::ImageFileView() -: wxView(), m_canvas(NULL), m_frame(NULL), m_bMinSpecified(false), m_bMaxSpecified(false), m_pFileMenu(0) +: wxView(), m_canvas(NULL), m_pFrame(NULL), m_bMinSpecified(false), m_bMaxSpecified(false), m_pFileMenu(0) { m_iDefaultExportFormatID = ImageFile::FORMAT_PNG; } ImageFileView::~ImageFileView() { - + theApp->getDocManager()->FileHistoryRemoveMenu (m_pFileMenu); } void @@ -786,7 +778,11 @@ ImageFileView::CreateCanvas (wxView *view, wxFrame *parent) return pCanvas; } -wxFrame* +#if CTSIM_MDI +wxDocMDIChildFrame* +#else +wxDocChildFrame* +#endif ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) { #if CTSIM_MDI @@ -909,23 +905,23 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) bool ImageFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) ) { - m_frame = CreateChildFrame(doc, this); - SetFrame (m_frame); + m_pFrame = CreateChildFrame(doc, this); + SetFrame (m_pFrame); m_bMinSpecified = false; m_bMaxSpecified = false; m_dAutoScaleFactor = 1.; int width, height; - m_frame->GetClientSize (&width, &height); - m_frame->SetTitle("ImageFileView"); - m_canvas = CreateCanvas (this, m_frame); + m_pFrame->GetClientSize (&width, &height); + m_pFrame->SetTitle("ImageFileView"); + m_canvas = CreateCanvas (this, m_pFrame); int x, y; // X requires a forced resize - m_frame->GetSize(&x, &y); - m_frame->SetSize(-1, -1, x, y); - m_frame->SetFocus(); - m_frame->Show(true); + m_pFrame->GetSize(&x, &y); + m_pFrame->SetSize(-1, -1, x, y); + m_pFrame->SetFocus(); + m_pFrame->Show(true); Activate(true); return true; @@ -934,10 +930,10 @@ ImageFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) ) void ImageFileView::OnDraw (wxDC* dc) { - wxSize sizeWindow = m_frame->GetClientSize(); + wxSize sizeWindow = m_pFrame->GetClientSize(); wxSize sizeBest = m_canvas->GetBestSize(); if (sizeWindow.x > sizeBest.x || sizeWindow.y > sizeBest.y) - m_frame->SetClientSize (sizeBest); + m_pFrame->SetClientSize (sizeBest); if (m_bitmap.Ok()) dc->DrawBitmap(m_bitmap, 0, 0, false); @@ -982,7 +978,7 @@ ImageFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) int xSize = nx; int ySize = ny; ySize = clamp (ySize, 0, 800); - m_frame->SetClientSize (xSize, ySize); + m_pFrame->SetClientSize (xSize, ySize); m_canvas->SetScrollbars(20, 20, nx/20, ny/20); m_canvas->SetBackgroundColour(*wxWHITE); } @@ -998,20 +994,23 @@ ImageFileView::OnClose (bool deleteWindow) return false; if (m_canvas) { - // m_canvas->Clear(); + m_canvas->Clear(); + m_canvas->Show(false); m_canvas->setView(NULL); m_canvas = NULL; } wxString s(theApp->GetAppName()); -// if (m_frame) -// m_frame->SetTitle(s); + if (m_pFrame) + m_pFrame->SetTitle(s); SetFrame(NULL); Activate(false); if (deleteWindow) { - delete m_frame; - return true; + m_pFrame->Show(false); + m_pFrame->Destroy(); +// delete m_pFrame; + m_pFrame = NULL; } return true; } @@ -1707,12 +1706,7 @@ PhantomCanvas::PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& PhantomCanvas::~PhantomCanvas () { - if (m_pView) { - wxMenu* pMenu = m_pView->getFileMenu(); - theApp->getDocManager()->FileHistoryRemoveMenu (pMenu); - m_pView->canvasClosed(); m_pView = NULL; - } } void @@ -1734,11 +1728,11 @@ EVT_MENU(PHMMENU_PROCESS_PROJECTIONS, PhantomFileView::OnProjections) END_EVENT_TABLE() PhantomFileView::PhantomFileView() -: wxView(), m_canvas(NULL), m_frame(NULL), m_pFileMenu(0) +: wxView(), m_canvas(NULL), m_pFrame(NULL), m_pFileMenu(0) { m_iDefaultNDet = 367; m_iDefaultNView = 320; - m_iDefaultNSample = 2; + m_iDefaultNSample = 1; m_dDefaultRotation = 1; m_dDefaultFocalLength = 2; m_dDefaultFieldOfView = 1; @@ -1752,7 +1746,7 @@ PhantomFileView::PhantomFileView() PhantomFileView::~PhantomFileView() { - + theApp->getDocManager()->FileHistoryRemoveMenu (m_pFileMenu); } void @@ -1838,7 +1832,7 @@ PhantomFileView::OnProjections (wxCommandEvent& event) rProj.setRemark (os.str()); *theApp->getLog() << os.str().c_str() << "\n"; - m_frame->Lower(); + m_pFrame->Lower(); ::wxYield(); ProjectionFileView* projView = dynamic_cast(pProjectionDoc->GetFirstView()); if (projView) { @@ -1925,7 +1919,11 @@ PhantomFileView::CreateCanvas (wxView *view, wxFrame *parent) return pCanvas; } -wxFrame* +#if CTSIM_MDI +wxDocMDIChildFrame* +#else +wxDocChildFrame* +#endif PhantomFileView::CreateChildFrame(wxDocument *doc, wxView *view) { #if CTSIM_MDI @@ -1994,21 +1992,21 @@ PhantomFileView::CreateChildFrame(wxDocument *doc, wxView *view) bool PhantomFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) { - m_frame = CreateChildFrame(doc, this); - SetFrame(m_frame); + m_pFrame = CreateChildFrame(doc, this); + SetFrame(m_pFrame); int width, height; - m_frame->GetClientSize(&width, &height); - m_frame->SetTitle("PhantomFileView"); - m_canvas = CreateCanvas (this, m_frame); + m_pFrame->GetClientSize(&width, &height); + m_pFrame->SetTitle("PhantomFileView"); + m_canvas = CreateCanvas (this, m_pFrame); #ifdef __X__ int x, y; // X requires a forced resize - m_frame->GetSize(&x, &y); - m_frame->SetSize(-1, -1, x, y); + m_pFrame->GetSize(&x, &y); + m_pFrame->SetSize(-1, -1, x, y); #endif - m_frame->Show(true); + m_pFrame->Show(true); Activate(true); return true; @@ -2030,18 +2028,21 @@ PhantomFileView::OnClose (bool deleteWindow) if (m_canvas) { m_canvas->Clear(); m_canvas->setView(NULL); + m_canvas->Show(false); m_canvas = NULL; } wxString s(wxTheApp->GetAppName()); - if (m_frame) - m_frame->SetTitle(s); + if (m_pFrame) + m_pFrame->SetTitle(s); SetFrame(NULL); Activate(false); if (deleteWindow) { - delete m_frame; - m_frame = NULL; + m_pFrame->Show(false); + m_pFrame->Destroy(); +// delete m_pFrame; + m_pFrame = NULL; } return true; @@ -2069,12 +2070,7 @@ ProjectionFileCanvas::ProjectionFileCanvas (ProjectionFileView* v, wxFrame *fram ProjectionFileCanvas::~ProjectionFileCanvas () { - if (m_pView) { - wxMenu* pMenu = m_pView->getFileMenu(); - theApp->getDocManager()->FileHistoryRemoveMenu (pMenu); - m_pView->canvasClosed(); - m_pView = NULL; - } + m_pView = NULL; } void @@ -2109,7 +2105,7 @@ EVT_MENU(PJMENU_CONVERT_FFT_POLAR, ProjectionFileView::OnConvertFFTPolar) END_EVENT_TABLE() ProjectionFileView::ProjectionFileView() -: wxView(), m_canvas(NULL), m_frame(NULL), m_pFileMenu(0) +: wxView(), m_canvas(NULL), m_pFrame(NULL), m_pFileMenu(0) { m_iDefaultNX = 256; m_iDefaultNY = 256; @@ -2136,7 +2132,7 @@ ProjectionFileView::ProjectionFileView() ProjectionFileView::~ProjectionFileView() { - + theApp->getDocManager()->FileHistoryRemoveMenu (m_pFileMenu); } void @@ -2324,7 +2320,11 @@ ProjectionFileView::CreateCanvas (wxView *view, wxFrame *parent) return pCanvas; } -wxFrame* +#if CTSIM_MDI +wxDocMDIChildFrame* +#else +wxDocChildFrame* +#endif ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view) { #ifdef CTSIM_MDI @@ -2402,21 +2402,21 @@ ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view) bool ProjectionFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) { - m_frame = CreateChildFrame(doc, this); - SetFrame(m_frame); + m_pFrame = CreateChildFrame(doc, this); + SetFrame(m_pFrame); int width, height; - m_frame->GetClientSize(&width, &height); - m_frame->SetTitle("ProjectionFileView"); - m_canvas = CreateCanvas(this, m_frame); + m_pFrame->GetClientSize(&width, &height); + m_pFrame->SetTitle("ProjectionFileView"); + m_canvas = CreateCanvas(this, m_pFrame); #ifdef __X__ int x, y; // X requires a forced resize - m_frame->GetSize(&x, &y); - m_frame->SetSize(-1, -1, x, y); + m_pFrame->GetSize(&x, &y); + m_pFrame->SetSize(-1, -1, x, y); #endif - m_frame->Show(true); + m_pFrame->Show(true); Activate(true); return true; @@ -2425,11 +2425,11 @@ ProjectionFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) void ProjectionFileView::OnDraw (wxDC* dc) { - wxSize clientSize = m_frame->GetClientSize(); + wxSize clientSize = m_pFrame->GetClientSize(); wxSize bestSize = m_canvas->GetBestSize(); if (clientSize.x > bestSize.x || clientSize.y > bestSize.y) - m_frame->SetClientSize (bestSize); + m_pFrame->SetClientSize (bestSize); if (m_bitmap.Ok()) dc->DrawBitmap (m_bitmap, 0, 0, false); @@ -2477,7 +2477,7 @@ ProjectionFileView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) int ySize = nView; xSize = clamp (xSize, 0, 800); ySize = clamp (ySize, 0, 800); - m_frame->SetClientSize (xSize, ySize); + m_pFrame->SetClientSize (xSize, ySize); m_canvas->SetScrollbars (20, 20, nDet/20, nView/20); } @@ -2492,20 +2492,23 @@ ProjectionFileView::OnClose (bool deleteWindow) return false; if (m_canvas) { - //m_canvas->Clear(); + m_canvas->Clear(); m_canvas->setView(NULL); + m_canvas->Show(false); m_canvas = NULL; } -// wxString s(wxTheApp->GetAppName()); -// if (m_frame) -// m_frame->SetTitle(s); - SetFrame(NULL); + wxString s(wxTheApp->GetAppName()); + if (m_pFrame) + m_pFrame->SetTitle(s); +// SetFrame(NULL); Activate(false); if (deleteWindow) { - delete m_frame; - return true; + m_pFrame->Show(false); + m_pFrame->Destroy(); +// delete m_pFrame; + m_pFrame = NULL; } return true; } @@ -2521,12 +2524,7 @@ PlotFileCanvas::PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& PlotFileCanvas::~PlotFileCanvas () { - if (m_pView) { - wxMenu* pMenu = m_pView->getFileMenu(); - theApp->getDocManager()->FileHistoryRemoveMenu (pMenu); - m_pView->canvasClosed(); m_pView = NULL; - } } void @@ -2549,7 +2547,7 @@ EVT_MENU(PLOTMENU_VIEW_SCALE_FULL, PlotFileView::OnScaleFull) END_EVENT_TABLE() PlotFileView::PlotFileView() -: wxView(), m_canvas(NULL), m_frame(NULL), m_pEZPlot(NULL), m_pFileMenu(0) +: wxView(), m_canvas(NULL), m_pFrame(NULL), m_pEZPlot(NULL), m_pFileMenu(0) { m_bMinSpecified = false; m_bMaxSpecified = false; @@ -2560,7 +2558,7 @@ PlotFileView::~PlotFileView() if (m_pEZPlot) delete m_pEZPlot; - + theApp->getDocManager()->FileHistoryRemoveMenu (m_pFileMenu); } void @@ -2653,7 +2651,11 @@ PlotFileView::CreateCanvas (wxView *view, wxFrame *parent) return pCanvas; } -wxFrame* +#if CTSIM_MDI +wxDocMDIChildFrame* +#else +wxDocChildFrame* +#endif PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view) { #ifdef CTSIM_MDI @@ -2726,25 +2728,25 @@ PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view) bool PlotFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) ) { - m_frame = CreateChildFrame(doc, this); - SetFrame(m_frame); + m_pFrame = CreateChildFrame(doc, this); + SetFrame(m_pFrame); m_bMinSpecified = false; m_bMaxSpecified = false; m_dAutoScaleFactor = 1.; int width, height; - m_frame->GetClientSize(&width, &height); - m_frame->SetTitle ("Plot File"); - m_canvas = CreateCanvas (this, m_frame); + m_pFrame->GetClientSize(&width, &height); + m_pFrame->SetTitle ("Plot File"); + m_canvas = CreateCanvas (this, m_pFrame); #ifdef __X__ int x, y; // X requires a forced resize - m_frame->GetSize(&x, &y); - m_frame->SetSize(-1, -1, x, y); + m_pFrame->GetSize(&x, &y); + m_pFrame->SetSize(-1, -1, x, y); #endif - m_frame->Show(true); + m_pFrame->Show(true); Activate(true); return true; @@ -2822,20 +2824,23 @@ PlotFileView::OnClose (bool deleteWindow) return false; if (m_canvas) { - //m_canvas->Clear(); + m_canvas->Clear(); m_canvas->setView (NULL); + m_canvas->Show(false); m_canvas = NULL; } -// wxString s(wxTheApp->GetAppName()); -// if (m_frame) -// m_frame->SetTitle(s); + wxString s(wxTheApp->GetAppName()); + if (m_pFrame) + m_pFrame->SetTitle(s); SetFrame(NULL); Activate(false); if (deleteWindow) { - delete m_frame; - return true; + m_pFrame->Show(false); + m_pFrame->Destroy(); +// delete m_pFrame; + m_pFrame = NULL; } return true; } @@ -2848,7 +2853,7 @@ IMPLEMENT_DYNAMIC_CLASS(TextFileView, wxView) TextFileView::~TextFileView() { - + theApp->getDocManager()->FileHistoryRemoveMenu (m_pFileMenu); } bool TextFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) @@ -2892,19 +2897,25 @@ TextFileView::OnClose (bool deleteWindow) if (! GetDocument() || ! GetDocument()->Close()) return false; - + + m_pCanvas->Show(false); Activate(false); - if (deleteWindow) - { - delete m_pFrame; + if (deleteWindow) { + m_pFrame->Show(false); + m_pFrame->Destroy(); +// delete m_pFrame; m_pFrame = NULL; } return TRUE; } -wxFrame* +#if CTSIM_MDI +wxDocMDIChildFrame* +#else +wxDocChildFrame* +#endif TextFileView::CreateChildFrame (wxDocument *doc, wxView *view) { #if CTSIM_MDI @@ -2968,10 +2979,5 @@ TextFileCanvas::TextFileCanvas (TextFileView* v, wxFrame* frame, const wxPoint& TextFileCanvas::~TextFileCanvas () { - if (m_pView) { - wxMenu* pMenu = m_pView->getFileMenu(); - theApp->getDocManager()->FileHistoryRemoveMenu (pMenu); - m_pView->canvasClosed(); - m_pView = NULL; - } + m_pView = NULL; }