** This is part of the CTSim program
** Copyright (c) 1983-2001 Kevin Rosenberg
**
-** $Id: views.cpp,v 1.160 2002/06/03 16:57:22 kevin Exp $
+** $Id: views.cpp,v 1.161 2002/06/06 22:50:24 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
END_EVENT_TABLE()
ImageFileView::ImageFileView()
-: wxView(), m_pFrame(NULL), m_pCanvas(NULL), m_pFileMenu(0), m_pFilterMenu(0), m_bMinSpecified(false), m_bMaxSpecified(false)
-{
- m_iDefaultExportFormatID = ImageFile::EXPORT_FORMAT_PNG;
-}
+: wxView(), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0), m_pFilterMenu(0),
+ m_bMinSpecified(false), m_bMaxSpecified(false),
+ m_iDefaultExportFormatID(ImageFile::EXPORT_FORMAT_PNG)
+{}
ImageFileView::~ImageFileView()
{
// PlotFileCanvas
PlotFileCanvas::PlotFileCanvas (PlotFileView* 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_pView = v;
}
-wxSize
-PlotFileCanvas::GetBestSize() const
+PlotFileCanvas::~PlotFileCanvas ()
{
- if (! m_pView)
- return wxSize(0,0);
-
- int xSize, ySize;
- theApp->getMainFrame()->GetClientSize (&xSize, &ySize);
- xSize = maxValue<int> (xSize, ySize);
-#ifdef CTSIM_MDI
- ySize = xSize = (xSize / 4);
-#else
- ySize = xSize;
-#endif
- return wxSize (xSize, ySize);
}
-PlotFileCanvas::~PlotFileCanvas ()
+wxSize
+PlotFileCanvas::GetBestSize() const
{
- m_pView = NULL;
+ return wxSize (500, 300);
}
+
void
PlotFileCanvas::OnDraw(wxDC& dc)
{
END_EVENT_TABLE()
PlotFileView::PlotFileView()
-: wxView(), m_pFrame(NULL), m_pCanvas(NULL), m_pEZPlot(NULL), m_pFileMenu(0), m_bMinSpecified(false), m_bMaxSpecified(false)
+: wxView(), m_pFrame(0), m_pCanvas(0), m_pEZPlot(0), m_pFileMenu(0),
+ m_bMinSpecified(false), m_bMaxSpecified(false)
{
}
delete m_pEZPlot;
GetDocumentManager()->FileHistoryRemoveMenu (m_pFileMenu);
+ GetDocumentManager()->ActivateView(this, FALSE, TRUE);
}
void
PlotFileView::CreateCanvas (wxFrame* parent)
{
PlotFileCanvas* pCanvas;
- int width, height;
- parent->GetClientSize(&width, &height);
-
- pCanvas = new PlotFileCanvas (this, parent, wxPoint(-1,-1), wxSize(width, height), 0);
+ pCanvas = new PlotFileCanvas (this, parent, wxPoint(-1,-1), wxSize(-1,-1), 0);
pCanvas->SetBackgroundColour(*wxWHITE);
pCanvas->Clear();
PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view)
{
#ifdef CTSIM_MDI
- wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(-1,-1), wxSize(500, 300), wxDEFAULT_FRAME_STYLE);
+ wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#else
- wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(-1,-1), wxSize(500, 300), wxDEFAULT_FRAME_STYLE);
+ wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, theApp->getMainFrame(), -1, "Plot Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#endif
theApp->setIconForFrame (subframe);
bool
PlotFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) )
{
- m_pFrame = CreateChildFrame(doc, this);
- SetFrame(m_pFrame);
-
m_bMinSpecified = false;
m_bMaxSpecified = false;
m_dAutoScaleFactor = 1.;
- int width, height;
- m_pFrame->GetClientSize(&width, &height);
- m_pFrame->SetTitle ("Plot File");
+ m_pFrame = CreateChildFrame(doc, this);
+ SetFrame(m_pFrame);
m_pCanvas = CreateCanvas (m_pFrame);
+ m_pFrame->SetClientSize (m_pCanvas->GetBestSize());
+ m_pCanvas->SetClientSize (m_pCanvas->GetBestSize());
+ m_pFrame->SetTitle ("Plot File");
m_pFrame->Show(true);
Activate(true);
return true;
}
+void
+PlotFileView::setInitialClientSize ()
+{
+ if (m_pFrame && m_pCanvas) {
+ wxSize bestSize = m_pCanvas->GetBestSize();
+
+ m_pFrame->SetClientSize (bestSize);
+ m_pFrame->Show (true);
+ m_pFrame->SetFocus();
+ }
+}
+
+
void
PlotFileView::OnDraw (wxDC* dc)
{
bool
PlotFileView::OnClose (bool deleteWindow)
{
- //GetDocumentManager()->ActivateView (this, false, true);
if (! GetDocument() || ! GetDocument()->Close())
return false;