1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtWidgets module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QSTYLEOPTION_H
41#define QSTYLEOPTION_H
42
43#include <QtWidgets/qtwidgetsglobal.h>
44#include <QtCore/qlocale.h>
45#include <QtCore/qvariant.h>
46#if QT_CONFIG(spinbox)
47#include <QtWidgets/qabstractspinbox.h>
48#endif
49#include <QtGui/qicon.h>
50#include <QtGui/qmatrix.h>
51#if QT_CONFIG(slider)
52#include <QtWidgets/qslider.h>
53#endif
54#include <QtWidgets/qstyle.h>
55#if QT_CONFIG(tabbar)
56#include <QtWidgets/qtabbar.h>
57#endif
58#if QT_CONFIG(tabwidget)
59#include <QtWidgets/qtabwidget.h>
60#endif
61#if QT_CONFIG(rubberband)
62#include <QtWidgets/qrubberband.h>
63#endif
64#include <QtWidgets/qframe.h>
65#if QT_CONFIG(itemviews)
66# include <QtCore/qabstractitemmodel.h>
67#endif
68
69QT_BEGIN_NAMESPACE
70
71
72class QDebug;
73
74class Q_WIDGETS_EXPORT QStyleOption
75{
76public:
77 enum OptionType {
78 SO_Default, SO_FocusRect, SO_Button, SO_Tab, SO_MenuItem,
79 SO_Frame, SO_ProgressBar, SO_ToolBox, SO_Header,
80 SO_DockWidget, SO_ViewItem, SO_TabWidgetFrame,
81 SO_TabBarBase, SO_RubberBand, SO_ToolBar, SO_GraphicsItem,
82
83 SO_Complex = 0xf0000, SO_Slider, SO_SpinBox, SO_ToolButton, SO_ComboBox,
84 SO_TitleBar, SO_GroupBox, SO_SizeGrip,
85
86 SO_CustomBase = 0xf00,
87 SO_ComplexCustomBase = 0xf000000
88 };
89
90 enum StyleOptionType { Type = SO_Default };
91 enum StyleOptionVersion { Version = 1 };
92
93 int version;
94 int type;
95 QStyle::State state;
96 Qt::LayoutDirection direction;
97 QRect rect;
98 QFontMetrics fontMetrics;
99 QPalette palette;
100 QObject *styleObject;
101
102 QStyleOption(int version = QStyleOption::Version, int type = SO_Default);
103 QStyleOption(const QStyleOption &other);
104 ~QStyleOption();
105
106 void init(const QWidget *w);
107 inline void initFrom(const QWidget *w) { init(w); }
108 QStyleOption &operator=(const QStyleOption &other);
109};
110
111class Q_WIDGETS_EXPORT QStyleOptionFocusRect : public QStyleOption
112{
113public:
114 enum StyleOptionType { Type = SO_FocusRect };
115 enum StyleOptionVersion { Version = 1 };
116
117 QColor backgroundColor;
118
119 QStyleOptionFocusRect();
120 QStyleOptionFocusRect(const QStyleOptionFocusRect &other) : QStyleOption(Version, Type) { *this = other; }
121 QStyleOptionFocusRect &operator=(const QStyleOptionFocusRect &) = default;
122
123protected:
124 QStyleOptionFocusRect(int version);
125};
126
127class Q_WIDGETS_EXPORT QStyleOptionFrame : public QStyleOption
128{
129public:
130 enum StyleOptionType { Type = SO_Frame };
131 enum StyleOptionVersion { Version = 3 };
132
133 int lineWidth;
134 int midLineWidth;
135 enum FrameFeature {
136 None = 0x00,
137 Flat = 0x01,
138 Rounded = 0x02
139 };
140 Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)
141 FrameFeatures features;
142 QFrame::Shape frameShape;
143
144 QStyleOptionFrame();
145 QStyleOptionFrame(const QStyleOptionFrame &other) : QStyleOption(Version, Type) { *this = other; }
146 QStyleOptionFrame &operator=(const QStyleOptionFrame &) = default;
147
148protected:
149 QStyleOptionFrame(int version);
150};
151
152Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionFrame::FrameFeatures)
153
154typedef Q_DECL_DEPRECATED QStyleOptionFrame QStyleOptionFrameV2;
155typedef Q_DECL_DEPRECATED QStyleOptionFrame QStyleOptionFrameV3;
156
157#if QT_CONFIG(tabwidget)
158class Q_WIDGETS_EXPORT QStyleOptionTabWidgetFrame : public QStyleOption
159{
160public:
161 enum StyleOptionType { Type = SO_TabWidgetFrame };
162 enum StyleOptionVersion { Version = 2 };
163
164 int lineWidth;
165 int midLineWidth;
166 QTabBar::Shape shape;
167 QSize tabBarSize;
168 QSize rightCornerWidgetSize;
169 QSize leftCornerWidgetSize;
170 QRect tabBarRect;
171 QRect selectedTabRect;
172
173 QStyleOptionTabWidgetFrame();
174 inline QStyleOptionTabWidgetFrame(const QStyleOptionTabWidgetFrame &other)
175 : QStyleOption(Version, Type) { *this = other; }
176 QStyleOptionTabWidgetFrame &operator=(const QStyleOptionTabWidgetFrame &) = default;
177
178protected:
179 QStyleOptionTabWidgetFrame(int version);
180};
181
182typedef Q_DECL_DEPRECATED QStyleOptionTabWidgetFrame QStyleOptionTabWidgetFrameV2;
183#endif // QT_CONFIG(tabwidget)
184
185
186#if QT_CONFIG(tabbar)
187class Q_WIDGETS_EXPORT QStyleOptionTabBarBase : public QStyleOption
188{
189public:
190 enum StyleOptionType { Type = SO_TabBarBase };
191 enum StyleOptionVersion { Version = 2 };
192
193 QTabBar::Shape shape;
194 QRect tabBarRect;
195 QRect selectedTabRect;
196 bool documentMode;
197
198 QStyleOptionTabBarBase();
199 QStyleOptionTabBarBase(const QStyleOptionTabBarBase &other) : QStyleOption(Version, Type) { *this = other; }
200 QStyleOptionTabBarBase &operator=(const QStyleOptionTabBarBase &) = default;
201
202protected:
203 QStyleOptionTabBarBase(int version);
204};
205
206typedef Q_DECL_DEPRECATED QStyleOptionTabBarBase QStyleOptionTabBarBaseV2;
207#endif // QT_CONFIG(tabbar)
208
209class Q_WIDGETS_EXPORT QStyleOptionHeader : public QStyleOption
210{
211public:
212 enum StyleOptionType { Type = SO_Header };
213 enum StyleOptionVersion { Version = 1 };
214
215 enum SectionPosition { Beginning, Middle, End, OnlyOneSection };
216 enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected,
217 NextAndPreviousAreSelected };
218 enum SortIndicator { None, SortUp, SortDown };
219
220 int section;
221 QString text;
222 Qt::Alignment textAlignment;
223 QIcon icon;
224 Qt::Alignment iconAlignment;
225 SectionPosition position;
226 SelectedPosition selectedPosition;
227 SortIndicator sortIndicator;
228 Qt::Orientation orientation;
229
230 QStyleOptionHeader();
231 QStyleOptionHeader(const QStyleOptionHeader &other) : QStyleOption(Version, Type) { *this = other; }
232 QStyleOptionHeader &operator=(const QStyleOptionHeader &) = default;
233
234protected:
235 QStyleOptionHeader(int version);
236};
237
238class Q_WIDGETS_EXPORT QStyleOptionButton : public QStyleOption
239{
240public:
241 enum StyleOptionType { Type = SO_Button };
242 enum StyleOptionVersion { Version = 1 };
243
244 enum ButtonFeature { None = 0x00, Flat = 0x01, HasMenu = 0x02, DefaultButton = 0x04,
245 AutoDefaultButton = 0x08, CommandLinkButton = 0x10 };
246 Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature)
247
248 ButtonFeatures features;
249 QString text;
250 QIcon icon;
251 QSize iconSize;
252
253 QStyleOptionButton();
254 QStyleOptionButton(const QStyleOptionButton &other) : QStyleOption(Version, Type) { *this = other; }
255 QStyleOptionButton &operator=(const QStyleOptionButton &) = default;
256
257protected:
258 QStyleOptionButton(int version);
259};
260
261Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionButton::ButtonFeatures)
262
263#if QT_CONFIG(tabbar)
264class Q_WIDGETS_EXPORT QStyleOptionTab : public QStyleOption
265{
266public:
267 enum StyleOptionType { Type = SO_Tab };
268 enum StyleOptionVersion { Version = 3 };
269
270 enum TabPosition { Beginning, Middle, End, OnlyOneTab };
271 enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected };
272 enum CornerWidget { NoCornerWidgets = 0x00, LeftCornerWidget = 0x01,
273 RightCornerWidget = 0x02 };
274 enum TabFeature { None = 0x00, HasFrame = 0x01 };
275 Q_DECLARE_FLAGS(CornerWidgets, CornerWidget)
276 Q_DECLARE_FLAGS(TabFeatures, TabFeature)
277
278 QTabBar::Shape shape;
279 QString text;
280 QIcon icon;
281 int row;
282 TabPosition position;
283 SelectedPosition selectedPosition;
284 CornerWidgets cornerWidgets;
285 QSize iconSize;
286 bool documentMode;
287 QSize leftButtonSize;
288 QSize rightButtonSize;
289 TabFeatures features;
290
291 QStyleOptionTab();
292 QStyleOptionTab(const QStyleOptionTab &other) : QStyleOption(Version, Type) { *this = other; }
293 QStyleOptionTab &operator=(const QStyleOptionTab &) = default;
294
295protected:
296 QStyleOptionTab(int version);
297};
298
299class Q_WIDGETS_EXPORT QStyleOptionTabV4 : public QStyleOptionTab
300{
301public:
302 enum StyleOptionVersion { Version = 4 };
303 QStyleOptionTabV4();
304 int tabIndex = -1;
305};
306
307Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionTab::CornerWidgets)
308
309typedef Q_DECL_DEPRECATED QStyleOptionTab QStyleOptionTabV2;
310typedef Q_DECL_DEPRECATED QStyleOptionTab QStyleOptionTabV3;
311#endif // QT_CONFIG(tabbar)
312
313
314#if QT_CONFIG(toolbar)
315
316class Q_WIDGETS_EXPORT QStyleOptionToolBar : public QStyleOption
317{
318public:
319 enum StyleOptionType { Type = SO_ToolBar };
320 enum StyleOptionVersion { Version = 1 };
321 enum ToolBarPosition { Beginning, Middle, End, OnlyOne };
322 enum ToolBarFeature { None = 0x0, Movable = 0x1 };
323 Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)
324 ToolBarPosition positionOfLine; // The toolbar line position
325 ToolBarPosition positionWithinLine; // The position within a toolbar
326 Qt::ToolBarArea toolBarArea; // The toolbar docking area
327 ToolBarFeatures features;
328 int lineWidth;
329 int midLineWidth;
330 QStyleOptionToolBar();
331 QStyleOptionToolBar(const QStyleOptionToolBar &other) : QStyleOption(Version, Type) { *this = other; }
332 QStyleOptionToolBar &operator=(const QStyleOptionToolBar &) = default;
333
334protected:
335 QStyleOptionToolBar(int version);
336};
337
338Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolBar::ToolBarFeatures)
339
340#endif // QT_CONFIG(toolbar)
341
342class Q_WIDGETS_EXPORT QStyleOptionProgressBar : public QStyleOption
343{
344public:
345 enum StyleOptionType { Type = SO_ProgressBar };
346 enum StyleOptionVersion { Version = 2 };
347
348 int minimum;
349 int maximum;
350 int progress;
351 QString text;
352 Qt::Alignment textAlignment;
353 bool textVisible;
354 Qt::Orientation orientation; // ### Qt 6: remove
355 bool invertedAppearance;
356 bool bottomToTop;
357
358 QStyleOptionProgressBar();
359 QStyleOptionProgressBar(const QStyleOptionProgressBar &other) : QStyleOption(Version, Type) { *this = other; }
360 QStyleOptionProgressBar &operator=(const QStyleOptionProgressBar &) = default;
361
362protected:
363 QStyleOptionProgressBar(int version);
364};
365
366typedef Q_DECL_DEPRECATED QStyleOptionProgressBar QStyleOptionProgressBarV2;
367
368class Q_WIDGETS_EXPORT QStyleOptionMenuItem : public QStyleOption
369{
370public:
371 enum StyleOptionType { Type = SO_MenuItem };
372 enum StyleOptionVersion { Version = 1 };
373
374 enum MenuItemType { Normal, DefaultItem, Separator, SubMenu, Scroller, TearOff, Margin,
375 EmptyArea };
376 enum CheckType { NotCheckable, Exclusive, NonExclusive };
377
378 MenuItemType menuItemType;
379 CheckType checkType;
380 bool checked;
381 bool menuHasCheckableItems;
382 QRect menuRect;
383 QString text;
384 QIcon icon;
385 int maxIconWidth;
386 int tabWidth; // ### Qt 6: rename to reservedShortcutWidth
387 QFont font;
388
389 QStyleOptionMenuItem();
390 QStyleOptionMenuItem(const QStyleOptionMenuItem &other) : QStyleOption(Version, Type) { *this = other; }
391 QStyleOptionMenuItem &operator=(const QStyleOptionMenuItem &) = default;
392
393protected:
394 QStyleOptionMenuItem(int version);
395};
396
397class Q_WIDGETS_EXPORT QStyleOptionDockWidget : public QStyleOption
398{
399public:
400 enum StyleOptionType { Type = SO_DockWidget };
401 enum StyleOptionVersion { Version = 2 };
402
403 QString title;
404 bool closable;
405 bool movable;
406 bool floatable;
407 bool verticalTitleBar;
408
409 QStyleOptionDockWidget();
410 QStyleOptionDockWidget(const QStyleOptionDockWidget &other) : QStyleOption(Version, Type) { *this = other; }
411 QStyleOptionDockWidget &operator=(const QStyleOptionDockWidget &) = default;
412
413protected:
414 QStyleOptionDockWidget(int version);
415};
416
417typedef Q_DECL_DEPRECATED QStyleOptionDockWidget QStyleOptionDockWidgetV2;
418
419#if QT_CONFIG(itemviews)
420
421class Q_WIDGETS_EXPORT QStyleOptionViewItem : public QStyleOption
422{
423public:
424 enum StyleOptionType { Type = SO_ViewItem };
425 enum StyleOptionVersion { Version = 4 };
426
427 enum Position { Left, Right, Top, Bottom };
428
429 Qt::Alignment displayAlignment;
430 Qt::Alignment decorationAlignment;
431 Qt::TextElideMode textElideMode;
432 Position decorationPosition;
433 QSize decorationSize;
434 QFont font;
435 bool showDecorationSelected;
436
437 enum ViewItemFeature {
438 None = 0x00,
439 WrapText = 0x01,
440 Alternate = 0x02,
441 HasCheckIndicator = 0x04,
442 HasDisplay = 0x08,
443 HasDecoration = 0x10
444 };
445 Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)
446
447 ViewItemFeatures features;
448
449 QLocale locale;
450 const QWidget *widget;
451
452 enum ViewItemPosition { Invalid, Beginning, Middle, End, OnlyOne };
453
454 QModelIndex index;
455 Qt::CheckState checkState;
456 QIcon icon;
457 QString text;
458 ViewItemPosition viewItemPosition;
459 QBrush backgroundBrush;
460
461 QStyleOptionViewItem();
462 QStyleOptionViewItem(const QStyleOptionViewItem &other) : QStyleOption(Version, Type) { *this = other; }
463 QStyleOptionViewItem &operator=(const QStyleOptionViewItem &) = default;
464
465protected:
466 QStyleOptionViewItem(int version);
467};
468
469Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionViewItem::ViewItemFeatures)
470
471typedef Q_DECL_DEPRECATED QStyleOptionViewItem QStyleOptionViewItemV2;
472typedef Q_DECL_DEPRECATED QStyleOptionViewItem QStyleOptionViewItemV3;
473typedef Q_DECL_DEPRECATED QStyleOptionViewItem QStyleOptionViewItemV4;
474
475#endif // QT_CONFIG(itemviews)
476
477class Q_WIDGETS_EXPORT QStyleOptionToolBox : public QStyleOption
478{
479public:
480 enum StyleOptionType { Type = SO_ToolBox };
481 enum StyleOptionVersion { Version = 2 };
482
483 QString text;
484 QIcon icon;
485
486 enum TabPosition { Beginning, Middle, End, OnlyOneTab };
487 enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected };
488
489 TabPosition position;
490 SelectedPosition selectedPosition;
491
492 QStyleOptionToolBox();
493 QStyleOptionToolBox(const QStyleOptionToolBox &other) : QStyleOption(Version, Type) { *this = other; }
494 QStyleOptionToolBox &operator=(const QStyleOptionToolBox &) = default;
495
496protected:
497 QStyleOptionToolBox(int version);
498};
499
500typedef Q_DECL_DEPRECATED QStyleOptionToolBox QStyleOptionToolBoxV2;
501
502#if QT_CONFIG(rubberband)
503class Q_WIDGETS_EXPORT QStyleOptionRubberBand : public QStyleOption
504{
505public:
506 enum StyleOptionType { Type = SO_RubberBand };
507 enum StyleOptionVersion { Version = 1 };
508
509 QRubberBand::Shape shape;
510 bool opaque;
511
512 QStyleOptionRubberBand();
513 QStyleOptionRubberBand(const QStyleOptionRubberBand &other) : QStyleOption(Version, Type) { *this = other; }
514 QStyleOptionRubberBand &operator=(const QStyleOptionRubberBand &) = default;
515
516protected:
517 QStyleOptionRubberBand(int version);
518};
519#endif // QT_CONFIG(rubberband)
520
521// -------------------------- Complex style options -------------------------------
522class Q_WIDGETS_EXPORT QStyleOptionComplex : public QStyleOption
523{
524public:
525 enum StyleOptionType { Type = SO_Complex };
526 enum StyleOptionVersion { Version = 1 };
527
528 QStyle::SubControls subControls;
529 QStyle::SubControls activeSubControls;
530
531 QStyleOptionComplex(int version = QStyleOptionComplex::Version, int type = SO_Complex);
532 QStyleOptionComplex(const QStyleOptionComplex &other) : QStyleOption(Version, Type) { *this = other; }
533 QStyleOptionComplex &operator=(const QStyleOptionComplex &) = default;
534};
535
536#if QT_CONFIG(slider)
537class Q_WIDGETS_EXPORT QStyleOptionSlider : public QStyleOptionComplex
538{
539public:
540 enum StyleOptionType { Type = SO_Slider };
541 enum StyleOptionVersion { Version = 1 };
542
543 Qt::Orientation orientation;
544 int minimum;
545 int maximum;
546 QSlider::TickPosition tickPosition;
547 int tickInterval;
548 bool upsideDown;
549 int sliderPosition;
550 int sliderValue;
551 int singleStep;
552 int pageStep;
553 qreal notchTarget;
554 bool dialWrapping;
555
556 QStyleOptionSlider();
557 QStyleOptionSlider(const QStyleOptionSlider &other) : QStyleOptionComplex(Version, Type) { *this = other; }
558 QStyleOptionSlider &operator=(const QStyleOptionSlider &) = default;
559
560protected:
561 QStyleOptionSlider(int version);
562};
563#endif // QT_CONFIG(slider)
564
565#if QT_CONFIG(spinbox)
566class Q_WIDGETS_EXPORT QStyleOptionSpinBox : public QStyleOptionComplex
567{
568public:
569 enum StyleOptionType { Type = SO_SpinBox };
570 enum StyleOptionVersion { Version = 1 };
571
572 QAbstractSpinBox::ButtonSymbols buttonSymbols;
573 QAbstractSpinBox::StepEnabled stepEnabled;
574 bool frame;
575
576 QStyleOptionSpinBox();
577 QStyleOptionSpinBox(const QStyleOptionSpinBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
578 QStyleOptionSpinBox &operator=(const QStyleOptionSpinBox &) = default;
579
580protected:
581 QStyleOptionSpinBox(int version);
582};
583#endif // QT_CONFIG(spinbox)
584
585class Q_WIDGETS_EXPORT QStyleOptionToolButton : public QStyleOptionComplex
586{
587public:
588 enum StyleOptionType { Type = SO_ToolButton };
589 enum StyleOptionVersion { Version = 1 };
590
591 enum ToolButtonFeature { None = 0x00, Arrow = 0x01, Menu = 0x04, MenuButtonPopup = Menu, PopupDelay = 0x08,
592 HasMenu = 0x10 };
593 Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)
594
595 ToolButtonFeatures features;
596 QIcon icon;
597 QSize iconSize;
598 QString text;
599 Qt::ArrowType arrowType;
600 Qt::ToolButtonStyle toolButtonStyle;
601 QPoint pos;
602 QFont font;
603
604 QStyleOptionToolButton();
605 QStyleOptionToolButton(const QStyleOptionToolButton &other) : QStyleOptionComplex(Version, Type) { *this = other; }
606 QStyleOptionToolButton &operator=(const QStyleOptionToolButton &) = default;
607
608protected:
609 QStyleOptionToolButton(int version);
610};
611
612Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolButton::ToolButtonFeatures)
613
614class Q_WIDGETS_EXPORT QStyleOptionComboBox : public QStyleOptionComplex
615{
616public:
617 enum StyleOptionType { Type = SO_ComboBox };
618 enum StyleOptionVersion { Version = 1 };
619
620 bool editable;
621 QRect popupRect;
622 bool frame;
623 QString currentText;
624 QIcon currentIcon;
625 QSize iconSize;
626
627 QStyleOptionComboBox();
628 QStyleOptionComboBox(const QStyleOptionComboBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
629 QStyleOptionComboBox &operator=(const QStyleOptionComboBox &) = default;
630
631protected:
632 QStyleOptionComboBox(int version);
633};
634
635class Q_WIDGETS_EXPORT QStyleOptionTitleBar : public QStyleOptionComplex
636{
637public:
638 enum StyleOptionType { Type = SO_TitleBar };
639 enum StyleOptionVersion { Version = 1 };
640
641 QString text;
642 QIcon icon;
643 int titleBarState;
644 Qt::WindowFlags titleBarFlags;
645
646 QStyleOptionTitleBar();
647 QStyleOptionTitleBar(const QStyleOptionTitleBar &other) : QStyleOptionComplex(Version, Type) { *this = other; }
648 QStyleOptionTitleBar &operator=(const QStyleOptionTitleBar &) = default;
649
650protected:
651 QStyleOptionTitleBar(int version);
652};
653
654class Q_WIDGETS_EXPORT QStyleOptionGroupBox : public QStyleOptionComplex
655{
656public:
657 enum StyleOptionType { Type = SO_GroupBox };
658 enum StyleOptionVersion { Version = 1 };
659
660 QStyleOptionFrame::FrameFeatures features;
661 QString text;
662 Qt::Alignment textAlignment;
663 QColor textColor;
664 int lineWidth;
665 int midLineWidth;
666
667 QStyleOptionGroupBox();
668 QStyleOptionGroupBox(const QStyleOptionGroupBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
669 QStyleOptionGroupBox &operator=(const QStyleOptionGroupBox &) = default;
670protected:
671 QStyleOptionGroupBox(int version);
672};
673
674class Q_WIDGETS_EXPORT QStyleOptionSizeGrip : public QStyleOptionComplex
675{
676public:
677 enum StyleOptionType { Type = SO_SizeGrip };
678 enum StyleOptionVersion { Version = 1 };
679
680 Qt::Corner corner;
681
682 QStyleOptionSizeGrip();
683 QStyleOptionSizeGrip(const QStyleOptionSizeGrip &other) : QStyleOptionComplex(Version, Type) { *this = other; }
684 QStyleOptionSizeGrip &operator=(const QStyleOptionSizeGrip &) = default;
685protected:
686 QStyleOptionSizeGrip(int version);
687};
688
689class Q_WIDGETS_EXPORT QStyleOptionGraphicsItem : public QStyleOption
690{
691public:
692 enum StyleOptionType { Type = SO_GraphicsItem };
693 enum StyleOptionVersion { Version = 1 };
694
695 QRectF exposedRect;
696 QMatrix matrix;
697 qreal levelOfDetail;
698
699 QStyleOptionGraphicsItem();
700 QStyleOptionGraphicsItem(const QStyleOptionGraphicsItem &other) : QStyleOption(Version, Type) { *this = other; }
701 QStyleOptionGraphicsItem &operator=(const QStyleOptionGraphicsItem &) = default;
702 static qreal levelOfDetailFromTransform(const QTransform &worldTransform);
703protected:
704 QStyleOptionGraphicsItem(int version);
705};
706
707template <typename T>
708T qstyleoption_cast(const QStyleOption *opt)
709{
710 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
711 if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type
712 || int(Opt::Type) == QStyleOption::SO_Default
713 || (int(Opt::Type) == QStyleOption::SO_Complex
714 && opt->type > QStyleOption::SO_Complex)))
715 return static_cast<T>(opt);
716 return nullptr;
717}
718
719template <typename T>
720T qstyleoption_cast(QStyleOption *opt)
721{
722 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
723 if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type
724 || int(Opt::Type) == QStyleOption::SO_Default
725 || (int(Opt::Type) == QStyleOption::SO_Complex
726 && opt->type > QStyleOption::SO_Complex)))
727 return static_cast<T>(opt);
728 return nullptr;
729}
730
731// -------------------------- QStyleHintReturn -------------------------------
732class Q_WIDGETS_EXPORT QStyleHintReturn {
733public:
734 enum HintReturnType {
735 SH_Default=0xf000, SH_Mask, SH_Variant
736 };
737
738 enum StyleOptionType { Type = SH_Default };
739 enum StyleOptionVersion { Version = 1 };
740
741 QStyleHintReturn(int version = QStyleOption::Version, int type = SH_Default);
742 ~QStyleHintReturn();
743
744 int version;
745 int type;
746};
747
748class Q_WIDGETS_EXPORT QStyleHintReturnMask : public QStyleHintReturn {
749public:
750 enum StyleOptionType { Type = SH_Mask };
751 enum StyleOptionVersion { Version = 1 };
752
753 QStyleHintReturnMask();
754 ~QStyleHintReturnMask();
755
756 QRegion region;
757};
758
759class Q_WIDGETS_EXPORT QStyleHintReturnVariant : public QStyleHintReturn {
760public:
761 enum StyleOptionType { Type = SH_Variant };
762 enum StyleOptionVersion { Version = 1 };
763
764 QStyleHintReturnVariant();
765 ~QStyleHintReturnVariant();
766
767 QVariant variant;
768};
769
770template <typename T>
771T qstyleoption_cast(const QStyleHintReturn *hint)
772{
773 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
774 if (hint && hint->version <= Opt::Version &&
775 (hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default))
776 return static_cast<T>(hint);
777 return nullptr;
778}
779
780template <typename T>
781T qstyleoption_cast(QStyleHintReturn *hint)
782{
783 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
784 if (hint && hint->version <= Opt::Version &&
785 (hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default))
786 return static_cast<T>(hint);
787 return nullptr;
788}
789
790#if !defined(QT_NO_DEBUG_STREAM)
791Q_WIDGETS_EXPORT QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType);
792Q_WIDGETS_EXPORT QDebug operator<<(QDebug debug, const QStyleOption &option);
793#endif
794
795QT_END_NAMESPACE
796
797#endif // QSTYLEOPTION_H
798

source code of qtbase/src/widgets/styles/qstyleoption.h