1 /****************************************************************************
2 ** $Id: qt/qtabbar.h   3.3.8   edited Jan 11 14:39 $
3 **
4 ** Definition of QTab and QTabBar classes
5 **
6 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
7 **
8 ** This file is part of the widgets module of the Qt GUI Toolkit.
9 **
10 ** This file may be distributed under the terms of the Q Public License
11 ** as defined by Trolltech ASA of Norway and appearing in the file
12 ** LICENSE.QPL included in the packaging of this file.
13 **
14 ** This file may be distributed and/or modified under the terms of the
15 ** GNU General Public License version 2 as published by the Free Software
16 ** Foundation and appearing in the file LICENSE.GPL included in the
17 ** packaging of this file.
18 **
19 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
20 ** licenses may use this file in accordance with the Qt Commercial License
21 ** Agreement provided with the Software.
22 **
23 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25 **
26 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27 **   information about Qt Commercial License Agreements.
28 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
29 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
30 **
31 ** Contact info@trolltech.com if any conditions of this licensing are
32 ** not clear to you.
33 **
34 **********************************************************************/
35 
36 #ifndef QTABBAR_H
37 #define QTABBAR_H
38 
39 #ifndef QT_H
40 #include "qwidget.h"
41 #include "qptrlist.h"
42 #endif // QT_H
43 
44 #ifndef QT_NO_TABBAR
45 
46 class QTabBar;
47 class QIconSet;
48 
49 class Q_EXPORT QTab : public Qt
50 {
51     friend class QTabBar;
52     friend class QTabWidget;
53 
54 public:
55     QTab();
56     virtual ~QTab();
57     QTab( const QString& text );
58     QTab( const QIconSet& icon, const QString& text = QString::null );
59 
60     void setText( const QString& text);
text()61     QString text() const { return label; }
62     void setIconSet( const QIconSet& icon );
iconSet()63     QIconSet* iconSet() const { return iconset; }
setRect(const QRect & rect)64     void setRect( const QRect& rect ) { r = rect; }
rect()65     QRect rect() const { return r; }
setEnabled(bool enable)66     void setEnabled( bool enable ) { enabled = enable; }
isEnabled()67     bool isEnabled() const { return enabled; }
setIdentifier(int i)68     void setIdentifier( int i ) { id = i; }
identifier()69     int identifier() const { return id; }
70 
71 private:
72     void setTabBar( QTabBar *tb );
73     QString label;
74     QRect r; // the bounding rectangle of this (may overlap with others)
75     bool enabled;
76     int id;
77     QIconSet* iconset; // optional iconset
78     QTabBar *tb;
79 };
80 
81 
82 struct QTabPrivate;
83 //class *QAccel;
84 
85 class Q_EXPORT QTabBar: public QWidget
86 {
87     Q_OBJECT
88     Q_ENUMS( Shape )
89     Q_PROPERTY( Shape shape READ shape WRITE setShape )
90     Q_PROPERTY( int currentTab READ currentTab WRITE setCurrentTab )
91     Q_PROPERTY( int count READ count )
92     Q_PROPERTY( int keyboardFocusTab READ keyboardFocusTab )
93 
94 public:
95     QTabBar( QWidget* parent=0, const char* name=0 );
96     ~QTabBar();
97 
98     enum Shape { RoundedAbove, RoundedBelow,
99 		 TriangularAbove, TriangularBelow };
100 
101     Shape shape() const;
102     virtual void setShape( Shape );
103 
104     void show();
105 
106     virtual int addTab( QTab * );
107     virtual int insertTab( QTab *, int index = -1 );
108     virtual void removeTab( QTab * );
109 
110     virtual void setTabEnabled( int, bool );
111     bool isTabEnabled( int ) const;
112 
113 
114     QSize sizeHint() const;
115     QSize minimumSizeHint() const;
116 
117     int currentTab() const;
118     int keyboardFocusTab() const;
119 
120     QTab * tab( int ) const;
121     QTab * tabAt( int ) const;
122     int indexOf( int ) const;
123     int count() const;
124 
125     virtual void layoutTabs();
126     virtual QTab * selectTab( const QPoint & p ) const;
127 
128     void 	removeToolTip( int index );
129     void     	setToolTip( int index, const QString & tip );
130     QString 	toolTip( int index ) const;
131 
132 public slots:
133     virtual void setCurrentTab( int );
134     virtual void setCurrentTab( QTab * );
135 
136 signals:
137     void selected( int );
138     void layoutChanged();
139 
140 protected:
141     virtual void paint( QPainter *, QTab *, bool ) const; // ### not const
142     virtual void paintLabel( QPainter*, const QRect&, QTab*, bool ) const;
143 
144     void focusInEvent( QFocusEvent *e );
145     void focusOutEvent( QFocusEvent *e );
146 
147     void resizeEvent( QResizeEvent * );
148     void paintEvent( QPaintEvent * );
149     void mousePressEvent ( QMouseEvent * );
150     void mouseMoveEvent ( QMouseEvent * );
151     void mouseReleaseEvent ( QMouseEvent * );
152     void keyPressEvent( QKeyEvent * );
153     void styleChange( QStyle& );
154     void fontChange ( const QFont & );
155 
156     bool event( QEvent *e );
157 
158     QPtrList<QTab> * tabList();
159 
160 private slots:
161     void scrollTabs();
162 
163 private:
164     QPtrList<QTab> * l;
165     QPtrList<QTab> * lstatic;
166     void makeVisible( QTab* t = 0 );
167     void updateArrowButtons();
168     QTabPrivate * d;
169 
170     friend class QTabBarToolTip;
171     friend class QTab;
172 
173 private:	// Disabled copy constructor and operator=
174 #if defined(Q_DISABLE_COPY)
175     QTabBar( const QTabBar & );
176     QTabBar& operator=( const QTabBar & );
177 #endif
178 };
179 
180 
181 #endif // QT_NO_TABBAR
182 
183 #endif // QTABBAR_H
184