+/*****************************************************************************
+** FILE IDENTIFICATION
+**
+** Name: dialogs.cpp
+** Purpose: Dialog routines for CTSim program
+** Programmer: Kevin Rosenberg
+** Date Started: July 2000
+**
+** This is part of the CTSim program
+** Copyright (C) 1983-2000 Kevin Rosenberg
+**
+** $Id: dialogs.cpp,v 1.1 2000/07/18 03:14:35 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 __GNUG__
+// #pragma implementation
+#endif
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif
+
+#if !wxUSE_DOC_VIEW_ARCHITECTURE
+#error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in setup.h!
+#endif
+
+#include "wx/statline.h"
+#include "wx/sizer.h"
+#include "dialogs.h"
+#include <sstream>
+
+DialogGetImageMinMax::DialogGetImageMinMax (wxFrame* pParent, const ImageFile& rImagefile, double dDefaultMin = 0., double dDefaultMax = 0.)
+ : wxDialog (pParent, -1, "Set Image Display Minimum & Maximum", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxCAPTION), m_pTopSizer(NULL), m_pTextCtrlMin(NULL), m_pTextCtrlMax(NULL), m_pButtonSizer(NULL), m_pButtonOk(NULL), m_pButtonCancel(NULL), m_dDefaultMin(dDefaultMin), m_dDefaultMax(dDefaultMax)
+{
+ wxBoxSizer* m_pTopSizer = new wxBoxSizer (wxVERTICAL);
+
+ m_pTopSizer->Add (new wxStaticText (this, -1, "Set Image Display Minimum and Maximum"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
+
+ ostringstream os;
+ os << dDefaultMin;
+ m_pTextCtrlMin = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
+ ostringstream osMax;
+ osMax << dDefaultMax;
+ m_pTextCtrlMax = new wxTextCtrl (this, -1, osMax.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
+
+ wxGridSizer *pGridSizer = new wxGridSizer (2, 2, 5);
+ pGridSizer->Add (new wxStaticText (this, -1, "Minimum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+ pGridSizer->Add (m_pTextCtrlMin, 0, wxALIGN_CENTER_VERTICAL);
+ pGridSizer->Add (new wxStaticText (this, -1, "Maximum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+ pGridSizer->Add (m_pTextCtrlMax, 0, wxALIGN_CENTER_VERTICAL);
+ m_pTopSizer->Add (pGridSizer, 1, wxALL, 10);
+
+ m_pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
+
+ m_pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
+ m_pButtonOk = new wxButton (this, wxID_OK, "Okay");
+ m_pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
+ m_pButtonSizer->Add (m_pButtonOk, 0, wxEXPAND | wxALL, 10);
+ m_pButtonSizer->Add (m_pButtonCancel, 0, wxEXPAND | wxALL, 10);
+
+ m_pTopSizer->Add (m_pButtonSizer, 0, wxALIGN_CENTER);
+
+ SetAutoLayout (true);
+ SetSizer (m_pTopSizer);
+ m_pTopSizer->Fit (this);
+ m_pTopSizer->SetSizeHints (this);
+}
+
+DialogGetImageMinMax::~DialogGetImageMinMax (void)
+{
+#if 0
+ delete m_pTopSizer;
+ delete m_pTextCtrlMin;
+ delete m_pTextCtrlMax;
+ delete m_pButtonSizer;
+ delete m_pButtonOk;
+ delete m_pButtonCancel;
+#endif
+}
+
+double
+DialogGetImageMinMax::getMinimum (void)
+{
+ wxString strCtrl = m_pTextCtrlMin->GetValue();
+ double dValue;
+ if (strCtrl.ToDouble (&dValue))
+ return dValue;
+ else
+ return (m_dDefaultMin);
+}
+
+double
+DialogGetImageMinMax::getMaximum (void)
+{
+ wxString strCtrl = m_pTextCtrlMax->GetValue();
+ double dValue;
+ if (strCtrl.ToDouble (&dValue))
+ return dValue;
+ else
+ return (m_dDefaultMax);
+}
+