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