libyui  3.3.2
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 }
YFrame(YWidget *parent, const std::string &label)
Constructor.
Definition: YFrame.cc:45
std::string label() const
Get the current frame label.
Definition: YFrame.cc:65
virtual ~YFrame()
Destructor.
Definition: YFrame.cc:53
bool isEmpty() const
Returns &#39;true&#39; if this property set does not contain anything.
Definition: YProperty.h:263
virtual void setLabel(const std::string &newLabel)
Change the frame label.
Definition: YFrame.cc:59
Transport class for the value of simple properties.
Definition: YProperty.h:104
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
Definition: YFrame.cc:91
void add(const YProperty &prop)
Add a property to this property set.
Definition: YProperty.cc:145
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
Definition: YWidget.cc:428
A set of properties to check names and types against.
Definition: YProperty.h:197
Helper class for shortcut management: This class holds data about the shortcut for one single widget...
Definition: YShortcut.h:40
Container widget class that manages one child.
virtual const YPropertySet & propertySet()
Return this class&#39;s property set.
Definition: YWidget.cc:393
std::string cleanShortcutString()
Returns the shortcut string ( from the widget&#39;s shortcut property ) without any "&" markers...
Definition: YShortcut.cc:91
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Definition: YWidget.cc:453
std::string stringVal() const
Methods to get the value of this property.
Definition: YProperty.h:180
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Definition: YFrame.cc:106
Class for widget properties.
Definition: YProperty.h:51
virtual const YPropertySet & propertySet()
Return this class&#39;s property set.
Definition: YFrame.cc:72
void check(const std::string &propertyName) const
Check if a property &#39;propertyName&#39; exists in this property set.
Definition: YProperty.cc:87
Abstract base class of all UI widgets.
Definition: YWidget.h:54
YPropertyType type() const
Returns the type of this property value.
Definition: YProperty.h:169