libyui  3.0.10
 All Classes Functions Variables Enumerations Friends
YFrame.cc
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YFrame.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #define YUILogComponent "ui"
27 #include "YUILog.h"
28 
29 #include "YUISymbols.h"
30 #include "YFrame.h"
31 #include "YShortcut.h"
32 
34 {
35  YFramePrivate( const std::string & frameLabel )
36  : label( frameLabel )
37  {}
38 
39  std::string label;
40 };
41 
42 
43 
44 
45 YFrame::YFrame( YWidget * parent, const std::string & label )
46  : YSingleChildContainerWidget( parent )
47  , priv( new YFramePrivate( YShortcut::cleanShortcutString( label ) ) )
48 {
49  YUI_CHECK_NEW( priv );
50 }
51 
52 
54 {
55  // NOP
56 }
57 
58 
59 void YFrame::setLabel( const std::string & newLabel )
60 {
61  priv->label = YShortcut::cleanShortcutString( newLabel );
62 }
63 
64 
65 std::string YFrame::label() const
66 {
67  return priv->label;
68 }
69 
70 
71 const YPropertySet &
73 {
74  static YPropertySet propSet;
75 
76  if ( propSet.isEmpty() )
77  {
78  /*
79  * @property std::string Label the text on the frame
80  */
81 
82  propSet.add( YProperty( YUIProperty_Label, YStringProperty ) );
83  propSet.add( YWidget::propertySet() );
84  }
85 
86  return propSet;
87 }
88 
89 
90 bool
91 YFrame::setProperty( const std::string & propertyName, const YPropertyValue & val )
92 {
93  propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
94 
95  if ( propertyName == YUIProperty_Label ) setLabel( val.stringVal() );
96  else
97  {
98  return YWidget::setProperty( propertyName, val );
99  }
100 
101  return true; // success -- no special processing necessary
102 }
103 
104 
106 YFrame::getProperty( const std::string & propertyName )
107 {
108  propertySet().check( propertyName ); // throws exceptions if not found
109 
110  if ( propertyName == YUIProperty_Label ) return YPropertyValue( label() );
111  else
112  {
113  return YWidget::getProperty( propertyName );
114  }
115 }