libyui

/data/gitorious.org/libyui/libyui-master/src/YCheckBox.h

00001 /**************************************************************************
00002 Copyright (C) 2000 - 2010 Novell, Inc.
00003 All Rights Reserved.
00004 
00005 This program is free software; you can redistribute it and/or modify
00006 it under the terms of the GNU General Public License as published by
00007 the Free Software Foundation; either version 2 of the License, or
00008 (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License along
00016 with this program; if not, write to the Free Software Foundation, Inc.,
00017 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018 
00019 **************************************************************************/
00020 
00021 
00022 /*---------------------------------------------------------------------\
00023 |                                                                      |
00024 |                      __   __    ____ _____ ____                      |
00025 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00026 |                       \ V / _` \___ \ | |   __) |                    |
00027 |                        | | (_| |___) || |  / __/                     |
00028 |                        |_|\__,_|____/ |_| |_____|                    |
00029 |                                                                      |
00030 |                               core system                            |
00031 |                                                        (C) SuSE GmbH |
00032 \----------------------------------------------------------------------/
00033 
00034   File:         YCheckBox.h
00035 
00036   Author:       Stefan Hundhammer <sh@suse.de>
00037 
00038 /-*/
00039 
00040 #ifndef YCheckBox_h
00041 #define YCheckBox_h
00042 
00043 #include <string>
00044 
00045 #include "YWidget.h"
00046 #include "ImplPtr.h"
00047 
00048 using std::string;
00049 class YCheckBoxPrivate;
00050 
00051 enum YCheckBoxState
00052 {
00053     YCheckBox_dont_care = -1,   // tristate
00054     YCheckBox_off       = 0,
00055     YCheckBox_on        = 1
00056 };
00057 
00058 
00059 class YCheckBox : public YWidget
00060 {
00061 protected:
00065     YCheckBox( YWidget * parent, const string & label );
00066     
00067 public:
00071     virtual ~YCheckBox();
00072 
00077     virtual const char * widgetClass() const { return "YCheckBox"; }
00078 
00079 
00102     virtual YCheckBoxState value() = 0;
00103 
00109     virtual void setValue( YCheckBoxState state ) = 0;
00110 
00114     bool isChecked() { return value() == YCheckBox_on; }
00115 
00119     void setChecked( bool checked = true )
00120         { setValue( checked ? YCheckBox_on : YCheckBox_off ); }
00121 
00125     bool dontCare() { return value() == YCheckBox_dont_care; }
00126     
00130     void setDontCare() { setValue( YCheckBox_dont_care ); }
00131     
00135     string label() const;
00136 
00143     virtual void setLabel( const string & label );
00144 
00148     bool useBoldFont() const;
00149 
00156     virtual void setUseBoldFont( bool bold = true );
00157 
00171     virtual bool setProperty( const string & propertyName,
00172                               const YPropertyValue & val );
00173 
00181     virtual YPropertyValue getProperty( const string & propertyName );
00182 
00189     virtual const YPropertySet & propertySet();
00190 
00196     virtual string shortcutString() const { return label(); }
00197 
00203     virtual void setShortcutString( const string & str )
00204         { setLabel( str ); }
00205 
00210     const char * userInputProperty() { return YUIProperty_Value; }
00211 
00212 
00213 private:
00214 
00215     ImplPtr<YCheckBoxPrivate> priv;
00216 };
00217 
00218 
00219 #endif // YCheckBox_h
 All Classes Functions Variables Enumerations Friends