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