libyui  3.0.10
/usr/src/RPM/BUILD/libyui-3.0.10/src/YSimpleInputField.h
00001 /*
00002   Copyright (C) 2000-2012 Novell, Inc
00003   This library is free software; you can redistribute it and/or modify
00004   it under the terms of the GNU Lesser General Public License as
00005   published by the Free Software Foundation; either version 2.1 of the
00006   License, or (at your option) version 3.0 of the License. This library
00007   is distributed in the hope that it will be useful, but WITHOUT ANY
00008   WARRANTY; without even the implied warranty of MERCHANTABILITY or 
00009   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00010   License for more details. You should have received a copy of the GNU
00011   Lesser General Public License along with this library; if not, write
00012   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
00013   Floor, Boston, MA 02110-1301 USA
00014 */
00015 
00016 
00017 /*-/
00018 
00019   File:         YSimpleInputField.h
00020 
00021   Author:       Stefan Hundhammer <sh@suse.de>
00022 
00023 /-*/
00024 
00025 #ifndef YSimpleInputField_h
00026 #define YSimpleInputField_h
00027 
00028 #include "YWidget.h"
00029 
00030 class YSimpleInputFieldPrivate;
00031 
00032 
00033 /**
00034  * Abstract base class for simple input fields with a label above the field and
00035  * a text value.
00036  **/
00037 class YSimpleInputField : public YWidget
00038 {
00039 protected:
00040     /**
00041      * Constructor.
00042      **/
00043     YSimpleInputField( YWidget * parent, const std::string & label );
00044 
00045 public:
00046     /**
00047      * Destructor.
00048      **/
00049     virtual ~YSimpleInputField();
00050 
00051     /**
00052      * Get the current value (the text entered by the user or set from the
00053      * outside) of this input field.
00054      *
00055      * Derived classes are required to implement this.
00056      **/
00057     virtual std::string value() = 0;
00058 
00059     /**
00060      * Set the current value (the text entered by the user or set from the
00061      * outside) of this input field.
00062      *
00063      * Derived classes are required to implement this.
00064      **/
00065     virtual void setValue( const std::string & text ) = 0;
00066 
00067     /**
00068      * Get the label (the caption above the input field).
00069      **/
00070     std::string label() const;
00071 
00072     /**
00073      * Set the label (the caption above the input field).
00074      *
00075      * Derived classes are free to reimplement this, but they should call this
00076      * base class method at the end of the overloaded function.
00077      **/
00078     virtual void setLabel( const std::string & label );
00079 
00080     /**
00081      * Set a property.
00082      * Reimplemented from YWidget.
00083      *
00084      * This function may throw YUIPropertyExceptions.
00085      *
00086      * This function returns 'true' if the value was successfully set and
00087      * 'false' if that value requires special handling (not in error cases:
00088      * those are covered by exceptions).
00089      **/
00090     virtual bool setProperty( const std::string & propertyName,
00091                               const YPropertyValue & val );
00092 
00093     /**
00094      * Get a property.
00095      * Reimplemented from YWidget.
00096      *
00097      * This method may throw YUIPropertyExceptions.
00098      **/
00099     virtual YPropertyValue getProperty( const std::string & propertyName );
00100 
00101     /**
00102      * Return this class's property set.
00103      * This also initializes the property upon the first call.
00104      *
00105      * Reimplemented from YWidget.
00106      **/
00107     virtual const YPropertySet & propertySet();
00108 
00109     /**
00110      * Get the string of this widget that holds the keyboard shortcut.
00111      *
00112      * Reimplemented from YWidget.
00113      **/
00114     virtual std::string shortcutString() const { return label(); }
00115 
00116     /**
00117      * Set the string of this widget that holds the keyboard shortcut.
00118      *
00119      * Reimplemented from YWidget.
00120      **/
00121     virtual void setShortcutString( const std::string & str )
00122         { setLabel( str ); }
00123 
00124     /**
00125      * The name of the widget property that will return user input.
00126      * Inherited from YWidget.
00127      **/
00128     const char * userInputProperty() { return YUIProperty_Value; }
00129 
00130 
00131 private:
00132 
00133     ImplPtr<YSimpleInputFieldPrivate> priv;
00134 };
00135 
00136 
00137 #endif // YSimpleInputField_h
 All Classes Functions Variables Enumerations Friends