summaryrefslogtreecommitdiffstats
path: root/kstyles
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2012-10-16 16:02:16 -0500
committerTimothy Pearson <[email protected]>2012-10-16 16:02:16 -0500
commit2ed8f9ade70bd38a541d7e62e02962a1311aabb5 (patch)
treee369c4e00f3e1b2b112c3282293290d9dc6441a1 /kstyles
parenta151a4d477b5f9948ada98155ea9bcca7973748f (diff)
downloadtdelibs-2ed8f9ade70bd38a541d7e62e02962a1311aabb5.tar.gz
tdelibs-2ed8f9ade70bd38a541d7e62e02962a1311aabb5.zip
Use internal Qt hover widget drawing
Diffstat (limited to 'kstyles')
-rw-r--r--kstyles/asteroid/asteroid.cpp16
-rw-r--r--kstyles/highcolor/highcolor.cpp38
-rw-r--r--kstyles/highcolor/highcolor.h1
-rw-r--r--kstyles/highcontrast/highcontrast.cpp53
-rw-r--r--kstyles/highcontrast/highcontrast.h2
-rw-r--r--kstyles/keramik/keramik.cpp31
-rw-r--r--kstyles/keramik/keramik.h3
-rw-r--r--kstyles/plastik/plastik.cpp105
-rw-r--r--kstyles/plastik/plastik.h3
9 files changed, 32 insertions, 220 deletions
diff --git a/kstyles/asteroid/asteroid.cpp b/kstyles/asteroid/asteroid.cpp
index ca93f0b37..7f06b2ee8 100644
--- a/kstyles/asteroid/asteroid.cpp
+++ b/kstyles/asteroid/asteroid.cpp
@@ -2615,16 +2615,12 @@ void AsteroidStyle::paletteChanged()
bool AsteroidStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e )
{
- if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
- TQObject* o = reinterpret_cast<TQObject*>(source);
- /* Win2K has this interesting behaviour where it sets the current
- default button to whatever pushbutton the user presses the mouse
- on. I _think_ this emulates that properly. -clee */
- if (o->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) {
- if (e->type() == TQEvent::MouseButtonPress) {
- TQPushButton *pb = dynamic_cast<TQPushButton *>(o);
- pb->setDefault(TRUE);
- }
+ /* Win2K has this interesting behaviour where it sets the current
+ default button to whatever pushbutton the user presses the mouse
+ on. I _think_ this emulates that properly. -clee */
+ if (ceData.widgetObjectTypes.contains(TQPUSHBUTTON_OBJECT_NAME_STRING)) {
+ if (e->type() == TQEvent::MouseButtonPress) {
+ widgetActionRequest(ceData, elementFlags, source, WAR_SetDefault);
}
}
diff --git a/kstyles/highcolor/highcolor.cpp b/kstyles/highcolor/highcolor.cpp
index bd17b3dfc..06de67bd6 100644
--- a/kstyles/highcolor/highcolor.cpp
+++ b/kstyles/highcolor/highcolor.cpp
@@ -179,7 +179,6 @@ HighColorStyle::HighColorStyle( StyleType styleType )
type = styleType;
highcolor = (type == HighColor && TQPixmap::defaultDepth() > 8);
gDict.setAutoDelete(true);
- hoverWidget = 0L;
selectionBackground = false;
}
@@ -1121,9 +1120,6 @@ void HighColorStyle::drawControl( TQ_ControlElement element,
// PUSHBUTTON
// -------------------------------------------------------------------
case CE_PushButton: {
- if ( widget == hoverWidget )
- flags |= Style_MouseOver;
-
if ( type != HighColor ) {
TQPushButton *button = (TQPushButton*) widget;
TQRect br = r;
@@ -1971,31 +1967,22 @@ bool HighColorStyle::objectEventHandler( TQStyleControlElementData ceData, Contr
if (KStyle::objectEventHandler( ceData, elementFlags, source, event ))
return true;
- if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
+ TQToolBar* toolbar;
+
+ if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING))
+ {
TQObject* object = reinterpret_cast<TQObject*>(source);
- TQToolBar* toolbar;
-
- // Handle push button hover effects.
- TQPushButton* button = dynamic_cast<TQPushButton*>(object);
- if ( button )
- {
- if ( (event->type() == TQEvent::Enter) &&
- (button->isEnabled()) ) {
- hoverWidget = button;
- button->repaint( false );
- }
- else if ( (event->type() == TQEvent::Leave) &&
- (TQT_BASE_OBJECT(object) == TQT_BASE_OBJECT(hoverWidget)) ) {
- hoverWidget = 0L;
- button->repaint( false );
- }
- } else if ( object->parent() && !qstrcmp( object->name(), kdeToolbarWidget ) )
+ if ( object->parent() && !qstrcmp( object->name(), kdeToolbarWidget ) )
{
// Draw a gradient background for custom widgets in the toolbar
// that have specified a "kde toolbar widget" name.
+ // FIXME
+ // This currently requires direct widget access
+ // Is there any way to do this without it?
if (event->type() == TQEvent::Paint ) {
+
// Find the top-level toolbar of this widget, since it may be nested in other
// widgets that are on the toolbar.
TQWidget *widget = TQT_TQWIDGET(object);
@@ -2023,11 +2010,16 @@ bool HighColorStyle::objectEventHandler( TQStyleControlElementData ceData, Contr
return false; // Now draw the contents
}
} else if ( object->parent() &&
- (toolbar = dynamic_cast<TQToolBar*>(object->parent())) )
+ (toolbar = dynamic_cast<TQToolBar*>(object->parent())) )
{
// We need to override the paint event to draw a
// gradient on a QToolBarExtensionWidget.
+ // FIXME
+ // This currently requires direct widget access
+ // Is there any way to do this without it?
+
if ( event->type() == TQEvent::Paint ) {
+
TQWidget *widget = TQT_TQWIDGET(object);
TQRect wr = widget->rect(), tr = toolbar->rect();
TQPainter p( widget );
diff --git a/kstyles/highcolor/highcolor.h b/kstyles/highcolor/highcolor.h
index 043441f95..461902403 100644
--- a/kstyles/highcolor/highcolor.h
+++ b/kstyles/highcolor/highcolor.h
@@ -171,7 +171,6 @@ class HighColorStyle : public KStyle
int pwidth=-1,
int pheight=-1 ) const;
- TQWidget *hoverWidget;
StyleType type;
bool highcolor;
mutable bool selectionBackground;
diff --git a/kstyles/highcontrast/highcontrast.cpp b/kstyles/highcontrast/highcontrast.cpp
index 543b71d0f..7b6ed4a9e 100644
--- a/kstyles/highcontrast/highcontrast.cpp
+++ b/kstyles/highcontrast/highcontrast.cpp
@@ -118,7 +118,6 @@ HighContrastStyle::HighContrastStyle()
TQSettings settings;
settings.beginGroup("/highcontraststyle/Settings/");
bool useWideLines = settings.readBoolEntry("wideLines", false);
- hoverWidget = 0L;
basicLineWidth = useWideLines ? 4 : 2;
}
@@ -665,9 +664,6 @@ void HighContrastStyle::drawKStylePrimitive (KStylePrimitive kpe,
const TQStyleOption &opt,
const TQWidget* widget ) const
{
- if ( widget == hoverWidget )
- flags |= Style_MouseOver;
-
switch ( kpe )
{
// TOOLBAR HANDLE
@@ -760,9 +756,6 @@ void HighContrastStyle::drawControl (TQ_ControlElement element,
const TQStyleOption& opt,
const TQWidget *widget ) const
{
- if ( widget == hoverWidget )
- flags |= Style_MouseOver;
-
switch (element)
{
// TABS
@@ -1213,9 +1206,6 @@ void HighContrastStyle::drawComplexControl (TQ_ComplexControl control,
const TQStyleOption& opt,
const TQWidget *widget ) const
{
- if ( widget == hoverWidget )
- flags |= Style_MouseOver;
-
switch(control)
{
// COMBOBOX
@@ -1830,49 +1820,6 @@ TQRect HighContrastStyle::subRect (SubRect subrect, const TQStyleControlElementD
bool HighContrastStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *event )
{
- if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
- TQObject* object = reinterpret_cast<TQObject*>(source);
-
- TQWidget* widget = dynamic_cast<TQWidget*>(object);
- if (widget)
- {
- // Handle hover effects.
- if (event->type() == TQEvent::Enter
- && (widget->inherits (TQBUTTON_OBJECT_NAME_STRING)
- || widget->inherits (TQCOMBOBOX_OBJECT_NAME_STRING)
- || widget->inherits (TQSPINWIDGET_OBJECT_NAME_STRING)))
- {
- hoverWidget = widget;
- widget->repaint (false);
- }
- else if (event->type() == TQEvent::Leave
- && (widget->inherits (TQBUTTON_OBJECT_NAME_STRING)
- || widget->inherits (TQCOMBOBOX_OBJECT_NAME_STRING)
- || widget->inherits (TQSPINWIDGET_OBJECT_NAME_STRING)))
- {
- if (TQT_BASE_OBJECT(object) == TQT_BASE_OBJECT(hoverWidget))
- hoverWidget = 0L;
- widget->repaint (false);
- }
- // Make sure the focus rectangle is shown correctly.
- else if (event->type() == TQEvent::FocusIn || event->type() == TQEvent::FocusOut)
- {
- TQWidget* widgetparent = dynamic_cast<TQWidget*>(widget->parent());
- while (widgetparent
- && ! widgetparent->inherits (TQCOMBOBOX_OBJECT_NAME_STRING)
- && ! widgetparent->inherits (TQSPINWIDGET_OBJECT_NAME_STRING))
- {
- widgetparent = dynamic_cast<TQWidget*>(widgetparent->parent());
- }
-
- if (widgetparent)
- widgetparent->repaint (false);
- else
- widget->repaint (false);
- }
- }
- }
-
return KStyle::objectEventHandler (ceData, elementFlags, source, event);
}
diff --git a/kstyles/highcontrast/highcontrast.h b/kstyles/highcontrast/highcontrast.h
index 509d6552a..56470993a 100644
--- a/kstyles/highcontrast/highcontrast.h
+++ b/kstyles/highcontrast/highcontrast.h
@@ -152,8 +152,6 @@ class HighContrastStyle : public KStyle
protected:
virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
- TQWidget *hoverWidget;
-
private:
void setColorsNormal (TQPainter* p, const TQColorGroup& cg, int flags = Style_Enabled, int highlight = Style_Down|Style_MouseOver) const;
void setColorsButton (TQPainter* p, const TQColorGroup& cg, int flags = Style_Enabled, int highlight = Style_Down|Style_MouseOver) const;
diff --git a/kstyles/keramik/keramik.cpp b/kstyles/keramik/keramik.cpp
index af9866c2f..02f720636 100644
--- a/kstyles/keramik/keramik.cpp
+++ b/kstyles/keramik/keramik.cpp
@@ -284,7 +284,6 @@ KeramikStyle::KeramikStyle()
toolbarBlendWidget(0), titleBarMode(None), flatMode(false), customScrollMode(false), kickerMode(false)
{
forceSmallMode = false;
- hoverWidget = 0;
TQSettings settings;
@@ -1368,9 +1367,6 @@ void KeramikStyle::drawControl( TQ_ControlElement element,
if (isFormWidget(btn))
formMode = true;
- if ( widget == hoverWidget )
- flags |= Style_MouseOver;
-
if ( btn->isFlat( ) )
flatMode = true;
@@ -2037,9 +2033,6 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
if (toolbarMode)
toolbarBlendWidget = widget;
- if ( widget == hoverWidget )
- flags |= Style_MouseOver;
-
drawPrimitive( PE_ButtonCommand, p2, ceData, elementFlags, br, cg, flags );
toolbarBlendWidget = 0;
@@ -2259,10 +2252,6 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
if (active & SC_ToolButtonMenu)
mflags |= Style_Down;
- if ( widget == hoverWidget )
- bflags |= Style_MouseOver;
-
-
if (onToolbar && static_cast<TQToolBar*>(TQT_TQWIDGET(widget->parent()))->orientation() == Qt::Horizontal)
bflags |= Style_Horizontal;
@@ -2781,26 +2770,6 @@ bool KeramikStyle::objectEventHandler( TQStyleControlElementData ceData, Control
if ( !object->isWidgetType() ) return false;
- //Clear hover highlight when needed
- if ( (event->type() == TQEvent::Leave) && (TQT_BASE_OBJECT(object) == TQT_BASE_OBJECT(hoverWidget)) )
- {
- TQWidget* button = TQT_TQWIDGET(object);
- hoverWidget = 0;
- button->repaint( false );
- return false;
- }
-
- //Hover highlight on buttons, toolbuttons and combos
- if ( ::tqqt_cast<TQPushButton*>(object) || ::tqqt_cast<TQComboBox*>(object) || ::tqqt_cast<TQToolButton*>(object) )
- {
- if (event->type() == TQEvent::Enter && TQT_TQWIDGET(object)->isEnabled() )
- {
- hoverWidget = TQT_TQWIDGET(object);
- hoverWidget->repaint( false );
- }
- return false;
- }
-
//Combo line edits get special frames
if ( event->type() == TQEvent::Paint && ::tqqt_cast<TQLineEdit*>(object) )
{
diff --git a/kstyles/keramik/keramik.h b/kstyles/keramik/keramik.h
index dd5ad6b31..d40b21dda 100644
--- a/kstyles/keramik/keramik.h
+++ b/kstyles/keramik/keramik.h
@@ -204,9 +204,6 @@ private:
return maskMode?Keramik::TilePainter::PaintMask : Keramik::TilePainter::PaintFullBlend;
}
- TQWidget* hoverWidget;
-
-
bool kickerMode;
// For progress bar animation
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;