diff options
Diffstat (limited to 'src/kernel/qstyle.cpp')
-rw-r--r-- | src/kernel/qstyle.cpp | 143 |
1 files changed, 111 insertions, 32 deletions
diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index 8c150d5..f8c0fd9 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -802,11 +802,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 +935,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 +1094,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 +1167,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 +1299,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 +1312,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 +1322,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 +1397,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 +1433,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 +1450,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 +1565,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. - 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: + \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 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 +1627,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 +1817,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 +1864,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 +1878,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 +1904,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()) + |