diff options
author | Timothy Pearson <[email protected]> | 2012-08-07 01:31:43 -0500 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2012-08-07 01:31:43 -0500 |
commit | 58451e41d9ecfb405f5dd2718444ac78e8d51c8b (patch) | |
tree | 1b52d26a8b3ffe81516df83896285ebfa843d849 /src/styles/qsgistyle.cpp | |
parent | 0008bc5bcd95694b38b0d0322aac2ea6fdb21298 (diff) | |
download | qt3-58451e41d9ecfb405f5dd2718444ac78e8d51c8b.tar.gz qt3-58451e41d9ecfb405f5dd2718444ac78e8d51c8b.zip |
Extend TQStyle API further and bump Qt version number
Diffstat (limited to 'src/styles/qsgistyle.cpp')
-rw-r--r-- | src/styles/qsgistyle.cpp | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/src/styles/qsgistyle.cpp b/src/styles/qsgistyle.cpp index 5695348..a66fcda 100644 --- a/src/styles/qsgistyle.cpp +++ b/src/styles/qsgistyle.cpp @@ -65,7 +65,7 @@ struct SliderLastPosition { SliderLastPosition() : rect(0,-1,0,-1), slider(0) {} QRect rect; - const QSlider* slider; + const void* slider; }; #endif @@ -74,7 +74,7 @@ struct ScrollbarLastPosition { ScrollbarLastPosition() : rect( 0,-1, 0,-1 ), scrollbar(0) {} QRect rect; - const QScrollBar *scrollbar; + const void* scrollbar; }; #endif @@ -86,7 +86,7 @@ public: { } - const QWidget *hotWidget; + const void* hotWidget; QPoint mousePos; #ifndef QT_NO_SCROLLBAR ScrollbarLastPosition lastScrollbarRect; @@ -136,10 +136,10 @@ QSGIStyle::~QSGIStyle() bold italic font for menu options. */ void -QSGIStyle::polish( QApplication* app) +QSGIStyle::applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { isApplicationStyle = 1; - QMotifStyle::polish( app ); + QMotifStyle::polish( ceData, elementFlags, ptr ); QPalette pal = QApplication::palette(); // check this on SGI-Boxes @@ -181,7 +181,7 @@ QSGIStyle::polish( QApplication* app) /*! \reimp */ void -QSGIStyle::unPolish( QApplication* /* app */ ) +QSGIStyle::applicationUnPolish( QStyleControlElementData, ControlElementFlags, void * ) { QFont f = QApplication::font(); QApplication::setFont( f, TRUE ); // get rid of the special fonts for special widget classes @@ -194,9 +194,9 @@ QSGIStyle::unPolish( QApplication* /* app */ ) hovering. */ void -QSGIStyle::polish( QWidget* w ) +QSGIStyle::polish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { - QMotifStyle::polish(w); + QMotifStyle::polish(ceData, elementFlags, ptr); if ( !isApplicationStyle ) { QPalette sgiPal = QApplication::palette(); @@ -214,7 +214,7 @@ QSGIStyle::polish( QWidget* w ) sgiPal.setColor( QPalette::Disabled, QColorGroup::HighlightedText, sgiPal.disabled().base() ); } - if ( ::qt_cast<QLineEdit*>(w) || ::qt_cast<QTextEdit*>(w) ) { + if ( (ceData.widgetObjectTypes.contains("QLineEdit")) || (ceData.widgetObjectTypes.contains("QTextEdit")) ) { // different basecolor and highlighting in Q(Multi)LineEdit sgiPal.setColor( QColorGroup::Base, QColor(211,181,181) ); sgiPal.setColor( QPalette::Active, QColorGroup::Highlight, sgiPal.active().midlight() ); @@ -224,89 +224,89 @@ QSGIStyle::polish( QWidget* w ) sgiPal.setColor( QPalette::Disabled, QColorGroup::Highlight, sgiPal.disabled().midlight() ); sgiPal.setColor( QPalette::Disabled, QColorGroup::HighlightedText, sgiPal.disabled().text() ); - } else if ( ::qt_cast<QMenuBar*>(w) || ::qt_cast<QToolBar*>(w) ) { + } else if ( (ceData.widgetObjectTypes.contains("QMenuBar")) || (ceData.widgetObjectTypes.contains("QToolBar")) ) { sgiPal.setColor( QColorGroup::Button, sgiPal.active().midlight() ); } - w->setPalette( sgiPal ); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetPalette, QStyleWidgetActionRequestData(sgiPal)); } - if ( ::qt_cast<QButton*>(w) || ::qt_cast<QSlider*>(w) || ::qt_cast<QScrollBar*>(w) ) { - w->installEventFilter( this ); - w->setMouseTracking( TRUE ); + if ( (ceData.widgetObjectTypes.contains("QButton")) || (ceData.widgetObjectTypes.contains("QSlider")) || (ceData.widgetObjectTypes.contains("QScrollBar")) ) { + installObjectEventHandler(ceData, elementFlags, ptr, this); + widgetActionRequest(ceData, elementFlags, ptr, WAR_EnableMouseTracking); #ifndef QT_NO_SCROLLBAR - if ( ::qt_cast<QScrollBar*>(w) ) - w->setBackgroundMode( QWidget::NoBackground ); + if ( ceData.widgetObjectTypes.contains("QScrollBar") ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundMode, QStyleWidgetActionRequestData(QWidget::NoBackground)); + } #endif - } else if ( ::qt_cast<QComboBox*>(w) ) { + } else if ( ceData.widgetObjectTypes.contains("QComboBox") ) { QFont f = QApplication::font(); f.setBold( TRUE ); f.setItalic( TRUE ); - w->setFont( f ); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, QStyleWidgetActionRequestData(f)); #ifndef QT_NO_MENUBAR - } else if ( ::qt_cast<QMenuBar*>(w) ) { - ((QFrame*) w)->setFrameStyle(QFrame::StyledPanel | QFrame::Raised); - w->setBackgroundMode( QWidget::PaletteBackground ); + } else if ( ceData.widgetObjectTypes.contains("QMenuBar") ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetStyle, QStyleWidgetActionRequestData(QFrame::StyledPanel | QFrame::Raised)); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundMode, QStyleWidgetActionRequestData(QWidget::PaletteBackground)); QFont f = QApplication::font(); f.setBold( TRUE ); f.setItalic( TRUE ); - w->setFont( f ); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, QStyleWidgetActionRequestData(f)); #endif #ifndef QT_NO_POPUPMENU - } else if ( ::qt_cast<QPopupMenu*>(w) ) { - ((QFrame*) w)->setLineWidth( pixelMetric( PM_DefaultFrameWidth, QStyleControlElementData(), CEF_None ) + 1 ); + } else if ( ceData.widgetObjectTypes.contains("QPopupMenu") ) { + QStyleWidgetActionRequestData requestData; + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetLineWidth, QStyleWidgetActionRequestData(pixelMetric( PM_DefaultFrameWidth, QStyleControlElementData(), CEF_None ) + 1)); QFont f = QApplication::font(); f.setBold( TRUE ); f.setItalic( TRUE ); - w->setFont( f ); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, QStyleWidgetActionRequestData(f)); #endif - } else if ( ::qt_cast<QToolBar*>(w) || w->inherits("QToolBarSeparator") ) { - w->setBackgroundMode( QWidget::PaletteBackground ); + } else if ( (ceData.widgetObjectTypes.contains("QToolBar")) || (ceData.widgetObjectTypes.contains("QToolBarSeparator")) ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundMode, QStyleWidgetActionRequestData(QWidget::PaletteBackground)); } } /*! \reimp */ void -QSGIStyle::unPolish( QWidget* w ) +QSGIStyle::unPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { - if ( ::qt_cast<QButton*>(w) || ::qt_cast<QSlider*>(w) || ::qt_cast<QScrollBar*>(w) ) { - w->removeEventFilter( this ); + if ( (ceData.widgetObjectTypes.contains("QButton")) || (ceData.widgetObjectTypes.contains("QSlider")) || (ceData.widgetObjectTypes.contains("QScrollBar")) ) { + removeObjectEventHandler(ceData, elementFlags, ptr, this); #ifndef QT_NO_POPUPMENU - } else if ( ::qt_cast<QPopupMenu*>(w) ) { - ((QFrame*)w)->setLineWidth( pixelMetric( PM_DefaultFrameWidth, QStyleControlElementData(), CEF_None ) ); - w->setFont( QApplication::font() ); + } else if ( ceData.widgetObjectTypes.contains("QPopupMenu") ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetLineWidth, QStyleWidgetActionRequestData(pixelMetric( PM_DefaultFrameWidth, QStyleControlElementData(), CEF_None ))); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, QStyleWidgetActionRequestData(QApplication::font())); #endif #if !defined(QT_NO_MENUBAR) || !defined(QT_NO_COMBOBOX) - } else if ( ::qt_cast<QMenuBar*>(w) || ::qt_cast<QComboBox*>(w) ) { - w->setFont( QApplication::font() ); + } else if ( (ceData.widgetObjectTypes.contains("QMenuBar")) || (ceData.widgetObjectTypes.contains("QComboBox")) ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, QStyleWidgetActionRequestData(QApplication::font())); #endif } } /*! \reimp */ -bool QSGIStyle::eventFilter( QObject* o, QEvent* e ) +bool QSGIStyle::objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ) { - if ( !o->isWidgetType() || e->type() == QEvent::Paint ) - return QMotifStyle::eventFilter( o, e ); - - QWidget *widget = (QWidget*)o; + if ( (!(ceData.widgetObjectTypes.contains("QWidget"))) || (e->type() == QEvent::Paint) ) + return QMotifStyle::objectEventHandler( ceData, elementFlags, source, e ); switch ( e->type() ) { case QEvent::MouseButtonPress: { #ifndef QT_NO_SCROLLBAR - if ( ::qt_cast<QScrollBar*>(widget) ) { - d->lastScrollbarRect.rect = ((QScrollBar*)widget)->sliderRect(); - d->lastScrollbarRect.scrollbar = ((QScrollBar*)widget); - widget->repaint( FALSE ); + if (ceData.widgetObjectTypes.contains("QScrollBar")) { + d->lastScrollbarRect.rect = ceData.sliderRect; + d->lastScrollbarRect.scrollbar = source; + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); } else #endif { #ifndef QT_NO_SLIDER - if ( ::qt_cast<QSlider*>(widget) ) { - d->lastSliderRect.rect = ((QSlider*)widget)->sliderRect(); - d->lastSliderRect.slider = ((QSlider*)widget); - widget->repaint( FALSE ); + if (ceData.widgetObjectTypes.contains("QSlider")) { + d->lastSliderRect.rect = ceData.sliderRect; + d->lastSliderRect.slider = source; + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); } #endif } @@ -317,52 +317,52 @@ bool QSGIStyle::eventFilter( QObject* o, QEvent* e ) { if ( 0 ) { #ifndef QT_NO_SCROLLBAR - } else if ( ::qt_cast<QScrollBar*>(widget) ) { + } else if (ceData.widgetObjectTypes.contains("QScrollBar")) { QRect oldRect = d->lastScrollbarRect.rect; d->lastScrollbarRect.rect = QRect( 0, -1, 0, -1 ); - widget->repaint( oldRect, FALSE ); + widgetActionRequest(ceData, elementFlags, source, WAR_RepaintRect, QStyleWidgetActionRequestData(oldRect)); #endif #ifndef QT_NO_SLIDER - } else if ( ::qt_cast<QSlider*>(widget) ) { + } else if (ceData.widgetObjectTypes.contains("QSlider")) { QRect oldRect = d->lastSliderRect.rect; d->lastSliderRect.rect = QRect( 0, -1, 0, -1 ); - widget->repaint( oldRect, FALSE ); + widgetActionRequest(ceData, elementFlags, source, WAR_RepaintRect, QStyleWidgetActionRequestData(oldRect)); #endif } } break; case QEvent::MouseMove: - if ( !widget->isActiveWindow() ) + if ( !(elementFlags & CEF_IsActiveWindow) ) break; if ( ((QMouseEvent*)e)->button() ) break; - d->hotWidget = widget; + d->hotWidget = source; d->mousePos = ((QMouseEvent*)e)->pos(); - widget->repaint( FALSE ); + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); break; case QEvent::Enter: - if ( !widget->isActiveWindow() ) + if ( !(elementFlags & CEF_IsActiveWindow) ) break; - d->hotWidget = widget; - widget->repaint( FALSE ); + d->hotWidget = source; + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); break; case QEvent::Leave: - if ( !widget->isActiveWindow() ) + if ( !(elementFlags & CEF_IsActiveWindow) ) break; - if ( widget == d->hotWidget) { + if ( source == d->hotWidget) { d->hotWidget = 0; - widget->repaint( FALSE ); + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); } break; default: break; } - return QMotifStyle::eventFilter( o, e ); + return QMotifStyle::objectEventHandler( ceData, elementFlags, source, e ); } static const int sgiItemFrame = 2; // menu item frame width |