source: trunk/include/qtabbar.h@ 25

Last change on this file since 25 was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 5.2 KB
Line 
1/****************************************************************************
2** $Id: qtabbar.h 2 2005-11-16 15:49:26Z dmik $
3**
4** Definition of QTab and QTabBar classes
5**
6** Copyright (C) 1992-2000 Trolltech AS. 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 AS 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
46class QTabBar;
47class QIconSet;
48
49class Q_EXPORT QTab : public Qt
50{
51 friend class QTabBar;
52 friend class QTabWidget;
53
54public:
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);
61 QString text() const { return label; }
62 void setIconSet( const QIconSet& icon );
63 QIconSet* iconSet() const { return iconset; }
64 void setRect( const QRect& rect ) { r = rect; }
65 QRect rect() const { return r; }
66 void setEnabled( bool enable ) { enabled = enable; }
67 bool isEnabled() const { return enabled; }
68 void setIdentifier( int i ) { id = i; }
69 int identifier() const { return id; }
70
71private:
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
82struct QTabPrivate;
83//class *QAccel;
84
85class 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
94public:
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
132public slots:
133 virtual void setCurrentTab( int );
134 virtual void setCurrentTab( QTab * );
135
136signals:
137 void selected( int );
138 void layoutChanged();
139
140protected:
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
160private slots:
161 void scrollTabs();
162
163private:
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
173private: // 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
Note: See TracBrowser for help on using the repository browser.