libyui  3.3.1
YDumbTab.h
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.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 #ifndef YDumbTab_h
26 #define YDumbTab_h
27 
28 #include "YSelectionWidget.h"
29 
30 class YDumbTabPrivate;
31 
32 /**
33  * DumbTab: A very simple tab widget that can display and switch between a
34  * number of tabs, but will only deliver the "user clicked on tab " event very
35  * much like a PushButton does. Actually exchanging the content of the tab is
36  * left to the application.
37  *
38  * DumbTab accepts a single child widget.
39  **/
40 class YDumbTab : public YSelectionWidget
41 {
42 protected:
43  /**
44  * Constructor.
45  **/
46  YDumbTab( YWidget * parent );
47 
48 public:
49  /**
50  * Destructor.
51  **/
52  virtual ~YDumbTab();
53 
54  /**
55  * Returns a descriptive name of this widget class for logging,
56  * debugging etc.
57  **/
58  virtual const char * widgetClass() const { return "YDumbTab"; }
59 
60  /**
61  * Add an item (a tab page).
62  *
63  * Reimplemented from YSelectionWidget.
64  *
65  * Derived classes can overwrite this function, but they should call this
66  * base class function in the new implementation.
67  **/
68  virtual void addItem( YItem * item );
69 
70  /**
71  * Notification that any shortcut of any item was changed by the shortcut
72  * conflict manager.
73  *
74  * Derived classes should reimplement this.
75  **/
76  virtual void shortcutChanged() {}
77 
78  /**
79  * Set a property.
80  * Reimplemented from YWidget.
81  *
82  * This method may throw exceptions, for example
83  * - if there is no property with that name
84  * - if the expected type and the type mismatch
85  * - if the value is out of range
86  *
87  * This function returns 'true' if the value was successfully set and
88  * 'false' if that value requires special handling (not in error cases:
89  * those are covered by exceptions).
90  **/
91  virtual bool setProperty( const std::string & propertyName,
92  const YPropertyValue & val );
93 
94  /**
95  * Get a property.
96  * Reimplemented from YWidget.
97  *
98  * This method may throw exceptions, for example
99  * - if there is no property with that name
100  **/
101  virtual YPropertyValue getProperty( const std::string & propertyName );
102 
103  /**
104  * Return this class's property set.
105  * This also initializes the property set upon the first call.
106  *
107  * Reimplemented from YWidget.
108  **/
109  virtual const YPropertySet & propertySet();
110 
111  /**
112  * Get the string of this widget that holds the keyboard shortcut.
113  * Notice that since YDumbTab has one shortcut for each tab page (for each
114  * item), this is not meaningful for this widget class.
115  *
116  * Check YItemShortcut in YShortcut.{cc,h} for more details.
117  *
118  * Reimplemented from YSelectionWidget.
119  **/
120  virtual std::string shortcutString() const { return ""; }
121 
122  /**
123  * Set the string of this widget that holds the keyboard shortcut.
124  * Since YDumbTab doesn't have a shortcut for the widget itself (only for
125  * the tab pages, i.e. the items), this will simply trigger a
126  * shortcutChanged() notification.
127  *
128  * Reimplemented from YSelectionWidget.
129  **/
130  virtual void setShortcutString( const std::string & str ) { shortcutChanged(); }
131 
132  /**
133  * Returns 'true' if this widget is stretchable in the specified dimension.
134  * In this case, the stretchability of the single child is returned.
135  *
136  * Reimplemented from YWidget.
137  **/
138  virtual bool stretchable( YUIDimension dim ) const;
139 
140  /**
141  * Descriptive label for debugging. Derived from this widget's only child
142  * (if there is one).
143  **/
144  virtual std::string debugLabel() const;
145 
146 private:
147 
148  // Disable unwanted base class methods
149  std::string label() const;
150  virtual void setLabel( const std::string & newLabel ) {};
151 
152 
154 };
155 
156 
157 #endif // YDumbTab_h
virtual ~YDumbTab()
Destructor.
Definition: YDumbTab.cc:59
DumbTab: A very simple tab widget that can display and switch between a number of tabs...
Definition: YDumbTab.h:40
Transport class for the value of simple properties.
Definition: YProperty.h:104
Base class for various kinds of multi-value widgets.
A set of properties to check names and types against.
Definition: YProperty.h:197
YWidget * parent() const
Return this widget&#39;s parent or 0 if it doesn&#39;t have a parent.
Definition: YWidget.cc:269
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
virtual void addItem(YItem *item)
Add an item (a tab page).
Definition: YDumbTab.cc:66
virtual std::string shortcutString() const
Get the string of this widget that holds the keyboard shortcut.
Definition: YDumbTab.h:120
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Definition: YDumbTab.cc:139
virtual void setShortcutString(const std::string &str)
Set the string of this widget that holds the keyboard shortcut.
Definition: YDumbTab.h:130
virtual bool stretchable(YUIDimension dim) const
Returns &#39;true&#39; if this widget is stretchable in the specified dimension.
Definition: YDumbTab.cc:73
Simple item class for SelectionBox, ComboBox, MultiSelectionBox etc.
Definition: YItem.h:49
virtual void shortcutChanged()
Notification that any shortcut of any item was changed by the shortcut conflict manager.
Definition: YDumbTab.h:76
YDumbTab(YWidget *parent)
Constructor.
Definition: YDumbTab.cc:45
Abstract base class of all UI widgets.
Definition: YWidget.h:54
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