Qt 4.8
qstyle.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
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 
61 
62 static const int MaxBits = 8 * sizeof(QSizePolicy::ControlType);
63 
64 static 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 
338  : QObject(*new QStylePrivate)
339 {
340  Q_D(QStyle);
341  d->proxyStyle = this;
342 }
343 
353  : QObject(dd)
354 {
355  Q_D(QStyle);
356  d->proxyStyle = this;
357 }
358 
363 {
364 }
365 
390 void QStyle::polish(QWidget * /* widget */)
391 {
392 }
393 
409 void QStyle::unpolish(QWidget * /* widget */)
410 {
411 }
412 
419 void QStyle::polish(QApplication * /* app */)
420 {
421 }
422 
430 {
431 }
432 
445 void QStyle::polish(QPalette & /* pal */)
446 {
447 }
448 
470 QRect QStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled,
471  const QString &text) const
472 {
473  QRect result;
474  int x, y, w, h;
475  rect.getRect(&x, &y, &w, &h);
476  if (!text.isEmpty()) {
477  result = metrics.boundingRect(x, y, w, h, alignment, text);
478  if (!enabled && proxy()->styleHint(SH_EtchDisabledText)) {
479  result.setWidth(result.width()+1);
480  result.setHeight(result.height()+1);
481  }
482  } else {
483  result = QRect(x, y, w, h);
484  }
485  return result;
486 }
487 
497 QRect QStyle::itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const
498 {
499  QRect result;
500  int x, y, w, h;
501  rect.getRect(&x, &y, &w, &h);
502  if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter)
503  y += h/2 - pixmap.height()/2;
504  else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom)
505  y += h - pixmap.height();
506  if ((alignment & Qt::AlignRight) == Qt::AlignRight)
507  x += w - pixmap.width();
508  else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter)
509  x += w/2 - pixmap.width()/2;
510  else if ((alignment & Qt::AlignLeft) != Qt::AlignLeft && QApplication::isRightToLeft())
511  x += w - pixmap.width();
512  result = QRect(x, y, pixmap.width(), pixmap.height());
513  return result;
514 }
515 
532 void QStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
533  bool enabled, const QString& text, QPalette::ColorRole textRole) const
534 {
535  if (text.isEmpty())
536  return;
537  QPen savedPen;
538  if (textRole != QPalette::NoRole) {
539  savedPen = painter->pen();
540  painter->setPen(QPen(pal.brush(textRole), savedPen.widthF()));
541  }
542  if (!enabled) {
544  QRect br;
545  painter->drawText(rect, alignment, text, &br);
546  painter->fillRect(br, QBrush(painter->background().color(), Qt::Dense5Pattern));
547  return;
548  } else if (proxy()->styleHint(SH_EtchDisabledText)) {
549  QPen pen = painter->pen();
550  painter->setPen(pal.light().color());
551  painter->drawText(rect.adjusted(1, 1, 1, 1), alignment, text);
552  painter->setPen(pen);
553  }
554  }
555  painter->drawText(rect, alignment, text);
556  if (textRole != QPalette::NoRole)
557  painter->setPen(savedPen);
558 }
559 
570 void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
571  const QPixmap &pixmap) const
572 {
573  QRect aligned = alignedRect(QApplication::layoutDirection(), QFlag(alignment), pixmap.size(), rect);
574  QRect inter = aligned.intersected(rect);
575 
576  painter->drawPixmap(inter.x(), inter.y(), pixmap, inter.x() - aligned.x(), inter.y() - aligned.y(), inter.width(), inter.height());
577 }
578 
2088 {
2089  if (direction == Qt::LeftToRight)
2090  return logicalRect;
2091  QRect rect = logicalRect;
2092  rect.translate(2 * (boundingRect.right() - logicalRect.right()) +
2093  logicalRect.width() - boundingRect.width(), 0);
2094  return rect;
2095 }
2096 
2110 {
2111  if (direction == Qt::LeftToRight)
2112  return logicalPos;
2113  return QPoint(boundingRect.right() - logicalPos.x(), logicalPos.y());
2114 }
2115 
2120 QRect QStyle::alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)
2121 {
2122  alignment = visualAlignment(direction, alignment);
2123  int x = rectangle.x();
2124  int y = rectangle.y();
2125  int w = size.width();
2126  int h = size.height();
2127  if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter)
2128  y += rectangle.size().height()/2 - h/2;
2129  else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom)
2130  y += rectangle.size().height() - h;
2131  if ((alignment & Qt::AlignRight) == Qt::AlignRight)
2132  x += rectangle.size().width() - w;
2133  else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter)
2134  x += rectangle.size().width()/2 - w/2;
2135  return QRect(x, y, w, h);
2136 }
2137 
2149 Qt::Alignment QStyle::visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
2150 {
2151  if (!(alignment & Qt::AlignHorizontal_Mask))
2152  alignment |= Qt::AlignLeft;
2153  if ((alignment & Qt::AlignAbsolute) == 0 && (alignment & (Qt::AlignLeft | Qt::AlignRight))) {
2154  if (direction == Qt::RightToLeft)
2155  alignment ^= (Qt::AlignLeft | Qt::AlignRight);
2156  alignment |= Qt::AlignAbsolute;
2157  }
2158  return alignment;
2159 }
2160 
2176 int QStyle::sliderPositionFromValue(int min, int max, int logicalValue, int span, bool upsideDown)
2177 {
2178  if (span <= 0 || logicalValue < min || max <= min)
2179  return 0;
2180  if (logicalValue > max)
2181  return upsideDown ? span : min;
2182 
2183  uint range = max - min;
2184  uint p = upsideDown ? max - logicalValue : logicalValue - min;
2185 
2186  if (range > (uint)INT_MAX/4096) {
2187  double dpos = (double(p))/(double(range)/span);
2188  return int(dpos);
2189  } else if (range > (uint)span) {
2190  return (2 * p * span + range) / (2*range);
2191  } else {
2192  uint div = span / range;
2193  uint mod = span % range;
2194  return p * div + (2 * p * mod + range) / (2 * range);
2195  }
2196  // equiv. to (p * span) / range + 0.5
2197  // no overflow because of this implicit assumption:
2198  // span <= 4096
2199 }
2200 
2222 int QStyle::sliderValueFromPosition(int min, int max, int pos, int span, bool upsideDown)
2223 {
2224  if (span <= 0 || pos <= 0)
2225  return upsideDown ? max : min;
2226  if (pos >= span)
2227  return upsideDown ? min : max;
2228 
2229  uint range = max - min;
2230 
2231  if ((uint)span > range) {
2232  int tmp = (2 * pos * range + span) / (2 * span);
2233  return upsideDown ? max - tmp : tmp + min;
2234  } else {
2235  uint div = range / span;
2236  uint mod = range % span;
2237  int tmp = pos * div + (2 * pos * mod + span) / (2 * span);
2238  return upsideDown ? max - tmp : tmp + min;
2239  }
2240  // equiv. to min + (pos*range)/span + 0.5
2241  // no overflow because of this implicit assumption:
2242  // pos <= span < sqrt(INT_MAX+0.0625)+0.25 ~ sqrt(INT_MAX)
2243 }
2244 
2245 /*### \fn void QStyle::drawItem(QPainter *p, const QRect &r,
2246  int flags, const QColorGroup &colorgroup, bool enabled,
2247  const QString &text, int len = -1,
2248  const QColor *penColor = 0) const
2249 
2250  Use one of the drawItem() overloads that takes a QPalette instead
2251  of a QColorGroup.
2252 */
2253 
2254 /*### \fn void QStyle::drawItem(QPainter *p, const QRect &r,
2255  int flags, const QColorGroup colorgroup, bool enabled,
2256  const QPixmap &pixmap,
2257  const QColor *penColor = 0) const
2258 
2259  Use one of the drawItem() overloads that takes a QPalette instead
2260  of a QColorGroup.
2261 */
2262 
2263 /*### \fn void QStyle::drawItem(QPainter *p, const QRect &r,
2264  int flags, const QColorGroup colorgroup, bool enabled,
2265  const QPixmap *pixmap,
2266  const QString &text, int len = -1,
2267  const QColor *penColor = 0) const
2268 
2269  Use one of the drawItem() overloads that takes a QPalette instead
2270  of a QColorGroup.
2271 */
2272 
2284 {
2285 #ifdef Q_WS_X11
2286  QColor background;
2287  if (QX11Info::appDepth() > 8)
2288  background = QColor(0xd4, 0xd0, 0xc8); // win 2000 grey
2289  else
2290  background = QColor(192, 192, 192);
2291 #else
2292  QColor background(0xd4, 0xd0, 0xc8); // win 2000 grey
2293 #endif
2294  QColor light(background.lighter());
2295  QColor dark(background.darker());
2296  QColor mid(Qt::gray);
2297  QPalette palette(Qt::black, background, light, dark, mid, Qt::black, Qt::white);
2299  palette.setBrush(QPalette::Disabled, QPalette::Text, dark);
2301  palette.setBrush(QPalette::Disabled, QPalette::Base, background);
2302  return palette;
2303 }
2304 
2328  const QWidget *widget) const
2329 {
2330  QIcon result;
2331  // ### Qt 4.1: invokeMethod should accept const functions, to avoid this dirty cast
2332  QMetaObject::invokeMethod(const_cast<QStyle*>(this),
2333  "standardIconImplementation", Qt::DirectConnection,
2334  Q_RETURN_ARG(QIcon, result),
2335  Q_ARG(StandardPixmap, standardIcon),
2336  Q_ARG(const QStyleOption*, option),
2337  Q_ARG(const QWidget*, widget));
2338  return result;
2339 }
2340 
2364  const QWidget *widget) const
2365 {
2366  return QIcon(standardPixmap(standardIcon, option, widget));
2367 }
2368 
2396  Qt::Orientation orientation, const QStyleOption *option,
2397  const QWidget *widget) const
2398 {
2399  Q_D(const QStyle);
2400  if (d->layoutSpacingIndex == -1) {
2401  d->layoutSpacingIndex = metaObject()->indexOfMethod(
2402  "layoutSpacingImplementation(QSizePolicy::ControlType,QSizePolicy::ControlType,"
2403  "Qt::Orientation,const QStyleOption*,const QWidget*)"
2404  );
2405  }
2406  if (d->layoutSpacingIndex < 0)
2407  return -1;
2408  int result = -1;
2409  void *param[] = {&result, &control1, &control2, &orientation, &option, &widget};
2410 
2411  const_cast<QStyle *>(this)->qt_metacall(QMetaObject::InvokeMetaMethod,
2412  d->layoutSpacingIndex, param);
2413  return result;
2414 }
2415 
2438 int QStyle::combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
2439  QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,
2440  QStyleOption *option, QWidget *widget) const
2441 {
2444  int count1 = unpackControlTypes(controls1, array1);
2445  int count2 = unpackControlTypes(controls2, array2);
2446  int result = -1;
2447 
2448  for (int i = 0; i < count1; ++i) {
2449  for (int j = 0; j < count2; ++j) {
2450  int spacing = layoutSpacing(array1[i], array2[j], orientation, option, widget);
2451  result = qMax(spacing, result);
2452  }
2453  }
2454  return result;
2455 }
2456 
2482  QSizePolicy::ControlType /* control2 */,
2483  Qt::Orientation /*orientation*/,
2484  const QStyleOption * /* option */,
2485  const QWidget * /* widget */) const
2486 {
2487  return -1;
2488 }
2489 
2491 #include <QDebug>
2493 
2494 #if !defined(QT_NO_DEBUG_STREAM)
2496 {
2497 #if !defined(QT_NO_DEBUG)
2498  debug << "QStyle::State(";
2499 
2500  QStringList states;
2501  if (state & QStyle::State_Active) states << QLatin1String("Active");
2502  if (state & QStyle::State_AutoRaise) states << QLatin1String("AutoRaise");
2503  if (state & QStyle::State_Bottom) states << QLatin1String("Bottom");
2504  if (state & QStyle::State_Children) states << QLatin1String("Children");
2505  if (state & QStyle::State_DownArrow) states << QLatin1String("DownArrow");
2506  if (state & QStyle::State_Editing) states << QLatin1String("Editing");
2507  if (state & QStyle::State_Enabled) states << QLatin1String("Enabled");
2508  if (state & QStyle::State_FocusAtBorder) states << QLatin1String("FocusAtBorder");
2509  if (state & QStyle::State_HasFocus) states << QLatin1String("HasFocus");
2510  if (state & QStyle::State_Horizontal) states << QLatin1String("Horizontal");
2511  if (state & QStyle::State_Item) states << QLatin1String("Item");
2512  if (state & QStyle::State_KeyboardFocusChange) states << QLatin1String("KeyboardFocusChange");
2513  if (state & QStyle::State_MouseOver) states << QLatin1String("MouseOver");
2514  if (state & QStyle::State_NoChange) states << QLatin1String("NoChange");
2515  if (state & QStyle::State_Off) states << QLatin1String("Off");
2516  if (state & QStyle::State_On) states << QLatin1String("On");
2517  if (state & QStyle::State_Open) states << QLatin1String("Open");
2518  if (state & QStyle::State_Raised) states << QLatin1String("Raised");
2519  if (state & QStyle::State_ReadOnly) states << QLatin1String("ReadOnly");
2520  if (state & QStyle::State_Selected) states << QLatin1String("Selected");
2521  if (state & QStyle::State_Sibling) states << QLatin1String("Sibling");
2522  if (state & QStyle::State_Sunken) states << QLatin1String("Sunken");
2523  if (state & QStyle::State_Top) states << QLatin1String("Top");
2524  if (state & QStyle::State_UpArrow) states << QLatin1String("UpArrow");
2525 
2526  qSort(states);
2527  debug << states.join(QLatin1String(" | "));
2528  debug << ')';
2529 #else
2530  Q_UNUSED(state);
2531 #endif
2532  return debug;
2533 }
2534 #endif
2535 
2546 const QStyle * QStyle::proxy() const
2547 {
2548  Q_D(const QStyle);
2549  return d->proxyStyle;
2550 }
2551 
2552 /* \internal
2553 
2554  This function sets the base style that style calls will be
2555  redirected to. Note that ownership is not transferred.
2556 */
2558 {
2559  Q_D(QStyle);
2560  d->proxyStyle = style;
2561 }
2562 
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:62
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
static QRect alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)
Returns a new rectangle of the specified size that is aligned to the given rectangle according to the...
Definition: qstyle.cpp:2120
virtual void unpolish(QWidget *)
Uninitialize the given {widget}&#39;s appearance.
Definition: qstyle.cpp:409
static Qt::LayoutDirection layoutDirection()
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::ControlType *array)
Definition: qstyle.cpp:64
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
QPointer< QWidget > widget
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
static QPoint visualPos(Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)
Returns the given logicalPosition converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2109
const QBrush & background() const
Returns the current background brush.
Definition: qpainter.cpp:2482
The QFlag class is a helper data type for QFlags.
Definition: qglobal.h:2289
static int appDepth(int screen=-1)
Returns the color depth (bits per pixel) used by the application on the given screen.
virtual QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
Returns the area within the given rectangle in which to draw the specified pixmap according to the de...
Definition: qstyle.cpp:497
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
static const int MaxBits
Definition: qstyle.cpp:62
#define Q_ARG(type, data)
Definition: qobjectdefs.h:246
#define QT_END_INCLUDE_NAMESPACE
This macro is equivalent to QT_BEGIN_NAMESPACE.
Definition: qglobal.h:92
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
Draws the given text in the specified rectangle using the provided painter and palette.
Definition: qstyle.cpp:532
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: qrect.h:481
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
static int sliderPositionFromValue(int min, int max, int val, int space, bool upsideDown=false)
Converts the given logicalValue to a pixel position.
Definition: qstyle.cpp:2176
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
StandardPixmap
This enum describes the available standard pixmaps.
Definition: qstyle.h:755
int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option=0, const QWidget *widget=0) const
Returns the spacing that should be used between control1 and control2 in a layout.
Definition: qstyle.cpp:2395
virtual ~QStyle()
Destroys the style object.
Definition: qstyle.cpp:362
QRect boundingRect(QChar) const
Returns the rectangle that is covered by ink if character ch were to be drawn at the origin of the co...
static const QRectF boundingRect(const QPointF *points, int pointCount)
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
int width() const
Returns the width.
Definition: qsize.h:126
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
Definition: qpainter.cpp:6231
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
Definition: qstyle.cpp:2327
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette...
Definition: qpalette.h:206
virtual QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const
Returns the area within the given rectangle in which to draw the provided text according to the speci...
Definition: qstyle.cpp:470
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
virtual QPalette standardPalette() const
Returns the style&#39;s standard palette.
Definition: qstyle.cpp:2283
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
LayoutDirection
Definition: qnamespace.h:1580
unsigned int uint
Definition: qglobal.h:996
#define Q_RETURN_ARG(type, data)
Definition: qobjectdefs.h:247
void qSort(RandomAccessIterator start, RandomAccessIterator end)
Definition: qalgorithms.h:177
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition: qpalette.cpp:874
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
QString join(const QString &sep) const
Joins all the string list&#39;s strings into a single string with each element separated by the given sep...
Definition: qstringlist.h:162
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Draws the given pixmap in the specified rectangle, according to the specified alignment, using the provided painter.
Definition: qstyle.cpp:570
static Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
Transforms an alignment of Qt::AlignLeft or Qt::AlignRight without Qt::AlignAbsolute into Qt::AlignLe...
Definition: qstyle.cpp:2149
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
QStyle()
Constructs a style object.
Definition: qstyle.cpp:337
State
Definition: qaudio.h:59
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int indexOfMethod(const char *method) const
Finds method and returns its index; otherwise returns -1.
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
int height() const
Returns the height.
Definition: qsize.h:129
qreal widthF() const
Returns the pen width with floating point precision.
Definition: qpen.cpp:645
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void getRect(int *x, int *y, int *w, int *h) const
Extracts the position of the rectangle&#39;s top-left corner to *x and *y, and its dimensions to *width a...
Definition: qrect.h:392
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
#define QT_BEGIN_INCLUDE_NAMESPACE
This macro is equivalent to QT_END_NAMESPACE.
Definition: qglobal.h:91
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
Definition: qcolor.h:298
void setProxy(QStyle *style)
Definition: qstyle.cpp:2557
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
Orientation
Definition: qnamespace.h:174
static bool isRightToLeft()
Returns true if the application&#39;s layout direction is Qt::RightToLeft; otherwise returns false...
Definition: qapplication.h:233
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
static int sliderValueFromPosition(int min, int max, int pos, int space, bool upsideDown=false)
Converts the given pixel position to a logical value.
Definition: qstyle.cpp:2222
virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt=0, const QWidget *widget=0) const =0
int combinedLayoutSpacing(QSizePolicy::ControlTypes controls1, QSizePolicy::ControlTypes controls2, Qt::Orientation orientation, QStyleOption *option=0, QWidget *widget=0) const
Returns the spacing that should be used between controls1 and controls2 in a layout.
Definition: qstyle.cpp:2438
#define INT_MAX
#define enabled
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
Definition: qstyle.cpp:2363
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
int layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option=0, const QWidget *widget=0) const
This slot is called by layoutSpacing() to determine the spacing that should be used between control1 ...
Definition: qstyle.cpp:2481
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
#define text
Definition: qobjectdefs.h:80
QDebug operator<<(QDebug debug, QStyle::State state)
Definition: qstyle.cpp:2495
Qt::LayoutDirection direction
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60