libyui  3.0.10
/usr/src/RPM/BUILD/libyui-3.0.10/src/YCheckBoxFrame.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:         YCheckBoxFrame.h
00020 
00021   Author:       Stefan Hundhammer <sh@suse.de>
00022 
00023 /-*/
00024 
00025 #ifndef YCheckBoxFrame_h
00026 #define YCheckBoxFrame_h
00027 
00028 #include <string>
00029 #include "YSingleChildContainerWidget.h"
00030 #include "ImplPtr.h"
00031 
00032 class YCheckBoxFramePrivate;
00033 
00034 
00035 class YCheckBoxFrame : public YSingleChildContainerWidget
00036 {
00037 public:
00038     /**
00039      * Constructor.
00040      **/
00041     YCheckBoxFrame( YWidget *           parent,
00042                     const std::string & label,
00043                     bool                checked );
00044 
00045     /**
00046      * Destructor.
00047      **/
00048     virtual ~YCheckBoxFrame();
00049 
00050     /**
00051      * Returns a descriptive name of this widget class for logging,
00052      * debugging etc.
00053      **/
00054     virtual const char * widgetClass() const { return "YCheckBoxFrame"; }
00055 
00056     /**
00057      * Return the label text on the CheckBoxFrame.
00058      **/
00059     std::string label() const;
00060 
00061     /**
00062      * Change the label text on the CheckBoxFrame.
00063      *
00064      * Derived classes should overload this, but call this base class function
00065      * in the overloaded function.
00066      **/
00067     virtual void setLabel( const std::string & label );
00068 
00069     /**
00070      * Check or uncheck the CheckBoxFrame's check box.
00071      *
00072      * Derived classes are required to implement this.
00073      **/
00074     virtual void setValue( bool isChecked ) = 0;
00075 
00076     /**
00077      * Get the status of the CheckBoxFrame's check box.
00078      *
00079      * Derived classes are required to implement this.
00080      **/
00081     virtual bool value() = 0;
00082 
00083     /**
00084      * Handle children enabling/disabling automatically based on the
00085      * CheckBoxFrame's check box?
00086      **/
00087     bool autoEnable() const;
00088 
00089     /**
00090      * Change autoEnabled flag.
00091      *
00092      * Derived classes are free to overload this, but they should call this
00093      * base class function in the overloaded function.
00094      **/
00095     virtual void setAutoEnable( bool autoEnable );
00096 
00097     /**
00098      * Invert the meaning of the CheckBoxFrame's check box, i.e., disable child
00099      * widgets when checked?
00100      **/
00101     bool invertAutoEnable() const;
00102 
00103     /**
00104      * Change invertAutonEnable flag.
00105      *
00106      * Derived classes are free to overload this, but they should call this
00107      * base class function in the overloaded function.
00108      **/
00109     virtual void setInvertAutoEnable( bool invertAutoEnable );
00110 
00111     /**
00112      * Handle enabling/disabling of child widgets based on 'isChecked' (the
00113      * current status of the check box) and autoEnable() and
00114      * invertAutoEnable().
00115      *
00116      * Derived classes should call this when the check box status changes
00117      * rather than try to handle it on their level.
00118      *
00119      * This method also needs to be called after new child widgets are added to
00120      * establish the initial enabled or disabled state of the child widgets.
00121      **/
00122     void handleChildrenEnablement( bool isChecked );
00123 
00124     /**
00125      * Get the string of this widget that holds the keyboard shortcut.
00126      *
00127      * Reimplemented from YWidget.
00128      **/
00129     virtual std::string shortcutString() const { return label(); }
00130 
00131     /**
00132      * Set the string of this widget that holds the keyboard shortcut.
00133      *
00134      * Reimplemented from YWidget.
00135      **/
00136     virtual void setShortcutString( const std::string & str )
00137         { setLabel( str ); }
00138 
00139     /**
00140      * The name of the widget property that will return user input.
00141      * Inherited from YWidget.
00142      **/
00143     const char * userInputProperty() { return YUIProperty_Value; }
00144 
00145     /**
00146      * Set a property.
00147      * Reimplemented from YWidget.
00148      *
00149      * This method may throw exceptions, for example
00150      *   - if there is no property with that name
00151      *   - if the expected type and the type mismatch
00152      *   - if the value is out of range
00153      *
00154      * This function returns 'true' if the value was successfully set and
00155      * 'false' if that value requires special handling (not in error cases:
00156      * those are covered by exceptions).
00157      **/
00158     virtual bool setProperty( const std::string & propertyName,
00159                               const YPropertyValue & val );
00160 
00161     /**
00162      * Get a property.
00163      * Reimplemented from YWidget.
00164      *
00165      * This method may throw exceptions, for example
00166      *   - if there is no property with that name
00167      **/
00168     virtual YPropertyValue getProperty( const std::string & propertyName );
00169 
00170     /**
00171      * Return this class's property set.
00172      * This also initializes the property set upon the first call.
00173      *
00174      * Reimplemented from YWidget.
00175      **/
00176     virtual const YPropertySet & propertySet();
00177 
00178 private:
00179 
00180     ImplPtr<YCheckBoxFramePrivate> priv;
00181 };
00182 
00183 
00184 #endif // YCheckBoxFrame_h
 All Classes Functions Variables Enumerations Friends