summaryrefslogtreecommitdiffstats
path: root/kstyles
diff options
context:
space:
mode:
Diffstat (limited to 'kstyles')
-rw-r--r--kstyles/asteroid/asteroid.cpp88
-rw-r--r--kstyles/asteroid/asteroid.h11
-rw-r--r--kstyles/highcolor/highcolor.cpp202
-rw-r--r--kstyles/highcolor/highcolor.h7
-rw-r--r--kstyles/highcontrast/highcontrast.cpp113
-rw-r--r--kstyles/highcontrast/highcontrast.h6
-rw-r--r--kstyles/keramik/keramik.cpp483
-rw-r--r--kstyles/keramik/keramik.h8
-rw-r--r--kstyles/kthemestyle/kthemestyle.cpp305
-rw-r--r--kstyles/kthemestyle/kthemestyle.h10
-rw-r--r--kstyles/plastik/plastik.cpp338
-rw-r--r--kstyles/plastik/plastik.h10
12 files changed, 834 insertions, 747 deletions
diff --git a/kstyles/asteroid/asteroid.cpp b/kstyles/asteroid/asteroid.cpp
index 9da74e237..e0261369a 100644
--- a/kstyles/asteroid/asteroid.cpp
+++ b/kstyles/asteroid/asteroid.cpp
@@ -104,41 +104,46 @@ AsteroidStyle::~AsteroidStyle()
* get deleted here. */
}
-void AsteroidStyle::polish(TQWidget *w)
+void AsteroidStyle::polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{
-/* Screwing with the palette is fun! and required in order to make it feel
- authentic. -clee */
- TQPalette wp = w->palette();
- //wp.setColor(TQColorGroup::Dark, wp.active().color(TQColorGroup::Button).dark(350));
- wp.setColor(TQColorGroup::Dark, TQColor(128, 128, 128));
- wp.setColor(TQColorGroup::Mid, wp.active().color(TQColorGroup::Button).dark(150)); // Which GUI element(s) does this correspond to?
-
- bool isProtectedObject = false;
- TQObject *curparent = TQT_TQOBJECT(w);
- while (curparent) {
- if (curparent->inherits("KonqFileTip") || curparent->inherits("AppletItem")
- || curparent->inherits("KJanusWidget")
- ) {
- isProtectedObject = true;
+ if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
+ TQWidget *w = reinterpret_cast<TQWidget*>(ptr);
+/* Screwing with the palette is fun! and required in order to make it feel
+ authentic. -clee */
+ TQPalette wp = w->palette();
+ //wp.setColor(TQColorGroup::Dark, wp.active().color(TQColorGroup::Button).dark(350));
+ wp.setColor(TQColorGroup::Dark, TQColor(128, 128, 128));
+ wp.setColor(TQColorGroup::Mid, wp.active().color(TQColorGroup::Button).dark(150)); // Which GUI element(s) does this correspond to?
+
+ bool isProtectedObject = false;
+ TQObject *curparent = TQT_TQOBJECT(w);
+ while (curparent) {
+ if (curparent->inherits("KonqFileTip") || curparent->inherits("AppletItem")
+ || curparent->inherits("KJanusWidget")
+ ) {
+ isProtectedObject = true;
+ }
+ curparent = curparent->parent();
+ }
+ if ((w->parent()) && (!w->ownPalette())) {
+ isProtectedObject = true;
+ }
+ if (!isProtectedObject) {
+ w->setPalette(wp);
}
- curparent = curparent->parent();
- }
- if ((w->parent()) && (!w->ownPalette())) {
- isProtectedObject = true;
}
- if (!isProtectedObject)
- w->setPalette(wp);
- if (w->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) {
- w->installEventFilter(this);
- } else {
- KStyle::polish(w);
+ if (ceData.widgetObjectTypes.contains(TQPUSHBUTTON_OBJECT_NAME_STRING)) {
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ }
+ else {
+ KStyle::polish(ceData, elementFlags, ptr);
}
}
-void AsteroidStyle::unPolish(TQWidget *w)
+void AsteroidStyle::unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{
- KStyle::unPolish(w);
+ KStyle::unPolish(ceData, elementFlags, ptr);
}
/*!
@@ -147,7 +152,7 @@ void AsteroidStyle::unPolish(TQWidget *w)
Changes some application-wide settings
*/
void
-AsteroidStyle::polish( TQApplication* app)
+AsteroidStyle::applicationPolish(TQStyleControlElementData, ControlElementFlags, void *)
{
TQPalette wp = TQApplication::palette();
wp.setColor(TQColorGroup::Dark, TQColor(128, 128, 128));
@@ -158,7 +163,7 @@ AsteroidStyle::polish( TQApplication* app)
/*! \reimp
*/
void
-AsteroidStyle::unPolish( TQApplication* /* app */ )
+AsteroidStyle::applicationUnPolish(TQStyleControlElementData, ControlElementFlags, void *)
{
}
@@ -1090,7 +1095,7 @@ void AsteroidStyle::drawControl(TQ_ControlElement ce,
pixelMetric( TQStyle::PM_DefaultFrameWidth, ceData, elementFlags, tb ) );
int alignment = TQt::AlignCenter | TQt::ShowPrefix;
- if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, w))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, w)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, w)) && (!acceleratorsShown())))
alignment |= TQt::NoAccel;
tr.setWidth(tr.width()+4); // Compensate for text appearing too far to the left
// TQRect tr_offset = TQRect(tr.x()+ETCH_X_OFFSET, tr.y()+ETCH_Y_OFFSET, tr.width(), tr.height());
@@ -1137,7 +1142,7 @@ void AsteroidStyle::drawControl(TQ_ControlElement ce,
bool etchtext = styleHint( SH_EtchDisabledText, ceData, elementFlags );
int alignment = TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft;
- if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, w))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, w)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, w)) && (!acceleratorsShown())))
alignment |= TQt::NoAccel;
//TQRect r_offset = TQRect(r.x()+ETCH_X_OFFSET, r.y()+ETCH_Y_OFFSET, r.width(), r.height());
@@ -1186,7 +1191,7 @@ void AsteroidStyle::drawControl(TQ_ControlElement ce,
bool etchtext = styleHint( SH_EtchDisabledText, ceData, elementFlags );
int alignment = TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft;
- if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, w))
+ if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, w)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, w)) && (!acceleratorsShown())))
alignment |= TQt::NoAccel;
// TQRect r_offset = TQRect(r.x()+ETCH_X_OFFSET, r.y()+ETCH_Y_OFFSET, r.width(), r.height());
@@ -2549,15 +2554,18 @@ void AsteroidStyle::paletteChanged()
{
}
-bool AsteroidStyle::eventFilter(TQObject *o, TQEvent *e)
+bool AsteroidStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e )
{
- /* 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);
+ 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);
+ }
}
}
diff --git a/kstyles/asteroid/asteroid.h b/kstyles/asteroid/asteroid.h
index 9b8450084..4d0216c4c 100644
--- a/kstyles/asteroid/asteroid.h
+++ b/kstyles/asteroid/asteroid.h
@@ -17,10 +17,10 @@ public:
AsteroidStyle();
virtual ~AsteroidStyle();
- void polish(TQWidget *);
- void unPolish(TQWidget *);
- void polish( TQApplication* );
- void unPolish( TQApplication* );
+ void polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
+ void unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
+ void applicationPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
+ void applicationUnPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void renderSliderHandle(TQPainter *p,
@@ -116,8 +116,7 @@ public:
const TQStyleOption &,
const TQWidget * = 0) const;
-protected:
- bool eventFilter(TQObject *, TQEvent *);
+ virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
protected slots:
void paletteChanged();
diff --git a/kstyles/highcolor/highcolor.cpp b/kstyles/highcolor/highcolor.cpp
index 4087ecc37..bd17b3dfc 100644
--- a/kstyles/highcolor/highcolor.cpp
+++ b/kstyles/highcolor/highcolor.cpp
@@ -189,43 +189,49 @@ HighColorStyle::~HighColorStyle()
}
-void HighColorStyle::polish(TQWidget* widget)
+void HighColorStyle::polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{
- // Put in order of highest occurrence to maximise hit rate
- if (widget->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) {
- widget->installEventFilter(this);
- } else if (widget->inherits(TQMENUBAR_OBJECT_NAME_STRING) || widget->inherits(TQPOPUPMENU_OBJECT_NAME_STRING)) {
- widget->setBackgroundMode(TQWidget::NoBackground);
- } else if (type == HighColor && widget->inherits("QToolBarExtensionWidget")) {
- widget->installEventFilter(this);
- } else if ( !qstrcmp( widget->name(), kdeToolbarWidget) ) {
- widget->setBackgroundMode( NoBackground ); // We paint the whole background.
- widget->installEventFilter(this);
- } else if (widget->inherits(TQTOOLBOXBUTTON_OBJECT_NAME_STRING)) {
- TQFont font = widget->font();
- font.setBold(true);
- widget->setFont(font);
+ if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
+ TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
+ // Put in order of highest occurrence to maximise hit rate
+ if (widget->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) {
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ } else if (widget->inherits(TQMENUBAR_OBJECT_NAME_STRING) || widget->inherits(TQPOPUPMENU_OBJECT_NAME_STRING)) {
+ widget->setBackgroundMode(TQWidget::NoBackground);
+ } else if (type == HighColor && widget->inherits("QToolBarExtensionWidget")) {
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ } else if ( !qstrcmp( widget->name(), kdeToolbarWidget) ) {
+ widget->setBackgroundMode( NoBackground ); // We paint the whole background.
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ } else if (widget->inherits(TQTOOLBOXBUTTON_OBJECT_NAME_STRING)) {
+ TQFont font = widget->font();
+ font.setBold(true);
+ widget->setFont(font);
+ }
}
- KStyle::polish( widget );
+ KStyle::polish( ceData, elementFlags, ptr );
}
-void HighColorStyle::unPolish(TQWidget* widget)
+void HighColorStyle::unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{
- if (widget->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) {
- widget->removeEventFilter(this);
- }
- else if (widget->inherits(TQMENUBAR_OBJECT_NAME_STRING) || widget->inherits(TQPOPUPMENU_OBJECT_NAME_STRING)) {
- widget->setBackgroundMode(TQWidget::PaletteBackground);
- } else if (type == HighColor && widget->inherits("QToolBarExtensionWidget")) {
- widget->removeEventFilter(this);
- } else if ( !qstrcmp( widget->name(), kdeToolbarWidget) ) {
- widget->removeEventFilter(this);
- widget->setBackgroundMode( PaletteBackground );
+ if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
+ TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
+ if (widget->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) {
+ removeObjectEventHandler(ceData, elementFlags, ptr, this);
+ }
+ else if (widget->inherits(TQMENUBAR_OBJECT_NAME_STRING) || widget->inherits(TQPOPUPMENU_OBJECT_NAME_STRING)) {
+ widget->setBackgroundMode(TQWidget::PaletteBackground);
+ } else if (type == HighColor && widget->inherits("QToolBarExtensionWidget")) {
+ removeObjectEventHandler(ceData, elementFlags, ptr, this);
+ } else if ( !qstrcmp( widget->name(), kdeToolbarWidget) ) {
+ removeObjectEventHandler(ceData, elementFlags, ptr, this);
+ widget->setBackgroundMode( PaletteBackground );
+ }
}
- KStyle::unPolish( widget );
+ KStyle::unPolish( ceData, elementFlags, ptr );
}
@@ -1960,79 +1966,83 @@ TQPixmap HighColorStyle::stylePixmap(StylePixmap stylepixmap,
}
-bool HighColorStyle::eventFilter( TQObject *object, TQEvent *event )
+bool HighColorStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *event )
{
- if (KStyle::eventFilter( object, event ))
+ if (KStyle::objectEventHandler( ceData, elementFlags, source, event ))
return true;
- TQToolBar* toolbar;
+ if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
+ TQObject* object = reinterpret_cast<TQObject*>(source);
- // 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 ) )
- {
- // Draw a gradient background for custom widgets in the toolbar
- // that have specified a "kde toolbar widget" name.
-
- 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);
- TQWidget *parent = TQT_TQWIDGET(object->parent());
- int x_offset = widget->x(), y_offset = widget->y();
- while (parent && parent->parent() && !qstrcmp( parent->name(), kdeToolbarWidget ) )
- {
- x_offset += parent->x();
- y_offset += parent->y();
- parent = TQT_TQWIDGET(parent->parent());
+ 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 ) )
+ {
+ // Draw a gradient background for custom widgets in the toolbar
+ // that have specified a "kde toolbar widget" name.
+
+ 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);
+ TQWidget *parent = TQT_TQWIDGET(object->parent());
+ int x_offset = widget->x(), y_offset = widget->y();
+ while (parent && parent->parent() && !qstrcmp( parent->name(), kdeToolbarWidget ) )
+ {
+ x_offset += parent->x();
+ y_offset += parent->y();
+ parent = TQT_TQWIDGET(parent->parent());
+ }
+
+ TQRect r = widget->rect();
+ TQRect pr = parent->rect();
+ bool horiz_grad = pr.width() < pr.height();
+
+ // Check if the parent is a QToolbar, and use its orientation, else guess.
+ TQToolBar* tb = dynamic_cast<TQToolBar*>(parent);
+ if (tb) horiz_grad = tb->orientation() == Qt::Vertical;
+
+ TQPainter p( widget );
+ renderGradient(&p, r, parent->colorGroup().button(), horiz_grad,
+ x_offset, y_offset, pr.width(), pr.height());
+
+ return false; // Now draw the contents
+ }
+ } else if ( object->parent() &&
+ (toolbar = dynamic_cast<TQToolBar*>(object->parent())) )
+ {
+ // We need to override the paint event to draw a
+ // gradient on a QToolBarExtensionWidget.
+ if ( event->type() == TQEvent::Paint ) {
+ TQWidget *widget = TQT_TQWIDGET(object);
+ TQRect wr = widget->rect(), tr = toolbar->rect();
+ TQPainter p( widget );
+ renderGradient(&p, wr, toolbar->colorGroup().button(),
+ toolbar->orientation() == Qt::Vertical,
+ wr.x(), wr.y(), tr.width() - 2, tr.height() - 2);
+
+ p.setPen( toolbar->colorGroup().dark() );
+ if ( toolbar->orientation() == Qt::Horizontal )
+ p.drawLine( wr.width()-1, 0, wr.width()-1, wr.height()-1 );
+ else
+ p.drawLine( 0, wr.height()-1, wr.width()-1, wr.height()-1 );
+
+ return true;
}
-
- TQRect r = widget->rect();
- TQRect pr = parent->rect();
- bool horiz_grad = pr.width() < pr.height();
-
- // Check if the parent is a QToolbar, and use its orientation, else guess.
- TQToolBar* tb = dynamic_cast<TQToolBar*>(parent);
- if (tb) horiz_grad = tb->orientation() == Qt::Vertical;
-
- TQPainter p( widget );
- renderGradient(&p, r, parent->colorGroup().button(), horiz_grad,
- x_offset, y_offset, pr.width(), pr.height());
-
- return false; // Now draw the contents
- }
- } else if ( object->parent() &&
- (toolbar = dynamic_cast<TQToolBar*>(object->parent())) )
- {
- // We need to override the paint event to draw a
- // gradient on a QToolBarExtensionWidget.
- if ( event->type() == TQEvent::Paint ) {
- TQWidget *widget = TQT_TQWIDGET(object);
- TQRect wr = widget->rect(), tr = toolbar->rect();
- TQPainter p( widget );
- renderGradient(&p, wr, toolbar->colorGroup().button(),
- toolbar->orientation() == Qt::Vertical,
- wr.x(), wr.y(), tr.width() - 2, tr.height() - 2);
-
- p.setPen( toolbar->colorGroup().dark() );
- if ( toolbar->orientation() == Qt::Horizontal )
- p.drawLine( wr.width()-1, 0, wr.width()-1, wr.height()-1 );
- else
- p.drawLine( 0, wr.height()-1, wr.width()-1, wr.height()-1 );
-
- return true;
}
}
diff --git a/kstyles/highcolor/highcolor.h b/kstyles/highcolor/highcolor.h
index d5b6f526c..043441f95 100644
--- a/kstyles/highcolor/highcolor.h
+++ b/kstyles/highcolor/highcolor.h
@@ -65,8 +65,8 @@ class HighColorStyle : public KStyle
HighColorStyle( StyleType );
virtual ~HighColorStyle();
- void polish( TQWidget* widget );
- void unPolish( TQWidget* widget );
+ void polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
+ void unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void renderMenuBlendPixmap( KPixmap& pix, const TQColorGroup &cg,
const TQPopupMenu* popup ) const;
@@ -158,8 +158,9 @@ class HighColorStyle : public KStyle
const TQStyleOption& = TQStyleOption::Default,
const TQWidget *widget = 0 ) const;
+ virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
+
protected:
- bool eventFilter( TQObject *object, TQEvent *event );
void renderGradient( TQPainter* p,
const TQRect& r,
diff --git a/kstyles/highcontrast/highcontrast.cpp b/kstyles/highcontrast/highcontrast.cpp
index 8d4629677..1447a8e99 100644
--- a/kstyles/highcontrast/highcontrast.cpp
+++ b/kstyles/highcontrast/highcontrast.cpp
@@ -153,30 +153,43 @@ void HighContrastStyle::polish( TQPalette& pal )
}
-void HighContrastStyle::polish (TQWidget* widget)
+void HighContrastStyle::polish (TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{
- if (widget->inherits (TQBUTTON_OBJECT_NAME_STRING)
- || widget->inherits (TQCOMBOBOX_OBJECT_NAME_STRING)
- || widget->inherits (TQSPINWIDGET_OBJECT_NAME_STRING)
- || widget->inherits (TQLINEEDIT_OBJECT_NAME_STRING)
- || widget->inherits (TQTEXTEDIT_OBJECT_NAME_STRING))
- {
- widget->installEventFilter (this);
-
- TQSpinWidget* spinwidget = dynamic_cast<TQSpinWidget*>(widget);
- if (spinwidget && spinwidget->editWidget())
- spinwidget->editWidget()->installEventFilter (this);
+ if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
+ TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
+
+ if (widget->inherits (TQBUTTON_OBJECT_NAME_STRING)
+ || widget->inherits (TQCOMBOBOX_OBJECT_NAME_STRING)
+ || widget->inherits (TQSPINWIDGET_OBJECT_NAME_STRING)
+ || widget->inherits (TQLINEEDIT_OBJECT_NAME_STRING)
+ || widget->inherits (TQTEXTEDIT_OBJECT_NAME_STRING))
+ {
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+
+ TQSpinWidget* spinwidget = dynamic_cast<TQSpinWidget*>(widget);
+ if (spinwidget && spinwidget->editWidget()) {
+ TQWidget* spinEditWidget = spinwidget->editWidget();
+ TQStyleControlElementData swCeData = populateControlElementDataFromWidget(spinEditWidget, TQStyleOption());
+ ControlElementFlags swElementFlags = getControlElementFlagsForObject(spinEditWidget, swCeData.widgetObjectTypes, TQStyleOption());
+ installObjectEventHandler(swCeData, swElementFlags, spinEditWidget, this);
+ }
+ }
}
- KStyle::polish (widget);
+ KStyle::polish (ceData, elementFlags, ptr);
}
-void HighContrastStyle::unPolish (TQWidget* widget)
+void HighContrastStyle::unPolish (TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{
- if (widget->inherits (TQWIDGET_OBJECT_NAME_STRING) || widget->inherits (TQCOMBOBOX_OBJECT_NAME_STRING) || widget->inherits (TQSPINWIDGET_OBJECT_NAME_STRING) || widget->inherits (TQLINEEDIT_OBJECT_NAME_STRING) || widget->inherits (TQTEXTEDIT_OBJECT_NAME_STRING))
- widget->removeEventFilter (this);
- KStyle::unPolish (widget);
+ if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
+ TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
+ if (widget->inherits (TQWIDGET_OBJECT_NAME_STRING) || widget->inherits (TQCOMBOBOX_OBJECT_NAME_STRING) || widget->inherits (TQSPINWIDGET_OBJECT_NAME_STRING) || widget->inherits (TQLINEEDIT_OBJECT_NAME_STRING) || widget->inherits (TQTEXTEDIT_OBJECT_NAME_STRING)) {
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ }
+ }
+
+ KStyle::unPolish (ceData, elementFlags, ptr);
}
void HighContrastStyle::setColorsNormal (TQPainter* p, const TQColorGroup& cg, int flags, int highlight) const
@@ -1815,48 +1828,52 @@ TQRect HighContrastStyle::subRect (SubRect subrect, const TQStyleControlElementD
}
}
-bool HighContrastStyle::eventFilter (TQObject *object, TQEvent *event)
+bool HighContrastStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *event )
{
- 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)))
+ if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
+ TQObject* object = reinterpret_cast<TQObject*>(source);
+
+ TQWidget* widget = dynamic_cast<TQWidget*>(object);
+ if (widget)
{
- hoverWidget = widget;
- widget->repaint (false);
- }
- else if (event->type() == TQEvent::Leave
+ // 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)))
- {
- 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());
+ hoverWidget = widget;
+ widget->repaint (false);
}
-
- if (widgetparent)
- widgetparent->repaint (false);
- else
+ 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::eventFilter (object, event);
+ return KStyle::objectEventHandler (ceData, elementFlags, source, event);
}
// vim: set noet ts=4 sw=4:
diff --git a/kstyles/highcontrast/highcontrast.h b/kstyles/highcontrast/highcontrast.h
index 4d853e705..6ea667cc6 100644
--- a/kstyles/highcontrast/highcontrast.h
+++ b/kstyles/highcontrast/highcontrast.h
@@ -56,8 +56,8 @@ class HighContrastStyle : public KStyle
void polish( TQPalette& pal );
- void polish( TQWidget* widget );
- void unPolish( TQWidget* widget );
+ void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
+ void unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void drawKStylePrimitive( KStylePrimitive kpe,
TQPainter* p,
@@ -150,7 +150,7 @@ class HighContrastStyle : public KStyle
TQRect subRect (SubRect subrect, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget * widget) const;
protected:
- bool eventFilter( TQObject *object, TQEvent *event );
+ virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
TQWidget *hoverWidget;
diff --git a/kstyles/keramik/keramik.cpp b/kstyles/keramik/keramik.cpp
index 0b1ddd9a9..af9866c2f 100644
--- a/kstyles/keramik/keramik.cpp
+++ b/kstyles/keramik/keramik.cpp
@@ -331,86 +331,98 @@ KeramikStyle::~KeramikStyle()
KeramikDbCleanup();
}
-void KeramikStyle::polish(TQApplication* app)
+void KeramikStyle::applicationPolish(TQStyleControlElementData ceData, ControlElementFlags, void *ptr)
{
- if (!qstrcmp(app->argv()[0], "kicker"))
- kickerMode = true;
+ if (ceData.widgetObjectTypes.contains(TQAPPLICATION_OBJECT_NAME_STRING)) {
+ TQApplication *app = reinterpret_cast<TQApplication*>(ptr);
+ if (!qstrcmp(app->argv()[0], "kicker")) {
+ kickerMode = true;
+ }
+ }
}
-void KeramikStyle::polish(TQWidget* widget)
+void KeramikStyle::polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{
- // Put in order of highest occurrence to maximise hit rate
- if ( widget->inherits( TQPUSHBUTTON_OBJECT_NAME_STRING ) || widget->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) || widget->inherits(TQTOOLBUTTON_OBJECT_NAME_STRING) )
- {
- widget->installEventFilter(this);
- if ( widget->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) )
- widget->setBackgroundMode( NoBackground );
- }
- else if ( widget->inherits( TQMENUBAR_OBJECT_NAME_STRING ) || widget->inherits( TQPOPUPMENU_OBJECT_NAME_STRING ) )
- widget->setBackgroundMode( NoBackground );
-
- else if ( widget->parentWidget() &&
- ( ( widget->inherits( TQLISTBOX_OBJECT_NAME_STRING ) && widget->parentWidget()->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) ) ||
- widget->inherits( "KCompletionBox" ) ) ) {
- TQListBox* listbox = (TQListBox*) widget;
- listbox->setLineWidth( 4 );
- listbox->setBackgroundMode( NoBackground );
- widget->installEventFilter( this );
-
- } else if (widget->inherits("QToolBarExtensionWidget")) {
- widget->installEventFilter(this);
- //widget->setBackgroundMode( NoBackground );
- }
- else if ( !qstrcmp( widget->name(), kdeToolbarWidget ) ) {
- widget->setBackgroundMode( NoBackground );
- widget->installEventFilter(this);
- }
+ if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
+ TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
- if (animateProgressBar && ::tqqt_cast<TQProgressBar*>(widget))
- {
- widget->installEventFilter(this);
- progAnimWidgets[static_cast<TQProgressBar*>(widget)] = 0;
- connect(widget, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(progressBarDestroyed(TQObject*)));
- if (!animationTimer->isActive())
- animationTimer->start( 50, false );
+ // Put in order of highest occurrence to maximise hit rate
+ if ( widget->inherits( TQPUSHBUTTON_OBJECT_NAME_STRING ) || widget->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) || widget->inherits(TQTOOLBUTTON_OBJECT_NAME_STRING) )
+ {
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ if ( widget->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) )
+ widget->setBackgroundMode( NoBackground );
+ }
+ else if ( widget->inherits( TQMENUBAR_OBJECT_NAME_STRING ) || widget->inherits( TQPOPUPMENU_OBJECT_NAME_STRING ) )
+ widget->setBackgroundMode( NoBackground );
+
+ else if ( widget->parentWidget() &&
+ ( ( widget->inherits( TQLISTBOX_OBJECT_NAME_STRING ) && widget->parentWidget()->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) ) ||
+ widget->inherits( "KCompletionBox" ) ) ) {
+ TQListBox* listbox = (TQListBox*) widget;
+ listbox->setLineWidth( 4 );
+ listbox->setBackgroundMode( NoBackground );
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+
+ } else if (widget->inherits("QToolBarExtensionWidget")) {
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ //widget->setBackgroundMode( NoBackground );
+ }
+ else if ( !qstrcmp( widget->name(), kdeToolbarWidget ) ) {
+ widget->setBackgroundMode( NoBackground );
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ }
+
+ if (animateProgressBar && ::tqqt_cast<TQProgressBar*>(widget))
+ {
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ progAnimWidgets[static_cast<TQProgressBar*>(widget)] = 0;
+ connect(widget, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(progressBarDestroyed(TQObject*)));
+ if (!animationTimer->isActive())
+ animationTimer->start( 50, false );
+ }
}
- KStyle::polish(widget);
+ KStyle::polish(ceData, elementFlags, ptr);
}
-void KeramikStyle::unPolish(TQWidget* widget)
+void KeramikStyle::unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{
- //### TODO: This needs major cleanup (and so does polish() )
- if ( widget->inherits( TQPUSHBUTTON_OBJECT_NAME_STRING ) || widget->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) )
- {
- if ( widget->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) )
- widget->setBackgroundMode( PaletteButton );
- widget->removeEventFilter(this);
- }
- else if ( widget->inherits( TQMENUBAR_OBJECT_NAME_STRING ) || widget->inherits( TQPOPUPMENU_OBJECT_NAME_STRING ) )
- widget->setBackgroundMode( PaletteBackground );
-
- else if ( widget->parentWidget() &&
- ( ( widget->inherits( TQLISTBOX_OBJECT_NAME_STRING ) && widget->parentWidget()->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) ) ||
- widget->inherits( "KCompletionBox" ) ) ) {
- TQListBox* listbox = (TQListBox*) widget;
- listbox->setLineWidth( 1 );
- listbox->setBackgroundMode( PaletteBackground );
- widget->removeEventFilter( this );
- widget->clearMask();
- } else if (widget->inherits("QToolBarExtensionWidget")) {
- widget->removeEventFilter(this);
- }
- else if ( !qstrcmp( widget->name(), kdeToolbarWidget ) ) {
- widget->setBackgroundMode( PaletteBackground );
- widget->removeEventFilter(this);
- }
- else if ( ::tqqt_cast<TQProgressBar*>(widget) )
- {
- progAnimWidgets.remove(static_cast<TQProgressBar*>(widget));
+ if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
+ TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
+
+ //### TODO: This needs major cleanup (and so does polish() )
+ if ( widget->inherits( TQPUSHBUTTON_OBJECT_NAME_STRING ) || widget->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) )
+ {
+ if ( widget->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) )
+ widget->setBackgroundMode( PaletteButton );
+ removeObjectEventHandler(ceData, elementFlags, ptr, this);
+ }
+ else if ( widget->inherits( TQMENUBAR_OBJECT_NAME_STRING ) || widget->inherits( TQPOPUPMENU_OBJECT_NAME_STRING ) )
+ widget->setBackgroundMode( PaletteBackground );
+
+ else if ( widget->parentWidget() &&
+ ( ( widget->inherits( TQLISTBOX_OBJECT_NAME_STRING ) && widget->parentWidget()->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) ) ||
+ widget->inherits( "KCompletionBox" ) ) ) {
+ TQListBox* listbox = (TQListBox*) widget;
+ listbox->setLineWidth( 1 );
+ listbox->setBackgroundMode( PaletteBackground );
+ removeObjectEventHandler(ceData, elementFlags, ptr, this);
+ widget->clearMask();
+ } else if (widget->inherits("QToolBarExtensionWidget")) {
+ removeObjectEventHandler(ceData, elementFlags, ptr, this);
+ }
+ else if ( !qstrcmp( widget->name(), kdeToolbarWidget ) ) {
+ widget->setBackgroundMode( PaletteBackground );
+ removeObjectEventHandler(ceData, elementFlags, ptr, this);
+ }
+ else if ( ::tqqt_cast<TQProgressBar*>(widget) )
+ {
+ progAnimWidgets.remove(static_cast<TQProgressBar*>(widget));
+ }
}
- KStyle::unPolish(widget);
+ KStyle::unPolish(ceData, elementFlags, ptr);
}
void KeramikStyle::progressBarDestroyed(TQObject* obj)
@@ -2759,197 +2771,202 @@ TQRect KeramikStyle::querySubControlMetrics( TQ_ComplexControl control,
#undef KeyRelease
#endif
-bool KeramikStyle::eventFilter( TQObject* object, TQEvent* event )
+bool KeramikStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *event )
{
- if (KStyle::eventFilter( object, event ))
+ if (KStyle::objectEventHandler( ceData, elementFlags, source, event ))
return true;
- if ( !object->isWidgetType() ) return false;
+ if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
+ TQObject* object = reinterpret_cast<TQObject*>(source);
- //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() )
+ if ( !object->isWidgetType() ) return false;
+
+ //Clear hover highlight when needed
+ if ( (event->type() == TQEvent::Leave) && (TQT_BASE_OBJECT(object) == TQT_BASE_OBJECT(hoverWidget)) )
{
- hoverWidget = TQT_TQWIDGET(object);
- hoverWidget->repaint( false );
- }
- return false;
- }
-
- //Combo line edits get special frames
- if ( event->type() == TQEvent::Paint && ::tqqt_cast<TQLineEdit*>(object) )
- {
- static bool recursion = false;
- if (recursion )
+ TQWidget* button = TQT_TQWIDGET(object);
+ hoverWidget = 0;
+ button->repaint( false );
return false;
-
- recursion = true;
- object->event( TQT_TQPAINTEVENT( event ) );
- TQWidget* widget = TQT_TQWIDGET( object );
- TQPainter p( widget );
- Keramik::RectTilePainter( keramik_frame_shadow, false, false, 2, 2 ).draw( &p, widget->rect(),
- widget->palette().color( TQPalette::Normal, TQColorGroup::Button ),
- Qt::black, false, Keramik::TilePainter::PaintFullBlend);
- recursion = false;
- return true;
- }
- else if ( ::tqqt_cast<TQListBox*>(object) )
- {
- //Handle combobox drop downs
- switch (event->type())
+ }
+
+ //Hover highlight on buttons, toolbuttons and combos
+ if ( ::tqqt_cast<TQPushButton*>(object) || ::tqqt_cast<TQComboBox*>(object) || ::tqqt_cast<TQToolButton*>(object) )
{
-#ifdef HAVE_X11_EXTENSIONS_SHAPE_H
- //Combo dropdowns are shaped
- case TQEvent::Resize:
+ if (event->type() == TQEvent::Enter && TQT_TQWIDGET(object)->isEnabled() )
{
- TQListBox* listbox = static_cast<TQListBox*>(TQT_TQWIDGET(object));
- TQResizeEvent* resize = TQT_TQRESIZEEVENT(event);
- if (resize->size().height() < 6)
- return false;
-
- //CHECKME: Not sure the rects are perfect..
- XRectangle rects[5] = {
- {0, 0, resize->size().width()-2, resize->size().height()-6},
- {0, resize->size().height()-6, resize->size().width()-2, 1},
- {1, resize->size().height()-5, resize->size().width()-3, 1},
- {2, resize->size().height()-4, resize->size().width()-5, 1},
- {3, resize->size().height()-3, resize->size().width()-7, 1}
- };
-
- XShapeCombineRectangles(tqt_xdisplay(), listbox->handle(), ShapeBounding, 0, 0,
- rects, 5, ShapeSet, YXSorted);
+ hoverWidget = TQT_TQWIDGET(object);
+ hoverWidget->repaint( false );
}
- break;
-#endif
- //Combo dropdowns get fancy borders
- case TQEvent::Paint:
+ return false;
+ }
+
+ //Combo line edits get special frames
+ if ( event->type() == TQEvent::Paint && ::tqqt_cast<TQLineEdit*>(object) )
+ {
+ static bool recursion = false;
+ if (recursion )
+ return false;
+
+ recursion = true;
+ object->event( TQT_TQPAINTEVENT( event ) );
+ TQWidget* widget = TQT_TQWIDGET( object );
+ TQPainter p( widget );
+ Keramik::RectTilePainter( keramik_frame_shadow, false, false, 2, 2 ).draw( &p, widget->rect(),
+ widget->palette().color( TQPalette::Normal, TQColorGroup::Button ),
+ Qt::black, false, Keramik::TilePainter::PaintFullBlend);
+ recursion = false;
+ return true;
+ }
+ else if ( ::tqqt_cast<TQListBox*>(object) )
+ {
+ //Handle combobox drop downs
+ switch (event->type())
{
- static bool recursion = false;
- if (recursion )
- return false;
- TQListBox* listbox = (TQListBox*) object;
- TQPaintEvent* paint = (TQPaintEvent*) event;
-
-
- if ( !listbox->contentsRect().contains( paint->rect() ) )
+#ifdef HAVE_X11_EXTENSIONS_SHAPE_H
+ //Combo dropdowns are shaped
+ case TQEvent::Resize:
{
- TQPainter p( listbox );
- Keramik::RectTilePainter( keramik_combobox_list, false, false ).draw( &p, 0, 0, listbox->width(), listbox->height(),
- listbox->palette().color( TQPalette::Normal, TQColorGroup::Button ),
- listbox->palette().color( TQPalette::Normal, TQColorGroup::Background ) );
-
- TQPaintEvent newpaint( paint->region().intersect( listbox->contentsRect() ), paint->erased() );
- recursion = true;
- object->event( &newpaint );
- recursion = false;
- return true;
- }
- }
- break;
+ TQListBox* listbox = static_cast<TQListBox*>(TQT_TQWIDGET(object));
+ TQResizeEvent* resize = TQT_TQRESIZEEVENT(event);
+ if (resize->size().height() < 6)
+ return false;
- /**
- Since our popup is shown a bit overlapping the combo body, a mouse click at the bottom of the
- widget will result in the release going to the popup, which will cause it to close (#56435).
- We solve it by filtering out the first release, if it's in the right area. To do this, we notices shows,
- move ourselves to front of event filter list, and then capture the first release event, and if it's
- in the overlap area, filter it out.
- */
- case TQEvent::Show:
- //Prioritize ourselves to see the mouse events first
- object->removeEventFilter(this);
- object->installEventFilter(this);
- firstComboPopupRelease = true;
- break;
+ //CHECKME: Not sure the rects are perfect..
+ XRectangle rects[5] = {
+ {0, 0, resize->size().width()-2, resize->size().height()-6},
+ {0, resize->size().height()-6, resize->size().width()-2, 1},
+ {1, resize->size().height()-5, resize->size().width()-3, 1},
+ {2, resize->size().height()-4, resize->size().width()-5, 1},
+ {3, resize->size().height()-3, resize->size().width()-7, 1}
+ };
- //We need to filter some clicks out.
- case TQEvent::MouseButtonRelease:
- if (firstComboPopupRelease)
+ XShapeCombineRectangles(tqt_xdisplay(), listbox->handle(), ShapeBounding, 0, 0,
+ rects, 5, ShapeSet, YXSorted);
+ }
+ break;
+#endif
+ //Combo dropdowns get fancy borders
+ case TQEvent::Paint:
{
- firstComboPopupRelease = false;
-
- TQMouseEvent* mev = TQT_TQMOUSEEVENT(event);
- TQListBox* box = static_cast<TQListBox*>(TQT_TQWIDGET(object));
-
- TQWidget* parent = box->parentWidget();
- if (!parent)
+ static bool recursion = false;
+ if (recursion )
return false;
-
- TQPoint inParCoords = parent->mapFromGlobal(mev->globalPos());
- if (parent->rect().contains(inParCoords))
+ TQListBox* listbox = (TQListBox*) object;
+ TQPaintEvent* paint = (TQPaintEvent*) event;
+
+
+ if ( !listbox->contentsRect().contains( paint->rect() ) )
+ {
+ TQPainter p( listbox );
+ Keramik::RectTilePainter( keramik_combobox_list, false, false ).draw( &p, 0, 0, listbox->width(), listbox->height(),
+ listbox->palette().color( TQPalette::Normal, TQColorGroup::Button ),
+ listbox->palette().color( TQPalette::Normal, TQColorGroup::Background ) );
+
+ TQPaintEvent newpaint( paint->region().intersect( listbox->contentsRect() ), paint->erased() );
+ recursion = true;
+ object->event( &newpaint );
+ recursion = false;
return true;
+ }
}
break;
- case TQEvent::MouseButtonPress:
- case TQEvent::MouseButtonDblClick:
- case TQEvent::Wheel:
- case TQEvent::KeyPress:
- case TQEvent::KeyRelease:
- firstComboPopupRelease = false;
- default:
- return false;
+
+ /**
+ Since our popup is shown a bit overlapping the combo body, a mouse click at the bottom of the
+ widget will result in the release going to the popup, which will cause it to close (#56435).
+ We solve it by filtering out the first release, if it's in the right area. To do this, we notices shows,
+ move ourselves to front of event filter list, and then capture the first release event, and if it's
+ in the overlap area, filter it out.
+ */
+ case TQEvent::Show:
+ //Prioritize ourselves to see the mouse events first
+ removeObjectEventHandler(ceData, elementFlags, source, this);
+ installObjectEventHandler(ceData, elementFlags, source, this);
+ firstComboPopupRelease = true;
+ break;
+
+ //We need to filter some clicks out.
+ case TQEvent::MouseButtonRelease:
+ if (firstComboPopupRelease)
+ {
+ firstComboPopupRelease = false;
+
+ TQMouseEvent* mev = TQT_TQMOUSEEVENT(event);
+ TQListBox* box = static_cast<TQListBox*>(TQT_TQWIDGET(object));
+
+ TQWidget* parent = box->parentWidget();
+ if (!parent)
+ return false;
+
+ TQPoint inParCoords = parent->mapFromGlobal(mev->globalPos());
+ if (parent->rect().contains(inParCoords))
+ return true;
+ }
+ break;
+ case TQEvent::MouseButtonPress:
+ case TQEvent::MouseButtonDblClick:
+ case TQEvent::Wheel:
+ case TQEvent::KeyPress:
+ case TQEvent::KeyRelease:
+ firstComboPopupRelease = false;
+ default:
+ return false;
+ }
}
- }
- //Toolbar background gradient handling
- else if (event->type() == TQEvent::Paint &&
- object->parent() && !qstrcmp(object->name(), kdeToolbarWidget) )
- {
- // Draw a gradient background for custom widgets in the toolbar
- // that have specified a "kde toolbar widget" name.
- renderToolbarWidgetBackground(0, TQT_TQWIDGET(object));
-
- return false; // Now draw the contents
- }
- else if (event->type() == TQEvent::Paint && object->parent() && ::tqqt_cast<TQToolBar*>(object->parent())
- && !::tqqt_cast<TQPopupMenu*>(object) )
- {
- // We need to override the paint event to draw a
- // gradient on a QToolBarExtensionWidget.
- TQToolBar* toolbar = static_cast<TQToolBar*>(TQT_TQWIDGET(object->parent()));
- TQWidget* widget = TQT_TQWIDGET(object);
- TQRect wr = widget->rect (), tr = toolbar->rect();
- TQPainter p( widget );
-
- if ( toolbar->orientation() == Qt::Horizontal )
+ //Toolbar background gradient handling
+ else if (event->type() == TQEvent::Paint &&
+ object->parent() && !qstrcmp(object->name(), kdeToolbarWidget) )
{
- Keramik::GradientPainter::renderGradient( &p, wr, widget->colorGroup().button(),
- true /*horizontal*/, false /*not a menu*/,
- 0, widget->y(), wr.width(), tr.height());
+ // Draw a gradient background for custom widgets in the toolbar
+ // that have specified a "kde toolbar widget" name.
+ renderToolbarWidgetBackground(0, TQT_TQWIDGET(object));
+
+ return false; // Now draw the contents
}
- else
+ else if (event->type() == TQEvent::Paint && object->parent() && ::tqqt_cast<TQToolBar*>(object->parent())
+ && !::tqqt_cast<TQPopupMenu*>(object) )
{
- Keramik::GradientPainter::renderGradient( &p, wr, widget->colorGroup().button(),
- false /*vertical*/, false /*not a menu*/,
- widget->x(), 0, tr.width(), wr.height());
+ // We need to override the paint event to draw a
+ // gradient on a QToolBarExtensionWidget.
+ TQToolBar* toolbar = static_cast<TQToolBar*>(TQT_TQWIDGET(object->parent()));
+ TQWidget* widget = TQT_TQWIDGET(object);
+ TQRect wr = widget->rect (), tr = toolbar->rect();
+ TQPainter p( widget );
+
+ if ( toolbar->orientation() == Qt::Horizontal )
+ {
+ Keramik::GradientPainter::renderGradient( &p, wr, widget->colorGroup().button(),
+ true /*horizontal*/, false /*not a menu*/,
+ 0, widget->y(), wr.width(), tr.height());
+ }
+ else
+ {
+ Keramik::GradientPainter::renderGradient( &p, wr, widget->colorGroup().button(),
+ false /*vertical*/, false /*not a menu*/,
+ widget->x(), 0, tr.width(), wr.height());
+ }
+
+
+ //Draw terminator line, too
+ p.setPen( toolbar->colorGroup().mid() );
+ if ( toolbar->orientation() == Qt::Horizontal )
+ p.drawLine( wr.width()-1, 0, wr.width()-1, wr.height()-1 );
+ else
+ p.drawLine( 0, wr.height()-1, wr.width()-1, wr.height()-1 );
+ return true;
+
}
-
-
- //Draw terminator line, too
- p.setPen( toolbar->colorGroup().mid() );
- if ( toolbar->orientation() == Qt::Horizontal )
- p.drawLine( wr.width()-1, 0, wr.width()-1, wr.height()-1 );
- else
- p.drawLine( 0, wr.height()-1, wr.width()-1, wr.height()-1 );
- return true;
-
- }
- // Track show events for progress bars
- if ( animateProgressBar && ::tqqt_cast<TQProgressBar*>(object) )
- {
- if ((event->type() == TQEvent::Show) && !animationTimer->isActive())
+ // Track show events for progress bars
+ if ( animateProgressBar && ::tqqt_cast<TQProgressBar*>(object) )
{
- animationTimer->start( 50, false );
+ if ((event->type() == TQEvent::Show) && !animationTimer->isActive())
+ {
+ animationTimer->start( 50, false );
+ }
}
}
+
return false;
}
diff --git a/kstyles/keramik/keramik.h b/kstyles/keramik/keramik.h
index c4c77b371..dd5ad6b31 100644
--- a/kstyles/keramik/keramik.h
+++ b/kstyles/keramik/keramik.h
@@ -50,10 +50,10 @@ public:
void renderMenuBlendPixmap( KPixmap& pix, const TQColorGroup &cg, const TQPopupMenu* ) const;
TQPixmap stylePixmap(StylePixmap stylepixmap, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQStyleOption& opt, const TQWidget* widget = 0) const;
- void polish( TQWidget* widget );
- void unPolish( TQWidget* widget );
+ void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
+ void unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void polish( TQPalette& );
- void polish( TQApplication *app );
+ void applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void drawKStylePrimitive( KStylePrimitive kpe,
TQPainter* p,
@@ -177,7 +177,7 @@ private:
//Animation support.
TQMap<TQProgressBar*, int> progAnimWidgets;
- bool eventFilter( TQObject* object, TQEvent* event );
+ virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
Keramik::TilePainter::PaintMode pmode() const
{
diff --git a/kstyles/kthemestyle/kthemestyle.cpp b/kstyles/kthemestyle/kthemestyle.cpp
index 3d5a7d149..50f14b9e3 100644
--- a/kstyles/kthemestyle/kthemestyle.cpp
+++ b/kstyles/kthemestyle/kthemestyle.cpp
@@ -414,10 +414,14 @@ KThemeStyle::~KThemeStyle()
}
-void KThemeStyle::polish( TQApplication * app )
+void KThemeStyle::applicationPolish( TQStyleControlElementData ceData, ControlElementFlags, void *ptr )
{
- if (!qstrcmp(app->argv()[0], "kicker"))
- kickerMode = true;
+ if (ceData.widgetObjectTypes.contains(TQAPPLICATION_OBJECT_NAME_STRING)) {
+ TQApplication *app = reinterpret_cast<TQApplication*>(ptr);
+ if (!qstrcmp(app->argv()[0], "kicker")) {
+ kickerMode = true;
+ }
+ }
}
@@ -458,186 +462,201 @@ void KThemeStyle::paletteChanged()
}
-void KThemeStyle::unPolish( TQApplication *app )
+void KThemeStyle::applicationUnPolish( TQStyleControlElementData ceData, ControlElementFlags, void *ptr )
{
- app->setPalette( oldPalette, true );
+ if (ceData.widgetObjectTypes.contains(TQAPPLICATION_OBJECT_NAME_STRING)) {
+ TQApplication *app = reinterpret_cast<TQApplication*>(ptr);
+ app->setPalette( oldPalette, true );
+ }
}
-bool KThemeStyle::eventFilter( TQObject* object, TQEvent* event )
+bool KThemeStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *event )
{
- if( object->inherits("KActiveLabel"))
- {
- if(event->type() == TQEvent::Move || event->type() == TQEvent::Resize ||
- event->type() == TQEvent::Show)
+ if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
+ TQObject* object = reinterpret_cast<TQObject*>(source);
+
+ if( object->inherits("KActiveLabel"))
{
- TQWidget *w = TQT_TQWIDGET(object);
- TQPoint pos(0, 0);
- pos = w->mapTo(w->topLevelWidget(), pos);
- TQPixmap pix(uncached( Background )->size());
- TQPainter p;
- p.begin(&pix);
- p.drawTiledPixmap(0, 0,
- uncached( Background )->width(),
- uncached( Background )->height() ,
- *uncached( Background ),
- pos.x(), pos.y());
- p.end();
- TQPalette pal(w->palette());
- TQBrush brush( pal.color( TQPalette::Normal,
- TQColorGroup::Background),
- pix );
- pal.setBrush(TQColorGroup::Base, brush);
- w->setPalette(pal);
+ if(event->type() == TQEvent::Move || event->type() == TQEvent::Resize ||
+ event->type() == TQEvent::Show)
+ {
+ TQWidget *w = TQT_TQWIDGET(object);
+ TQPoint pos(0, 0);
+ pos = w->mapTo(w->topLevelWidget(), pos);
+ TQPixmap pix(uncached( Background )->size());
+ TQPainter p;
+ p.begin(&pix);
+ p.drawTiledPixmap(0, 0,
+ uncached( Background )->width(),
+ uncached( Background )->height() ,
+ *uncached( Background ),
+ pos.x(), pos.y());
+ p.end();
+ TQPalette pal(w->palette());
+ TQBrush brush( pal.color( TQPalette::Normal,
+ TQColorGroup::Background),
+ pix );
+ pal.setBrush(TQColorGroup::Base, brush);
+ w->setPalette(pal);
+ }
+ }
+ if (!qstrcmp(object->name(), "kde toolbar widget") && object->inherits(TQLABEL_OBJECT_NAME_STRING))
+ {
+ TQWidget* lb = TQT_TQWIDGET(object);
+ if (lb->backgroundMode() == TQt::PaletteButton)
+ lb->setBackgroundMode(TQt::PaletteBackground);
+ removeObjectEventHandler(ceData, elementFlags, source, this);
}
- }
- if (!qstrcmp(object->name(), "kde toolbar widget") && object->inherits(TQLABEL_OBJECT_NAME_STRING))
- {
- TQWidget* lb = TQT_TQWIDGET(object);
- if (lb->backgroundMode() == TQt::PaletteButton)
- lb->setBackgroundMode(TQt::PaletteBackground);
- lb->removeEventFilter(this);
}
- return KStyle::eventFilter(object, event);
+ return KStyle::objectEventHandler(ceData, elementFlags, source, event);
}
-void KThemeStyle::polish( TQWidget *w )
+void KThemeStyle::polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{
- if (::tqqt_cast<TQStatusBar*>(w))
- w->setPaletteBackgroundColor(TQApplication::palette().color(TQPalette::Normal, TQColorGroup::Background));
-
- if (::tqqt_cast<TQLabel*>(w) && !qstrcmp(w->name(), "kde toolbar widget"))
- w->installEventFilter(this);
-
- if (w->backgroundPixmap() && !w->isTopLevel() &&
- (!kickerMode ||
- (!w->inherits("TaskBar") && !w->inherits("TaskBarContainer") && !w->inherits("TaskbarApplet") && !w->inherits("ContainerArea") && !w->inherits("AppletHandle"))))
- {
- //The brushHandle check verifies that the bg pixmap is actually the brush..
- if (!brushHandleSet || brushHandle == w->backgroundPixmap()->handle())
+ if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
+ TQWidget *w = reinterpret_cast<TQWidget*>(ptr);
+
+ if (::tqqt_cast<TQStatusBar*>(w))
+ w->setPaletteBackgroundColor(TQApplication::palette().color(TQPalette::Normal, TQColorGroup::Background));
+
+ if (::tqqt_cast<TQLabel*>(w) && !qstrcmp(w->name(), "kde toolbar widget"))
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+
+ if (w->backgroundPixmap() && !w->isTopLevel() &&
+ (!kickerMode ||
+ (!w->inherits("TaskBar") && !w->inherits("TaskBarContainer") && !w->inherits("TaskbarApplet") && !w->inherits("ContainerArea") && !w->inherits("AppletHandle"))))
{
- w->setBackgroundOrigin( TQWidget::WindowOrigin );
+ //The brushHandle check verifies that the bg pixmap is actually the brush..
+ if (!brushHandleSet || brushHandle == w->backgroundPixmap()->handle())
+ {
+ w->setBackgroundOrigin( TQWidget::WindowOrigin );
+ }
}
- }
- if (w->inherits("KActiveLabel"))
- {
- if (uncached( Background ))
- w->installEventFilter(this);
- }
+ if (w->inherits("KActiveLabel"))
+ {
+ if (uncached( Background ))
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ }
- if ( w->inherits( "QTipLabel" ) )
- {
- polishLock = true;
+ if ( w->inherits( "QTipLabel" ) )
+ {
+ polishLock = true;
- TQColorGroup clrGroup( Qt::black, TQColor( 255, 255, 220 ),
- TQColor( 96, 96, 96 ), Qt::black, Qt::black,
- Qt::black, TQColor( 255, 255, 220 ) );
- TQPalette toolTip ( clrGroup, clrGroup, clrGroup );
+ TQColorGroup clrGroup( Qt::black, TQColor( 255, 255, 220 ),
+ TQColor( 96, 96, 96 ), Qt::black, Qt::black,
+ Qt::black, TQColor( 255, 255, 220 ) );
+ TQPalette toolTip ( clrGroup, clrGroup, clrGroup );
- TQToolTip::setPalette( toolTip );
- polishLock = false;
- }
+ TQToolTip::setPalette( toolTip );
+ polishLock = false;
+ }
- if ( w->inherits( "KonqIconViewWidget" ) ) //Konqueror background hack/workaround
- {
- w->setPalette( oldPalette );
- return ;
- }
+ if ( w->inherits( "KonqIconViewWidget" ) ) //Konqueror background hack/workaround
+ {
+ w->setPalette( oldPalette );
+ return ;
+ }
- if ( ::tqqt_cast<TQMenuBar*>(w) )
- {
- w->setBackgroundMode( TQWidget::NoBackground );
- }
- else if ( w->inherits( "KToolBarSeparator" ) || w->inherits( "QToolBarSeparator" ) )
- {
- w->setBackgroundMode( TQWidget::PaletteBackground );
- }
- else if ( ::tqqt_cast<TQPopupMenu*>(w) )
- {
- popupPalette = w->palette();
- if ( isColor( MenuItem ) || isColor( MenuItemDown ) )
+ if ( ::tqqt_cast<TQMenuBar*>(w) )
{
- TQPalette newPal( w->palette() );
- if ( isColor( MenuItem ) )
- {
- newPal.setActive( *colorGroup( newPal.active(), MenuItem ) );
- newPal.setDisabled( *colorGroup( newPal.active(), MenuItem ) );
- }
- if ( isColor( MenuItemDown ) )
+ w->setBackgroundMode( TQWidget::NoBackground );
+ }
+ else if ( w->inherits( "KToolBarSeparator" ) || w->inherits( "QToolBarSeparator" ) )
+ {
+ w->setBackgroundMode( TQWidget::PaletteBackground );
+ }
+ else if ( ::tqqt_cast<TQPopupMenu*>(w) )
+ {
+ popupPalette = w->palette();
+ if ( isColor( MenuItem ) || isColor( MenuItemDown ) )
{
- newPal.setActive( *colorGroup( newPal.active(), MenuItemDown ) );
+ TQPalette newPal( w->palette() );
+ if ( isColor( MenuItem ) )
+ {
+ newPal.setActive( *colorGroup( newPal.active(), MenuItem ) );
+ newPal.setDisabled( *colorGroup( newPal.active(), MenuItem ) );
+ }
+ if ( isColor( MenuItemDown ) )
+ {
+ newPal.setActive( *colorGroup( newPal.active(), MenuItemDown ) );
+ }
+ w->setPalette( newPal );
}
- w->setPalette( newPal );
- }
- w->setBackgroundMode( TQWidget::NoBackground );
- }
- else if ( ::tqqt_cast<TQCheckBox*>(w) )
- {
- if ( isColor( IndicatorOff ) || isColor( IndicatorOn ) )
+ w->setBackgroundMode( TQWidget::NoBackground );
+ }
+ else if ( ::tqqt_cast<TQCheckBox*>(w) )
{
- TQPalette newPal( w->palette() );
- if ( isColor( IndicatorOff ) )
+ if ( isColor( IndicatorOff ) || isColor( IndicatorOn ) )
{
- newPal.setActive( *colorGroup( newPal.active(), IndicatorOff ) );
- newPal.setDisabled( *colorGroup( newPal.active(), IndicatorOff ) );
+ TQPalette newPal( w->palette() );
+ if ( isColor( IndicatorOff ) )
+ {
+ newPal.setActive( *colorGroup( newPal.active(), IndicatorOff ) );
+ newPal.setDisabled( *colorGroup( newPal.active(), IndicatorOff ) );
+ }
+ if ( isColor( IndicatorOn ) )
+ newPal.setActive( *colorGroup( newPal.active(), IndicatorOn ) );
+ w->setPalette( newPal );
}
- if ( isColor( IndicatorOn ) )
- newPal.setActive( *colorGroup( newPal.active(), IndicatorOn ) );
- w->setPalette( newPal );
}
- }
- else if ( ::tqqt_cast<TQRadioButton*>(w) )
- {
- if ( isColor( ExIndicatorOff ) || isColor( ExIndicatorOn ) )
+ else if ( ::tqqt_cast<TQRadioButton*>(w) )
{
- TQPalette newPal( w->palette() );
- if ( isColor( ExIndicatorOff ) )
+ if ( isColor( ExIndicatorOff ) || isColor( ExIndicatorOn ) )
{
- newPal.setActive( *colorGroup( newPal.active(), ExIndicatorOff ) );
- newPal.setDisabled( *colorGroup( newPal.active(),
- ExIndicatorOff ) );
+ TQPalette newPal( w->palette() );
+ if ( isColor( ExIndicatorOff ) )
+ {
+ newPal.setActive( *colorGroup( newPal.active(), ExIndicatorOff ) );
+ newPal.setDisabled( *colorGroup( newPal.active(),
+ ExIndicatorOff ) );
+ }
+ if ( isColor( ExIndicatorOn ) )
+ newPal.setActive( *colorGroup( newPal.active(), ExIndicatorOn ) );
+ w->setPalette( newPal );
}
- if ( isColor( ExIndicatorOn ) )
- newPal.setActive( *colorGroup( newPal.active(), ExIndicatorOn ) );
- w->setPalette( newPal );
}
}
- KStyle::polish( w );
+ KStyle::polish( ceData, elementFlags, ptr );
}
-void KThemeStyle::unPolish( TQWidget* w )
+void KThemeStyle::unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{
- if (w->backgroundPixmap() && !w->isTopLevel())
- {
- //The brushHandle check verifies that the bg pixmap is actually the brush..
- if (!brushHandleSet || brushHandle ==w->backgroundPixmap()->handle())
+ if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
+ TQWidget *w = reinterpret_cast<TQWidget*>(ptr);
+
+ if (w->backgroundPixmap() && !w->isTopLevel())
{
- w->setBackgroundOrigin( TQWidget::WidgetOrigin );
+ //The brushHandle check verifies that the bg pixmap is actually the brush..
+ if (!brushHandleSet || brushHandle ==w->backgroundPixmap()->handle())
+ {
+ w->setBackgroundOrigin( TQWidget::WidgetOrigin );
+ }
}
+
+ //Toolbar labels should nornally be PaletteButton
+ if ( ::tqqt_cast<TQLabel*>(w) && !qstrcmp(w->name(), "kde toolbar widget"))
+ w->setBackgroundMode( TQWidget::PaletteButton );
+
+ //The same for menu bars, popup menus
+ else if ( ::tqqt_cast<TQMenuBar*>(w) || ::tqqt_cast<TQPopupMenu*>(w) )
+ w->setBackgroundMode( TQWidget::PaletteButton );
+
+ //For toolbar internal separators, return to button, too (can't use tqqt_cast here since don't have access to the class)
+ else if ( w->inherits( "KToolBarSeparator" ) || w->inherits( "QToolBarSeparator" ) )
+ w->setBackgroundMode( TQWidget::PaletteButton );
+
+ //For scrollbars, we don't do much, since the widget queries the style on the switch
+
+ //Drop some custom palettes. ### this really should check the serial number to be 100% correct.
+ if ( ::tqqt_cast<TQPopupMenu*>(w) || ::tqqt_cast<TQCheckBox*>(w) || ::tqqt_cast<TQRadioButton*>(w) || ::tqqt_cast<TQStatusBar*>(w) )
+ w->unsetPalette();
}
- //Toolbar labels should nornally be PaletteButton
- if ( ::tqqt_cast<TQLabel*>(w) && !qstrcmp(w->name(), "kde toolbar widget"))
- w->setBackgroundMode( TQWidget::PaletteButton );
-
- //The same for menu bars, popup menus
- else if ( ::tqqt_cast<TQMenuBar*>(w) || ::tqqt_cast<TQPopupMenu*>(w) )
- w->setBackgroundMode( TQWidget::PaletteButton );
-
- //For toolbar internal separators, return to button, too (can't use tqqt_cast here since don't have access to the class)
- else if ( w->inherits( "KToolBarSeparator" ) || w->inherits( "QToolBarSeparator" ) )
- w->setBackgroundMode( TQWidget::PaletteButton );
-
- //For scrollbars, we don't do much, since the widget queries the style on the switch
-
- //Drop some custom palettes. ### this really should check the serial number to be 100% correct.
- if ( ::tqqt_cast<TQPopupMenu*>(w) || ::tqqt_cast<TQCheckBox*>(w) || ::tqqt_cast<TQRadioButton*>(w) || ::tqqt_cast<TQStatusBar*>(w) )
- w->unsetPalette();
-
- KStyle::unPolish( w );
+ KStyle::unPolish( ceData, elementFlags, ptr );
}
diff --git a/kstyles/kthemestyle/kthemestyle.h b/kstyles/kthemestyle/kthemestyle.h
index ea162d966..d6e28afc2 100644
--- a/kstyles/kthemestyle/kthemestyle.h
+++ b/kstyles/kthemestyle/kthemestyle.h
@@ -143,15 +143,15 @@ public:
virtual TQRect subRect(SubRect, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *) const;
- virtual void polish( TQWidget* );
- virtual void unPolish( TQWidget* );
- virtual bool eventFilter( TQObject* object, TQEvent* event );
+ virtual void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
+ virtual void unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
+ virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
/**
* By default this just sets the background brushes to the pixmapped
* background.
*/
- virtual void polish( TQApplication *app );
- virtual void unPolish( TQApplication* );
+ virtual void applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
+ virtual void applicationUnPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
/** \internal */
// to make it possible for derived classes to overload this function
diff --git a/kstyles/plastik/plastik.cpp b/kstyles/plastik/plastik.cpp
index df61ebe2c..7dfc180ae 100644
--- a/kstyles/plastik/plastik.cpp
+++ b/kstyles/plastik/plastik.cpp
@@ -227,83 +227,95 @@ PlastikStyle::~PlastikStyle()
delete verticalLine;
}
-void PlastikStyle::polish(TQApplication* app)
+void PlastikStyle::applicationPolish(TQStyleControlElementData ceData, ControlElementFlags, void *ptr)
{
- if (!qstrcmp(app->argv()[0], "kicker"))
- kickerMode = true;
- else if (!qstrcmp(app->argv()[0], "korn"))
- kornMode = true;
-}
-
-void PlastikStyle::polish(TQWidget* widget)
-{
- if( !strcmp(widget->name(), "__khtml") ) { // is it a khtml widget...?
- khtmlWidgets[widget] = true;
- connect(widget, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(khtmlWidgetDestroyed(TQObject*)));
- }
-
- // use tqqt_cast where possible to check if the widget inheits one of the classes. might improve
- // performance compared to TQObject::inherits()
- if ( ::tqqt_cast<TQPushButton*>(widget) || ::tqqt_cast<TQComboBox*>(widget) ||
- ::tqqt_cast<TQSpinWidget*>(widget) || ::tqqt_cast<TQSlider*>(widget) ||
- ::tqqt_cast<TQCheckBox*>(widget) || ::tqqt_cast<TQRadioButton*>(widget) ||
- ::tqqt_cast<TQToolButton*>(widget) || widget->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) )
- {
-// widget->setBackgroundMode(PaletteBackground);
- widget->installEventFilter(this);
- } else if (::tqqt_cast<TQLineEdit*>(widget)) {
- widget->installEventFilter(this);
- } else if (::tqqt_cast<TQTabBar*>(widget)) {
- widget->setMouseTracking(true);
- widget->installEventFilter(this);
- } else if (::tqqt_cast<TQPopupMenu*>(widget)) {
- widget->setBackgroundMode( NoBackground );
- } else if ( !qstrcmp(widget->name(), "kde toolbar widget") ) {
- widget->installEventFilter(this);
- }
+ if (ceData.widgetObjectTypes.contains(TQAPPLICATION_OBJECT_NAME_STRING)) {
+ TQApplication *app = reinterpret_cast<TQApplication*>(ptr);
- if( _animateProgressBar && ::tqqt_cast<TQProgressBar*>(widget) )
- {
- widget->installEventFilter(this);
- progAnimWidgets[widget] = 0;
- connect(widget, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(progressBarDestroyed(TQObject*)));
- if (!animationTimer->isActive())
- animationTimer->start( 50, false );
+ if (!qstrcmp(app->argv()[0], "kicker"))
+ kickerMode = true;
+ else if (!qstrcmp(app->argv()[0], "korn"))
+ kornMode = true;
}
-
- KStyle::polish(widget);
}
-void PlastikStyle::unPolish(TQWidget* widget)
+void PlastikStyle::polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{
- if( !strcmp(widget->name(), "__khtml") ) { // is it a khtml widget...?
- khtmlWidgets.remove(widget);
+ if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
+ TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
+
+ if( !strcmp(widget->name(), "__khtml") ) { // is it a khtml widget...?
+ khtmlWidgets[widget] = true;
+ connect(widget, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(khtmlWidgetDestroyed(TQObject*)));
+ }
+
+ // use tqqt_cast where possible to check if the widget inheits one of the classes. might improve
+ // performance compared to TQObject::inherits()
+ if ( ::tqqt_cast<TQPushButton*>(widget) || ::tqqt_cast<TQComboBox*>(widget) ||
+ ::tqqt_cast<TQSpinWidget*>(widget) || ::tqqt_cast<TQSlider*>(widget) ||
+ ::tqqt_cast<TQCheckBox*>(widget) || ::tqqt_cast<TQRadioButton*>(widget) ||
+ ::tqqt_cast<TQToolButton*>(widget) || widget->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) )
+ {
+ // widget->setBackgroundMode(PaletteBackground);
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ } else if (::tqqt_cast<TQLineEdit*>(widget)) {
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ } else if (::tqqt_cast<TQTabBar*>(widget)) {
+ widget->setMouseTracking(true);
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ } else if (::tqqt_cast<TQPopupMenu*>(widget)) {
+ widget->setBackgroundMode( NoBackground );
+ } else if ( !qstrcmp(widget->name(), "kde toolbar widget") ) {
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ }
+
+ if( _animateProgressBar && ::tqqt_cast<TQProgressBar*>(widget) )
+ {
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ progAnimWidgets[widget] = 0;
+ connect(widget, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(progressBarDestroyed(TQObject*)));
+ if (!animationTimer->isActive())
+ animationTimer->start( 50, false );
+ }
}
- // use tqqt_cast to check if the widget inheits one of the classes.
- if ( ::tqqt_cast<TQPushButton*>(widget) || ::tqqt_cast<TQComboBox*>(widget) ||
- ::tqqt_cast<TQSpinWidget*>(widget) || ::tqqt_cast<TQSlider*>(widget) ||
- ::tqqt_cast<TQCheckBox*>(widget) || ::tqqt_cast<TQRadioButton*>(widget) ||
- ::tqqt_cast<TQToolButton*>(widget) || ::tqqt_cast<TQLineEdit*>(widget) ||
- widget->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) )
- {
- widget->removeEventFilter(this);
- }
- else if (::tqqt_cast<TQTabBar*>(widget)) {
- widget->setMouseTracking(false);
- widget->removeEventFilter(this);
- } else if (::tqqt_cast<TQPopupMenu*>(widget)) {
- widget->setBackgroundMode( PaletteBackground );
- } else if ( !qstrcmp(widget->name(), "kde toolbar widget") ) {
- widget->removeEventFilter(this);
- }
+ KStyle::polish(ceData, elementFlags, ptr);
+}
- if ( ::tqqt_cast<TQProgressBar*>(widget) )
- {
- progAnimWidgets.remove(widget);
+void PlastikStyle::unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
+{
+ if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
+ TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
+
+ if( !strcmp(widget->name(), "__khtml") ) { // is it a khtml widget...?
+ khtmlWidgets.remove(widget);
+ }
+
+ // use tqqt_cast to check if the widget inheits one of the classes.
+ if ( ::tqqt_cast<TQPushButton*>(widget) || ::tqqt_cast<TQComboBox*>(widget) ||
+ ::tqqt_cast<TQSpinWidget*>(widget) || ::tqqt_cast<TQSlider*>(widget) ||
+ ::tqqt_cast<TQCheckBox*>(widget) || ::tqqt_cast<TQRadioButton*>(widget) ||
+ ::tqqt_cast<TQToolButton*>(widget) || ::tqqt_cast<TQLineEdit*>(widget) ||
+ widget->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) )
+ {
+ removeObjectEventHandler(ceData, elementFlags, ptr, this);
+ }
+ else if (::tqqt_cast<TQTabBar*>(widget)) {
+ widget->setMouseTracking(false);
+ removeObjectEventHandler(ceData, elementFlags, ptr, this);
+ } else if (::tqqt_cast<TQPopupMenu*>(widget)) {
+ widget->setBackgroundMode( PaletteBackground );
+ } else if ( !qstrcmp(widget->name(), "kde toolbar widget") ) {
+ removeObjectEventHandler(ceData, elementFlags, ptr, this);
+ }
+
+ if ( ::tqqt_cast<TQProgressBar*>(widget) )
+ {
+ progAnimWidgets.remove(widget);
+ }
}
- KStyle::unPolish(widget);
+ KStyle::unPolish(ceData, elementFlags, ptr);
}
void PlastikStyle::khtmlWidgetDestroyed(TQObject* obj)
@@ -3466,104 +3478,108 @@ int PlastikStyle::styleHint( TQ_StyleHint stylehint,
}
}
-bool PlastikStyle::eventFilter(TQObject *obj, TQEvent *ev)
+bool PlastikStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *ev )
{
- if (KStyle::eventFilter(obj, ev) )
+ if (KStyle::objectEventHandler(ceData, elementFlags, source, ev) )
return true;
- 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) )
- {
- if ((ev->type() == TQEvent::Show) && !animationTimer->isActive())
- {
- animationTimer->start( 50, false );
- }
- }
- if ( !qstrcmp(obj->name(), "kde toolbar widget") )
- {
- TQWidget* lb = TQT_TQWIDGET(obj);
- if (lb->backgroundMode() == TQt::PaletteButton)
- lb->setBackgroundMode(TQt::PaletteBackground);
- lb->removeEventFilter(this);
+ if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
+ 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) )
+ {
+ if ((ev->type() == TQEvent::Show) && !animationTimer->isActive())
+ {
+ animationTimer->start( 50, false );
+ }
+ }
+ if ( !qstrcmp(obj->name(), "kde toolbar widget") )
+ {
+ TQWidget* lb = TQT_TQWIDGET(obj);
+ if (lb->backgroundMode() == TQt::PaletteButton)
+ lb->setBackgroundMode(TQt::PaletteBackground);
+ removeObjectEventHandler(ceData, elementFlags, source, this);
+ }
}
return false;
diff --git a/kstyles/plastik/plastik.h b/kstyles/plastik/plastik.h
index 507222412..995bb7c85 100644
--- a/kstyles/plastik/plastik.h
+++ b/kstyles/plastik/plastik.h
@@ -62,9 +62,9 @@ public:
PlastikStyle();
virtual ~PlastikStyle();
- void polish(TQApplication* app );
- void polish(TQWidget* widget );
- void unPolish(TQWidget* widget );
+ void applicationPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
+ void polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
+ void unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void drawKStylePrimitive(KStylePrimitive kpe,
TQPainter* p,
@@ -265,8 +265,8 @@ protected:
virtual void renderMenuBlendPixmap( KPixmap& pix, const TQColorGroup& cg,
const TQPopupMenu* popup ) const;
-
- bool eventFilter(TQObject *, TQEvent *);
+
+ virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
TQWidget* hoverWidget;
protected slots: