From 8e1d13677231dbaef4cdd985df209e2e1ca51ac3 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 16 Oct 2012 16:02:55 -0500 Subject: [PATCH] Use internal Qt hover drawing --- style/lipstik.cpp | 94 ++++++++--------------------------------------- style/lipstik.h | 3 -- 2 files changed, 15 insertions(+), 82 deletions(-) diff --git a/style/lipstik.cpp b/style/lipstik.cpp index 7b4c1a3..4ba5deb 100644 --- a/style/lipstik.cpp +++ b/style/lipstik.cpp @@ -165,9 +165,6 @@ LipstikStyle::LipstikStyle() : KStyle( AllowMenuTransparency, ThreeButtonScrollB kornMode(false), flatMode(false) { - hoverWidget = 0; - hoverTab = 0; - horizontalDots = 0; verticalDots = 0; @@ -1355,7 +1352,7 @@ void LipstikStyle::drawKStylePrimitive(KStylePrimitive kpe, if(!enabled) surfaceFlags |= Is_Disabled; - else if(hoverWidget == widget) { + else if(flags & Style_MouseOver) { surfaceFlags |= Highlight_Right|Highlight_Left; } @@ -1381,7 +1378,7 @@ void LipstikStyle::drawKStylePrimitive(KStylePrimitive kpe, if(!enabled) surfaceFlags |= Is_Disabled; - else if(hoverWidget == widget) + else if(flags & Style_MouseOver) surfaceFlags |= Highlight_Top|Highlight_Bottom; renderSurface(p, TQRect(xcenter-6, ycenter-8, 13, 18), @@ -1510,7 +1507,7 @@ void LipstikStyle::drawKStylePrimitive(KStylePrimitive kpe, if(!enabled) surfaceFlags |= Is_Disabled; - else if(hoverWidget == widget) { + else if(flags & Style_MouseOver) { surfaceFlags |= Highlight_Right|Highlight_Left; } @@ -1535,7 +1532,7 @@ void LipstikStyle::drawKStylePrimitive(KStylePrimitive kpe, if(!enabled) surfaceFlags |= Is_Disabled; - else if(hoverWidget == widget) + else if(flags & Style_MouseOver) surfaceFlags |= Highlight_Top|Highlight_Bottom; renderSurface(p, TQRect(xcenter-6, ycenter-15, 13, 31), @@ -1791,7 +1788,7 @@ void LipstikStyle::drawPrimitive(PrimitiveElement pe, uint surfaceFlags = Draw_Left|Draw_Right|Draw_Top|Draw_Bottom|Is_Horizontal; - if(hoverWidget == p->device()) + if(flags & Style_MouseOver) { scrollbarHighlighted = true; if(horiz) @@ -2050,7 +2047,7 @@ void LipstikStyle::drawPrimitive(PrimitiveElement pe, // -------------- case PE_Splitter: { // highlight on mouse over - TQColor color = (hoverWidget == p->device())?cg.highlight():cg.background(); + TQColor color = (flags & Style_MouseOver)?cg.highlight():cg.background(); //p->fillRect(r, color); if (w > h) { if (h > 4) { @@ -2235,7 +2232,7 @@ void LipstikStyle::drawPrimitive(PrimitiveElement pe, if(_drawToolBarHandle) { if (horiz) { int center = r.left() + (r.width()/2) - 2 ; - if(hoverWidget == p->device()) + if(flags & Style_MouseOver) handleDotColor = cg.highlight(); for(int j = kickerMode?r.top()+1:r.top()+4; j <= r.bottom()-2; j+=4) { @@ -2243,7 +2240,7 @@ void LipstikStyle::drawPrimitive(PrimitiveElement pe, } } else { int center = r.top() + (r.height()/2) - 2 ; - if(hoverWidget == p->device()) + if(flags & Style_MouseOver) handleDotColor = cg.highlight(); for(int j = kickerMode?r.left()+1:r.left()+4; j <= r.right()-2; j+=5) { @@ -2646,7 +2643,7 @@ void LipstikStyle::drawControl(ControlElement element, } bool mouseOver = false; - if (opt.tab() == hoverTab) { + if (opt.tab() == opt.hoverTab()) { mouseOver = true; flags |= Style_MouseOver; } @@ -2681,9 +2678,6 @@ void LipstikStyle::drawControl(ControlElement element, if (button->isFlat() ) flatMode = true; - if (widget == hoverWidget) - flags |= Style_MouseOver; - TQColorGroup g2 = cg; if (isDefault) g2.setColor(TQColorGroup::Background, cg.background().dark(120) ); @@ -3311,7 +3305,7 @@ void LipstikStyle::drawComplexControl(ComplexControl control, surfaceFlags |= Round_UpperRight|Round_BottomRight; } - if ((widget == hoverWidget) || (flags & Style_MouseOver)) { + if (flags & Style_MouseOver) { surfaceFlags |= Is_Highlight; if(editable) surfaceFlags |= Highlight_Left|Highlight_Right; surfaceFlags |= Highlight_Top|Highlight_Bottom; @@ -3335,7 +3329,7 @@ void LipstikStyle::drawComplexControl(ComplexControl control, surfaceFlags |= Round_UpperLeft|Round_BottomLeft; } - if ((widget == hoverWidget) || (flags & Style_MouseOver)) { + if (flags & Style_MouseOver) { surfaceFlags |= Is_Highlight; surfaceFlags |= Highlight_Top|Highlight_Bottom; } @@ -3445,8 +3439,8 @@ void LipstikStyle::drawComplexControl(ComplexControl control, // Its not highly efficient, but im fu***ng tired... if (controls & SC_ToolButton) { // If we're pressed, on, or raised... - if (bflags & (Style_Down | Style_On | Style_Raised) || widget==hoverWidget) { - if ( widget == hoverWidget && tb->parentWidget()->inherits( "KTabWidget" )) { + if (bflags & (Style_Down | Style_On | Style_Raised) || (flags & Style_MouseOver)) { + if ( (flags & Style_MouseOver) && tb->parentWidget()->inherits( "KTabWidget" )) { renderButton(p, r, cg, false, true, false, true, false ); } else { drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, button, cg, bflags, opt); @@ -3560,7 +3554,7 @@ void LipstikStyle::drawComplexControl(ComplexControl control, } else { surfaceFlags |= Round_UpperRight; } - if ((widget == hoverWidget) || (sflags & Style_MouseOver)) { + if (sflags & Style_MouseOver) { surfaceFlags |= Is_Highlight; surfaceFlags |= Highlight_Top|Highlight_Left|Highlight_Right; } @@ -3574,7 +3568,7 @@ void LipstikStyle::drawComplexControl(ComplexControl control, } else { surfaceFlags |= Round_BottomRight; } - if ((widget == hoverWidget) || (sflags & Style_MouseOver)) { + if (sflags & Style_MouseOver) { surfaceFlags |= Is_Highlight; surfaceFlags |= Highlight_Bottom|Highlight_Left|Highlight_Right; } @@ -4000,64 +3994,6 @@ bool LipstikStyle::objectEventHandler( TQStyleControlElementData ceData, Control return false; } - //Hover highlight... use tqt_cast to check if the widget inheits one of the classes. - if ( ::tqqt_cast(obj) || ::tqqt_cast(obj) || - ::tqqt_cast(obj) || ::tqqt_cast(obj) || - ::tqqt_cast(obj) || ::tqqt_cast(obj) || - ::tqqt_cast(obj) || ::tqqt_cast(obj) || - obj->inherits(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING) || obj->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) ) - { - if ((ev->type() == TQEvent::Enter) && TQT_TQWIDGET(obj)->isEnabled()) - { - TQWidget* button = TQT_TQWIDGET(obj); - hoverWidget = button; - button->repaint(false); - } - else if ((ev->type() == TQEvent::Leave) && (TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(hoverWidget)) ) - { - TQWidget* button = TQT_TQWIDGET(obj); - hoverWidget = 0; - button->repaint(false); - } - return false; - } - if ( ::tqqt_cast(obj) ) { - if ((ev->type() == TQEvent::Enter) && TQT_TQWIDGET(obj)->isEnabled()) - { - TQWidget* tabbar = TQT_TQWIDGET(obj); - hoverWidget = tabbar; - hoverTab = 0; - tabbar->repaint(false); - } - else if (ev->type() == TQEvent::MouseMove) - { - TQTabBar *tabbar = dynamic_cast(obj); - TQMouseEvent *me = dynamic_cast(ev); - - if (tabbar && me) { - // avoid unnecessary repaints (which otherwise would occour on every - // MouseMove event causing high cpu load). - - bool repaint = true; - - TQTab *tab = tabbar->selectTab(me->pos() ); - if (hoverTab == tab) - repaint = false; - hoverTab = tab; - - if (repaint) - tabbar->repaint(false); - } - } - else if (ev->type() == TQEvent::Leave) - { - TQWidget* tabbar = TQT_TQWIDGET(obj); - hoverWidget = 0; - hoverTab = 0; - tabbar->repaint(false); - } - return false; - } // Track show events for progress bars if ( _animateProgressBar && ::tqqt_cast(obj) ) { diff --git a/style/lipstik.h b/style/lipstik.h index 98edac9..453f66a 100644 --- a/style/lipstik.h +++ b/style/lipstik.h @@ -278,7 +278,6 @@ protected: virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); - TQWidget* hoverWidget; protected slots: void khtmlWidgetDestroyed(TQObject* w); @@ -340,8 +339,6 @@ private: TQColor _defaultMenuStripeColor; // TQColor _arrowColor; - TQTab *hoverTab; - // track khtml widgets. TQMap khtmlWidgets;