libyui  3.0.10
 All Classes Functions Variables Enumerations Friends
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 }