Qt 4.8
qstylehelper_p.h
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 <QtCore/qglobal.h>
43 #include <QtCore/qpoint.h>
44 #include <QtCore/qstring.h>
45 #include <QtGui/qpolygon.h>
46 #include <QtCore/qstringbuilder.h>
47 
48 #ifndef QSTYLEHELPER_P_H
49 #define QSTYLEHELPER_P_H
50 
51 //
52 // W A R N I N G
53 // -------------
54 //
55 // This file is not part of the Qt API. It exists purely as an
56 // implementation detail. This header file may change from version to
57 // version without notice, or even be removed.
58 //
59 // We mean it.
60 //
61 
63 
64 class QPainter;
65 class QPixmap;
66 class QStyleOptionSlider;
67 class QStyleOption;
68 
69 namespace QStyleHelper
70 {
71  QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size);
72  qreal dpiScaled(qreal value);
73 #ifndef QT_NO_DIAL
74  qreal angle(const QPointF &p1, const QPointF &p2);
76  int calcBigLineSize(int radius);
77  void drawDial(const QStyleOptionSlider *dial, QPainter *painter);
78 #endif //QT_NO_DIAL
79  void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect,
80  int left = 0, int top = 0, int right = 0,
81  int bottom = 0);
82 }
83 
84 // internal helper. Converts an integer value to an unique string token
85 template <typename T>
86  struct HexString
87 {
88  inline HexString(const T t)
89  : val(t)
90  {}
91 
92  inline void write(QChar *&dest) const
93  {
94  const ushort hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
95  const char *c = reinterpret_cast<const char *>(&val);
96  for (uint i = 0; i < sizeof(T); ++i) {
97  *dest++ = hexChars[*c & 0xf];
98  *dest++ = hexChars[(*c & 0xf0) >> 4];
99  ++c;
100  }
101  }
102  const T val;
103 };
104 
105 // specialization to enable fast concatenating of our string tokens to a string
106 template <typename T>
108 {
110  enum { ExactSize = true };
111  static int size(const HexString<T> &) { return sizeof(T) * 2; }
112  static inline void appendTo(const HexString<T> &str, QChar *&out) { str.write(out); }
114 };
115 
117 
118 #endif // QSTYLEHELPER_P_H
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
double qreal
Definition: qglobal.h:1193
HexString(const T t)
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QString class provides a Unicode character string.
Definition: qstring.h:83
const T val
void write(QChar *&dest) const
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
static void appendTo(const HexString< T > &str, QChar *&out)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void drawDial(const QStyleOptionSlider *option, QPainter *painter)
int calcBigLineSize(int radius)
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
The QPolygonF class provides a vector of points using floating point precision.
Definition: qpolygon.h:134
unsigned int uint
Definition: qglobal.h:996
qreal dpiScaled(qreal value)
qreal angle(const QPointF &p1, const QPointF &p2)
QPolygonF calcLines(const QStyleOptionSlider *dial)
unsigned short ushort
Definition: qglobal.h:995
int key
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect, int left, int top, int right, int bottom)
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
static int size(const HexString< T > &)