diff options
author | Darrell Anderson <[email protected]> | 2012-08-08 15:38:38 -0500 |
---|---|---|
committer | Darrell Anderson <[email protected]> | 2012-08-08 15:38:38 -0500 |
commit | a236ea2ad383387255621fc8eaddc3c5d17f1e30 (patch) | |
tree | ecacdf1f8c9c02f545e06f8a430a145998fe11ea /src/kernel | |
parent | 92b8aca467ad650f9b77a5b6a0f56c27ecbfe80a (diff) | |
parent | 47132557a4c58d4ad69bc2898bb2bd9c424b3b64 (diff) | |
download | qt3-a236ea2ad383387255621fc8eaddc3c5d17f1e30.tar.gz qt3-a236ea2ad383387255621fc8eaddc3c5d17f1e30.zip |
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/qt3
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/qapplication_x11.cpp | 4 | ||||
-rw-r--r-- | src/kernel/qstyle.cpp | 530 | ||||
-rw-r--r-- | src/kernel/qstyle.h | 412 | ||||
-rw-r--r-- | src/kernel/qwidget.h | 6 |
4 files changed, 885 insertions, 67 deletions
diff --git a/src/kernel/qapplication_x11.cpp b/src/kernel/qapplication_x11.cpp index cd1573b..ef6571a 100644 --- a/src/kernel/qapplication_x11.cpp +++ b/src/kernel/qapplication_x11.cpp @@ -2147,7 +2147,7 @@ void qt_init_internal( int *argcptr, char **argv, for (i = 0; i < map->max_keypermod; i++) { if (map->modifiermap[mapIndex]) { KeySym sym = - XKeycodeToKeysym(appDpy, map->modifiermap[mapIndex], 0); + XkbKeycodeToKeysym(appDpy, map->modifiermap[mapIndex], 0, 0); if ( qt_alt_mask == 0 && ( sym == XK_Alt_L || sym == XK_Alt_R ) ) { qt_alt_mask = 1 << maskIndex; @@ -2177,7 +2177,7 @@ void qt_init_internal( int *argcptr, char **argv, for ( i = 0; i < map->max_keypermod; i++ ) { if ( map->modifiermap[ mapIndex ] ) { KeySym sym = - XKeycodeToKeysym( appDpy, map->modifiermap[ mapIndex ], 0 ); + XkbKeycodeToKeysym( appDpy, map->modifiermap[ mapIndex ], 0, 0 ); if ( sym == XK_Mode_switch ) { qt_mode_switch_remove_mask |= 1 << maskIndex; } diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index 8c150d5..fc4daa2 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -44,6 +44,10 @@ #include "qpainter.h" #include "qbitmap.h" #include "qpixmapcache.h" +#include "qframe.h" +#include "qlayout.h" +#include "qobjectlist.h" +#include "qwidgetlist.h" #include <limits.h> @@ -394,6 +398,10 @@ public: */ QStyle::QStyle() { + m_eventHandlerInstallationHook = NULL; + m_eventHandlerRemovalHook = NULL; + m_widgetActionRequestHook = NULL; + conditionalAcceleratorsEnabled = false; d = new QStylePrivate; } @@ -414,8 +422,6 @@ QStyle::~QStyle() style. Current supported values are Qt::WindowsStyle and Qt::MotifStyle. */ - - /*! Initializes the appearance of a widget. @@ -439,8 +445,9 @@ QStyle::~QStyle() \sa unPolish() */ -void QStyle::polish( QWidget*) -{ +void QStyle::polish( QWidget *widget ) { + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + polish(ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), widget); } /*! @@ -453,10 +460,62 @@ void QStyle::polish( QWidget*) \sa polish() */ -void QStyle::unPolish( QWidget*) -{ +void QStyle::unPolish( QWidget *widget ) { + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + unPolish(ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), widget); +} + +/*! + Initializes the appearance of a widget. + + This function is called for every widget at some point after it + has been fully created but just \e before it is shown the very + first time. + + Reasonable actions in this function might be to install a widget + event handler for the style. An example of highly unreasonable + use would be setting the geometry! With Qt 3.0's style engine + you will rarely need to write your own polish(); instead reimplement + drawItem(), drawPrimitive(), etc. + + The \a objectTypes object may provide enough information to + allow class-specific customizations. But be careful not to + hard-code things too much because new QStyle subclasses are + expected to work reasonably with all current and \e future + widgets. + + You may specify either a QWidget pointer or a custom pointer. + If a custom pointer is specified, you must be careful to intercept any event + handler installation/removal calls via setEventHandlerInstallationHook and + setEventHandlerRemovalHook. + + \sa unPolish() +*/ +void QStyle::polish( QStyleControlElementData ceData, ControlElementFlags, void *ptr ) { + if (ceData.widgetObjectTypes.contains("QWidget")) { + // Enable dynamic hide/show of accelerator shortcuts + QWidget* widget = reinterpret_cast<QWidget*>(ptr); + widget->installEventFilter(this); + } } +/*! + Undoes the initialization of a widget's appearance. + + This function is the counterpart to polish. It is called for every + polished widget when the style is dynamically changed. The former + style has to unpolish its settings before the new style can polish + them again. + + \sa polish() +*/ +void QStyle::unPolish( QStyleControlElementData ceData, ControlElementFlags, void *ptr ) { + if (ceData.widgetObjectTypes.contains("QWidget")) { + // Disable dynamic hide/show of accelerator shortcuts + QWidget* widget = reinterpret_cast<QWidget*>(ptr); + widget->installEventFilter(this); + } +} /*! \overload @@ -464,8 +523,10 @@ void QStyle::unPolish( QWidget*) \sa unPolish() */ -void QStyle::polish( QApplication*) -{ +void QStyle::polish( QApplication *app ) { + QStyleControlElementData ceData; + ceData.widgetObjectTypes = getObjectTypeListForObject(app); + applicationPolish(ceData, getControlElementFlagsForObject(app, ceData.widgetObjectTypes, QStyleOption()), app); } /*! @@ -475,8 +536,41 @@ void QStyle::polish( QApplication*) \sa polish() */ -void QStyle::unPolish( QApplication*) -{ +void QStyle::unPolish( QApplication *app ) { + QStyleControlElementData ceData; + ceData.widgetObjectTypes = getObjectTypeListForObject(app); + applicationUnPolish(ceData, getControlElementFlagsForObject(app, ceData.widgetObjectTypes, QStyleOption()), app); +} + +/*! + \overload + Late initialization of the QApplication object or other global application object. + + You may specify either a QApplication pointer or a custom pointer. + If a custom pointer is specified, you must be careful to intercept any event + handler installation/removal calls via setEventHandlerInstallationHook and + setEventHandlerRemovalHook. + + \sa unPolish() +*/ +void QStyle::applicationPolish( QStyleControlElementData, ControlElementFlags, void * ) { + // +} + +/*! + \overload + + Undoes the application polish. + + You may specify either a QApplication pointer or a custom pointer. + If a custom pointer is specified, you must be careful to intercept any event + handler installation/removal calls via setEventHandlerInstallationHook and + setEventHandlerRemovalHook. + + \sa polish() +*/ +void QStyle::applicationUnPolish( QStyleControlElementData, ControlElementFlags, void * ) { + // } /*! @@ -802,11 +896,14 @@ void QStyle::drawItem( QPainter *p, const QRect &r, */ /*! - \fn void QStyle::drawPrimitive( PrimitiveElement pe, QPainter *p, const QRect &r, const QColorGroup &cg, SFlags flags, const QStyleOption& opt) const + \fn void QStyle::drawPrimitive( PrimitiveElement pe, QPainter *p, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, SFlags flags, const QStyleOption& opt) const Draws the style PrimitiveElement \a pe using the painter \a p in the area \a r. Colors are used from the color group \a cg. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The rect \a r should be in screen coordinates. The \a flags argument is used to control how the PrimitiveElement @@ -932,20 +1029,25 @@ void QStyle::drawItem( QPainter *p, const QRect &r, */ /*! - \fn void QStyle::drawControl( ControlElement element, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags how, const QStyleOption& opt) const + \fn void QStyle::drawControl( ControlElement element, QPainter *p, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, SFlags how, const QStyleOption& opt, const QWidget *widget) const Draws the ControlElement \a element using the painter \a p in the area \a r. Colors are used from the color group \a cg. The rect \a r should be in screen coordinates. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The \a how argument is used to control how the ControlElement is drawn. Multiple flags can be OR'ed together. See the table below for an explanation of which flags are used with the various ControlElements. The \a widget argument is a pointer to a QWidget or one of its - subclasses. The widget can be cast to the appropriate type based + subclasses. Note that usage of the widget argument is deprecated + in favor of specifying widget parameters via \a ceData and \a elementFlags. + The widget can be cast to the appropriate type based on the value of \a element. The \a opt argument can be used to pass extra information required when drawing the ControlElement. Note that \a opt may be the default value even for ControlElements @@ -1086,14 +1188,19 @@ void QStyle::drawItem( QPainter *p, const QRect &r, */ /*! - \fn void QStyle::drawControlMask( ControlElement element, QPainter *p, const QWidget *widget, const QRect &r, const QStyleOption& opt) const + \fn void QStyle::drawControlMask( ControlElement element, QPainter *p, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QRect &r, const QStyleOption& opt, const QWidget *widget) const Draw a bitmask for the ControlElement \a element using the painter \a p in the area \a r. See drawControl() for an explanation of the use of the \a widget and \a opt arguments. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The rect \a r should be in screen coordinates. + \a widget is deprecated and should not be used. + \sa drawControl(), ControlElement */ @@ -1154,15 +1261,19 @@ void QStyle::drawItem( QPainter *p, const QRect &r, */ /*! - \fn QRect QStyle::subRect( SubRect subrect, const QWidget *widget ) const; + \fn QRect QStyle::subRect( SubRect subrect, const QStyleControlElementData ceData, const ControlElementFlags elementFlags, const QWidget *widget ) const; Returns the sub-area \a subrect for the \a widget in logical coordinates. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The \a widget argument is a pointer to a QWidget or one of its - subclasses. The widget can be cast to the appropriate type based - on the value of \a subrect. See the table below for the - appropriate \a widget casts: + subclasses. Note that usage of \a widget is deprecated in favor + of \a ceData and \a elementFlags. The widget can be cast to the + appropriate type based on the value of \a subrect. See the table + below for the appropriate \a widget casts: \table \header \i SubRect \i Widget Cast @@ -1282,7 +1393,7 @@ void QStyle::drawItem( QPainter *p, const QRect &r, */ /*! - \fn void QStyle::drawComplexControl( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags how, SCFlags sub, SCFlags subActive, const QStyleOption& opt ) const + \fn void QStyle::drawComplexControl( ComplexControl control, QPainter *p, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, SFlags how, SCFlags sub, SCFlags subActive, const QStyleOption& opt, const QWidget *widget ) const Draws the ComplexControl \a control using the painter \a p in the area \a r. Colors are used from the color group \a cg. The \a sub @@ -1295,6 +1406,9 @@ void QStyle::drawItem( QPainter *p, const QRect &r, coordinates into screen coordinates when using drawPrimitive() and drawControl(). + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The \a how argument is used to control how the ComplexControl is drawn. Multiple flags can OR'ed together. See the table below for an explanation of which flags are used with the various @@ -1302,11 +1416,13 @@ void QStyle::drawItem( QPainter *p, const QRect &r, The \a widget argument is a pointer to a QWidget or one of its subclasses. The widget can be cast to the appropriate type based - on the value of \a control. The \a opt argument can be used to - pass extra information required when drawing the ComplexControl. - Note that \a opt may be the default value even for ComplexControls - that can make use of the extra options. See the table below for - the appropriate \a widget and \a opt usage: + on the value of \a control. Note that usage of \a widget is + deprecated in favor of \a ceData and \a elementFlags. The \a opt + argument can be used to pass extra information required when + drawing the ComplexControl. Note that \a opt may be the default + value even for ComplexControls that can make use of the extra + options. See the table below for the appropriate \a widget and + \a opt usage: \table \header \i ComplexControl<br>\& Widget Cast @@ -1375,26 +1491,34 @@ void QStyle::drawItem( QPainter *p, const QRect &r, */ /*! - \fn void QStyle::drawComplexControlMask( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QStyleOption& opt) const + \fn void QStyle::drawComplexControlMask( ComplexControl control, QPainter *p, const QStyleControlElementData ceData, const ControlElementFlags elementFlags, const QRect &r, const QStyleOption& opt, const QWidget *widget) const Draw a bitmask for the ComplexControl \a control using the painter \a p in the area \a r. See drawComplexControl() for an explanation of the use of the \a widget and \a opt arguments. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The rect \a r should be in logical coordinates. Reimplementations of this function should use visualRect() to change the logical corrdinates into screen coordinates when using drawPrimitive() and drawControl(). + Note that usage of \a widget is deprecated in favor of \a ceData and \a elementFlags. + \sa drawComplexControl() ComplexControl */ /*! - \fn QRect QStyle::querySubControlMetrics( ComplexControl control, const QWidget *widget, SubControl subcontrol, const QStyleOption& opt = QStyleOption::Default ) const; + \fn QRect QStyle::querySubControlMetrics( ComplexControl control, QStyleControlElementData ceData, ControlElementFlags elementFlags, SubControl subcontrol, const QStyleOption& opt = QStyleOption::Default, const QWidget *widget = 0 ) const; Returns the rect for the SubControl \a subcontrol for \a widget in logical coordinates. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The \a widget argument is a pointer to a QWidget or one of its subclasses. The widget can be cast to the appropriate type based on the value of \a control. The \a opt argument can be used to @@ -1403,11 +1527,13 @@ void QStyle::drawItem( QPainter *p, const QRect &r, that can make use of the extra options. See drawComplexControl() for an explanation of the \a widget and \a opt arguments. + Note that usage of \a widget is deprecated in favor of \a ceData and \a elementFlags. + \sa drawComplexControl(), ComplexControl, SubControl */ /*! - \fn SubControl QStyle::querySubControl( ComplexControl control, const QWidget *widget, const QPoint &pos, const QStyleOption& opt = QStyleOption::Default ) const; + \fn SubControl QStyle::querySubControl( ComplexControl control, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QPoint &pos, const QStyleOption& opt = QStyleOption::Default, const QWidget *widget = 0 ) const; Returns the SubControl for \a widget at the point \a pos. The \a widget argument is a pointer to a QWidget or one of its @@ -1418,11 +1544,16 @@ void QStyle::drawItem( QPainter *p, const QRect &r, that can make use of the extra options. See drawComplexControl() for an explanation of the \a widget and \a opt arguments. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + Note that \a pos is passed in screen coordinates. When using querySubControlMetrics() to check for hits and misses, use visualRect() to change the logical coordinates into screen coordinates. + Note that usage of \a widget is deprecated in favor of \a ceData and \a elementFlags. + \sa drawComplexControl(), ComplexControl, SubControl, querySubControlMetrics() */ @@ -1528,14 +1659,20 @@ void QStyle::drawItem( QPainter *p, const QRect &r, */ /*! - \fn int QStyle::pixelMetric( PixelMetric metric, const QWidget *widget = 0 ) const; + \fn int QStyle::pixelMetric( PixelMetric metric, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QWidget *widget = 0 ) const; + + Returns the pixel metric for \a metric. + + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. - Returns the pixel metric for \a metric. The \a widget argument is - a pointer to a QWidget or one of its subclasses. The widget can be - cast to the appropriate type based on the value of \a metric. Note - that \a widget may be zero even for PixelMetrics that can make use - of \a widget. See the table below for the appropriate \a widget - casts: + The \a widget argument is a pointer to a QWidget or one of its + subclasses. The widget can be cast to the appropriate type based + on the value of \a metric. Note that \a widget may be zero even + for PixelMetrics that can make use of \a widget. Note also that + usage of \a widget is deprecated in favor of \a ceData and + \a elementFlags. See the table below for the appropriate + \a widget casts: \table \header \i PixelMetric \i Widget Cast @@ -1584,18 +1721,22 @@ void QStyle::drawItem( QPainter *p, const QRect &r, */ /*! - \fn QSize QStyle::sizeFromContents( ContentsType contents, const QWidget *widget, const QSize &contentsSize, const QStyleOption& opt = QStyleOption::Default ) const; + \fn QSize QStyle::sizeFromContents( ContentsType contents, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QSize &contentsSize, const QStyleOption& opt = QStyleOption::Default, const QWidget *widget = 0 ) const; Returns the size of \a widget based on the contents size \a contentsSize. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The \a widget argument is a pointer to a QWidget or one of its subclasses. The widget can be cast to the appropriate type based on the value of \a contents. The \a opt argument can be used to pass extra information required when calculating the size. Note that \a opt may be the default value even for ContentsTypes that - can make use of the extra options. See the table below for the - appropriate \a widget and \a opt usage: + can make use of the extra options. Note that usage of \a widget + is deprecated in favor of \a ceData and \a elementFlags. See the + table below for the appropriate \a widget and \a opt usage: \table \header \i ContentsType \i Widget Cast \i Options \i Notes @@ -1770,12 +1911,18 @@ void QStyle::drawItem( QPainter *p, const QRect &r, */ /*! - \fn int QStyle::styleHint( StyleHint stylehint, const QWidget *widget = 0, const QStyleOption &opt = QStyleOption::Default, QStyleHintReturn *returnData = 0 ) const; + \fn int QStyle::styleHint( StyleHint stylehint, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &opt = QStyleOption::Default, QStyleHintReturn *returnData = 0, const QWidget *widget = 0 ) const; Returns the style hint \a stylehint for \a widget. Currently, \a widget, \a opt, and \a returnData are unused; they're included to allow for future enhancements. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + + Note that usage of \a widget is deprecated in favor of \a ceData + and \a elementFlags. + For an explanation of the return value see \l StyleHint. */ @@ -1811,10 +1958,13 @@ void QStyle::drawItem( QPainter *p, const QRect &r, */ /*! - \fn QPixmap QStyle::stylePixmap( StylePixmap stylepixmap, const QWidget *widget = 0, const QStyleOption& opt = QStyleOption::Default ) const; + \fn QPixmap QStyle::stylePixmap( StylePixmap stylepixmap, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption& opt = QStyleOption::Default, const QWidget *widget = 0 ) const; Returns a pixmap for \a stylepixmap. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The \a opt argument can be used to pass extra information required when drawing the ControlElement. Note that \a opt may be the default value even for StylePixmaps that can make use of the extra @@ -1822,8 +1972,9 @@ void QStyle::drawItem( QPainter *p, const QRect &r, The \a widget argument is a pointer to a QWidget or one of its subclasses. The widget can be cast to the appropriate type based - on the value of \a stylepixmap. See the table below for the - appropriate \a widget casts: + on the value of \a stylepixmap. Note that usage of \a widget is + deprecated in favor of \a ceData and \a elementFlags.See the table + below for the appropriate \a widget casts: \table \header \i StylePixmap \i Widget Cast @@ -1847,11 +1998,33 @@ void QStyle::drawItem( QPainter *p, const QRect &r, function is provided to aid style implementors in supporting right-to-left mode. + Note that this function is deprecated in favor of visualRect( const QRect &logical, const QStyleControlElementData ceData, const ControlElementFlags elementFlags ); + \sa QApplication::reverseLayout() */ QRect QStyle::visualRect( const QRect &logical, const QWidget *w ) { - QRect boundingRect = w->rect(); + QStyleControlElementData ceData; + ceData.rect = w->rect(); + return visualRect(logical, ceData, CEF_None); +} + +/*! + \fn QRect QStyle::visualRect( const QRect &logical, const QStyleControlElementData ceData, const ControlElementFlags elementFlags ); + + Returns the rect \a logical in screen coordinates. The bounding + rect for the widget described by \a ceData and \a elementFlags + is used to perform the translation. This function is provided to + aid style implementors in supporting + right-to-left mode. + + \sa QApplication::reverseLayout() +*/ +QRect QStyle::visualRect( const QRect &logical, const QStyleControlElementData ceData, const ControlElementFlags elementFlags ) +{ + Q_UNUSED(elementFlags) + + QRect boundingRect = ceData.rect; QRect r = logical; if ( QApplication::reverseLayout() ) r.moveBy( 2*(boundingRect.right() - logical.right()) + @@ -1879,6 +2052,279 @@ QRect QStyle::visualRect( const QRect &logical, const QRect &boundingRect ) } /*! + \fn void QStyle::installObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ); + + Intercepts events generated by \a source and sends them to \a handler via + the bool QStyle::objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ) virtual method. + + \sa void QStyle::removeObjectEventHandler( QObject* source, QStyle* handler ) + \sa bool QStyle::objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ) +*/ +void QStyle::installObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ) { + bool cbret = false; + if (m_eventHandlerInstallationHook) { + cbret = (*m_eventHandlerInstallationHook)(ceData, elementFlags, source, handler); + } + if (!cbret) { + if (ceData.widgetObjectTypes.contains("QObject")) { + QObject* o = reinterpret_cast<QObject*>(source); + o->installEventFilter(this); + m_objectEventSourceToHandlerMap[source] = handler; + m_objectEventSourceDataToHandlerMap[source] = ceData; + m_objectEventSourceFlagsToHandlerMap[source] = elementFlags; + } + } +} + +/*! + \fn void QStyle::removeObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ); + + Stops intercepting events generated by \a source. + + \sa void QStyle::installObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ) +*/ +void QStyle::removeObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ) { + bool cbret = false; + if (m_eventHandlerRemovalHook) { + cbret = (*m_eventHandlerRemovalHook)(ceData, elementFlags, source, handler); + } + if (!cbret) { + if (ceData.widgetObjectTypes.contains("QObject")) { + QObject* o = reinterpret_cast<QObject*>(source); + m_objectEventSourceToHandlerMap.remove(source); + m_objectEventSourceDataToHandlerMap.remove(source); + m_objectEventSourceFlagsToHandlerMap.remove(source); + o->removeEventFilter(this); + } + } +} + +/*! + \fn void QStyle::setEventHandlerInstallationHook( EventHandlerInstallationHook hook ); + + Sets a callback function \a hook which will be called whenever a new intercept request + is made via the QStyle::installObjectEventHandler method. The callback function must + use this definition: bool callbackFunction( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ). + + \sa void QStyle::installObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ) +*/ +void QStyle::setEventHandlerInstallationHook( EventHandlerInstallationHook hook ) { + m_eventHandlerInstallationHook = hook; +} + +/*! + \fn void QStyle::setEventHandlerRemovalHook( EventHandlerRemovalHook hook ); + + Sets a callback function \a hook which will be called whenever a new intercept deactivation request + is made via the QStyle::removeObjectEventHandler method. The callback function must + use this definition: bool callbackFunction( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ). + + \sa void QStyle::removeObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ) +*/ +void QStyle::setEventHandlerRemovalHook( EventHandlerRemovalHook hook ) { + m_eventHandlerRemovalHook = hook; +} + +/*! + \fn bool QStyle::objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ); + + Override this virtual function to intercept events requested by a previous call to + QStyle::installObjectEventHandler. + + \sa void QStyle::installObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ) + \sa void QStyle::removeObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ) +*/ +bool QStyle::objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ) { + Q_UNUSED(ceData); + Q_UNUSED(elementFlags); + Q_UNUSED(source); + Q_UNUSED(e); + return false; +} + +/*! + \fn bool QStyle::eventFilter(QObject *o, QEvent *e); + \internal +*/ +bool QStyle::eventFilter(QObject *o, QEvent *e) { + acceleratorKeypressEventMonitor(o, e); + + if (m_objectEventSourceToHandlerMap.contains(o)) { + QStyle* handler = m_objectEventSourceToHandlerMap[o]; + QStyleControlElementData ceData = m_objectEventSourceDataToHandlerMap[o]; + ControlElementFlags elementFlags = m_objectEventSourceFlagsToHandlerMap[o]; + bool ret = handler->objectEventHandler(ceData, elementFlags, o, e); + if (ret) { + return ret; + } + else { + return QObject::eventFilter(o, e); + } + } + else { + return QObject::eventFilter(o, e); + } +} + +/*! + \fn void QStyle::setWidgetActionRequestHook( WidgetActionRequestHook hook ); + + Sets a callback function \a hook which will be called whenever a new widget action request + is made via the QStyle::installObjectEventHandler method. The callback function must + use this definition: bool callbackFunction( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ). + + \sa void QStyle::installObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ) +*/ +void QStyle::setWidgetActionRequestHook( WidgetActionRequestHook hook ) { + m_widgetActionRequestHook = hook; +} + +/*! + \fn bool widgetActionRequestHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request ); + + Handles widget action requests. Return FALSE to continue processing in base classes, TRUE to eat the request and halt processing. +*/ +bool QStyle::widgetActionRequest( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, QStyleWidgetActionRequestData requestData ) { + bool cbret = false; + if (m_widgetActionRequestHook) { + cbret = (*m_widgetActionRequestHook)(ceData, elementFlags, source, request, requestData); + } + if (!cbret) { + if (ceData.widgetObjectTypes.contains("QWidget")) { + QWidget* widget = reinterpret_cast<QWidget*>(source); + if (request == WAR_Repaint) { + widget->repaint(FALSE); + } + else if (request == WAR_RepaintRect) { + widget->repaint(requestData.rect, FALSE); + } + else if (request == WAR_EnableMouseTracking) { + widget->setMouseTracking(TRUE); + } + else if (request == WAR_DisableMouseTracking) { + widget->setMouseTracking(FALSE); + } + else if (request == WAR_FrameSetStyle) { + QFrame* frame = dynamic_cast<QFrame*>(widget); + if (frame) { + frame->setFrameStyle(requestData.metric1); + } + } + else if (request == WAR_FrameSetLineWidth) { + QFrame* frame = dynamic_cast<QFrame*>(widget); + if (frame) { + frame->setLineWidth(requestData.metric1); + } + } + else if (request == WAR_SetLayoutMargin) { + QLayout* layout = widget->layout(); + if (layout) { + layout->setMargin(requestData.metric1); + } + } + else if (request == WAR_SetPalette) { + widget->setPalette(requestData.palette); + } + else if (request == WAR_SetBackgroundMode) { + widget->setBackgroundMode((Qt::BackgroundMode)requestData.metric1); + } + else if (request == WAR_SetFont) { + widget->setFont(requestData.font); + } + else if (request == WAR_RepaintAllAccelerators) { + QWidgetList *list = QApplication::topLevelWidgets(); + QWidgetListIt it( *list ); + QWidget * widget; + while ((widget=it.current()) != 0) { + ++it; + + QObjectList *l = widget->queryList("QWidget"); + QObjectListIt it2( *l ); + QWidget *w; + while ( (w = (QWidget*)it2.current()) != 0 ) { + ++it2; + if (w->isTopLevel() || !w->isVisible() || w->style().styleHint(SH_UnderlineAccelerator, QStyleControlElementData(), CEF_None, w)) { + l->removeRef(w); + } + } + + // Repaint all relevant widgets + it2.toFirst(); + while ( (w = (QWidget*)it2.current()) != 0 ) { + ++it2; + w->repaint(FALSE); + } + delete l; + } + delete list; + } + return true; + } + } + return true; +} + +void QStyle::acceleratorKeypressEventMonitor( QObject *o, QEvent *e ) { + if (styleHint(SH_HideUnderlineAcceleratorWhenAltUp, QStyleControlElementData(), CEF_None, QStyleOption::Default, NULL, NULL) != 0) { + QWidget *widget = dynamic_cast<QWidget*>(o); + if (widget) { + switch(e->type()) { + case QEvent::KeyPress: + if (((QKeyEvent*)e)->key() == Key_Alt) { + conditionalAcceleratorsEnabled = true; + widgetActionRequest(QStyleControlElementData(), CEF_None, o, WAR_RepaintAllAccelerators); + } + break; + case QEvent::KeyRelease: + if (((QKeyEvent*)e)->key() == Key_Alt) { + conditionalAcceleratorsEnabled = false; + widgetActionRequest(QStyleControlElementData(), CEF_None, o, WAR_RepaintAllAccelerators); + } + break; + default: + break; + } + } + } + else { + conditionalAcceleratorsEnabled = false; + } +} + +bool QStyle::acceleratorsShown() const { + if (styleHint(SH_HideUnderlineAcceleratorWhenAltUp, QStyleControlElementData(), CEF_None, QStyleOption::Default, NULL, NULL) != 0) { + return conditionalAcceleratorsEnabled; + } + else { + return true; + } +} + +QStyleWidgetActionRequestData::QStyleWidgetActionRequestData() { + // +} +QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(int param1, int param2) { + metric1 = param1; + metric2 = param2; +} + +QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QPalette param) { + palette = param; +} + +QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QFont param) { + font = param; +} + +QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QRect param) { + rect = param; +} + +QStyleWidgetActionRequestData::~QStyleWidgetActionRequestData() { + // +} + +/*! \fn int QStyle::defaultFrameWidth() const \obsolete */ diff --git a/src/kernel/qstyle.h b/src/kernel/qstyle.h index 64152ed..bb2efbc 100644 --- a/src/kernel/qstyle.h +++ b/src/kernel/qstyle.h @@ -42,6 +42,11 @@ #ifndef QT_H #include "qobject.h" +#include "qpixmap.h" +#include "qcolor.h" +#include "qiconset.h" +#include "qtabbar.h" +#include "qtoolbutton.h" #endif // QT_H @@ -58,26 +63,26 @@ class QStyleOption { public: enum StyleOptionDefault { Default }; - QStyleOption(StyleOptionDefault=Default) : def(TRUE) {} + QStyleOption(StyleOptionDefault=Default) : def(TRUE), tb(NULL) {} // Note: we don't use default arguments since that is unnecessary // initialization. QStyleOption(int in1) : - def(FALSE), i1(in1) {} + def(FALSE), tb(NULL), i1(in1) {} QStyleOption(int in1, int in2) : - def(FALSE), i1(in1), i2(in2) {} + def(FALSE), tb(NULL), i1(in1), i2(in2) {} QStyleOption(int in1, int in2, int in3, int in4) : - def(FALSE), i1(in1), i2(in2), i3(in3), i4(in4) {} - QStyleOption(QMenuItem* m) : def(FALSE), mi(m) {} - QStyleOption(QMenuItem* m, int in1) : def(FALSE), mi(m), i1(in1) {} - QStyleOption(QMenuItem* m, int in1, int in2) : def(FALSE), mi(m), i1(in1), i2(in2) {} - QStyleOption(const QColor& c) : def(FALSE), cl(&c) {} + def(FALSE), tb(NULL), i1(in1), i2(in2), i3(in3), i4(in4) {} + QStyleOption(QMenuItem* m) : def(FALSE), mi(m), tb(NULL) {} + QStyleOption(QMenuItem* m, int in1) : def(FALSE), mi(m), tb(NULL), i1(in1) {} + QStyleOption(QMenuItem* m, int in1, int in2) : def(FALSE), mi(m), tb(NULL), i1(in1), i2(in2) {} + QStyleOption(const QColor& c) : def(FALSE), tb(NULL), cl(&c) {} QStyleOption(QTab* t) : def(FALSE), tb(t) {} - QStyleOption(QListViewItem* i) : def(FALSE), li(i) {} - QStyleOption(QCheckListItem* i) : def(FALSE), cli(i) {} - QStyleOption(Qt::ArrowType a) : def(FALSE), i1((int)a) {} - QStyleOption(const QRect& r) : def(FALSE), i1(r.x()), i2(r.y()), i3(r.width()),i4(r.height()){} - QStyleOption(QWidget *w) : def(FALSE), p1((void*)w) {} + QStyleOption(QListViewItem* i) : def(FALSE), tb(NULL), li(i) {} + QStyleOption(QCheckListItem* i) : def(FALSE), tb(NULL), cli(i) {} + QStyleOption(Qt::ArrowType a) : def(FALSE), tb(NULL), i1((int)a) {} + QStyleOption(const QRect& r) : def(FALSE), tb(NULL), i1(r.x()), i2(r.y()), i3(r.width()),i4(r.height()){} + QStyleOption(QWidget *w) : def(FALSE), tb(NULL), p1((void*)w) {} bool isDefault() const { return def; } @@ -121,6 +126,138 @@ private: class QStyleHintReturn; // not defined yet +typedef QMap<Q_UINT32, QSize> DialogButtonSizeMap; +typedef QMap<Q_INT32, Q_INT32> TabIdentifierIndexMap; + +class QStyleControlElementPopupMenuData { + public: + // +}; + +class QStyleControlElementTabBarData { + public: + int tabCount; + QTabBar::Shape shape; + TabIdentifierIndexMap identIndexMap; +}; + +class QStyleControlElementListViewData { + public: + bool rootDecorated; + int itemMargin; +}; + +class QStyleControlElementSpinWidgetData { + public: + Q_UINT32 buttonSymbols; + QRect upRect; + QRect downRect; + bool upEnabled; + bool downEnabled; +}; + +class QStyleControlElementTitleBarData { + public: + bool hasWindow; + bool usesActiveColor; + int windowState; + QString visibleText; +}; + +class QStyleControlElementDockWidgetData { + public: + bool hasDockArea; + bool closeEnabled; + Qt::Orientation areaOrientation; +}; + +class QStyleControlElementGenericWidgetData { + public: + QStringList widgetObjectTypes; + bool allDataPopulated; + Qt::WFlags wflags; + QPixmap bgPixmap; + QBrush bgBrush; + QColor bgColor; + QPoint bgOffset; + Qt::BackgroundMode backgroundMode; + QColor fgColor; + QColorGroup colorGroup; + QRect geometry; + QRect rect; + QPoint pos; + QPixmap icon; + QPalette palette; + QFont font; +}; + +class QStyleControlElementData { + public: + QStringList widgetObjectTypes; + bool allDataPopulated; + Qt::WFlags wflags; + QPixmap bgPixmap; + QBrush bgBrush; + QColor bgColor; + QPoint bgOffset; + Qt::BackgroundMode backgroundMode; + QPixmap fgPixmap; + QColor fgColor; + QColorGroup colorGroup; + QRect geometry; + QRect rect; + QPoint pos; + QPixmap icon; + QIconSet iconSet; + QString text; + Qt::Orientation orientation; + QColor activeItemPaletteBgColor; + QPalette palette; + int totalSteps; + int currentStep; + Q_UINT32 tickMarkSetting; + int tickInterval; + int minSteps; + int maxSteps; + int startStep; + int pageStep; + int lineStep; + int dlgVisibleButtons; + DialogButtonSizeMap dlgVisibleSizeHints; + QString progressText; + QString textLabel; + QFont font; + int percentageVisible; + QStyleControlElementDockWidgetData dwData; + QToolButton::TextPosition toolButtonTextPosition; + int popupDelay; + QStyleControlElementTitleBarData titleBarData; + QStyleControlElementSpinWidgetData spinWidgetData; + QStyleControlElementGenericWidgetData parentWidgetData; + QStyleControlElementGenericWidgetData viewportData; + QStyleControlElementListViewData listViewData; + QStyleControlElementTabBarData tabBarData; + Q_UINT32 comboBoxLineEditFlags; + Q_UINT32 frameStyle; + QRect sliderRect; +}; + +class QStyleWidgetActionRequestData { + public: + QStyleWidgetActionRequestData(); + QStyleWidgetActionRequestData(int metric1, int metric2=0); + QStyleWidgetActionRequestData(QPalette palette); + QStyleWidgetActionRequestData(QFont font); + QStyleWidgetActionRequestData(QRect rect); + ~QStyleWidgetActionRequestData(); + public: + int metric1; + int metric2; + QPalette palette; + QFont font; + QRect rect; +}; + class Q_EXPORT QStyle: public QObject { Q_OBJECT @@ -129,14 +266,64 @@ public: QStyle(); virtual ~QStyle(); + enum ControlElementFlags { + CEF_None = 0x00000000, + CEF_IsDefault = 0x00000001, + CEF_AutoDefault = 0x00000002, + CEF_IsActive = 0x00000004, + CEF_IsDown = 0x00000008, + CEF_IsOn = 0x00000010, + CEF_IsEnabled = 0x00000020, + CEF_BiState = 0x00000040, + CEF_HasFocus = 0x00000080, + CEF_IsMenuWidget = 0x00000100, + CEF_IsContainerEmpty = 0x00000200, + CEF_CenterIndicator = 0x00000400, + CEF_IndicatorFollowsStyle = 0x00000800, + CEF_UsesTextLabel = 0x00001000, + CEF_UsesBigPixmap = 0x00002000, + CEF_UseGenericParameters = 0x00004000, + CEF_HasParentWidget = 0x00008000, + CEF_HasPopupMenu = 0x00010000, + CEF_IsCheckable = 0x00020000, + CEF_HasFocusProxy = 0x00040000, + CEF_IsEditable = 0x00080000, + CEF_IsFlat = 0x00100000, + CEF_IsActiveWindow = 0x00200000, + CEF_IsTopLevel = 0x00400000, + CEF_IsVisible = 0x00800000, + }; + // New QStyle API - most of these should probably be pure virtual + // Old API + // DEPRECATED virtual void polish( QWidget * ); + + // New API + virtual void polish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + + // Old API + // DEPRECATED virtual void unPolish( QWidget * ); + // New API + virtual void unPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + + // Old API + // DEPRECATED virtual void polish( QApplication * ); + + // New API + virtual void applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + + // Old API + // DEPRECATED virtual void unPolish( QApplication * ); + // New API + virtual void applicationUnPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + virtual void polish( QPalette & ); virtual void polishPopupMenu( QPopupMenu* ) = 0; @@ -151,7 +338,6 @@ public: const QPixmap *pixmap, const QString &text, int len = -1, const QColor *penColor = 0 ) const; - enum PrimitiveElement { PE_ButtonCommand, PE_ButtonDefault, @@ -252,8 +438,20 @@ public: }; typedef uint SFlags; + // Old API + // DEPRECATED + virtual void drawPrimitive( PrimitiveElement pe, + QPainter *p, + const QRect &r, + const QColorGroup &cg, + SFlags flags = Style_Default, + const QStyleOption& = QStyleOption::Default ) const = 0; + + // New API virtual void drawPrimitive( PrimitiveElement pe, QPainter *p, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, SFlags flags = Style_Default, @@ -294,6 +492,8 @@ public: CE_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED virtual void drawControl( ControlElement element, QPainter *p, const QWidget *widget, @@ -301,12 +501,35 @@ public: const QColorGroup &cg, SFlags how = Style_Default, const QStyleOption& = QStyleOption::Default ) const = 0; + + // New API + virtual void drawControl( ControlElement element, + QPainter *p, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QRect &r, + const QColorGroup &cg, + SFlags how = Style_Default, + const QStyleOption& = QStyleOption::Default, + const QWidget *widget = 0 /* compat, will likely go away */ ) const = 0; + + // Old API + // DEPRECATED virtual void drawControlMask( ControlElement element, QPainter *p, const QWidget *widget, const QRect &r, const QStyleOption& = QStyleOption::Default ) const = 0; + // New API + virtual void drawControlMask( ControlElement element, + QPainter *p, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QRect &r, + const QStyleOption& = QStyleOption::Default, + const QWidget *widget = 0 /* compat, will likely go away */ ) const = 0; + enum SubRect { SR_PushButtonContents, SR_PushButtonFocusRect, @@ -347,8 +570,13 @@ public: SR_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED virtual QRect subRect( SubRect r, const QWidget *widget ) const = 0; + // New API + virtual QRect subRect( SubRect r, const QStyleControlElementData ceData, const ControlElementFlags elementFlags, const QWidget *widget ) const = 0; + enum ComplexControl{ CC_SpinWidget, @@ -411,6 +639,8 @@ public: typedef uint SCFlags; + // Old API + // DEPRECATED virtual void drawComplexControl( ComplexControl control, QPainter *p, const QWidget *widget, @@ -424,21 +654,70 @@ public: #endif SCFlags subActive = SC_None, const QStyleOption& = QStyleOption::Default ) const = 0; + + virtual void drawComplexControl( ComplexControl control, + QPainter *p, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QRect &r, + const QColorGroup &cg, + SFlags how = Style_Default, +#ifdef Q_QDOC + SCFlags sub = SC_All, +#else + SCFlags sub = (uint)SC_All, +#endif + SCFlags subActive = SC_None, + const QStyleOption& = QStyleOption::Default, + const QWidget *widget = 0 ) const = 0; + + // Old API + // DEPRECATED virtual void drawComplexControlMask( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QStyleOption& = QStyleOption::Default ) const = 0; + // New API + virtual void drawComplexControlMask( ComplexControl control, + QPainter *p, + const QStyleControlElementData ceData, + const ControlElementFlags elementFlags, + const QRect &r, + const QStyleOption& = QStyleOption::Default, + const QWidget *widget = 0 ) const = 0; + + // Old API + // DEPRECATED virtual QRect querySubControlMetrics( ComplexControl control, const QWidget *widget, SubControl sc, const QStyleOption& = QStyleOption::Default ) const = 0; + + // New API + virtual QRect querySubControlMetrics( ComplexControl control, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + SubControl sc, + const QStyleOption& = QStyleOption::Default, + const QWidget *widget = 0 ) const = 0; + + // Old API + // DEPRECATED virtual SubControl querySubControl( ComplexControl control, const QWidget *widget, const QPoint &pos, const QStyleOption& = QStyleOption::Default ) const = 0; + // New API + virtual SubControl querySubControl( ComplexControl control, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QPoint &pos, + const QStyleOption& = QStyleOption::Default, + const QWidget *widget = 0 ) const = 0; + enum PixelMetric { PM_ButtonMargin, @@ -508,7 +787,15 @@ public: PM_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED + virtual int pixelMetric( PixelMetric metric, + const QWidget *widget = 0 ) const = 0; + + // New API virtual int pixelMetric( PixelMetric metric, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, const QWidget *widget = 0 ) const = 0; @@ -536,11 +823,20 @@ public: CT_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED virtual QSize sizeFromContents( ContentsType contents, const QWidget *widget, const QSize &contentsSize, const QStyleOption& = QStyleOption::Default ) const = 0; + virtual QSize sizeFromContents( ContentsType contents, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QSize &contentsSize, + const QStyleOption& = QStyleOption::Default, + const QWidget *widget = 0 ) const = 0; + enum StyleHint { // ... // the general hints @@ -683,16 +979,30 @@ public: // when the mouse is over the button SH_ToolButton_Uses3D, + // bool - hide underlined accelerators uless Alt key is currently down + SH_HideUnderlineAcceleratorWhenAltUp, + // do not add any values below/greater than this SH_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED virtual int styleHint( StyleHint stylehint, const QWidget *widget = 0, const QStyleOption& = QStyleOption::Default, QStyleHintReturn* returnData = 0 ) const = 0; + // New API + virtual int styleHint( StyleHint stylehint, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QStyleOption& = QStyleOption::Default, + QStyleHintReturn* returnData = 0, + const QWidget *widget = 0 + ) const = 0; + enum StylePixmap { SP_TitleBarMinButton, @@ -711,39 +1021,86 @@ public: SP_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED virtual QPixmap stylePixmap( StylePixmap stylepixmap, const QWidget *widget = 0, const QStyleOption& = QStyleOption::Default ) const = 0; + virtual QPixmap stylePixmap( StylePixmap stylepixmap, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QStyleOption& = QStyleOption::Default, + const QWidget *widget = 0 ) const = 0; + + // Old API + // DEPRECATED static QRect visualRect( const QRect &logical, const QWidget *w ); + // New API + static QRect visualRect( const QRect &logical, const QStyleControlElementData ceData, const ControlElementFlags elementFlags ); + static QRect visualRect( const QRect &logical, const QRect &bounding ); + // Object event handling API + typedef QMap<void*, QStyle*> ObjectEventSourceToHandlerMap; + typedef QMap<void*, QStyleControlElementData> ObjectEventSourceDataToHandlerMap; + typedef QMap<void*, ControlElementFlags> ObjectEventSourceFlagsToHandlerMap; + typedef bool (*EventHandlerInstallationHook)(QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler); + typedef bool (*EventHandlerRemovalHook)(QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler); + void installObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ); + void removeObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ); + void setEventHandlerInstallationHook( EventHandlerInstallationHook ); + void setEventHandlerRemovalHook( EventHandlerRemovalHook hook ); + virtual bool objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ); + + enum WidgetActionRequest { + WAR_Repaint, + WAR_RepaintRect, + WAR_EnableMouseTracking, + WAR_DisableMouseTracking, + WAR_FrameSetStyle, + WAR_FrameSetLineWidth, + WAR_SetLayoutMargin, + WAR_SetPalette, + WAR_SetBackgroundMode, + WAR_SetFont, + WAR_RepaintAllAccelerators + }; + typedef bool (*WidgetActionRequestHook)(QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, QStyleWidgetActionRequestData requestData); + void setWidgetActionRequestHook( WidgetActionRequestHook ); + virtual bool widgetActionRequest( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, QStyleWidgetActionRequestData requestData = QStyleWidgetActionRequestData() ); // Old 2.x QStyle API #ifndef QT_NO_COMPAT int defaultFrameWidth() const { - return pixelMetric( PM_DefaultFrameWidth ); + return pixelMetric( PM_DefaultFrameWidth, QStyleControlElementData(), CEF_None ); } void tabbarMetrics( const QWidget* t, int& hf, int& vf, int& ov ) const { - hf = pixelMetric( PM_TabBarTabHSpace, t ); - vf = pixelMetric( PM_TabBarTabVSpace, t ); - ov = pixelMetric( PM_TabBarBaseOverlap, t ); + hf = pixelMetric( PM_TabBarTabHSpace, QStyleControlElementData(), CEF_None, t ); + vf = pixelMetric( PM_TabBarTabVSpace, QStyleControlElementData(), CEF_None, t ); + ov = pixelMetric( PM_TabBarBaseOverlap, QStyleControlElementData(), CEF_None, t ); } QSize scrollBarExtent() const { - return QSize(pixelMetric(PM_ScrollBarExtent), - pixelMetric(PM_ScrollBarExtent)); + return QSize(pixelMetric(PM_ScrollBarExtent, QStyleControlElementData(), CEF_None), + pixelMetric(PM_ScrollBarExtent, QStyleControlElementData(), CEF_None)); } #endif +public: + virtual bool eventFilter( QObject *, QEvent * ); + bool acceleratorsShown() const; + +protected: + void acceleratorKeypressEventMonitor( QObject *, QEvent * ); private: QStylePrivate * d; @@ -752,7 +1109,22 @@ private: QStyle( const QStyle & ); QStyle& operator=( const QStyle & ); #endif + + EventHandlerInstallationHook m_eventHandlerInstallationHook; + EventHandlerRemovalHook m_eventHandlerRemovalHook; + WidgetActionRequestHook m_widgetActionRequestHook; + ObjectEventSourceToHandlerMap m_objectEventSourceToHandlerMap; + ObjectEventSourceDataToHandlerMap m_objectEventSourceDataToHandlerMap; + ObjectEventSourceFlagsToHandlerMap m_objectEventSourceFlagsToHandlerMap; + bool conditionalAcceleratorsEnabled; }; +inline QStyle::ControlElementFlags operator|(const QStyle::ControlElementFlags a, const QStyle::ControlElementFlags b) { return static_cast<QStyle::ControlElementFlags>(static_cast<int>(a) | static_cast<int>(b)); } +// inline QStyle::ControlElementFlags operator|=(QStyle::ControlElementFlags &a, const QStyle::ControlElementFlags b) { a = static_cast<QStyle::ControlElementFlags>(static_cast<int>(a) | static_cast<int>(b)); return a; } + +Q_EXPORT QStyleControlElementData populateControlElementDataFromWidget(const QWidget* widget, const QStyleOption& opt, bool populateReliantFields=true); +Q_EXPORT QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* object, QStringList objectTypeList, const QStyleOption& opt, bool populateReliantFields=true); +Q_EXPORT QStringList getObjectTypeListForObject(const QObject* object); + #endif // QT_NO_STYLE #endif // QSTYLE_H diff --git a/src/kernel/qwidget.h b/src/kernel/qwidget.h index d20fe4d..9df9710 100644 --- a/src/kernel/qwidget.h +++ b/src/kernel/qwidget.h @@ -456,6 +456,9 @@ public: WState testWState( WState s ) const; WFlags testWFlags( WFlags f ) const; NFlags testNFlags( NFlags f ) const; + uint getWState() const; + WFlags getWFlags() const; + NFlags getNFlags() const; static QWidget * find( WId ); static QWidgetMapper *wmapper(); @@ -573,13 +576,10 @@ protected: bool destroyOldWindow = TRUE ); virtual void destroy( bool destroyWindow = TRUE, bool destroySubWindows = TRUE ); - uint getWState() const; virtual void setWState( uint ); void clearWState( uint n ); - WFlags getWFlags() const; virtual void setWFlags( WFlags ); void clearWFlags( WFlags n ); - NFlags getNFlags() const; virtual void setNFlags( NFlags ); void clearNFlags( NFlags n ); |