summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-10-16 15:40:54 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-10-16 15:40:54 -0500
commit0e044c1a92745f8508f5813efc9709a280583d11 (patch)
tree67963c1b752b6fa680f9123b73fca2c703b7c61b /src/widgets
parentff2caed1b8e1bea513172d48d07b13f53b73a9de (diff)
downloadtqt3-0e044c1a92745f8508f5813efc9709a280583d11.tar.gz
tqt3-0e044c1a92745f8508f5813efc9709a280583d11.zip
Automated update from Qt3
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/ntqtabbar.h10
-rw-r--r--src/widgets/qcombobox.cpp2
-rw-r--r--src/widgets/qprogressbar.cpp2
-rw-r--r--src/widgets/qpushbutton.cpp2
-rw-r--r--src/widgets/qscrollbar.cpp2
-rw-r--r--src/widgets/qslider.cpp5
-rw-r--r--src/widgets/qspinwidget.cpp2
-rw-r--r--src/widgets/qsplitter.cpp8
-rw-r--r--src/widgets/qtabbar.cpp237
-rw-r--r--src/widgets/qtextedit.cpp2
-rw-r--r--src/widgets/qtoolbutton.cpp2
11 files changed, 176 insertions, 98 deletions
diff --git a/src/widgets/ntqtabbar.h b/src/widgets/ntqtabbar.h
index 2172f8be..a8271308 100644
--- a/src/widgets/ntqtabbar.h
+++ b/src/widgets/ntqtabbar.h
@@ -178,6 +178,16 @@ private: // Disabled copy constructor and operator=
TQTabBar( const TQTabBar & );
TQTabBar& operator=( const TQTabBar & );
#endif
+
+protected:
+ void enterEvent ( TQEvent * );
+ void leaveEvent ( TQEvent * );
+
+private:
+ TQTab *hoverTab;
+
+public:
+ TQTab *mouseHoverTab() const;
};
diff --git a/src/widgets/qcombobox.cpp b/src/widgets/qcombobox.cpp
index c595d75e..9cbb6960 100644
--- a/src/widgets/qcombobox.cpp
+++ b/src/widgets/qcombobox.cpp
@@ -1244,6 +1244,8 @@ void TQComboBox::paintEvent( TQPaintEvent * )
flags |= TQStyle::Style_Enabled;
if (hasFocus())
flags |= TQStyle::Style_HasFocus;
+ if (hasMouse())
+ flags |= TQStyle::Style_MouseOver;
if ( width() < 5 || height() < 5 ) {
qDrawShadePanel( &p, rect(), g, FALSE, 2,
diff --git a/src/widgets/qprogressbar.cpp b/src/widgets/qprogressbar.cpp
index 09d6befd..7a4ec383 100644
--- a/src/widgets/qprogressbar.cpp
+++ b/src/widgets/qprogressbar.cpp
@@ -390,6 +390,8 @@ void TQProgressBar::drawContents( TQPainter *p )
flags |= TQStyle::Style_Enabled;
if (hasFocus())
flags |= TQStyle::Style_HasFocus;
+ if (hasMouse())
+ flags |= TQStyle::Style_MouseOver;
style().drawControl(TQStyle::CE_ProgressBarGroove, buffer.painter(), this,
TQStyle::visualRect(style().subRect(TQStyle::SR_ProgressBarGroove, this), this ),
diff --git a/src/widgets/qpushbutton.cpp b/src/widgets/qpushbutton.cpp
index 3e3925ab..e43ff240 100644
--- a/src/widgets/qpushbutton.cpp
+++ b/src/widgets/qpushbutton.cpp
@@ -555,6 +555,8 @@ void TQPushButton::drawButton( TQPainter *paint )
flags |= TQStyle::Style_Raised;
if (isDefault())
flags |= TQStyle::Style_ButtonDefault;
+ if (hasMouse())
+ flags |= TQStyle::Style_MouseOver;
style().drawControl(TQStyle::CE_PushButton, paint, this, rect(), colorGroup(), flags);
drawButtonLabel( paint );
diff --git a/src/widgets/qscrollbar.cpp b/src/widgets/qscrollbar.cpp
index 18d62acd..ecaa3b3f 100644
--- a/src/widgets/qscrollbar.cpp
+++ b/src/widgets/qscrollbar.cpp
@@ -940,6 +940,8 @@ void TQScrollBar::drawControls( uint controls, uint activeControl,
flags |= TQStyle::Style_Enabled;
if (hasFocus())
flags |= TQStyle::Style_HasFocus;
+ if (hasMouse())
+ flags |= TQStyle::Style_MouseOver;
if ( orientation() == Horizontal )
flags |= TQStyle::Style_Horizontal;
diff --git a/src/widgets/qslider.cpp b/src/widgets/qslider.cpp
index fd9dd15b..fd8c3658 100644
--- a/src/widgets/qslider.cpp
+++ b/src/widgets/qslider.cpp
@@ -415,10 +415,13 @@ void TQSlider::paintEvent( TQPaintEvent * )
flags |= TQStyle::Style_Enabled;
if (hasFocus())
flags |= TQStyle::Style_HasFocus;
+ if (hasMouse())
+ flags |= TQStyle::Style_MouseOver;
TQStyle::SCFlags sub = TQStyle::SC_SliderGroove | TQStyle::SC_SliderHandle;
- if ( tickmarks() != NoMarks )
+ if ( tickmarks() != NoMarks ) {
sub |= TQStyle::SC_SliderTickmarks;
+ }
style().drawComplexControl( TQStyle::CC_Slider, &p, this, rect(), colorGroup(),
flags, sub, state == Dragging ? TQStyle::SC_SliderHandle : TQStyle::SC_None );
diff --git a/src/widgets/qspinwidget.cpp b/src/widgets/qspinwidget.cpp
index af2e1988..9c0b2cbb 100644
--- a/src/widgets/qspinwidget.cpp
+++ b/src/widgets/qspinwidget.cpp
@@ -323,6 +323,8 @@ void TQSpinWidget::paintEvent( TQPaintEvent * )
TQStyle::SFlags flags = TQStyle::Style_Default;
if (isEnabled())
flags |= TQStyle::Style_Enabled;
+ if (hasMouse())
+ flags |= TQStyle::Style_MouseOver;
if (hasFocus() || (focusProxy() && focusProxy()->hasFocus()))
flags |= TQStyle::Style_HasFocus;
diff --git a/src/widgets/qsplitter.cpp b/src/widgets/qsplitter.cpp
index cedb498b..f179a7ae 100644
--- a/src/widgets/qsplitter.cpp
+++ b/src/widgets/qsplitter.cpp
@@ -141,11 +141,15 @@ void TQSplitterHandle::mouseReleaseEvent( TQMouseEvent *e )
void TQSplitterHandle::paintEvent( TQPaintEvent * )
{
+ TQStyle::SFlags flags = (orientation() == Horizontal ? TQStyle::Style_Horizontal : 0);
+ if (hasMouse()) {
+ flags |= TQStyle::Style_MouseOver;
+ }
+
TQPainter p( this );
parentWidget()->style().drawPrimitive( TQStyle::PE_Splitter, &p, rect(),
colorGroup(),
- (orientation() == Horizontal ?
- TQStyle::Style_Horizontal : 0) );
+ flags );
}
TQCOORD TQSplitterLayoutStruct::getSizer( Orientation orient )
diff --git a/src/widgets/qtabbar.cpp b/src/widgets/qtabbar.cpp
index caa8e7d1..db08012c 100644
--- a/src/widgets/qtabbar.cpp
+++ b/src/widgets/qtabbar.cpp
@@ -335,7 +335,7 @@ private:
*/
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->pressed = 0;
@@ -581,45 +581,49 @@ TQSize TQTabBar::minimumSizeHint() const
void TQTabBar::paint( TQPainter * p, TQTab * t, bool selected ) const
{
- TQStyle::SFlags flags = TQStyle::Style_Default;
-
- if (isEnabled() && t->isEnabled())
- flags |= TQStyle::Style_Enabled;
- if (topLevelWidget() == tqApp->activeWindow())
- flags |= TQStyle::Style_Active;
- if ( selected )
- flags |= TQStyle::Style_Selected;
- else if(t == d->pressed)
- flags |= TQStyle::Style_Sunken;
- //selection flags
- if(t->rect().contains(mapFromGlobal(TQCursor::pos())))
- flags |= TQStyle::Style_MouseOver;
- style().drawControl( TQStyle::CE_TabBarTab, p, this, t->rect(),
- colorGroup(), flags, TQStyleOption(t) );
-
- TQRect r( t->r );
- p->setFont( font() );
-
- int iw = 0;
- int ih = 0;
- if ( t->iconset != 0 ) {
- iw = t->iconset->pixmap( TQIconSet::Small, TQIconSet::Normal ).width() + 4;
- ih = t->iconset->pixmap( TQIconSet::Small, TQIconSet::Normal ).height();
- }
- TQFontMetrics fm = p->fontMetrics();
- int fw = fm.width( t->label );
- fw -= t->label.contains('&') * fm.width('&');
- fw += t->label.contains("&&") * fm.width('&');
- int w = iw + fw + 4;
- int h = TQMAX(fm.height() + 4, ih );
- int offset = 3;
+ TQStyle::SFlags flags = TQStyle::Style_Default;
+
+ if (isEnabled() && t->isEnabled()) {
+ flags |= TQStyle::Style_Enabled;
+ }
+ if (topLevelWidget() == tqApp->activeWindow()) {
+ flags |= TQStyle::Style_Active;
+ }
+ if ( selected ) {
+ flags |= TQStyle::Style_Selected;
+ }
+ else if (t == d->pressed) {
+ flags |= TQStyle::Style_Sunken;
+ }
+
+ //selection flags
+ if (t->rect().contains(mapFromGlobal(TQCursor::pos()))) {
+ flags |= TQStyle::Style_MouseOver;
+ }
+ style().drawControl( TQStyle::CE_TabBarTab, p, this, t->rect(), colorGroup(), flags, TQStyleOption(t, hoverTab) );
+
+ TQRect r( t->r );
+ p->setFont( font() );
+
+ int iw = 0;
+ int ih = 0;
+ if ( t->iconset != 0 ) {
+ iw = t->iconset->pixmap( TQIconSet::Small, TQIconSet::Normal ).width() + 4;
+ ih = t->iconset->pixmap( TQIconSet::Small, TQIconSet::Normal ).height();
+ }
+ TQFontMetrics fm = p->fontMetrics();
+ int fw = fm.width( t->label );
+ fw -= t->label.contains('&') * fm.width('&');
+ fw += t->label.contains("&&") * fm.width('&');
+ int w = iw + fw + 4;
+ int h = TQMAX(fm.height() + 4, ih );
+ int offset = 3;
#ifdef Q_WS_MAC
- if (::tqt_cast<TQMacStyle *>(&style()))
- offset = 0;
+ if (::tqt_cast<TQMacStyle *>(&style())) {
+ offset = 0;
+ }
#endif
- paintLabel( p, TQRect( r.left() + (r.width()-w)/2 - offset,
- r.top() + (r.height()-h)/2,
- w, h ), t, t->id == keyboardFocusTab() );
+ paintLabel( p, TQRect( r.left() + (r.width()-w)/2 - offset, r.top() + (r.height()-h)/2, w, h ), t, t->id == keyboardFocusTab() );
}
/*!
@@ -630,43 +634,48 @@ void TQTabBar::paint( TQPainter * p, TQTab * t, bool selected ) const
void TQTabBar::paintLabel( TQPainter* p, const TQRect& br,
TQTab* t, bool has_focus ) const
{
- TQRect r = br;
- bool selected = currentTab() == t->id;
- if ( t->iconset) {
- // the tab has an iconset, draw it in the right mode
- TQIconSet::Mode mode = (t->enabled && isEnabled())
- ? TQIconSet::Normal : TQIconSet::Disabled;
- if ( mode == TQIconSet::Normal && has_focus )
- mode = TQIconSet::Active;
- TQPixmap pixmap = t->iconset->pixmap( TQIconSet::Small, mode );
- int pixw = pixmap.width();
- int pixh = pixmap.height();
- r.setLeft( r.left() + pixw + 4 );
- r.setRight( r.right() + 2 );
-
- int xoff = 0, yoff = 0;
- if(!selected) {
- xoff = style().pixelMetric(TQStyle::PM_TabBarTabShiftHorizontal, this);
- yoff = style().pixelMetric(TQStyle::PM_TabBarTabShiftVertical, this);
+ TQRect r = br;
+ bool selected = currentTab() == t->id;
+ if ( t->iconset) {
+ // the tab has an iconset, draw it in the right mode
+ TQIconSet::Mode mode = (t->enabled && isEnabled())
+ ? TQIconSet::Normal : TQIconSet::Disabled;
+ if ( mode == TQIconSet::Normal && has_focus )
+ mode = TQIconSet::Active;
+ TQPixmap pixmap = t->iconset->pixmap( TQIconSet::Small, mode );
+ int pixw = pixmap.width();
+ int pixh = pixmap.height();
+ r.setLeft( r.left() + pixw + 4 );
+ r.setRight( r.right() + 2 );
+
+ int xoff = 0, yoff = 0;
+ if(!selected) {
+ xoff = style().pixelMetric(TQStyle::PM_TabBarTabShiftHorizontal, this);
+ yoff = style().pixelMetric(TQStyle::PM_TabBarTabShiftVertical, this);
+ }
+ p->drawPixmap( br.left() + 2 + xoff, br.center().y()-pixh/2 + yoff, pixmap );
}
- p->drawPixmap( br.left() + 2 + xoff, br.center().y()-pixh/2 + yoff, pixmap );
- }
- TQStyle::SFlags flags = TQStyle::Style_Default;
-
- if (isEnabled() && t->isEnabled())
- flags |= TQStyle::Style_Enabled;
- if (has_focus)
- flags |= TQStyle::Style_HasFocus;
- if ( selected )
- flags |= TQStyle::Style_Selected;
- else if(t == d->pressed)
- flags |= TQStyle::Style_Sunken;
- if(t->rect().contains(mapFromGlobal(TQCursor::pos())))
- flags |= TQStyle::Style_MouseOver;
- style().drawControl( TQStyle::CE_TabBarLabel, p, this, r,
- t->isEnabled() ? colorGroup(): palette().disabled(),
- flags, TQStyleOption(t) );
+ TQStyle::SFlags flags = TQStyle::Style_Default;
+
+ if (isEnabled() && t->isEnabled()) {
+ flags |= TQStyle::Style_Enabled;
+ }
+ if (has_focus) {
+ flags |= TQStyle::Style_HasFocus;
+ }
+ if ( selected ) {
+ flags |= TQStyle::Style_Selected;
+ }
+ else if(t == d->pressed) {
+ flags |= TQStyle::Style_Sunken;
+ }
+ if(t->rect().contains(mapFromGlobal(TQCursor::pos()))) {
+ flags |= TQStyle::Style_MouseOver;
+ }
+ style().drawControl( TQStyle::CE_TabBarLabel, p, this, r,
+ t->isEnabled() ? colorGroup(): palette().disabled(),
+ flags, TQStyleOption(t, hoverTab) );
}
@@ -689,8 +698,9 @@ void TQTabBar::paintEvent( TQPaintEvent * e )
t = l->first();
do {
TQTab * n = l->next();
- if ( t && t->r.intersects( e->rect() ) )
+ if ( t && t->r.intersects( e->rect() ) ) {
paint( buffer.painter(), t, n == 0 );
+ }
t = n;
} while ( t != 0 );
@@ -776,19 +786,38 @@ void TQTabBar::mousePressEvent( TQMouseEvent * e )
void TQTabBar::mouseMoveEvent ( TQMouseEvent *e )
{
- if ( e->state() != LeftButton ) {
- e->ignore();
- return;
- }
- if(style().styleHint( TQStyle::SH_TabBar_SelectMouseType, this ) == TQEvent::MouseButtonRelease) {
TQTab *t = selectTab( e->pos() );
- if(t != d->pressed) {
- if(d->pressed)
- repaint(d->pressed->rect(), FALSE);
- if((d->pressed = t))
- repaint(t->rect(), FALSE);
+
+ // 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 ) {
+ e->ignore();
+ return;
+ }
+
+ if(style().styleHint( TQStyle::SH_TabBar_SelectMouseType, this ) == TQEvent::MouseButtonRelease) {
+ if(t != d->pressed) {
+ if (d->pressed) {
+ if (!forceRepaint) {
+ repaint(d->pressed->rect(), FALSE);
+ }
+ }
+ if ((d->pressed = t)) {
+ if (!forceRepaint) {
+ repaint(t->rect(), FALSE);
+ }
+ }
+ }
}
- }
}
/*!
@@ -797,16 +826,28 @@ void TQTabBar::mouseMoveEvent ( TQMouseEvent *e )
void TQTabBar::mouseReleaseEvent( TQMouseEvent *e )
{
- if ( e->button() != LeftButton )
- e->ignore();
- if(d->pressed) {
- TQTab *t = selectTab( e->pos() ) == d->pressed ? d->pressed : 0;
- d->pressed = 0;
- if(t && t->enabled && e->type() == style().styleHint( TQStyle::SH_TabBar_SelectMouseType, this ))
- setCurrentTab( t );
- }
+ if (e->button() != LeftButton) {
+ e->ignore();
+ }
+
+ if (d->pressed) {
+ TQTab *t = selectTab( e->pos() ) == d->pressed ? d->pressed : 0;
+ d->pressed = 0;
+ if(t && t->enabled && e->type() == style().styleHint( TQStyle::SH_TabBar_SelectMouseType, this )) {
+ setCurrentTab( t );
+ }
+ }
}
+void TQTabBar::enterEvent( TQEvent * )
+{
+ hoverTab = 0;
+}
+
+void TQTabBar::leaveEvent( TQEvent * )
+{
+ hoverTab = 0;
+}
/*!
\reimp
@@ -1119,7 +1160,7 @@ void TQTabBar::layoutTabs()
h += vframe;
t->r = TQRect(TQPoint(x, 0), style().sizeFromContents(TQStyle::CT_TabBarTab, this,
TQSize( TQMAX( lw + hframe + iw, TQApplication::globalStrut().width() ), h ),
- TQStyleOption(t) ));
+ TQStyleOption(t, hoverTab) ));
x += t->r.width() - overlap;
r = r.unite( t->r );
if ( reverse )
@@ -1375,4 +1416,12 @@ void TQTabBar::fontChange( const TQFont & 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
diff --git a/src/widgets/qtextedit.cpp b/src/widgets/qtextedit.cpp
index 3475b2bf..fa480edc 100644
--- a/src/widgets/qtextedit.cpp
+++ b/src/widgets/qtextedit.cpp
@@ -1123,7 +1123,7 @@ bool TQTextEdit::event( TQEvent *e )
{
if ( e->type() == TQEvent::AccelOverride && !isReadOnly() ) {
TQKeyEvent* ke = (TQKeyEvent*) e;
- switch(ke->state()) {
+ switch((int)(ke->state())) {
case NoButton:
case Keypad:
case ShiftButton:
diff --git a/src/widgets/qtoolbutton.cpp b/src/widgets/qtoolbutton.cpp
index e7f7e6db..1912bebf 100644
--- a/src/widgets/qtoolbutton.cpp
+++ b/src/widgets/qtoolbutton.cpp
@@ -484,6 +484,8 @@ void TQToolButton::drawButton( TQPainter * p )
flags |= TQStyle::Style_Down;
if (isOn())
flags |= TQStyle::Style_On;
+ if (hasMouse())
+ flags |= TQStyle::Style_MouseOver;
if (autoRaise()) {
flags |= TQStyle::Style_AutoRaise;
if (uses3D()) {