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.1 2001/01/12 16:41:56 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"
52 #include "dlgezplot.h"
56 static const int LAYOUT_X_MARGIN = 4;
57 static const int LAYOUT_Y_MARGIN = 4;
59 BEGIN_EVENT_TABLE(EZPlotDialog, wxDialog)
60 EVT_BUTTON(wxID_CANCEL, EZPlotDialog::OnCancel)
61 EVT_CLOSE(EZPlotDialog::OnClose)
62 EVT_PAINT(EZPlotDialog::OnPaint)
65 IMPLEMENT_CLASS(EZPlotDialog, wxDialog)
68 EZPlotDialog::EZPlotDialog (wxWindow *parent)
69 : wxDialog(parent, -1, wxString("EZPlot"), wxDefaultPosition, wxDefaultSize, wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE),
70 m_pEZPlot(0), m_pSGPDriver(0), m_pSGP(0), m_pDC(0)
73 while ( m_parentTop && m_parentTop->GetParent() )
74 m_parentTop = m_parentTop->GetParent();
76 wxLayoutConstraints* c = new wxLayoutConstraints;
77 c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN);
78 c->bottom.SameAs(this, wxBottom, 2*LAYOUT_Y_MARGIN);
80 wxSize sizeBtn = wxButton::GetDefaultSize();
81 c->width.Absolute(sizeBtn.x);
82 c->height.Absolute(sizeBtn.y);
87 wxSize sizeDlg (500,500);
88 if (sizeDlg.x != sizeDlg.y) {
89 sizeDlg.x = max(sizeDlg.x,sizeDlg.y);
90 sizeDlg.y = max(sizeDlg.x,sizeDlg.y);
93 m_iClientX = sizeDlg.x;
94 m_iClientY = sizeDlg.y;
95 SetClientSize(sizeDlg);
97 Centre(wxCENTER_FRAME | wxBOTH);
100 m_parentTop->Enable(FALSE);
103 Enable(TRUE); // enable this window
105 m_pDC = dynamic_cast<wxDC*> (new wxClientDC (this));
107 this->GetClientSize(&x, &y);
108 m_pSGPDriver = new SGPDriver (m_pDC, x, y);
109 m_pSGP = new SGP (*m_pSGPDriver);
110 m_pSGP->setTextPointSize(10);
111 m_pEZPlot = new EZPlot;
114 MacUpdateImmediately();
119 void EZPlotDialog::OnClose(wxCloseEvent& event)
124 EZPlotDialog::OnPaint (wxPaintEvent& event)
126 m_pEZPlot->plot (m_pSGP);
130 /////////////////////////////////////////////////////
133 EZPlotDialog::~EZPlotDialog()
136 m_parentTop->Enable(TRUE);