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-2009 Kevin Rosenberg
12 ** This program is free software; you can redistribute it and/or modify
13 ** it under the terms of the GNU General Public License (version 2) as
14 ** published by the Free Software Foundation.
16 ** This program is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ** GNU General Public License for more details.
21 ** You should have received a copy of the GNU General Public License
22 ** along with this program; if not, write to the Free Software
23 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ******************************************************************************/
32 // For compilers that support precompilation, includes "wx.h".
33 #include "wx/wxprec.h"
38 #include "wx/button.h"
39 #include "wx/stattext.h"
40 #include "wx/layout.h"
43 #include "wx/settings.h"
44 #include "wx/dcclient.h"
49 #include "../src/ctsim.h"
50 #include "dlgezplot.h"
53 static const int LAYOUT_X_MARGIN = 4;
54 static const int LAYOUT_Y_MARGIN = 4;
56 BEGIN_EVENT_TABLE(EZPlotControl, wxPanel)
57 EVT_PAINT(EZPlotControl::OnPaint)
60 IMPLEMENT_CLASS(EZPlotControl, wxPanel)
63 EZPlotControl::EZPlotControl (wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
64 long style, const wxValidator& validator, const wxString& name)
65 : m_pEZPlot(0), m_pSGPDriver(0), m_pSGP(0), m_pDC(0)
67 Create(parent, id, pos, size, style, name);
69 SetSize (GetBestSize());
71 m_pEZPlot = new EZPlot;
75 EZPlotControl::GetBestSize () const
77 return wxSize (500,500);
80 EZPlotControl::~EZPlotControl()
89 EZPlotControl::OnPaint (wxPaintEvent& event)
92 GetClientSize (&m_iClientX, &m_iClientY);
93 m_pSGPDriver = new SGPDriver (&dc, m_iClientX, m_iClientY);
94 m_pSGP = new SGP (*m_pSGPDriver);
95 m_pSGP->setTextPointSize(10);
96 // m_pSGP->setViewport (0, 0, 1., 0.5); // for debugging testing only
97 if (m_pEZPlot && m_pSGP) {
98 m_pSGP->eraseWindow();
99 m_pEZPlot->plot (m_pSGP);
104 wxEZPlotDialog::wxEZPlotDialog (wxWindow *parent, bool bCancelButton)
105 : wxDialog((parent ? parent : theApp->getMainFrame()), -1, _T("EZPlot"), wxDefaultPosition, wxDefaultSize, wxDIALOG_MODAL),
109 parent = theApp->getMainFrame();
111 m_parentTop = parent;
112 while ( m_parentTop && m_parentTop->GetParent() )
113 m_parentTop = m_parentTop->GetParent();
115 wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
117 pTopSizer->Add (m_pEZPlotCtrl = new EZPlotControl (this), 0, wxALIGN_CENTER | wxALL, 5);
119 wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
120 wxButton* pButtonOk = new wxButton (this, wxID_OK, _T("Ok"));
121 pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
123 wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, _T("Cancel"));
124 pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
126 pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
128 SetAutoLayout (true);
129 SetSizer (pTopSizer);
130 pTopSizer->Fit (this);
131 pTopSizer->SetSizeHints (this);
136 EZPlotDialog::EZPlotDialog(wxWindow* parent, bool bCancelButton)
137 : m_pDialog(new wxEZPlotDialog(parent, bCancelButton))
142 EZPlotDialog::getEZPlot()
143 { return m_pDialog->getEZPlot(); }
146 EZPlotDialog::ShowModal()
147 { return m_pDialog->ShowModal(); }
149 wxEZPlotDialog::~wxEZPlotDialog()
152 m_parentTop->Enable(TRUE);
157 #endif // HAVE_WXWINDOWS