casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
DParameterButton.h
Go to the documentation of this file.
00001 //# DParameterButton.h: class to package interface to button autoguis.
00002 //# Copyright (C) 2000,2002
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
00027 
00028 #ifndef TRIALDISPLAY_DPARAMETERBUTTON_H
00029 #define TRIALDISPLAY_DPARAMETERBUTTON_H
00030 
00031 #include <casa/aips.h>
00032 #include <display/Display/DisplayParameter.h>
00033 
00034 namespace casa { //# NAMESPACE CASA - BEGIN
00035 
00036 // <summary>
00037 // Implementation of DisplayParameter to package interface to button autoguis.
00038 // </summary>
00039 
00040 // <use visibility=export>
00041 
00042 // <reviewed reviewer="" date="" test="" demos="">
00043 // </reviewed>
00044 
00045 // <prerequisite>
00046 // <li> <linkto class=DisplayParameter>DisplayParameter</linkto>
00047 // </prerequisite>
00048 
00049 // <etymology>
00050 // DParameterButton is an implementation of a DisplayParameter for Buttons.
00051 // It defines the necessary information to define a button in autogui.g,
00052 // and packages it into the parameter record field autogui requires.
00053 //
00054 // </etymology>
00055 
00056 // <synopsis>
00057 // This class is derived from <linkto
00058 // class=DisplayParameter>DisplayParameter</linkto>
00059 // It holds the meta-information neccessary to define a button widget,
00060 // packaging it into the 'parameter record' field required by autogui.g.
00061 // It can determine whether the button was pressed.
00062 // The 'value' has no meaning here (it will be True).
00063 // </synopsis>
00064 
00065 // <example>
00066 
00067 // <srcblock>
00068 // DParameterButton pbtn("unique_btn_id", "Label Beside Button",
00069 //                       "Text on Button", "Help Message for Button");
00070 //
00071 // Record rec;                  // (usually within 'getoptions()')
00072 // pstring.toRecord(rec);       // rec is returned to autogui.g
00073 //                              // to define the button.
00074 //
00075 // // ...when inRec is received recording user gui updates
00076 // // (usually within 'setOptions()'):
00077 // 
00078 // if(pbtn.fromRecord(inRec)) /* button was pressed; respond */ ;
00079 //
00080 // </srcblock>
00081 // </example>
00082 
00083 // <motivation>
00084 // Allows buttons to be defined using the same compact DParameter
00085 // interface used for other autogui widgets.
00086 // </motivation>
00087 
00088 // <thrown>
00089 // <li> None.
00090 // </thrown>
00091 
00092 class DParameterButton : public DisplayParameter {
00093 
00094  public:
00095 
00096   // Constructor taking the name (id) of the button, a label which will
00097   // appear beside the button, and the text which will appear on the button.
00098   // Optionally, popup help text, 'context' string, and a flag indicating
00099   // whether the button is enabled (disable is not fully supported yet).
00100   // The context string determines which autogui rollup the button will
00101   // appear in (replace spaces with underscores in this string).
00102   DParameterButton(const String name, const String description,
00103                    const String text, const String help="",
00104                    const String context="", const Bool editable=True);
00105 
00106   // copy constructor.
00107   DParameterButton(const DParameterButton &other);
00108 
00109   // Destructor.
00110   virtual ~DParameterButton();
00111 
00112   // copy assignment.
00113   DParameterButton &operator=(const DParameterButton &other);
00114 
00115   // Determine whether the record (passed originally from autogui.g)
00116   // indicates that the button was pressed.
00117   virtual Bool fromRecord(const RecordInterface &record);
00118 
00119   // Place a record describing this button in a sub-field of
00120   // <src>record</src> with name matching that of this parameter.  If
00121   // <src>overwrite</src> is <src>True</src>, then any existing field
00122   // with matching name will be overwritten.  If <src>fullrecord</src>
00123   // is <src>True</src>, then a complete description of the parameter
00124   // is given, otherwise just its current value is stored in
00125   // <src>record</src>.  (At present, <src>fullrecord</src> is ignored;
00126   // the full record is always returned).
00127   virtual void toRecord(RecordInterface &record, const Bool fullrecord = True,
00128                         const Bool overwrite = False);
00129 
00130  private:
00131 
00132   // default constructor disabled--do not use.
00133   DParameterButton() : DisplayParameter(), itsText("") {  }
00134 
00135   // Store for the text on the button.
00136   String itsText;
00137 
00138 };
00139 
00140 
00141 } //# NAMESPACE CASA - END
00142 
00143 #endif