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