|
|
/* $@KEC10@$ Generated by KEncoder 1.0 ****************************************************************************** * File Name : tabbar.h - Tab bar * Created on : Wednesday, October 23, 2002 * Product id : KitClasses version 1.1 - Add-on classes for KDE * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Copyright : © 2002 by Bruce Hunt Supporting Cast * Email : SuppCast@users.sourceforge.net * Web site : http://kinterdev.sourceforge.net ****************************************************************************** * This program is being provided under the LICENSING terms and conditions as * specified in the file "COPYING" which has been included with this software * package. This program is distributed WITHOUT ANY WARRANTY, without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ****************************************************************************** * M o d i f i c a t i o n L o g * *****************************************************************************/ #ifndef _TABBAR_H_ #define _TABBAR_H_ #include#include #include class QIconSet; class QPainter; class QTab; class QTabBar; class QToolButton; class KActionMenu; class KPopupMenu; class KitTabBarPrivate; class KitTabBarToolTip; class KitTabBarWhatsThis; /** * KitTabBar is a full function Tabbar similar to QTabBar but has * additional functionality. Additional features include side tabs, * tab sizing, context menu support, and QWhatsThis support. * @short Tab bar with side tab support * @author Bruce Hunt SuppCast@users.sourceforge.net */ class KitTabBar : public QWidget { Q_OBJECT public: /** * The position of the tab bar */ enum Position { Left, Right, Top, Bottom }; /** * The shape of the tabs */ enum TabShape { Rounded, Triangular }; /** * The size of the tabs */ enum TabSize { Normal, Thin }; /** * Constructor */ KitTabBar( KitTabBar::Position pos = KitTabBar::Top, QWidget * parent = 0, const char * name = 0 ); /** * Destructor */ ~KitTabBar(); /** * Adds a tab to the bar. * @param text the text of the tab * @return the id of the tab */ int addTab( const QString & text ); /** * Same as above but with an icon. * @param icon the icon of the tab * @param text the text of the tab * @return the id of the tab */ int addTab( const QIconSet & icon, const QString & text = QString::null ); /** * Adds a tab to the bar at the index specified. * @param text the text of the tab * @param index the index of the tab placement * @return the id of the tab */ int insertTab( const QString & text, int index = -1 ); /** * Same as above but with an icon. * @param icon the icon of the tab * @param text the text of the tab * @param index the index of the tab placement * @return the id of the tab */ int insertTab( const QIconSet & icon, const QString & text = QString::null, int index = -1 ); /** * Same as above but with a pointer to an existing tab. The tab may or may * not already have an icon and text. * @param tab the pointer to the tab * @param index the index of the tab placement * @return the id of the tab */ int insertTab( QTab * tab, int index = -1 ); /** * Removes the tab from the bar. If the tab is the currently selected tab * the next available tab is set as selected. * @param id the id of the tab */ void removeTab( int id ); /** * Same as above * @param tab the pointer to the tab */ void removeTab( QTab * tab ); /** * @return the id of the currently selected tab */ int currentTab(); /** * Sets the tab with id as selected * @param id the id of the tab */ void setCurrentTab( int id ); /** * Same as above * @param tab the pointer to the tab */ void setCurrentTab( QTab * tab ); /** * Set a tab as enabled or disabled. Use this method instead of using the * tab pointer. Using the tab pointer directly has unpredictable results. * Disabling the currently selected tab causes the next available enabled * tab to be set as selected. * @param id the id of the tab * @param enabled toggle the tab as enabled/disabled */ void setTabEnabled( int id, bool enabled ); /** * Same as above * @param tab the pointer to the tab * @param enabled toggle the tab as enabled/disabled */ void setTabEnabled( QTab * tab, bool enabled ); /** * Sets the tab icon * @param id the id of the tab * @param icon the iconset for the tab icon */ void setTabIconSet( int id, const QIconSet & icon ); /** * Sets the tab label * @param id the id of the tab * @param text the text for the tab label */ void setTabLabel( int id, const QString & text ); /** * @return the current bar position */ KitTabBar::Position position(); /** * Sets the tab bar position (Left, Right, Top, Bottom) * @param pos the position of the tab bar */ void setPosition( KitTabBar::Position pos ); /** * @return the bar orientation ( Horizontal or Vertical ) */ Qt::Orientation orientation(); /** * Sets the menu for a right click on the tab. This menu superceeds the * popup menu if set. * @param menu KActionMenu pointer */ void setActionMenu( KActionMenu * menu ); /** * Sets the menu for a right click on the tab. This menu is superceeded by * the action menu if set. * @param menu KPopupMenu pointer */ void setPopupMenu( KPopupMenu * menu ); /** * Use this to identify the tab that was right clicked. * @return the pointer to the tab that was right clicked */ QTab * menuTab(); /** * @return the current toggle mode */ bool allowToggle(); /** * Sets the tab toggle mode. You can unselect a tab if set to true. * Toggling is off by default. * @param toggle allows tab toggling */ void setAllowToggle( bool toggle ); /** * @return the current auto-select mode */ bool autoSelect(); /** * Sets the auto-select mode. This will disable automatic selection of * tabs when the currently selected tab is removed or disabled. * Auto-select is on by default. * @param auto the auto-select mode */ void setAutoSelect( bool select ); /** * @return the shape of the tabs */ KitTabBar::TabShape tabShape() const; /** * Sets the shape of the tabs * @param tab shape */ void setTabShape( TabShape shape ); /** * @return the size of the tabs */ KitTabBar::TabSize tabSize() const; /** * Sets the size of the tabs * @param size tab size */ void setTabSize( TabSize size ); /** * @param id the id of the tab * @return a pointer to the tab */ QTab * tab( int id ) const; /** * @param id the id of the tab * @return the tooltip text for the tab */ const QString toolTip( int id ); /** * @param tab the pointer to the tab * @return the tooltip text for the tab */ const QString toolTip( QTab * tab ); /** * Sets the text for the tab tooltip. * @param id the id of the tab * @param tip the tooltip text for the tab */ void setToolTip( int id, const QString & tip ); /** * Sets the text for the tab tooltip. * @param tab the pointer to the tab * @param tip the tooltip text for the tab */ void setToolTip( QTab * tab, const QString & tip ); /** * Removes the tooltip from the tab. * @param id the id of the tab */ void removeToolTip( int id ); /** * Removes the tooltip from the tab. * @param tab the pointer to the tab */ void removeToolTip( QTab * tab ); /** * @param id the id of the tab * @return the 'whats this' text for the tab */ const QString whatsThis( int id ); /** * @param tab the pointer to the tab * @return the 'whats this' text for the tab */ const QString whatsThis( QTab * tab ); /** * Sets the 'whats this' text for the tab. * @param id the id of the tab * @param text the 'whats this' text for the tab */ void setWhatsThis( int id, const QString & text ); /** * Sets the 'whats this' text for the tab. * @param tab the pointer to the tab * @param text the 'whats this' text for the tab */ void setWhatsThis( QTab * tab, const QString & text ); /** * Removes the 'whats this' from the tab. * @param id the id of the tab */ void removeWhatsThis( int id ); /** * Removes the 'whats this' from the tab. * @param tab the pointer to the tab */ void removeWhatsThis( QTab * tab ); /** * @return the number of tabs in the bar */ int count(); /** * @return the pointer list of tabs in the bar */ const QPtrList * tabList(); signals: /** * This is emitted only when the tab is first selected, not when toggled off. * @return the id of the tab selected */ void selected( int id ); /** * @return the tab id and the selection status */ void toggled( int id, bool selected ); /** * This is emitted previous to the menu popup. Use this for * custom right click processing. Menu's will popup only if set. * @return the id of the tab that was right clicked. */ void rmbClicked( int id ); /** * Same as above but provides the tab pointer. * @return the pointer to the tab that was right clicked. */ void rmbClicked( QTab * tab ); protected: QSize sizeHint() const; QSize minimumSizeHint() const; void fontChange ( const QFont & ); void paintEvent( QPaintEvent * ); void resizeEvent( QResizeEvent * ); void styleChange( QStyle & ); private: KitTabBarPrivate * k; QPtrList * plTabs; QTab * getScrollTab( int ); QSize getTabSize( QTab * ); void layoutTabs(); void makeVisible( QTab *, bool ); void mousePressEvent ( QMouseEvent * ); void paintTab( QPainter *, QTab *, bool ); QTab * selectTab( const QPoint & p ); void updateArrowButtons(); friend class QTab; friend class KitTabBarToolTip; friend class KitTabBarWhatsThis; private slots: void scrollLeft(); void scrollRight(); }; #endif
Generated by: bhunt on Lurch on Sun Nov 24 02:45:27 2002, using kdoc 2.0a54. |