1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this 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 have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
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 |
|
---|
62 | QT_BEGIN_NAMESPACE
|
---|
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);
|
---|
75 | QPolygonF calcLines(const QStyleOptionSlider *dial);
|
---|
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>
|
---|
107 | struct QConcatenable<HexString<T> >
|
---|
108 | {
|
---|
109 | typedef HexString<T> type;
|
---|
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); }
|
---|
113 | };
|
---|
114 |
|
---|
115 | QT_END_NAMESPACE
|
---|
116 |
|
---|
117 | #endif // QSTYLEHELPER_P_H
|
---|