qstyle.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  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. #ifndef QSTYLE_H
  40. #define QSTYLE_H
  41. #include <QtCore/qobject.h>
  42. #include <QtCore/qrect.h>
  43. #include <QtCore/qsize.h>
  44. #include <QtGui/qicon.h>
  45. #include <QtGui/qpixmap.h>
  46. #include <QtGui/qpalette.h>
  47. #include <QtWidgets/qsizepolicy.h>
  48. QT_BEGIN_NAMESPACE
  49. class QAction;
  50. class QDebug;
  51. class QTab;
  52. class QFontMetrics;
  53. class QStyleHintReturn;
  54. class QStyleOption;
  55. class QStyleOptionComplex;
  56. class QStylePrivate;
  57. class Q_WIDGETS_EXPORT QStyle : public QObject
  58. {
  59. Q_OBJECT
  60. Q_DECLARE_PRIVATE(QStyle)
  61. protected:
  62. QStyle(QStylePrivate &dd);
  63. public:
  64. QStyle();
  65. virtual ~QStyle();
  66. virtual void polish(QWidget *widget);
  67. virtual void unpolish(QWidget *widget);
  68. virtual void polish(QApplication *application);
  69. virtual void unpolish(QApplication *application);
  70. virtual void polish(QPalette &palette);
  71. virtual QRect itemTextRect(const QFontMetrics &fm, const QRect &r,
  72. int flags, bool enabled,
  73. const QString &text) const;
  74. virtual QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const;
  75. virtual void drawItemText(QPainter *painter, const QRect &rect,
  76. int flags, const QPalette &pal, bool enabled,
  77. const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
  78. virtual void drawItemPixmap(QPainter *painter, const QRect &rect,
  79. int alignment, const QPixmap &pixmap) const;
  80. virtual QPalette standardPalette() const;
  81. enum StateFlag {
  82. State_None = 0x00000000,
  83. State_Enabled = 0x00000001,
  84. State_Raised = 0x00000002,
  85. State_Sunken = 0x00000004,
  86. State_Off = 0x00000008,
  87. State_NoChange = 0x00000010,
  88. State_On = 0x00000020,
  89. State_DownArrow = 0x00000040,
  90. State_Horizontal = 0x00000080,
  91. State_HasFocus = 0x00000100,
  92. State_Top = 0x00000200,
  93. State_Bottom = 0x00000400,
  94. State_FocusAtBorder = 0x00000800,
  95. State_AutoRaise = 0x00001000,
  96. State_MouseOver = 0x00002000,
  97. State_UpArrow = 0x00004000,
  98. State_Selected = 0x00008000,
  99. State_Active = 0x00010000,
  100. State_Window = 0x00020000,
  101. State_Open = 0x00040000,
  102. State_Children = 0x00080000,
  103. State_Item = 0x00100000,
  104. State_Sibling = 0x00200000,
  105. State_Editing = 0x00400000,
  106. State_KeyboardFocusChange = 0x00800000,
  107. #ifdef QT_KEYPAD_NAVIGATION
  108. State_HasEditFocus = 0x01000000,
  109. #endif
  110. State_ReadOnly = 0x02000000,
  111. State_Small = 0x04000000,
  112. State_Mini = 0x08000000
  113. };
  114. Q_ENUM(StateFlag)
  115. Q_DECLARE_FLAGS(State, StateFlag)
  116. enum PrimitiveElement {
  117. PE_Frame,
  118. PE_FrameDefaultButton,
  119. PE_FrameDockWidget,
  120. PE_FrameFocusRect,
  121. PE_FrameGroupBox,
  122. PE_FrameLineEdit,
  123. PE_FrameMenu,
  124. PE_FrameStatusBar, // ### Qt 6: remove
  125. PE_FrameStatusBarItem = PE_FrameStatusBar,
  126. PE_FrameTabWidget,
  127. PE_FrameWindow,
  128. PE_FrameButtonBevel,
  129. PE_FrameButtonTool,
  130. PE_FrameTabBarBase,
  131. PE_PanelButtonCommand,
  132. PE_PanelButtonBevel,
  133. PE_PanelButtonTool,
  134. PE_PanelMenuBar,
  135. PE_PanelToolBar,
  136. PE_PanelLineEdit,
  137. PE_IndicatorArrowDown,
  138. PE_IndicatorArrowLeft,
  139. PE_IndicatorArrowRight,
  140. PE_IndicatorArrowUp,
  141. PE_IndicatorBranch,
  142. PE_IndicatorButtonDropDown,
  143. PE_IndicatorViewItemCheck, // ### Qt 6: remove
  144. PE_IndicatorItemViewItemCheck = PE_IndicatorViewItemCheck,
  145. PE_IndicatorCheckBox,
  146. PE_IndicatorDockWidgetResizeHandle,
  147. PE_IndicatorHeaderArrow,
  148. PE_IndicatorMenuCheckMark,
  149. PE_IndicatorProgressChunk,
  150. PE_IndicatorRadioButton,
  151. PE_IndicatorSpinDown,
  152. PE_IndicatorSpinMinus,
  153. PE_IndicatorSpinPlus,
  154. PE_IndicatorSpinUp,
  155. PE_IndicatorToolBarHandle,
  156. PE_IndicatorToolBarSeparator,
  157. PE_PanelTipLabel,
  158. PE_IndicatorTabTear,
  159. PE_IndicatorTabTearLeft = PE_IndicatorTabTear,
  160. PE_PanelScrollAreaCorner,
  161. PE_Widget,
  162. PE_IndicatorColumnViewArrow,
  163. PE_IndicatorItemViewItemDrop,
  164. PE_PanelItemViewItem,
  165. PE_PanelItemViewRow, // ### Qt 6: remove
  166. PE_PanelStatusBar,
  167. PE_IndicatorTabClose,
  168. PE_PanelMenu,
  169. PE_IndicatorTabTearRight,
  170. // do not add any values below/greater this
  171. PE_CustomBase = 0xf000000
  172. };
  173. Q_ENUM(PrimitiveElement)
  174. virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
  175. const QWidget *w = Q_NULLPTR) const = 0;
  176. enum ControlElement {
  177. CE_PushButton,
  178. CE_PushButtonBevel,
  179. CE_PushButtonLabel,
  180. CE_CheckBox,
  181. CE_CheckBoxLabel,
  182. CE_RadioButton,
  183. CE_RadioButtonLabel,
  184. CE_TabBarTab,
  185. CE_TabBarTabShape,
  186. CE_TabBarTabLabel,
  187. CE_ProgressBar,
  188. CE_ProgressBarGroove,
  189. CE_ProgressBarContents,
  190. CE_ProgressBarLabel,
  191. CE_MenuItem,
  192. CE_MenuScroller,
  193. CE_MenuVMargin,
  194. CE_MenuHMargin,
  195. CE_MenuTearoff,
  196. CE_MenuEmptyArea,
  197. CE_MenuBarItem,
  198. CE_MenuBarEmptyArea,
  199. CE_ToolButtonLabel,
  200. CE_Header,
  201. CE_HeaderSection,
  202. CE_HeaderLabel,
  203. CE_ToolBoxTab,
  204. CE_SizeGrip,
  205. CE_Splitter,
  206. CE_RubberBand,
  207. CE_DockWidgetTitle,
  208. CE_ScrollBarAddLine,
  209. CE_ScrollBarSubLine,
  210. CE_ScrollBarAddPage,
  211. CE_ScrollBarSubPage,
  212. CE_ScrollBarSlider,
  213. CE_ScrollBarFirst,
  214. CE_ScrollBarLast,
  215. CE_FocusFrame,
  216. CE_ComboBoxLabel,
  217. CE_ToolBar,
  218. CE_ToolBoxTabShape,
  219. CE_ToolBoxTabLabel,
  220. CE_HeaderEmptyArea,
  221. CE_ColumnViewGrip,
  222. CE_ItemViewItem,
  223. CE_ShapedFrame,
  224. // do not add any values below/greater than this
  225. CE_CustomBase = 0xf0000000
  226. };
  227. Q_ENUM(ControlElement)
  228. virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
  229. const QWidget *w = Q_NULLPTR) const = 0;
  230. enum SubElement {
  231. SE_PushButtonContents,
  232. SE_PushButtonFocusRect,
  233. SE_CheckBoxIndicator,
  234. SE_CheckBoxContents,
  235. SE_CheckBoxFocusRect,
  236. SE_CheckBoxClickRect,
  237. SE_RadioButtonIndicator,
  238. SE_RadioButtonContents,
  239. SE_RadioButtonFocusRect,
  240. SE_RadioButtonClickRect,
  241. SE_ComboBoxFocusRect,
  242. SE_SliderFocusRect,
  243. SE_ProgressBarGroove,
  244. SE_ProgressBarContents,
  245. SE_ProgressBarLabel,
  246. SE_ToolBoxTabContents,
  247. SE_HeaderLabel,
  248. SE_HeaderArrow,
  249. SE_TabWidgetTabBar,
  250. SE_TabWidgetTabPane,
  251. SE_TabWidgetTabContents,
  252. SE_TabWidgetLeftCorner,
  253. SE_TabWidgetRightCorner,
  254. SE_ViewItemCheckIndicator, // ### Qt 6: remove
  255. SE_ItemViewItemCheckIndicator = SE_ViewItemCheckIndicator,
  256. SE_TabBarTearIndicator,
  257. SE_TabBarTearIndicatorLeft = SE_TabBarTearIndicator,
  258. SE_TreeViewDisclosureItem,
  259. SE_LineEditContents,
  260. SE_FrameContents,
  261. SE_DockWidgetCloseButton,
  262. SE_DockWidgetFloatButton,
  263. SE_DockWidgetTitleBarText,
  264. SE_DockWidgetIcon,
  265. SE_CheckBoxLayoutItem,
  266. SE_ComboBoxLayoutItem,
  267. SE_DateTimeEditLayoutItem,
  268. SE_DialogButtonBoxLayoutItem, // ### Qt 6: remove
  269. SE_LabelLayoutItem,
  270. SE_ProgressBarLayoutItem,
  271. SE_PushButtonLayoutItem,
  272. SE_RadioButtonLayoutItem,
  273. SE_SliderLayoutItem,
  274. SE_SpinBoxLayoutItem,
  275. SE_ToolButtonLayoutItem,
  276. SE_FrameLayoutItem,
  277. SE_GroupBoxLayoutItem,
  278. SE_TabWidgetLayoutItem,
  279. SE_ItemViewItemDecoration,
  280. SE_ItemViewItemText,
  281. SE_ItemViewItemFocusRect,
  282. SE_TabBarTabLeftButton,
  283. SE_TabBarTabRightButton,
  284. SE_TabBarTabText,
  285. SE_ShapedFrameContents,
  286. SE_ToolBarHandle,
  287. SE_TabBarScrollLeftButton,
  288. SE_TabBarScrollRightButton,
  289. SE_TabBarTearIndicatorRight,
  290. // do not add any values below/greater than this
  291. SE_CustomBase = 0xf0000000
  292. };
  293. Q_ENUM(SubElement)
  294. virtual QRect subElementRect(SubElement subElement, const QStyleOption *option,
  295. const QWidget *widget = Q_NULLPTR) const = 0;
  296. enum ComplexControl {
  297. CC_SpinBox,
  298. CC_ComboBox,
  299. CC_ScrollBar,
  300. CC_Slider,
  301. CC_ToolButton,
  302. CC_TitleBar,
  303. CC_Dial,
  304. CC_GroupBox,
  305. CC_MdiControls,
  306. // do not add any values below/greater than this
  307. CC_CustomBase = 0xf0000000
  308. };
  309. Q_ENUM(ComplexControl)
  310. enum SubControl {
  311. SC_None = 0x00000000,
  312. SC_ScrollBarAddLine = 0x00000001,
  313. SC_ScrollBarSubLine = 0x00000002,
  314. SC_ScrollBarAddPage = 0x00000004,
  315. SC_ScrollBarSubPage = 0x00000008,
  316. SC_ScrollBarFirst = 0x00000010,
  317. SC_ScrollBarLast = 0x00000020,
  318. SC_ScrollBarSlider = 0x00000040,
  319. SC_ScrollBarGroove = 0x00000080,
  320. SC_SpinBoxUp = 0x00000001,
  321. SC_SpinBoxDown = 0x00000002,
  322. SC_SpinBoxFrame = 0x00000004,
  323. SC_SpinBoxEditField = 0x00000008,
  324. SC_ComboBoxFrame = 0x00000001,
  325. SC_ComboBoxEditField = 0x00000002,
  326. SC_ComboBoxArrow = 0x00000004,
  327. SC_ComboBoxListBoxPopup = 0x00000008,
  328. SC_SliderGroove = 0x00000001,
  329. SC_SliderHandle = 0x00000002,
  330. SC_SliderTickmarks = 0x00000004,
  331. SC_ToolButton = 0x00000001,
  332. SC_ToolButtonMenu = 0x00000002,
  333. SC_TitleBarSysMenu = 0x00000001,
  334. SC_TitleBarMinButton = 0x00000002,
  335. SC_TitleBarMaxButton = 0x00000004,
  336. SC_TitleBarCloseButton = 0x00000008,
  337. SC_TitleBarNormalButton = 0x00000010,
  338. SC_TitleBarShadeButton = 0x00000020,
  339. SC_TitleBarUnshadeButton = 0x00000040,
  340. SC_TitleBarContextHelpButton = 0x00000080,
  341. SC_TitleBarLabel = 0x00000100,
  342. SC_DialGroove = 0x00000001,
  343. SC_DialHandle = 0x00000002,
  344. SC_DialTickmarks = 0x00000004,
  345. SC_GroupBoxCheckBox = 0x00000001,
  346. SC_GroupBoxLabel = 0x00000002,
  347. SC_GroupBoxContents = 0x00000004,
  348. SC_GroupBoxFrame = 0x00000008,
  349. SC_MdiMinButton = 0x00000001,
  350. SC_MdiNormalButton = 0x00000002,
  351. SC_MdiCloseButton = 0x00000004,
  352. SC_CustomBase = 0xf0000000,
  353. SC_All = 0xffffffff
  354. };
  355. Q_ENUM(SubControl)
  356. Q_DECLARE_FLAGS(SubControls, SubControl)
  357. virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
  358. const QWidget *widget = Q_NULLPTR) const = 0;
  359. virtual SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
  360. const QPoint &pt, const QWidget *widget = Q_NULLPTR) const = 0;
  361. virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
  362. SubControl sc, const QWidget *widget = Q_NULLPTR) const = 0;
  363. enum PixelMetric {
  364. PM_ButtonMargin,
  365. PM_ButtonDefaultIndicator,
  366. PM_MenuButtonIndicator,
  367. PM_ButtonShiftHorizontal,
  368. PM_ButtonShiftVertical,
  369. PM_DefaultFrameWidth,
  370. PM_SpinBoxFrameWidth,
  371. PM_ComboBoxFrameWidth,
  372. PM_MaximumDragDistance,
  373. PM_ScrollBarExtent,
  374. PM_ScrollBarSliderMin,
  375. PM_SliderThickness, // total slider thickness
  376. PM_SliderControlThickness, // thickness of the business part
  377. PM_SliderLength, // total length of slider
  378. PM_SliderTickmarkOffset, //
  379. PM_SliderSpaceAvailable, // available space for slider to move
  380. PM_DockWidgetSeparatorExtent,
  381. PM_DockWidgetHandleExtent,
  382. PM_DockWidgetFrameWidth,
  383. PM_TabBarTabOverlap,
  384. PM_TabBarTabHSpace,
  385. PM_TabBarTabVSpace,
  386. PM_TabBarBaseHeight,
  387. PM_TabBarBaseOverlap,
  388. PM_ProgressBarChunkWidth,
  389. PM_SplitterWidth,
  390. PM_TitleBarHeight,
  391. PM_MenuScrollerHeight,
  392. PM_MenuHMargin,
  393. PM_MenuVMargin,
  394. PM_MenuPanelWidth,
  395. PM_MenuTearoffHeight,
  396. PM_MenuDesktopFrameWidth,
  397. PM_MenuBarPanelWidth,
  398. PM_MenuBarItemSpacing,
  399. PM_MenuBarVMargin,
  400. PM_MenuBarHMargin,
  401. PM_IndicatorWidth,
  402. PM_IndicatorHeight,
  403. PM_ExclusiveIndicatorWidth,
  404. PM_ExclusiveIndicatorHeight,
  405. PM_DialogButtonsSeparator,
  406. PM_DialogButtonsButtonWidth,
  407. PM_DialogButtonsButtonHeight,
  408. PM_MdiSubWindowFrameWidth,
  409. PM_MDIFrameWidth = PM_MdiSubWindowFrameWidth, // ### Qt 6: remove
  410. PM_MdiSubWindowMinimizedWidth,
  411. PM_MDIMinimizedWidth = PM_MdiSubWindowMinimizedWidth, // ### Qt 6: remove
  412. PM_HeaderMargin,
  413. PM_HeaderMarkSize,
  414. PM_HeaderGripMargin,
  415. PM_TabBarTabShiftHorizontal,
  416. PM_TabBarTabShiftVertical,
  417. PM_TabBarScrollButtonWidth,
  418. PM_ToolBarFrameWidth,
  419. PM_ToolBarHandleExtent,
  420. PM_ToolBarItemSpacing,
  421. PM_ToolBarItemMargin,
  422. PM_ToolBarSeparatorExtent,
  423. PM_ToolBarExtensionExtent,
  424. PM_SpinBoxSliderHeight,
  425. PM_DefaultTopLevelMargin, // ### Qt 6: remove
  426. PM_DefaultChildMargin, // ### Qt 6: remove
  427. PM_DefaultLayoutSpacing, // ### Qt 6: remove
  428. PM_ToolBarIconSize,
  429. PM_ListViewIconSize,
  430. PM_IconViewIconSize,
  431. PM_SmallIconSize,
  432. PM_LargeIconSize,
  433. PM_FocusFrameVMargin,
  434. PM_FocusFrameHMargin,
  435. PM_ToolTipLabelFrameWidth,
  436. PM_CheckBoxLabelSpacing,
  437. PM_TabBarIconSize,
  438. PM_SizeGripSize,
  439. PM_DockWidgetTitleMargin,
  440. PM_MessageBoxIconSize,
  441. PM_ButtonIconSize,
  442. PM_DockWidgetTitleBarButtonMargin,
  443. PM_RadioButtonLabelSpacing,
  444. PM_LayoutLeftMargin,
  445. PM_LayoutTopMargin,
  446. PM_LayoutRightMargin,
  447. PM_LayoutBottomMargin,
  448. PM_LayoutHorizontalSpacing,
  449. PM_LayoutVerticalSpacing,
  450. PM_TabBar_ScrollButtonOverlap,
  451. PM_TextCursorWidth,
  452. PM_TabCloseIndicatorWidth,
  453. PM_TabCloseIndicatorHeight,
  454. PM_ScrollView_ScrollBarSpacing,
  455. PM_ScrollView_ScrollBarOverlap,
  456. PM_SubMenuOverlap,
  457. PM_TreeViewIndentation,
  458. PM_HeaderDefaultSectionSizeHorizontal,
  459. PM_HeaderDefaultSectionSizeVertical,
  460. // do not add any values below/greater than this
  461. PM_CustomBase = 0xf0000000
  462. };
  463. Q_ENUM(PixelMetric)
  464. virtual int pixelMetric(PixelMetric metric, const QStyleOption *option = Q_NULLPTR,
  465. const QWidget *widget = Q_NULLPTR) const = 0;
  466. enum ContentsType {
  467. CT_PushButton,
  468. CT_CheckBox,
  469. CT_RadioButton,
  470. CT_ToolButton,
  471. CT_ComboBox,
  472. CT_Splitter,
  473. CT_ProgressBar,
  474. CT_MenuItem,
  475. CT_MenuBarItem,
  476. CT_MenuBar,
  477. CT_Menu,
  478. CT_TabBarTab,
  479. CT_Slider,
  480. CT_ScrollBar,
  481. CT_LineEdit,
  482. CT_SpinBox,
  483. CT_SizeGrip,
  484. CT_TabWidget,
  485. CT_DialogButtons,
  486. CT_HeaderSection,
  487. CT_GroupBox,
  488. CT_MdiControls,
  489. CT_ItemViewItem,
  490. // do not add any values below/greater than this
  491. CT_CustomBase = 0xf0000000
  492. };
  493. Q_ENUM(ContentsType)
  494. virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
  495. const QSize &contentsSize, const QWidget *w = Q_NULLPTR) const = 0;
  496. enum RequestSoftwareInputPanel {
  497. RSIP_OnMouseClickAndAlreadyFocused,
  498. RSIP_OnMouseClick
  499. };
  500. Q_ENUM(RequestSoftwareInputPanel)
  501. enum StyleHint {
  502. SH_EtchDisabledText,
  503. SH_DitherDisabledText,
  504. SH_ScrollBar_MiddleClickAbsolutePosition,
  505. SH_ScrollBar_ScrollWhenPointerLeavesControl,
  506. SH_TabBar_SelectMouseType,
  507. SH_TabBar_Alignment,
  508. SH_Header_ArrowAlignment,
  509. SH_Slider_SnapToValue,
  510. SH_Slider_SloppyKeyEvents,
  511. SH_ProgressDialog_CenterCancelButton,
  512. SH_ProgressDialog_TextLabelAlignment,
  513. SH_PrintDialog_RightAlignButtons,
  514. SH_MainWindow_SpaceBelowMenuBar,
  515. SH_FontDialog_SelectAssociatedText,
  516. SH_Menu_AllowActiveAndDisabled,
  517. SH_Menu_SpaceActivatesItem,
  518. SH_Menu_SubMenuPopupDelay,
  519. SH_ScrollView_FrameOnlyAroundContents,
  520. SH_MenuBar_AltKeyNavigation,
  521. SH_ComboBox_ListMouseTracking,
  522. SH_Menu_MouseTracking,
  523. SH_MenuBar_MouseTracking,
  524. SH_ItemView_ChangeHighlightOnFocus,
  525. SH_Widget_ShareActivation,
  526. SH_Workspace_FillSpaceOnMaximize,
  527. SH_ComboBox_Popup,
  528. SH_TitleBar_NoBorder,
  529. SH_Slider_StopMouseOverSlider,
  530. SH_ScrollBar_StopMouseOverSlider = SH_Slider_StopMouseOverSlider, // ### Qt 6: remove
  531. SH_BlinkCursorWhenTextSelected,
  532. SH_RichText_FullWidthSelection,
  533. SH_Menu_Scrollable,
  534. SH_GroupBox_TextLabelVerticalAlignment,
  535. SH_GroupBox_TextLabelColor,
  536. SH_Menu_SloppySubMenus,
  537. SH_Table_GridLineColor,
  538. SH_LineEdit_PasswordCharacter,
  539. SH_DialogButtons_DefaultButton,
  540. SH_ToolBox_SelectedPageTitleBold,
  541. SH_TabBar_PreferNoArrows,
  542. SH_ScrollBar_LeftClickAbsolutePosition,
  543. SH_ListViewExpand_SelectMouseType,
  544. SH_UnderlineShortcut,
  545. SH_SpinBox_AnimateButton,
  546. SH_SpinBox_KeyPressAutoRepeatRate,
  547. SH_SpinBox_ClickAutoRepeatRate,
  548. SH_Menu_FillScreenWithScroll,
  549. SH_ToolTipLabel_Opacity,
  550. SH_DrawMenuBarSeparator,
  551. SH_TitleBar_ModifyNotification,
  552. SH_Button_FocusPolicy,
  553. SH_MessageBox_UseBorderForButtonSpacing,
  554. SH_TitleBar_AutoRaise,
  555. SH_ToolButton_PopupDelay,
  556. SH_FocusFrame_Mask,
  557. SH_RubberBand_Mask,
  558. SH_WindowFrame_Mask,
  559. SH_SpinControls_DisableOnBounds,
  560. SH_Dial_BackgroundRole,
  561. SH_ComboBox_LayoutDirection,
  562. SH_ItemView_EllipsisLocation,
  563. SH_ItemView_ShowDecorationSelected,
  564. SH_ItemView_ActivateItemOnSingleClick,
  565. SH_ScrollBar_ContextMenu,
  566. SH_ScrollBar_RollBetweenButtons,
  567. SH_Slider_AbsoluteSetButtons,
  568. SH_Slider_PageSetButtons,
  569. SH_Menu_KeyboardSearch,
  570. SH_TabBar_ElideMode,
  571. SH_DialogButtonLayout,
  572. SH_ComboBox_PopupFrameStyle,
  573. SH_MessageBox_TextInteractionFlags,
  574. SH_DialogButtonBox_ButtonsHaveIcons,
  575. SH_SpellCheckUnderlineStyle,
  576. SH_MessageBox_CenterButtons,
  577. SH_Menu_SelectionWrap,
  578. SH_ItemView_MovementWithoutUpdatingSelection,
  579. SH_ToolTip_Mask,
  580. SH_FocusFrame_AboveWidget,
  581. SH_TextControl_FocusIndicatorTextCharFormat,
  582. SH_WizardStyle,
  583. SH_ItemView_ArrowKeysNavigateIntoChildren,
  584. SH_Menu_Mask,
  585. SH_Menu_FlashTriggeredItem,
  586. SH_Menu_FadeOutOnHide,
  587. SH_SpinBox_ClickAutoRepeatThreshold,
  588. SH_ItemView_PaintAlternatingRowColorsForEmptyArea,
  589. SH_FormLayoutWrapPolicy,
  590. SH_TabWidget_DefaultTabPosition,
  591. SH_ToolBar_Movable,
  592. SH_FormLayoutFieldGrowthPolicy,
  593. SH_FormLayoutFormAlignment,
  594. SH_FormLayoutLabelAlignment,
  595. SH_ItemView_DrawDelegateFrame,
  596. SH_TabBar_CloseButtonPosition,
  597. SH_DockWidget_ButtonsHaveFrame,
  598. SH_ToolButtonStyle,
  599. SH_RequestSoftwareInputPanel,
  600. SH_ScrollBar_Transient,
  601. SH_Menu_SupportsSections,
  602. SH_ToolTip_WakeUpDelay,
  603. SH_ToolTip_FallAsleepDelay,
  604. SH_Widget_Animate,
  605. SH_Splitter_OpaqueResize,
  606. // Whether we should use a native popup.
  607. // Only supported for non-editable combo boxes on Mac OS X so far.
  608. SH_ComboBox_UseNativePopup,
  609. SH_LineEdit_PasswordMaskDelay,
  610. SH_TabBar_ChangeCurrentDelay,
  611. SH_Menu_SubMenuUniDirection,
  612. SH_Menu_SubMenuUniDirectionFailCount,
  613. SH_Menu_SubMenuSloppySelectOtherActions,
  614. SH_Menu_SubMenuSloppyCloseTimeout,
  615. SH_Menu_SubMenuResetWhenReenteringParent,
  616. SH_Menu_SubMenuDontStartSloppyOnLeave,
  617. SH_ItemView_ScrollMode,
  618. // Add new style hint values here
  619. SH_CustomBase = 0xf0000000
  620. };
  621. Q_ENUM(StyleHint)
  622. virtual int styleHint(StyleHint stylehint, const QStyleOption *opt = Q_NULLPTR,
  623. const QWidget *widget = Q_NULLPTR, QStyleHintReturn* returnData = Q_NULLPTR) const = 0;
  624. enum StandardPixmap {
  625. SP_TitleBarMenuButton,
  626. SP_TitleBarMinButton,
  627. SP_TitleBarMaxButton,
  628. SP_TitleBarCloseButton,
  629. SP_TitleBarNormalButton,
  630. SP_TitleBarShadeButton,
  631. SP_TitleBarUnshadeButton,
  632. SP_TitleBarContextHelpButton,
  633. SP_DockWidgetCloseButton,
  634. SP_MessageBoxInformation,
  635. SP_MessageBoxWarning,
  636. SP_MessageBoxCritical,
  637. SP_MessageBoxQuestion,
  638. SP_DesktopIcon,
  639. SP_TrashIcon,
  640. SP_ComputerIcon,
  641. SP_DriveFDIcon,
  642. SP_DriveHDIcon,
  643. SP_DriveCDIcon,
  644. SP_DriveDVDIcon,
  645. SP_DriveNetIcon,
  646. SP_DirOpenIcon,
  647. SP_DirClosedIcon,
  648. SP_DirLinkIcon,
  649. SP_DirLinkOpenIcon,
  650. SP_FileIcon,
  651. SP_FileLinkIcon,
  652. SP_ToolBarHorizontalExtensionButton,
  653. SP_ToolBarVerticalExtensionButton,
  654. SP_FileDialogStart,
  655. SP_FileDialogEnd,
  656. SP_FileDialogToParent,
  657. SP_FileDialogNewFolder,
  658. SP_FileDialogDetailedView,
  659. SP_FileDialogInfoView,
  660. SP_FileDialogContentsView,
  661. SP_FileDialogListView,
  662. SP_FileDialogBack,
  663. SP_DirIcon,
  664. SP_DialogOkButton,
  665. SP_DialogCancelButton,
  666. SP_DialogHelpButton,
  667. SP_DialogOpenButton,
  668. SP_DialogSaveButton,
  669. SP_DialogCloseButton,
  670. SP_DialogApplyButton,
  671. SP_DialogResetButton,
  672. SP_DialogDiscardButton,
  673. SP_DialogYesButton,
  674. SP_DialogNoButton,
  675. SP_ArrowUp,
  676. SP_ArrowDown,
  677. SP_ArrowLeft,
  678. SP_ArrowRight,
  679. SP_ArrowBack,
  680. SP_ArrowForward,
  681. SP_DirHomeIcon,
  682. SP_CommandLink,
  683. SP_VistaShield,
  684. SP_BrowserReload,
  685. SP_BrowserStop,
  686. SP_MediaPlay,
  687. SP_MediaStop,
  688. SP_MediaPause,
  689. SP_MediaSkipForward,
  690. SP_MediaSkipBackward,
  691. SP_MediaSeekForward,
  692. SP_MediaSeekBackward,
  693. SP_MediaVolume,
  694. SP_MediaVolumeMuted,
  695. SP_LineEditClearButton,
  696. // do not add any values below/greater than this
  697. SP_CustomBase = 0xf0000000
  698. };
  699. Q_ENUM(StandardPixmap)
  700. virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt = Q_NULLPTR,
  701. const QWidget *widget = Q_NULLPTR) const = 0;
  702. virtual QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = Q_NULLPTR,
  703. const QWidget *widget = Q_NULLPTR) const = 0;
  704. virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
  705. const QStyleOption *opt) const = 0;
  706. static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect,
  707. const QRect &logicalRect);
  708. static QPoint visualPos(Qt::LayoutDirection direction, const QRect &boundingRect,
  709. const QPoint &logicalPos);
  710. static int sliderPositionFromValue(int min, int max, int val, int space,
  711. bool upsideDown = false);
  712. static int sliderValueFromPosition(int min, int max, int pos, int space,
  713. bool upsideDown = false);
  714. static Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment);
  715. static QRect alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment,
  716. const QSize &size, const QRect &rectangle);
  717. virtual int layoutSpacing(QSizePolicy::ControlType control1,
  718. QSizePolicy::ControlType control2, Qt::Orientation orientation,
  719. const QStyleOption *option = Q_NULLPTR, const QWidget *widget = Q_NULLPTR) const = 0;
  720. int combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
  721. QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,
  722. QStyleOption *option = Q_NULLPTR, QWidget *widget = Q_NULLPTR) const;
  723. const QStyle * proxy() const;
  724. private:
  725. Q_DISABLE_COPY(QStyle)
  726. friend class QWidget;
  727. friend class QWidgetPrivate;
  728. friend class QApplication;
  729. friend class QProxyStyle;
  730. friend class QProxyStylePrivate;
  731. void setProxy(QStyle *style);
  732. };
  733. Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::State)
  734. Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::SubControls)
  735. #if !defined(QT_NO_DEBUG_STREAM)
  736. // ### Qt 6: Remove in favor of template<class T> QDebug operator<<(QDebug, const QFlags<T> &).
  737. # if QT_VERSION < QT_VERSION_CHECK(6,0,0)
  738. Q_WIDGETS_EXPORT QDebug operator<<(QDebug debug, QStyle::State state);
  739. # endif
  740. #endif
  741. QT_END_NAMESPACE
  742. #endif // QSTYLE_H