Update for new style API

pull/16/head
Timothy Pearson 12 years ago
parent 2ba2bd6da0
commit 2053998fef

@ -104,41 +104,46 @@ AsteroidStyle::~AsteroidStyle()
* get deleted here. */ * 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 if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
authentic. -clee */ TQWidget *w = reinterpret_cast<TQWidget*>(ptr);
TQPalette wp = w->palette(); /* Screwing with the palette is fun! and required in order to make it feel
//wp.setColor(TQColorGroup::Dark, wp.active().color(TQColorGroup::Button).dark(350)); authentic. -clee */
wp.setColor(TQColorGroup::Dark, TQColor(128, 128, 128)); TQPalette wp = w->palette();
wp.setColor(TQColorGroup::Mid, wp.active().color(TQColorGroup::Button).dark(150)); // Which GUI element(s) does this correspond to? //wp.setColor(TQColorGroup::Dark, wp.active().color(TQColorGroup::Button).dark(350));
wp.setColor(TQColorGroup::Dark, TQColor(128, 128, 128));
bool isProtectedObject = false; wp.setColor(TQColorGroup::Mid, wp.active().color(TQColorGroup::Button).dark(150)); // Which GUI element(s) does this correspond to?
TQObject *curparent = TQT_TQOBJECT(w);
while (curparent) { bool isProtectedObject = false;
if (curparent->inherits("KonqFileTip") || curparent->inherits("AppletItem") TQObject *curparent = TQT_TQOBJECT(w);
|| curparent->inherits("KJanusWidget") while (curparent) {
) { if (curparent->inherits("KonqFileTip") || curparent->inherits("AppletItem")
isProtectedObject = true; || 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)) { if (ceData.widgetObjectTypes.contains(TQPUSHBUTTON_OBJECT_NAME_STRING)) {
w->installEventFilter(this); installObjectEventHandler(ceData, elementFlags, ptr, this);
} else { }
KStyle::polish(w); 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 Changes some application-wide settings
*/ */
void void
AsteroidStyle::polish( TQApplication* app) AsteroidStyle::applicationPolish(TQStyleControlElementData, ControlElementFlags, void *)
{ {
TQPalette wp = TQApplication::palette(); TQPalette wp = TQApplication::palette();
wp.setColor(TQColorGroup::Dark, TQColor(128, 128, 128)); wp.setColor(TQColorGroup::Dark, TQColor(128, 128, 128));
@ -158,7 +163,7 @@ AsteroidStyle::polish( TQApplication* app)
/*! \reimp /*! \reimp
*/ */
void 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 ) ); pixelMetric( TQStyle::PM_DefaultFrameWidth, ceData, elementFlags, tb ) );
int alignment = TQt::AlignCenter | TQt::ShowPrefix; 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; alignment |= TQt::NoAccel;
tr.setWidth(tr.width()+4); // Compensate for text appearing too far to the left 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()); // 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 ); bool etchtext = styleHint( SH_EtchDisabledText, ceData, elementFlags );
int alignment = TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft; 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; alignment |= TQt::NoAccel;
//TQRect r_offset = TQRect(r.x()+ETCH_X_OFFSET, r.y()+ETCH_Y_OFFSET, r.width(), r.height()); //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 ); bool etchtext = styleHint( SH_EtchDisabledText, ceData, elementFlags );
int alignment = TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft; 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; alignment |= TQt::NoAccel;
// TQRect r_offset = TQRect(r.x()+ETCH_X_OFFSET, r.y()+ETCH_Y_OFFSET, r.width(), r.height()); // 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 if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
default button to whatever pushbutton the user presses the mouse TQObject* o = reinterpret_cast<TQObject*>(source);
on. I _think_ this emulates that properly. -clee */ /* Win2K has this interesting behaviour where it sets the current
if (o->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) { default button to whatever pushbutton the user presses the mouse
if (e->type() == TQEvent::MouseButtonPress) { on. I _think_ this emulates that properly. -clee */
TQPushButton *pb = dynamic_cast<TQPushButton *>(o); if (o->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) {
pb->setDefault(TRUE); if (e->type() == TQEvent::MouseButtonPress) {
TQPushButton *pb = dynamic_cast<TQPushButton *>(o);
pb->setDefault(TRUE);
}
} }
} }

@ -17,10 +17,10 @@ public:
AsteroidStyle(); AsteroidStyle();
virtual ~AsteroidStyle(); virtual ~AsteroidStyle();
void polish(TQWidget *); void polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void unPolish(TQWidget *); void unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void polish( TQApplication* ); void applicationPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void unPolish( TQApplication* ); void applicationUnPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void renderSliderHandle(TQPainter *p, void renderSliderHandle(TQPainter *p,
@ -116,8 +116,7 @@ public:
const TQStyleOption &, const TQStyleOption &,
const TQWidget * = 0) const; const TQWidget * = 0) const;
protected: virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
bool eventFilter(TQObject *, TQEvent *);
protected slots: protected slots:
void paletteChanged(); void paletteChanged();

@ -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 (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
if (widget->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) { TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
widget->installEventFilter(this); // Put in order of highest occurrence to maximise hit rate
} else if (widget->inherits(TQMENUBAR_OBJECT_NAME_STRING) || widget->inherits(TQPOPUPMENU_OBJECT_NAME_STRING)) { if (widget->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) {
widget->setBackgroundMode(TQWidget::NoBackground); installObjectEventHandler(ceData, elementFlags, ptr, this);
} else if (type == HighColor && widget->inherits("QToolBarExtensionWidget")) { } else if (widget->inherits(TQMENUBAR_OBJECT_NAME_STRING) || widget->inherits(TQPOPUPMENU_OBJECT_NAME_STRING)) {
widget->installEventFilter(this); widget->setBackgroundMode(TQWidget::NoBackground);
} else if ( !qstrcmp( widget->name(), kdeToolbarWidget) ) { } else if (type == HighColor && widget->inherits("QToolBarExtensionWidget")) {
widget->setBackgroundMode( NoBackground ); // We paint the whole background. installObjectEventHandler(ceData, elementFlags, ptr, this);
widget->installEventFilter(this); } else if ( !qstrcmp( widget->name(), kdeToolbarWidget) ) {
} else if (widget->inherits(TQTOOLBOXBUTTON_OBJECT_NAME_STRING)) { widget->setBackgroundMode( NoBackground ); // We paint the whole background.
TQFont font = widget->font(); installObjectEventHandler(ceData, elementFlags, ptr, this);
font.setBold(true); } else if (widget->inherits(TQTOOLBOXBUTTON_OBJECT_NAME_STRING)) {
widget->setFont(font); 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)) { if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
widget->removeEventFilter(this); TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
} if (widget->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) {
else if (widget->inherits(TQMENUBAR_OBJECT_NAME_STRING) || widget->inherits(TQPOPUPMENU_OBJECT_NAME_STRING)) { removeObjectEventHandler(ceData, elementFlags, ptr, this);
widget->setBackgroundMode(TQWidget::PaletteBackground); }
} else if (type == HighColor && widget->inherits("QToolBarExtensionWidget")) { else if (widget->inherits(TQMENUBAR_OBJECT_NAME_STRING) || widget->inherits(TQPOPUPMENU_OBJECT_NAME_STRING)) {
widget->removeEventFilter(this); widget->setBackgroundMode(TQWidget::PaletteBackground);
} else if ( !qstrcmp( widget->name(), kdeToolbarWidget) ) { } else if (type == HighColor && widget->inherits("QToolBarExtensionWidget")) {
widget->removeEventFilter(this); removeObjectEventHandler(ceData, elementFlags, ptr, this);
widget->setBackgroundMode( PaletteBackground ); } 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; return true;
TQToolBar* toolbar; if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
TQObject* object = reinterpret_cast<TQObject*>(source);
// Handle push button hover effects. TQToolBar* toolbar;
TQPushButton* button = dynamic_cast<TQPushButton*>(object);
if ( button ) // Handle push button hover effects.
{ TQPushButton* button = dynamic_cast<TQPushButton*>(object);
if ( (event->type() == TQEvent::Enter) && if ( button )
(button->isEnabled()) ) { {
hoverWidget = button; if ( (event->type() == TQEvent::Enter) &&
button->repaint( false ); (button->isEnabled()) ) {
} hoverWidget = button;
else if ( (event->type() == TQEvent::Leave) && button->repaint( false );
(TQT_BASE_OBJECT(object) == TQT_BASE_OBJECT(hoverWidget)) ) { }
hoverWidget = 0L; else if ( (event->type() == TQEvent::Leave) &&
button->repaint( false ); (TQT_BASE_OBJECT(object) == TQT_BASE_OBJECT(hoverWidget)) ) {
} hoverWidget = 0L;
} else if ( object->parent() && !qstrcmp( object->name(), kdeToolbarWidget ) ) button->repaint( false );
{ }
// Draw a gradient background for custom widgets in the toolbar } else if ( object->parent() && !qstrcmp( object->name(), kdeToolbarWidget ) )
// that have specified a "kde toolbar widget" name. {
// Draw a gradient background for custom widgets in the toolbar
if (event->type() == TQEvent::Paint ) { // that have specified a "kde toolbar widget" name.
// Find the top-level toolbar of this widget, since it may be nested in other
// widgets that are on the toolbar. if (event->type() == TQEvent::Paint ) {
TQWidget *widget = TQT_TQWIDGET(object); // Find the top-level toolbar of this widget, since it may be nested in other
TQWidget *parent = TQT_TQWIDGET(object->parent()); // widgets that are on the toolbar.
int x_offset = widget->x(), y_offset = widget->y(); TQWidget *widget = TQT_TQWIDGET(object);
while (parent && parent->parent() && !qstrcmp( parent->name(), kdeToolbarWidget ) ) TQWidget *parent = TQT_TQWIDGET(object->parent());
{ int x_offset = widget->x(), y_offset = widget->y();
x_offset += parent->x(); while (parent && parent->parent() && !qstrcmp( parent->name(), kdeToolbarWidget ) )
y_offset += parent->y(); {
parent = TQT_TQWIDGET(parent->parent()); 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;
} }
} }

@ -65,8 +65,8 @@ class HighColorStyle : public KStyle
HighColorStyle( StyleType ); HighColorStyle( StyleType );
virtual ~HighColorStyle(); virtual ~HighColorStyle();
void polish( TQWidget* widget ); void polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void unPolish( TQWidget* widget ); void unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void renderMenuBlendPixmap( KPixmap& pix, const TQColorGroup &cg, void renderMenuBlendPixmap( KPixmap& pix, const TQColorGroup &cg,
const TQPopupMenu* popup ) const; const TQPopupMenu* popup ) const;
@ -158,8 +158,9 @@ class HighColorStyle : public KStyle
const TQStyleOption& = TQStyleOption::Default, const TQStyleOption& = TQStyleOption::Default,
const TQWidget *widget = 0 ) const; const TQWidget *widget = 0 ) const;
virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
protected: protected:
bool eventFilter( TQObject *object, TQEvent *event );
void renderGradient( TQPainter* p, void renderGradient( TQPainter* p,
const TQRect& r, const TQRect& r,

@ -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) if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
|| widget->inherits (TQCOMBOBOX_OBJECT_NAME_STRING) TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
|| widget->inherits (TQSPINWIDGET_OBJECT_NAME_STRING)
|| widget->inherits (TQLINEEDIT_OBJECT_NAME_STRING) if (widget->inherits (TQBUTTON_OBJECT_NAME_STRING)
|| widget->inherits (TQTEXTEDIT_OBJECT_NAME_STRING)) || widget->inherits (TQCOMBOBOX_OBJECT_NAME_STRING)
{ || widget->inherits (TQSPINWIDGET_OBJECT_NAME_STRING)
widget->installEventFilter (this); || widget->inherits (TQLINEEDIT_OBJECT_NAME_STRING)
|| widget->inherits (TQTEXTEDIT_OBJECT_NAME_STRING))
TQSpinWidget* spinwidget = dynamic_cast<TQSpinWidget*>(widget); {
if (spinwidget && spinwidget->editWidget()) installObjectEventHandler(ceData, elementFlags, ptr, this);
spinwidget->editWidget()->installEventFilter (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)) if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
widget->removeEventFilter (this); TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
KStyle::unPolish (widget); 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 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 (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
if (widget) TQObject* object = reinterpret_cast<TQObject*>(source);
{
// Handle hover effects. TQWidget* widget = dynamic_cast<TQWidget*>(object);
if (event->type() == TQEvent::Enter if (widget)
&& (widget->inherits (TQBUTTON_OBJECT_NAME_STRING)
|| widget->inherits (TQCOMBOBOX_OBJECT_NAME_STRING)
|| widget->inherits (TQSPINWIDGET_OBJECT_NAME_STRING)))
{ {
hoverWidget = widget; // Handle hover effects.
widget->repaint (false); if (event->type() == TQEvent::Enter
}
else if (event->type() == TQEvent::Leave
&& (widget->inherits (TQBUTTON_OBJECT_NAME_STRING) && (widget->inherits (TQBUTTON_OBJECT_NAME_STRING)
|| widget->inherits (TQCOMBOBOX_OBJECT_NAME_STRING) || widget->inherits (TQCOMBOBOX_OBJECT_NAME_STRING)
|| widget->inherits (TQSPINWIDGET_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);
} }
else if (event->type() == TQEvent::Leave
if (widgetparent) && (widget->inherits (TQBUTTON_OBJECT_NAME_STRING)
widgetparent->repaint (false); || widget->inherits (TQCOMBOBOX_OBJECT_NAME_STRING)
else || widget->inherits (TQSPINWIDGET_OBJECT_NAME_STRING)))
{
if (TQT_BASE_OBJECT(object) == TQT_BASE_OBJECT(hoverWidget))
hoverWidget = 0L;
widget->repaint (false); 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: // vim: set noet ts=4 sw=4:

@ -56,8 +56,8 @@ class HighContrastStyle : public KStyle
void polish( TQPalette& pal ); void polish( TQPalette& pal );
void polish( TQWidget* widget ); void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void unPolish( TQWidget* widget ); void unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void drawKStylePrimitive( KStylePrimitive kpe, void drawKStylePrimitive( KStylePrimitive kpe,
TQPainter* p, TQPainter* p,
@ -150,7 +150,7 @@ class HighContrastStyle : public KStyle
TQRect subRect (SubRect subrect, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget * widget) const; TQRect subRect (SubRect subrect, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget * widget) const;
protected: protected:
bool eventFilter( TQObject *object, TQEvent *event ); virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
TQWidget *hoverWidget; TQWidget *hoverWidget;

@ -331,86 +331,98 @@ KeramikStyle::~KeramikStyle()
KeramikDbCleanup(); KeramikDbCleanup();
} }
void KeramikStyle::polish(TQApplication* app) void KeramikStyle::applicationPolish(TQStyleControlElementData ceData, ControlElementFlags, void *ptr)
{ {
if (!qstrcmp(app->argv()[0], "kicker")) if (ceData.widgetObjectTypes.contains(TQAPPLICATION_OBJECT_NAME_STRING)) {
kickerMode = true; 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 (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
if ( widget->inherits( TQPUSHBUTTON_OBJECT_NAME_STRING ) || widget->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) || widget->inherits(TQTOOLBUTTON_OBJECT_NAME_STRING) ) TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
{
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 (animateProgressBar && ::tqqt_cast<TQProgressBar*>(widget)) // 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); {
progAnimWidgets[static_cast<TQProgressBar*>(widget)] = 0; installObjectEventHandler(ceData, elementFlags, ptr, this);
connect(widget, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(progressBarDestroyed(TQObject*))); if ( widget->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) )
if (!animationTimer->isActive()) widget->setBackgroundMode( NoBackground );
animationTimer->start( 50, false ); }
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 (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
if ( widget->inherits( TQPUSHBUTTON_OBJECT_NAME_STRING ) || widget->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) ) TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
{
if ( widget->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) ) //### TODO: This needs major cleanup (and so does polish() )
widget->setBackgroundMode( PaletteButton ); if ( widget->inherits( TQPUSHBUTTON_OBJECT_NAME_STRING ) || widget->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) )
widget->removeEventFilter(this); {
} if ( widget->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) )
else if ( widget->inherits( TQMENUBAR_OBJECT_NAME_STRING ) || widget->inherits( TQPOPUPMENU_OBJECT_NAME_STRING ) ) widget->setBackgroundMode( PaletteButton );
widget->setBackgroundMode( PaletteBackground ); removeObjectEventHandler(ceData, elementFlags, ptr, this);
}
else if ( widget->parentWidget() && else if ( widget->inherits( TQMENUBAR_OBJECT_NAME_STRING ) || widget->inherits( TQPOPUPMENU_OBJECT_NAME_STRING ) )
( ( widget->inherits( TQLISTBOX_OBJECT_NAME_STRING ) && widget->parentWidget()->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) ) || widget->setBackgroundMode( PaletteBackground );
widget->inherits( "KCompletionBox" ) ) ) {
TQListBox* listbox = (TQListBox*) widget; else if ( widget->parentWidget() &&
listbox->setLineWidth( 1 ); ( ( widget->inherits( TQLISTBOX_OBJECT_NAME_STRING ) && widget->parentWidget()->inherits( TQCOMBOBOX_OBJECT_NAME_STRING ) ) ||
listbox->setBackgroundMode( PaletteBackground ); widget->inherits( "KCompletionBox" ) ) ) {
widget->removeEventFilter( this ); TQListBox* listbox = (TQListBox*) widget;
widget->clearMask(); listbox->setLineWidth( 1 );
} else if (widget->inherits("QToolBarExtensionWidget")) { listbox->setBackgroundMode( PaletteBackground );
widget->removeEventFilter(this); removeObjectEventHandler(ceData, elementFlags, ptr, this);
} widget->clearMask();
else if ( !qstrcmp( widget->name(), kdeToolbarWidget ) ) { } else if (widget->inherits("QToolBarExtensionWidget")) {
widget->setBackgroundMode( PaletteBackground ); removeObjectEventHandler(ceData, elementFlags, ptr, this);
widget->removeEventFilter(this); }
} else if ( !qstrcmp( widget->name(), kdeToolbarWidget ) ) {
else if ( ::tqqt_cast<TQProgressBar*>(widget) ) widget->setBackgroundMode( PaletteBackground );
{ removeObjectEventHandler(ceData, elementFlags, ptr, this);
progAnimWidgets.remove(static_cast<TQProgressBar*>(widget)); }
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) void KeramikStyle::progressBarDestroyed(TQObject* obj)
@ -2759,197 +2771,202 @@ TQRect KeramikStyle::querySubControlMetrics( TQ_ComplexControl control,
#undef KeyRelease #undef KeyRelease
#endif #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; 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 ( !object->isWidgetType() ) return false;
if ( (event->type() == TQEvent::Leave) && (TQT_BASE_OBJECT(object) == TQT_BASE_OBJECT(hoverWidget)) )
{ //Clear hover highlight when needed
TQWidget* button = TQT_TQWIDGET(object); if ( (event->type() == TQEvent::Leave) && (TQT_BASE_OBJECT(object) == TQT_BASE_OBJECT(hoverWidget)) )
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); TQWidget* button = TQT_TQWIDGET(object);
hoverWidget->repaint( false ); hoverWidget = 0;
} button->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 )
return false; return false;
}
recursion = true;
object->event( TQT_TQPAINTEVENT( event ) ); //Hover highlight on buttons, toolbuttons and combos
TQWidget* widget = TQT_TQWIDGET( object ); if ( ::tqqt_cast<TQPushButton*>(object) || ::tqqt_cast<TQComboBox*>(object) || ::tqqt_cast<TQToolButton*>(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())
{ {
#ifdef HAVE_X11_EXTENSIONS_SHAPE_H if (event->type() == TQEvent::Enter && TQT_TQWIDGET(object)->isEnabled() )
//Combo dropdowns are shaped
case TQEvent::Resize:
{ {
TQListBox* listbox = static_cast<TQListBox*>(TQT_TQWIDGET(object)); hoverWidget = TQT_TQWIDGET(object);
TQResizeEvent* resize = TQT_TQRESIZEEVENT(event); hoverWidget->repaint( false );
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);
} }
break; return false;
#endif }
//Combo dropdowns get fancy borders
case TQEvent::Paint: //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; #ifdef HAVE_X11_EXTENSIONS_SHAPE_H
if (recursion ) //Combo dropdowns are shaped
return false; case TQEvent::Resize:
TQListBox* listbox = (TQListBox*) object;
TQPaintEvent* paint = (TQPaintEvent*) event;
if ( !listbox->contentsRect().contains( paint->rect() ) )
{ {
TQPainter p( listbox ); TQListBox* listbox = static_cast<TQListBox*>(TQT_TQWIDGET(object));
Keramik::RectTilePainter( keramik_combobox_list, false, false ).draw( &p, 0, 0, listbox->width(), listbox->height(), TQResizeEvent* resize = TQT_TQRESIZEEVENT(event);
listbox->palette().color( TQPalette::Normal, TQColorGroup::Button ), if (resize->size().height() < 6)
listbox->palette().color( TQPalette::Normal, TQColorGroup::Background ) ); return false;
TQPaintEvent newpaint( paint->region().intersect( listbox->contentsRect() ), paint->erased() );
recursion = true;
object->event( &newpaint );
recursion = false;
return true;
}
}
break;
/** //CHECKME: Not sure the rects are perfect..
Since our popup is shown a bit overlapping the combo body, a mouse click at the bottom of the XRectangle rects[5] = {
widget will result in the release going to the popup, which will cause it to close (#56435). {0, 0, resize->size().width()-2, resize->size().height()-6},
We solve it by filtering out the first release, if it's in the right area. To do this, we notices shows, {0, resize->size().height()-6, resize->size().width()-2, 1},
move ourselves to front of event filter list, and then capture the first release event, and if it's {1, resize->size().height()-5, resize->size().width()-3, 1},
in the overlap area, filter it out. {2, resize->size().height()-4, resize->size().width()-5, 1},
*/ {3, resize->size().height()-3, resize->size().width()-7, 1}
case TQEvent::Show: };
//Prioritize ourselves to see the mouse events first
object->removeEventFilter(this);
object->installEventFilter(this);
firstComboPopupRelease = true;
break;
//We need to filter some clicks out. XShapeCombineRectangles(tqt_xdisplay(), listbox->handle(), ShapeBounding, 0, 0,
case TQEvent::MouseButtonRelease: rects, 5, ShapeSet, YXSorted);
if (firstComboPopupRelease) }
break;
#endif
//Combo dropdowns get fancy borders
case TQEvent::Paint:
{ {
firstComboPopupRelease = false; static bool recursion = false;
if (recursion )
TQMouseEvent* mev = TQT_TQMOUSEEVENT(event);
TQListBox* box = static_cast<TQListBox*>(TQT_TQWIDGET(object));
TQWidget* parent = box->parentWidget();
if (!parent)
return false; return false;
TQListBox* listbox = (TQListBox*) object;
TQPoint inParCoords = parent->mapFromGlobal(mev->globalPos()); TQPaintEvent* paint = (TQPaintEvent*) event;
if (parent->rect().contains(inParCoords))
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; return true;
}
} }
break; break;
case TQEvent::MouseButtonPress:
case TQEvent::MouseButtonDblClick: /**
case TQEvent::Wheel: Since our popup is shown a bit overlapping the combo body, a mouse click at the bottom of the
case TQEvent::KeyPress: widget will result in the release going to the popup, which will cause it to close (#56435).
case TQEvent::KeyRelease: We solve it by filtering out the first release, if it's in the right area. To do this, we notices shows,
firstComboPopupRelease = false; move ourselves to front of event filter list, and then capture the first release event, and if it's
default: in the overlap area, filter it out.
return false; */
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
//Toolbar background gradient handling else if (event->type() == TQEvent::Paint &&
else if (event->type() == TQEvent::Paint && object->parent() && !qstrcmp(object->name(), kdeToolbarWidget) )
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 )
{ {
Keramik::GradientPainter::renderGradient( &p, wr, widget->colorGroup().button(), // Draw a gradient background for custom widgets in the toolbar
true /*horizontal*/, false /*not a menu*/, // that have specified a "kde toolbar widget" name.
0, widget->y(), wr.width(), tr.height()); 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(), // We need to override the paint event to draw a
false /*vertical*/, false /*not a menu*/, // gradient on a QToolBarExtensionWidget.
widget->x(), 0, tr.width(), wr.height()); 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;
} }
// Track show events for progress bars
if ( animateProgressBar && ::tqqt_cast<TQProgressBar*>(object) )
//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())
{ {
animationTimer->start( 50, false ); if ((event->type() == TQEvent::Show) && !animationTimer->isActive())
{
animationTimer->start( 50, false );
}
} }
} }
return false; return false;
} }

@ -50,10 +50,10 @@ public:
void renderMenuBlendPixmap( KPixmap& pix, const TQColorGroup &cg, const TQPopupMenu* ) const; 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; TQPixmap stylePixmap(StylePixmap stylepixmap, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQStyleOption& opt, const TQWidget* widget = 0) const;
void polish( TQWidget* widget ); void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void unPolish( TQWidget* widget ); void unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void polish( TQPalette& ); void polish( TQPalette& );
void polish( TQApplication *app ); void applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void drawKStylePrimitive( KStylePrimitive kpe, void drawKStylePrimitive( KStylePrimitive kpe,
TQPainter* p, TQPainter* p,
@ -177,7 +177,7 @@ private:
//Animation support. //Animation support.
TQMap<TQProgressBar*, int> progAnimWidgets; 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 Keramik::TilePainter::PaintMode pmode() const
{ {

@ -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")) if (ceData.widgetObjectTypes.contains(TQAPPLICATION_OBJECT_NAME_STRING)) {
kickerMode = true; 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 (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
{ TQObject* object = reinterpret_cast<TQObject*>(source);
if(event->type() == TQEvent::Move || event->type() == TQEvent::Resize ||
event->type() == TQEvent::Show) if( object->inherits("KActiveLabel"))
{ {
TQWidget *w = TQT_TQWIDGET(object); if(event->type() == TQEvent::Move || event->type() == TQEvent::Resize ||
TQPoint pos(0, 0); event->type() == TQEvent::Show)
pos = w->mapTo(w->topLevelWidget(), pos); {
TQPixmap pix(uncached( Background )->size()); TQWidget *w = TQT_TQWIDGET(object);
TQPainter p; TQPoint pos(0, 0);
p.begin(&pix); pos = w->mapTo(w->topLevelWidget(), pos);
p.drawTiledPixmap(0, 0, TQPixmap pix(uncached( Background )->size());
uncached( Background )->width(), TQPainter p;
uncached( Background )->height() , p.begin(&pix);
*uncached( Background ), p.drawTiledPixmap(0, 0,
pos.x(), pos.y()); uncached( Background )->width(),
p.end(); uncached( Background )->height() ,
TQPalette pal(w->palette()); *uncached( Background ),
TQBrush brush( pal.color( TQPalette::Normal, pos.x(), pos.y());
TQColorGroup::Background), p.end();
pix ); TQPalette pal(w->palette());
pal.setBrush(TQColorGroup::Base, brush); TQBrush brush( pal.color( TQPalette::Normal,
w->setPalette(pal); 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)) if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
w->setPaletteBackgroundColor(TQApplication::palette().color(TQPalette::Normal, TQColorGroup::Background)); TQWidget *w = reinterpret_cast<TQWidget*>(ptr);
if (::tqqt_cast<TQLabel*>(w) && !qstrcmp(w->name(), "kde toolbar widget")) if (::tqqt_cast<TQStatusBar*>(w))
w->installEventFilter(this); w->setPaletteBackgroundColor(TQApplication::palette().color(TQPalette::Normal, TQColorGroup::Background));
if (w->backgroundPixmap() && !w->isTopLevel() && if (::tqqt_cast<TQLabel*>(w) && !qstrcmp(w->name(), "kde toolbar widget"))
(!kickerMode || installObjectEventHandler(ceData, elementFlags, ptr, this);
(!w->inherits("TaskBar") && !w->inherits("TaskBarContainer") && !w->inherits("TaskbarApplet") && !w->inherits("ContainerArea") && !w->inherits("AppletHandle"))))
{ if (w->backgroundPixmap() && !w->isTopLevel() &&
//The brushHandle check verifies that the bg pixmap is actually the brush.. (!kickerMode ||
if (!brushHandleSet || brushHandle == w->backgroundPixmap()->handle()) (!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 (w->inherits("KActiveLabel"))
{ {
if (uncached( Background )) if (uncached( Background ))
w->installEventFilter(this); installObjectEventHandler(ceData, elementFlags, ptr, this);
} }
if ( w->inherits( "QTipLabel" ) ) if ( w->inherits( "QTipLabel" ) )
{ {
polishLock = true; polishLock = true;
TQColorGroup clrGroup( Qt::black, TQColor( 255, 255, 220 ), TQColorGroup clrGroup( Qt::black, TQColor( 255, 255, 220 ),
TQColor( 96, 96, 96 ), Qt::black, Qt::black, TQColor( 96, 96, 96 ), Qt::black, Qt::black,
Qt::black, TQColor( 255, 255, 220 ) ); Qt::black, TQColor( 255, 255, 220 ) );
TQPalette toolTip ( clrGroup, clrGroup, clrGroup ); TQPalette toolTip ( clrGroup, clrGroup, clrGroup );
TQToolTip::setPalette( toolTip ); TQToolTip::setPalette( toolTip );
polishLock = false; polishLock = false;
} }
if ( w->inherits( "KonqIconViewWidget" ) ) //Konqueror background hack/workaround if ( w->inherits( "KonqIconViewWidget" ) ) //Konqueror background hack/workaround
{ {
w->setPalette( oldPalette ); w->setPalette( oldPalette );
return ; return ;
} }
if ( ::tqqt_cast<TQMenuBar*>(w) ) 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 ) )
{ {
TQPalette newPal( w->palette() ); w->setBackgroundMode( TQWidget::NoBackground );
if ( isColor( MenuItem ) ) }
{ else if ( w->inherits( "KToolBarSeparator" ) || w->inherits( "QToolBarSeparator" ) )
newPal.setActive( *colorGroup( newPal.active(), MenuItem ) ); {
newPal.setDisabled( *colorGroup( newPal.active(), MenuItem ) ); w->setBackgroundMode( TQWidget::PaletteBackground );
} }
if ( isColor( MenuItemDown ) ) 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 ); w->setBackgroundMode( TQWidget::NoBackground );
} }
else if ( ::tqqt_cast<TQCheckBox*>(w) ) else if ( ::tqqt_cast<TQCheckBox*>(w) )
{
if ( isColor( IndicatorOff ) || isColor( IndicatorOn ) )
{ {
TQPalette newPal( w->palette() ); if ( isColor( IndicatorOff ) || isColor( IndicatorOn ) )
if ( isColor( IndicatorOff ) )
{ {
newPal.setActive( *colorGroup( newPal.active(), IndicatorOff ) ); TQPalette newPal( w->palette() );
newPal.setDisabled( *colorGroup( newPal.active(), IndicatorOff ) ); 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) )
else if ( ::tqqt_cast<TQRadioButton*>(w) )
{
if ( isColor( ExIndicatorOff ) || isColor( ExIndicatorOn ) )
{ {
TQPalette newPal( w->palette() ); if ( isColor( ExIndicatorOff ) || isColor( ExIndicatorOn ) )
if ( isColor( ExIndicatorOff ) )
{ {
newPal.setActive( *colorGroup( newPal.active(), ExIndicatorOff ) ); TQPalette newPal( w->palette() );
newPal.setDisabled( *colorGroup( newPal.active(), if ( isColor( ExIndicatorOff ) )
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()) if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
{ TQWidget *w = reinterpret_cast<TQWidget*>(ptr);
//The brushHandle check verifies that the bg pixmap is actually the brush..
if (!brushHandleSet || brushHandle ==w->backgroundPixmap()->handle()) 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 KStyle::unPolish( ceData, elementFlags, ptr );
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 );
} }

@ -143,15 +143,15 @@ public:
virtual TQRect subRect(SubRect, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *) const; virtual TQRect subRect(SubRect, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *) const;
virtual void polish( TQWidget* ); virtual void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
virtual void unPolish( TQWidget* ); virtual void unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
virtual bool eventFilter( TQObject* object, TQEvent* event ); virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
/** /**
* By default this just sets the background brushes to the pixmapped * By default this just sets the background brushes to the pixmapped
* background. * background.
*/ */
virtual void polish( TQApplication *app ); virtual void applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
virtual void unPolish( TQApplication* ); virtual void applicationUnPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
/** \internal */ /** \internal */
// to make it possible for derived classes to overload this function // to make it possible for derived classes to overload this function

@ -227,83 +227,95 @@ PlastikStyle::~PlastikStyle()
delete verticalLine; delete verticalLine;
} }
void PlastikStyle::polish(TQApplication* app) void PlastikStyle::applicationPolish(TQStyleControlElementData ceData, ControlElementFlags, void *ptr)
{ {
if (!qstrcmp(app->argv()[0], "kicker")) if (ceData.widgetObjectTypes.contains(TQAPPLICATION_OBJECT_NAME_STRING)) {
kickerMode = true; TQApplication *app = reinterpret_cast<TQApplication*>(ptr);
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( _animateProgressBar && ::tqqt_cast<TQProgressBar*>(widget) ) if (!qstrcmp(app->argv()[0], "kicker"))
{ kickerMode = true;
widget->installEventFilter(this); else if (!qstrcmp(app->argv()[0], "korn"))
progAnimWidgets[widget] = 0; kornMode = true;
connect(widget, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(progressBarDestroyed(TQObject*)));
if (!animationTimer->isActive())
animationTimer->start( 50, false );
} }
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...? if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
khtmlWidgets.remove(widget); 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. KStyle::polish(ceData, elementFlags, ptr);
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);
}
if ( ::tqqt_cast<TQProgressBar*>(widget) ) void PlastikStyle::unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{ {
progAnimWidgets.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.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) 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; return true;
if (!obj->isWidgetType() ) return false; if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
TQObject* obj = reinterpret_cast<TQObject*>(source);
// focus highlight
if ( ::tqqt_cast<TQLineEdit*>(obj) ) { if (!obj->isWidgetType() ) return false;
TQWidget* widget = TQT_TQWIDGET(obj);
// focus highlight
if ( ::tqqt_cast<TQSpinWidget*>(widget->parentWidget()) ) if ( ::tqqt_cast<TQLineEdit*>(obj) ) {
{ TQWidget* widget = TQT_TQWIDGET(obj);
TQWidget* spinbox = widget->parentWidget();
if ((ev->type() == TQEvent::FocusIn) || (ev->type() == TQEvent::FocusOut)) if ( ::tqqt_cast<TQSpinWidget*>(widget->parentWidget()) )
{ {
spinbox->repaint(false); TQWidget* spinbox = widget->parentWidget();
} if ((ev->type() == TQEvent::FocusIn) || (ev->type() == TQEvent::FocusOut))
return false; {
} spinbox->repaint(false);
}
if ((ev->type() == TQEvent::FocusIn) || (ev->type() == TQEvent::FocusOut)) return false;
{ }
widget->repaint(false);
} if ((ev->type() == TQEvent::FocusIn) || (ev->type() == TQEvent::FocusOut))
return false; {
} widget->repaint(false);
}
//Hover highlight... use tqqt_cast to check if the widget inheits one of the classes. return false;
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) ) //Hover highlight... use tqqt_cast to check if the widget inheits one of the classes.
{ if ( ::tqqt_cast<TQPushButton*>(obj) || ::tqqt_cast<TQComboBox*>(obj) ||
if ((ev->type() == TQEvent::Enter) && TQT_TQWIDGET(obj)->isEnabled()) ::tqqt_cast<TQSpinWidget*>(obj) || ::tqqt_cast<TQCheckBox*>(obj) ||
{ ::tqqt_cast<TQRadioButton*>(obj) || ::tqqt_cast<TQToolButton*>(obj) || obj->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) )
TQWidget* button = TQT_TQWIDGET(obj); {
hoverWidget = button; if ((ev->type() == TQEvent::Enter) && TQT_TQWIDGET(obj)->isEnabled())
button->repaint(false); {
} TQWidget* button = TQT_TQWIDGET(obj);
else if ((ev->type() == TQEvent::Leave) && (TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(hoverWidget)) ) hoverWidget = button;
{ button->repaint(false);
TQWidget* button = TQT_TQWIDGET(obj); }
hoverWidget = 0; else if ((ev->type() == TQEvent::Leave) && (TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(hoverWidget)) )
button->repaint(false); {
} TQWidget* button = TQT_TQWIDGET(obj);
return false; hoverWidget = 0;
} button->repaint(false);
if ( ::tqqt_cast<TQTabBar*>(obj) ) { }
if ((ev->type() == TQEvent::Enter) && TQT_TQWIDGET(obj)->isEnabled()) return false;
{ }
TQWidget* tabbar = TQT_TQWIDGET(obj); if ( ::tqqt_cast<TQTabBar*>(obj) ) {
hoverWidget = tabbar; if ((ev->type() == TQEvent::Enter) && TQT_TQWIDGET(obj)->isEnabled())
hoverTab = 0; {
tabbar->repaint(false); TQWidget* tabbar = TQT_TQWIDGET(obj);
} hoverWidget = tabbar;
else if (ev->type() == TQEvent::MouseMove) hoverTab = 0;
{ tabbar->repaint(false);
TQTabBar *tabbar = dynamic_cast<TQTabBar*>(obj); }
TQMouseEvent *me = dynamic_cast<TQMouseEvent*>(ev); else if (ev->type() == TQEvent::MouseMove)
{
if (tabbar && me) { TQTabBar *tabbar = dynamic_cast<TQTabBar*>(obj);
// avoid unnecessary repaints (which otherwise would occour on every TQMouseEvent *me = dynamic_cast<TQMouseEvent*>(ev);
// MouseMove event causing high cpu load).
if (tabbar && me) {
bool repaint = true; // avoid unnecessary repaints (which otherwise would occour on every
// MouseMove event causing high cpu load).
TQTab *tab = tabbar->selectTab(me->pos() );
if (hoverTab == tab) bool repaint = true;
repaint = false;
hoverTab = tab; TQTab *tab = tabbar->selectTab(me->pos() );
if (hoverTab == tab)
if (repaint) repaint = false;
tabbar->repaint(false); hoverTab = tab;
}
} if (repaint)
else if (ev->type() == TQEvent::Leave) tabbar->repaint(false);
{ }
TQWidget* tabbar = TQT_TQWIDGET(obj); }
hoverWidget = 0; else if (ev->type() == TQEvent::Leave)
hoverTab = 0; {
tabbar->repaint(false); TQWidget* tabbar = TQT_TQWIDGET(obj);
} hoverWidget = 0;
return false; hoverTab = 0;
} tabbar->repaint(false);
// Track show events for progress bars }
if ( _animateProgressBar && ::tqqt_cast<TQProgressBar*>(obj) ) return false;
{ }
if ((ev->type() == TQEvent::Show) && !animationTimer->isActive()) // Track show events for progress bars
{ if ( _animateProgressBar && ::tqqt_cast<TQProgressBar*>(obj) )
animationTimer->start( 50, false ); {
} if ((ev->type() == TQEvent::Show) && !animationTimer->isActive())
} {
if ( !qstrcmp(obj->name(), "kde toolbar widget") ) animationTimer->start( 50, false );
{ }
TQWidget* lb = TQT_TQWIDGET(obj); }
if (lb->backgroundMode() == TQt::PaletteButton) if ( !qstrcmp(obj->name(), "kde toolbar widget") )
lb->setBackgroundMode(TQt::PaletteBackground); {
lb->removeEventFilter(this); TQWidget* lb = TQT_TQWIDGET(obj);
if (lb->backgroundMode() == TQt::PaletteButton)
lb->setBackgroundMode(TQt::PaletteBackground);
removeObjectEventHandler(ceData, elementFlags, source, this);
}
} }
return false; return false;

@ -62,9 +62,9 @@ public:
PlastikStyle(); PlastikStyle();
virtual ~PlastikStyle(); virtual ~PlastikStyle();
void polish(TQApplication* app ); void applicationPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void polish(TQWidget* widget ); void polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void unPolish(TQWidget* widget ); void unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void drawKStylePrimitive(KStylePrimitive kpe, void drawKStylePrimitive(KStylePrimitive kpe,
TQPainter* p, TQPainter* p,
@ -265,8 +265,8 @@ protected:
virtual void renderMenuBlendPixmap( KPixmap& pix, const TQColorGroup& cg, virtual void renderMenuBlendPixmap( KPixmap& pix, const TQColorGroup& cg,
const TQPopupMenu* popup ) const; const TQPopupMenu* popup ) const;
bool eventFilter(TQObject *, TQEvent *); virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
TQWidget* hoverWidget; TQWidget* hoverWidget;
protected slots: protected slots:

@ -259,39 +259,45 @@ TQString KStyle::defaultStyle()
return TQString("light, 3rd revision"); return TQString("light, 3rd revision");
} }
void KStyle::polish( TQWidget* widget ) void KStyle::polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{ {
if ( d->useFilledFrameWorkaround ) if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
{ TQWidget* widget = reinterpret_cast<TQWidget*>(ptr);
if ( TQFrame *frame = ::tqqt_cast< TQFrame* >( widget ) ) { if ( d->useFilledFrameWorkaround )
TQFrame::Shape shape = frame->frameShape(); {
if (shape == TQFrame::ToolBarPanel || shape == TQFrame::MenuBarPanel) if ( TQFrame *frame = ::tqqt_cast< TQFrame* >( widget ) ) {
widget->installEventFilter(this); TQFrame::Shape shape = frame->frameShape();
} if (shape == TQFrame::ToolBarPanel || shape == TQFrame::MenuBarPanel)
} widget->installEventFilter(this);
if (widget->isTopLevel()) }
{ }
if (!d->menuHandler && useDropShadow(widget)) if (widget->isTopLevel())
d->menuHandler = new TransparencyHandler(this, Disabled, 1.0, false); {
if (!d->menuHandler && useDropShadow(widget))
d->menuHandler = new TransparencyHandler(this, Disabled, 1.0, false);
if (d->menuHandler && useDropShadow(widget)) if (d->menuHandler && useDropShadow(widget))
widget->installEventFilter(d->menuHandler); widget->installEventFilter(d->menuHandler);
}
} }
} }
void KStyle::unPolish( TQWidget* widget ) void KStyle::unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{ {
if ( d->useFilledFrameWorkaround ) if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
{ TQWidget* widget = reinterpret_cast<TQWidget*>(ptr);
if ( TQFrame *frame = ::tqqt_cast< TQFrame* >( widget ) ) { if ( d->useFilledFrameWorkaround )
TQFrame::Shape shape = frame->frameShape(); {
if (shape == TQFrame::ToolBarPanel || shape == TQFrame::MenuBarPanel) if ( TQFrame *frame = ::tqqt_cast< TQFrame* >( widget ) ) {
widget->removeEventFilter(this); TQFrame::Shape shape = frame->frameShape();
if (shape == TQFrame::ToolBarPanel || shape == TQFrame::MenuBarPanel)
widget->removeEventFilter(this);
}
} }
if (widget->isTopLevel() && d->menuHandler && useDropShadow(widget))
widget->removeEventFilter(d->menuHandler);
} }
if (widget->isTopLevel() && d->menuHandler && useDropShadow(widget))
widget->removeEventFilter(d->menuHandler);
} }
@ -1926,50 +1932,53 @@ int KStyle::styleHint( TQ_StyleHint sh, TQStyleControlElementData ceData, Contro
} }
bool KStyle::eventFilter( TQObject* object, TQEvent* event ) bool KStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *event )
{ {
if ( d->useFilledFrameWorkaround ) if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
{ TQObject* object = reinterpret_cast<TQObject*>(source);
// Make the QMenuBar/TQToolBar paintEvent() cover a larger area to if ( d->useFilledFrameWorkaround )
// ensure that the filled frame contents are properly painted.
// We essentially modify the paintEvent's rect to include the
// panel border, which also paints the widget's interior.
// This is nasty, but I see no other way to properly repaint
// filled frames in all QMenuBars and QToolBars.
// -- Karol.
TQFrame *frame = 0;
if ( event->type() == TQEvent::Paint
&& (frame = ::tqqt_cast<TQFrame*>(object)) )
{ {
if (frame->frameShape() != TQFrame::ToolBarPanel && frame->frameShape() != TQFrame::MenuBarPanel) // Make the QMenuBar/TQToolBar paintEvent() cover a larger area to
return false; // ensure that the filled frame contents are properly painted.
// We essentially modify the paintEvent's rect to include the
bool horizontal = true; // panel border, which also paints the widget's interior.
TQPaintEvent* pe = (TQPaintEvent*)event; // This is nasty, but I see no other way to properly repaint
TQToolBar *toolbar = ::tqqt_cast< TQToolBar *>( frame ); // filled frames in all QMenuBars and QToolBars.
TQRect r = pe->rect(); // -- Karol.
TQFrame *frame = 0;
if ( event->type() == TQEvent::Paint
&& (frame = ::tqqt_cast<TQFrame*>(object)) )
{
if (frame->frameShape() != TQFrame::ToolBarPanel && frame->frameShape() != TQFrame::MenuBarPanel)
return false;
if (toolbar && toolbar->orientation() == Qt::Vertical) bool horizontal = true;
horizontal = false; TQPaintEvent* pe = (TQPaintEvent*)event;
TQToolBar *toolbar = ::tqqt_cast< TQToolBar *>( frame );
TQRect r = pe->rect();
if (horizontal) { if (toolbar && toolbar->orientation() == Qt::Vertical)
if ( r.height() == frame->height() ) horizontal = false;
return false; // Let TQFrame handle the painting now.
// Else, send a new paint event with an updated paint rect. if (horizontal) {
TQPaintEvent dummyPE( TQRect( r.x(), 0, r.width(), frame->height()) ); if ( r.height() == frame->height() )
TQApplication::sendEvent( frame, &dummyPE ); return false; // Let TQFrame handle the painting now.
}
else { // Vertical
if ( r.width() == frame->width() )
return false;
TQPaintEvent dummyPE( TQRect( 0, r.y(), frame->width(), r.height()) ); // Else, send a new paint event with an updated paint rect.
TQApplication::sendEvent( frame, &dummyPE ); TQPaintEvent dummyPE( TQRect( r.x(), 0, r.width(), frame->height()) );
} TQApplication::sendEvent( frame, &dummyPE );
}
else { // Vertical
if ( r.width() == frame->width() )
return false;
TQPaintEvent dummyPE( TQRect( 0, r.y(), frame->width(), r.height()) );
TQApplication::sendEvent( frame, &dummyPE );
}
// Discard this event as we sent a new paintEvent. // Discard this event as we sent a new paintEvent.
return true; return true;
}
} }
} }

@ -286,8 +286,8 @@ class TDEFX_EXPORT KStyle: public TQCommonStyle
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void polish( TQWidget* widget ); void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void unPolish( TQWidget* widget ); void unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void polishPopupMenu( TQPopupMenu* ); void polishPopupMenu( TQPopupMenu* );
void tqdrawPrimitive( TQ_PrimitiveElement pe, void tqdrawPrimitive( TQ_PrimitiveElement pe,
@ -367,7 +367,7 @@ class TDEFX_EXPORT KStyle: public TQCommonStyle
const TQWidget* w = 0 ) const; const TQWidget* w = 0 ) const;
protected: protected:
bool eventFilter( TQObject* object, TQEvent* event ); virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
private: private:
// Disable copy constructor and = operator // Disable copy constructor and = operator

Loading…
Cancel
Save