source: trunk/src/gui/styles/qstyle.h@ 255

Last change on this file since 255 was 2, checked in by Dmitry A. Kuminov, 17 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 26.9 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QSTYLE_H
43#define QSTYLE_H
44
45#include <QtCore/qobject.h>
46#include <QtCore/qrect.h>
47#include <QtCore/qsize.h>
48#include <QtGui/qicon.h>
49#include <QtGui/qpixmap.h>
50#include <QtGui/qpalette.h>
51#include <QtGui/qsizepolicy.h>
52
53QT_BEGIN_HEADER
54
55QT_BEGIN_NAMESPACE
56
57QT_MODULE(Gui)
58
59class QAction;
60class QDebug;
61class QTab;
62class QFontMetrics;
63class QStyleHintReturn;
64class QStyleOption;
65class QStyleOptionComplex;
66class QStylePrivate;
67
68class Q_GUI_EXPORT QStyle : public QObject
69{
70 Q_OBJECT
71 Q_DECLARE_PRIVATE(QStyle)
72
73protected:
74 QStyle(QStylePrivate &dd);
75
76public:
77 QStyle();
78 virtual ~QStyle();
79
80 virtual void polish(QWidget *);
81 virtual void unpolish(QWidget *);
82
83 virtual void polish(QApplication *);
84 virtual void unpolish(QApplication *);
85
86 virtual void polish(QPalette &);
87
88 virtual QRect itemTextRect(const QFontMetrics &fm, const QRect &r,
89 int flags, bool enabled,
90 const QString &text) const;
91
92 virtual QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const;
93
94 virtual void drawItemText(QPainter *painter, const QRect &rect,
95 int flags, const QPalette &pal, bool enabled,
96 const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
97
98 virtual void drawItemPixmap(QPainter *painter, const QRect &rect,
99 int alignment, const QPixmap &pixmap) const;
100
101 virtual QPalette standardPalette() const;
102
103 enum StateFlag {
104 State_None = 0x00000000,
105#ifdef QT3_SUPPORT
106 State_Default = State_None,
107#endif
108 State_Enabled = 0x00000001,
109 State_Raised = 0x00000002,
110 State_Sunken = 0x00000004,
111 State_Off = 0x00000008,
112 State_NoChange = 0x00000010,
113 State_On = 0x00000020,
114 State_DownArrow = 0x00000040,
115 State_Horizontal = 0x00000080,
116 State_HasFocus = 0x00000100,
117 State_Top = 0x00000200,
118 State_Bottom = 0x00000400,
119 State_FocusAtBorder = 0x00000800,
120 State_AutoRaise = 0x00001000,
121 State_MouseOver = 0x00002000,
122 State_UpArrow = 0x00004000,
123 State_Selected = 0x00008000,
124 State_Active = 0x00010000,
125 State_Window = 0x00020000,
126 State_Open = 0x00040000,
127 State_Children = 0x00080000,
128 State_Item = 0x00100000,
129 State_Sibling = 0x00200000,
130 State_Editing = 0x00400000,
131 State_KeyboardFocusChange = 0x00800000,
132#ifdef QT_KEYPAD_NAVIGATION
133 State_HasEditFocus = 0x01000000,
134#endif
135 State_ReadOnly = 0x02000000,
136 State_Small = 0x04000000,
137 State_Mini = 0x08000000
138 };
139 Q_DECLARE_FLAGS(State, StateFlag)
140
141#ifdef QT3_SUPPORT
142 typedef State SFlags;
143#endif
144
145 enum PrimitiveElement {
146 PE_Q3CheckListController,
147 PE_Q3CheckListExclusiveIndicator,
148 PE_Q3CheckListIndicator,
149 PE_Q3DockWindowSeparator,
150 PE_Q3Separator,
151
152 PE_Frame,
153 PE_FrameDefaultButton,
154 PE_FrameDockWidget,
155 PE_FrameFocusRect,
156 PE_FrameGroupBox,
157 PE_FrameLineEdit,
158 PE_FrameMenu,
159 PE_FrameStatusBar, // obsolete
160 PE_FrameStatusBarItem = PE_FrameStatusBar,
161 PE_FrameTabWidget,
162 PE_FrameWindow,
163 PE_FrameButtonBevel,
164 PE_FrameButtonTool,
165 PE_FrameTabBarBase,
166
167 PE_PanelButtonCommand,
168 PE_PanelButtonBevel,
169 PE_PanelButtonTool,
170 PE_PanelMenuBar,
171 PE_PanelToolBar,
172 PE_PanelLineEdit,
173
174 PE_IndicatorArrowDown,
175 PE_IndicatorArrowLeft,
176 PE_IndicatorArrowRight,
177 PE_IndicatorArrowUp,
178 PE_IndicatorBranch,
179 PE_IndicatorButtonDropDown,
180 PE_IndicatorViewItemCheck,
181 PE_IndicatorItemViewItemCheck = PE_IndicatorViewItemCheck,
182 PE_IndicatorCheckBox,
183 PE_IndicatorDockWidgetResizeHandle,
184 PE_IndicatorHeaderArrow,
185 PE_IndicatorMenuCheckMark,
186 PE_IndicatorProgressChunk,
187 PE_IndicatorRadioButton,
188 PE_IndicatorSpinDown,
189 PE_IndicatorSpinMinus,
190 PE_IndicatorSpinPlus,
191 PE_IndicatorSpinUp,
192 PE_IndicatorToolBarHandle,
193 PE_IndicatorToolBarSeparator,
194 PE_PanelTipLabel,
195 PE_IndicatorTabTear,
196 PE_PanelScrollAreaCorner,
197
198 PE_Widget,
199
200 PE_IndicatorColumnViewArrow,
201 PE_IndicatorItemViewItemDrop,
202
203 PE_PanelItemViewItem,
204 PE_PanelItemViewRow, // ### Qt 5: remove
205
206 PE_PanelStatusBar,
207
208 PE_IndicatorTabClose,
209 PE_PanelMenu,
210
211 // do not add any values below/greater this
212 PE_CustomBase = 0xf000000
213 };
214
215 virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
216 const QWidget *w = 0) const = 0;
217 enum ControlElement {
218 CE_PushButton,
219 CE_PushButtonBevel,
220 CE_PushButtonLabel,
221
222 CE_CheckBox,
223 CE_CheckBoxLabel,
224
225 CE_RadioButton,
226 CE_RadioButtonLabel,
227
228 CE_TabBarTab,
229 CE_TabBarTabShape,
230 CE_TabBarTabLabel,
231
232 CE_ProgressBar,
233 CE_ProgressBarGroove,
234 CE_ProgressBarContents,
235 CE_ProgressBarLabel,
236
237 CE_MenuItem,
238 CE_MenuScroller,
239 CE_MenuVMargin,
240 CE_MenuHMargin,
241 CE_MenuTearoff,
242 CE_MenuEmptyArea,
243
244 CE_MenuBarItem,
245 CE_MenuBarEmptyArea,
246
247 CE_ToolButtonLabel,
248
249 CE_Header,
250 CE_HeaderSection,
251 CE_HeaderLabel,
252
253 CE_Q3DockWindowEmptyArea,
254 CE_ToolBoxTab,
255 CE_SizeGrip,
256 CE_Splitter,
257 CE_RubberBand,
258 CE_DockWidgetTitle,
259
260 CE_ScrollBarAddLine,
261 CE_ScrollBarSubLine,
262 CE_ScrollBarAddPage,
263 CE_ScrollBarSubPage,
264 CE_ScrollBarSlider,
265 CE_ScrollBarFirst,
266 CE_ScrollBarLast,
267
268 CE_FocusFrame,
269 CE_ComboBoxLabel,
270
271 CE_ToolBar,
272 CE_ToolBoxTabShape,
273 CE_ToolBoxTabLabel,
274 CE_HeaderEmptyArea,
275
276 CE_ColumnViewGrip,
277
278 CE_ItemViewItem,
279
280 CE_ShapedFrame,
281
282 // do not add any values below/greater than this
283 CE_CustomBase = 0xf0000000
284 };
285
286 virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
287 const QWidget *w = 0) const = 0;
288
289 enum SubElement {
290 SE_PushButtonContents,
291 SE_PushButtonFocusRect,
292
293 SE_CheckBoxIndicator,
294 SE_CheckBoxContents,
295 SE_CheckBoxFocusRect,
296 SE_CheckBoxClickRect,
297
298 SE_RadioButtonIndicator,
299 SE_RadioButtonContents,
300 SE_RadioButtonFocusRect,
301 SE_RadioButtonClickRect,
302
303 SE_ComboBoxFocusRect,
304
305 SE_SliderFocusRect,
306
307 SE_Q3DockWindowHandleRect,
308
309 SE_ProgressBarGroove,
310 SE_ProgressBarContents,
311 SE_ProgressBarLabel,
312
313 // ### Qt 5: These values are unused; eliminate them
314 SE_DialogButtonAccept,
315 SE_DialogButtonReject,
316 SE_DialogButtonApply,
317 SE_DialogButtonHelp,
318 SE_DialogButtonAll,
319 SE_DialogButtonAbort,
320 SE_DialogButtonIgnore,
321 SE_DialogButtonRetry,
322 SE_DialogButtonCustom,
323
324 SE_ToolBoxTabContents,
325
326 SE_HeaderLabel,
327 SE_HeaderArrow,
328
329 SE_TabWidgetTabBar,
330 SE_TabWidgetTabPane,
331 SE_TabWidgetTabContents,
332 SE_TabWidgetLeftCorner,
333 SE_TabWidgetRightCorner,
334
335 SE_ViewItemCheckIndicator,
336 SE_ItemViewItemCheckIndicator = SE_ViewItemCheckIndicator,
337
338 SE_TabBarTearIndicator,
339
340 SE_TreeViewDisclosureItem,
341
342 SE_LineEditContents,
343 SE_FrameContents,
344
345 SE_DockWidgetCloseButton,
346 SE_DockWidgetFloatButton,
347 SE_DockWidgetTitleBarText,
348 SE_DockWidgetIcon,