OpenWalnut  1.5.0dev
WUITabbedWidget.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WUITABBEDWIDGET_H
26 #define WUITABBEDWIDGET_H
27 
28 #include <memory>
29 #include <string>
30 
31 
32 #include "WUIWidgetBase.h"
33 
34 /**
35  * Widget which is a container for others. The child widgets can be arranged in tabs. The WUITabbedWidget itself is a widget, which means you can
36  * embed tabs in other container widgets (like grids).
37  *
38  * \note Please read documentation of \ref WUIWidgetFactory for limitations, requirements and creation of these widgets.
39  */
41 {
42 public:
43  /**
44  * Convenience typedef for a std::shared_ptr< WUITabbedWidget >.
45  */
46  typedef std::shared_ptr< WUITabbedWidget > SPtr;
47 
48  /**
49  * Convenience typedef for a std::shared_ptr< const WUITabbedWidget >.
50  */
51  typedef std::shared_ptr< const WUITabbedWidget > ConstSPtr;
52 
53  /**
54  * Destructor.
55  */
56  virtual ~WUITabbedWidget();
57 
58  /**
59  * Tell the user whether this kind of widget can be used as parent. In other word, whether it is allowed to nest other widgets into this one.
60  *
61  * \return true if nesting other widgets INTO this one is allowed
62  */
63  virtual bool allowNesting() const;
64 
65  /**
66  * Set label of the tab with given index. If the tab does not exist, nothing happens.
67  *
68  * \param index the index of the tab
69  * \param label the label of the tab
70  */
71  virtual void setTabText( int index, const std::string& label ) = 0;
72 
73  /**
74  * Set the given tab active. If it not exists, the current tab stays active.
75  *
76  * \param index the index of the tab
77  */
78  virtual void setActiveTab( int index ) = 0;
79 
80  /**
81  * Get the index of the currently active tab.
82  *
83  * \return the index, or -1 if error
84  */
85  virtual int getActiveTab() const = 0;
86 
87  /**
88  * Query the number of tabs.
89  *
90  * \return the number of tabs, or -1 if error.
91  */
92  virtual int getNumTabs() const = 0;
93 
94  /**
95  * Write some tool tip for a given tab. If the index is invalid, nothing happens.
96  *
97  * \param index the tab index
98  * \param tip the tooltip text
99  */
100  virtual void setTabToolTip( int index, const std::string& tip ) = 0;
101 
102  /**
103  * Allows en/disabling a tab. If the index is invalid, nothing happens.
104  *
105  * \param index the index.
106  * \param enable true to enable
107  */
108  virtual void setTabEnabled( int index, bool enable ) = 0;
109 
110  /**
111  * Tab positions.
112  */
114  {
115  North = 0, //!< The tabs are drawn above the pages.
116  South, //!< The tabs are drawn below the pages.
117  West, //!< The tabs are drawn to the left of the pages.
118  East //!< The tabs are drawn to the right of the pages.
119  };
120 
121  /**
122  * Specify where to place the tabs
123  *
124  * \param position the position
125  */
126  virtual void setTabPosition( TabPosition position ) = 0;
127 
128  /**
129  * Place the given widget in this tab widget in a new tab with a given label. The widget to be placed must be created with this tab widget as parent or an
130  * exception will be thrown.
131  *
132  * \param widget the widget
133  * \param label the label of the tab
134  *
135  * \return the index of the new tab, or -1 if error.
136  */
137  virtual int addTab( WUIWidgetBase::SPtr widget, const std::string& label );
138 protected:
139  /**
140  * Default constructor. Create an empty grid widget.
141  *
142  * \param title the widget title
143  */
144  explicit WUITabbedWidget( std::string title );
145 
146  /**
147  * Place the given widget in this tab widget in a new tab with a given label. The widget to be placed must be created with this tab widget as parent or an
148  * exception will be thrown.
149  *
150  * \param widget the widget
151  * \param label the label of the tab
152  *
153  * \return the index of the new tab
154  */
155  virtual int addTabImpl( WUIWidgetBase::SPtr widget, std::string label ) = 0;
156 private:
157 };
158 
159 #endif // WUITABBEDWIDGET_H
160 
Widget which is a container for others.
WUITabbedWidget(std::string title)
Default constructor.
virtual void setTabText(int index, const std::string &label)=0
Set label of the tab with given index.
virtual void setTabToolTip(int index, const std::string &tip)=0
Write some tool tip for a given tab.
virtual bool allowNesting() const
Tell the user whether this kind of widget can be used as parent.
TabPosition
Tab positions.
@ West
The tabs are drawn to the left of the pages.
@ East
The tabs are drawn to the right of the pages.
@ South
The tabs are drawn below the pages.
@ North
The tabs are drawn above the pages.
virtual int getNumTabs() const =0
Query the number of tabs.
virtual int addTab(WUIWidgetBase::SPtr widget, const std::string &label)
Place the given widget in this tab widget in a new tab with a given label.
std::shared_ptr< WUITabbedWidget > SPtr
Convenience typedef for a std::shared_ptr< WUITabbedWidget >.
virtual void setTabEnabled(int index, bool enable)=0
Allows en/disabling a tab.
virtual int addTabImpl(WUIWidgetBase::SPtr widget, std::string label)=0
Place the given widget in this tab widget in a new tab with a given label.
virtual int getActiveTab() const =0
Get the index of the currently active tab.
virtual void setTabPosition(TabPosition position)=0
Specify where to place the tabs.
virtual ~WUITabbedWidget()
Destructor.
virtual void setActiveTab(int index)=0
Set the given tab active.
std::shared_ptr< const WUITabbedWidget > ConstSPtr
Convenience typedef for a std::shared_ptr< const WUITabbedWidget >.
Base class for all the widget abstraction the core UI provides.
Definition: WUIWidgetBase.h:45
std::shared_ptr< WUIWidgetBase > SPtr
Convenience typedef for a std::shared_ptr< WUIWidgetBase >.
Definition: WUIWidgetBase.h:51