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 &other) = 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 &other) = 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 &other) = 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 &other) = 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 &other) = 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 &other) = 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 &other) = default;
294
295protected:
296 QStyleOptionTab(int version);
297};
298
299Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionTab::CornerWidgets)
300
301typedef Q_DECL_DEPRECATED QStyleOptionTab QStyleOptionTabV2;
302typedef Q_DECL_DEPRECATED QStyleOptionTab QStyleOptionTabV3;
303#endif // QT_CONFIG(tabbar)
304
305
306#if QT_CONFIG(toolbar)
307
308class Q_WIDGETS_EXPORT QStyleOptionToolBar : public QStyleOption
309{
310public:
311 enum StyleOptionType { Type = SO_ToolBar };
312 enum StyleOptionVersion { Version = 1 };
313 enum ToolBarPosition { Beginning, Middle, End, OnlyOne };
314 enum ToolBarFeature { None = 0x0, Movable = 0x1 };
315 Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)
316 ToolBarPosition positionOfLine; // The toolbar line position
317 ToolBarPosition positionWithinLine; // The position within a toolbar
318 Qt::ToolBarArea toolBarArea; // The toolbar docking area
319 ToolBarFeatures features;
320 int lineWidth;
321 int midLineWidth;
322 QStyleOptionToolBar();
323 QStyleOptionToolBar(const QStyleOptionToolBar &other) : QStyleOption(Version, Type) { *this = other; }
324 QStyleOptionToolBar &operator=(const QStyleOptionToolBar &other) = default;
325
326protected:
327 QStyleOptionToolBar(int version);
328};
329
330Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolBar::ToolBarFeatures)
331
332#endif // QT_CONFIG(toolbar)
333
334class Q_WIDGETS_EXPORT QStyleOptionProgressBar : public QStyleOption
335{
336public:
337 enum StyleOptionType { Type = SO_ProgressBar };
338 enum StyleOptionVersion { Version = 2 };
339
340 int minimum;
341 int maximum;
342 int progress;
343 QString text;
344 Qt::Alignment textAlignment;
345 bool textVisible;
346 Qt::Orientation orientation; // ### Qt 6: remove
347 bool invertedAppearance;
348 bool bottomToTop;
349
350 QStyleOptionProgressBar();
351 QStyleOptionProgressBar(const QStyleOptionProgressBar &other) : QStyleOption(Version, Type) { *this = other; }
352 QStyleOptionProgressBar &operator=(const QStyleOptionProgressBar &other) = default;
353
354protected:
355 QStyleOptionProgressBar(int version);
356};
357
358typedef Q_DECL_DEPRECATED QStyleOptionProgressBar QStyleOptionProgressBarV2;
359
360class Q_WIDGETS_EXPORT QStyleOptionMenuItem : public QStyleOption
361{
362public:
363 enum StyleOptionType { Type = SO_MenuItem };
364 enum StyleOptionVersion { Version = 1 };
365
366 enum MenuItemType { Normal, DefaultItem, Separator, SubMenu, Scroller, TearOff, Margin,
367 EmptyArea };
368 enum CheckType { NotCheckable, Exclusive, NonExclusive };
369
370 MenuItemType menuItemType;
371 CheckType checkType;
372 bool checked;
373 bool menuHasCheckableItems;
374 QRect menuRect;
375 QString text;
376 QIcon icon;
377 int maxIconWidth;
378 int tabWidth; // ### Qt 6: rename to reservedShortcutWidth
379 QFont font;
380
381 QStyleOptionMenuItem();
382 QStyleOptionMenuItem(const QStyleOptionMenuItem &other) : QStyleOption(Version, Type) { *this = other; }
383 QStyleOptionMenuItem &operator=(const QStyleOptionMenuItem &other) = default;
384
385protected:
386 QStyleOptionMenuItem(int version);
387};
388
389class Q_WIDGETS_EXPORT QStyleOptionDockWidget : public QStyleOption
390{
391public:
392 enum StyleOptionType { Type = SO_DockWidget };
393 enum StyleOptionVersion { Version = 2 };
394
395 QString title;
396 bool closable;
397 bool movable;
398 bool floatable;
399 bool verticalTitleBar;
400
401 QStyleOptionDockWidget();
402 QStyleOptionDockWidget(const QStyleOptionDockWidget &other) : QStyleOption(Version, Type) { *this = other; }
403 QStyleOptionDockWidget &operator=(const QStyleOptionDockWidget &other) = default;
404
405protected:
406 QStyleOptionDockWidget(int version);
407};
408
409typedef Q_DECL_DEPRECATED QStyleOptionDockWidget QStyleOptionDockWidgetV2;
410
411#if QT_CONFIG(itemviews)
412
413class Q_WIDGETS_EXPORT QStyleOptionViewItem : public QStyleOption
414{
415public:
416 enum StyleOptionType { Type = SO_ViewItem };
417 enum StyleOptionVersion { Version = 4 };
418
419 enum Position { Left, Right, Top, Bottom };
420
421 Qt::Alignment displayAlignment;
422 Qt::Alignment decorationAlignment;
423 Qt::TextElideMode textElideMode;
424 Position decorationPosition;
425 QSize decorationSize;
426 QFont font;
427 bool showDecorationSelected;
428
429 enum ViewItemFeature {
430 None = 0x00,
431 WrapText = 0x01,
432 Alternate = 0x02,
433 HasCheckIndicator = 0x04,
434 HasDisplay = 0x08,
435 HasDecoration = 0x10
436 };
437 Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)
438
439 ViewItemFeatures features;
440
441 QLocale locale;
442 const QWidget *widget;
443
444 enum ViewItemPosition { Invalid, Beginning, Middle, End, OnlyOne };
445
446 QModelIndex index;
447 Qt::CheckState checkState;
448 QIcon icon;
449 QString text;
450 ViewItemPosition viewItemPosition;
451 QBrush backgroundBrush;
452
453 QStyleOptionViewItem();
454 QStyleOptionViewItem(const QStyleOptionViewItem &other) : QStyleOption(Version, Type) { *this = other; }
455 QStyleOptionViewItem &operator=(const QStyleOptionViewItem &other) = default;
456
457protected:
458 QStyleOptionViewItem(int version);
459};
460
461Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionViewItem::ViewItemFeatures)
462
463typedef Q_DECL_DEPRECATED QStyleOptionViewItem QStyleOptionViewItemV2;
464typedef Q_DECL_DEPRECATED QStyleOptionViewItem QStyleOptionViewItemV3;
465typedef Q_DECL_DEPRECATED QStyleOptionViewItem QStyleOptionViewItemV4;
466
467#endif // QT_CONFIG(itemviews)
468
469class Q_WIDGETS_EXPORT QStyleOptionToolBox : public QStyleOption
470{
471public:
472 enum StyleOptionType { Type = SO_ToolBox };
473 enum StyleOptionVersion { Version = 2 };
474
475 QString text;
476 QIcon icon;
477
478 enum TabPosition { Beginning, Middle, End, OnlyOneTab };
479 enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected };
480
481 TabPosition position;
482 SelectedPosition selectedPosition;
483
484 QStyleOptionToolBox();
485 QStyleOptionToolBox(const QStyleOptionToolBox &other) : QStyleOption(Version, Type) { *this = other; }
486 QStyleOptionToolBox &operator=(const QStyleOptionToolBox &other) = default;
487
488protected:
489 QStyleOptionToolBox(int version);
490};
491
492typedef Q_DECL_DEPRECATED QStyleOptionToolBox QStyleOptionToolBoxV2;
493
494#if QT_CONFIG(rubberband)
495class Q_WIDGETS_EXPORT QStyleOptionRubberBand : public QStyleOption
496{
497public:
498 enum StyleOptionType { Type = SO_RubberBand };
499 enum StyleOptionVersion { Version = 1 };
500
501 QRubberBand::Shape shape;
502 bool opaque;
503
504 QStyleOptionRubberBand();
505 QStyleOptionRubberBand(const QStyleOptionRubberBand &other) : QStyleOption(Version, Type) { *this = other; }
506 QStyleOptionRubberBand &operator=(const QStyleOptionRubberBand &other) = default;
507
508protected:
509 QStyleOptionRubberBand(int version);
510};
511#endif // QT_CONFIG(rubberband)
512
513// -------------------------- Complex style options -------------------------------
514class Q_WIDGETS_EXPORT QStyleOptionComplex : public QStyleOption
515{
516public:
517 enum StyleOptionType { Type = SO_Complex };
518 enum StyleOptionVersion { Version = 1 };
519
520 QStyle::SubControls subControls;
521 QStyle::SubControls activeSubControls;
522
523 QStyleOptionComplex(int version = QStyleOptionComplex::Version, int type = SO_Complex);
524 QStyleOptionComplex(const QStyleOptionComplex &other) : QStyleOption(Version, Type) { *this = other; }
525 QStyleOptionComplex &operator=(const QStyleOptionComplex &other) = default;
526};
527
528#if QT_CONFIG(slider)
529class Q_WIDGETS_EXPORT QStyleOptionSlider : public QStyleOptionComplex
530{
531public:
532 enum StyleOptionType { Type = SO_Slider };
533 enum StyleOptionVersion { Version = 1 };
534
535 Qt::Orientation orientation;
536 int minimum;
537 int maximum;
538 QSlider::TickPosition tickPosition;
539 int tickInterval;
540 bool upsideDown;
541 int sliderPosition;
542 int sliderValue;
543 int singleStep;
544 int pageStep;
545 qreal notchTarget;
546 bool dialWrapping;
547
548 QStyleOptionSlider();
549 QStyleOptionSlider(const QStyleOptionSlider &other) : QStyleOptionComplex(Version, Type) { *this = other; }
550 QStyleOptionSlider &operator=(const QStyleOptionSlider &other) = default;
551
552protected:
553 QStyleOptionSlider(int version);
554};
555#endif // QT_CONFIG(slider)
556
557#if QT_CONFIG(spinbox)
558class Q_WIDGETS_EXPORT QStyleOptionSpinBox : public QStyleOptionComplex
559{
560public:
561 enum StyleOptionType { Type = SO_SpinBox };
562 enum StyleOptionVersion { Version = 1 };
563
564 QAbstractSpinBox::ButtonSymbols buttonSymbols;
565 QAbstractSpinBox::StepEnabled stepEnabled;
566 bool frame;
567
568 QStyleOptionSpinBox();
569 QStyleOptionSpinBox(const QStyleOptionSpinBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
570 QStyleOptionSpinBox &operator=(const QStyleOptionSpinBox &other) = default;
571
572protected:
573 QStyleOptionSpinBox(int version);
574};
575#endif // QT_CONFIG(spinbox)
576
577class Q_WIDGETS_EXPORT QStyleOptionToolButton : public QStyleOptionComplex
578{
579public:
580 enum StyleOptionType { Type = SO_ToolButton };
581 enum StyleOptionVersion { Version = 1 };
582
583 enum ToolButtonFeature { None = 0x00, Arrow = 0x01, Menu = 0x04, MenuButtonPopup = Menu, PopupDelay = 0x08,
584 HasMenu = 0x10 };
585 Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)
586
587 ToolButtonFeatures features;
588 QIcon icon;
589 QSize iconSize;
590 QString text;
591 Qt::ArrowType arrowType;
592 Qt::ToolButtonStyle toolButtonStyle;
593 QPoint pos;
594 QFont font;
595
596 QStyleOptionToolButton();
597 QStyleOptionToolButton(const QStyleOptionToolButton &other) : QStyleOptionComplex(Version, Type) { *this = other; }
598 QStyleOptionToolButton &operator=(const QStyleOptionToolButton &other) = default;
599
600protected:
601 QStyleOptionToolButton(int version);
602};
603
604Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolButton::ToolButtonFeatures)
605
606class Q_WIDGETS_EXPORT QStyleOptionComboBox : public QStyleOptionComplex
607{
608public:
609 enum StyleOptionType { Type = SO_ComboBox };
610 enum StyleOptionVersion { Version = 1 };
611
612 bool editable;
613 QRect popupRect;
614 bool frame;
615 QString currentText;
616 QIcon currentIcon;
617 QSize iconSize;
618
619 QStyleOptionComboBox();
620 QStyleOptionComboBox(const QStyleOptionComboBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
621 QStyleOptionComboBox &operator=(const QStyleOptionComboBox &other) = default;
622
623protected:
624 QStyleOptionComboBox(int version);
625};
626
627class Q_WIDGETS_EXPORT QStyleOptionTitleBar : public QStyleOptionComplex
628{
629public:
630 enum StyleOptionType { Type = SO_TitleBar };
631 enum StyleOptionVersion { Version = 1 };
632
633 QString text;
634 QIcon icon;
635 int titleBarState;
636 Qt::WindowFlags titleBarFlags;
637
638 QStyleOptionTitleBar();
639 QStyleOptionTitleBar(const QStyleOptionTitleBar &other) : QStyleOptionComplex(Version, Type) { *this = other; }
640 QStyleOptionTitleBar &operator=(const QStyleOptionTitleBar &other) = default;
641
642protected:
643 QStyleOptionTitleBar(int version);
644};
645
646class Q_WIDGETS_EXPORT QStyleOptionGroupBox : public QStyleOptionComplex
647{
648public:
649 enum StyleOptionType { Type = SO_GroupBox };
650 enum StyleOptionVersion { Version = 1 };
651
652 QStyleOptionFrame::FrameFeatures features;
653 QString text;
654 Qt::Alignment textAlignment;
655 QColor textColor;
656 int lineWidth;
657 int midLineWidth;
658
659 QStyleOptionGroupBox();
660 QStyleOptionGroupBox(const QStyleOptionGroupBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
661 QStyleOptionGroupBox &operator=(const QStyleOptionGroupBox &other) = default;
662protected:
663 QStyleOptionGroupBox(int version);
664};
665
666class Q_WIDGETS_EXPORT QStyleOptionSizeGrip : public QStyleOptionComplex
667{
668public:
669 enum StyleOptionType { Type = SO_SizeGrip };
670 enum StyleOptionVersion { Version = 1 };
671
672 Qt::Corner corner;
673
674 QStyleOptionSizeGrip();
675 QStyleOptionSizeGrip(const QStyleOptionSizeGrip &other) : QStyleOptionComplex(Version, Type) { *this = other; }
676 QStyleOptionSizeGrip &operator=(const QStyleOptionSizeGrip &other) = default;
677protected:
678 QStyleOptionSizeGrip(int version);
679};
680
681class Q_WIDGETS_EXPORT QStyleOptionGraphicsItem : public QStyleOption
682{
683public:
684 enum StyleOptionType { Type = SO_GraphicsItem };
685 enum StyleOptionVersion { Version = 1 };
686
687 QRectF exposedRect;
688 QMatrix matrix;
689 qreal levelOfDetail;
690
691 QStyleOptionGraphicsItem();
692 QStyleOptionGraphicsItem(const QStyleOptionGraphicsItem &other) : QStyleOption(Version, Type) { *this = other; }
693 QStyleOptionGraphicsItem &operator=(const QStyleOptionGraphicsItem &other) = default;
694 static qreal levelOfDetailFromTransform(const QTransform &worldTransform);
695protected:
696 QStyleOptionGraphicsItem(int version);
697};
698
699template <typename T>
700T qstyleoption_cast(const QStyleOption *opt)
701{
702 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
703 if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type
704 || int(Opt::Type) == QStyleOption::SO_Default
705 || (int(Opt::Type) == QStyleOption::SO_Complex
706 && opt->type > QStyleOption::SO_Complex)))
707 return static_cast<T>(opt);
708 return nullptr;
709}
710
711template <typename T>
712T qstyleoption_cast(QStyleOption *opt)
713{
714 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
715 if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type
716 || int(Opt::Type) == QStyleOption::SO_Default
717 || (int(Opt::Type) == QStyleOption::SO_Complex
718 && opt->type > QStyleOption::SO_Complex)))
719 return static_cast<T>(opt);
720 return nullptr;
721}
722
723// -------------------------- QStyleHintReturn -------------------------------
724class Q_WIDGETS_EXPORT QStyleHintReturn {
725public:
726 enum HintReturnType {
727 SH_Default=0xf000, SH_Mask, SH_Variant
728 };
729
730 enum StyleOptionType { Type = SH_Default };
731 enum StyleOptionVersion { Version = 1 };
732
733 QStyleHintReturn(int version = QStyleOption::Version, int type = SH_Default);
734 ~QStyleHintReturn();
735
736 int version;
737 int type;
738};
739
740class Q_WIDGETS_EXPORT QStyleHintReturnMask : public QStyleHintReturn {
741public:
742 enum StyleOptionType { Type = SH_Mask };
743 enum StyleOptionVersion { Version = 1 };
744
745 QStyleHintReturnMask();
746 ~QStyleHintReturnMask();
747
748 QRegion region;
749};
750
751class Q_WIDGETS_EXPORT QStyleHintReturnVariant : public QStyleHintReturn {
752public:
753 enum StyleOptionType { Type = SH_Variant };
754 enum StyleOptionVersion { Version = 1 };
755
756 QStyleHintReturnVariant();
757 ~QStyleHintReturnVariant();
758
759 QVariant variant;
760};
761
762template <typename T>
763T qstyleoption_cast(const QStyleHintReturn *hint)
764{
765 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
766 if (hint && hint->version <= Opt::Version &&
767 (hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default))
768 return static_cast<T>(hint);
769 return nullptr;
770}
771
772template <typename T>
773T qstyleoption_cast(QStyleHintReturn *hint)
774{
775 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
776 if (hint && hint->version <= Opt::Version &&
777 (hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default))
778 return static_cast<T>(hint);
779 return nullptr;
780}
781
782#if !defined(QT_NO_DEBUG_STREAM)
783Q_WIDGETS_EXPORT QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType);
784Q_WIDGETS_EXPORT QDebug operator<<(QDebug debug, const QStyleOption &option);
785#endif
786
787QT_END_NAMESPACE
788
789#endif // QSTYLEOPTION_H
790