ktabbar.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2003 Stephan Binner <binner@kde.org> 00003 Copyright (C) 2003 Zack Rusin <zack@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef KTABBAR_H 00022 #define KTABBAR_H 00023 00024 #include <tqtabbar.h> 00025 00026 #include <kdelibs_export.h> 00027 00028 class TQTimer; 00029 class TQPushButton; 00030 class KTabBarPrivate; 00031 00035 class KDEUI_EXPORT KTabBar: public TQTabBar 00036 { 00037 Q_OBJECT 00038 00039 public: 00040 KTabBar( TQWidget* parent=0, const char* name=0 ); 00041 virtual ~KTabBar(); 00042 00043 virtual void setTabEnabled( int, bool ); 00044 00045 const TQColor &tabColor( int ) const; 00046 void setTabColor( int, const TQColor& ); 00047 00048 virtual int insertTab( TQTab *, int index = -1 ); 00049 virtual void removeTab( TQTab * ); 00050 00051 void setTabReorderingEnabled( bool enable ); 00052 bool isTabReorderingEnabled() const; 00053 00054 void setHoverCloseButton( bool ); 00055 bool hoverCloseButton() const; 00056 00057 void setHoverCloseButtonDelayed( bool ); 00058 bool hoverCloseButtonDelayed() const; 00059 00060 void setTabCloseActivatePrevious( bool ); 00061 bool tabCloseActivatePrevious() const; 00062 00063 signals: 00064 void contextMenu( int, const TQPoint & ); 00065 void mouseDoubleClick( int ); 00066 void mouseMiddleClick( int ); 00067 void initiateDrag( int ); 00068 void testCanDecode(const TQDragMoveEvent *e, bool &accept /* result */); 00069 void receivedDropEvent( int, TQDropEvent * ); 00070 void moveTab( int, int ); 00071 void closeRequest( int ); 00072 #ifndef QT_NO_WHEELEVENT 00073 void wheelDelta( int ); 00074 #endif 00075 00076 protected: 00077 virtual void mouseDoubleClickEvent( TQMouseEvent *e ); 00078 virtual void mousePressEvent( TQMouseEvent *e ); 00079 virtual void mouseMoveEvent( TQMouseEvent *e ); 00080 virtual void mouseReleaseEvent( TQMouseEvent *e ); 00081 #ifndef QT_NO_WHEELEVENT 00082 virtual void wheelEvent( TQWheelEvent *e ); 00083 #endif 00084 00085 virtual void dragMoveEvent( TQDragMoveEvent *e ); 00086 virtual void dropEvent( TQDropEvent *e ); 00087 00088 virtual void paintLabel( TQPainter*, const TQRect&, TQTab*, bool ) const; 00089 00090 protected slots: 00091 virtual void closeButtonClicked(); 00092 virtual void onLayoutChange(); 00093 virtual void enableCloseButton(); 00094 virtual void activateDragSwitchTab(); 00095 00096 private: 00097 TQPoint mDragStart; 00098 int mReorderStartTab; 00099 int mReorderPreviousTab; 00100 TQMap<int, TQColor> mTabColors; 00101 TQTab *mHoverCloseButtonTab, *mDragSwitchTab; 00102 TQPushButton *mHoverCloseButton; 00103 TQTimer *mEnableCloseButtonTimer, *mActivateDragSwitchTabTimer; 00104 00105 bool mHoverCloseButtonEnabled; 00106 bool mHoverCloseButtonDelayed; 00107 bool mTabReorderingEnabled; 00108 bool mTabCloseActivatePrevious; 00109 00110 KTabBarPrivate * d; 00111 }; 00112 00113 #endif