libyui  3.10.0
YDumbTab.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: YDumbTab.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 "YDumbTab.h"
31 #include "YShortcut.h"
32 
33 using std::string;
34 
35 
37 {
39  {}
40 
41  bool dummy;
42 };
43 
44 
45 
46 
48  : YSelectionWidget( parent,
49  "", // label
50  true ) // enforceSingleSelection
51  , priv( new YDumbTabPrivate )
52 {
53  YUI_CHECK_NEW( priv );
55 
56  setDefaultStretchable( YD_HORIZ, true );
57  setDefaultStretchable( YD_VERT, true );
58 }
59 
60 
62 {
63  // NOP
64 }
65 
66 
67 void
69 {
71 }
72 
73 
74 bool
75 YDumbTab::stretchable( YUIDimension dim ) const
76 {
77  if ( hasChildren() )
78  return firstChild()->stretchable( dim );
79  else
80  return YWidget::stretchable( dim );
81 }
82 
83 
84 string
86 {
87  string str = widgetClass();
88 
89  for ( YItemConstIterator it = itemsBegin();
90  it != itemsEnd();
91  ++it )
92  {
93  str += " [" + (*it)->label() + "]";
94  }
95 
96  return str;
97 }
98 
99 
100 
101 const YPropertySet &
103 {
104  static YPropertySet propSet;
105 
106  if ( propSet.isEmpty() )
107  {
108  /*
109  * @property itemID Value The currently selected item (tab page)
110  * @property itemID CurrentItem The currently selected item (tab page)
111  * @property itemList Items All items (all tab pages)
112  */
113  propSet.add( YProperty( YUIProperty_Value, YOtherProperty ) );
114  propSet.add( YProperty( YUIProperty_CurrentItem, YOtherProperty ) );
115  propSet.add( YProperty( YUIProperty_Items, YOtherProperty ) );
116  propSet.add( YWidget::propertySet() );
117  }
118 
119  return propSet;
120 }
121 
122 
123 bool
124 YDumbTab::setProperty( const string & propertyName, const YPropertyValue & val )
125 {
126  propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
127 
128  if ( propertyName == YUIProperty_Value ) return false; // Needs special handling
129  else if ( propertyName == YUIProperty_CurrentItem ) return false; // Needs special handling
130  else if ( propertyName == YUIProperty_Items ) return false; // Needs special handling
131  else
132  {
133  return YWidget::setProperty( propertyName, val );
134  }
135 
136  return true; // success -- no special processing necessary
137 }
138 
139 
141 YDumbTab::getProperty( const string & propertyName )
142 {
143  propertySet().check( propertyName ); // throws exceptions if not found
144 
145  if ( propertyName == YUIProperty_Value ) return YPropertyValue( YOtherProperty );
146  else if ( propertyName == YUIProperty_CurrentItem ) return YPropertyValue( YOtherProperty );
147  else if ( propertyName == YUIProperty_Items ) return YPropertyValue( YOtherProperty );
148  else
149  {
150  return YWidget::getProperty( propertyName );
151  }
152 }
YDumbTab::addItem
virtual void addItem(YItem *item)
Add an item (a tab page).
Definition: YDumbTab.cc:68
YPropertySet::add
void add(const YProperty &prop)
Add a property to this property set.
Definition: YProperty.cc:146
YWidget
Abstract base class of all UI widgets.
Definition: YWidget.h:55
YSelectionWidget
Base class for various kinds of multi-value widgets.
Definition: YSelectionWidget.h:43
YDumbTabPrivate
Definition: YDumbTab.cc:37
YWidget::setChildrenManager
void setChildrenManager(YWidgetChildrenManager *manager)
Sets a new children manager for this widget.
Definition: YWidget.cc:166
YPropertySet
A set of properties to check names and types against.
Definition: YProperty.h:198
YDumbTab::widgetClass
virtual const char * widgetClass() const
Returns a descriptive name of this widget class for logging, debugging etc.
Definition: YDumbTab.h:58
YDumbTab::propertySet
virtual const YPropertySet & propertySet()
Return this class's property set.
Definition: YDumbTab.cc:102
YPropertySet::isEmpty
bool isEmpty() const
Returns 'true' if this property set does not contain anything.
Definition: YProperty.h:263
YSelectionWidget::itemsEnd
YItemIterator itemsEnd()
Return an iterator that points behind the last item.
Definition: YSelectionWidget.cc:296
YDumbTab::~YDumbTab
virtual ~YDumbTab()
Destructor.
Definition: YDumbTab.cc:61
YWidget::firstChild
YWidget * firstChild() const
Returns the first child or 0 if there is none.
Definition: YWidget.h:199
YPropertyValue::type
YPropertyType type() const
Returns the type of this property value.
Definition: YProperty.h:169
YWidget::getProperty
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Definition: YWidget.cc:457
YProperty
Class for widget properties.
Definition: YProperty.h:52
YDumbTab::YDumbTab
YDumbTab(YWidget *parent)
Constructor.
Definition: YDumbTab.cc:47
YSelectionWidget::itemsBegin
YItemIterator itemsBegin()
Return an iterator that points to the first item.
Definition: YSelectionWidget.cc:283
YDumbTab::debugLabel
virtual std::string debugLabel() const
Descriptive label for debugging.
Definition: YDumbTab.cc:85
YSingleChildManager
Children manager that can handle one single child (rejecting any more).
Definition: YChildrenManager.h:174
YPropertySet::check
void check(const std::string &propertyName) const
Check if a property 'propertyName' exists in this property set.
Definition: YProperty.cc:88
YPropertyValue
Transport class for the value of simple properties.
Definition: YProperty.h:105
YWidget::setDefaultStretchable
void setDefaultStretchable(YUIDimension dim, bool newStretch)
Set the stretchable state to "newStretch".
Definition: YWidget.cc:566
YWidget::hasChildren
bool hasChildren() const
Returns 'true' if this widget has any children.
Definition: YWidget.h:192
YSelectionWidget::addItem
virtual void addItem(YItem *item_disown)
Add one item.
Definition: YSelectionWidget.cc:186
YDumbTab::setProperty
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
Definition: YDumbTab.cc:124
YDumbTab::getProperty
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Definition: YDumbTab.cc:141
YWidget::stretchable
virtual bool stretchable(YUIDimension dim) const
This is a boolean value that determines whether the widget is resizable beyond its preferred size in ...
Definition: YWidget.cc:572
YWidget::setProperty
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
Definition: YWidget.cc:432
YItemConstIterator
YItemCollection::const_iterator YItemConstIterator
Const iterator over YItemCollection.
Definition: YItem.h:42
YItem
Simple item class for SelectionBox, ComboBox, MultiSelectionBox etc.
Definition: YItem.h:50
YDumbTab::stretchable
virtual bool stretchable(YUIDimension dim) const
Returns 'true' if this widget is stretchable in the specified dimension.
Definition: YDumbTab.cc:75
YWidget::propertySet
virtual const YPropertySet & propertySet()
Return this class's property set.
Definition: YWidget.cc:395