Qt 4.8
qt-4.8.6
src
gui
styles
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
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
typedef
QString
ConvertTo
;
114
};
115
116
QT_END_NAMESPACE
117
118
#endif // QSTYLEHELPER_P_H
QConcatenable< HexString< T > >::type
HexString< T > type
Definition:
qstylehelper_p.h:109
QPainter
The QPainter class performs low-level painting on widgets and other paint devices.
Definition:
qpainter.h:86
HexString
Definition:
qstylehelper_p.h:86
qreal
double qreal
Definition:
qglobal.h:1193
HexString::HexString
HexString(const T t)
Definition:
qstylehelper_p.h:88
c
unsigned char c[8]
Definition:
qnumeric_p.h:62
QT_END_NAMESPACE
#define QT_END_NAMESPACE
This macro expands to.
Definition:
qglobal.h:90
QStyleHelper::uniqueName
QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)
Definition:
qstylehelper.cpp:62
QPointF
The QPointF class defines a point in the plane using floating point precision.
Definition:
qpoint.h:214
QConcatenable< HexString< T > >::ConvertTo
QString ConvertTo
Definition:
qstylehelper_p.h:113
QString
The QString class provides a Unicode character string.
Definition:
qstring.h:83
HexString::val
const T val
Definition:
qstylehelper_p.h:102
HexString::write
void write(QChar *&dest) const
Definition:
qstylehelper_p.h:92
QChar
The QChar class provides a 16-bit Unicode character.
Definition:
qchar.h:72
right
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
QConcatenable< HexString< T > >::appendTo
static void appendTo(const HexString< T > &str, QChar *&out)
Definition:
qstylehelper_p.h:112
QStyleHelper
Definition:
qstylehelper.cpp:60
QT_BEGIN_NAMESPACE
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition:
qglobal.h:89
QStyleHelper::drawDial
void drawDial(const QStyleOptionSlider *option, QPainter *painter)
Definition:
qstylehelper.cpp:213
QStyleHelper::calcBigLineSize
int calcBigLineSize(int radius)
Definition:
qstylehelper.cpp:104
QStyleOption
The QStyleOption class stores the parameters used by QStyle functions.
Definition:
qstyleoption.h:67
QPolygonF
The QPolygonF class provides a vector of points using floating point precision.
Definition:
qpolygon.h:134
uint
unsigned int uint
Definition:
qglobal.h:996
QStyleHelper::dpiScaled
qreal dpiScaled(qreal value)
Definition:
qstylehelper.cpp:82
QStyleHelper::angle
qreal angle(const QPointF &p1, const QPointF &p2)
Definition:
qstylehelper.cpp:137
QStyleHelper::calcLines
QPolygonF calcLines(const QStyleOptionSlider *dial)
Definition:
qstylehelper.cpp:169
ushort
unsigned short ushort
Definition:
qglobal.h:995
key
int key
Definition:
qkeysequence.cpp:395
QRect
The QRect class defines a rectangle in the plane using integer precision.
Definition:
qrect.h:58
QPixmap
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition:
qpixmap.h:71
QStyleHelper::drawBorderPixmap
void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect, int left, int top, int right, int bottom)
Definition:
qstylehelper.cpp:323
QStyleOptionSlider
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition:
qstyleoption.h:701
QSize
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition:
qsize.h:53
QConcatenable
Definition:
qstringbuilder.h:109
left
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
QConcatenable< HexString< T > >::size
static int size(const HexString< T > &)
Definition:
qstylehelper_p.h:111
Qt 4.8 Source Code Browser