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.4 2001/03/29 21:25:50 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 ******************************************************************************/
35 #pragma implementation "dlgezplot.h"
38 // For compilers that support precompilation, includes "wx.h".
39 #include "wx/wxprec.h"
48 #include "wx/button.h"
49 #include "wx/stattext.h"
50 #include "wx/layout.h"
53 #include "wx/settings.h"
54 #include "wx/dcclient.h"
59 #include "../src/ctsim.h"
60 #include "dlgezplot.h"
63 static const int LAYOUT_X_MARGIN = 4;
64 static const int LAYOUT_Y_MARGIN = 4;
66 BEGIN_EVENT_TABLE(EZPlotControl, wxPanel)
67 EVT_PAINT(EZPlotControl::OnPaint)
70 IMPLEMENT_CLASS(EZPlotControl, wxPanel)
73 EZPlotControl::EZPlotControl (wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
74 long style, const wxValidator& validator, const wxString& name)
75 : m_pEZPlot(0), m_pSGPDriver(0), m_pSGP(0), m_pDC(0)
77 Create(parent, id, pos, size, style, name);
79 SetSize (GetBestSize());
81 m_pEZPlot = new EZPlot;
85 EZPlotControl::GetBestSize () const
87 return wxSize (500,500);
90 EZPlotControl::~EZPlotControl()
99 EZPlotControl::OnPaint (wxPaintEvent& event)
102 GetClientSize (&m_iClientX, &m_iClientY);
103 m_pSGPDriver = new SGPDriver (&dc, m_iClientX, m_iClientY);
104 m_pSGP = new SGP (*m_pSGPDriver);
105 m_pSGP->setTextPointSize(10);
106 // m_pSGP->setViewport (0, 0, 1., 0.5); // for debugging testing only
107 if (m_pEZPlot && m_pSGP) {
108 m_pSGP->eraseWindow();
109 m_pEZPlot->plot (m_pSGP);
114 wxEZPlotDialog::wxEZPlotDialog (wxWindow *parent, bool bCancelButton)
115 : wxDialog((parent ? parent : theApp->getMainFrame()), -1, wxString("EZPlot"), wxDefaultPosition, wxDefaultSize, wxDIALOG_MODAL),
119 parent = theApp->getMainFrame();
121 m_parentTop = parent;
122 while ( m_parentTop && m_parentTop->GetParent() )
123 m_parentTop = m_parentTop->GetParent();
125 wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
127 pTopSizer->Add (m_pEZPlotCtrl = new EZPlotControl (this), 0, wxALIGN_CENTER | wxALL, 5);
129 wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
130 wxButton* pButtonOk = new wxButton (this, wxID_OK, "Ok");
131 pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
133 wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
134 pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
136 pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
138 SetAutoLayout (true);
139 SetSizer (pTopSizer);
140 pTopSizer->Fit (this);
141 pTopSizer->SetSizeHints (this);
146 EZPlotDialog::EZPlotDialog(wxWindow* parent, bool bCancelButton)
147 : m_pDialog(new wxEZPlotDialog(parent, bCancelButton))
152 EZPlotDialog::getEZPlot()
153 { return m_pDialog->getEZPlot(); }
156 EZPlotDialog::ShowModal()
157 { return m_pDialog->ShowModal(); }
159 wxEZPlotDialog::~wxEZPlotDialog()
162 m_parentTop->Enable(TRUE);
167 #endif // HAVE_WXWINDOWS