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