Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtWidgets/qstyleoption.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2020 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QSTYLEOPTION_H
0005 #define QSTYLEOPTION_H
0006 
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtCore/qlocale.h>
0009 #include <QtCore/qvariant.h>
0010 #if QT_CONFIG(spinbox)
0011 #include <QtWidgets/qabstractspinbox.h>
0012 #endif
0013 #include <QtGui/qicon.h>
0014 #include <QtGui/qtransform.h>
0015 #if QT_CONFIG(slider)
0016 #include <QtWidgets/qslider.h>
0017 #endif
0018 #include <QtWidgets/qstyle.h>
0019 #if QT_CONFIG(tabbar)
0020 #include <QtWidgets/qtabbar.h>
0021 #endif
0022 #if QT_CONFIG(tabwidget)
0023 #include <QtWidgets/qtabwidget.h>
0024 #endif
0025 #if QT_CONFIG(rubberband)
0026 #include <QtWidgets/qrubberband.h>
0027 #endif
0028 #include <QtWidgets/qframe.h>
0029 #if QT_CONFIG(itemviews)
0030 #   include <QtCore/qabstractitemmodel.h>
0031 #endif
0032 
0033 QT_BEGIN_NAMESPACE
0034 
0035 
0036 class QDebug;
0037 
0038 class Q_WIDGETS_EXPORT QStyleOption
0039 {
0040 public:
0041     enum OptionType {
0042                       SO_Default, SO_FocusRect, SO_Button, SO_Tab, SO_MenuItem,
0043                       SO_Frame, SO_ProgressBar, SO_ToolBox, SO_Header,
0044                       SO_DockWidget, SO_ViewItem, SO_TabWidgetFrame,
0045                       SO_TabBarBase, SO_RubberBand, SO_ToolBar, SO_GraphicsItem,
0046 
0047                       SO_Complex = 0xf0000, SO_Slider, SO_SpinBox, SO_ToolButton, SO_ComboBox,
0048                       SO_TitleBar, SO_GroupBox, SO_SizeGrip,
0049 
0050                       SO_CustomBase = 0xf00,
0051                       SO_ComplexCustomBase = 0xf000000
0052                     };
0053 
0054     enum StyleOptionType { Type = SO_Default };
0055     enum StyleOptionVersion { Version = 1 };
0056 
0057     int version;
0058     int type;
0059     QStyle::State state;
0060     Qt::LayoutDirection direction;
0061     QRect rect;
0062     QFontMetrics fontMetrics;
0063     QPalette palette;
0064     QObject *styleObject;
0065 
0066     QStyleOption(int version = QStyleOption::Version, int type = SO_Default);
0067     QStyleOption(const QStyleOption &other);
0068     ~QStyleOption();
0069 
0070     void initFrom(const QWidget *w);
0071     QStyleOption &operator=(const QStyleOption &other);
0072 };
0073 
0074 class Q_WIDGETS_EXPORT QStyleOptionFocusRect : public QStyleOption
0075 {
0076 public:
0077     enum StyleOptionType { Type = SO_FocusRect };
0078     enum StyleOptionVersion { Version = 1 };
0079 
0080     QColor backgroundColor;
0081 
0082     QStyleOptionFocusRect();
0083     QStyleOptionFocusRect(const QStyleOptionFocusRect &other) : QStyleOption(Version, Type) { *this = other; }
0084     QStyleOptionFocusRect &operator=(const QStyleOptionFocusRect &) = default;
0085 
0086 protected:
0087     QStyleOptionFocusRect(int version);
0088 };
0089 
0090 class Q_WIDGETS_EXPORT QStyleOptionFrame : public QStyleOption
0091 {
0092 public:
0093     enum StyleOptionType { Type = SO_Frame };
0094     enum StyleOptionVersion { Version = 1 };
0095 
0096     int lineWidth;
0097     int midLineWidth;
0098     enum FrameFeature {
0099         None = 0x00,
0100         Flat = 0x01,
0101         Rounded = 0x02
0102     };
0103     Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)
0104     FrameFeatures features;
0105     QFrame::Shape frameShape;
0106 
0107     QStyleOptionFrame();
0108     QStyleOptionFrame(const QStyleOptionFrame &other) : QStyleOption(Version, Type) { *this = other; }
0109     QStyleOptionFrame &operator=(const QStyleOptionFrame &) = default;
0110 
0111 protected:
0112     QStyleOptionFrame(int version);
0113 };
0114 
0115 Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionFrame::FrameFeatures)
0116 
0117 #if QT_CONFIG(tabwidget)
0118 class Q_WIDGETS_EXPORT QStyleOptionTabWidgetFrame : public QStyleOption
0119 {
0120 public:
0121     enum StyleOptionType { Type = SO_TabWidgetFrame };
0122     enum StyleOptionVersion { Version = 1 };
0123 
0124     int lineWidth;
0125     int midLineWidth;
0126     QTabBar::Shape shape;
0127     QSize tabBarSize;
0128     QSize rightCornerWidgetSize;
0129     QSize leftCornerWidgetSize;
0130     QRect tabBarRect;
0131     QRect selectedTabRect;
0132 
0133     QStyleOptionTabWidgetFrame();
0134     inline QStyleOptionTabWidgetFrame(const QStyleOptionTabWidgetFrame &other)
0135         : QStyleOption(Version, Type) { *this = other; }
0136     QStyleOptionTabWidgetFrame &operator=(const QStyleOptionTabWidgetFrame &) = default;
0137 
0138 protected:
0139     QStyleOptionTabWidgetFrame(int version);
0140 };
0141 
0142 #endif // QT_CONFIG(tabwidget)
0143 
0144 
0145 #if QT_CONFIG(tabbar)
0146 class Q_WIDGETS_EXPORT QStyleOptionTabBarBase : public QStyleOption
0147 {
0148 public:
0149     enum StyleOptionType { Type = SO_TabBarBase };
0150     enum StyleOptionVersion { Version = 1 };
0151 
0152     QTabBar::Shape shape;
0153     QRect tabBarRect;
0154     QRect selectedTabRect;
0155     bool documentMode;
0156 
0157     QStyleOptionTabBarBase();
0158     QStyleOptionTabBarBase(const QStyleOptionTabBarBase &other) : QStyleOption(Version, Type) { *this = other; }
0159     QStyleOptionTabBarBase &operator=(const QStyleOptionTabBarBase &) = default;
0160 
0161 protected:
0162     QStyleOptionTabBarBase(int version);
0163 };
0164 
0165 #endif // QT_CONFIG(tabbar)
0166 
0167 class Q_WIDGETS_EXPORT QStyleOptionHeader : public QStyleOption
0168 {
0169 public:
0170     enum StyleOptionType { Type = SO_Header };
0171     enum StyleOptionVersion { Version = 1 };
0172 
0173     enum SectionPosition { Beginning, Middle, End, OnlyOneSection };
0174     enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected,
0175                             NextAndPreviousAreSelected };
0176     enum SortIndicator { None, SortUp, SortDown };
0177 
0178     int section;
0179     QString text;
0180     Qt::Alignment textAlignment;
0181     QIcon icon;
0182     Qt::Alignment iconAlignment;
0183     SectionPosition position;
0184     SelectedPosition selectedPosition;
0185     SortIndicator sortIndicator;
0186     Qt::Orientation orientation;
0187 
0188     QStyleOptionHeader();
0189     QStyleOptionHeader(const QStyleOptionHeader &other) : QStyleOption(Version, Type) { *this = other; }
0190     QStyleOptionHeader &operator=(const QStyleOptionHeader &) = default;
0191 
0192 protected:
0193     QStyleOptionHeader(int version);
0194 };
0195 
0196 // ### Qt7: merge with QStyleOptionHeader
0197 class Q_WIDGETS_EXPORT QStyleOptionHeaderV2 : public QStyleOptionHeader
0198 {
0199 public:
0200     enum StyleOptionType { Type = SO_Header };
0201     enum StyleOptionVersion { Version = 2 };
0202 
0203     QStyleOptionHeaderV2();
0204     QStyleOptionHeaderV2(const QStyleOptionHeaderV2 &other) : QStyleOptionHeader(Version) { *this = other; }
0205     QStyleOptionHeaderV2 &operator=(const QStyleOptionHeaderV2 &) = default;
0206 
0207     Qt::TextElideMode textElideMode:2;
0208     bool isSectionDragTarget:1;
0209     int unused:29;
0210 
0211 protected:
0212     QStyleOptionHeaderV2(int version);
0213 };
0214 
0215 class Q_WIDGETS_EXPORT QStyleOptionButton : public QStyleOption
0216 {
0217 public:
0218     enum StyleOptionType { Type = SO_Button };
0219     enum StyleOptionVersion { Version = 1 };
0220 
0221     enum ButtonFeature { None = 0x00, Flat = 0x01, HasMenu = 0x02, DefaultButton = 0x04,
0222                          AutoDefaultButton = 0x08, CommandLinkButton = 0x10  };
0223     Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature)
0224 
0225     ButtonFeatures features;
0226     QString text;
0227     QIcon icon;
0228     QSize iconSize;
0229 
0230     QStyleOptionButton();
0231     QStyleOptionButton(const QStyleOptionButton &other) : QStyleOption(Version, Type) { *this = other; }
0232     QStyleOptionButton &operator=(const QStyleOptionButton &) = default;
0233 
0234 protected:
0235     QStyleOptionButton(int version);
0236 };
0237 
0238 Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionButton::ButtonFeatures)
0239 
0240 #if QT_CONFIG(tabbar)
0241 class Q_WIDGETS_EXPORT QStyleOptionTab : public QStyleOption
0242 {
0243 public:
0244     enum StyleOptionType { Type = SO_Tab };
0245     enum StyleOptionVersion { Version = 1 };
0246 
0247     enum TabPosition { Beginning, Middle, End, OnlyOneTab, Moving };
0248     enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected };
0249     enum CornerWidget { NoCornerWidgets = 0x00, LeftCornerWidget = 0x01,
0250                         RightCornerWidget = 0x02 };
0251     enum TabFeature { None = 0x00, HasFrame = 0x01 };
0252     Q_DECLARE_FLAGS(CornerWidgets, CornerWidget)
0253     Q_DECLARE_FLAGS(TabFeatures, TabFeature)
0254 
0255     QTabBar::Shape shape;
0256     QString text;
0257     QIcon icon;
0258     int row;
0259     TabPosition position;
0260     SelectedPosition selectedPosition;
0261     CornerWidgets cornerWidgets;
0262     QSize iconSize;
0263     bool documentMode;
0264     QSize leftButtonSize;
0265     QSize rightButtonSize;
0266     TabFeatures features;
0267     int tabIndex = -1;
0268 
0269     QStyleOptionTab();
0270     QStyleOptionTab(const QStyleOptionTab &other) : QStyleOption(Version, Type) { *this = other; }
0271     QStyleOptionTab &operator=(const QStyleOptionTab &) = default;
0272 
0273 protected:
0274     QStyleOptionTab(int version);
0275 };
0276 
0277 Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionTab::CornerWidgets)
0278 
0279 #endif // QT_CONFIG(tabbar)
0280 
0281 
0282 #if QT_CONFIG(toolbar)
0283 
0284 class Q_WIDGETS_EXPORT QStyleOptionToolBar : public QStyleOption
0285 {
0286 public:
0287     enum StyleOptionType { Type = SO_ToolBar };
0288     enum StyleOptionVersion { Version = 1 };
0289     enum ToolBarPosition { Beginning, Middle, End, OnlyOne };
0290     enum ToolBarFeature { None = 0x0, Movable = 0x1 };
0291     Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)
0292     ToolBarPosition positionOfLine; // The toolbar line position
0293     ToolBarPosition positionWithinLine; // The position within a toolbar
0294     Qt::ToolBarArea toolBarArea; // The toolbar docking area
0295     ToolBarFeatures features;
0296     int lineWidth;
0297     int midLineWidth;
0298     QStyleOptionToolBar();
0299     QStyleOptionToolBar(const QStyleOptionToolBar &other) : QStyleOption(Version, Type) { *this = other; }
0300     QStyleOptionToolBar &operator=(const QStyleOptionToolBar &) = default;
0301 
0302 protected:
0303     QStyleOptionToolBar(int version);
0304 };
0305 
0306 Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolBar::ToolBarFeatures)
0307 
0308 #endif // QT_CONFIG(toolbar)
0309 
0310 class Q_WIDGETS_EXPORT QStyleOptionProgressBar : public QStyleOption
0311 {
0312 public:
0313     enum StyleOptionType { Type = SO_ProgressBar };
0314     enum StyleOptionVersion { Version = 1 };
0315 
0316     int minimum;
0317     int maximum;
0318     int progress;
0319     QString text;
0320     Qt::Alignment textAlignment;
0321     bool textVisible;
0322     bool invertedAppearance;
0323     bool bottomToTop;
0324 
0325     QStyleOptionProgressBar();
0326     QStyleOptionProgressBar(const QStyleOptionProgressBar &other) : QStyleOption(Version, Type) { *this = other; }
0327     QStyleOptionProgressBar &operator=(const QStyleOptionProgressBar &) = default;
0328 
0329 protected:
0330     QStyleOptionProgressBar(int version);
0331 };
0332 
0333 class Q_WIDGETS_EXPORT QStyleOptionMenuItem : public QStyleOption
0334 {
0335 public:
0336     enum StyleOptionType { Type = SO_MenuItem };
0337     enum StyleOptionVersion { Version = 1 };
0338 
0339     enum MenuItemType { Normal, DefaultItem, Separator, SubMenu, Scroller, TearOff, Margin,
0340                         EmptyArea };
0341     enum CheckType { NotCheckable, Exclusive, NonExclusive };
0342 
0343     MenuItemType menuItemType;
0344     CheckType checkType;
0345     bool checked;
0346     bool menuHasCheckableItems;
0347     QRect menuRect;
0348     QString text;
0349     QIcon icon;
0350     int maxIconWidth;
0351     int reservedShortcutWidth;
0352     QFont font;
0353 
0354     QStyleOptionMenuItem();
0355     QStyleOptionMenuItem(const QStyleOptionMenuItem &other) : QStyleOption(Version, Type) { *this = other; }
0356     QStyleOptionMenuItem &operator=(const QStyleOptionMenuItem &) = default;
0357 
0358 protected:
0359     QStyleOptionMenuItem(int version);
0360 };
0361 
0362 class Q_WIDGETS_EXPORT QStyleOptionDockWidget : public QStyleOption
0363 {
0364 public:
0365     enum StyleOptionType { Type = SO_DockWidget };
0366     enum StyleOptionVersion { Version = 1 };
0367 
0368     QString title;
0369     bool closable;
0370     bool movable;
0371     bool floatable;
0372     bool verticalTitleBar;
0373 
0374     QStyleOptionDockWidget();
0375     QStyleOptionDockWidget(const QStyleOptionDockWidget &other) : QStyleOption(Version, Type) { *this = other; }
0376     QStyleOptionDockWidget &operator=(const QStyleOptionDockWidget &) = default;
0377 
0378 protected:
0379     QStyleOptionDockWidget(int version);
0380 };
0381 
0382 #if QT_CONFIG(itemviews)
0383 
0384 class Q_WIDGETS_EXPORT QStyleOptionViewItem : public QStyleOption
0385 {
0386 public:
0387     enum StyleOptionType { Type = SO_ViewItem };
0388     enum StyleOptionVersion { Version = 1 };
0389 
0390     enum Position { Left, Right, Top, Bottom };
0391 
0392     Qt::Alignment displayAlignment;
0393     Qt::Alignment decorationAlignment;
0394     Qt::TextElideMode textElideMode;
0395     Position decorationPosition;
0396     QSize decorationSize;
0397     QFont font;
0398     bool showDecorationSelected;
0399 
0400     enum ViewItemFeature {
0401         None = 0x00,
0402         WrapText = 0x01,
0403         Alternate = 0x02,
0404         HasCheckIndicator = 0x04,
0405         HasDisplay = 0x08,
0406         HasDecoration = 0x10
0407     };
0408     Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)
0409 
0410     ViewItemFeatures features;
0411 
0412     QLocale locale;
0413     const QWidget *widget;
0414 
0415     enum ViewItemPosition { Invalid, Beginning, Middle, End, OnlyOne };
0416 
0417     QModelIndex index;
0418     Qt::CheckState checkState;
0419     QIcon icon;
0420     QString text;
0421     ViewItemPosition viewItemPosition;
0422     QBrush backgroundBrush;
0423 
0424     QStyleOptionViewItem();
0425     QStyleOptionViewItem(const QStyleOptionViewItem &other) : QStyleOption(Version, Type) { *this = other; }
0426     QStyleOptionViewItem &operator=(const QStyleOptionViewItem &) = default;
0427 
0428 protected:
0429     QStyleOptionViewItem(int version);
0430 };
0431 
0432 Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionViewItem::ViewItemFeatures)
0433 
0434 #endif // QT_CONFIG(itemviews)
0435 
0436 class Q_WIDGETS_EXPORT QStyleOptionToolBox : public QStyleOption
0437 {
0438 public:
0439     enum StyleOptionType { Type = SO_ToolBox };
0440     enum StyleOptionVersion { Version = 1 };
0441 
0442     QString text;
0443     QIcon icon;
0444 
0445     enum TabPosition { Beginning, Middle, End, OnlyOneTab };
0446     enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected };
0447 
0448     TabPosition position;
0449     SelectedPosition selectedPosition;
0450 
0451     QStyleOptionToolBox();
0452     QStyleOptionToolBox(const QStyleOptionToolBox &other) : QStyleOption(Version, Type) { *this = other; }
0453     QStyleOptionToolBox &operator=(const QStyleOptionToolBox &) = default;
0454 
0455 protected:
0456     QStyleOptionToolBox(int version);
0457 };
0458 
0459 #if QT_CONFIG(rubberband)
0460 class Q_WIDGETS_EXPORT QStyleOptionRubberBand : public QStyleOption
0461 {
0462 public:
0463     enum StyleOptionType { Type = SO_RubberBand };
0464     enum StyleOptionVersion { Version = 1 };
0465 
0466     QRubberBand::Shape shape;
0467     bool opaque;
0468 
0469     QStyleOptionRubberBand();
0470     QStyleOptionRubberBand(const QStyleOptionRubberBand &other) : QStyleOption(Version, Type) { *this = other; }
0471     QStyleOptionRubberBand &operator=(const QStyleOptionRubberBand &) = default;
0472 
0473 protected:
0474     QStyleOptionRubberBand(int version);
0475 };
0476 #endif // QT_CONFIG(rubberband)
0477 
0478 // -------------------------- Complex style options -------------------------------
0479 class Q_WIDGETS_EXPORT QStyleOptionComplex : public QStyleOption
0480 {
0481 public:
0482     enum StyleOptionType { Type = SO_Complex };
0483     enum StyleOptionVersion { Version = 1 };
0484 
0485     QStyle::SubControls subControls;
0486     QStyle::SubControls activeSubControls;
0487 
0488     QStyleOptionComplex(int version = QStyleOptionComplex::Version, int type = SO_Complex);
0489     QStyleOptionComplex(const QStyleOptionComplex &other) : QStyleOption(Version, Type) { *this = other; }
0490     QStyleOptionComplex &operator=(const QStyleOptionComplex &) = default;
0491 };
0492 
0493 #if QT_CONFIG(slider)
0494 class Q_WIDGETS_EXPORT QStyleOptionSlider : public QStyleOptionComplex
0495 {
0496 public:
0497     enum StyleOptionType { Type = SO_Slider };
0498     enum StyleOptionVersion { Version = 1 };
0499 
0500     Qt::Orientation orientation;
0501     int minimum;
0502     int maximum;
0503     QSlider::TickPosition tickPosition;
0504     int tickInterval;
0505     bool upsideDown;
0506     int sliderPosition;
0507     int sliderValue;
0508     int singleStep;
0509     int pageStep;
0510     qreal notchTarget;
0511     bool dialWrapping;
0512     Qt::KeyboardModifiers keyboardModifiers;
0513 
0514     QStyleOptionSlider();
0515     QStyleOptionSlider(const QStyleOptionSlider &other) : QStyleOptionComplex(Version, Type) { *this = other; }
0516     QStyleOptionSlider &operator=(const QStyleOptionSlider &) = default;
0517 
0518 protected:
0519     QStyleOptionSlider(int version);
0520 };
0521 #endif // QT_CONFIG(slider)
0522 
0523 #if QT_CONFIG(spinbox)
0524 class Q_WIDGETS_EXPORT QStyleOptionSpinBox : public QStyleOptionComplex
0525 {
0526 public:
0527     enum StyleOptionType { Type = SO_SpinBox };
0528     enum StyleOptionVersion { Version = 1 };
0529 
0530     QAbstractSpinBox::ButtonSymbols buttonSymbols;
0531     QAbstractSpinBox::StepEnabled stepEnabled;
0532     bool frame;
0533 
0534     QStyleOptionSpinBox();
0535     QStyleOptionSpinBox(const QStyleOptionSpinBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
0536     QStyleOptionSpinBox &operator=(const QStyleOptionSpinBox &) = default;
0537 
0538 protected:
0539     QStyleOptionSpinBox(int version);
0540 };
0541 #endif // QT_CONFIG(spinbox)
0542 
0543 class Q_WIDGETS_EXPORT QStyleOptionToolButton : public QStyleOptionComplex
0544 {
0545 public:
0546     enum StyleOptionType { Type = SO_ToolButton };
0547     enum StyleOptionVersion { Version = 1 };
0548 
0549     enum ToolButtonFeature { None = 0x00, Arrow = 0x01, Menu = 0x04, MenuButtonPopup = Menu, PopupDelay = 0x08,
0550                              HasMenu = 0x10 };
0551     Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)
0552 
0553     ToolButtonFeatures features;
0554     QIcon icon;
0555     QSize iconSize;
0556     QString text;
0557     Qt::ArrowType arrowType;
0558     Qt::ToolButtonStyle toolButtonStyle;
0559     QPoint pos;
0560     QFont font;
0561 
0562     QStyleOptionToolButton();
0563     QStyleOptionToolButton(const QStyleOptionToolButton &other) : QStyleOptionComplex(Version, Type) { *this = other; }
0564     QStyleOptionToolButton &operator=(const QStyleOptionToolButton &) = default;
0565 
0566 protected:
0567     QStyleOptionToolButton(int version);
0568 };
0569 
0570 Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolButton::ToolButtonFeatures)
0571 
0572 class Q_WIDGETS_EXPORT QStyleOptionComboBox : public QStyleOptionComplex
0573 {
0574 public:
0575     enum StyleOptionType { Type = SO_ComboBox };
0576     enum StyleOptionVersion { Version = 1 };
0577 
0578     bool editable;
0579     QRect popupRect;
0580     bool frame;
0581     QString currentText;
0582     QIcon currentIcon;
0583     QSize iconSize;
0584     Qt::Alignment textAlignment = Qt::AlignLeft | Qt::AlignVCenter;
0585 
0586     QStyleOptionComboBox();
0587     QStyleOptionComboBox(const QStyleOptionComboBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
0588     QStyleOptionComboBox &operator=(const QStyleOptionComboBox &) = default;
0589 
0590 protected:
0591     QStyleOptionComboBox(int version);
0592 };
0593 
0594 class Q_WIDGETS_EXPORT QStyleOptionTitleBar : public QStyleOptionComplex
0595 {
0596 public:
0597     enum StyleOptionType { Type = SO_TitleBar };
0598     enum StyleOptionVersion { Version = 1 };
0599 
0600     QString text;
0601     QIcon icon;
0602     int titleBarState;
0603     Qt::WindowFlags titleBarFlags;
0604 
0605     QStyleOptionTitleBar();
0606     QStyleOptionTitleBar(const QStyleOptionTitleBar &other) : QStyleOptionComplex(Version, Type) { *this = other; }
0607     QStyleOptionTitleBar &operator=(const QStyleOptionTitleBar &) = default;
0608 
0609 protected:
0610     QStyleOptionTitleBar(int version);
0611 };
0612 
0613 class Q_WIDGETS_EXPORT QStyleOptionGroupBox : public QStyleOptionComplex
0614 {
0615 public:
0616     enum StyleOptionType { Type = SO_GroupBox };
0617     enum StyleOptionVersion { Version = 1 };
0618 
0619     QStyleOptionFrame::FrameFeatures features;
0620     QString text;
0621     Qt::Alignment textAlignment;
0622     QColor textColor;
0623     int lineWidth;
0624     int midLineWidth;
0625 
0626     QStyleOptionGroupBox();
0627     QStyleOptionGroupBox(const QStyleOptionGroupBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
0628     QStyleOptionGroupBox &operator=(const QStyleOptionGroupBox &) = default;
0629 protected:
0630     QStyleOptionGroupBox(int version);
0631 };
0632 
0633 class Q_WIDGETS_EXPORT QStyleOptionSizeGrip : public QStyleOptionComplex
0634 {
0635 public:
0636     enum StyleOptionType { Type = SO_SizeGrip };
0637     enum StyleOptionVersion { Version = 1 };
0638 
0639     Qt::Corner corner;
0640 
0641     QStyleOptionSizeGrip();
0642     QStyleOptionSizeGrip(const QStyleOptionSizeGrip &other) : QStyleOptionComplex(Version, Type) { *this = other; }
0643     QStyleOptionSizeGrip &operator=(const QStyleOptionSizeGrip &) = default;
0644 protected:
0645     QStyleOptionSizeGrip(int version);
0646 };
0647 
0648 class Q_WIDGETS_EXPORT QStyleOptionGraphicsItem : public QStyleOption
0649 {
0650 public:
0651     enum StyleOptionType { Type = SO_GraphicsItem };
0652     enum StyleOptionVersion { Version = 1 };
0653 
0654     QRectF exposedRect;
0655 
0656     QStyleOptionGraphicsItem();
0657     QStyleOptionGraphicsItem(const QStyleOptionGraphicsItem &other) : QStyleOption(Version, Type) { *this = other; }
0658     QStyleOptionGraphicsItem &operator=(const QStyleOptionGraphicsItem &) = default;
0659     static qreal levelOfDetailFromTransform(const QTransform &worldTransform);
0660 protected:
0661     QStyleOptionGraphicsItem(int version);
0662 };
0663 
0664 template <typename T>
0665 T qstyleoption_cast(const QStyleOption *opt)
0666 {
0667     typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
0668     if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type
0669         || int(Opt::Type) == QStyleOption::SO_Default
0670         || (int(Opt::Type) == QStyleOption::SO_Complex
0671             && opt->type > QStyleOption::SO_Complex)))
0672         return static_cast<T>(opt);
0673     return nullptr;
0674 }
0675 
0676 template <typename T>
0677 T qstyleoption_cast(QStyleOption *opt)
0678 {
0679     typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
0680     if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type
0681         || int(Opt::Type) == QStyleOption::SO_Default
0682         || (int(Opt::Type) == QStyleOption::SO_Complex
0683             && opt->type > QStyleOption::SO_Complex)))
0684         return static_cast<T>(opt);
0685     return nullptr;
0686 }
0687 
0688 // -------------------------- QStyleHintReturn -------------------------------
0689 class Q_WIDGETS_EXPORT QStyleHintReturn {
0690 public:
0691     enum HintReturnType {
0692         SH_Default=0xf000, SH_Mask, SH_Variant
0693     };
0694 
0695     enum StyleOptionType { Type = SH_Default };
0696     enum StyleOptionVersion { Version = 1 };
0697 
0698     QStyleHintReturn(int version = QStyleOption::Version, int type = SH_Default);
0699     ~QStyleHintReturn();
0700 
0701     int version;
0702     int type;
0703 };
0704 
0705 class Q_WIDGETS_EXPORT QStyleHintReturnMask : public QStyleHintReturn {
0706 public:
0707     enum StyleOptionType { Type = SH_Mask };
0708     enum StyleOptionVersion { Version = 1 };
0709 
0710     QStyleHintReturnMask();
0711     ~QStyleHintReturnMask();
0712 
0713     QRegion region;
0714 };
0715 
0716 class Q_WIDGETS_EXPORT QStyleHintReturnVariant : public QStyleHintReturn {
0717 public:
0718     enum StyleOptionType { Type = SH_Variant };
0719     enum StyleOptionVersion { Version = 1 };
0720 
0721     QStyleHintReturnVariant();
0722     ~QStyleHintReturnVariant();
0723 
0724     QVariant variant;
0725 };
0726 
0727 template <typename T>
0728 T qstyleoption_cast(const QStyleHintReturn *hint)
0729 {
0730     typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
0731     if (hint && hint->version <= Opt::Version &&
0732         (hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default))
0733         return static_cast<T>(hint);
0734     return nullptr;
0735 }
0736 
0737 template <typename T>
0738 T qstyleoption_cast(QStyleHintReturn *hint)
0739 {
0740     typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
0741     if (hint && hint->version <= Opt::Version &&
0742         (hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default))
0743         return static_cast<T>(hint);
0744     return nullptr;
0745 }
0746 
0747 #if !defined(QT_NO_DEBUG_STREAM)
0748 Q_WIDGETS_EXPORT QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType);
0749 Q_WIDGETS_EXPORT QDebug operator<<(QDebug debug, const QStyleOption &option);
0750 #endif
0751 
0752 QT_END_NAMESPACE
0753 
0754 #endif // QSTYLEOPTION_H