TQStyle API update

pull/1/head
Timothy Pearson 12 years ago
parent b80c68a29b
commit 71dde9e35e

@ -278,101 +278,112 @@ LipstikStyle::~LipstikStyle()
delete verticalLine; delete verticalLine;
} }
void LipstikStyle::polish(TQApplication* app) void LipstikStyle::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")) if (!qstrcmp(app->argv()[0], "kicker"))
kornMode = true; kickerMode = true;
else if (!qstrcmp(app->argv()[0], "korn"))
kornMode = true;
}
} }
void LipstikStyle::polish(TQWidget* widget) void LipstikStyle::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[widget] = true; TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
connect(widget, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(khtmlWidgetDestroyed(TQObject*)));
}
// use tqt_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->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(::tqqt_cast<TQScrollBar*>(widget)) {
widget->setMouseTracking(true);
widget->installEventFilter(this);
} else if (widget->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) || widget->inherits(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING) ) {
widget->installEventFilter(this);
} else if (::tqqt_cast<TQLineEdit*>(widget)) {
widget->installEventFilter(this);
} else if ( !qstrcmp(widget->name(), "kde toolbar widget") ) {
widget->installEventFilter(this);
}
if( _animateProgressBar && ::tqqt_cast<TQProgressBar*>(widget) ) { if( !strcmp(widget->name(), "__khtml") ) { // is it a khtml widget...?
widget->installEventFilter(this); khtmlWidgets[widget] = true;
progAnimWidgets[widget] = 0; connect(widget, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(khtmlWidgetDestroyed(TQObject*)));
connect(widget, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(progressBarDestroyed(TQObject*))); }
if (!animationTimer->isActive())
animationTimer->start( 50, false ); // use tqt_cast where possible to check if the widget inheits one of the classes. might improve
} else if( !qstrcmp(widget->className(), "KonqFrameStatusBar") ) { // performance compared to TQObject::inherits()
// This disables the white background of the KonquerorFrameStatusBar. if ( ::tqqt_cast<TQPushButton*>(widget) || ::tqqt_cast<TQComboBox*>(widget) ||
// When the green led is shown the background is set to ::tqqt_cast<TQSpinWidget*>(widget) || ::tqqt_cast<TQSlider*>(widget) ||
// applications cg.midlight() so we override it to standard background. ::tqqt_cast<TQCheckBox*>(widget) || ::tqqt_cast<TQRadioButton*>(widget) ||
// Thanks Comix! (because this was ugly from day one!) ::tqqt_cast<TQToolButton*>(widget)
// NOTE: Check if we can set it earlier (before painting), cause )
// on slow machines we can see the repainting of the bar (from white to background...) {
TQPalette kPalette = TQApplication::palette(); installObjectEventHandler(ceData, elementFlags, ptr, this);
kPalette.setColor( TQColorGroup::Midlight,kPalette.active().background() ); } else if (::tqqt_cast<TQTabBar*>(widget)) {
TQApplication::setPalette( kPalette ); widget->setMouseTracking(true);
installObjectEventHandler(ceData, elementFlags, ptr, this);
} else if (::tqqt_cast<TQPopupMenu*>(widget)) {
widget->setBackgroundMode( NoBackground );
} else if(::tqqt_cast<TQScrollBar*>(widget)) {
widget->setMouseTracking(true);
installObjectEventHandler(ceData, elementFlags, ptr, this);
} else if (widget->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) || widget->inherits(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING) ) {
installObjectEventHandler(ceData, elementFlags, ptr, this);
} else if (::tqqt_cast<TQLineEdit*>(widget)) {
installObjectEventHandler(ceData, elementFlags, ptr, this);
} 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 );
} else if( !qstrcmp(widget->className(), "KonqFrameStatusBar") ) {
// This disables the white background of the KonquerorFrameStatusBar.
// When the green led is shown the background is set to
// applications cg.midlight() so we override it to standard background.
// Thanks Comix! (because this was ugly from day one!)
// NOTE: Check if we can set it earlier (before painting), cause
// on slow machines we can see the repainting of the bar (from white to background...)
TQPalette kPalette = TQApplication::palette();
kPalette.setColor( TQColorGroup::Midlight,kPalette.active().background() );
TQApplication::setPalette( kPalette );
}
} }
KStyle::polish(widget); KStyle::polish(ceData, elementFlags, ptr);
} }
void LipstikStyle::unPolish(TQWidget* widget) void LipstikStyle::unPolish(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);
}
// use tqt_cast to check if the widget inheits one of the classes. if( !strcmp(widget->name(), "__khtml") ) { // is it a khtml widget...?
if ( ::tqqt_cast<TQPushButton*>(widget) || ::tqqt_cast<TQComboBox*>(widget) || khtmlWidgets.remove(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) || // use tqt_cast to check if the widget inheits one of the classes.
widget->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) ) if ( ::tqqt_cast<TQPushButton*>(widget) || ::tqqt_cast<TQComboBox*>(widget) ||
{ ::tqqt_cast<TQSpinWidget*>(widget) || ::tqqt_cast<TQSlider*>(widget) ||
widget->removeEventFilter(this); ::tqqt_cast<TQCheckBox*>(widget) || ::tqqt_cast<TQRadioButton*>(widget) ||
} ::tqqt_cast<TQToolButton*>(widget) || ::tqqt_cast<TQLineEdit*>(widget) ||
else if (::tqqt_cast<TQTabBar*>(widget)) { widget->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) )
widget->setMouseTracking(false); {
widget->removeEventFilter(this); removeObjectEventHandler(ceData, elementFlags, ptr, this);
} else if (::tqqt_cast<TQScrollBar*>(widget)) { }
widget->setMouseTracking(false); else if (::tqqt_cast<TQTabBar*>(widget)) {
widget->removeEventFilter(this); widget->setMouseTracking(false);
} else if (::tqqt_cast<TQPopupMenu*>(widget)) { removeObjectEventHandler(ceData, elementFlags, ptr, this);
widget->setBackgroundMode( PaletteBackground ); } else if (::tqqt_cast<TQScrollBar*>(widget)) {
} else if ( !qstrcmp(widget->name(), "kde toolbar widget") ) { widget->setMouseTracking(false);
widget->removeEventFilter(this); removeObjectEventHandler(ceData, elementFlags, ptr, this);
} } else if (::tqqt_cast<TQPopupMenu*>(widget)) {
widget->setBackgroundMode( PaletteBackground );
if ( ::tqqt_cast<TQProgressBar*>(widget) ) { } else if ( !qstrcmp(widget->name(), "kde toolbar widget") ) {
progAnimWidgets.remove(widget); removeObjectEventHandler(ceData, elementFlags, ptr, this);
} else if( widget->inherits("KonqFrameStatusBar") ) { }
widget->removeEventFilter(this);
if ( ::tqqt_cast<TQProgressBar*>(widget) ) {
progAnimWidgets.remove(widget);
} else if( widget->inherits("KonqFrameStatusBar") ) {
removeObjectEventHandler(ceData, elementFlags, ptr, this);
}
} }
KStyle::unPolish(widget); KStyle::unPolish(ceData, elementFlags, ptr);
} }
void LipstikStyle::khtmlWidgetDestroyed(TQObject* obj) void LipstikStyle::khtmlWidgetDestroyed(TQObject* obj)
@ -3958,106 +3969,110 @@ int LipstikStyle::styleHint( StyleHint stylehint,
} }
} }
bool LipstikStyle::eventFilter(TQObject *obj, TQEvent *ev) bool LipstikStyle::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) ) {
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 tqt_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) ||
::tqqt_cast<TQSlider*>(obj) || ::tqqt_cast<TQScrollBar*>(obj) ||
obj->inherits(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING) || obj->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) )
{
if ((ev->type() == TQEvent::Enter) && TQT_TQWIDGET(obj)->isEnabled())
{
TQWidget* button = TQT_TQWIDGET(obj);
hoverWidget = button;
button->repaint(false);
}
else if ((ev->type() == TQEvent::Leave) && (TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(hoverWidget)) )
{
TQWidget* button = TQT_TQWIDGET(obj);
hoverWidget = 0;
button->repaint(false);
}
return false;
}
if ( ::tqqt_cast<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; if (!obj->isWidgetType() ) return false;
TQTab *tab = tabbar->selectTab(me->pos() ); // focus highlight
if (hoverTab == tab) if ( ::tqqt_cast<TQLineEdit*>(obj) ) {
repaint = false; TQWidget* widget = TQT_TQWIDGET(obj);
hoverTab = tab;
if ( ::tqqt_cast<TQSpinWidget*>(widget->parentWidget()) )
if (repaint) {
tabbar->repaint(false); TQWidget* spinbox = widget->parentWidget();
} if ((ev->type() == TQEvent::FocusIn) || (ev->type() == TQEvent::FocusOut))
} {
else if (ev->type() == TQEvent::Leave) spinbox->repaint(false);
{ }
TQWidget* tabbar = TQT_TQWIDGET(obj); return false;
hoverWidget = 0; }
hoverTab = 0;
tabbar->repaint(false); if ((ev->type() == TQEvent::FocusIn) || (ev->type() == TQEvent::FocusOut))
} {
return false; widget->repaint(false);
} }
// Track show events for progress bars return false;
if ( _animateProgressBar && ::tqqt_cast<TQProgressBar*>(obj) ) }
{
if ((ev->type() == TQEvent::Show) && !animationTimer->isActive()) //Hover highlight... use tqt_cast to check if the widget inheits one of the classes.
{ if ( ::tqqt_cast<TQPushButton*>(obj) || ::tqqt_cast<TQComboBox*>(obj) ||
animationTimer->start( 50, false ); ::tqqt_cast<TQSpinWidget*>(obj) || ::tqqt_cast<TQCheckBox*>(obj) ||
} ::tqqt_cast<TQRadioButton*>(obj) || ::tqqt_cast<TQToolButton*>(obj) ||
} ::tqqt_cast<TQSlider*>(obj) || ::tqqt_cast<TQScrollBar*>(obj) ||
if ( !qstrcmp(obj->name(), "kde toolbar widget") ) obj->inherits(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING) || obj->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) )
{ {
TQWidget* lb = TQT_TQWIDGET(obj); if ((ev->type() == TQEvent::Enter) && TQT_TQWIDGET(obj)->isEnabled())
if (lb->backgroundMode() == TQt::PaletteButton) {
lb->setBackgroundMode(TQt::PaletteBackground); TQWidget* button = TQT_TQWIDGET(obj);
lb->removeEventFilter(this); 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; return false;

@ -69,9 +69,9 @@ public:
LipstikStyle(); LipstikStyle();
virtual ~LipstikStyle(); virtual ~LipstikStyle();
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,
@ -276,7 +276,7 @@ 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:

Loading…
Cancel
Save