| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2020 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/qtransform.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 initFrom(const QWidget *w); |
| 107 | QStyleOption &operator=(const QStyleOption &other); |
| 108 | }; |
| 109 | |
| 110 | class Q_WIDGETS_EXPORT QStyleOptionFocusRect : public QStyleOption |
| 111 | { |
| 112 | public: |
| 113 | enum StyleOptionType { Type = SO_FocusRect }; |
| 114 | enum StyleOptionVersion { Version = 1 }; |
| 115 | |
| 116 | QColor backgroundColor; |
| 117 | |
| 118 | QStyleOptionFocusRect(); |
| 119 | QStyleOptionFocusRect(const QStyleOptionFocusRect &other) : QStyleOption(Version, Type) { *this = other; } |
| 120 | QStyleOptionFocusRect &operator=(const QStyleOptionFocusRect &) = default; |
| 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 = 1 }; |
| 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 | QStyleOptionFrame &operator=(const QStyleOptionFrame &) = default; |
| 146 | |
| 147 | protected: |
| 148 | QStyleOptionFrame(int version); |
| 149 | }; |
| 150 | |
| 151 | Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionFrame::FrameFeatures) |
| 152 | |
| 153 | #if QT_CONFIG(tabwidget) |
| 154 | class Q_WIDGETS_EXPORT QStyleOptionTabWidgetFrame : public QStyleOption |
| 155 | { |
| 156 | public: |
| 157 | enum StyleOptionType { Type = SO_TabWidgetFrame }; |
| 158 | enum StyleOptionVersion { Version = 1 }; |
| 159 | |
| 160 | int lineWidth; |
| 161 | int midLineWidth; |
| 162 | QTabBar::Shape shape; |
| 163 | QSize tabBarSize; |
| 164 | QSize rightCornerWidgetSize; |
| 165 | QSize leftCornerWidgetSize; |
| 166 | QRect tabBarRect; |
| 167 | QRect selectedTabRect; |
| 168 | |
| 169 | QStyleOptionTabWidgetFrame(); |
| 170 | inline QStyleOptionTabWidgetFrame(const QStyleOptionTabWidgetFrame &other) |
| 171 | : QStyleOption(Version, Type) { *this = other; } |
| 172 | QStyleOptionTabWidgetFrame &operator=(const QStyleOptionTabWidgetFrame &) = default; |
| 173 | |
| 174 | protected: |
| 175 | QStyleOptionTabWidgetFrame(int version); |
| 176 | }; |
| 177 | |
| 178 | #endif // QT_CONFIG(tabwidget) |
| 179 | |
| 180 | |
| 181 | #if QT_CONFIG(tabbar) |
| 182 | class Q_WIDGETS_EXPORT QStyleOptionTabBarBase : public QStyleOption |
| 183 | { |
| 184 | public: |
| 185 | enum StyleOptionType { Type = SO_TabBarBase }; |
| 186 | enum StyleOptionVersion { Version = 1 }; |
| 187 | |
| 188 | QTabBar::Shape shape; |
| 189 | QRect tabBarRect; |
| 190 | QRect selectedTabRect; |
| 191 | bool documentMode; |
| 192 | |
| 193 | QStyleOptionTabBarBase(); |
| 194 | QStyleOptionTabBarBase(const QStyleOptionTabBarBase &other) : QStyleOption(Version, Type) { *this = other; } |
| 195 | QStyleOptionTabBarBase &operator=(const QStyleOptionTabBarBase &) = default; |
| 196 | |
| 197 | protected: |
| 198 | QStyleOptionTabBarBase(int version); |
| 199 | }; |
| 200 | |
| 201 | #endif // QT_CONFIG(tabbar) |
| 202 | |
| 203 | class Q_WIDGETS_EXPORT : public QStyleOption |
| 204 | { |
| 205 | public: |
| 206 | enum { = SO_Header }; |
| 207 | enum { = 1 }; |
| 208 | |
| 209 | enum { , , , }; |
| 210 | enum { , , , |
| 211 | NextAndPreviousAreSelected }; |
| 212 | enum { , , }; |
| 213 | |
| 214 | int ; |
| 215 | QString ; |
| 216 | Qt::Alignment ; |
| 217 | QIcon ; |
| 218 | Qt::Alignment ; |
| 219 | SectionPosition ; |
| 220 | SelectedPosition ; |
| 221 | SortIndicator ; |
| 222 | Qt::Orientation ; |
| 223 | |
| 224 | (); |
| 225 | (const QStyleOptionHeader &other) : QStyleOption(Version, Type) { *this = other; } |
| 226 | QStyleOptionHeader &(const QStyleOptionHeader &) = default; |
| 227 | |
| 228 | protected: |
| 229 | (int version); |
| 230 | }; |
| 231 | |
| 232 | class Q_WIDGETS_EXPORT QStyleOptionButton : public QStyleOption |
| 233 | { |
| 234 | public: |
| 235 | enum StyleOptionType { Type = SO_Button }; |
| 236 | enum StyleOptionVersion { Version = 1 }; |
| 237 | |
| 238 | enum ButtonFeature { None = 0x00, Flat = 0x01, = 0x02, DefaultButton = 0x04, |
| 239 | AutoDefaultButton = 0x08, CommandLinkButton = 0x10 }; |
| 240 | Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature) |
| 241 | |
| 242 | ButtonFeatures features; |
| 243 | QString text; |
| 244 | QIcon icon; |
| 245 | QSize iconSize; |
| 246 | |
| 247 | QStyleOptionButton(); |
| 248 | QStyleOptionButton(const QStyleOptionButton &other) : QStyleOption(Version, Type) { *this = other; } |
| 249 | QStyleOptionButton &operator=(const QStyleOptionButton &) = default; |
| 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 = 1 }; |
| 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 | int tabIndex = -1; |
| 285 | |
| 286 | QStyleOptionTab(); |
| 287 | QStyleOptionTab(const QStyleOptionTab &other) : QStyleOption(Version, Type) { *this = other; } |
| 288 | QStyleOptionTab &operator=(const QStyleOptionTab &) = default; |
| 289 | |
| 290 | protected: |
| 291 | QStyleOptionTab(int version); |
| 292 | }; |
| 293 | |
| 294 | Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionTab::CornerWidgets) |
| 295 | |
| 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 | QStyleOptionToolBar &operator=(const QStyleOptionToolBar &) = default; |
| 318 | |
| 319 | protected: |
| 320 | QStyleOptionToolBar(int version); |
| 321 | }; |
| 322 | |
| 323 | Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolBar::ToolBarFeatures) |
| 324 | |
| 325 | #endif // QT_CONFIG(toolbar) |
| 326 | |
| 327 | class Q_WIDGETS_EXPORT QStyleOptionProgressBar : public QStyleOption |
| 328 | { |
| 329 | public: |
| 330 | enum StyleOptionType { Type = SO_ProgressBar }; |
| 331 | enum StyleOptionVersion { Version = 1 }; |
| 332 | |
| 333 | int minimum; |
| 334 | int maximum; |
| 335 | int progress; |
| 336 | QString text; |
| 337 | Qt::Alignment textAlignment; |
| 338 | bool textVisible; |
| 339 | bool invertedAppearance; |
| 340 | bool bottomToTop; |
| 341 | |
| 342 | QStyleOptionProgressBar(); |
| 343 | QStyleOptionProgressBar(const QStyleOptionProgressBar &other) : QStyleOption(Version, Type) { *this = other; } |
| 344 | QStyleOptionProgressBar &operator=(const QStyleOptionProgressBar &) = default; |
| 345 | |
| 346 | protected: |
| 347 | QStyleOptionProgressBar(int version); |
| 348 | }; |
| 349 | |
| 350 | class Q_WIDGETS_EXPORT : public QStyleOption |
| 351 | { |
| 352 | public: |
| 353 | enum { = SO_MenuItem }; |
| 354 | enum { = 1 }; |
| 355 | |
| 356 | enum { , , , , , , , |
| 357 | }; |
| 358 | enum { , , }; |
| 359 | |
| 360 | MenuItemType ; |
| 361 | CheckType ; |
| 362 | bool ; |
| 363 | bool ; |
| 364 | QRect ; |
| 365 | QString ; |
| 366 | QIcon ; |
| 367 | int ; |
| 368 | int ; |
| 369 | QFont ; |
| 370 | |
| 371 | (); |
| 372 | (const QStyleOptionMenuItem &other) : QStyleOption(Version, Type) { *this = other; } |
| 373 | QStyleOptionMenuItem &(const QStyleOptionMenuItem &) = default; |
| 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 = 1 }; |
| 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 | QStyleOptionDockWidget &operator=(const QStyleOptionDockWidget &) = default; |
| 394 | |
| 395 | protected: |
| 396 | QStyleOptionDockWidget(int version); |
| 397 | }; |
| 398 | |
| 399 | #if QT_CONFIG(itemviews) |
| 400 | |
| 401 | class Q_WIDGETS_EXPORT QStyleOptionViewItem : public QStyleOption |
| 402 | { |
| 403 | public: |
| 404 | enum StyleOptionType { Type = SO_ViewItem }; |
| 405 | enum StyleOptionVersion { Version = 1 }; |
| 406 | |
| 407 | enum Position { Left, Right, Top, Bottom }; |
| 408 | |
| 409 | Qt::Alignment displayAlignment; |
| 410 | Qt::Alignment decorationAlignment; |
| 411 | Qt::TextElideMode textElideMode; |
| 412 | Position decorationPosition; |
| 413 | QSize decorationSize; |
| 414 | QFont font; |
| 415 | bool showDecorationSelected; |
| 416 | |
| 417 | enum ViewItemFeature { |
| 418 | None = 0x00, |
| 419 | WrapText = 0x01, |
| 420 | Alternate = 0x02, |
| 421 | HasCheckIndicator = 0x04, |
| 422 | HasDisplay = 0x08, |
| 423 | HasDecoration = 0x10 |
| 424 | }; |
| 425 | Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature) |
| 426 | |
| 427 | ViewItemFeatures features; |
| 428 | |
| 429 | QLocale locale; |
| 430 | const QWidget *widget; |
| 431 | |
| 432 | enum ViewItemPosition { Invalid, Beginning, Middle, End, OnlyOne }; |
| 433 | |
| 434 | QModelIndex index; |
| 435 | Qt::CheckState checkState; |
| 436 | QIcon icon; |
| 437 | QString text; |
| 438 | ViewItemPosition viewItemPosition; |
| 439 | QBrush backgroundBrush; |
| 440 | |
| 441 | QStyleOptionViewItem(); |
| 442 | QStyleOptionViewItem(const QStyleOptionViewItem &other) : QStyleOption(Version, Type) { *this = other; } |
| 443 | QStyleOptionViewItem &operator=(const QStyleOptionViewItem &) = default; |
| 444 | |
| 445 | protected: |
| 446 | QStyleOptionViewItem(int version); |
| 447 | }; |
| 448 | |
| 449 | Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionViewItem::ViewItemFeatures) |
| 450 | |
| 451 | #endif // QT_CONFIG(itemviews) |
| 452 | |
| 453 | class Q_WIDGETS_EXPORT QStyleOptionToolBox : public QStyleOption |
| 454 | { |
| 455 | public: |
| 456 | enum StyleOptionType { Type = SO_ToolBox }; |
| 457 | enum StyleOptionVersion { Version = 1 }; |
| 458 | |
| 459 | QString text; |
| 460 | QIcon icon; |
| 461 | |
| 462 | enum TabPosition { Beginning, Middle, End, OnlyOneTab }; |
| 463 | enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected }; |
| 464 | |
| 465 | TabPosition position; |
| 466 | SelectedPosition selectedPosition; |
| 467 | |
| 468 | QStyleOptionToolBox(); |
| 469 | QStyleOptionToolBox(const QStyleOptionToolBox &other) : QStyleOption(Version, Type) { *this = other; } |
| 470 | QStyleOptionToolBox &operator=(const QStyleOptionToolBox &) = default; |
| 471 | |
| 472 | protected: |
| 473 | QStyleOptionToolBox(int version); |
| 474 | }; |
| 475 | |
| 476 | #if QT_CONFIG(rubberband) |
| 477 | class Q_WIDGETS_EXPORT QStyleOptionRubberBand : public QStyleOption |
| 478 | { |
| 479 | public: |
| 480 | enum StyleOptionType { Type = SO_RubberBand }; |
| 481 | enum StyleOptionVersion { Version = 1 }; |
| 482 | |
| 483 | QRubberBand::Shape shape; |
| 484 | bool opaque; |
| 485 | |
| 486 | QStyleOptionRubberBand(); |
| 487 | QStyleOptionRubberBand(const QStyleOptionRubberBand &other) : QStyleOption(Version, Type) { *this = other; } |
| 488 | QStyleOptionRubberBand &operator=(const QStyleOptionRubberBand &) = default; |
| 489 | |
| 490 | protected: |
| 491 | QStyleOptionRubberBand(int version); |
| 492 | }; |
| 493 | #endif // QT_CONFIG(rubberband) |
| 494 | |
| 495 | // -------------------------- Complex style options ------------------------------- |
| 496 | class Q_WIDGETS_EXPORT QStyleOptionComplex : public QStyleOption |
| 497 | { |
| 498 | public: |
| 499 | enum StyleOptionType { Type = SO_Complex }; |
| 500 | enum StyleOptionVersion { Version = 1 }; |
| 501 | |
| 502 | QStyle::SubControls subControls; |
| 503 | QStyle::SubControls activeSubControls; |
| 504 | |
| 505 | QStyleOptionComplex(int version = QStyleOptionComplex::Version, int type = SO_Complex); |
| 506 | QStyleOptionComplex(const QStyleOptionComplex &other) : QStyleOption(Version, Type) { *this = other; } |
| 507 | QStyleOptionComplex &operator=(const QStyleOptionComplex &) = default; |
| 508 | }; |
| 509 | |
| 510 | #if QT_CONFIG(slider) |
| 511 | class Q_WIDGETS_EXPORT QStyleOptionSlider : public QStyleOptionComplex |
| 512 | { |
| 513 | public: |
| 514 | enum StyleOptionType { Type = SO_Slider }; |
| 515 | enum StyleOptionVersion { Version = 1 }; |
| 516 | |
| 517 | Qt::Orientation orientation; |
| 518 | int minimum; |
| 519 | int maximum; |
| 520 | QSlider::TickPosition tickPosition; |
| 521 | int tickInterval; |
| 522 | bool upsideDown; |
| 523 | int sliderPosition; |
| 524 | int sliderValue; |
| 525 | int singleStep; |
| 526 | int pageStep; |
| 527 | qreal notchTarget; |
| 528 | bool dialWrapping; |
| 529 | Qt::KeyboardModifiers keyboardModifiers; |
| 530 | |
| 531 | QStyleOptionSlider(); |
| 532 | QStyleOptionSlider(const QStyleOptionSlider &other) : QStyleOptionComplex(Version, Type) { *this = other; } |
| 533 | QStyleOptionSlider &operator=(const QStyleOptionSlider &) = default; |
| 534 | |
| 535 | protected: |
| 536 | QStyleOptionSlider(int version); |
| 537 | }; |
| 538 | #endif // QT_CONFIG(slider) |
| 539 | |
| 540 | #if QT_CONFIG(spinbox) |
| 541 | class Q_WIDGETS_EXPORT QStyleOptionSpinBox : public QStyleOptionComplex |
| 542 | { |
| 543 | public: |
| 544 | enum StyleOptionType { Type = SO_SpinBox }; |
| 545 | enum StyleOptionVersion { Version = 1 }; |
| 546 | |
| 547 | QAbstractSpinBox::ButtonSymbols buttonSymbols; |
| 548 | QAbstractSpinBox::StepEnabled stepEnabled; |
| 549 | bool frame; |
| 550 | |
| 551 | QStyleOptionSpinBox(); |
| 552 | QStyleOptionSpinBox(const QStyleOptionSpinBox &other) : QStyleOptionComplex(Version, Type) { *this = other; } |
| 553 | QStyleOptionSpinBox &operator=(const QStyleOptionSpinBox &) = default; |
| 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 | QStyleOptionToolButton &operator=(const QStyleOptionToolButton &) = default; |
| 582 | |
| 583 | protected: |
| 584 | QStyleOptionToolButton(int version); |
| 585 | }; |
| 586 | |
| 587 | Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolButton::ToolButtonFeatures) |
| 588 | |
| 589 | class Q_WIDGETS_EXPORT QStyleOptionComboBox : public QStyleOptionComplex |
| 590 | { |
| 591 | public: |
| 592 | enum StyleOptionType { Type = SO_ComboBox }; |
| 593 | enum StyleOptionVersion { Version = 1 }; |
| 594 | |
| 595 | bool editable; |
| 596 | QRect ; |
| 597 | bool frame; |
| 598 | QString currentText; |
| 599 | QIcon currentIcon; |
| 600 | QSize iconSize; |
| 601 | Qt::Alignment textAlignment = Qt::AlignLeft | Qt::AlignVCenter; |
| 602 | |
| 603 | QStyleOptionComboBox(); |
| 604 | QStyleOptionComboBox(const QStyleOptionComboBox &other) : QStyleOptionComplex(Version, Type) { *this = other; } |
| 605 | QStyleOptionComboBox &operator=(const QStyleOptionComboBox &) = default; |
| 606 | |
| 607 | protected: |
| 608 | QStyleOptionComboBox(int version); |
| 609 | }; |
| 610 | |
| 611 | class Q_WIDGETS_EXPORT QStyleOptionTitleBar : public QStyleOptionComplex |
| 612 | { |
| 613 | public: |
| 614 | enum StyleOptionType { Type = SO_TitleBar }; |
| 615 | enum StyleOptionVersion { Version = 1 }; |
| 616 | |
| 617 | QString text; |
| 618 | QIcon icon; |
| 619 | int titleBarState; |
| 620 | Qt::WindowFlags titleBarFlags; |
| 621 | |
| 622 | QStyleOptionTitleBar(); |
| 623 | QStyleOptionTitleBar(const QStyleOptionTitleBar &other) : QStyleOptionComplex(Version, Type) { *this = other; } |
| 624 | QStyleOptionTitleBar &operator=(const QStyleOptionTitleBar &) = default; |
| 625 | |
| 626 | protected: |
| 627 | QStyleOptionTitleBar(int version); |
| 628 | }; |
| 629 | |
| 630 | class Q_WIDGETS_EXPORT QStyleOptionGroupBox : public QStyleOptionComplex |
| 631 | { |
| 632 | public: |
| 633 | enum StyleOptionType { Type = SO_GroupBox }; |
| 634 | enum StyleOptionVersion { Version = 1 }; |
| 635 | |
| 636 | QStyleOptionFrame::FrameFeatures features; |
| 637 | QString text; |
| 638 | Qt::Alignment textAlignment; |
| 639 | QColor textColor; |
| 640 | int lineWidth; |
| 641 | int midLineWidth; |
| 642 | |
| 643 | QStyleOptionGroupBox(); |
| 644 | QStyleOptionGroupBox(const QStyleOptionGroupBox &other) : QStyleOptionComplex(Version, Type) { *this = other; } |
| 645 | QStyleOptionGroupBox &operator=(const QStyleOptionGroupBox &) = default; |
| 646 | protected: |
| 647 | QStyleOptionGroupBox(int version); |
| 648 | }; |
| 649 | |
| 650 | class Q_WIDGETS_EXPORT QStyleOptionSizeGrip : public QStyleOptionComplex |
| 651 | { |
| 652 | public: |
| 653 | enum StyleOptionType { Type = SO_SizeGrip }; |
| 654 | enum StyleOptionVersion { Version = 1 }; |
| 655 | |
| 656 | Qt::Corner corner; |
| 657 | |
| 658 | QStyleOptionSizeGrip(); |
| 659 | QStyleOptionSizeGrip(const QStyleOptionSizeGrip &other) : QStyleOptionComplex(Version, Type) { *this = other; } |
| 660 | QStyleOptionSizeGrip &operator=(const QStyleOptionSizeGrip &) = default; |
| 661 | protected: |
| 662 | QStyleOptionSizeGrip(int version); |
| 663 | }; |
| 664 | |
| 665 | class Q_WIDGETS_EXPORT QStyleOptionGraphicsItem : public QStyleOption |
| 666 | { |
| 667 | public: |
| 668 | enum StyleOptionType { Type = SO_GraphicsItem }; |
| 669 | enum StyleOptionVersion { Version = 1 }; |
| 670 | |
| 671 | QRectF exposedRect; |
| 672 | |
| 673 | QStyleOptionGraphicsItem(); |
| 674 | QStyleOptionGraphicsItem(const QStyleOptionGraphicsItem &other) : QStyleOption(Version, Type) { *this = other; } |
| 675 | QStyleOptionGraphicsItem &operator=(const QStyleOptionGraphicsItem &) = default; |
| 676 | static qreal levelOfDetailFromTransform(const QTransform &worldTransform); |
| 677 | protected: |
| 678 | QStyleOptionGraphicsItem(int version); |
| 679 | }; |
| 680 | |
| 681 | template <typename T> |
| 682 | T qstyleoption_cast(const QStyleOption *opt) |
| 683 | { |
| 684 | typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt; |
| 685 | if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type |
| 686 | || int(Opt::Type) == QStyleOption::SO_Default |
| 687 | || (int(Opt::Type) == QStyleOption::SO_Complex |
| 688 | && opt->type > QStyleOption::SO_Complex))) |
| 689 | return static_cast<T>(opt); |
| 690 | return nullptr; |
| 691 | } |
| 692 | |
| 693 | template <typename T> |
| 694 | T qstyleoption_cast(QStyleOption *opt) |
| 695 | { |
| 696 | typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt; |
| 697 | if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type |
| 698 | || int(Opt::Type) == QStyleOption::SO_Default |
| 699 | || (int(Opt::Type) == QStyleOption::SO_Complex |
| 700 | && opt->type > QStyleOption::SO_Complex))) |
| 701 | return static_cast<T>(opt); |
| 702 | return nullptr; |
| 703 | } |
| 704 | |
| 705 | // -------------------------- QStyleHintReturn ------------------------------- |
| 706 | class Q_WIDGETS_EXPORT QStyleHintReturn { |
| 707 | public: |
| 708 | enum HintReturnType { |
| 709 | SH_Default=0xf000, SH_Mask, SH_Variant |
| 710 | }; |
| 711 | |
| 712 | enum StyleOptionType { Type = SH_Default }; |
| 713 | enum StyleOptionVersion { Version = 1 }; |
| 714 | |
| 715 | QStyleHintReturn(int version = QStyleOption::Version, int type = SH_Default); |
| 716 | ~QStyleHintReturn(); |
| 717 | |
| 718 | int version; |
| 719 | int type; |
| 720 | }; |
| 721 | |
| 722 | class Q_WIDGETS_EXPORT QStyleHintReturnMask : public QStyleHintReturn { |
| 723 | public: |
| 724 | enum StyleOptionType { Type = SH_Mask }; |
| 725 | enum StyleOptionVersion { Version = 1 }; |
| 726 | |
| 727 | QStyleHintReturnMask(); |
| 728 | ~QStyleHintReturnMask(); |
| 729 | |
| 730 | QRegion region; |
| 731 | }; |
| 732 | |
| 733 | class Q_WIDGETS_EXPORT QStyleHintReturnVariant : public QStyleHintReturn { |
| 734 | public: |
| 735 | enum StyleOptionType { Type = SH_Variant }; |
| 736 | enum StyleOptionVersion { Version = 1 }; |
| 737 | |
| 738 | QStyleHintReturnVariant(); |
| 739 | ~QStyleHintReturnVariant(); |
| 740 | |
| 741 | QVariant variant; |
| 742 | }; |
| 743 | |
| 744 | template <typename T> |
| 745 | T qstyleoption_cast(const QStyleHintReturn *hint) |
| 746 | { |
| 747 | typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt; |
| 748 | if (hint && hint->version <= Opt::Version && |
| 749 | (hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default)) |
| 750 | return static_cast<T>(hint); |
| 751 | return nullptr; |
| 752 | } |
| 753 | |
| 754 | template <typename T> |
| 755 | T qstyleoption_cast(QStyleHintReturn *hint) |
| 756 | { |
| 757 | typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt; |
| 758 | if (hint && hint->version <= Opt::Version && |
| 759 | (hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default)) |
| 760 | return static_cast<T>(hint); |
| 761 | return nullptr; |
| 762 | } |
| 763 | |
| 764 | #if !defined(QT_NO_DEBUG_STREAM) |
| 765 | Q_WIDGETS_EXPORT QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType); |
| 766 | Q_WIDGETS_EXPORT QDebug operator<<(QDebug debug, const QStyleOption &option); |
| 767 | #endif |
| 768 | |
| 769 | QT_END_NAMESPACE |
| 770 | |
| 771 | #endif // QSTYLEOPTION_H |
| 772 | |