1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
/* This file is part of the KDE project
Copyright (C) 2003 Ariya Hidayat <ariya@kde.org>
Copyright (C) 2003 Norbert Andres <nandres@web.de>
Copyright (C) 2002 Laurent Montel <montel@kde.org>
Copyright (C) 1999 David Faure <faure@kde.org>
Copyright (C) 1999 Boris Wedl <boris.wedl@kfunigraz.ac.at>
Copyright (C) 1998-2000 Torben Weis <weis@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef kotabbar_h
#define kotabbar_h
#include <tqwidget.h>
#include <tqstringlist.h>
#include <koffice_export.h>
class KoTabBarPrivate;
/**
* The KoTabBar class provides a tab bar, for use to switch active
* page/sheet in a document.
*
* The tab bar is typically used in the main view.
* It is the small widget on the bottom left corner.
* Pages/sheets are displayed as tabs, clicking on
* one of the tab will activate the corresponding sheet (this is actually
* done in main view). Current active page/sheet is marked by bold text.
*
* The tab bar supports page/sheet reorder by dragging a certain tab
* and move it to another location. The main view should handle the necessary
* action to perform the actual reorder.
*
* There are four scroll buttons available in the tab bar. They are used
* to shift the tabs in left and right direction, for example when there
* are more tabs than the space available to display all tabs.
*
* Since a page/sheet can be hidden, the tab bar only shows the visible page/sheet.
* When a hidden page or sheet is shown again, it will be on the same position as
* before it was hidden.
*
* When the document is protected, it is necessary to set the tab bar as
* read-only using setReadOnly (see also readOnly). If it is set to true,
* tabs can not be moved by dragging and context menu will not be displayed.
*
* @short A bar with tabs and scroll buttons.
*/
class KOFFICEUI_EXPORT KoTabBar : public TQWidget
{
Q_OBJECT
TQ_PROPERTY( TQString activeTab READ activeTab WRITE setActiveTab )
TQ_PROPERTY( bool readOnly READ readOnly WRITE setReadOnly )
TQ_PROPERTY( TQStringList tabs READ tabs WRITE setTabs )
TQ_PROPERTY( unsigned count READ count )
public:
/**
* Creates a new tabbar.
*/
KoTabBar( TQWidget* parent = 0, const char *name = 0 );
/**
* Destroy the tabbar.
*/
virtual ~KoTabBar();
/**
* Returns true if the tab bar is read only.
*/
bool readOnly() const;
/**
* Returns true if tabs and scroll buttons will be laid out in a mirrored
* (right to left) fashion.
*/
bool reverseLayout() const;
/**
* Returns all the tab as list of strings.
*/
TQStringList tabs() const;
/**
* Returns number of tabs.
* This is the same as KoTabBar::tabs().count()
*/
unsigned count() const;
/**
* Returns the active tab.
*/
TQString activeTab() const;
/**
* Returns true if it is possible to scroll one tab back.
*
* \sa scrollBack
*/
bool canScrollBack() const;
/**
* Returns true if it is possible to scroll one tab forward.
*
* \sa scrollForward
*/
bool canScrollForward() const;
/**
* Ensures that specified tab is visible.
*/
void ensureVisible( const TQString& tab );
public slots:
/**
* Replaces all tabs with the list of strings.
*/
void setTabs( const TQStringList& list );
/**
* Sets the tab bar to be read only.
*
* If the tab bar is read only, tab reordering is not allowed.
* This means that signal tabMoved, contextMenu and doubleClicked
* would not be emitted.
*/
void setReadOnly( bool ro );
/**
* If reverse is true, dialogs and scroll buttonswidgets will be laid out in a mirrored
* as if the sheet is in right to left languages (such as Arabic and Hebrew)
*/
void setReverseLayout( bool reverse );
/**
* Adds a tab to the tab bar.
*/
void addTab( const TQString& text );
/**
* Removes a tab from the bar. If the tab was the active one then
* no tab will be active.
* It is recommended to call setActiveTab after a call to this function.
*/
void removeTab( const TQString& text );
/**
* Renames a tab.
*/
void renameTab( const TQString& old_name, const TQString& new_name );
/**
* Moves a tab to another position and reorder other tabs.
*
* Example 1: if there are four tabs A - B - C - D, then
* moveTab(2,1) will yield A - C - B - D. This is because
* 2nd tab (i.e C) is moved to a position before 1th tab (i.e B).
*
* Example 2: for these tabs: X - Y - Z, moveTab(0,3) will
* move tab X after tab Z so that the result is Y - Z - X.
*/
void moveTab( unsigned tab, unsigned target );
/**
* Scrolls one tab back. Does nothing if the leftmost tab (rightmost tab
* when reverseLayout is true) is already the first tab.
*
* \sa canScrollBack
*/
void scrollBack();
/**
* Scrolls one tab forward. Does nothing if the rightmost tab (leftmost tab
* when reverseLayout is true) is already the last tab.
*
* \sa canScrollForward
*/
void scrollForward();
/**
* Scrolls to the first tab. Does nothing if the leftmost tab (rightmost tab
* when reverseLayout is true) is already the first tab.
*
* \sa canScrollBack
*/
void scrollFirst();
/**
* Scrolls to the last tab. Does nothing if the rightmost tab (leftmost tab
* when reverseLayout is true) is already the last tab.
*
* \sa canScrollForward
*/
void scrollLast();
/**
* Sets active tab.
*/
void setActiveTab( const TQString& text );
/**
* Removes all tabs.
*/
void clear();
TQSize sizeHint() const;
signals:
/**
* Emitted if the active tab changed.
*/
void tabChanged( const TQString& _text );
/**
* This signal is emitted whenever a tab is dragged, moved and
* released. This means that the user wants to move a tab into
* another position (right before target).
*
* When the signal is emitted, the tabs are not reordered.
* Therefore if you just ignore this signal, than no tab reorder
* is possible. Call moveTab (from the slot connected to this signal)
* to perform the actual tab reorder.
*/
void tabMoved( unsigned tab, unsigned target );
/**
* This signal is emitted whenever the tab bar is right-clicked.
* Typically it is used to popup a context menu.
*/
void contextMenu( const TQPoint& pos );
/**
* This signal is emitted whenever the tab bar is double-clicked.
*/
void doubleClicked();
protected slots:
void autoScrollBack();
void autoScrollForward();
protected:
virtual void paintEvent ( TQPaintEvent* ev );
virtual void resizeEvent( TQResizeEvent* ev );
virtual void mousePressEvent ( TQMouseEvent* ev );
virtual void mouseReleaseEvent ( TQMouseEvent* ev );
virtual void mouseDoubleClickEvent ( TQMouseEvent* ev );
virtual void mouseMoveEvent ( TQMouseEvent* ev );
virtual void wheelEvent ( TQWheelEvent * e );
private:
KoTabBarPrivate *d;
// don't allow copy or assignment
KoTabBar( const KoTabBar& );
KoTabBar& operator=( const KoTabBar& );
};
#endif // kotabbar_h
|