** 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
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
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
return pCanvas;
}
-wxFrame*
+#if CTSIM_MDI
+wxDocMDIChildFrame*
+#else
+wxDocChildFrame*
+#endif
ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view)
{
#if CTSIM_MDI
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;
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);
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);
}
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;
}
PhantomCanvas::~PhantomCanvas ()
{
- if (m_pView) {
- wxMenu* pMenu = m_pView->getFileMenu();
- theApp->getDocManager()->FileHistoryRemoveMenu (pMenu);
- m_pView->canvasClosed();
m_pView = NULL;
- }
}
void
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;
PhantomFileView::~PhantomFileView()
{
-
+ theApp->getDocManager()->FileHistoryRemoveMenu (m_pFileMenu);
}
void
rProj.setRemark (os.str());
*theApp->getLog() << os.str().c_str() << "\n";
- m_frame->Lower();
+ m_pFrame->Lower();
::wxYield();
ProjectionFileView* projView = dynamic_cast<ProjectionFileView*>(pProjectionDoc->GetFirstView());
if (projView) {
return pCanvas;
}
-wxFrame*
+#if CTSIM_MDI
+wxDocMDIChildFrame*
+#else
+wxDocChildFrame*
+#endif
PhantomFileView::CreateChildFrame(wxDocument *doc, wxView *view)
{
#if CTSIM_MDI
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;
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;
ProjectionFileCanvas::~ProjectionFileCanvas ()
{
- if (m_pView) {
- wxMenu* pMenu = m_pView->getFileMenu();
- theApp->getDocManager()->FileHistoryRemoveMenu (pMenu);
- m_pView->canvasClosed();
- m_pView = NULL;
- }
+ m_pView = NULL;
}
void
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;
ProjectionFileView::~ProjectionFileView()
{
-
+ theApp->getDocManager()->FileHistoryRemoveMenu (m_pFileMenu);
}
void
return pCanvas;
}
-wxFrame*
+#if CTSIM_MDI
+wxDocMDIChildFrame*
+#else
+wxDocChildFrame*
+#endif
ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view)
{
#ifdef CTSIM_MDI
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;
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);
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);
}
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;
}
PlotFileCanvas::~PlotFileCanvas ()
{
- if (m_pView) {
- wxMenu* pMenu = m_pView->getFileMenu();
- theApp->getDocManager()->FileHistoryRemoveMenu (pMenu);
- m_pView->canvasClosed();
m_pView = NULL;
- }
}
void
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;
if (m_pEZPlot)
delete m_pEZPlot;
-
+ theApp->getDocManager()->FileHistoryRemoveMenu (m_pFileMenu);
}
void
return pCanvas;
}
-wxFrame*
+#if CTSIM_MDI
+wxDocMDIChildFrame*
+#else
+wxDocChildFrame*
+#endif
PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view)
{
#ifdef CTSIM_MDI
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;
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;
}
TextFileView::~TextFileView()
{
-
+ theApp->getDocManager()->FileHistoryRemoveMenu (m_pFileMenu);
}
bool TextFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
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
TextFileCanvas::~TextFileCanvas ()
{
- if (m_pView) {
- wxMenu* pMenu = m_pView->getFileMenu();
- theApp->getDocManager()->FileHistoryRemoveMenu (pMenu);
- m_pView->canvasClosed();
- m_pView = NULL;
- }
+ m_pView = NULL;
}