1 /*****************************************************************************
5 ** Purpose: EZPlot Dialog
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: Jan 2001
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2001 Kevin Rosenberg
12 ** $Id: dlgezplot.cpp,v 1.2 2001/01/12 21:53:27 kevin Exp $
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
29 #pragma implementation "dlgezplot.h"
32 // For compilers that support precompilation, includes "wx.h".
33 #include "wx/wxprec.h"
42 #include "wx/button.h"
43 #include "wx/stattext.h"
44 #include "wx/layout.h"
47 #include "wx/settings.h"
48 #include "wx/dcclient.h"
54 #include "dlgezplot.h"
57 static const int LAYOUT_X_MARGIN = 4;
58 static const int LAYOUT_Y_MARGIN = 4;
60 BEGIN_EVENT_TABLE(EZPlotControl, wxPanel)
61 EVT_PAINT(EZPlotControl::OnPaint)
64 IMPLEMENT_CLASS(EZPlotControl, wxPanel)
67 EZPlotControl::EZPlotControl (wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style,
68 const wxValidator& validator, const wxString& name)
69 : m_pEZPlot(0), m_pSGPDriver(0), m_pSGP(0), m_pDC(0)
71 Create(parent, id, pos, size, style, name);
73 SetSize (GetBestSize());
75 m_pEZPlot = new EZPlot;
79 EZPlotControl::GetBestSize () const
81 return wxSize (500,500);
84 EZPlotControl::~EZPlotControl()
93 EZPlotControl::OnPaint (wxPaintEvent& event)
96 GetClientSize (&m_iClientX, &m_iClientY);
97 m_pSGPDriver = new SGPDriver (&dc, m_iClientX, m_iClientY);
98 m_pSGP = new SGP (*m_pSGPDriver);
99 m_pSGP->setTextPointSize(10);
100 if (m_pEZPlot && m_pSGP) {
101 m_pSGP->eraseWindow();
102 m_pEZPlot->plot (m_pSGP);
107 EZPlotDialog::EZPlotDialog (wxWindow *parent)
108 : wxDialog((parent ? parent : theApp->getMainFrame()), -1, wxString("EZPlot"), wxDefaultPosition, wxDefaultSize, wxDIALOG_MODAL),
112 parent = theApp->getMainFrame();
114 m_parentTop = parent;
115 while ( m_parentTop && m_parentTop->GetParent() )
116 m_parentTop = m_parentTop->GetParent();
118 wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
120 pTopSizer->Add (m_pEZPlotCtrl = new EZPlotControl (this), 0, wxALIGN_CENTER | wxALL, 5);
122 wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
123 wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
124 wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
125 pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
126 pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
128 pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
130 SetAutoLayout (true);
131 SetSizer (pTopSizer);
132 pTopSizer->Fit (this);
133 pTopSizer->SetSizeHints (this);
138 /////////////////////////////////////////////////////
141 EZPlotDialog::~EZPlotDialog()
144 m_parentTop->Enable(TRUE);