You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
293 lines
8.5 KiB
293 lines
8.5 KiB
15 years ago
|
/* This file is part of the KDE libraries
|
||
|
Copyright (C) 2003 Stephan Binner <binner@kde.org>
|
||
|
Copyright (C) 2003 Zack Rusin <zack@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#ifndef KTABWIDGET_H
|
||
|
#define KTABWIDGET_H
|
||
|
|
||
15 years ago
|
#include <tqtabwidget.h>
|
||
|
#include <tqstringlist.h>
|
||
15 years ago
|
|
||
13 years ago
|
#include <tdelibs_export.h>
|
||
15 years ago
|
|
||
|
class KTabWidgetPrivate;
|
||
|
|
||
|
/**
|
||
|
* \brief A widget containing multiple tabs
|
||
|
*
|
||
|
* @since 3.2
|
||
|
*/
|
||
13 years ago
|
class TDEUI_EXPORT KTabWidget : public TQTabWidget
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
13 years ago
|
|
||
14 years ago
|
TQ_PROPERTY( bool tabReorderingEnabled READ isTabReorderingEnabled WRITE setTabReorderingEnabled )
|
||
|
TQ_PROPERTY( bool hoverCloseButton READ hoverCloseButton WRITE setHoverCloseButton )
|
||
|
TQ_PROPERTY( bool hoverCloseButtonDelayed READ hoverCloseButtonDelayed WRITE setHoverCloseButtonDelayed )
|
||
|
TQ_PROPERTY( bool tabCloseActivatePrevious READ tabCloseActivatePrevious WRITE setTabCloseActivatePrevious )
|
||
|
TQ_PROPERTY( bool automaticResizeTabs READ automaticResizeTabs WRITE setAutomaticResizeTabs )
|
||
15 years ago
|
|
||
|
public:
|
||
14 years ago
|
KTabWidget( TQWidget *parent = 0, const char *name = 0, WFlags f = 0 );
|
||
15 years ago
|
/**
|
||
|
* Destructor.
|
||
|
*/
|
||
|
virtual ~KTabWidget();
|
||
|
/*!
|
||
|
Set the tab of the given widget to \a color.
|
||
|
*/
|
||
15 years ago
|
void setTabColor( TQWidget *, const TQColor& color );
|
||
|
TQColor tabColor( TQWidget * ) const;
|
||
15 years ago
|
|
||
|
/*!
|
||
|
Returns true if tab ordering with the middle mouse button
|
||
|
has been enabled.
|
||
|
*/
|
||
|
bool isTabReorderingEnabled() const;
|
||
|
|
||
|
/*!
|
||
|
Returns true if the close button is shown on tabs
|
||
|
when mouse is hovering over them.
|
||
|
*/
|
||
|
bool hoverCloseButton() const;
|
||
|
|
||
|
/*!
|
||
|
Returns true if the close button is shown on tabs
|
||
|
after a delay.
|
||
|
*/
|
||
|
bool hoverCloseButtonDelayed() const;
|
||
|
|
||
|
/*!
|
||
|
Returns true if closing the current tab activates the previous
|
||
|
actice tab instead of the one to the right.
|
||
|
@since 3.3
|
||
|
*/
|
||
|
bool tabCloseActivatePrevious() const;
|
||
|
|
||
|
/*!
|
||
|
Returns true if calling setTitle() will resize tabs
|
||
|
to the width of the tab bar.
|
||
|
@since 3.4
|
||
|
*/
|
||
|
bool automaticResizeTabs() const;
|
||
|
|
||
|
/*!
|
||
|
If \a hide is true, the tabbar is hidden along with any corner
|
||
|
widgets.
|
||
|
@since 3.4
|
||
|
*/
|
||
|
void setTabBarHidden( bool hide );
|
||
|
|
||
|
/*!
|
||
|
Return true if the tabbar is hidden.
|
||
|
@since 3.4
|
||
|
*/
|
||
|
bool isTabBarHidden() const;
|
||
|
|
||
|
/*!
|
||
|
Reimplemented for internal reasons.
|
||
|
*/
|
||
15 years ago
|
virtual void insertTab( TQWidget *, const TQString &, int index = -1 );
|
||
15 years ago
|
|
||
|
/*!
|
||
|
Reimplemented for internal reasons.
|
||
|
*/
|
||
15 years ago
|
virtual void insertTab( TQWidget *child, const TQIconSet& iconset,
|
||
|
const TQString &label, int index = -1 );
|
||
15 years ago
|
/*!
|
||
|
Reimplemented for internal reasons.
|
||
|
*/
|
||
15 years ago
|
virtual void insertTab( TQWidget *, TQTab *, int index = -1 );
|
||
15 years ago
|
|
||
|
/*!
|
||
|
Reimplemented for internal reasons.
|
||
|
*/
|
||
15 years ago
|
void changeTab( TQWidget *, const TQString & );
|
||
15 years ago
|
|
||
|
/*!
|
||
|
Reimplemented for internal reasons.
|
||
|
*/
|
||
15 years ago
|
void changeTab( TQWidget *child, const TQIconSet& iconset, const TQString &label );
|
||
15 years ago
|
|
||
|
/*!
|
||
|
Reimplemented for internal reasons.
|
||
|
*/
|
||
15 years ago
|
TQString label( int ) const;
|
||
15 years ago
|
|
||
|
/*!
|
||
|
Reimplemented for internal reasons.
|
||
|
*/
|
||
15 years ago
|
TQString tabLabel( TQWidget * ) const;
|
||
15 years ago
|
|
||
|
/*!
|
||
|
Reimplemented for internal reasons.
|
||
|
*/
|
||
15 years ago
|
void setTabLabel( TQWidget *, const TQString & );
|
||
15 years ago
|
|
||
|
public slots:
|
||
|
/*!
|
||
|
Move a widget's tab from first to second specified index and emit
|
||
|
signal movedTab( int, int ) afterwards.
|
||
|
*/
|
||
|
virtual void moveTab( int, int );
|
||
|
|
||
|
/*!
|
||
|
Removes the widget, reimplemented for
|
||
|
internal reasons (keeping labels in sync).
|
||
|
*/
|
||
15 years ago
|
virtual void removePage ( TQWidget * w );
|
||
15 years ago
|
|
||
|
/*!
|
||
|
If \a enable is true, tab reordering with middle button will be enabled.
|
||
|
|
||
|
Note that once enabled you shouldn't rely on previously queried
|
||
15 years ago
|
currentPageIndex() or indexOf( TQWidget * ) values anymore.
|
||
15 years ago
|
|
||
|
You can connect to signal movedTab(int, int) which will notify
|
||
|
you from which index to which index a tab has been moved.
|
||
|
*/
|
||
|
void setTabReorderingEnabled( bool enable );
|
||
|
|
||
|
/*!
|
||
|
If \a enable is true, a close button will be shown on mouse hover
|
||
15 years ago
|
over tab icons which will emit signal closeRequest( TQWidget * )
|
||
15 years ago
|
when pressed.
|
||
|
*/
|
||
|
void setHoverCloseButton( bool enable );
|
||
|
|
||
|
/*!
|
||
|
If \a delayed is true, a close button will be shown on mouse hover
|
||
|
over tab icons after mouse double click delay else immediately.
|
||
|
*/
|
||
|
void setHoverCloseButtonDelayed( bool delayed );
|
||
|
|
||
|
/*!
|
||
|
If \a delayed is true, closing the current tab activates the
|
||
|
previous active tab instead of the one to the right.
|
||
|
@since 3.3
|
||
|
*/
|
||
|
void setTabCloseActivatePrevious( bool previous );
|
||
|
|
||
|
/*!
|
||
|
If \a enable is true, tabs will be resized to the width of the tab bar.
|
||
|
|
||
15 years ago
|
Does not work reliable with "TQTabWidget* foo=new KTabWidget()" and if
|
||
15 years ago
|
you change tabs via the tabbar or by accessing tabs directly.
|
||
|
@since 3.4
|
||
|
*/
|
||
|
void setAutomaticResizeTabs( bool enable );
|
||
|
|
||
|
signals:
|
||
|
/*!
|
||
|
Connect to this and set accept to true if you can and want to decode the event.
|
||
|
*/
|
||
15 years ago
|
void testCanDecode(const TQDragMoveEvent *e, bool &accept /* result */);
|
||
15 years ago
|
|
||
|
/*!
|
||
|
Received an event in the empty space beside tabbar. Usually creates a new tab.
|
||
|
This signal is only possible after testCanDecode and positive accept result.
|
||
|
*/
|
||
15 years ago
|
void receivedDropEvent( TQDropEvent * );
|
||
15 years ago
|
|
||
|
/*!
|
||
|
Received an drop event on given widget's tab.
|
||
|
This signal is only possible after testCanDecode and positive accept result.
|
||
|
*/
|
||
15 years ago
|
void receivedDropEvent( TQWidget *, TQDropEvent * );
|
||
15 years ago
|
|
||
|
/*!
|
||
|
Request to start a drag operation on the given tab.
|
||
|
*/
|
||
15 years ago
|
void initiateDrag( TQWidget * );
|
||
15 years ago
|
|
||
|
/*!
|
||
|
The right mouse button was pressed over empty space besides tabbar.
|
||
|
*/
|
||
15 years ago
|
void contextMenu( const TQPoint & );
|
||
15 years ago
|
|
||
|
/*!
|
||
|
The right mouse button was pressed over a widget.
|
||
|
*/
|
||
15 years ago
|
void contextMenu( TQWidget *, const TQPoint & );
|
||
15 years ago
|
|
||
|
/*!
|
||
|
A tab was moved from first to second index. This signal is only
|
||
|
possible after you have called setTabReorderingEnabled( true ).
|
||
|
*/
|
||
|
void movedTab( int, int );
|
||
|
|
||
|
/*!
|
||
|
A double left mouse button click was performed over empty space besides tabbar.
|
||
|
@since 3.3
|
||
|
*/
|
||
|
void mouseDoubleClick();
|
||
|
|
||
|
/*!
|
||
|
A double left mouse button click was performed over the widget.
|
||
|
*/
|
||
15 years ago
|
void mouseDoubleClick( TQWidget * );
|
||
15 years ago
|
|
||
|
/*!
|
||
|
A middle mouse button click was performed over empty space besides tabbar.
|
||
|
*/
|
||
|
void mouseMiddleClick();
|
||
|
|
||
|
/*!
|
||
|
A middle mouse button click was performed over the widget.
|
||
|
*/
|
||
15 years ago
|
void mouseMiddleClick( TQWidget * );
|
||
15 years ago
|
|
||
|
/*!
|
||
|
The close button of a widget's tab was clicked. This signal is
|
||
|
only possible after you have called setHoverCloseButton( true ).
|
||
|
*/
|
||
15 years ago
|
void closeRequest( TQWidget * );
|
||
15 years ago
|
|
||
|
protected:
|
||
15 years ago
|
virtual void mouseDoubleClickEvent( TQMouseEvent *e );
|
||
|
virtual void mousePressEvent( TQMouseEvent * );
|
||
|
virtual void dragMoveEvent( TQDragMoveEvent * );
|
||
|
virtual void dropEvent( TQDropEvent * );
|
||
15 years ago
|
unsigned int tabBarWidthForMaxChars( uint maxLength );
|
||
14 years ago
|
#ifndef TQT_NO_WHEELEVENT
|
||
15 years ago
|
virtual void wheelEvent( TQWheelEvent *e );
|
||
15 years ago
|
#endif
|
||
15 years ago
|
virtual void resizeEvent( TQResizeEvent * );
|
||
15 years ago
|
|
||
|
protected slots:
|
||
15 years ago
|
virtual void receivedDropEvent( int, TQDropEvent * );
|
||
15 years ago
|
virtual void initiateDrag( int );
|
||
15 years ago
|
virtual void contextMenu( int, const TQPoint & );
|
||
15 years ago
|
virtual void mouseDoubleClick( int );
|
||
|
virtual void mouseMiddleClick( int );
|
||
|
virtual void closeRequest( int );
|
||
14 years ago
|
#ifndef TQT_NO_WHEELEVENT
|
||
15 years ago
|
virtual void wheelDelta( int );
|
||
|
#endif
|
||
|
|
||
|
private:
|
||
15 years ago
|
bool isEmptyTabbarSpace( const TQPoint & ) const;
|
||
15 years ago
|
void resizeTabs( int changedTabIndex = -1 );
|
||
|
void updateTab( int index );
|
||
|
|
||
|
KTabWidgetPrivate *d;
|
||
|
};
|
||
|
|
||
|
#endif
|