X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=libctgraphics%2Fdlgezplot.cpp;fp=libctgraphics%2Fdlgezplot.cpp;h=d59f11f9452dac00086816fb2594baa323438d83;hb=0b7751a41a5a51daa7f919e5ba492a5f629c1393;hp=0000000000000000000000000000000000000000;hpb=d5e6a7c9a42e5599ffd80efee363956837dfd3da;p=ctsim.git diff --git a/libctgraphics/dlgezplot.cpp b/libctgraphics/dlgezplot.cpp new file mode 100644 index 0000000..d59f11f --- /dev/null +++ b/libctgraphics/dlgezplot.cpp @@ -0,0 +1,150 @@ +/***************************************************************************** +** FILE IDENTIFICATION +** +** Name: dlgezplot.cpp +** Purpose: EZPlot Dialog +** Programmer: Kevin Rosenberg +** Date Started: Jan 2001 +** +** This is part of the CTSim program +** Copyright (C) 1983-2001 Kevin Rosenberg +** +** $Id: dlgezplot.cpp,v 1.1 2001/01/13 04:47:50 kevin Exp $ +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License (version 2) as +** published by the Free Software Foundation. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +******************************************************************************/ + +#ifdef HAVE_WXWINDOWS + +#ifdef __GNUG__ +#pragma implementation "dlgezplot.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/utils.h" +#include "wx/frame.h" +#include "wx/button.h" +#include "wx/stattext.h" +#include "wx/layout.h" +#include "wx/event.h" +#include "wx/intl.h" +#include "wx/settings.h" +#include "wx/dcclient.h" +#include "wx/timer.h" +#endif + +#include "ct.h" +#include "../src/ctsim.h" +#include "dlgezplot.h" + + +static const int LAYOUT_X_MARGIN = 4; +static const int LAYOUT_Y_MARGIN = 4; + +BEGIN_EVENT_TABLE(EZPlotControl, wxPanel) +EVT_PAINT(EZPlotControl::OnPaint) +END_EVENT_TABLE() + +IMPLEMENT_CLASS(EZPlotControl, wxPanel) + + +EZPlotControl::EZPlotControl (wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, + const wxValidator& validator, const wxString& name) + : m_pEZPlot(0), m_pSGPDriver(0), m_pSGP(0), m_pDC(0) +{ + Create(parent, id, pos, size, style, name); + + SetSize (GetBestSize()); + + m_pEZPlot = new EZPlot; +} + +wxSize +EZPlotControl::GetBestSize () const +{ + return wxSize (500,500); +} + +EZPlotControl::~EZPlotControl() +{ + delete m_pEZPlot; + delete m_pSGP; + delete m_pSGPDriver; + delete m_pDC; +} + +void +EZPlotControl::OnPaint (wxPaintEvent& event) +{ + wxPaintDC dc(this); + GetClientSize (&m_iClientX, &m_iClientY); + m_pSGPDriver = new SGPDriver (&dc, m_iClientX, m_iClientY); + m_pSGP = new SGP (*m_pSGPDriver); + m_pSGP->setTextPointSize(10); + if (m_pEZPlot && m_pSGP) { + m_pSGP->eraseWindow(); + m_pEZPlot->plot (m_pSGP); + } +} + + +EZPlotDialog::EZPlotDialog (wxWindow *parent) +: wxDialog((parent ? parent : theApp->getMainFrame()), -1, wxString("EZPlot"), wxDefaultPosition, wxDefaultSize, wxDIALOG_MODAL), + m_parentTop(0) +{ + if (! parent) + parent = theApp->getMainFrame(); + + m_parentTop = parent; + while ( m_parentTop && m_parentTop->GetParent() ) + m_parentTop = m_parentTop->GetParent(); + + wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); + + pTopSizer->Add (m_pEZPlotCtrl = new EZPlotControl (this), 0, wxALIGN_CENTER | wxALL, 5); + + wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL); + wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay"); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); + pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); + pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); + + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); + + SetAutoLayout (true); + SetSizer (pTopSizer); + pTopSizer->Fit (this); + pTopSizer->SetSizeHints (this); +} + + + +///////////////////////////////////////////////////// +// destruction + +EZPlotDialog::~EZPlotDialog() +{ + if ( m_parentTop ) + m_parentTop->Enable(TRUE); +} + + +#endif // HAVE_WXWINDOWS