source: trunk/src/gui/styles/qstyle.cpp@ 371

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

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

File size: 105.4 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#include "qstyle.h"
43#include "qapplication.h"
44#include "qpainter.h"
45#include "qwidget.h"
46#include "qbitmap.h"
47#include "qpixmapcache.h"
48#include "qstyleoption.h"
49#include "private/qstyle_p.h"
50#ifndef QT_NO_DEBUG
51#include "qdebug.h"
52#endif
53
54#ifdef Q_WS_X11
55#include <qx11info_x11.h>
56#endif
57
58#include <limits.h>
59
60QT_BEGIN_NAMESPACE
61
62static const int MaxBits = 8 * sizeof(QSizePolicy::ControlType);
63
64static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::ControlType *array)
65{
66 if (!controls)
67 return 0;
68
69 // optimization: exactly one bit is set
70 if ((controls & (controls - 1)) == 0) {
71 array[0] = QSizePolicy::ControlType(uint(controls));
72 return 1;
73 }
74
75 int count = 0;
76 for (int i = 0; i < MaxBits; ++i) {
77 if (uint bit = (controls & (0x1 << i)))
78 array[count++] = QSizePolicy::ControlType(bit);
79 }
80 return count;
81}
82
83/*!
84 \class QStyle
85 \brief The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
86
87 \ingroup appearance
88
89 Qt contains a set of QStyle subclasses that emulate the styles of
90 the different platforms supported by Qt (QWindowsStyle,
91 QMacStyle, QMotifStyle, etc.). By default, these styles are built
92 into the QtGui library. Styles can also be made available as
93 plugins.
94
95 Qt's built-in widgets use QStyle to perform nearly all of their
96 drawing, ensuring that they look exactly like the equivalent
97 native widgets. The diagram below shows a QComboBox in eight
98 different styles.
99
100 \img qstyle-comboboxes.png Eight combo boxes
101
102 Topics:
103
104 \tableofcontents
105
106 \section1 Setting a Style
107
108 The style of the entire application can be set using the
109 QApplication::setStyle() function. It can also be specified by the
110 user of the application, using the \c -style command-line option:
111
112 \snippet doc/src/snippets/code/src_gui_styles_qstyle.cpp 0
113
114 If no style is specified, Qt will choose the most appropriate
115 style for the user's platform or desktop environment.
116
117 A style can also be set on an individual widget using the
118 QWidget::setStyle() function.
119
120 \section1 Developing Style-Aware Custom Widgets
121
122 If you are developing custom widgets and want them to look good on
123 all platforms, you can use QStyle functions to perform parts of
124 the widget drawing, such as drawItemText(), drawItemPixmap(),
125 drawPrimitive(), drawControl(), and drawComplexControl().
126
127 Most QStyle draw functions take four arguments:
128 \list
129 \o an enum value specifying which graphical element to draw
130 \o a QStyleOption specifying how and where to render that element
131 \o a QPainter that should be used to draw the element
132 \o a QWidget on which the drawing is performed (optional)
133 \endlist
134
135 For example, if you want to draw a focus rectangle on your
136 widget, you can write:
137
138 \snippet doc/src/snippets/styles/styles.cpp 1
139
140 QStyle gets all the information it needs to render the graphical
141 element from QStyleOption. The widget is passed as the last
142 argument in case the style needs it to perform special effects
143 (such as animated default buttons on Mac OS X), but it isn't
144 mandatory. In fact, you can use QStyle to draw on any paint
145 device, not just widgets, by setting the QPainter properly.
146
147 QStyleOption has various subclasses for the various types of
148 graphical elements that can be drawn. For example,
149 PE_FrameFocusRect expects a QStyleOptionFocusRect argument.
150
151 To ensure that drawing operations are as fast as possible,
152 QStyleOption and its subclasses have public data members. See the
153 QStyleOption class documentation for details on how to use it.
154
155 For convenience, Qt provides the QStylePainter class, which
156 combines a QStyle, a QPainter, and a QWidget. This makes it
157 possible to write
158
159 \snippet doc/src/snippets/styles/styles.cpp 5
160 \dots
161 \snippet doc/src/snippets/styles/styles.cpp 7
162
163 instead of
164
165 \snippet doc/src/snippets/styles/styles.cpp 2
166 \dots
167 \snippet doc/src/snippets/styles/styles.cpp 3
168
169 \section1 Creating a Custom Style
170
171 If you want to design a custom look and feel for your application,
172 the first step is to pick one of the styles provided with Qt to
173 build your custom style from. The choice will depend on which
174 existing style resembles your style the most. The most general
175 class that you can use as base is QCommonStyle (and not QStyle).
176 This is because Qt requires its styles to be \l{QCommonStyle}s.
177
178 Depending on which parts of the base style you want to change,
179 you must reimplement the functions that are used to draw those
180 parts of the interface. To illustrate this, we will modify the
181 look of the spin box arrows drawn by QWindowsStyle. The arrows
182 are \e{primitive elements} that are drawn by the drawPrimitive()
183 function, so we need to reimplement that function. We need the
184 following class declaration:
185
186 \snippet doc/src/snippets/customstyle/customstyle.h 0
187
188 To draw its up and down arrows, QSpinBox uses the
189 PE_IndicatorSpinUp and PE_IndicatorSpinDown primitive elements.
190 Here's how to reimplement the drawPrimitive() function to draw
191 them differently:
192
193 \snippet doc/src/snippets/customstyle/customstyle.cpp 2
194 \snippet doc/src/snippets/customstyle/customstyle.cpp 3
195 \snippet doc/src/snippets/customstyle/customstyle.cpp 4
196
197 Notice that we don't use the \c widget argument, except to pass it
198 on to the QWindowStyle::drawPrimitive() function. As mentioned
199 earlier, the information about what is to be drawn and how it
200 should be drawn is specified by a QStyleOption object, so there is
201 no need to ask the widget.
202
203 If you need to use the \c widget argument to obtain additional
204 information, be careful to ensure that it isn't 0 and that it is
205 of the correct type before using it. For example:
206
207 \snippet doc/src/snippets/customstyle/customstyle.cpp 0
208 \dots
209 \snippet doc/src/snippets/customstyle/customstyle.cpp 1
210
211 When implementing a custom style, you cannot assume that the
212 widget is a QSpinBox just because the enum value is called
213 PE_IndicatorSpinUp or PE_IndicatorSpinDown.
214
215 The documentation for the \l{widgets/styles}{Styles} example
216 covers this topic in more detail.
217
218 \warning Qt style sheets are currently not supported for custom QStyle
219 subclasses. We plan to address this in some future release.
220
221
222 \section1 Using a Custom Style
223
224 There are several ways of using a custom style in a Qt
225 application. The simplest way is call the
226 QApplication::setStyle() static function before creating the
227 QApplication object:
228
229 \snippet snippets/customstyle/main.cpp using a custom style
230
231 You can call QApplication::setStyle() at any time, but by calling
232 it before the constructor, you ensure that the user's preference,
233 set using the \c -style command-line option, is respected.
234
235 You may want to make your style available for use in other
236 applications, some of which may not be yours and are not available for
237 you to recompile. The Qt Plugin system makes it possible to create
238 styles as plugins. Styles created as plugins are loaded as shared
239 objects at runtime by Qt itself. Please refer to the \link
240 plugins-howto.html Qt Plugin\endlink documentation for more
241 information on how to go about creating a style plugin.
242
243 Compile your plugin and put it into Qt's \c plugins/styles
244 directory. We now have a pluggable style that Qt can load
245 automatically. To use your new style with existing applications,
246 simply start the application with the following argument:
247
248 \snippet doc/src/snippets/code/src_gui_styles_qstyle.cpp 1
249
250 The application will use the look and feel from the custom style you
251 implemented.
252
253 \section1 Right-to-Left Desktops
254
255 Languages written from right to left (such as Arabic and Hebrew)
256 usually also mirror the whole layout of widgets, and require the
257 light to come from the screen's top-right corner instead of
258 top-left.
259
260 If you create a custom style, you should take special care when
261 drawing asymmetric elements to make sure that they also look
262 correct in a mirrored layout. An easy way to test your styles is
263 to run applications with the \c -reverse command-line option or
264 to call QApplication::setLayoutDirection() in your \c main()
265 function.
266
267 Here are some things to keep in mind when making a style work well in a
268 right-to-left environment:
269
270 \list
271 \o subControlRect() and subElementRect() return rectangles in screen coordinates
272 \o QStyleOption::direction indicates in which direction the item should be drawn in
273 \o If a style is not right-to-left aware it will display items as if it were left-to-right
274 \o visualRect(), visualPos(), and visualAlignment() are helpful functions that will
275 translate from logical to screen representations.
276 \o alignedRect() will return a logical rect aligned for the current direction
277 \endlist
278
279 \section1 Styles in Item Views
280
281 The painting of items in views is performed by a delegate. Qt's
282 default delegate, QStyledItemDelegate, is also used for for calculating bounding
283 rectangles of items, and their sub-elements for the various kind
284 of item \l{Qt::ItemDataRole}{data roles}
285 QStyledItemDelegate supports. See the QStyledItemDelegate class
286 description to find out which datatypes and roles are supported. You
287 can read more about item data roles in \l{Model/View Programming}.
288
289 When QStyledItemDelegate paints its items, it draws
290 CE_ItemViewItem, and calculates their size with CT_ItemViewItem.
291 Note also that it uses SE_ItemViewItemText to set the size of
292 editors. When implementing a style to customize drawing of item
293 views, you need to check the implementation of QCommonStyle (and
294 any other subclasses from which your style
295 inherits). This way, you find out which and how
296 other style elements are painted, and you can then reimplement the
297 painting of elements that should be drawn differently.
298
299 We include a small example where we customize the drawing of item
300 backgrounds.
301
302 \snippet doc/src/snippets/customviewstyle.cpp 0
303
304 The primitive element PE_PanelItemViewItem is responsible for
305 painting the background of items, and is called from
306 \l{QCommonStyle}'s implementation of CE_ItemViewItem.
307
308 To add support for drawing of new datatypes and item data roles,
309 it is necessary to create a custom delegate. But if you only
310 need to support the datatypes implemented by the default
311 delegate, a custom style does not need an accompanying
312 delegate. The QStyledItemDelegate class description gives more
313 information on custom delegates.
314
315 The drawing of item view headers is also done by the style, giving
316 control over size of header items and row and column sizes.
317
318 \sa QStyleOption, QStylePainter, {Styles Example},
319 {Implementing Styles and Style Aware Widgets}, QStyledItemDelegate
320*/
321
322/*!
323 Constructs a style object.
324*/
325QStyle::QStyle()
326 : QObject(*new QStylePrivate)
327{
328}
329
330
331/*!
332 \internal
333
334 Constructs a style object.
335*/
336QStyle::QStyle(QStylePrivate &dd)
337 : QObject(dd)
338{
339}
340
341/*!
342 Destroys the style object.
343*/
344QStyle::~QStyle()
345{
346}
347
348/*!
349 Initializes the appearance of the given \a widget.
350
351 This function is called for every widget at some point after it
352 has been fully created but just \e before it is shown for the very
353 first time.
354
355 Note that the default implementation does nothing. Reasonable
356 actions in this function might be to call the
357 QWidget::setBackgroundMode() function for the widget. Do not use
358 the function to set, for example, the geometry; reimplementing
359 this function do provide a back-door through which the appearance
360 of a widget can be changed, but with Qt 4.0's style engine there
361 is rarely necessary to implement this function; reimplement the
362 drawItemPixmap(), drawItemText(), drawPrimitive(), etc. instead.
363
364 The QWidget::inherits() function may provide enough information to
365 allow class-specific customizations. But because new QStyle
366 subclasses are expected to work reasonably with all current and \e
367 future widgets, limited use of hard-coded customization is
368 recommended.
369
370 \sa unpolish()
371*/
372void QStyle::polish(QWidget * /* widget */)
373{
374}
375
376/*!
377 Uninitialize the given \a{widget}'s appearance.
378
379 This function is the counterpart to polish(). It is called for
380 every polished widget whenever the style is dynamically changed;
381 the former style has to unpolish its settings before the new style
382 can polish them again.
383
384 Note that unpolish() will only be called if the widget is
385 destroyed. This can cause problems in some cases, e.g, if you
386 remove a widget from the UI, cache it, and then reinsert it after
387 the style has changed; some of Qt's classes cache their widgets.
388
389 \sa polish()
390*/
391void QStyle::unpolish(QWidget * /* widget */)
392{
393}
394
395/*!
396 \fn void QStyle::polish(QApplication * application)
397 \overload
398
399 Late initialization of the given \a application object.
400*/
401void QStyle::polish(QApplication * /* app */)
402{
403}
404
405/*!
406 \fn void QStyle::unpolish(QApplication * application)
407 \overload
408
409 Uninitialize the given \a application.
410*/
411void QStyle::unpolish(QApplication * /* app */)
412{
413}
414
415/*!
416 \fn void QStyle::polish(QPalette & palette)
417 \overload
418
419 Changes the \a palette according to style specific requirements
420 for color palettes (if any).
421
422 \sa QPalette, QApplication::setPalette()
423*/
424void QStyle::polish(QPalette & /* pal */)
425{
426}
427
428/*!
429 \fn QRect QStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rectangle, int alignment, bool enabled, const QString &text) const
430
431 Returns the area within the given \a rectangle in which to draw
432 the provided \a text according to the specified font \a metrics
433 and \a alignment. The \a enabled parameter indicates whether or
434 not the associated item is enabled.
435
436 If the given \a rectangle is larger than the area needed to render
437 the \a text, the rectangle that is returned will be offset within
438 \a rectangle according to the specified \a alignment. For
439 example, if \a alignment is Qt::AlignCenter, the returned
440 rectangle will be centered within \a rectangle. If the given \a
441 rectangle is smaller than the area needed, the returned rectangle
442 will be the smallest rectangle large enough to render the \a text.
443
444 \sa Qt::Alignment
445*/
446QRect QStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled,
447 const QString &text) const
448{
449 QRect result;
450 int x, y, w, h;
451 rect.getRect(&x, &y, &w, &h);
452 if (!text.isEmpty()) {
453 result = metrics.boundingRect(x, y, w, h, alignment, text);
454 if (!enabled && styleHint(SH_EtchDisabledText)) {
455 result.setWidth(result.width()+1);
456 result.setHeight(result.height()+1);
457 }
458 } else {
459 result = QRect(x, y, w, h);
460 }
461 return result;
462}
463
464/*!
465 \fn QRect QStyle::itemPixmapRect(const QRect &rectangle, int alignment, const QPixmap &pixmap) const
466
467 Returns the area within the given \a rectangle in which to draw
468 the specified \a pixmap according to the defined \a alignment.
469*/
470QRect QStyle::itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const
471{
472 QRect result;
473 int x, y, w, h;
474 rect.getRect(&x, &y, &w, &h);
475 if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter)
476 y += h/2 - pixmap.height()/2;
477 else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom)
478 y += h - pixmap.height();
479 if ((alignment & Qt::AlignRight) == Qt::AlignRight)
480 x += w - pixmap.width();
481 else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter)
482 x += w/2 - pixmap.width()/2;
483 else if ((alignment & Qt::AlignLeft) != Qt::AlignLeft && QApplication::isRightToLeft())
484 x += w - pixmap.width();
485 result = QRect(x, y, pixmap.width(), pixmap.height());
486 return result;
487}
488
489/*!
490 \fn void QStyle::drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette, bool enabled, const QString& text, QPalette::ColorRole textRole) const
491
492 Draws the given \a text in the specified \a rectangle using the
493 provided \a painter and \a palette.
494
495 The text is drawn using the painter's pen, and aligned and wrapped
496 according to the specified \a alignment. If an explicit \a
497 textRole is specified, the text is drawn using the \a palette's
498 color for the given role. The \a enabled parameter indicates
499 whether or not the item is enabled; when reimplementing this
500 function, the \a enabled parameter should influence how the item is
501 drawn.
502
503 \sa Qt::Alignment, drawItemPixmap()
504*/
505void QStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
506 bool enabled, const QString& text, QPalette::ColorRole textRole) const
507{
508 if (text.isEmpty())
509 return;
510 QPen savedPen;
511 if (textRole != QPalette::NoRole) {
512 savedPen = painter->pen();
513 painter->setPen(QPen(pal.brush(textRole), savedPen.widthF()));
514 }
515 if (!enabled) {
516 if (styleHint(SH_DitherDisabledText)) {
517 painter->drawText(rect, alignment, text);
518 painter->fillRect(painter->boundingRect(rect, alignment, text), QBrush(painter->background().color(), Qt::Dense5Pattern));
519 return;
520 } else if (styleHint(SH_EtchDisabledText)) {
521 QPen pen = painter->pen();
522 painter->setPen(pal.light().color());
523 painter->drawText(rect.adjusted(1, 1, 1, 1), alignment, text);
524 painter->setPen(pen);
525 }
526 }
527 painter->drawText(rect, alignment, text);
528 if (textRole != QPalette::NoRole)
529 painter->setPen(savedPen);
530}
531
532/*!
533 \fn void QStyle::drawItemPixmap(QPainter *painter, const QRect &rectangle, int alignment,
534 const QPixmap &pixmap) const
535
536 Draws the given \a pixmap in the specified \a rectangle, according
537 to the specified \a alignment, using the provided \a painter.
538
539 \sa drawItemText()
540*/
541
542void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
543 const QPixmap &pixmap) const
544{
545 QRect aligned = alignedRect(QApplication::layoutDirection(), QFlag(alignment), pixmap.size(), rect);
546 QRect inter = aligned.intersected(rect);
547
548 painter->drawPixmap(inter.x(), inter.y(), pixmap, inter.x() - aligned.x(), inter.y() - aligned.y(), inter.width(), inter.height());
549}
550
551/*!
552 \enum QStyle::PrimitiveElement
553
554 This enum describes that various primitive elements. A
555 primitive element is a common GUI element, such as a checkbox
556 indicator or button bevel.
557
558 \omitvalue PE_IndicatorViewItemCheck
559 \value PE_FrameStatusBar Frame
560
561 \value PE_PanelButtonCommand Button used to initiate an action, for
562 example, a QPushButton.
563
564 \value PE_FrameDefaultButton This frame around a default button, e.g. in a dialog.
565 \value PE_PanelButtonBevel Generic panel with a button bevel.
566 \value PE_PanelButtonTool Panel for a Tool button, used with QToolButton.
567 \value PE_PanelLineEdit Panel for a QLineEdit.
568 \value PE_IndicatorButtonDropDown Indicator for a drop down button, for example, a tool
569 button that displays a menu.
570
571 \value PE_FrameFocusRect Generic focus indicator.
572
573 \value PE_IndicatorArrowUp Generic Up arrow.
574 \value PE_IndicatorArrowDown Generic Down arrow.
575 \value PE_IndicatorArrowRight Generic Right arrow.
576 \value PE_IndicatorArrowLeft Generic Left arrow.
577
578 \value PE_IndicatorSpinUp Up symbol for a spin widget, for example a QSpinBox.
579 \value PE_IndicatorSpinDown Down symbol for a spin widget.
580 \value PE_IndicatorSpinPlus Increase symbol for a spin widget.
581 \value PE_IndicatorSpinMinus Decrease symbol for a spin widget.
582
583 \value PE_IndicatorItemViewItemCheck On/off indicator for a view item.
584
585 \value PE_IndicatorCheckBox On/off indicator, for example, a QCheckBox.
586 \value PE_IndicatorRadioButton Exclusive on/off indicator, for example, a QRadioButton.
587
588 \value PE_Q3DockWindowSeparator Item separator for Qt 3 compatible dock window
589 and toolbar contents.
590 \value PE_IndicatorDockWidgetResizeHandle Resize handle for dock windows.
591
592 \value PE_Frame Generic frame
593 \value PE_FrameMenu Frame for popup windows/menus; see also QMenu.
594 \value PE_PanelMenuBar Panel for menu bars.
595 \value PE_PanelScrollAreaCorner Panel at the bottom-right (or
596 bottom-left) corner of a scroll area.
597
598 \value PE_FrameDockWidget Panel frame for dock windows and toolbars.
599 \value PE_FrameTabWidget Frame for tab widgets.
600 \value PE_FrameLineEdit Panel frame for line edits.
601 \value PE_FrameGroupBox Panel frame around group boxes.
602 \value PE_FrameButtonBevel Panel frame for a button bevel.
603 \value PE_FrameButtonTool Panel frame for a tool button.
604
605 \value PE_IndicatorHeaderArrow Arrow used to indicate sorting on a list or table
606 header.
607 \value PE_FrameStatusBarItem Frame for an item of a status bar; see also QStatusBar.
608
609 \value PE_FrameWindow Frame around a MDI window or a docking window.
610
611 \value PE_Q3Separator Qt 3 compatible generic separator.
612
613 \value PE_IndicatorMenuCheckMark Check mark used in a menu.
614
615 \value PE_IndicatorProgressChunk Section of a progress bar indicator; see also QProgressBar.
616
617 \value PE_Q3CheckListController Qt 3 compatible controller part of a list view item.
618 \value PE_Q3CheckListIndicator Qt 3 compatible checkbox part of a list view item.
619 \value PE_Q3CheckListExclusiveIndicator Qt 3 compatible radio button part of a list view item.
620
621 \value PE_IndicatorBranch Lines used to represent the branch of a tree in a tree view.
622 \value PE_IndicatorToolBarHandle The handle of a toolbar.
623 \value PE_IndicatorToolBarSeparator The separator in a toolbar.
624 \value PE_PanelToolBar The panel for a toolbar.
625 \value PE_PanelTipLabel The panel for a tip label.
626 \value PE_FrameTabBarBase The frame that is drawn for a tab bar, ususally drawn for a tab bar that isn't part of a tab widget.
627 \value PE_IndicatorTabTear An indicator that a tab is partially scrolled out of the visible tab bar when there are many tabs.
628 \value PE_IndicatorColumnViewArrow An arrow in a QColumnView.
629
630 \value PE_Widget A plain QWidget.
631
632 \value PE_CustomBase Base value for custom primitive elements.
633 All values above this are reserved for custom use. Custom values
634 must be greater than this value.
635
636 \value PE_IndicatorItemViewItemDrop An indicator that is drawn to show where an item in an item view is about to be dropped
637 during a drag-and-drop operation in an item view.
638 \value PE_PanelItemViewItem The background for an item in an item view.
639 \value PE_PanelItemViewRow The background of a row in an item view.
640
641 \value PE_PanelStatusBar The panel for a status bar.
642
643 \value PE_IndicatorTabClose The close button on a tab bar.
644 \value PE_PanelMenu The panel for a menu.
645
646 \sa drawPrimitive()
647*/
648
649/*!
650 \typedef QStyle::SFlags
651 \internal
652*/
653
654/*!
655 \typedef QStyle::SCFlags
656 \internal
657*/
658
659/*!
660 \enum QStyle::StateFlag
661
662 This enum describes flags that are used when drawing primitive
663 elements.
664
665 Note that not all primitives use all of these flags, and that the
666 flags may mean different things to different items.
667
668 \value State_None Indicates that the widget does not have a state.
669 \value State_Active Indicates that the widget is active.
670 \value State_AutoRaise Used to indicate if auto-raise appearance should be usd on a tool button.
671 \value State_Children Used to indicate if an item view branch has children.
672 \value State_DownArrow Used to indicate if a down arrow should be visible on the widget.
673 \value State_Editing Used to indicate if an editor is opened on the widget.
674 \value State_Enabled Used to indicate if the widget is enabled.
675 \value State_HasEditFocus Used to indicate if the widget currently has edit focus.
676 \value State_HasFocus Used to indicate if the widget has focus.
677 \value State_Horizontal Used to indicate if the widget is laid out horizontally, for example. a tool bar.
678 \value State_KeyboardFocusChange Used to indicate if the focus was changed with the keyboard, e.g., tab, backtab or shortcut.
679 \value State_MouseOver Used to indicate if the widget is under the mouse.
680 \value State_NoChange Used to indicate a tri-state checkbox.
681 \value State_Off Used to indicate if the widget is not checked.
682 \value State_On Used to indicate if the widget is checked.
683 \value State_Raised Used to indicate if a button is raised.
684 \value State_ReadOnly Used to indicate if a widget is read-only.
685 \value State_Selected Used to indicate if a widget is selected.
686 \value State_Item Used by item views to indicate if a horizontal branch should be drawn.
687 \value State_Open Used by item views to indicate if the tree branch is open.
688 \value State_Sibling Used by item views to indicate if a vertical line needs to be drawn (for siblings).
689 \value State_Sunken Used to indicate if the widget is sunken or pressed.
690 \value State_UpArrow Used to indicate if an up arrow should be visible on the widget.
691 \value State_Mini Used to indicate a mini style Mac widget or button.
692 \value State_Small Used to indicate a small style Mac widget or button.
693 \omitvalue State_Window
694 \omitvalue State_Bottom
695 \omitvalue State_Default
696 \omitvalue State_FocusAtBorder
697 \omitvalue State_Top
698
699 \sa drawPrimitive()
700*/
701
702/*!
703 \fn void QStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, \
704 QPainter *painter, const QWidget *widget) const
705
706 Draws the given primitive \a element with the provided \a painter using the style
707 options specified by \a option.
708
709 The \a widget argument is optional and may contain a widget that may
710 aid in drawing the primitive element.
711
712 The table below is listing the primitive elements and their
713 associated style option subclasses. The style options contain all
714 the parameters required to draw the elements, including
715 QStyleOption::state which holds the style flags that are used when
716 drawing. The table also describes which flags that are set when
717 casting the given option to the appropriate subclass.
718
719 Note that if a primitive element is not listed here, it is because
720 it uses a plain QStyleOption object.
721
722 \table
723 \header \o Primitive Element \o QStyleOption Subclass \o Style Flag \o Remark
724 \row \o \l PE_FrameFocusRect \o \l QStyleOptionFocusRect
725 \o \l State_FocusAtBorder
726 \o Whether the focus is is at the border or inside the widget.
727 \row \o{1,2} \l PE_IndicatorCheckBox \o{1,2} \l QStyleOptionButton
728 \o \l State_NoChange \o Indicates a "tri-state" checkbox.
729 \row \o \l State_On \o Indicates the indicator is checked.
730 \row \o \l PE_IndicatorRadioButton \o \l QStyleOptionButton
731 \o \l State_On \o Indicates that a radio button is selected.
732 \row \o{1,3} \l PE_Q3CheckListExclusiveIndicator, \l PE_Q3CheckListIndicator
733 \o{1,3} \l QStyleOptionQ3ListView \o \l State_On
734 \o Indicates whether or not the controller is selected.
735 \row \o \l State_NoChange \o Indicates a "tri-state" controller.
736 \row \o \l State_Enabled \o Indicates the controller is enabled.
737 \row \o{1,4} \l PE_IndicatorBranch \o{1,4} \l QStyleOption
738 \o \l State_Children \o Indicates that the control for expanding the tree to show child items, should be drawn.
739 \row \o \l State_Item \o Indicates that a horizontal branch (to show a child item), should be drawn.
740 \row \o \l State_Open \o Indicates that the tree branch is expanded.
741 \row \o \l State_Sibling \o Indicates that a vertical line (to show a sibling item), should be drawn.
742 \row \o \l PE_IndicatorHeaderArrow \o \l QStyleOptionHeader
743 \o \l State_UpArrow \o Indicates that the arrow should be drawn up;
744 otherwise it should be down.
745 \row \o \l PE_FrameGroupBox, \l PE_Frame, \l PE_FrameLineEdit,
746 \l PE_FrameMenu, \l PE_FrameDockWidget, \l PE_FrameWindow
747 \o \l QStyleOptionFrame \o \l State_Sunken
748 \o Indicates that the Frame should be sunken.
749 \row \o \l PE_IndicatorToolBarHandle \o \l QStyleOption
750 \o \l State_Horizontal \o Indicates that the window handle is horizontal
751 instead of vertical.
752 \row \o \l PE_Q3DockWindowSeparator \o \l QStyleOption
753 \o \l State_Horizontal \o Indicates that the separator is horizontal
754 instead of vertical.
755 \row \o \l PE_IndicatorSpinPlus, \l PE_IndicatorSpinMinus, \l PE_IndicatorSpinUp,
756 \l PE_IndicatorSpinDown,
757 \o \l QStyleOptionSpinBox
758 \o \l State_Sunken \o Indicates that the button is pressed.
759 \row \o{1,5} \l PE_PanelButtonCommand
760 \o{1,5} \l QStyleOptionButton
761 \o \l State_Enabled \o Set if the button is enabled.
762 \row \o \l State_HasFocus \o Set if the button has input focus.
763 \row \o \l State_Raised \o Set if the button is not down, not on and not flat.
764 \row \o \l State_On \o Set if the button is a toggle button and is toggled on.
765 \row \o \l State_Sunken
766 \o Set if the button is down (i.e., the mouse button or the
767 space bar is pressed on the button).
768 \endtable
769
770 \sa drawComplexControl(), drawControl()
771*/
772
773/*!
774 \enum QStyle::ControlElement
775
776 This enum represents a control element. A control element is a
777 part of a widget that performs some action or displays information
778 to the user.
779
780 \value CE_PushButton A QPushButton, draws CE_PushButtonBevel, CE_PushButtonLabel and PE_FrameFocusRect.
781 \value CE_PushButtonBevel The bevel and default indicator of a QPushButton.
782 \value CE_PushButtonLabel The label (an icon with text or pixmap) of a QPushButton.
783
784 \value CE_DockWidgetTitle Dock window title.
785 \value CE_Splitter Splitter handle; see also QSplitter.
786
787
788 \value CE_CheckBox A QCheckBox, draws a PE_IndicatorCheckBox, a CE_CheckBoxLabel and a PE_FrameFocusRect.
789 \value CE_CheckBoxLabel The label (text or pixmap) of a QCheckBox.
790
791 \value CE_RadioButton A QRadioButton, draws a PE_IndicatorRadioButton, a CE_RadioButtonLabel and a PE_FrameFocusRect.
792 \value CE_RadioButtonLabel The label (text or pixmap) of a QRadioButton.
793
794 \value CE_TabBarTab The tab and label within a QTabBar.
795 \value CE_TabBarTabShape The tab shape within a tab bar.
796 \value CE_TabBarTabLabel The label within a tab.
797
798 \value CE_ProgressBar A QProgressBar, draws CE_ProgressBarGroove, CE_ProgressBarContents and CE_ProgressBarLabel.
799 \value CE_ProgressBarGroove The groove where the progress
800 indicator is drawn in a QProgressBar.
801 \value CE_ProgressBarContents The progress indicator of a QProgressBar.
802 \value CE_ProgressBarLabel The text label of a QProgressBar.
803
804 \value CE_ToolButtonLabel A tool button's label.
805
806 \value CE_MenuBarItem A menu item in a QMenuBar.
807 \value CE_MenuBarEmptyArea The empty area of a QMenuBar.
808
809 \value CE_MenuItem A menu item in a QMenu.
810 \value CE_MenuScroller Scrolling areas in a QMenu when the
811 style supports scrolling.
812 \value CE_MenuTearoff A menu item representing the tear off section of
813 a QMenu.
814 \value CE_MenuEmptyArea The area in a menu without menu items.
815 \value CE_MenuHMargin The horizontal extra space on the left/right of a menu.
816 \value CE_MenuVMargin The vertical extra space on the top/bottom of a menu.
817
818 \value CE_Q3DockWindowEmptyArea The empty area of a QDockWidget.
819
820 \value CE_ToolBoxTab The toolbox's tab and label within a QToolBox.
821 \value CE_SizeGrip Window resize handle; see also QSizeGrip.
822
823 \value CE_Header A header.
824 \value CE_HeaderSection A header section.
825 \value CE_HeaderLabel The header's label.
826
827 \value CE_ScrollBarAddLine Scroll bar line increase indicator.
828 (i.e., scroll down); see also QScrollBar.
829 \value CE_ScrollBarSubLine Scroll bar line decrease indicator (i.e., scroll up).
830 \value CE_ScrollBarAddPage Scolllbar page increase indicator (i.e., page down).
831 \value CE_ScrollBarSubPage Scroll bar page decrease indicator (i.e., page up).
832 \value CE_ScrollBarSlider Scroll bar slider.
833 \value CE_ScrollBarFirst Scroll bar first line indicator (i.e., home).
834 \value CE_ScrollBarLast Scroll bar last line indicator (i.e., end).
835
836 \value CE_RubberBand Rubber band used in for example an icon view.
837
838 \value CE_FocusFrame Focus frame that is style controlled.
839
840 \value CE_ItemViewItem An item inside an item view.
841
842 \value CE_CustomBase Base value for custom control elements;
843 custom values must be greater than this value.
844 \value CE_ComboBoxLabel The label of a non-editable QComboBox.
845 \value CE_ToolBar A toolbar like QToolBar.
846 \value CE_ToolBoxTabShape The toolbox's tab shape.
847 \value CE_ToolBoxTabLabel The toolbox's tab label.
848 \value CE_HeaderEmptyArea The area of a header view where there are no header sections.
849
850 \value CE_ShapedFrame The frame with the shape specified in the QStyleOptionFrameV3; see QFrame.
851
852 \omitvalue CE_ColumnViewGrip
853
854 \sa drawControl()
855*/
856
857/*!
858 \fn void QStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
859
860 Draws the given \a element with the provided \a painter with the
861 style options specified by \a option.
862
863 The \a widget argument is optional and can be used as aid in
864 drawing the control. The \a option parameter is a pointer to a
865 QStyleOption object that can be cast to the correct subclass
866 using the qstyleoption_cast() function.
867
868 The table below is listing the control elements and their
869 associated style option subclass. The style options contain all
870 the parameters required to draw the controls, including
871 QStyleOption::state which holds the style flags that are used when
872 drawing. The table also describes which flags that are set when
873 casting the given option to the appropriate subclass.
874
875 Note that if a control element is not listed here, it is because
876 it uses a plain QStyleOption object.
877
878 \table
879 \header \o Control Element \o QStyleOption Subclass \o Style Flag \o Remark
880 \row \o{1,5} \l CE_MenuItem, \l CE_MenuBarItem
881 \o{1,5} \l QStyleOptionMenuItem
882 \o \l State_Selected \o The menu item is currently selected item.
883 \row \o \l State_Enabled \o The item is enabled.
884 \row \o \l State_DownArrow \o Indicates that a scroll down arrow should be drawn.
885 \row \o \l State_UpArrow \o Indicates that a scroll up arrow should be drawn
886 \row \o \l State_HasFocus \o Set if the menu bar has input focus.
887
888 \row \o{1,5} \l CE_PushButton, \l CE_PushButtonBevel, \l CE_PushButtonLabel
889 \o{1,5} \l QStyleOptionButton
890 \o \l State_Enabled \o Set if the button is enabled.
891 \row \o \l State_HasFocus \o Set if the button has input focus.
892 \row \o \l State_Raised \o Set if the button is not down, not on and not flat.
893 \row \o \l State_On \o Set if the button is a toggle button and is toggled on.
894 \row \o \l State_Sunken
895 \o Set if the button is down (i.e., the mouse button or the
896 space bar is pressed on the button).
897
898 \row \o{1,6} \l CE_RadioButton, \l CE_RadioButtonLabel,
899 \l CE_CheckBox, \l CE_CheckBoxLabel
900 \o{1,6} \l QStyleOptionButton
901 \o \l State_Enabled \o Set if the button is enabled.
902 \row \o \l State_HasFocus \o Set if the button has input focus.
903 \row \o \l State_On \o Set if the button is checked.
904 \row \o \l State_Off \o Set if the button is not checked.
905 \row \o \l State_NoChange \o Set if the button is in the NoChange state.
906 \row \o \l State_Sunken
907 \o Set if the button is down (i.e., the mouse button or
908 the space bar is pressed on the button).
909
910 \row \o{1,2} \l CE_ProgressBarContents, \l CE_ProgressBarLabel,
911 \l CE_ProgressBarGroove
912 \o{1,2} \l QStyleOptionProgressBar
913 \o \l State_Enabled \o Set if the progress bar is enabled.
914 \row \o \l State_HasFocus \o Set if the progress bar has input focus.
915
916 \row \o \l CE_Header, \l CE_HeaderSection, \l CE_HeaderLabel \o \l QStyleOptionHeader \o \o
917
918 \row \o{1,3} \l CE_TabBarTab, CE_TabBarTabShape, CE_TabBarTabLabel
919 \o{1,3} \l QStyleOptionTab
920 \o \l State_Enabled \o Set if the tab bar is enabled.
921 \row \o \l State_Selected \o The tab bar is the currently selected tab bar.
922 \row \o \l State_HasFocus \o Set if the tab bar tab has input focus.
923
924 \row \o{1,7} \l CE_ToolButtonLabel
925 \o{1,7} \l QStyleOptionToolButton
926 \o \l State_Enabled \o Set if the tool button is enabled.
927 \row \o \l State_HasFocus \o Set if the tool button has input focus.
928 \row \o \l State_Sunken
929 \o Set if the tool button is down (i.e., a mouse button or
930 the space bar is pressed).
931 \row \o \l State_On \o Set if the tool button is a toggle button and is toggled on.
932 \row \o \l State_AutoRaise \o Set if the tool button has auto-raise enabled.
933 \row \o \l State_MouseOver \o Set if the mouse pointer is over the tool button.
934 \row \o \l State_Raised \o Set if the button is not down and is not on.
935
936 \row \o \l CE_ToolBoxTab \o \l QStyleOptionToolBox
937 \o \l State_Selected \o The tab is the currently selected tab.
938 \row \o{1,3} \l CE_HeaderSection \o{1,3} \l QStyleOptionHeader
939 \o \l State_Sunken \o Indicates that the section is pressed.
940 \row \o \l State_UpArrow \o Indicates that the sort indicator should be pointing up.
941 \row \o \l State_DownArrow \o Indicates that the sort indicator should be pointing down.
942 \endtable
943
944 \sa drawPrimitive(), drawComplexControl()
945*/
946
947/*!
948 \enum QStyle::SubElement
949
950 This enum represents a sub-area of a widget. Style implementations
951 use these areas to draw the different parts of a widget.
952
953 \value SE_PushButtonContents Area containing the label (icon
954 with text or pixmap).
955 \value SE_PushButtonFocusRect Area for the focus rect (usually
956 larger than the contents rect).
957 \value SE_PushButtonLayoutItem Area that counts for the parent layout.
958
959 \value SE_CheckBoxIndicator Area for the state indicator (e.g., check mark).
960 \value SE_CheckBoxContents Area for the label (text or pixmap).
961 \value SE_CheckBoxFocusRect Area for the focus indicator.
962 \value SE_CheckBoxClickRect Clickable area, defaults to SE_CheckBoxFocusRect.
963 \value SE_CheckBoxLayoutItem Area that counts for the parent layout.
964
965 \value SE_DateTimeEditLayoutItem Area that counts for the parent layout.
966
967 \value SE_RadioButtonIndicator Area for the state indicator.
968 \value SE_RadioButtonContents Area for the label.
969 \value SE_RadioButtonFocusRect Area for the focus indicator.
970 \value SE_RadioButtonClickRect Clickable area, defaults to SE_RadioButtonFocusRect.
971 \value SE_RadioButtonLayoutItem Area that counts for the parent layout.
972
973 \value SE_ComboBoxFocusRect Area for the focus indicator.
974
975 \value SE_SliderFocusRect Area for the focus indicator.
976 \value SE_SliderLayoutItem Area that counts for the parent layout.
977
978 \value SE_SpinBoxLayoutItem Area that counts for the parent layout.
979
980 \value SE_Q3DockWindowHandleRect Area for the tear-off handle.
981
982 \value SE_ProgressBarGroove Area for the groove.
983 \value SE_ProgressBarContents Area for the progress indicator.
984 \value SE_ProgressBarLabel Area for the text label.
985 \value SE_ProgressBarLayoutItem Area that counts for the parent layout.
986
987 \omitvalue SE_DialogButtonAccept
988 \omitvalue SE_DialogButtonReject
989 \omitvalue SE_DialogButtonApply
990 \omitvalue SE_DialogButtonHelp
991 \omitvalue SE_DialogButtonAll
992 \omitvalue SE_DialogButtonRetry
993 \omitvalue SE_DialogButtonAbort
994 \omitvalue SE_DialogButtonIgnore
995 \omitvalue SE_DialogButtonCustom
996 \omitvalue SE_ViewItemCheckIndicator
997
998 \value SE_FrameContents Area for a frame's contents.
999 \value SE_ShapedFrameContents Area for a frame's contents using the shape in QStyleOptionFrameV3; see QFrame
1000 \value SE_FrameLayoutItem Area that counts for the parent layout.
1001
1002 \value SE_HeaderArrow Area for the sort indicator for a header.
1003 \value SE_HeaderLabel Area for the label in a header.
1004
1005 \value SE_LabelLayoutItem Area that counts for the parent layout.
1006
1007 \value SE_LineEditContents Area for a line edit's contents.
1008
1009 \value SE_TabWidgetLeftCorner Area for the left corner widget in a tab widget.
1010 \value SE_TabWidgetRightCorner Area for the right corner widget in a tab widget.
1011 \value SE_TabWidgetTabBar Area for the tab bar widget in a tab widget.
1012 \value SE_TabWidgetTabContents Area for the contents of the tab widget.
1013 \value SE_TabWidgetTabPane Area for the pane of a tab widget.
1014 \value SE_TabWidgetLayoutItem Area that counts for the parent layout.
1015
1016 \value SE_ToolBoxTabContents Area for a toolbox tab's icon and label.
1017
1018 \value SE_ToolButtonLayoutItem Area that counts for the parent layout.
1019
1020 \value SE_ItemViewItemCheckIndicator Area for a view item's check mark.
1021
1022 \value SE_TabBarTearIndicator Area for the tear indicator on a tab bar with scroll arrows.
1023
1024 \value SE_TreeViewDisclosureItem Area for the actual disclosure item in a tree branch.
1025
1026 \value SE_DialogButtonBoxLayoutItem Area that counts for the parent layout.
1027
1028 \value SE_GroupBoxLayoutItem Area that counts for the parent layout.
1029
1030 \value SE_CustomBase Base value for custom sub-elements.
1031 Custom values must be greater than this value.
1032
1033 \value SE_DockWidgetFloatButton The float button of a dock
1034 widget.
1035 \value SE_DockWidgetTitleBarText The text bounds of the dock
1036 widgets title.
1037 \value SE_DockWidgetCloseButton The close button of a dock
1038 widget.
1039 \value SE_DockWidgetIcon The icon of a dock widget.
1040 \value SE_ComboBoxLayoutItem Area that counts for the parent layout.
1041
1042
1043 \value SE_ItemViewItemDecoration Area for a view item's decoration (icon).
1044 \value SE_ItemViewItemText Area for a view item's text.
1045 \value SE_ItemViewItemFocusRect Area for a view item's focus rect.
1046
1047 \value SE_TabBarTabLeftButton Area for a widget on the left side of a tab in a tab bar.
1048 \value SE_TabBarTabRightButton Area for a widget on the right side of a tab in a tab bar.
1049 \value SE_TabBarTabText Area for the text on a tab in a tab bar.
1050
1051 \sa subElementRect()
1052*/
1053
1054/*!
1055 \fn QRect QStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
1056
1057 Returns the sub-area for the given \a element as described in the
1058 provided style \a option. The returned rectangle is defined in
1059 screen coordinates.
1060
1061 The \a widget argument is optional and can be used to aid
1062 determining the area. The QStyleOption object can be cast to the
1063 appropriate type using the qstyleoption_cast() function. See the
1064 table below for the appropriate \a option casts:
1065
1066 \table
1067 \header \o Sub Element \o QStyleOption Subclass
1068 \row \o \l SE_PushButtonContents \o \l QStyleOptionButton
1069 \row \o \l SE_PushButtonFocusRect \o \l QStyleOptionButton
1070 \row \o \l SE_CheckBoxIndicator \o \l QStyleOptionButton
1071 \row \o \l SE_CheckBoxContents \o \l QStyleOptionButton
1072 \row \o \l SE_CheckBoxFocusRect \o \l QStyleOptionButton
1073 \row \o \l SE_RadioButtonIndicator \o \l QStyleOptionButton
1074 \row \o \l SE_RadioButtonContents \o \l QStyleOptionButton
1075 \row \o \l SE_RadioButtonFocusRect \o \l QStyleOptionButton
1076 \row \o \l SE_ComboBoxFocusRect \o \l QStyleOptionComboBox
1077 \row \o \l SE_Q3DockWindowHandleRect \o \l QStyleOptionQ3DockWindow
1078 \row \o \l SE_ProgressBarGroove \o \l QStyleOptionProgressBar
1079 \row \o \l SE_ProgressBarContents \o \l QStyleOptionProgressBar
1080 \row \o \l SE_ProgressBarLabel \o \l QStyleOptionProgressBar
1081 \endtable
1082*/
1083
1084/*!
1085 \enum QStyle::ComplexControl
1086
1087 This enum describes the available complex controls. Complex
1088 controls have different behavior depending upon where the user
1089 clicks on them or which keys are pressed.
1090
1091 \value CC_SpinBox A spinbox, like QSpinBox.
1092 \value CC_ComboBox A combobox, like QComboBox.
1093 \value CC_ScrollBar A scroll bar, like QScrollBar.
1094 \value CC_Slider A slider, like QSlider.
1095 \value CC_ToolButton A tool button, like QToolButton.
1096 \value CC_TitleBar A Title bar, like those used in QWorkspace.
1097 \value CC_Q3ListView Used for drawing the Q3ListView class.
1098 \value CC_GroupBox A group box, like QGroupBox.
1099 \value CC_Dial A dial, like QDial.
1100 \value CC_MdiControls The minimize, close, and normal
1101 button in the menu bar for a
1102 maximized MDI subwindow.
1103
1104 \value CC_CustomBase Base value for custom complex controls. Custom
1105 values must be greater than this value.
1106
1107 \sa SubControl drawComplexControl()
1108*/
1109
1110/*!
1111 \enum QStyle::SubControl
1112
1113 This enum describes the available sub controls. A subcontrol is a
1114 control element within a complex control (ComplexControl).
1115
1116 \value SC_None Special value that matches no other sub control.
1117
1118 \value SC_ScrollBarAddLine Scroll bar add line (i.e., down/right
1119 arrow); see also QScrollBar.
1120 \value SC_ScrollBarSubLine Scroll bar sub line (i.e., up/left arrow).
1121 \value SC_ScrollBarAddPage Scroll bar add page (i.e., page down).
1122 \value SC_ScrollBarSubPage Scroll bar sub page (i.e., page up).
1123 \value SC_ScrollBarFirst Scroll bar first line (i.e., home).
1124 \value SC_ScrollBarLast Scroll bar last line (i.e., end).
1125 \value SC_ScrollBarSlider Scroll bar slider handle.
1126 \value SC_ScrollBarGroove Special sub-control which contains the
1127 area in which the slider handle may move.
1128
1129 \value SC_SpinBoxUp Spin widget up/increase; see also QSpinBox.
1130 \value SC_SpinBoxDown Spin widget down/decrease.
1131 \value SC_SpinBoxFrame Spin widget frame.
1132 \value SC_SpinBoxEditField Spin widget edit field.
1133
1134 \value SC_ComboBoxEditField Combobox edit field; see also QComboBox.
1135 \value SC_ComboBoxArrow Combobox arrow button.
1136 \value SC_ComboBoxFrame Combobox frame.
1137 \value SC_ComboBoxListBoxPopup The reference rectangle for the combobox popup.
1138 Used to calculate the position of the popup.
1139
1140 \value SC_SliderGroove Special sub-control which contains the area
1141 in which the slider handle may move.
1142 \value SC_SliderHandle Slider handle.
1143 \value SC_SliderTickmarks Slider tickmarks.
1144
1145 \value SC_ToolButton Tool button (see also QToolButton).
1146 \value SC_ToolButtonMenu Sub-control for opening a popup menu in a
1147 tool button; see also Q3PopupMenu.
1148
1149 \value SC_TitleBarSysMenu System menu button (i.e., restore, close, etc.).
1150 \value SC_TitleBarMinButton Minimize button.
1151 \value SC_TitleBarMaxButton Maximize button.
1152 \value SC_TitleBarCloseButton Close button.
1153 \value SC_TitleBarLabel Window title label.
1154 \value SC_TitleBarNormalButton Normal (restore) button.
1155 \value SC_TitleBarShadeButton Shade button.
1156 \value SC_TitleBarUnshadeButton Unshade button.
1157 \value SC_TitleBarContextHelpButton Context Help button.
1158
1159 \value SC_Q3ListView The list view area.
1160 \value SC_Q3ListViewExpand Expand item (i.e., show/hide child items).
1161
1162 \value SC_DialHandle The handle of the dial (i.e. what you use to control the dial).
1163 \value SC_DialGroove The groove for the dial.
1164 \value SC_DialTickmarks The tickmarks for the dial.
1165
1166 \value SC_GroupBoxFrame The frame of a group box.
1167 \value SC_GroupBoxLabel The title of a group box.
1168 \value SC_GroupBoxCheckBox The optional check box of a group box.
1169 \value SC_GroupBoxContents The group box contents.
1170
1171 \value SC_MdiNormalButton The normal button for a MDI
1172 subwindow in the menu bar.
1173 \value SC_MdiMinButton The minimize button for a MDI
1174 subwindow in the menu bar.
1175 \value SC_MdiCloseButton The close button for a MDI subwindow
1176 in the menu bar.
1177
1178 \value SC_All Special value that matches all sub-controls.
1179 \omitvalue SC_Q3ListViewBranch
1180
1181 \sa ComplexControl
1182*/
1183
1184/*!
1185 \fn void QStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
1186
1187 Draws the given \a control using the provided \a painter with the
1188 style options specified by \a option.
1189
1190 The \a widget argument is optional and can be used as aid in
1191 drawing the control.
1192
1193 The \a option parameter is a pointer to a QStyleOptionComplex
1194 object that can be cast to the correct subclass using the
1195 qstyleoption_cast() function. Note that the \c rect member of the
1196 specified \a option must be in logical
1197 coordinates. Reimplementations of this function should use
1198 visualRect() to change the logical coordinates into screen
1199 coordinates before calling the drawPrimitive() or drawControl()
1200 function.
1201
1202 The table below is listing the complex control elements and their
1203 associated style option subclass. The style options contain all
1204 the parameters required to draw the controls, including
1205 QStyleOption::state which holds the \l {QStyle::StateFlag}{style
1206 flags} that are used when drawing. The table also describes which
1207 flags that are set when casting the given \a option to the
1208 appropriate subclass.
1209
1210 \table
1211 \header \o Complex Control \o QStyleOptionComplex Subclass \o Style Flag \o Remark
1212 \row \o{1,2} \l{CC_SpinBox} \o{1,2} \l QStyleOptionSpinBox
1213 \o \l State_Enabled \o Set if the spin box is enabled.
1214 \row \o \l State_HasFocus \o Set if the spin box has input focus.
1215
1216 \row \o{1,2} \l {CC_ComboBox} \o{1,2} \l QStyleOptionComboBox
1217 \o \l State_Enabled \o Set if the combobox is enabled.
1218 \row \o \l State_HasFocus \o Set if the combobox has input focus.
1219
1220 \row \o{1,2} \l {CC_ScrollBar} \o{1,2} \l QStyleOptionSlider
1221 \o \l State_Enabled \o Set if the scroll bar is enabled.
1222 \row \o \l State_HasFocus \o Set if the scroll bar has input focus.
1223
1224 \row \o{1,2} \l {CC_Slider} \o{1,2} \l QStyleOptionSlider
1225 \o \l State_Enabled \o Set if the slider is enabled.
1226 \row \o \l State_HasFocus \o Set if the slider has input focus.
1227
1228 \row \o{1,2} \l {CC_Dial} \o{1,2} \l QStyleOptionSlider
1229 \o \l State_Enabled \o Set if the dial is enabled.
1230 \row \o \l State_HasFocus \o Set if the dial has input focus.
1231
1232 \row \o{1,6} \l {CC_ToolButton} \o{1,6} \l QStyleOptionToolButton
1233 \o \l State_Enabled \o Set if the tool button is enabled.
1234 \row \o \l State_HasFocus \o Set if the tool button has input focus.
1235 \row \o \l State_DownArrow \o Set if the tool button is down (i.e., a mouse
1236 button or the space bar is pressed).
1237 \row \o \l State_On \o Set if the tool button is a toggle button
1238 and is toggled on.
1239 \row \o \l State_AutoRaise \o Set if the tool button has auto-raise enabled.
1240 \row \o \l State_Raised \o Set if the button is not down, not on, and doesn't
1241 contain the mouse when auto-raise is enabled.
1242
1243 \row \o \l{CC_TitleBar} \o \l QStyleOptionTitleBar
1244 \o \l State_Enabled \o Set if the title bar is enabled.
1245
1246 \row \o \l{CC_Q3ListView} \o \l QStyleOptionQ3ListView
1247 \o \l State_Enabled \o Set if the list view is enabled.
1248
1249 \endtable
1250
1251 \sa drawPrimitive(), drawControl()
1252*/
1253
1254
1255/*!
1256 \fn QRect QStyle::subControlRect(ComplexControl control,
1257 const QStyleOptionComplex *option, SubControl subControl,
1258 const QWidget *widget) const = 0
1259
1260 Returns the rectangle containing the specified \a subControl of
1261 the given complex \a control (with the style specified by \a
1262 option). The rectangle is defined in screen coordinates.
1263
1264 The \a option argument is a pointer to QStyleOptionComplex or
1265 one of its subclasses, and can be cast to the appropriate type
1266 using the qstyleoption_cast() function. See drawComplexControl()
1267 for details. The \a widget is optional and can contain additional
1268 information for the function.
1269
1270 \sa drawComplexControl()
1271*/
1272
1273/*!
1274 \fn QStyle::SubControl QStyle::hitTestComplexControl(ComplexControl control,
1275 const QStyleOptionComplex *option, const QPoint &position,
1276 const QWidget *widget) const = 0
1277
1278 Returns the sub control at the given \a position in the given
1279 complex \a control (with the style options specified by \a
1280 option).
1281
1282 Note that the \a position is expressed in screen coordinates.
1283
1284 The \a option argument is a pointer to a QStyleOptionComplex
1285 object (or one of its subclasses). The object can be cast to the
1286 appropriate type using the qstyleoption_cast() function. See
1287 drawComplexControl() for details. The \a widget argument is
1288 optional and can contain additional information for the function.
1289
1290 \sa drawComplexControl(), subControlRect()
1291*/
1292
1293/*!
1294 \enum QStyle::PixelMetric
1295
1296 This enum describes the various available pixel metrics. A pixel
1297 metric is a style dependent size represented by a single pixel
1298 value.
1299
1300 \value PM_ButtonMargin Amount of whitespace between push button
1301 labels and the frame.
1302 \value PM_DockWidgetTitleBarButtonMargin Amount of whitespace between dock widget's
1303 title bar button labels and the frame.
1304 \value PM_ButtonDefaultIndicator Width of the default-button indicator frame.
1305 \value PM_MenuButtonIndicator Width of the menu button indicator
1306 proportional to the widget height.
1307 \value PM_ButtonShiftHorizontal Horizontal contents shift of a
1308 button when the button is down.
1309 \value PM_ButtonShiftVertical Vertical contents shift of a button when the
1310 button is down.
1311
1312 \value PM_DefaultFrameWidth Default frame width (usually 2).
1313 \value PM_SpinBoxFrameWidth Frame width of a spin box, defaults to PM_DefaultFrameWidth.
1314 \value PM_ComboBoxFrameWidth Frame width of a combo box, defaults to PM_DefaultFrameWidth.
1315
1316 \value PM_MDIFrameWidth Obsolete. Use PM_MdiSubWindowFrameWidth instead.
1317 \value PM_MdiSubWindowFrameWidth Frame width of an MDI window.
1318 \value PM_MDIMinimizedWidth Obsolete. Use PM_MdiSubWindowMinimizedWidth instead.
1319 \value PM_MdiSubWindowMinimizedWidth Width of a minimized MDI window.
1320
1321 \value PM_LayoutLeftMargin Default \l{QLayout::setContentsMargins()}{left margin} for a
1322 QLayout.
1323 \value PM_LayoutTopMargin Default \l{QLayout::setContentsMargins()}{top margin} for a QLayout.
1324 \value PM_LayoutRightMargin Default \l{QLayout::setContentsMargins()}{right margin} for a
1325 QLayout.
1326 \value PM_LayoutBottomMargin Default \l{QLayout::setContentsMargins()}{bottom margin} for a
1327 QLayout.
1328 \value PM_LayoutHorizontalSpacing Default \l{QLayout::spacing}{horizontal spacing} for a
1329 QLayout.
1330 \value PM_LayoutVerticalSpacing Default \l{QLayout::spacing}{vertical spacing} for a QLayout.
1331
1332 \value PM_MaximumDragDistance The maximum allowed distance between
1333 the mouse and a slider when dragging. Exceeding the specified
1334 distance will cause the slider to jump back to the original
1335 position; a value of -1 disables this behavior.
1336
1337 \value PM_ScrollBarExtent Width of a vertical scroll bar and the
1338 height of a horizontal scroll bar.
1339 \value PM_ScrollBarSliderMin The minimum height of a vertical
1340 scroll bar's slider and the minimum width of a horizontal
1341 scroll bar's slider.
1342
1343 \value PM_SliderThickness Total slider thickness.
1344 \value PM_SliderControlThickness Thickness of the slider handle.
1345 \value PM_SliderLength Length of the slider.
1346 \value PM_SliderTickmarkOffset The offset between the tickmarks
1347 and the slider.
1348 \value PM_SliderSpaceAvailable The available space for the slider to move.
1349
1350 \value PM_DockWidgetSeparatorExtent Width of a separator in a
1351 horizontal dock window and the height of a separator in a
1352 vertical dock window.
1353 \value PM_DockWidgetHandleExtent Width of the handle in a
1354 horizontal dock window and the height of the handle in a
1355 vertical dock window.
1356 \value PM_DockWidgetFrameWidth Frame width of a dock window.
1357 \value PM_DockWidgetTitleMargin Margin of the dock window title.
1358
1359 \value PM_MenuBarPanelWidth Frame width of a menu bar, defaults to PM_DefaultFrameWidth.
1360 \value PM_MenuBarItemSpacing Spacing between menu bar items.
1361 \value PM_MenuBarHMargin Spacing between menu bar items and left/right of bar.
1362 \value PM_MenuBarVMargin Spacing between menu bar items and top/bottom of bar.
1363
1364 \value PM_ToolBarFrameWidth Width of the frame around toolbars.
1365 \value PM_ToolBarHandleExtent Width of a toolbar handle in a
1366 horizontal toolbar and the height of the handle in a vertical toolbar.
1367 \value PM_ToolBarItemMargin Spacing between the toolbar frame and the items.
1368 \value PM_ToolBarItemSpacing Spacing between toolbar items.
1369 \value PM_ToolBarSeparatorExtent Width of a toolbar separator in a
1370 horizontal toolbar and the height of a separator in a vertical toolbar.
1371 \value PM_ToolBarExtensionExtent Width of a toolbar extension
1372 button in a horizontal toolbar and the height of the button in a
1373 vertical toolbar.
1374
1375 \value PM_TabBarTabOverlap Number of pixels the tabs should overlap.
1376 (Currently only used in styles, not inside of QTabBar)
1377 \value PM_TabBarTabHSpace Extra space added to the tab width.
1378 \value PM_TabBarTabVSpace Extra space added to the tab height.
1379 \value PM_TabBarBaseHeight Height of the area between the tab bar
1380 and the tab pages.
1381 \value PM_TabBarBaseOverlap Number of pixels the tab bar overlaps
1382 the tab bar base.
1383 \value PM_TabBarScrollButtonWidth
1384 \value PM_TabBarTabShiftHorizontal Horizontal pixel shift when a
1385 tab is selected.
1386 \value PM_TabBarTabShiftVertical Vertical pixel shift when a
1387 tab is selected.
1388
1389 \value PM_ProgressBarChunkWidth Width of a chunk in a progress bar indicator.
1390
1391 \value PM_SplitterWidth Width of a splitter.
1392
1393 \value PM_TitleBarHeight Height of the title bar.
1394
1395 \value PM_IndicatorWidth Width of a check box indicator.
1396 \value PM_IndicatorHeight Height of a checkbox indicator.
1397 \value PM_ExclusiveIndicatorWidth Width of a radio button indicator.
1398 \value PM_ExclusiveIndicatorHeight Height of a radio button indicator.
1399
1400 \value PM_MenuPanelWidth Border width (applied on all sides) for a QMenu.
1401 \value PM_MenuHMargin Additional border (used on left and right) for a QMenu.
1402 \value PM_MenuVMargin Additional border (used for bottom and top) for a QMenu.
1403 \value PM_MenuScrollerHeight Height of the scroller area in a QMenu.
1404 \value PM_MenuTearoffHeight Height of a tear off area in a QMenu.
1405 \value PM_MenuDesktopFrameWidth The frame width for the menu on the desktop.
1406
1407 \value PM_CheckListButtonSize Area (width/height) of the
1408 checkbox/radio button in a Q3CheckListItem.
1409 \value PM_CheckListControllerSize Area (width/height) of the
1410 controller in a Q3CheckListItem.
1411
1412 \omitvalue PM_DialogButtonsSeparator
1413 \omitvalue PM_DialogButtonsButtonWidth
1414 \omitvalue PM_DialogButtonsButtonHeight
1415
1416 \value PM_HeaderMarkSize The size of the sort indicator in a header.
1417 \value PM_HeaderGripMargin The size of the resize grip in a header.
1418 \value PM_HeaderMargin The size of the margin between the sort indicator and the text.
1419 \value PM_SpinBoxSliderHeight The height of the optional spin box slider.
1420
1421 \value PM_ToolBarIconSize Default tool bar icon size
1422 \value PM_SmallIconSize Default small icon size
1423 \value PM_LargeIconSize Default large icon size
1424
1425 \value PM_FocusFrameHMargin Horizontal margin that the focus frame will outset the widget by.
1426 \value PM_FocusFrameVMargin Vertical margin that the focus frame will outset the widget by.
1427 \value PM_IconViewIconSize The default size for icons in an icon view.
1428 \value PM_ListViewIconSize The default size for icons in a list view.
1429
1430 \value PM_ToolTipLabelFrameWidth The frame width for a tool tip label.
1431 \value PM_CheckBoxLabelSpacing The spacing between a check box indicator and its label.
1432 \value PM_RadioButtonLabelSpacing The spacing between a radio button indicator and its label.
1433 \value PM_TabBarIconSize The default icon size for a tab bar.
1434 \value PM_SizeGripSize The size of a size grip.
1435 \value PM_MessageBoxIconSize The size of the standard icons in a message box
1436 \value PM_ButtonIconSize The default size of button icons
1437 \value PM_TextCursorWidth The width of the cursor in a line edit or text edit
1438 \value PM_TabBar_ScrollButtonOverlap The distance between the left and right buttons in a tab bar.
1439
1440 \value PM_TabCloseIndicatorWidth The default width of a close button on a tab in a tab bar.
1441 \value PM_TabCloseIndicatorHeight The default height of a close button on a tab in a tab bar.
1442
1443 \value PM_CustomBase Base value for custom pixel metrics. Custom
1444 values must be greater than this value.
1445
1446 The following values are obsolete:
1447
1448 \value PM_DefaultTopLevelMargin Use PM_LayoutLeftMargin,
1449 PM_LayoutTopMargin,
1450 PM_LayoutRightMargin, and
1451 PM_LayoutBottomMargin instead.
1452 \value PM_DefaultChildMargin Use PM_LayoutLeftMargin,
1453 PM_LayoutTopMargin,
1454 PM_LayoutRightMargin, and
1455 PM_LayoutBottomMargin instead.
1456 \value PM_DefaultLayoutSpacing Use PM_LayoutHorizontalSpacing
1457 and PM_LayoutVerticalSpacing
1458 instead.
1459
1460 \value PM_ScrollView_ScrollBarSpacing Distance between frame and scrollbar
1461 with SH_ScrollView_FrameOnlyAroundContents set.
1462 \value PM_SubMenuOverlap The horizontal overlap between a submenu and its parent.
1463
1464
1465 \sa pixelMetric()
1466*/
1467
1468/*!
1469 \fn int QStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const;
1470
1471 Returns the value of the given pixel \a metric.
1472
1473 The specified \a option and \a widget can be used for calculating
1474 the metric. In general, the \a widget argument is not used. The \a
1475 option can be cast to the appropriate type using the
1476 qstyleoption_cast() function. Note that the \a option may be zero
1477 even for PixelMetrics that can make use of it. See the table below
1478 for the appropriate \a option casts:
1479
1480 \table
1481 \header \o Pixel Metric \o QStyleOption Subclass
1482 \row \o \l PM_SliderControlThickness \o \l QStyleOptionSlider
1483 \row \o \l PM_SliderLength \o \l QStyleOptionSlider
1484 \row \o \l PM_SliderTickmarkOffset \o \l QStyleOptionSlider
1485 \row \o \l PM_SliderSpaceAvailable \o \l QStyleOptionSlider
1486 \row \o \l PM_ScrollBarExtent \o \l QStyleOptionSlider
1487 \row \o \l PM_TabBarTabOverlap \o \l QStyleOptionTab
1488 \row \o \l PM_TabBarTabHSpace \o \l QStyleOptionTab
1489 \row \o \l PM_TabBarTabVSpace \o \l QStyleOptionTab
1490 \row \o \l PM_TabBarBaseHeight \o \l QStyleOptionTab
1491 \row \o \l PM_TabBarBaseOverlap \o \l QStyleOptionTab
1492 \endtable
1493
1494 Some pixel metrics are called from widgets and some are only called
1495 internally by the style. If the metric is not called by a widget, it is the
1496 discretion of the style author to make use of it. For some styles, this
1497 may not be appropriate.
1498*/
1499
1500/*!
1501 \enum QStyle::ContentsType
1502
1503 This enum describes the available contents types. These are used to
1504 calculate sizes for the contents of various widgets.
1505
1506 \value CT_CheckBox A check box, like QCheckBox.
1507 \value CT_ComboBox A combo box, like QComboBox.
1508 \omitvalue CT_DialogButtons
1509 \value CT_Q3DockWindow A Q3DockWindow.
1510 \value CT_HeaderSection A header section, like QHeader.
1511 \value CT_LineEdit A line edit, like QLineEdit.
1512 \value CT_Menu A menu, like QMenu.
1513 \value CT_Q3Header A Qt 3 header section, like Q3Header.
1514 \value CT_MenuBar A menu bar, like QMenuBar.
1515 \value CT_MenuBarItem A menu bar item, like the buttons in a QMenuBar.
1516 \value CT_MenuItem A menu item, like QMenuItem.
1517 \value CT_ProgressBar A progress bar, like QProgressBar.
1518 \value CT_PushButton A push button, like QPushButton.
1519 \value CT_RadioButton A radio button, like QRadioButton.
1520 \value CT_SizeGrip A size grip, like QSizeGrip.
1521 \value CT_Slider A slider, like QSlider.
1522 \value CT_ScrollBar A scroll bar, like QScrollBar.
1523 \value CT_SpinBox A spin box, like QSpinBox.
1524 \value CT_Splitter A splitter, like QSplitter.
1525 \value CT_TabBarTab A tab on a tab bar, like QTabBar.
1526 \value CT_TabWidget A tab widget, like QTabWidget.
1527 \value CT_ToolButton A tool button, like QToolButton.
1528 \value CT_GroupBox A group box, like QGroupBox.
1529 \value CT_ItemViewItem An item inside an item view.
1530
1531 \value CT_CustomBase Base value for custom contents types.
1532 Custom values must be greater than this value.
1533
1534 \value CT_MdiControls The minimize, normal, and close button
1535 in the menu bar for a maximized MDI
1536 subwindow.
1537
1538 \sa sizeFromContents()
1539*/
1540
1541/*!
1542 \fn QSize QStyle::sizeFromContents(ContentsType type, const QStyleOption *option, \
1543 const QSize &contentsSize, const QWidget *widget) const
1544
1545 Returns the size of the element described by the specified
1546 \a option and \a type, based on the provided \a contentsSize.
1547
1548 The \a option argument is a pointer to a QStyleOption or one of
1549 its subclasses. The \a option can be cast to the appropriate type
1550 using the qstyleoption_cast() function. The \a widget is an
1551 optional argument and can contain extra information used for
1552 calculating the size.
1553
1554 See the table below for the appropriate \a option casts:
1555
1556 \table
1557 \header \o Contents Type \o QStyleOption Subclass
1558 \row \o \l CT_PushButton \o \l QStyleOptionButton
1559 \row \o \l CT_CheckBox \o \l QStyleOptionButton
1560 \row \o \l CT_RadioButton \o \l QStyleOptionButton
1561 \row \o \l CT_ToolButton \o \l QStyleOptionToolButton
1562 \row \o \l CT_ComboBox \o \l QStyleOptionComboBox
1563 \row \o \l CT_Splitter \o \l QStyleOption
1564 \row \o \l CT_Q3DockWindow \o \l QStyleOptionQ3DockWindow
1565 \row \o \l CT_ProgressBar \o \l QStyleOptionProgressBar
1566 \row \o \l CT_MenuItem \o \l QStyleOptionMenuItem
1567 \endtable
1568
1569 \sa ContentsType QStyleOption
1570*/
1571
1572/*!
1573 \enum QStyle::StyleHint
1574
1575 This enum describes the available style hints. A style hint is a general look
1576 and/or feel hint.
1577
1578 \value SH_EtchDisabledText Disabled text is "etched" as it is on Windows.
1579
1580 \value SH_DitherDisabledText Disabled text is dithered as it is on Motif.
1581
1582 \value SH_GUIStyle The GUI style to use.
1583
1584 \value SH_ScrollBar_ContextMenu Whether or not a scroll bar has a context menu.
1585
1586 \value SH_ScrollBar_MiddleClickAbsolutePosition A boolean value.
1587 If true, middle clicking on a scroll bar causes the slider to
1588 jump to that position. If false, middle clicking is
1589 ignored.
1590
1591 \value SH_ScrollBar_LeftClickAbsolutePosition A boolean value.
1592 If true, left clicking on a scroll bar causes the slider to
1593 jump to that position. If false, left clicking will
1594 behave as appropriate for each control.
1595
1596 \value SH_ScrollBar_ScrollWhenPointerLeavesControl A boolean
1597 value. If true, when clicking a scroll bar SubControl, holding
1598 the mouse button down and moving the pointer outside the
1599 SubControl, the scroll bar continues to scroll. If false, the
1600 scollbar stops scrolling when the pointer leaves the
1601 SubControl.
1602
1603 \value SH_ScrollBar_RollBetweenButtons A boolean value.
1604 If true, when clicking a scroll bar button (SC_ScrollBarAddLine or
1605 SC_ScrollBarSubLine) and dragging over to the opposite button (rolling)
1606 will press the new button and release the old one. When it is false, the
1607 original button is released and nothing happens (like a push button).
1608
1609 \value SH_TabBar_Alignment The alignment for tabs in a
1610 QTabWidget. Possible values are Qt::AlignLeft,
1611 Qt::AlignCenter and Qt::AlignRight.
1612
1613 \value SH_Header_ArrowAlignment The placement of the sorting
1614 indicator may appear in list or table headers. Possible values
1615 are Qt::Left or Qt::Right.
1616
1617 \value SH_Slider_SnapToValue Sliders snap to values while moving,
1618 as they do on Windows.
1619
1620 \value SH_Slider_SloppyKeyEvents Key presses handled in a sloppy
1621 manner, i.e., left on a vertical slider subtracts a line.
1622
1623 \value SH_ProgressDialog_CenterCancelButton Center button on
1624 progress dialogs, like Motif, otherwise right aligned.
1625
1626 \value SH_ProgressDialog_TextLabelAlignment The alignment for text
1627 labels in progress dialogs; Qt::AlignCenter on Windows,
1628 Qt::AlignVCenter otherwise.
1629
1630 \value SH_PrintDialog_RightAlignButtons Right align buttons in
1631 the print dialog, as done on Windows.
1632
1633 \value SH_MainWindow_SpaceBelowMenuBar One or two pixel space between
1634 the menu bar and the dockarea, as done on Windows.
1635
1636 \value SH_FontDialog_SelectAssociatedText Select the text in the
1637 line edit, or when selecting an item from the listbox, or when
1638 the line edit receives focus, as done on Windows.
1639
1640 \value SH_Menu_KeyboardSearch Typing causes a menu to be search
1641 for relevant items, otherwise only mnemnonic is considered.
1642
1643 \value SH_Menu_AllowActiveAndDisabled Allows disabled menu
1644 items to be active.
1645
1646 \value SH_Menu_SpaceActivatesItem Pressing the space bar activates
1647 the item, as done on Motif.
1648
1649 \value SH_Menu_SubMenuPopupDelay The number of milliseconds
1650 to wait before opening a submenu (256 on Windows, 96 on Motif).
1651
1652 \value SH_Menu_Scrollable Whether popup menus must support scrolling.
1653
1654 \value SH_Menu_SloppySubMenus Whether popupmenu's must support
1655 sloppy submenu; as implemented on Mac OS.
1656
1657 \value SH_ScrollView_FrameOnlyAroundContents Whether scrollviews
1658 draw their frame only around contents (like Motif), or around
1659 contents, scroll bars and corner widgets (like Windows).
1660
1661 \value SH_MenuBar_AltKeyNavigation Menu bars items are navigable
1662 by pressing Alt, followed by using the arrow keys to select
1663 the desired item.
1664
1665 \value SH_ComboBox_ListMouseTracking Mouse tracking in combobox
1666 drop-down lists.
1667
1668 \value SH_Menu_MouseTracking Mouse tracking in popup menus.
1669
1670 \value SH_MenuBar_MouseTracking Mouse tracking in menu bars.
1671
1672 \value SH_Menu_FillScreenWithScroll Whether scrolling popups
1673 should fill the screen as they are scrolled.
1674
1675 \value SH_Menu_SelectionWrap Whether popups should allow the selections
1676 to wrap, that is when selection should the next item be the first item.
1677
1678 \value SH_ItemView_ChangeHighlightOnFocus Gray out selected items
1679 when losing focus.
1680
1681 \value SH_Widget_ShareActivation Turn on sharing activation with
1682 floating modeless dialogs.
1683
1684 \value SH_TabBar_SelectMouseType Which type of mouse event should
1685 cause a tab to be selected.
1686
1687 \value SH_Q3ListViewExpand_SelectMouseType Which type of mouse event should
1688 cause a list view expansion to be selected.
1689
1690 \value SH_TabBar_PreferNoArrows Whether a tab bar should suggest a size
1691 to prevent scoll arrows.
1692
1693 \value SH_ComboBox_Popup Allows popups as a combobox drop-down
1694 menu.
1695
1696 \value SH_Workspace_FillSpaceOnMaximize The workspace should
1697 maximize the client area.
1698
1699 \value SH_TitleBar_NoBorder The title bar has no border.
1700
1701 \value SH_ScrollBar_StopMouseOverSlider Obsolete. Use
1702 SH_Slider_StopMouseOverSlider instead.
1703
1704 \value SH_Slider_StopMouseOverSlider Stops auto-repeat when
1705 the slider reaches the mouse position.
1706
1707 \value SH_BlinkCursorWhenTextSelected Whether cursor should blink
1708 when text is selected.
1709
1710 \value SH_RichText_FullWidthSelection Whether richtext selections
1711 should extend to the full width of the document.
1712
1713 \value SH_GroupBox_TextLabelVerticalAlignment How to vertically align a
1714 group box's text label.
1715
1716 \value SH_GroupBox_TextLabelColor How to paint a group box's text label.
1717
1718 \value SH_DialogButtons_DefaultButton Which button gets the
1719 default status in a dialog's button widget.
1720
1721 \value SH_ToolBox_SelectedPageTitleBold Boldness of the selected
1722 page title in a QToolBox.
1723
1724 \value SH_LineEdit_PasswordCharacter The Unicode character to be
1725 used for passwords.
1726
1727 \value SH_Table_GridLineColor The RGB value of the grid for a table.
1728
1729 \value SH_UnderlineShortcut Whether shortcuts are underlined.
1730
1731 \value SH_SpellCheckUnderlineStyle A
1732 QTextCharFormat::UnderlineStyle value that specifies the way
1733 misspelled words should be underlined.
1734
1735 \value SH_SpinBox_AnimateButton Animate a click when up or down is
1736 pressed in a spin box.
1737 \value SH_SpinBox_KeyPressAutoRepeatRate Auto-repeat interval for
1738 spinbox key presses.
1739 \value SH_SpinBox_ClickAutoRepeatRate Auto-repeat interval for
1740 spinbox mouse clicks.
1741 \value SH_SpinBox_ClickAutoRepeatThreshold Auto-repeat threshold for
1742 spinbox mouse clicks.
1743 \value SH_ToolTipLabel_Opacity An integer indicating the opacity for
1744 the tip label, 0 is completely transparent, 255 is completely
1745 opaque.
1746 \value SH_DrawMenuBarSeparator Indicates whether or not the menu bar draws separators.
1747 \value SH_TitleBar_ModifyNotification Indicates if the title bar should show
1748 a '*' for windows that are modified.
1749
1750 \value SH_Button_FocusPolicy The default focus policy for buttons.
1751
1752 \value SH_CustomBase Base value for custom style hints.
1753 Custom values must be greater than this value.
1754
1755 \value SH_MenuBar_DismissOnSecondClick A boolean indicating if a menu in
1756 the menu bar should be dismissed when it is clicked on a second time. (Example:
1757 Clicking and releasing on the File Menu in a menu bar and then
1758 immediately clicking on the File Menu again.)
1759
1760 \value SH_MessageBox_UseBorderForButtonSpacing A boolean indicating what the to
1761 use the border of the buttons (computed as half the button height) for the spacing
1762 of the button in a message box.
1763
1764 \value SH_MessageBox_CenterButtons A boolean indicating whether the buttons in the
1765 message box should be centered or not (see QDialogButtonBox::setCentered()).
1766
1767 \value SH_MessageBox_TextInteractionFlags A boolean indicating if
1768 the text in a message box should allow user interfactions (e.g.
1769 selection) or not.
1770
1771 \value SH_TitleBar_AutoRaise A boolean indicating whether
1772 controls on a title bar ought to update when the mouse is over them.
1773
1774 \value SH_ToolButton_PopupDelay An int indicating the popup delay in milliseconds
1775 for menus attached to tool buttons.
1776
1777 \value SH_FocusFrame_Mask The mask of the focus frame.
1778
1779 \value SH_RubberBand_Mask The mask of the rubber band.
1780
1781 \value SH_WindowFrame_Mask The mask of the window frame.
1782
1783 \value SH_SpinControls_DisableOnBounds Determines if the spin controls will shown
1784 as disabled when reaching the spin range boundary.
1785
1786 \value SH_Dial_BackgroundRole Defines the style's preferred
1787 background role (as QPalette::ColorRole) for a dial widget.
1788
1789 \value SH_ScrollBar_BackgroundMode The background mode for a scroll bar.
1790
1791 \value SH_ComboBox_LayoutDirection The layout direction for the
1792 combo box. By default it should be the same as indicated by the
1793 QStyleOption::direction variable.
1794
1795 \value SH_ItemView_EllipsisLocation The location where ellipses should be
1796 added for item text that is too long to fit in an view item.
1797
1798 \value SH_ItemView_ShowDecorationSelected When an item in an item
1799 view is selected, also highlight the branch or other decoration.
1800
1801 \value SH_ItemView_ActivateItemOnSingleClick Emit the activated signal
1802 when the user single clicks on an item in an item in an item view.
1803 Otherwise the signal is emitted when the user double clicks on an item.
1804
1805 \value SH_Slider_AbsoluteSetButtons Which mouse buttons cause a slider
1806 to set the value to the position clicked on.
1807
1808 \value SH_Slider_PageSetButtons Which mouse buttons cause a slider
1809 to page step the value.
1810
1811 \value SH_TabBar_ElideMode The default eliding style for a tab bar.
1812
1813 \value SH_DialogButtonLayout Controls how buttons are laid out in a QDialogButtonBox, returns a QDialogButtonBox::ButtonLayout enum.
1814
1815 \value SH_WizardStyle Controls the look and feel of a QWizard. Returns a QWizard::WizardStyle enum.
1816
1817 \value SH_FormLayoutWrapPolicy Provides a default for how rows are wrapped in a QFormLayout. Returns a QFormLayout::RowWrapPolicy enum.
1818 \value SH_FormLayoutFieldGrowthPolicy Provides a default for how fields can grow in a QFormLayout. Returns a QFormLayout::FieldGrowthPolicy enum.
1819 \value SH_FormLayoutFormAlignment Provides a default for how a QFormLayout aligns its contents within the available space. Returns a Qt::Alignment enum.
1820 \value SH_FormLayoutLabelAlignment Provides a default for how a QFormLayout aligns labels within the available space. Returns a Qt::Alignment enum.
1821
1822 \value SH_ItemView_ArrowKeysNavigateIntoChildren Controls whether the tree view will select the first child when it is exapanded and the right arrow key is pressed.
1823 \value SH_ComboBox_PopupFrameStyle The frame style used when drawing a combobox popup menu.
1824
1825 \value SH_DialogButtonBox_ButtonsHaveIcons Indicates whether or not StandardButtons in QDialogButtonBox should have icons or not.
1826 \value SH_ItemView_MovementWithoutUpdatingSelection The item view is able to indicate a current item without changing the selection.
1827 \value SH_ToolTip_Mask The mask of a tool tip.
1828
1829 \value SH_FocusFrame_AboveWidget The FocusFrame is stacked above the widget that it is "focusing on".
1830
1831 \value SH_TextControl_FocusIndicatorTextCharFormat Specifies the text format used to highlight focused anchors in rich text
1832 documents displayed for example in QTextBrowser. The format has to be a QTextCharFormat returned in the variant of the
1833 QStyleHintReturnVariant return value. The QTextFormat::OutlinePen property is used for the outline and QTextFormat::BackgroundBrush
1834 for the background of the highlighted area.
1835
1836 \value SH_Menu_FlashTriggeredItem Flash triggered item.
1837 \value SH_Menu_FadeOutOnHide Fade out the menu instead of hiding it immediately.
1838
1839 \value SH_TabWidget_DefaultTabPosition Default position of the tab bar in a tab widget.
1840
1841 \value SH_ToolBar_Movable Determines if the tool bar is movable by default.
1842
1843 \value SH_ItemView_PaintAlternatingRowColorsForEmptyArea Whether QTreeView paints alternating row colors for the area that does not have any items.
1844
1845 \value SH_Menu_Mask The mask for a popup menu.
1846
1847 \value SH_ItemView_DrawDelegateFrame Determines if there should be a frame for a delegate widget.
1848
1849 \value SH_TabBar_CloseButtonPosition Determines the position of the close button on a tab in a tab bar.
1850
1851 \value SH_DockWidget_ButtonsHaveFrame Determines if dockwidget buttons should have frames. Default is true.
1852
1853 \omitvalue SH_UnderlineAccelerator
1854
1855 \sa styleHint()
1856*/
1857
1858/*!
1859 \fn int QStyle::styleHint(StyleHint hint, const QStyleOption *option, \
1860 const QWidget *widget, QStyleHintReturn *returnData) const
1861
1862 Returns an integer representing the specified style \a hint for
1863 the given \a widget described by the provided style \a option.
1864
1865 Note that currently, the \a returnData and \a widget parameters
1866 are not used; they are provided for future enhancement. In
1867 addition, the \a option parameter is used only in case of the
1868 SH_ComboBox_Popup, SH_ComboBox_LayoutDirection, and
1869 SH_GroupBox_TextLabelColor style hints.
1870*/
1871
1872/*!
1873 \enum QStyle::StandardPixmap
1874
1875 This enum describes the available standard pixmaps. A standard pixmap is a pixmap that
1876 can follow some existing GUI style or guideline.
1877
1878 \value SP_TitleBarMinButton Minimize button on title bars (e.g.,
1879 in QWorkspace).
1880 \value SP_TitleBarMenuButton Menu button on a title bar.
1881 \value SP_TitleBarMaxButton Maximize button on title bars.
1882 \value SP_TitleBarCloseButton Close button on title bars.
1883 \value SP_TitleBarNormalButton Normal (restore) button on title bars.
1884 \value SP_TitleBarShadeButton Shade button on title bars.
1885 \value SP_TitleBarUnshadeButton Unshade button on title bars.
1886 \value SP_TitleBarContextHelpButton The Context help button on title bars.
1887 \value SP_MessageBoxInformation The "information" icon.
1888 \value SP_MessageBoxWarning The "warning" icon.
1889 \value SP_MessageBoxCritical The "critical" icon.
1890 \value SP_MessageBoxQuestion The "question" icon.
1891 \value SP_DesktopIcon The "desktop" icon.
1892 \value SP_TrashIcon The "trash" icon.
1893 \value SP_ComputerIcon The "My computer" icon.
1894 \value SP_DriveFDIcon The floppy icon.
1895 \value SP_DriveHDIcon The harddrive icon.
1896 \value SP_DriveCDIcon The CD icon.
1897 \value SP_DriveDVDIcon The DVD icon.
1898 \value SP_DriveNetIcon The network icon.
1899 \value SP_DirHomeIcon The home directory icon.
1900 \value SP_DirOpenIcon The open directory icon.
1901 \value SP_DirClosedIcon The closed directory icon.
1902 \value SP_DirIcon The directory icon.
1903 \value SP_DirLinkIcon The link to directory icon.
1904 \value SP_FileIcon The file icon.
1905 \value SP_FileLinkIcon The link to file icon.
1906 \value SP_FileDialogStart The "start" icon in a file dialog.
1907 \value SP_FileDialogEnd The "end" icon in a file dialog.
1908 \value SP_FileDialogToParent The "parent directory" icon in a file dialog.
1909 \value SP_FileDialogNewFolder The "create new folder" icon in a file dialog.
1910 \value SP_FileDialogDetailedView The detailed view icon in a file dialog.
1911 \value SP_FileDialogInfoView The file info icon in a file dialog.
1912 \value SP_FileDialogContentsView The contents view icon in a file dialog.
1913 \value SP_FileDialogListView The list view icon in a file dialog.
1914 \value SP_FileDialogBack The back arrow in a file dialog.
1915 \value SP_DockWidgetCloseButton Close button on dock windows (see also QDockWidget).
1916 \value SP_ToolBarHorizontalExtensionButton Extension button for horizontal toolbars.
1917 \value SP_ToolBarVerticalExtensionButton Extension button for vertical toolbars.
1918 \value SP_DialogOkButton Icon for a standard OK button in a QDialogButtonBox.
1919 \value SP_DialogCancelButton Icon for a standard Cancel button in a QDialogButtonBox.
1920 \value SP_DialogHelpButton Icon for a standard Help button in a QDialogButtonBox.
1921 \value SP_DialogOpenButton Icon for a standard Open button in a QDialogButtonBox.
1922 \value SP_DialogSaveButton Icon for a standard Save button in a QDialogButtonBox.
1923 \value SP_DialogCloseButton Icon for a standard Close button in a QDialogButtonBox.
1924 \value SP_DialogApplyButton Icon for a standard Apply button in a QDialogButtonBox.
1925 \value SP_DialogResetButton Icon for a standard Reset button in a QDialogButtonBox.
1926 \value SP_DialogDiscardButton Icon for a standard Discard button in a QDialogButtonBox.
1927 \value SP_DialogYesButton Icon for a standard Yes button in a QDialogButtonBox.
1928 \value SP_DialogNoButton Icon for a standard No button in a QDialogButtonBox.
1929 \value SP_ArrowUp Icon arrow pointing up.
1930 \value SP_ArrowDown Icon arrow pointing down.
1931 \value SP_ArrowLeft Icon arrow pointing left.
1932 \value SP_ArrowRight Icon arrow pointing right.
1933 \value SP_ArrowBack Equivalent to SP_ArrowLeft when the current layout direction is Qt::LeftToRight, otherwise SP_ArrowRight.
1934 \value SP_ArrowForward Equivalent to SP_ArrowRight when the current layout direction is Qt::LeftToRight, otherwise SP_ArrowLeft.
1935 \value SP_CommandLink Icon used to indicate a Vista style command link glyph.
1936 \value SP_VistaShield Icon used to indicate UAC prompts on Windows Vista. This will return a null pixmap or icon on all other platforms.
1937 \value SP_BrowserReload Icon indicating that the current page should be reloaded.
1938 \value SP_BrowserStop Icon indicating that the page loading should stop.
1939 \value SP_MediaPlay Icon indicating that media should begin playback.
1940 \value SP_MediaStop Icon indicating that media should stop playback.
1941 \value SP_MediaPause Icon indicating that media should pause playback.
1942 \value SP_MediaSkipForward Icon indicating that media should skip forward.
1943 \value SP_MediaSkipBackward Icon indicating that media should skip backward.
1944 \value SP_MediaSeekForward Icon indicating that media should seek forward.
1945 \value SP_MediaSeekBackward Icon indicating that media should seek backward.
1946 \value SP_MediaVolume Icon indicating a volume control.
1947 \value SP_MediaVolumeMuted Icon indicating a muted volume control.
1948 \value SP_CustomBase Base value for custom standard pixmaps;
1949 custom values must be greater than this value.
1950
1951 \sa standardPixmap() standardIcon()
1952*/
1953
1954/*###
1955 \enum QStyle::IconMode
1956
1957 This enum represents the effects performed on a pixmap to achieve a
1958 GUI style's perferred way of representing the image in different
1959 states.
1960
1961 \value IM_Disabled A disabled pixmap (drawn on disabled widgets)
1962 \value IM_Active An active pixmap (drawn on active tool buttons and menu items)
1963 \value IM_CustomBase Base value for custom PixmapTypes; custom
1964 values must be greater than this value
1965
1966 \sa generatedIconPixmap()
1967*/
1968
1969/*!
1970 \fn QPixmap QStyle::generatedIconPixmap(QIcon::Mode iconMode,
1971 const QPixmap &pixmap, const QStyleOption *option) const
1972
1973 Returns a copy of the given \a pixmap, styled to conform to the
1974 specified \a iconMode and taking into account the palette
1975 specified by \a option.
1976
1977 The \a option parameter can pass extra information, but
1978 it must contain a palette.
1979
1980 Note that not all pixmaps will conform, in which case the returned
1981 pixmap is a plain copy.
1982
1983 \sa QIcon
1984*/
1985
1986/*!
1987 \fn QPixmap QStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option, \
1988 const QWidget *widget) const
1989
1990 \obsolete
1991 Returns a pixmap for the given \a standardPixmap.
1992
1993 A standard pixmap is a pixmap that can follow some existing GUI
1994 style or guideline. The \a option argument can be used to pass
1995 extra information required when defining the appropriate
1996 pixmap. The \a widget argument is optional and can also be used to
1997 aid the determination of the pixmap.
1998
1999 Developers calling standardPixmap() should instead call standardIcon()
2000 Developers who re-implemented standardPixmap() should instead re-implement
2001 the slot standardIconImplementation().
2002
2003 \sa standardIcon()
2004*/
2005
2006
2007/*!
2008 \fn QRect QStyle::visualRect(Qt::LayoutDirection direction, const QRect &boundingRectangle, const QRect &logicalRectangle)
2009
2010 Returns the given \a logicalRectangle converted to screen
2011 coordinates based on the specified \a direction. The \a
2012 boundingRectangle is used when performing the translation.
2013
2014 This function is provided to support right-to-left desktops, and
2015 is typically used in implementations of the subControlRect()
2016 function.
2017
2018 \sa QWidget::layoutDirection
2019*/
2020QRect QStyle::visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
2021{
2022 if (direction == Qt::LeftToRight)
2023 return logicalRect;
2024 QRect rect = logicalRect;
2025 rect.translate(2 * (boundingRect.right() - logicalRect.right()) +
2026 logicalRect.width() - boundingRect.width(), 0);
2027 return rect;
2028}
2029
2030/*!
2031 \fn QPoint QStyle::visualPos(Qt::LayoutDirection direction, const QRect &boundingRectangle, const QPoint &logicalPosition)
2032
2033 Returns the given \a logicalPosition converted to screen
2034 coordinates based on the specified \a direction. The \a
2035 boundingRectangle is used when performing the translation.
2036
2037 \sa QWidget::layoutDirection
2038*/
2039QPoint QStyle::visualPos(Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)
2040{
2041 if (direction == Qt::LeftToRight)
2042 return logicalPos;
2043 return QPoint(boundingRect.right() - logicalPos.x(), logicalPos.y());
2044}
2045
2046/*!
2047 Returns a new rectangle of the specified \a size that is aligned to the given \a
2048 rectangle according to the specified \a alignment and \a direction.
2049 */
2050QRect QStyle::alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)
2051{
2052 alignment = visualAlignment(direction, alignment);
2053 int x = rectangle.x();
2054 int y = rectangle.y();
2055 int w = size.width();
2056 int h = size.height();
2057 if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter)
2058 y += rectangle.size().height()/2 - h/2;
2059 else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom)
2060 y += rectangle.size().height() - h;
2061 if ((alignment & Qt::AlignRight) == Qt::AlignRight)
2062 x += rectangle.size().width() - w;
2063 else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter)
2064 x += rectangle.size().width()/2 - w/2;
2065 return QRect(x, y, w, h);
2066}
2067
2068/*!
2069 Transforms an \a alignment of Qt::AlignLeft or Qt::AlignRight
2070 without Qt::AlignAbsolute into Qt::AlignLeft or Qt::AlignRight with
2071 Qt::AlignAbsolute according to the layout \a direction. The other
2072 alignment flags are left untouched.
2073
2074 If no horizontal alignment was specified, the function returns the
2075 default alignment for the given layout \a direction.
2076
2077 QWidget::layoutDirection
2078*/
2079Qt::Alignment QStyle::visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
2080{
2081 if (!(alignment & Qt::AlignHorizontal_Mask))
2082 alignment |= Qt::AlignLeft;
2083 if ((alignment & Qt::AlignAbsolute) == 0 && (alignment & (Qt::AlignLeft | Qt::AlignRight))) {
2084 if (direction == Qt::RightToLeft)
2085 alignment ^= (Qt::AlignLeft | Qt::AlignRight);
2086 alignment |= Qt::AlignAbsolute;
2087 }
2088 return alignment;
2089}
2090
2091/*!
2092 Converts the given \a logicalValue to a pixel position. The \a min
2093 parameter maps to 0, \a max maps to \a span and other values are
2094 distributed evenly in-between.
2095
2096 This function can handle the entire integer range without
2097 overflow, providing that \a span is less than 4096.
2098
2099 By default, this function assumes that the maximum value is on the
2100 right for horizontal items and on the bottom for vertical items.
2101 Set the \a upsideDown parameter to true to reverse this behavior.
2102
2103 \sa sliderValueFromPosition()
2104*/
2105
2106int QStyle::sliderPositionFromValue(int min, int max, int logicalValue, int span, bool upsideDown)
2107{
2108 if (span <= 0 || logicalValue < min || max <= min)
2109 return 0;
2110 if (logicalValue > max)
2111 return upsideDown ? span : min;
2112
2113 uint range = max - min;
2114 uint p = upsideDown ? max - logicalValue : logicalValue - min;
2115
2116 if (range > (uint)INT_MAX/4096) {
2117 double dpos = (double(p))/(double(range)/span);
2118 return int(dpos);
2119 } else if (range > (uint)span) {
2120 return (2 * p * span + range) / (2*range);
2121 } else {
2122 uint div = span / range;
2123 uint mod = span % range;
2124 return p * div + (2 * p * mod + range) / (2 * range);
2125 }
2126 // equiv. to (p * span) / range + 0.5
2127 // no overflow because of this implicit assumption:
2128 // span <= 4096
2129}
2130
2131/*!
2132 \fn int QStyle::sliderValueFromPosition(int min, int max, int position, int span, bool upsideDown)
2133
2134 Converts the given pixel \a position to a logical value. 0 maps to
2135 the \a min parameter, \a span maps to \a max and other values are
2136 distributed evenly in-between.
2137
2138 This function can handle the entire integer range without
2139 overflow.
2140
2141 By default, this function assumes that the maximum value is on the
2142 right for horizontal items and on the bottom for vertical
2143 items. Set the \a upsideDown parameter to true to reverse this
2144 behavior.
2145
2146 \sa sliderPositionFromValue()
2147*/
2148
2149int QStyle::sliderValueFromPosition(int min, int max, int pos, int span, bool upsideDown)
2150{
2151 if (span <= 0 || pos <= 0)
2152 return upsideDown ? max : min;
2153 if (pos >= span)
2154 return upsideDown ? min : max;
2155
2156 uint range = max - min;
2157
2158 if ((uint)span > range) {
2159 int tmp = (2 * pos * range + span) / (2 * span);
2160 return upsideDown ? max - tmp : tmp + min;
2161 } else {
2162 uint div = range / span;
2163 uint mod = range % span;
2164 int tmp = pos * div + (2 * pos * mod + span) / (2 * span);
2165 return upsideDown ? max - tmp : tmp + min;
2166 }
2167 // equiv. to min + (pos*range)/span + 0.5
2168 // no overflow because of this implicit assumption:
2169 // pos <= span < sqrt(INT_MAX+0.0625)+0.25 ~ sqrt(INT_MAX)
2170}
2171
2172/*### \fn void QStyle::drawItem(QPainter *p, const QRect &r,
2173 int flags, const QColorGroup &colorgroup, bool enabled,
2174 const QString &text, int len = -1,
2175 const QColor *penColor = 0) const
2176
2177 Use one of the drawItem() overloads that takes a QPalette instead
2178 of a QColorGroup.
2179*/
2180
2181/*### \fn void QStyle::drawItem(QPainter *p, const QRect &r,
2182 int flags, const QColorGroup colorgroup, bool enabled,
2183 const QPixmap &pixmap,
2184 const QColor *penColor = 0) const
2185
2186 Use one of the drawItem() overloads that takes a QPalette instead
2187 of a QColorGroup.
2188*/
2189
2190/*### \fn void QStyle::drawItem(QPainter *p, const QRect &r,
2191 int flags, const QColorGroup colorgroup, bool enabled,
2192 const QPixmap *pixmap,
2193 const QString &text, int len = -1,
2194 const QColor *penColor = 0) const
2195
2196 Use one of the drawItem() overloads that takes a QPalette instead
2197 of a QColorGroup.
2198*/
2199
2200/*!
2201 Returns the style's standard palette.
2202
2203 Note that on systems that support system colors, the style's
2204 standard palette is not used. In particular, the Windows XP,
2205 Vista, and Mac styles do not use the standard palette, but make
2206 use of native theme engines. With these styles, you should not set
2207 the palette with QApplication::setStandardPalette().
2208
2209 */
2210QPalette QStyle::standardPalette() const
2211{
2212#ifdef Q_WS_X11
2213 QColor background;
2214 if (QX11Info::appDepth() > 8)
2215 background = QColor(0xd4, 0xd0, 0xc8); // win 2000 grey
2216 else
2217 background = QColor(192, 192, 192);
2218#else
2219 QColor background(0xd4, 0xd0, 0xc8); // win 2000 grey
2220#endif
2221 QColor light(background.lighter());
2222 QColor dark(background.darker());
2223 QColor mid(Qt::gray);
2224 QPalette palette(Qt::black, background, light, dark, mid, Qt::black, Qt::white);
2225 palette.setBrush(QPalette::Disabled, QPalette::WindowText, dark);
2226 palette.setBrush(QPalette::Disabled, QPalette::Text, dark);
2227 palette.setBrush(QPalette::Disabled, QPalette::ButtonText, dark);
2228 palette.setBrush(QPalette::Disabled, QPalette::Base, background);
2229 return palette;
2230}
2231
2232/*!
2233 \since 4.1
2234
2235 Returns an icon for the given \a standardIcon.
2236
2237 The \a standardIcon is a standard pixmap which can follow some
2238 existing GUI style or guideline. The \a option argument can be
2239 used to pass extra information required when defining the
2240 appropriate icon. The \a widget argument is optional and can also
2241 be used to aid the determination of the icon.
2242
2243 \warning Because of binary compatibility constraints, this
2244 function is not virtual. If you want to provide your own icons in
2245 a QStyle subclass, reimplement the standardIconImplementation()
2246 slot in your subclass instead. The standardIcon() function will
2247 dynamically detect the slot and call it.
2248
2249 \sa standardIconImplementation(), standardPixmap()
2250*/
2251QIcon QStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option,
2252 const QWidget *widget) const
2253{
2254 QIcon result;
2255 // ### Qt 4.1: invokeMethod should accept const functions, to avoid this dirty cast
2256 QMetaObject::invokeMethod(const_cast<QStyle*>(this),
2257 "standardIconImplementation", Qt::DirectConnection,
2258 Q_RETURN_ARG(QIcon, result),
2259 Q_ARG(StandardPixmap, standardIcon),
2260 Q_ARG(const QStyleOption*, option),
2261 Q_ARG(const QWidget*, widget));
2262 return result;
2263}
2264
2265/*!
2266 \since 4.1
2267
2268 Returns an icon for the given \a standardIcon.
2269
2270 Reimplement this slot to provide your own icons in a QStyle
2271 subclass; because of binary compatibility constraints, the
2272 standardIcon() function (introduced in Qt 4.1) is not
2273 virtual. Instead, standardIcon() will dynamically detect and call
2274 \e this slot. The default implementation simply calls the
2275 standardPixmap() function with the given parameters.
2276
2277 The \a standardIcon is a standard pixmap which can follow some
2278 existing GUI style or guideline. The \a option argument can be
2279 used to pass extra information required when defining the
2280 appropriate icon. The \a widget argument is optional and can also
2281 be used to aid the determination of the icon.
2282
2283 \sa standardIcon()
2284*/
2285QIcon QStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
2286 const QWidget *widget) const
2287{
2288 return QIcon(standardPixmap(standardIcon, option, widget));
2289}
2290
2291/*!
2292 \since 4.3
2293
2294 Returns the spacing that should be used between \a control1 and
2295 \a control2 in a layout. \a orientation specifies whether the
2296 controls are laid out side by side or stacked vertically. The \a
2297 option parameter can be used to pass extra information about the
2298 parent widget. The \a widget parameter is optional and can also
2299 be used if \a option is 0.
2300
2301 This function is called by the layout system. It is used only if
2302 PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
2303 negative value.
2304
2305 For binary compatibility reasons, this function is not virtual.
2306 If you want to specify custom layout spacings in a QStyle
2307 subclass, implement a slot called layoutSpacingImplementation().
2308 QStyle will discover the slot at run-time (using Qt's
2309 \l{meta-object system}) and direct all calls to layoutSpacing()
2310 to layoutSpacingImplementation().
2311
2312 \sa combinedLayoutSpacing(), layoutSpacingImplementation()
2313*/
2314int QStyle::layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
2315 Qt::Orientation orientation, const QStyleOption *option,
2316 const QWidget *widget) const
2317{
2318 Q_D(const QStyle);
2319 if (d->layoutSpacingIndex == -1) {
2320 d->layoutSpacingIndex = metaObject()->indexOfMethod(
2321 "layoutSpacingImplementation(QSizePolicy::ControlType,QSizePolicy::ControlType,"
2322 "Qt::Orientation,const QStyleOption*,const QWidget*)"
2323 );
2324 }
2325 if (d->layoutSpacingIndex < 0)
2326 return -1;
2327 int result = -1;
2328 void *param[] = {&result, &control1, &control2, &orientation, &option, &widget};
2329
2330 const_cast<QStyle *>(this)->qt_metacall(QMetaObject::InvokeMetaMethod,
2331 d->layoutSpacingIndex, param);
2332 return result;
2333}
2334
2335/*!
2336 \since 4.3
2337
2338 Returns the spacing that should be used between \a controls1 and
2339 \a controls2 in a layout. \a orientation specifies whether the
2340 controls are laid out side by side or stacked vertically. The \a
2341 option parameter can be used to pass extra information about the
2342 parent widget. The \a widget parameter is optional and can also
2343 be used if \a option is 0.
2344
2345 \a controls1 and \a controls2 are OR-combination of zero or more
2346 \l{QSizePolicy::ControlTypes}{control types}.
2347
2348 This function is called by the layout system. It is used only if
2349 PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
2350 negative value.
2351
2352 \sa layoutSpacing(), layoutSpacingImplementation()
2353*/
2354int QStyle::combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
2355 QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,
2356 QStyleOption *option, QWidget *widget) const
2357{
2358 QSizePolicy::ControlType array1[MaxBits];
2359 QSizePolicy::ControlType array2[MaxBits];
2360 int count1 = unpackControlTypes(controls1, array1);
2361 int count2 = unpackControlTypes(controls2, array2);
2362 int result = -1;
2363
2364 for (int i = 0; i < count1; ++i) {
2365 for (int j = 0; j < count2; ++j) {
2366 int spacing = layoutSpacing(array1[i], array2[j], orientation, option, widget);
2367 result = qMax(spacing, result);
2368 }
2369 }
2370 return result;
2371}
2372
2373/*!
2374 \since 4.3
2375
2376 This slot is called by layoutSpacing() to determine the spacing
2377 that should be used between \a control1 and \a control2 in a
2378 layout. \a orientation specifies whether the controls are laid
2379 out side by side or stacked vertically. The \a option parameter
2380 can be used to pass extra information about the parent widget.
2381 The \a widget parameter is optional and can also be used if \a
2382 option is 0.
2383
2384 If you want to provide custom layout spacings in a QStyle
2385 subclass, implement a slot called layoutSpacingImplementation()
2386 in your subclass. Be aware that this slot will only be called if
2387 PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
2388 negative value.
2389
2390 The default implementation returns -1.
2391
2392 \sa layoutSpacing(), combinedLayoutSpacing()
2393*/
2394int QStyle::layoutSpacingImplementation(QSizePolicy::ControlType /* control1 */,