summaryrefslogtreecommitdiff
path: root/libopie2/opieui/otabwidget.h
Unidiff
Diffstat (limited to 'libopie2/opieui/otabwidget.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/otabwidget.h295
1 files changed, 295 insertions, 0 deletions
diff --git a/libopie2/opieui/otabwidget.h b/libopie2/opieui/otabwidget.h
new file mode 100644
index 0000000..51d1c6d
--- a/dev/null
+++ b/libopie2/opieui/otabwidget.h
@@ -0,0 +1,295 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
5 =.
6 .=l.
7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29
30*/
31
32#ifndef OTABWIDGET_H
33#define OTABWIDGET_H
34
35/* OPIE */
36#include <opie2/otabinfo.h>
37
38/* QT */
39#include <qwidget.h>
40#include <qlist.h>
41
42using namespace Opie;
43
44class QComboBox;
45class QPixmap;
46class QTabBar;
47class QWidgetStack;
48
49namespace Opie
50{
51
52class OTabBar;
53
54/**
55 * @class OTabWidget
56 * @brief The OTabWidget class provides a stack of widgets.
57 *
58 * OTabWidget is a derivation of TrollTech's QTabWidget which provides
59 * a stack of widgets. Widgets can be selected using either a tab bar or
60 * drop down list box.
61 *
62 * The normal way to use OTabWidget is to do the following in the
63 * constructor:
64 * - Create a OTabWidget.
65 * - Create a QWidget for each of the pages in the control, insert
66 * children into it, set up geometry management for it, and use addTab()
67 * to add the widget.
68 */
69class OTabWidget : public QWidget
70{
71 Q_OBJECT
72public:
73
74/**
75 * @enum TabStyle
76 * @brief Defines how the widget selection control is displayed.
77 *
78 * Valid values:
79 * - Global: use globally selected options (qpe.conf - TabStyle & TabPosition)
80 * - TextTab: Tabbed widget selection with text labels
81 * - IconTab: Tabbed widget selection with icon labels, text label for active widget
82 * (similar to Opie launcher)
83 * - TextList: Drop down list widget selection with text labels
84 * - IconList: Drop down list widget selection with icon & text labels
85 */
86 enum TabStyle { Global, TextTab, IconTab, TextList, IconList };
87
88/**
89 * @enum TabPosition
90 * @brief Defines where the widget selection control is drawn.
91 *
92 * Valid values:
93 * - Top: Widget selection control is drawn above widgets
94 * - Bottom: Widget selection control is drawn below widgets
95 */
96 enum TabPosition { Top, Bottom };
97
98/**
99 * @fn OTabWidget( QWidget *parent = 0, const char *name = 0, TabStyle s = Global, TabPosition p = Top )
100 * @brief Object constructor.
101 *
102 * @param parent Pointer to parent of this control.
103 * @param name Name of control.
104 * @param s Style of widget selection control.
105 * @param p Position of the widget selection control.
106 *
107 * Constructs a new OTabWidget control with parent and name. The style and position parameters
108 * determine how the widget selection control will be displayed.
109 */
110 // FIXME WFlags? -zecke
111 OTabWidget( QWidget * = 0, const char * = 0, TabStyle = Global, TabPosition = Top );
112
113/**
114 * @fn ~OTabWidget()
115 * @brief Object destructor.
116 */
117 ~OTabWidget();
118
119/**
120 * @fn addTab( QWidget *child, const QString &icon, const QString &label )
121 * @brief Add new widget to control.
122 *
123 * @param child Widget control.
124 * @param icon Path to icon.
125 * @param label Text label.
126 */
127 void addTab( QWidget *, const QString &, const QString & );
128
129/**
130 * @fn removePage( QWidget *widget )
131 * @brief Remove widget from control. Does not delete widget.
132 *
133 * @param widget Widget control to be removed.
134 */
135 /* ### Page vs. Tab.. yes the widget is a Page but then is addTab wrong -zecke */
136 void removePage( QWidget * );
137
138/**
139 * @fn changeTab( QWidget *widget, const QString &icon, const QString &label )
140 * @brief Change text and/or icon for existing tab
141 *
142 * @param child Widget control.
143 * @param icon Path to icon.
144 * @param label Text label.
145 */
146 void changeTab( QWidget *, const QString &, const QString & );
147
148/**
149 * @fn tabStyle()const
150 * @brief Returns current widget selection control style.
151 */
152 TabStyle tabStyle() const;
153
154/**
155 * @fn setTabStyle( TabStyle s )
156 * @brief Set the current widget selection control style.
157 *
158 * @param s New style to be used.
159 */
160 void setTabStyle( TabStyle );
161
162/**
163 * @fn tabPosition()const
164 * @brief Returns current widget selection control position.
165 */
166 TabPosition tabPosition() const;
167
168/**
169 * @fn setTabPosition( TabPosition p )
170 * @brief Set the current widget selection control position.
171 *
172 * @param p New position of widget selection control.
173 */
174 void setTabPosition( TabPosition );
175
176/**
177 * @fn setCurrentTab( QWidget *childwidget )
178 * @brief Selects and brings to top the desired widget by using widget pointer.
179 *
180 * @param childwidget Widget to select.
181 */
182 void setCurrentTab( QWidget * );
183
184/**
185 * @fn setCurrentTab( const QString &tabname )
186 * @brief Selects and brings to top the desired widget, by using label.
187 *
188 * @param tabname Text label for widget to select.
189 */
190 void setCurrentTab( const QString & );
191
192/**
193 * @fn setCurrentTab( int )
194 * @brief Selects and brings to top the desired widget, by using id.
195 *
196 * @param tab id for widget to select.
197 */
198 void setCurrentTab(int);
199
200/**
201 * @fn sizeHint()const
202 * @brief Reimplemented for internal purposes.
203 */
204 QSize sizeHint() const;
205
206/**
207 * @fn currentTab( )
208 * @brief returns current tab id.
209 */
210 // ### make const
211 int currentTab()/* const */;
212/**
213 * @brief returns the current page of the active tab
214 *
215 * @since 1.2
216 */
217 QWidget* currentWidget()const;
218
219protected:
220
221/**
222 * @fn resizeEvent( QResizeEvent * )
223 * @brief Reimplemented for internal purposes.
224 */
225 void resizeEvent( QResizeEvent * );
226
227private:
228 OTabInfoList tabs;
229 OTabInfo *currTab;
230
231 TabStyle tabBarStyle;
232 TabPosition tabBarPosition;
233
234 QWidgetStack *tabBarStack;
235 OTabBar *tabBar;
236 QComboBox *tabList;
237
238 QWidgetStack *widgetStack;
239 class Private;
240 Private* d;
241
242/**
243 * @fn loadSmooth( const QString &name )
244 * @brief Loads icon for widget.
245 *
246 * @param name Name of icon image file.
247 */
248 QPixmap loadSmooth( const QString & );
249
250/**
251 * @fn selectTab( OTabInfo *tab )
252 * @brief Internal function to select desired widget.
253 *
254 * @param tab Pointer to data for widget.
255 */
256 void selectTab( OTabInfo * );
257
258/**
259 * @fn setUpLayout()
260 * @brief Internal function to adjust layout.
261 */
262 void setUpLayout();
263
264
265signals:
266/**
267 * @fn currentChanegd( QWidget *widget )
268 * @brief This signal is emitted whenever the widget has changed.
269 *
270 * @param widget Pointer to new current widget.
271 */
272 void currentChanged( QWidget * );
273
274private slots:
275
276/**
277 * @fn slotTabBarSelected( int id )
278 * @brief Slot which is called when a tab is selected.
279 *
280 * @param id ID of widget selected.
281 */
282 void slotTabBarSelected( int );
283
284/**
285 * @fn slotTabListSelected( int index )
286 * @brief Slot which is called when a drop down selection is made.
287 *
288 * @param id Index of widget selected.
289 */
290 void slotTabListSelected( int );
291};
292
293};
294
295#endif