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