libyui
3.0.10
|
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: YCheckBox.cc 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 00026 #define YUILogComponent "ui" 00027 #include "YUILog.h" 00028 00029 #include "YUISymbols.h" 00030 #include "YCheckBox.h" 00031 00032 00033 struct YCheckBoxPrivate 00034 { 00035 YCheckBoxPrivate( const std::string & label ) 00036 : label( label ) 00037 , useBoldFont( false ) 00038 {} 00039 00040 std::string label; 00041 bool useBoldFont; 00042 }; 00043 00044 00045 YCheckBox::YCheckBox( YWidget * parent, const std::string & label ) 00046 : YWidget( parent ) 00047 , priv( new YCheckBoxPrivate( label ) ) 00048 { 00049 YUI_CHECK_NEW( priv ); 00050 } 00051 00052 00053 YCheckBox::~YCheckBox() 00054 { 00055 // NOP 00056 } 00057 00058 00059 void YCheckBox::setLabel( const std::string & newLabel ) 00060 { 00061 priv->label = newLabel; 00062 } 00063 00064 00065 std::string YCheckBox::label() const 00066 { 00067 return priv->label; 00068 } 00069 00070 00071 bool YCheckBox::useBoldFont() const 00072 { 00073 return priv->useBoldFont; 00074 } 00075 00076 00077 void YCheckBox::setUseBoldFont( bool bold ) 00078 { 00079 priv->useBoldFont = bold; 00080 } 00081 00082 00083 const YPropertySet & 00084 YCheckBox::propertySet() 00085 { 00086 static YPropertySet propSet; 00087 00088 if ( propSet.isEmpty() ) 00089 { 00090 /* 00091 * @property boolean Value the on/off state; nil for "don't care" (tristate) 00092 * @property std::string Label the text on the CheckBox 00093 */ 00094 00095 propSet.add( YProperty( YUIProperty_Value, YOtherProperty ) ); 00096 propSet.add( YProperty( YUIProperty_Label, YStringProperty ) ); 00097 propSet.add( YWidget::propertySet() ); 00098 } 00099 00100 return propSet; 00101 } 00102 00103 00104 bool 00105 YCheckBox::setProperty( const std::string & propertyName, const YPropertyValue & val ) 00106 { 00107 propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch 00108 00109 if ( propertyName == YUIProperty_Value ) return false; // need special processing 00110 else if ( propertyName == YUIProperty_Label ) setLabel( val.stringVal() ); 00111 else 00112 { 00113 return YWidget::setProperty( propertyName, val ); 00114 } 00115 00116 return true; // success -- no special processing necessary 00117 } 00118 00119 00120 YPropertyValue 00121 YCheckBox::getProperty( const std::string & propertyName ) 00122 { 00123 propertySet().check( propertyName ); // throws exceptions if not found 00124 00125 if ( propertyName == YUIProperty_Value ) return YPropertyValue( YOtherProperty ); 00126 else if ( propertyName == YUIProperty_Label ) return YPropertyValue( label() ); 00127 else 00128 { 00129 return YWidget::getProperty( propertyName ); 00130 } 00131 }