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 <tdelibs_export.h> 00028 00029 class KTabWidgetPrivate; 00030 00036 class TDEUI_EXPORT KTabWidget : public TQTabWidget 00037 { 00038 Q_OBJECT 00039 TQ_PROPERTY( bool tabReorderingEnabled READ isTabReorderingEnabled WRITE setTabReorderingEnabled ) 00040 TQ_PROPERTY( bool hoverCloseButton READ hoverCloseButton WRITE setHoverCloseButton ) 00041 TQ_PROPERTY( bool hoverCloseButtonDelayed READ hoverCloseButtonDelayed WRITE setHoverCloseButtonDelayed ) 00042 TQ_PROPERTY( bool tabCloseActivatePrevious READ tabCloseActivatePrevious WRITE setTabCloseActivatePrevious ) 00043 TQ_PROPERTY( bool automaticResizeTabs READ automaticResizeTabs WRITE setAutomaticResizeTabs ) 00044 00045 public: 00046 KTabWidget( TQWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 00047 00051 virtual ~KTabWidget(); 00052 00056 void setTabColor( TQWidget *, const TQColor& color ); 00057 00061 TQColor tabColor( TQWidget * ) const; 00062 00067 bool isTabReorderingEnabled() const; 00068 00073 bool hoverCloseButton() const; 00074 00079 bool hoverCloseButtonDelayed() const; 00080 00086 bool tabCloseActivatePrevious() const; 00087 00093 bool automaticResizeTabs() const; 00094 00100 void setTabBarHidden( bool hide ); 00101 00106 bool isTabBarHidden() const; 00107 00113 void setMouseWheelScroll(bool mouseWheelScroll); 00114 00118 virtual void insertTab( TQWidget *, const TQString &, int index = -1 ); 00119 00123 virtual void insertTab( TQWidget *child, const TQIconSet& iconset, 00124 const TQString &label, int index = -1 ); 00128 virtual void insertTab( TQWidget *, TQTab *, int index = -1 ); 00129 00133 void changeTab( TQWidget *, const TQString & ); 00134 00138 void changeTab( TQWidget *child, const TQIconSet& iconset, const TQString &label ); 00139 00143 TQString label( int ) const; 00144 00148 TQString tabLabel( TQWidget * ) const; 00149 00153 void setTabLabel( TQWidget *, const TQString & ); 00154 00155 public slots: 00160 virtual void moveTab( int, int ); 00161 00166 virtual void removePage ( TQWidget * w ); 00167 00177 void setTabReorderingEnabled( bool enable ); 00178 00184 void setHoverCloseButton( bool enable ); 00185 00190 void setHoverCloseButtonDelayed( bool delayed ); 00191 00197 void setTabCloseActivatePrevious( bool previous ); 00198 00206 void setAutomaticResizeTabs( bool enable ); 00207 00208 signals: 00212 void testCanDecode(const TQDragMoveEvent *e, bool &accept /* result */); 00213 00218 void receivedDropEvent( TQDropEvent * ); 00219 00224 void receivedDropEvent( TQWidget *, TQDropEvent * ); 00225 00229 void initiateDrag( TQWidget * ); 00230 00234 void contextMenu( const TQPoint & ); 00235 00239 void contextMenu( TQWidget *, const TQPoint & ); 00240 00245 void movedTab( int, int ); 00246 00251 void mouseDoubleClick(); 00252 00256 void mouseDoubleClick( TQWidget * ); 00257 00261 void mouseMiddleClick(); 00262 00266 void mouseMiddleClick( TQWidget * ); 00267 00272 void closeRequest( TQWidget * ); 00273 00274 protected: 00275 virtual void mouseDoubleClickEvent( TQMouseEvent *e ); 00276 virtual void mousePressEvent( TQMouseEvent * ); 00277 virtual void dragMoveEvent( TQDragMoveEvent * ); 00278 virtual void dropEvent( TQDropEvent * ); 00279 unsigned int tabBarWidthForMaxChars( uint maxLength ); 00280 #ifndef QT_NO_WHEELEVENT 00281 virtual void wheelEvent( TQWheelEvent *e ); 00282 #endif 00283 virtual void resizeEvent( TQResizeEvent * ); 00284 00285 protected slots: 00286 virtual void receivedDropEvent( int, TQDropEvent * ); 00287 virtual void initiateDrag( int ); 00288 virtual void contextMenu( int, const TQPoint & ); 00289 virtual void mouseDoubleClick( int ); 00290 virtual void mouseMiddleClick( int ); 00291 virtual void closeRequest( int ); 00292 #ifndef QT_NO_WHEELEVENT 00293 virtual void wheelDelta( int ); 00294 #endif 00295 00296 private: 00297 bool isEmptyTabbarSpace( const TQPoint & ) const; 00298 void resizeTabs( int changedTabIndex = -1 ); 00299 void updateTab( int index ); 00300 00301 KTabWidgetPrivate *d; 00302 }; 00303 00304 #endif