diff options
Diffstat (limited to 'src/styles/qmotifplusstyle.cpp')
-rw-r--r-- | src/styles/qmotifplusstyle.cpp | 78 |
1 files changed, 44 insertions, 34 deletions
diff --git a/src/styles/qmotifplusstyle.cpp b/src/styles/qmotifplusstyle.cpp index 9245e65..86a2558 100644 --- a/src/styles/qmotifplusstyle.cpp +++ b/src/styles/qmotifplusstyle.cpp @@ -69,7 +69,9 @@ struct QMotifPlusStylePrivate scrollbarElement(0), lastElement(0), ref(1) { ; } - QGuardedPtr<QWidget> hoverWidget; + void* hoverWidget; + QStyleControlElementData hoverWidgetData; + QStyle::ControlElementFlags hoverWidgetFlags; bool hovering, sliderActive, mousePressed; int scrollbarElement, lastElement, ref; QPoint mousePos; @@ -176,52 +178,58 @@ void QMotifPlusStyle::polish(QPalette &) /*! \reimp */ -void QMotifPlusStyle::polish(QWidget *widget) +void QMotifPlusStyle::polish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr) { + if (ceData.widgetObjectTypes.contains("QWidget")) { #ifndef QT_NO_FRAME - if (::qt_cast<QFrame*>(widget) && ((QFrame *) widget)->frameStyle() == QFrame::Panel) - ((QFrame *) widget)->setFrameStyle(QFrame::WinPanel); + if ((ceData.widgetObjectTypes.contains("QFrame")) && (ceData.frameStyle == QFrame::Panel)) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetStyle, QStyleWidgetActionRequestData(QFrame::WinPanel)); + } #endif #ifndef QT_NO_MENUBAR - if (::qt_cast<QMenuBar*>(widget) && ((QMenuBar *) widget)->frameStyle() != QFrame::NoFrame) - ((QMenuBar *) widget)->setFrameStyle(QFrame::StyledPanel | QFrame::Raised); + if ((ceData.widgetObjectTypes.contains("QMenuBar")) && (ceData.frameStyle != QFrame::NoFrame)) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetStyle, QStyleWidgetActionRequestData(QFrame::StyledPanel | QFrame::Raised)); + } #endif #ifndef QT_NO_TOOLBAR - if (::qt_cast<QToolBar*>(widget)) - widget->layout()->setMargin(2); + if (ceData.widgetObjectTypes.contains("QToolBar")) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetLayoutMargin, QStyleWidgetActionRequestData(2)); + } #endif + } if (useHoveringHighlight) { - if (::qt_cast<QButton*>(widget) || ::qt_cast<QComboBox*>(widget)) - widget->installEventFilter(this); + if ((ceData.widgetObjectTypes.contains("QButton")) || (ceData.widgetObjectTypes.contains("QComboBox"))) { + installObjectEventHandler(ceData, elementFlags, ptr, this); + } - if (::qt_cast<QScrollBar*>(widget) || ::qt_cast<QSlider*>(widget)) { - widget->setMouseTracking(TRUE); - widget->installEventFilter(this); + if ((ceData.widgetObjectTypes.contains("QScrollBar")) || (ceData.widgetObjectTypes.contains("QSlider"))) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_EnableMouseTracking); + installObjectEventHandler(ceData, elementFlags, ptr, this); } } - QMotifStyle::polish(widget); + QMotifStyle::polish(ceData, elementFlags, ptr); } /*! \reimp */ -void QMotifPlusStyle::unPolish(QWidget *widget) +void QMotifPlusStyle::unPolish(QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr) { - widget->removeEventFilter(this); - QMotifStyle::unPolish(widget); + removeObjectEventHandler(ceData, elementFlags, ptr, this); + QMotifStyle::unPolish(ceData, elementFlags, ptr); } /*! \reimp */ -void QMotifPlusStyle::polish(QApplication *) +void QMotifPlusStyle::applicationPolish(QStyleControlElementData, ControlElementFlags, void *) { } /*! \reimp */ -void QMotifPlusStyle::unPolish(QApplication *) +void QMotifPlusStyle::applicationUnPolish(QStyleControlElementData, ControlElementFlags, void *) { } @@ -1477,14 +1485,14 @@ QRect QMotifPlusStyle::querySubControlMetrics(ComplexControl control, /*! \reimp */ -bool QMotifPlusStyle::eventFilter(QObject *object, QEvent *event) +bool QMotifPlusStyle::objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *event ) { switch(event->type()) { case QEvent::MouseButtonPress: { singleton->mousePressed = TRUE; - if (!::qt_cast<QSlider*>(object)) + if (!ceData.widgetObjectTypes.contains("QSlider")) break; singleton->sliderActive = TRUE; @@ -1495,50 +1503,52 @@ bool QMotifPlusStyle::eventFilter(QObject *object, QEvent *event) { singleton->mousePressed = FALSE; - if (!::qt_cast<QSlider*>(object)) + if (!ceData.widgetObjectTypes.contains("QSlider")) break; singleton->sliderActive = FALSE; - ((QWidget *) object)->repaint(FALSE); + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); break; } case QEvent::Enter: { - if (! object->isWidgetType()) + if (!ceData.widgetObjectTypes.contains("QWidget")) break; - singleton->hoverWidget = (QWidget *) object; - if (! singleton->hoverWidget->isEnabled()) { + singleton->hoverWidget = source; + singleton->hoverWidgetData = ceData; + singleton->hoverWidgetFlags = elementFlags; + if (!(singleton->hoverWidgetFlags & CEF_IsEnabled)) { singleton->hoverWidget = 0; break; } - singleton->hoverWidget->repaint(FALSE); + widgetActionRequest(singleton->hoverWidgetData, singleton->hoverWidgetFlags, singleton->hoverWidget, WAR_Repaint); break; } case QEvent::Leave: { - if (object != singleton->hoverWidget) + if (source != singleton->hoverWidget) break; - QWidget *w = singleton->hoverWidget; + void *w = singleton->hoverWidget; singleton->hoverWidget = 0; - w->repaint(FALSE); + widgetActionRequest(singleton->hoverWidgetData, singleton->hoverWidgetFlags, w, WAR_Repaint); break; } case QEvent::MouseMove: { - if (! object->isWidgetType() || object != singleton->hoverWidget) + if ((!ceData.widgetObjectTypes.contains("QWidget")) || source != singleton->hoverWidget) break; - if (!::qt_cast<QScrollBar*>(object) && ! ::qt_cast<QSlider*>(object)) + if ((!ceData.widgetObjectTypes.contains("QScrollBar")) && (!ceData.widgetObjectTypes.contains("QSlider"))) break; singleton->mousePos = ((QMouseEvent *) event)->pos(); if (! singleton->mousePressed) { singleton->hovering = TRUE; - singleton->hoverWidget->repaint(FALSE); + widgetActionRequest(singleton->hoverWidgetData, singleton->hoverWidgetFlags, singleton->hoverWidget, WAR_Repaint); singleton->hovering = FALSE; } @@ -1549,7 +1559,7 @@ bool QMotifPlusStyle::eventFilter(QObject *object, QEvent *event) break; } - return QMotifStyle::eventFilter(object, event); + return QMotifStyle::objectEventHandler(ceData, elementFlags, source, event); } |