|
|
@ -335,7 +335,7 @@ private:
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
TQTabBar::TQTabBar( TQWidget * parent, const char *name )
|
|
|
|
TQTabBar::TQTabBar( TQWidget * parent, const char *name )
|
|
|
|
: TQWidget( parent, name, WNoAutoErase | WNoMousePropagation ), l(NULL)
|
|
|
|
: TQWidget( parent, name, WNoAutoErase | WNoMousePropagation ), l(NULL), hoverTab( 0 )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d = new TQTabPrivate;
|
|
|
|
d = new TQTabPrivate;
|
|
|
|
d->pressed = 0;
|
|
|
|
d->pressed = 0;
|
|
|
@ -583,19 +583,24 @@ void TQTabBar::paint( TQPainter * p, TQTab * t, bool selected ) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQStyle::SFlags flags = TQStyle::Style_Default;
|
|
|
|
TQStyle::SFlags flags = TQStyle::Style_Default;
|
|
|
|
|
|
|
|
|
|
|
|
if (isEnabled() && t->isEnabled())
|
|
|
|
if (isEnabled() && t->isEnabled()) {
|
|
|
|
flags |= TQStyle::Style_Enabled;
|
|
|
|
flags |= TQStyle::Style_Enabled;
|
|
|
|
if (topLevelWidget() == tqApp->activeWindow())
|
|
|
|
}
|
|
|
|
|
|
|
|
if (topLevelWidget() == tqApp->activeWindow()) {
|
|
|
|
flags |= TQStyle::Style_Active;
|
|
|
|
flags |= TQStyle::Style_Active;
|
|
|
|
if ( selected )
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( selected ) {
|
|
|
|
flags |= TQStyle::Style_Selected;
|
|
|
|
flags |= TQStyle::Style_Selected;
|
|
|
|
else if(t == d->pressed)
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (t == d->pressed) {
|
|
|
|
flags |= TQStyle::Style_Sunken;
|
|
|
|
flags |= TQStyle::Style_Sunken;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//selection flags
|
|
|
|
//selection flags
|
|
|
|
if(t->rect().contains(mapFromGlobal(TQCursor::pos())))
|
|
|
|
if (t->rect().contains(mapFromGlobal(TQCursor::pos()))) {
|
|
|
|
flags |= TQStyle::Style_MouseOver;
|
|
|
|
flags |= TQStyle::Style_MouseOver;
|
|
|
|
style().drawControl( TQStyle::CE_TabBarTab, p, this, t->rect(),
|
|
|
|
}
|
|
|
|
colorGroup(), flags, TQStyleOption(t) );
|
|
|
|
style().drawControl( TQStyle::CE_TabBarTab, p, this, t->rect(), colorGroup(), flags, TQStyleOption(t, hoverTab) );
|
|
|
|
|
|
|
|
|
|
|
|
TQRect r( t->r );
|
|
|
|
TQRect r( t->r );
|
|
|
|
p->setFont( font() );
|
|
|
|
p->setFont( font() );
|
|
|
@ -614,12 +619,11 @@ void TQTabBar::paint( TQPainter * p, TQTab * t, bool selected ) const
|
|
|
|
int h = TQMAX(fm.height() + 4, ih );
|
|
|
|
int h = TQMAX(fm.height() + 4, ih );
|
|
|
|
int offset = 3;
|
|
|
|
int offset = 3;
|
|
|
|
#ifdef Q_WS_MAC
|
|
|
|
#ifdef Q_WS_MAC
|
|
|
|
if (::tqt_cast<TQMacStyle *>(&style()))
|
|
|
|
if (::tqt_cast<TQMacStyle *>(&style())) {
|
|
|
|
offset = 0;
|
|
|
|
offset = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
paintLabel( p, TQRect( r.left() + (r.width()-w)/2 - offset,
|
|
|
|
paintLabel( p, TQRect( r.left() + (r.width()-w)/2 - offset, r.top() + (r.height()-h)/2, w, h ), t, t->id == keyboardFocusTab() );
|
|
|
|
r.top() + (r.height()-h)/2,
|
|
|
|
|
|
|
|
w, h ), t, t->id == keyboardFocusTab() );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
@ -654,19 +658,24 @@ void TQTabBar::paintLabel( TQPainter* p, const TQRect& br,
|
|
|
|
|
|
|
|
|
|
|
|
TQStyle::SFlags flags = TQStyle::Style_Default;
|
|
|
|
TQStyle::SFlags flags = TQStyle::Style_Default;
|
|
|
|
|
|
|
|
|
|
|
|
if (isEnabled() && t->isEnabled())
|
|
|
|
if (isEnabled() && t->isEnabled()) {
|
|
|
|
flags |= TQStyle::Style_Enabled;
|
|
|
|
flags |= TQStyle::Style_Enabled;
|
|
|
|
if (has_focus)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (has_focus) {
|
|
|
|
flags |= TQStyle::Style_HasFocus;
|
|
|
|
flags |= TQStyle::Style_HasFocus;
|
|
|
|
if ( selected )
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( selected ) {
|
|
|
|
flags |= TQStyle::Style_Selected;
|
|
|
|
flags |= TQStyle::Style_Selected;
|
|
|
|
else if(t == d->pressed)
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(t == d->pressed) {
|
|
|
|
flags |= TQStyle::Style_Sunken;
|
|
|
|
flags |= TQStyle::Style_Sunken;
|
|
|
|
if(t->rect().contains(mapFromGlobal(TQCursor::pos())))
|
|
|
|
}
|
|
|
|
|
|
|
|
if(t->rect().contains(mapFromGlobal(TQCursor::pos()))) {
|
|
|
|
flags |= TQStyle::Style_MouseOver;
|
|
|
|
flags |= TQStyle::Style_MouseOver;
|
|
|
|
|
|
|
|
}
|
|
|
|
style().drawControl( TQStyle::CE_TabBarLabel, p, this, r,
|
|
|
|
style().drawControl( TQStyle::CE_TabBarLabel, p, this, r,
|
|
|
|
t->isEnabled() ? colorGroup(): palette().disabled(),
|
|
|
|
t->isEnabled() ? colorGroup(): palette().disabled(),
|
|
|
|
flags, TQStyleOption(t) );
|
|
|
|
flags, TQStyleOption(t, hoverTab) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -689,8 +698,9 @@ void TQTabBar::paintEvent( TQPaintEvent * e )
|
|
|
|
t = l->first();
|
|
|
|
t = l->first();
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
TQTab * n = l->next();
|
|
|
|
TQTab * n = l->next();
|
|
|
|
if ( t && t->r.intersects( e->rect() ) )
|
|
|
|
if ( t && t->r.intersects( e->rect() ) ) {
|
|
|
|
paint( buffer.painter(), t, n == 0 );
|
|
|
|
paint( buffer.painter(), t, n == 0 );
|
|
|
|
|
|
|
|
}
|
|
|
|
t = n;
|
|
|
|
t = n;
|
|
|
|
} while ( t != 0 );
|
|
|
|
} while ( t != 0 );
|
|
|
|
|
|
|
|
|
|
|
@ -776,20 +786,39 @@ void TQTabBar::mousePressEvent( TQMouseEvent * e )
|
|
|
|
|
|
|
|
|
|
|
|
void TQTabBar::mouseMoveEvent ( TQMouseEvent *e )
|
|
|
|
void TQTabBar::mouseMoveEvent ( TQMouseEvent *e )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
TQTab *t = selectTab( e->pos() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Repaint hover indicator(s)
|
|
|
|
|
|
|
|
// Also, avoid unnecessary repaints which otherwise would occour on every MouseMove event causing high cpu load
|
|
|
|
|
|
|
|
bool forceRepaint = true;
|
|
|
|
|
|
|
|
if (hoverTab == t) {
|
|
|
|
|
|
|
|
forceRepaint = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
hoverTab = t;
|
|
|
|
|
|
|
|
if (forceRepaint) {
|
|
|
|
|
|
|
|
repaint(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( e->state() != LeftButton ) {
|
|
|
|
if ( e->state() != LeftButton ) {
|
|
|
|
e->ignore();
|
|
|
|
e->ignore();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(style().styleHint( TQStyle::SH_TabBar_SelectMouseType, this ) == TQEvent::MouseButtonRelease) {
|
|
|
|
if(style().styleHint( TQStyle::SH_TabBar_SelectMouseType, this ) == TQEvent::MouseButtonRelease) {
|
|
|
|
TQTab *t = selectTab( e->pos() );
|
|
|
|
|
|
|
|
if(t != d->pressed) {
|
|
|
|
if(t != d->pressed) {
|
|
|
|
if(d->pressed)
|
|
|
|
if (d->pressed) {
|
|
|
|
|
|
|
|
if (!forceRepaint) {
|
|
|
|
repaint(d->pressed->rect(), FALSE);
|
|
|
|
repaint(d->pressed->rect(), FALSE);
|
|
|
|
if((d->pressed = t))
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((d->pressed = t)) {
|
|
|
|
|
|
|
|
if (!forceRepaint) {
|
|
|
|
repaint(t->rect(), FALSE);
|
|
|
|
repaint(t->rect(), FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
\reimp
|
|
|
|
\reimp
|
|
|
@ -797,16 +826,28 @@ void TQTabBar::mouseMoveEvent ( TQMouseEvent *e )
|
|
|
|
|
|
|
|
|
|
|
|
void TQTabBar::mouseReleaseEvent( TQMouseEvent *e )
|
|
|
|
void TQTabBar::mouseReleaseEvent( TQMouseEvent *e )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( e->button() != LeftButton )
|
|
|
|
if (e->button() != LeftButton) {
|
|
|
|
e->ignore();
|
|
|
|
e->ignore();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (d->pressed) {
|
|
|
|
if (d->pressed) {
|
|
|
|
TQTab *t = selectTab( e->pos() ) == d->pressed ? d->pressed : 0;
|
|
|
|
TQTab *t = selectTab( e->pos() ) == d->pressed ? d->pressed : 0;
|
|
|
|
d->pressed = 0;
|
|
|
|
d->pressed = 0;
|
|
|
|
if(t && t->enabled && e->type() == style().styleHint( TQStyle::SH_TabBar_SelectMouseType, this ))
|
|
|
|
if(t && t->enabled && e->type() == style().styleHint( TQStyle::SH_TabBar_SelectMouseType, this )) {
|
|
|
|
setCurrentTab( t );
|
|
|
|
setCurrentTab( t );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TQTabBar::enterEvent( TQEvent * )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
hoverTab = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TQTabBar::leaveEvent( TQEvent * )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
hoverTab = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
\reimp
|
|
|
|
\reimp
|
|
|
@ -1119,7 +1160,7 @@ void TQTabBar::layoutTabs()
|
|
|
|
h += vframe;
|
|
|
|
h += vframe;
|
|
|
|
t->r = TQRect(TQPoint(x, 0), style().sizeFromContents(TQStyle::CT_TabBarTab, this,
|
|
|
|
t->r = TQRect(TQPoint(x, 0), style().sizeFromContents(TQStyle::CT_TabBarTab, this,
|
|
|
|
TQSize( TQMAX( lw + hframe + iw, TQApplication::globalStrut().width() ), h ),
|
|
|
|
TQSize( TQMAX( lw + hframe + iw, TQApplication::globalStrut().width() ), h ),
|
|
|
|
TQStyleOption(t) ));
|
|
|
|
TQStyleOption(t, hoverTab) ));
|
|
|
|
x += t->r.width() - overlap;
|
|
|
|
x += t->r.width() - overlap;
|
|
|
|
r = r.unite( t->r );
|
|
|
|
r = r.unite( t->r );
|
|
|
|
if ( reverse )
|
|
|
|
if ( reverse )
|
|
|
@ -1375,4 +1416,12 @@ void TQTabBar::fontChange( const TQFont & oldFont )
|
|
|
|
TQWidget::fontChange( oldFont );
|
|
|
|
TQWidget::fontChange( oldFont );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
|
|
Returns the tab currently under the mouse pointer, or NULL if no tab is under the cursor
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
TQTab *TQTabBar::mouseHoverTab() const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return hoverTab;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|