0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the QtGui module of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
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 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
#include "qstylepainter.h"
|
|
43 |
|
|
44 |
QT_BEGIN_NAMESPACE
|
|
45 |
|
|
46 |
/*!
|
|
47 |
\class QStylePainter
|
|
48 |
|
|
49 |
\brief The QStylePainter class is a convenience class for drawing QStyle
|
|
50 |
elements inside a widget.
|
|
51 |
|
|
52 |
\ingroup appearance
|
|
53 |
\ingroup painting
|
|
54 |
|
|
55 |
QStylePainter extends QPainter with a set of high-level \c
|
|
56 |
draw...() functions implemented on top of QStyle's API. The
|
|
57 |
advantage of using QStylePainter is that the parameter lists get
|
|
58 |
considerably shorter. Whereas a QStyle object must be able to
|
|
59 |
draw on any widget using any painter (because the application
|
|
60 |
normally has one QStyle object shared by all widget), a
|
|
61 |
QStylePainter is initialized with a widget, eliminating the need
|
|
62 |
to specify the QWidget, the QPainter, and the QStyle for every
|
|
63 |
function call.
|
|
64 |
|
|
65 |
Example using QStyle directly:
|
|
66 |
|
|
67 |
\snippet doc/src/snippets/styles/styles.cpp 1
|
|
68 |
|
|
69 |
Example using QStylePainter:
|
|
70 |
|
|
71 |
\snippet doc/src/snippets/styles/styles.cpp 0
|
|
72 |
\snippet doc/src/snippets/styles/styles.cpp 4
|
|
73 |
\snippet doc/src/snippets/styles/styles.cpp 6
|
|
74 |
|
|
75 |
\sa QStyle, QStyleOption
|
|
76 |
*/
|
|
77 |
|
|
78 |
/*!
|
|
79 |
\fn QStylePainter::QStylePainter()
|
|
80 |
|
|
81 |
Constructs a QStylePainter.
|
|
82 |
*/
|
|
83 |
|
|
84 |
/*!
|
|
85 |
\fn QStylePainter::QStylePainter(QWidget *widget)
|
|
86 |
|
|
87 |
Construct a QStylePainter using widget \a widget for its paint device.
|
|
88 |
*/
|
|
89 |
|
|
90 |
/*!
|
|
91 |
\fn QStylePainter::QStylePainter(QPaintDevice *pd, QWidget *widget)
|
|
92 |
|
|
93 |
Construct a QStylePainter using \a pd for its paint device, and
|
|
94 |
attributes from \a widget.
|
|
95 |
*/
|
|
96 |
|
|
97 |
|
|
98 |
/*!
|
|
99 |
\fn bool QStylePainter::begin(QWidget *widget)
|
|
100 |
|
|
101 |
Begin painting operations on the specified \a widget.
|
|
102 |
Returns true if the painter is ready to use; otherwise returns false.
|
|
103 |
|
|
104 |
This is automatically called by the constructor that takes a QWidget.
|
|
105 |
*/
|
|
106 |
|
|
107 |
/*!
|
|
108 |
\fn bool QStylePainter::begin(QPaintDevice *pd, QWidget *widget)
|
|
109 |
\overload
|
|
110 |
|
|
111 |
Begin painting operations on paint device \a pd as if it was \a
|
|
112 |
widget.
|
|
113 |
|
|
114 |
This is automatically called by the constructor that
|
|
115 |
takes a QPaintDevice and a QWidget.
|
|
116 |
*/
|
|
117 |
|
|
118 |
|
|
119 |
/*!
|
|
120 |
\fn void QStylePainter::drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption &option)
|
|
121 |
|
|
122 |
Use the widget's style to draw a primitive element \a pe specified by QStyleOption \a option.
|
|
123 |
|
|
124 |
\sa QStyle::drawPrimitive()
|
|
125 |
*/
|
|
126 |
|
|
127 |
/*!
|
|
128 |
\fn void QStylePainter::drawControl(QStyle::ControlElement ce, const QStyleOption &option)
|
|
129 |
|
|
130 |
Use the widget's style to draw a control element \a ce specified by QStyleOption \a option.
|
|
131 |
|
|
132 |
\sa QStyle::drawControl()
|
|
133 |
*/
|
|
134 |
|
|
135 |
/*!
|
|
136 |
\fn void QStylePainter::drawComplexControl(QStyle::ComplexControl cc,
|
|
137 |
const QStyleOptionComplex &option)
|
|
138 |
|
|
139 |
Use the widget's style to draw a complex control \a cc specified by the
|
|
140 |
QStyleOptionComplex \a option.
|
|
141 |
|
|
142 |
\sa QStyle::drawComplexControl()
|
|
143 |
*/
|
|
144 |
|
|
145 |
/*!
|
|
146 |
\fn void QStylePainter::drawItemText(const QRect &rect, int flags, const QPalette &pal,
|
|
147 |
bool enabled, const QString &text,
|
|
148 |
QPalette::ColorRole textRole = QPalette::NoRole)
|
|
149 |
|
|
150 |
Draws the \a text in rectangle \a rect and palette \a pal.
|
|
151 |
The text is aligned and wrapped according to \a
|
|
152 |
flags.
|
|
153 |
|
|
154 |
The pen color is specified with \a textRole. The \a enabled bool
|
|
155 |
indicates whether or not the item is enabled; when reimplementing
|
|
156 |
this bool should influence how the item is drawn.
|
|
157 |
|
|
158 |
\sa QStyle::drawItemText(), Qt::Alignment
|
|
159 |
*/
|
|
160 |
|
|
161 |
/*!
|
|
162 |
\fn void QStylePainter::drawItemPixmap(const QRect &rect, int flags, const QPixmap &pixmap)
|
|
163 |
|
|
164 |
Draws the \a pixmap in rectangle \a rect.
|
|
165 |
The pixmap is aligned according to \a flags.
|
|
166 |
|
|
167 |
\sa QStyle::drawItemPixmap(), Qt::Alignment
|
|
168 |
*/
|
|
169 |
|
|
170 |
/*!
|
|
171 |
\fn QStyle *QStylePainter::style() const
|
|
172 |
|
|
173 |
Return the current style used by the QStylePainter.
|
|
174 |
*/
|
|
175 |
|
|
176 |
QT_END_NAMESPACE
|