ktabwidget.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 KTABWIDGET_H 00022 #define KTABWIDGET_H 00023 00024 #include <tqtabwidget.h> 00025 #include <tqstringlist.h> 00026 00027 #include <kdelibs_export.h> 00028 00029 class KTabWidgetPrivate; 00030 00036 class KDEUI_EXPORT KTabWidget : public TQTabWidget 00037 { 00038 Q_OBJECT 00039 Q_PROPERTY( bool tabReorderingEnabled READ isTabReorderingEnabled WRITE setTabReorderingEnabled ) 00040 Q_PROPERTY( bool hoverCloseButton READ hoverCloseButton WRITE setHoverCloseButton ) 00041 Q_PROPERTY( bool hoverCloseButtonDelayed READ hoverCloseButtonDelayed WRITE setHoverCloseButtonDelayed ) 00042 Q_PROPERTY( bool tabCloseActivatePrevious READ tabCloseActivatePrevious WRITE setTabCloseActivatePrevious ) 00043 Q_PROPERTY( bool automaticResizeTabs READ automaticResizeTabs WRITE setAutomaticResizeTabs ) 00044 00045 public: 00046 KTabWidget( TQWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 00050 virtual ~KTabWidget(); 00054 void setTabColor( TQWidget *, const TQColor& color ); 00058 TQColor tabColor( TQWidget * ) const; 00059 00064 bool isTabReorderingEnabled() const; 00065 00070 bool hoverCloseButton() const; 00071 00076 bool hoverCloseButtonDelayed() const; 00077 00083 bool tabCloseActivatePrevious() const; 00084 00090 bool automaticResizeTabs() const; 00091 00097 void setTabBarHidden( bool hide ); 00098 00103 bool isTabBarHidden() const; 00104 00108 virtual void insertTab( TQWidget *, const TQString &, int index = -1 ); 00109 00113 virtual void insertTab( TQWidget *child, const TQIconSet& iconset, 00114 const TQString &label, int index = -1 ); 00118 virtual void insertTab( TQWidget *, TQTab *, int index = -1 ); 00119 00123 void changeTab( TQWidget *, const TQString & ); 00124 00128 void changeTab( TQWidget *child, const TQIconSet& iconset, const TQString &label ); 00129 00133 TQString label( int ) const; 00134 00138 TQString tabLabel( TQWidget * ) const; 00139 00143 void setTabLabel( TQWidget *, const TQString & ); 00144 00145 public slots: 00150 virtual void moveTab( int, int ); 00151 00156 virtual void removePage ( TQWidget * w ); 00157 00167 void setTabReorderingEnabled( bool enable ); 00168 00174 void setHoverCloseButton( bool enable ); 00175 00180 void setHoverCloseButtonDelayed( bool delayed ); 00181 00187 void setTabCloseActivatePrevious( bool previous ); 00188 00196 void setAutomaticResizeTabs( bool enable ); 00197 00198 signals: 00202 void testCanDecode(const TQDragMoveEvent *e, bool &accept /* result */); 00203 00208 void receivedDropEvent( TQDropEvent * ); 00209 00214 void receivedDropEvent( TQWidget *, TQDropEvent * ); 00215 00219 void initiateDrag( TQWidget * ); 00220 00224 void contextMenu( const TQPoint & ); 00225 00229 void contextMenu( TQWidget *, const TQPoint & ); 00230 00235 void movedTab( int, int ); 00236 00241 void mouseDoubleClick(); 00242 00246 void mouseDoubleClick( TQWidget * ); 00247 00251 void mouseMiddleClick(); 00252 00256 void mouseMiddleClick( TQWidget * ); 00257 00262 void closeRequest( TQWidget * ); 00263 00264 protected: 00265 virtual void mouseDoubleClickEvent( TQMouseEvent *e ); 00266 virtual void mousePressEvent( TQMouseEvent * ); 00267 virtual void dragMoveEvent( TQDragMoveEvent * ); 00268 virtual void dropEvent( TQDropEvent * ); 00269 unsigned int tabBarWidthForMaxChars( uint maxLength ); 00270 #ifndef QT_NO_WHEELEVENT 00271 virtual void wheelEvent( TQWheelEvent *e ); 00272 #endif 00273 virtual void resizeEvent( TQResizeEvent * ); 00274 00275 protected slots: 00276 virtual void receivedDropEvent( int, TQDropEvent * ); 00277 virtual void initiateDrag( int ); 00278 virtual void contextMenu( int, const TQPoint & ); 00279 virtual void mouseDoubleClick( int ); 00280 virtual void mouseMiddleClick( int ); 00281 virtual void closeRequest( int ); 00282 #ifndef QT_NO_WHEELEVENT 00283 virtual void wheelDelta( int ); 00284 #endif 00285 00286 private: 00287 bool isEmptyTabbarSpace( const TQPoint & ) const; 00288 void resizeTabs( int changedTabIndex = -1 ); 00289 void updateTab( int index ); 00290 00291 KTabWidgetPrivate *d; 00292 }; 00293 00294 #endif