+/*****************************************************************************
+** FILE IDENTIFICATION
+**
+** Name: dlgezplot.cpp
+** Purpose: EZPlot Dialog
+** Programmer: Kevin Rosenberg
+** Date Started: Jan 2001
+**
+** This is part of the CTSim program
+** Copyright (C) 1983-2001 Kevin Rosenberg
+**
+** $Id: dlgezplot.cpp,v 1.1 2001/01/12 16:41:56 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
+** published by the Free Software Foundation.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+******************************************************************************/
+
+#ifdef __GNUG__
+#pragma implementation "dlgezplot.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/utils.h"
+#include "wx/frame.h"
+#include "wx/button.h"
+#include "wx/stattext.h"
+#include "wx/layout.h"
+#include "wx/event.h"
+#include "wx/intl.h"
+#include "wx/settings.h"
+#include "wx/dcclient.h"
+#include "wx/timer.h"
+#endif
+
+#include "dlgezplot.h"
+#include "ct.h"
+
+
+static const int LAYOUT_X_MARGIN = 4;
+static const int LAYOUT_Y_MARGIN = 4;
+
+BEGIN_EVENT_TABLE(EZPlotDialog, wxDialog)
+EVT_BUTTON(wxID_CANCEL, EZPlotDialog::OnCancel)
+EVT_CLOSE(EZPlotDialog::OnClose)
+EVT_PAINT(EZPlotDialog::OnPaint)
+END_EVENT_TABLE()
+
+IMPLEMENT_CLASS(EZPlotDialog, wxDialog)
+
+
+EZPlotDialog::EZPlotDialog (wxWindow *parent)
+: wxDialog(parent, -1, wxString("EZPlot"), wxDefaultPosition, wxDefaultSize, wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE),
+ m_pEZPlot(0), m_pSGPDriver(0), m_pSGP(0), m_pDC(0)
+{
+ m_parentTop = parent;
+ while ( m_parentTop && m_parentTop->GetParent() )
+ m_parentTop = m_parentTop->GetParent();
+
+ wxLayoutConstraints* c = new wxLayoutConstraints;
+ c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN);
+ c->bottom.SameAs(this, wxBottom, 2*LAYOUT_Y_MARGIN);
+
+ wxSize sizeBtn = wxButton::GetDefaultSize();
+ c->width.Absolute(sizeBtn.x);
+ c->height.Absolute(sizeBtn.y);
+
+ SetAutoLayout(TRUE);
+ Layout();
+
+ wxSize sizeDlg (500,500);
+ if (sizeDlg.x != sizeDlg.y) {
+ sizeDlg.x = max(sizeDlg.x,sizeDlg.y);
+ sizeDlg.y = max(sizeDlg.x,sizeDlg.y);
+ }
+
+ m_iClientX = sizeDlg.x;
+ m_iClientY = sizeDlg.y;
+ SetClientSize(sizeDlg);
+
+ Centre(wxCENTER_FRAME | wxBOTH);
+
+ if ( m_parentTop )
+ m_parentTop->Enable(FALSE);
+
+ Show(TRUE);
+ Enable(TRUE); // enable this window
+
+ m_pDC = dynamic_cast<wxDC*> (new wxClientDC (this));
+ int x, y;
+ this->GetClientSize(&x, &y);
+ m_pSGPDriver = new SGPDriver (m_pDC, x, y);
+ m_pSGP = new SGP (*m_pSGPDriver);
+ m_pSGP->setTextPointSize(10);
+ m_pEZPlot = new EZPlot;
+
+#ifdef __WXMAC__
+ MacUpdateImmediately();
+#endif
+}
+
+
+void EZPlotDialog::OnClose(wxCloseEvent& event)
+{
+}
+
+void
+EZPlotDialog::OnPaint (wxPaintEvent& event)
+{
+ m_pEZPlot->plot (m_pSGP);
+}
+
+
+/////////////////////////////////////////////////////
+// destruction
+
+EZPlotDialog::~EZPlotDialog()
+{
+ if ( m_parentTop )
+ m_parentTop->Enable(TRUE);
+
+ delete m_pEZPlot;
+ delete m_pSGP;
+ delete m_pSGPDriver;
+ delete m_pDC;
+}
+