r150: *** empty log message ***
[ctsim.git] / src / dialogs.cpp
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          dialogs.cpp
5 **   Purpose:       Dialog routines for CTSim program
6 **   Programmer:    Kevin Rosenberg
7 **   Date Started:  July 2000
8 **
9 **  This is part of the CTSim program
10 **  Copyright (C) 1983-2000 Kevin Rosenberg
11 **
12 **  $Id: dialogs.cpp,v 1.1 2000/07/18 03:14:35 kevin Exp $
13 **
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.
17 **
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.
22 **
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 ******************************************************************************/
27
28 #ifdef __GNUG__
29 // #pragma implementation
30 #endif
31
32 // For compilers that support precompilation, includes "wx/wx.h".
33 #include "wx/wxprec.h"
34
35 #ifdef __BORLANDC__
36 #pragma hdrstop
37 #endif
38
39 #ifndef WX_PRECOMP
40 #include "wx/wx.h"
41 #endif
42
43 #if !wxUSE_DOC_VIEW_ARCHITECTURE
44 #error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in setup.h!
45 #endif
46
47 #include "wx/statline.h"
48 #include "wx/sizer.h"
49 #include "dialogs.h"
50 #include <sstream>
51
52 DialogGetImageMinMax::DialogGetImageMinMax (wxFrame* pParent, const ImageFile& rImagefile, double dDefaultMin = 0., double dDefaultMax = 0.)
53     : 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)
54 {
55   wxBoxSizer* m_pTopSizer = new wxBoxSizer (wxVERTICAL);
56
57   m_pTopSizer->Add (new wxStaticText (this, -1, "Set Image Display Minimum and Maximum"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
58                    
59   ostringstream os;
60   os << dDefaultMin;
61   m_pTextCtrlMin = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
62   ostringstream osMax;
63   osMax << dDefaultMax;
64   m_pTextCtrlMax = new wxTextCtrl (this, -1, osMax.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
65
66   wxGridSizer *pGridSizer = new wxGridSizer (2, 2, 5);
67   pGridSizer->Add (new wxStaticText (this, -1, "Minimum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
68   pGridSizer->Add (m_pTextCtrlMin, 0, wxALIGN_CENTER_VERTICAL);
69   pGridSizer->Add (new wxStaticText (this, -1, "Maximum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
70   pGridSizer->Add (m_pTextCtrlMax, 0, wxALIGN_CENTER_VERTICAL);
71   m_pTopSizer->Add (pGridSizer, 1, wxALL, 10);
72
73   m_pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
74
75   m_pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
76   m_pButtonOk = new wxButton (this, wxID_OK, "Okay");
77   m_pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
78   m_pButtonSizer->Add (m_pButtonOk, 0, wxEXPAND | wxALL, 10);
79   m_pButtonSizer->Add (m_pButtonCancel, 0, wxEXPAND | wxALL, 10);
80
81   m_pTopSizer->Add (m_pButtonSizer, 0, wxALIGN_CENTER);
82
83   SetAutoLayout (true);
84   SetSizer (m_pTopSizer);
85   m_pTopSizer->Fit (this);
86   m_pTopSizer->SetSizeHints (this);
87 }
88
89 DialogGetImageMinMax::~DialogGetImageMinMax (void)
90 {
91 #if 0
92   delete m_pTopSizer;
93   delete m_pTextCtrlMin;
94   delete m_pTextCtrlMax;
95   delete m_pButtonSizer;
96   delete m_pButtonOk;
97   delete m_pButtonCancel;
98 #endif
99 }
100
101 double
102 DialogGetImageMinMax::getMinimum (void)
103 {
104     wxString strCtrl = m_pTextCtrlMin->GetValue();
105     double dValue;
106     if (strCtrl.ToDouble (&dValue))
107         return dValue;
108     else
109         return (m_dDefaultMin);
110 }
111
112 double
113 DialogGetImageMinMax::getMaximum (void)
114 {
115     wxString strCtrl = m_pTextCtrlMax->GetValue();
116     double dValue;
117     if (strCtrl.ToDouble (&dValue))
118         return dValue;
119     else
120         return (m_dDefaultMax);
121 }
122