libyui  3.0.10
/usr/src/RPM/BUILD/libyui-3.0.10/src/YFrame.cc
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:         YFrame.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 "YFrame.h"
00031 #include "YShortcut.h"
00032 
00033 struct YFramePrivate
00034 {
00035     YFramePrivate( const std::string & frameLabel )
00036         : label( frameLabel )
00037         {}
00038 
00039     std::string label;
00040 };
00041 
00042 
00043 
00044 
00045 YFrame::YFrame( YWidget * parent, const std::string & label )
00046     : YSingleChildContainerWidget( parent )
00047     , priv( new YFramePrivate( YShortcut::cleanShortcutString( label ) ) )
00048 {
00049     YUI_CHECK_NEW( priv );
00050 }
00051 
00052 
00053 YFrame::~YFrame()
00054 {
00055     // NOP
00056 }
00057 
00058 
00059 void YFrame::setLabel( const std::string & newLabel )
00060 {
00061     priv->label = YShortcut::cleanShortcutString( newLabel );
00062 }
00063 
00064 
00065 std::string YFrame::label() const
00066 {
00067     return priv->label;
00068 }
00069 
00070 
00071 const YPropertySet &
00072 YFrame::propertySet()
00073 {
00074     static YPropertySet propSet;
00075 
00076     if ( propSet.isEmpty() )
00077     {
00078         /*
00079          * @property std::string        Label   the text on the frame
00080          */
00081 
00082         propSet.add( YProperty( YUIProperty_Label,      YStringProperty ) );
00083         propSet.add( YWidget::propertySet() );
00084     }
00085 
00086     return propSet;
00087 }
00088 
00089 
00090 bool
00091 YFrame::setProperty( const std::string & propertyName, const YPropertyValue & val )
00092 {
00093     propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
00094 
00095     if      ( propertyName == YUIProperty_Label )       setLabel( val.stringVal() );
00096     else
00097     {
00098         return YWidget::setProperty( propertyName, val );
00099     }
00100 
00101     return true; // success -- no special processing necessary
00102 }
00103 
00104 
00105 YPropertyValue
00106 YFrame::getProperty( const std::string & propertyName )
00107 {
00108     propertySet().check( propertyName ); // throws exceptions if not found
00109 
00110     if      ( propertyName == YUIProperty_Label )       return YPropertyValue( label() );
00111     else
00112     {
00113         return YWidget::getProperty( propertyName );
00114     }
00115 }
 All Classes Functions Variables Enumerations Friends