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