diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-10-16 16:02:16 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-10-16 16:02:16 -0500 |
commit | 2ed8f9ade70bd38a541d7e62e02962a1311aabb5 (patch) | |
tree | e369c4e00f3e1b2b112c3282293290d9dc6441a1 /kstyles/plastik | |
parent | a151a4d477b5f9948ada98155ea9bcca7973748f (diff) | |
download | tdelibs-2ed8f9ade70bd38a541d7e62e02962a1311aabb5.tar.gz tdelibs-2ed8f9ade70bd38a541d7e62e02962a1311aabb5.zip |
Use internal Qt hover widget drawing
Diffstat (limited to 'kstyles/plastik')
-rw-r--r-- | kstyles/plastik/plastik.cpp | 105 | ||||
-rw-r--r-- | kstyles/plastik/plastik.h | 3 |
2 files changed, 11 insertions, 97 deletions
diff --git a/kstyles/plastik/plastik.cpp b/kstyles/plastik/plastik.cpp index 7dfc180ae..f827ca024 100644 --- a/kstyles/plastik/plastik.cpp +++ b/kstyles/plastik/plastik.cpp @@ -156,10 +156,6 @@ PlastikStyle::PlastikStyle() : KStyle( AllowMenuTransparency, ThreeButtonScrollB kornMode(false), flatMode(false) { - hoverWidget = 0; - hoverTab = 0; - - horizontalLine = 0; verticalLine = 0; @@ -1472,7 +1468,7 @@ void PlastikStyle::drawPrimitive(TQ_PrimitiveElement pe, bool horiz = flags & Style_Horizontal; const bool enabled = flags & Style_Enabled; const bool mouseOver = flags & Style_MouseOver; - + bool hasFocus = flags & Style_HasFocus; int x = r.x(); @@ -1835,7 +1831,7 @@ void PlastikStyle::drawPrimitive(TQ_PrimitiveElement pe, // -------------- case PE_Splitter: { // highlight on mouse over - TQColor color = (static_cast<TQPaintDevice*>(static_cast<TQWidget*>(hoverWidget)) == static_cast<TQPaintDevice*>(p->device()))?TQColor(cg.background().light(100+_contrast)):cg.background(); + TQColor color = (mouseOver)?TQColor(cg.background().light(100+_contrast)):cg.background(); p->fillRect(r, color); if (w > h) { if (h > 4) { @@ -2316,8 +2312,9 @@ void PlastikStyle::drawControl(TQ_ControlElement element, const TQTabWidget *tw = (const TQTabWidget*)tb->parent(); // is there a corner widget in the (top) left edge? TQWidget *cw = tw->cornerWidget(TQt::TopLeft); - if(cw) + if(cw) { cornerWidget = true; + } } TQTabBar::Shape tbs = tb->shape(); bool selected = false; @@ -2334,7 +2331,7 @@ void PlastikStyle::drawControl(TQ_ControlElement element, } bool mouseOver = false; - if (opt.tab() == hoverTab) { + if (opt.tab() == opt.hoverTab()) { mouseOver = true; flags |= Style_MouseOver; } @@ -2369,9 +2366,6 @@ void PlastikStyle::drawControl(TQ_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) ); @@ -2872,7 +2866,7 @@ void PlastikStyle::drawComplexControl(TQ_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; @@ -2889,7 +2883,7 @@ void PlastikStyle::drawComplexControl(TQ_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; } @@ -2974,7 +2968,7 @@ void PlastikStyle::drawComplexControl(TQ_ComplexControl control, if (controls & SC_ToolButton) { // If we're pressed, on, or raised... - if (bflags & (Style_Down | Style_On | Style_Raised) || widget==hoverWidget ) { + if (bflags & (Style_Down | Style_On | Style_Raised) || (flags & Style_MouseOver) ) { drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, button, cg, bflags, opt); } else if (tb->parentWidget() && tb->parentWidget()->backgroundPixmap() && @@ -3084,7 +3078,7 @@ void PlastikStyle::drawComplexControl(TQ_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; } @@ -3098,7 +3092,7 @@ void PlastikStyle::drawComplexControl(TQ_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; } @@ -3487,84 +3481,7 @@ bool PlastikStyle::objectEventHandler( TQStyleControlElementData ceData, Control TQObject* obj = reinterpret_cast<TQObject*>(source); if (!obj->isWidgetType() ) return false; - - // focus highlight - if ( ::tqqt_cast<TQLineEdit*>(obj) ) { - TQWidget* widget = TQT_TQWIDGET(obj); - - if ( ::tqqt_cast<TQSpinWidget*>(widget->parentWidget()) ) - { - TQWidget* spinbox = widget->parentWidget(); - if ((ev->type() == TQEvent::FocusIn) || (ev->type() == TQEvent::FocusOut)) - { - spinbox->repaint(false); - } - return false; - } - - if ((ev->type() == TQEvent::FocusIn) || (ev->type() == TQEvent::FocusOut)) - { - widget->repaint(false); - } - return false; - } - - //Hover highlight... use tqqt_cast to check if the widget inheits one of the classes. - if ( ::tqqt_cast<TQPushButton*>(obj) || ::tqqt_cast<TQComboBox*>(obj) || - ::tqqt_cast<TQSpinWidget*>(obj) || ::tqqt_cast<TQCheckBox*>(obj) || - ::tqqt_cast<TQRadioButton*>(obj) || ::tqqt_cast<TQToolButton*>(obj) || 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<TQTabBar*>(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<TQTabBar*>(obj); - TQMouseEvent *me = dynamic_cast<TQMouseEvent*>(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<TQProgressBar*>(obj) ) { diff --git a/kstyles/plastik/plastik.h b/kstyles/plastik/plastik.h index 995bb7c85..fb8c0a2de 100644 --- a/kstyles/plastik/plastik.h +++ b/kstyles/plastik/plastik.h @@ -268,7 +268,6 @@ protected: virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); - TQWidget* hoverWidget; protected slots: void khtmlWidgetDestroyed(TQObject* w); @@ -301,8 +300,6 @@ private: TQColor _focusHighlightColor; TQColor _checkMarkColor; - TQTab *hoverTab; - // track khtml widgets. TQMap<const TQWidget*,bool> khtmlWidgets; |