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.5 2003/01/23 23:35:58 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 ******************************************************************************/
34 // For compilers that support precompilation, includes "wx.h".
35 #include "wx/wxprec.h"
40 #include "wx/button.h"
41 #include "wx/stattext.h"
42 #include "wx/layout.h"
45 #include "wx/settings.h"
46 #include "wx/dcclient.h"
51 #include "../src/ctsim.h"
52 #include "dlgezplot.h"
55 static const int LAYOUT_X_MARGIN = 4;
56 static const int LAYOUT_Y_MARGIN = 4;
58 BEGIN_EVENT_TABLE(EZPlotControl, wxPanel)
59 EVT_PAINT(EZPlotControl::OnPaint)
62 IMPLEMENT_CLASS(EZPlotControl, wxPanel)
65 EZPlotControl::EZPlotControl (wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
66 long style, const wxValidator& validator, const wxString& name)
67 : m_pEZPlot(0), m_pSGPDriver(0), m_pSGP(0), m_pDC(0)
69 Create(parent, id, pos, size, style, name);
71 SetSize (GetBestSize());
73 m_pEZPlot = new EZPlot;
77 EZPlotControl::GetBestSize () const
79 return wxSize (500,500);
82 EZPlotControl::~EZPlotControl()
91 EZPlotControl::OnPaint (wxPaintEvent& event)
94 GetClientSize (&m_iClientX, &m_iClientY);
95 m_pSGPDriver = new SGPDriver (&dc, m_iClientX, m_iClientY);
96 m_pSGP = new SGP (*m_pSGPDriver);
97 m_pSGP->setTextPointSize(10);
98 // m_pSGP->setViewport (0, 0, 1., 0.5); // for debugging testing only
99 if (m_pEZPlot && m_pSGP) {
100 m_pSGP->eraseWindow();
101 m_pEZPlot->plot (m_pSGP);
106 wxEZPlotDialog::wxEZPlotDialog (wxWindow *parent, bool bCancelButton)
107 : wxDialog((parent ? parent : theApp->getMainFrame()), -1, wxString("EZPlot"), wxDefaultPosition, wxDefaultSize, wxDIALOG_MODAL),
111 parent = theApp->getMainFrame();
113 m_parentTop = parent;
114 while ( m_parentTop && m_parentTop->GetParent() )
115 m_parentTop = m_parentTop->GetParent();
117 wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
119 pTopSizer->Add (m_pEZPlotCtrl = new EZPlotControl (this), 0, wxALIGN_CENTER | wxALL, 5);
121 wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
122 wxButton* pButtonOk = new wxButton (this, wxID_OK, "Ok");
123 pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
125 wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
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 EZPlotDialog::EZPlotDialog(wxWindow* parent, bool bCancelButton)
139 : m_pDialog(new wxEZPlotDialog(parent, bCancelButton))
144 EZPlotDialog::getEZPlot()
145 { return m_pDialog->getEZPlot(); }
148 EZPlotDialog::ShowModal()
149 { return m_pDialog->ShowModal(); }
151 wxEZPlotDialog::~wxEZPlotDialog()
154 m_parentTop->Enable(TRUE);
159 #endif // HAVE_WXWINDOWS