| 1 | /* This file is part of the KDE libraries
|
|---|
| 2 | Copyright (C) 2003 Stephan Binner <binner@kde.org>
|
|---|
| 3 | Copyright (C) 2003 Zack Rusin <zack@kde.org>
|
|---|
| 4 |
|
|---|
| 5 | This library is free software; you can redistribute it and/or
|
|---|
| 6 | modify it under the terms of the GNU Library General Public
|
|---|
| 7 | License as published by the Free Software Foundation; either
|
|---|
| 8 | version 2 of the License, or (at your option) any later version.
|
|---|
| 9 |
|
|---|
| 10 | This library is distributed in the hope that it will be useful,
|
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 13 | Library General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU Library General Public License
|
|---|
| 16 | along with this library; see the file COPYING.LIB. If not, write to
|
|---|
| 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|---|
| 18 | Boston, MA 02111-1307, USA.
|
|---|
| 19 | */
|
|---|
| 20 |
|
|---|
| 21 | #ifndef KTABBAR_H
|
|---|
| 22 | #define KTABBAR_H
|
|---|
| 23 |
|
|---|
| 24 | #include <qtabbar.h>
|
|---|
| 25 | #include <qiconset.h>
|
|---|
| 26 |
|
|---|
| 27 | class QTimer;
|
|---|
| 28 | class QPushButton;
|
|---|
| 29 | class KTabBarPrivate;
|
|---|
| 30 |
|
|---|
| 31 | class KTabBar: public QTabBar
|
|---|
| 32 | {
|
|---|
| 33 | Q_OBJECT
|
|---|
| 34 |
|
|---|
| 35 | public:
|
|---|
| 36 | KTabBar( QWidget* parent=0, const char* name=0 );
|
|---|
| 37 | virtual ~KTabBar();
|
|---|
| 38 |
|
|---|
| 39 | void setCloseIcon(const QIconSet&);
|
|---|
| 40 |
|
|---|
| 41 | virtual void setTabEnabled( int, bool );
|
|---|
| 42 |
|
|---|
| 43 | const QColor &tabColor( int ) const;
|
|---|
| 44 | void setTabColor( int, const QColor& );
|
|---|
| 45 |
|
|---|
| 46 | virtual int insertTab( QTab *, int index = -1 );
|
|---|
| 47 | virtual void removeTab( QTab * );
|
|---|
| 48 |
|
|---|
| 49 | void setTabReorderingEnabled( bool enable );
|
|---|
| 50 | bool isTabReorderingEnabled() const;
|
|---|
| 51 |
|
|---|
| 52 | void setHoverCloseButton( bool );
|
|---|
| 53 | bool hoverCloseButton() const;
|
|---|
| 54 |
|
|---|
| 55 | void setHoverCloseButtonDelayed( bool );
|
|---|
| 56 | bool hoverCloseButtonDelayed() const;
|
|---|
| 57 |
|
|---|
| 58 | void setTabCloseActivatePrevious( bool );
|
|---|
| 59 | bool tabCloseActivatePrevious() const;
|
|---|
| 60 |
|
|---|
| 61 | signals:
|
|---|
| 62 | void contextMenu( int, const QPoint & );
|
|---|
| 63 | void mouseDoubleClick( int );
|
|---|
| 64 | void mouseMiddleClick( int );
|
|---|
| 65 | void initiateDrag( int );
|
|---|
| 66 | void testCanDecode(const QDragMoveEvent *e, bool &accept /* result */);
|
|---|
| 67 | void receivedDropEvent( int, QDropEvent * );
|
|---|
| 68 | void moveTab( int, int );
|
|---|
| 69 | void closeRequest( int );
|
|---|
| 70 | #ifndef QT_NO_WHEELEVENT
|
|---|
| 71 | void wheelDelta( int );
|
|---|
| 72 | #endif
|
|---|
| 73 |
|
|---|
| 74 | protected:
|
|---|
| 75 | virtual void mouseDoubleClickEvent( QMouseEvent *e );
|
|---|
| 76 | virtual void mousePressEvent( QMouseEvent *e );
|
|---|
| 77 | virtual void mouseMoveEvent( QMouseEvent *e );
|
|---|
| 78 | virtual void mouseReleaseEvent( QMouseEvent *e );
|
|---|
| 79 | #ifndef QT_NO_WHEELEVENT
|
|---|
| 80 | virtual void wheelEvent( QWheelEvent *e );
|
|---|
| 81 | #endif
|
|---|
| 82 |
|
|---|
| 83 | virtual void dragMoveEvent( QDragMoveEvent *e );
|
|---|
| 84 | virtual void dropEvent( QDropEvent *e );
|
|---|
| 85 |
|
|---|
| 86 | virtual void paintLabel( QPainter*, const QRect&, QTab*, bool ) const;
|
|---|
| 87 |
|
|---|
| 88 | protected slots:
|
|---|
| 89 | virtual void closeButtonClicked();
|
|---|
| 90 | virtual void onLayoutChange();
|
|---|
| 91 | virtual void enableCloseButton();
|
|---|
| 92 | virtual void activateDragSwitchTab();
|
|---|
| 93 |
|
|---|
| 94 | private:
|
|---|
| 95 | QPoint mDragStart;
|
|---|
| 96 | int mReorderStartTab;
|
|---|
| 97 | int mReorderPreviousTab;
|
|---|
| 98 | QMap<int, QColor> mTabColors;
|
|---|
| 99 | QTab *mHoverCloseButtonTab, *mDragSwitchTab;
|
|---|
| 100 | QPushButton *mHoverCloseButton;
|
|---|
| 101 | QTimer *mEnableCloseButtonTimer, *mActivateDragSwitchTabTimer;
|
|---|
| 102 |
|
|---|
| 103 | bool mHoverCloseButtonEnabled;
|
|---|
| 104 | bool mHoverCloseButtonDelayed;
|
|---|
| 105 | bool mTabReorderingEnabled;
|
|---|
| 106 | bool mTabCloseActivatePrevious;
|
|---|
| 107 |
|
|---|
| 108 | int dndEventDelay;
|
|---|
| 109 | QIconSet closeIcon;
|
|---|
| 110 | KTabBarPrivate * d;
|
|---|
| 111 | };
|
|---|
| 112 |
|
|---|
| 113 | #endif
|
|---|