styles/qdrawutil.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 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 "qdrawutil.h" -
43#include "qbitmap.h" -
44#include "qpixmapcache.h" -
45#include "qpainter.h" -
46#include "qpalette.h" -
47#include <private/qpaintengineex_p.h> -
48#include <qvarlengtharray.h> -
49#include <qmath.h> -
50#include <private/qhexstring_p.h> -
51 -
52QT_BEGIN_NAMESPACE -
53 -
54/*! -
55 \headerfile <qdrawutil.h> -
56 \title Drawing Utility Functions -
57 -
58 \sa QPainter -
59*/ -
60 -
61/*! -
62 \fn void qDrawShadeLine(QPainter *painter, int x1, int y1, int x2, int y2, -
63 const QPalette &palette, bool sunken, -
64 int lineWidth, int midLineWidth) -
65 \relates <qdrawutil.h> -
66 -
67 Draws a horizontal (\a y1 == \a y2) or vertical (\a x1 == \a x2) -
68 shaded line using the given \a painter. Note that nothing is -
69 drawn if \a y1 != \a y2 and \a x1 != \a x2 (i.e. the line is -
70 neither horizontal nor vertical). -
71 -
72 The provided \a palette specifies the shading colors (\l -
73 {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l -
74 {QPalette::mid()}{middle} colors). The given \a lineWidth -
75 specifies the line width for each of the lines; it is not the -
76 total line width. The given \a midLineWidth specifies the width of -
77 a middle line drawn in the QPalette::mid() color. -
78 -
79 The line appears sunken if \a sunken is true, otherwise raised. -
80 -
81 \warning This function does not look at QWidget::style() or -
82 QApplication::style(). Use the drawing functions in QStyle to -
83 make widgets that follow the current GUI style. -
84 -
85 -
86 Alternatively you can use a QFrame widget and apply the -
87 QFrame::setFrameStyle() function to display a shaded line: -
88 -
89 \snippet code/src_gui_painting_qdrawutil.cpp 0 -
90 -
91 \sa qDrawShadeRect(), qDrawShadePanel(), QStyle -
92*/ -
93 -
94void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2, -
95 const QPalette &pal, bool sunken, -
96 int lineWidth, int midLineWidth) -
97{ -
98 if (!(p && lineWidth >= 0 && midLineWidth >= 0)) {
never evaluated: p
never evaluated: lineWidth >= 0
never evaluated: midLineWidth >= 0
0
99 qWarning("qDrawShadeLine: Invalid parameters");
never executed (the execution status of this line is deduced): QMessageLogger("styles/qdrawutil.cpp", 99, __PRETTY_FUNCTION__).warning("qDrawShadeLine: Invalid parameters");
-
100 return;
never executed: return;
0
101 } -
102 int tlw = lineWidth*2 + midLineWidth; // total line width
never executed (the execution status of this line is deduced): int tlw = lineWidth*2 + midLineWidth;
-
103 QPen oldPen = p->pen(); // save pen
never executed (the execution status of this line is deduced): QPen oldPen = p->pen();
-
104 if (sunken)
never evaluated: sunken
0
105 p->setPen(pal.color(QPalette::Dark));
never executed: p->setPen(pal.color(QPalette::Dark));
0
106 else -
107 p->setPen(pal.light().color());
never executed: p->setPen(pal.light().color());
0
108 QPolygon a;
never executed (the execution status of this line is deduced): QPolygon a;
-
109 int i;
never executed (the execution status of this line is deduced): int i;
-
110 if (y1 == y2) { // horizontal line
never evaluated: y1 == y2
0
111 int y = y1 - tlw/2;
never executed (the execution status of this line is deduced): int y = y1 - tlw/2;
-
112 if (x1 > x2) { // swap x1 and x2
never evaluated: x1 > x2
0
113 int t = x1;
never executed (the execution status of this line is deduced): int t = x1;
-
114 x1 = x2;
never executed (the execution status of this line is deduced): x1 = x2;
-
115 x2 = t;
never executed (the execution status of this line is deduced): x2 = t;
-
116 }
never executed: }
0
117 x2--;
never executed (the execution status of this line is deduced): x2--;
-
118 for (i=0; i<lineWidth; i++) { // draw top shadow
never evaluated: i<lineWidth
0
119 a.setPoints(3, x1+i, y+tlw-1-i,
never executed (the execution status of this line is deduced): a.setPoints(3, x1+i, y+tlw-1-i,
-
120 x1+i, y+i,
never executed (the execution status of this line is deduced): x1+i, y+i,
-
121 x2-i, y+i);
never executed (the execution status of this line is deduced): x2-i, y+i);
-
122 p->drawPolyline(a);
never executed (the execution status of this line is deduced): p->drawPolyline(a);
-
123 }
never executed: }
0
124 if (midLineWidth > 0) {
never evaluated: midLineWidth > 0
0
125 p->setPen(pal.mid().color());
never executed (the execution status of this line is deduced): p->setPen(pal.mid().color());
-
126 for (i=0; i<midLineWidth; i++) // draw lines in the middle
never evaluated: i<midLineWidth
0
127 p->drawLine(x1+lineWidth, y+lineWidth+i,
never executed: p->drawLine(x1+lineWidth, y+lineWidth+i, x2-lineWidth, y+lineWidth+i);
0
128 x2-lineWidth, y+lineWidth+i);
never executed: p->drawLine(x1+lineWidth, y+lineWidth+i, x2-lineWidth, y+lineWidth+i);
0
129 }
never executed: }
0
130 if (sunken)
never evaluated: sunken
0
131 p->setPen(pal.light().color());
never executed: p->setPen(pal.light().color());
0
132 else -
133 p->setPen(pal.dark().color());
never executed: p->setPen(pal.dark().color());
0
134 for (i=0; i<lineWidth; i++) { // draw bottom shadow
never evaluated: i<lineWidth
0
135 a.setPoints(3, x1+i, y+tlw-i-1,
never executed (the execution status of this line is deduced): a.setPoints(3, x1+i, y+tlw-i-1,
-
136 x2-i, y+tlw-i-1,
never executed (the execution status of this line is deduced): x2-i, y+tlw-i-1,
-
137 x2-i, y+i+1);
never executed (the execution status of this line is deduced): x2-i, y+i+1);
-
138 p->drawPolyline(a);
never executed (the execution status of this line is deduced): p->drawPolyline(a);
-
139 }
never executed: }
0
140 }
never executed: }
0
141 else if (x1 == x2) { // vertical line
never evaluated: x1 == x2
0
142 int x = x1 - tlw/2;
never executed (the execution status of this line is deduced): int x = x1 - tlw/2;
-
143 if (y1 > y2) { // swap y1 and y2
never evaluated: y1 > y2
0
144 int t = y1;
never executed (the execution status of this line is deduced): int t = y1;
-
145 y1 = y2;
never executed (the execution status of this line is deduced): y1 = y2;
-
146 y2 = t;
never executed (the execution status of this line is deduced): y2 = t;
-
147 }
never executed: }
0
148 y2--;
never executed (the execution status of this line is deduced): y2--;
-
149 for (i=0; i<lineWidth; i++) { // draw left shadow
never evaluated: i<lineWidth
0
150 a.setPoints(3, x+i, y2,
never executed (the execution status of this line is deduced): a.setPoints(3, x+i, y2,
-
151 x+i, y1+i,
never executed (the execution status of this line is deduced): x+i, y1+i,
-
152 x+tlw-1, y1+i);
never executed (the execution status of this line is deduced): x+tlw-1, y1+i);
-
153 p->drawPolyline(a);
never executed (the execution status of this line is deduced): p->drawPolyline(a);
-
154 }
never executed: }
0
155 if (midLineWidth > 0) {
never evaluated: midLineWidth > 0
0
156 p->setPen(pal.mid().color());
never executed (the execution status of this line is deduced): p->setPen(pal.mid().color());
-
157 for (i=0; i<midLineWidth; i++) // draw lines in the middle
never evaluated: i<midLineWidth
0
158 p->drawLine(x+lineWidth+i, y1+lineWidth, x+lineWidth+i, y2);
never executed: p->drawLine(x+lineWidth+i, y1+lineWidth, x+lineWidth+i, y2);
0
159 }
never executed: }
0
160 if (sunken)
never evaluated: sunken
0
161 p->setPen(pal.light().color());
never executed: p->setPen(pal.light().color());
0
162 else -
163 p->setPen(pal.dark().color());
never executed: p->setPen(pal.dark().color());
0
164 for (i=0; i<lineWidth; i++) { // draw right shadow
never evaluated: i<lineWidth
0
165 a.setPoints(3, x+lineWidth, y2-i,
never executed (the execution status of this line is deduced): a.setPoints(3, x+lineWidth, y2-i,
-
166 x+tlw-i-1, y2-i,
never executed (the execution status of this line is deduced): x+tlw-i-1, y2-i,
-
167 x+tlw-i-1, y1+lineWidth);
never executed (the execution status of this line is deduced): x+tlw-i-1, y1+lineWidth);
-
168 p->drawPolyline(a);
never executed (the execution status of this line is deduced): p->drawPolyline(a);
-
169 }
never executed: }
0
170 }
never executed: }
0
171 p->setPen(oldPen);
never executed (the execution status of this line is deduced): p->setPen(oldPen);
-
172}
never executed: }
0
173 -
174/*! -
175 \fn void qDrawShadeRect(QPainter *painter, int x, int y, int width, int height, -
176 const QPalette &palette, bool sunken, -
177 int lineWidth, int midLineWidth, -
178 const QBrush *fill) -
179 \relates <qdrawutil.h> -
180 -
181 Draws the shaded rectangle beginning at (\a x, \a y) with the -
182 given \a width and \a height using the provided \a painter. -
183 -
184 The provide \a palette specifies the shading colors (\l -
185 {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l -
186 {QPalette::mid()}{middle} colors. The given \a lineWidth -
187 specifies the line width for each of the lines; it is not the -
188 total line width. The \a midLineWidth specifies the width of a -
189 middle line drawn in the QPalette::mid() color. The rectangle's -
190 interior is filled with the \a fill brush unless \a fill is 0. -
191 -
192 The rectangle appears sunken if \a sunken is true, otherwise -
193 raised. -
194 -
195 \warning This function does not look at QWidget::style() or -
196 QApplication::style(). Use the drawing functions in QStyle to make -
197 widgets that follow the current GUI style. -
198 -
199 Alternatively you can use a QFrame widget and apply the -
200 QFrame::setFrameStyle() function to display a shaded rectangle: -
201 -
202 \snippet code/src_gui_painting_qdrawutil.cpp 1 -
203 -
204 \sa qDrawShadeLine(), qDrawShadePanel(), qDrawPlainRect(), QStyle -
205*/ -
206 -
207void qDrawShadeRect(QPainter *p, int x, int y, int w, int h, -
208 const QPalette &pal, bool sunken, -
209 int lineWidth, int midLineWidth, -
210 const QBrush *fill) -
211{ -
212 if (w == 0 || h == 0)
partially evaluated: w == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:54
partially evaluated: h == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:54
0-54
213 return;
never executed: return;
0
214 if (! (w > 0 && h > 0 && lineWidth >= 0 && midLineWidth >= 0)) {
partially evaluated: w > 0
TRUEFALSE
yes
Evaluation Count:54
no
Evaluation Count:0
partially evaluated: h > 0
TRUEFALSE
yes
Evaluation Count:54
no
Evaluation Count:0
partially evaluated: lineWidth >= 0
TRUEFALSE
yes
Evaluation Count:54
no
Evaluation Count:0
partially evaluated: midLineWidth >= 0
TRUEFALSE
yes
Evaluation Count:54
no
Evaluation Count:0
0-54
215 qWarning("qDrawShadeRect: Invalid parameters");
never executed (the execution status of this line is deduced): QMessageLogger("styles/qdrawutil.cpp", 215, __PRETTY_FUNCTION__).warning("qDrawShadeRect: Invalid parameters");
-
216 return;
never executed: return;
0
217 } -
218 QPen oldPen = p->pen();
executed (the execution status of this line is deduced): QPen oldPen = p->pen();
-
219 if (sunken)
evaluated: sunken
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:12
12-42
220 p->setPen(pal.dark().color());
executed: p->setPen(pal.dark().color());
Execution Count:42
42
221 else -
222 p->setPen(pal.light().color());
executed: p->setPen(pal.light().color());
Execution Count:12
12
223 int x1=x, y1=y, x2=x+w-1, y2=y+h-1;
executed (the execution status of this line is deduced): int x1=x, y1=y, x2=x+w-1, y2=y+h-1;
-
224 -
225 if (lineWidth == 1 && midLineWidth == 0) {// standard shade rectangle
evaluated: lineWidth == 1
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:13
partially evaluated: midLineWidth == 0
TRUEFALSE
yes
Evaluation Count:41
no
Evaluation Count:0
0-41
226 p->drawRect(x1, y1, w-2, h-2);
executed (the execution status of this line is deduced): p->drawRect(x1, y1, w-2, h-2);
-
227 if (sunken)
evaluated: sunken
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:2
2-39
228 p->setPen(pal.light().color());
executed: p->setPen(pal.light().color());
Execution Count:39
39
229 else -
230 p->setPen(pal.dark().color());
executed: p->setPen(pal.dark().color());
Execution Count:2
2
231 QLineF lines[4] = { QLineF(x1+1, y1+1, x2-2, y1+1),
executed (the execution status of this line is deduced): QLineF lines[4] = { QLineF(x1+1, y1+1, x2-2, y1+1),
-
232 QLineF(x1+1, y1+2, x1+1, y2-2),
executed (the execution status of this line is deduced): QLineF(x1+1, y1+2, x1+1, y2-2),
-
233 QLineF(x1, y2, x2, y2),
executed (the execution status of this line is deduced): QLineF(x1, y2, x2, y2),
-
234 QLineF(x2,y1, x2,y2-1) };
executed (the execution status of this line is deduced): QLineF(x2,y1, x2,y2-1) };
-
235 p->drawLines(lines, 4); // draw bottom/right lines
executed (the execution status of this line is deduced): p->drawLines(lines, 4);
-
236 } else { // more complicated
executed: }
Execution Count:41
41
237 int m = lineWidth+midLineWidth;
executed (the execution status of this line is deduced): int m = lineWidth+midLineWidth;
-
238 int i, j=0, k=m;
executed (the execution status of this line is deduced): int i, j=0, k=m;
-
239 for (i=0; i<lineWidth; i++) { // draw top shadow
partially evaluated: i<lineWidth
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
240 QLineF lines[4] = { QLineF(x1+i, y2-i, x1+i, y1+i),
never executed (the execution status of this line is deduced): QLineF lines[4] = { QLineF(x1+i, y2-i, x1+i, y1+i),
-
241 QLineF(x1+i, y1+i, x2-i, y1+i),
never executed (the execution status of this line is deduced): QLineF(x1+i, y1+i, x2-i, y1+i),
-
242 QLineF(x1+k, y2-k, x2-k, y2-k),
never executed (the execution status of this line is deduced): QLineF(x1+k, y2-k, x2-k, y2-k),
-
243 QLineF(x2-k, y2-k, x2-k, y1+k) };
never executed (the execution status of this line is deduced): QLineF(x2-k, y2-k, x2-k, y1+k) };
-
244 p->drawLines(lines, 4);
never executed (the execution status of this line is deduced): p->drawLines(lines, 4);
-
245 k++;
never executed (the execution status of this line is deduced): k++;
-
246 }
never executed: }
0
247 p->setPen(pal.mid().color());
executed (the execution status of this line is deduced): p->setPen(pal.mid().color());
-
248 j = lineWidth*2;
executed (the execution status of this line is deduced): j = lineWidth*2;
-
249 for (i=0; i<midLineWidth; i++) { // draw lines in the middle
evaluated: i<midLineWidth
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:13
10-13
250 p->drawRect(x1+lineWidth+i, y1+lineWidth+i, w-j-1, h-j-1);
executed (the execution status of this line is deduced): p->drawRect(x1+lineWidth+i, y1+lineWidth+i, w-j-1, h-j-1);
-
251 j += 2;
executed (the execution status of this line is deduced): j += 2;
-
252 }
executed: }
Execution Count:10
10
253 if (sunken)
evaluated: sunken
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:10
3-10
254 p->setPen(pal.light().color());
executed: p->setPen(pal.light().color());
Execution Count:3
3
255 else -
256 p->setPen(pal.dark().color());
executed: p->setPen(pal.dark().color());
Execution Count:10
10
257 k = m;
executed (the execution status of this line is deduced): k = m;
-
258 for (i=0; i<lineWidth; i++) { // draw bottom shadow
partially evaluated: i<lineWidth
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
259 QLineF lines[4] = { QLineF(x1+1+i, y2-i, x2-i, y2-i),
never executed (the execution status of this line is deduced): QLineF lines[4] = { QLineF(x1+1+i, y2-i, x2-i, y2-i),
-
260 QLineF(x2-i, y2-i, x2-i, y1+i+1),
never executed (the execution status of this line is deduced): QLineF(x2-i, y2-i, x2-i, y1+i+1),
-
261 QLineF(x1+k, y2-k, x1+k, y1+k),
never executed (the execution status of this line is deduced): QLineF(x1+k, y2-k, x1+k, y1+k),
-
262 QLineF(x1+k, y1+k, x2-k, y1+k) };
never executed (the execution status of this line is deduced): QLineF(x1+k, y1+k, x2-k, y1+k) };
-
263 p->drawLines(lines, 4);
never executed (the execution status of this line is deduced): p->drawLines(lines, 4);
-
264 k++;
never executed (the execution status of this line is deduced): k++;
-
265 }
never executed: }
0
266 }
executed: }
Execution Count:13
13
267 if (fill) {
evaluated: fill
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:43
11-43
268 QBrush oldBrush = p->brush();
executed (the execution status of this line is deduced): QBrush oldBrush = p->brush();
-
269 int tlw = lineWidth + midLineWidth;
executed (the execution status of this line is deduced): int tlw = lineWidth + midLineWidth;
-
270 p->setPen(Qt::NoPen);
executed (the execution status of this line is deduced): p->setPen(Qt::NoPen);
-
271 p->setBrush(*fill);
executed (the execution status of this line is deduced): p->setBrush(*fill);
-
272 p->drawRect(x+tlw, y+tlw, w-2*tlw, h-2*tlw);
executed (the execution status of this line is deduced): p->drawRect(x+tlw, y+tlw, w-2*tlw, h-2*tlw);
-
273 p->setBrush(oldBrush);
executed (the execution status of this line is deduced): p->setBrush(oldBrush);
-
274 }
executed: }
Execution Count:11
11
275 p->setPen(oldPen); // restore pen
executed (the execution status of this line is deduced): p->setPen(oldPen);
-
276}
executed: }
Execution Count:54
54
277 -
278 -
279/*! -
280 \fn void qDrawShadePanel(QPainter *painter, int x, int y, int width, int height, -
281 const QPalette &palette, bool sunken, -
282 int lineWidth, const QBrush *fill) -
283 \relates <qdrawutil.h> -
284 -
285 Draws the shaded panel beginning at (\a x, \a y) with the given \a -
286 width and \a height using the provided \a painter and the given \a -
287 lineWidth. -
288 -
289 The given \a palette specifies the shading colors (\l -
290 {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l -
291 {QPalette::mid()}{middle} colors). The panel's interior is filled -
292 with the \a fill brush unless \a fill is 0. -
293 -
294 The panel appears sunken if \a sunken is true, otherwise raised. -
295 -
296 \warning This function does not look at QWidget::style() or -
297 QApplication::style(). Use the drawing functions in QStyle to make -
298 widgets that follow the current GUI style. -
299 -
300 Alternatively you can use a QFrame widget and apply the -
301 QFrame::setFrameStyle() function to display a shaded panel: -
302 -
303 \snippet code/src_gui_painting_qdrawutil.cpp 2 -
304 -
305 \sa qDrawWinPanel(), qDrawShadeLine(), qDrawShadeRect(), QStyle -
306*/ -
307 -
308void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, -
309 const QPalette &pal, bool sunken, -
310 int lineWidth, const QBrush *fill) -
311{ -
312 if (w == 0 || h == 0)
partially evaluated: w == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:139
partially evaluated: h == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:139
0-139
313 return;
never executed: return;
0
314 if (!(w > 0 && h > 0 && lineWidth >= 0)) {
partially evaluated: w > 0
TRUEFALSE
yes
Evaluation Count:139
no
Evaluation Count:0
partially evaluated: h > 0
TRUEFALSE
yes
Evaluation Count:139
no
Evaluation Count:0
partially evaluated: lineWidth >= 0
TRUEFALSE
yes
Evaluation Count:139
no
Evaluation Count:0
0-139
315 qWarning("qDrawShadePanel: Invalid parameters");
never executed (the execution status of this line is deduced): QMessageLogger("styles/qdrawutil.cpp", 315, __PRETTY_FUNCTION__).warning("qDrawShadePanel: Invalid parameters");
-
316 }
never executed: }
0
317 QColor shade = pal.dark().color();
executed (the execution status of this line is deduced): QColor shade = pal.dark().color();
-
318 QColor light = pal.light().color();
executed (the execution status of this line is deduced): QColor light = pal.light().color();
-
319 if (fill) {
evaluated: fill
TRUEFALSE
yes
Evaluation Count:120
yes
Evaluation Count:19
19-120
320 if (fill->color() == shade)
partially evaluated: fill->color() == shade
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:120
0-120
321 shade = pal.shadow().color();
never executed: shade = pal.shadow().color();
0
322 if (fill->color() == light)
partially evaluated: fill->color() == light
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:120
0-120
323 light = pal.midlight().color();
never executed: light = pal.midlight().color();
0
324 }
executed: }
Execution Count:120
120
325 QPen oldPen = p->pen(); // save pen
executed (the execution status of this line is deduced): QPen oldPen = p->pen();
-
326 QVector<QLineF> lines;
executed (the execution status of this line is deduced): QVector<QLineF> lines;
-
327 lines.reserve(2*lineWidth);
executed (the execution status of this line is deduced): lines.reserve(2*lineWidth);
-
328 -
329 if (sunken)
evaluated: sunken
TRUEFALSE
yes
Evaluation Count:122
yes
Evaluation Count:17
17-122
330 p->setPen(shade);
executed: p->setPen(shade);
Execution Count:122
122
331 else -
332 p->setPen(light);
executed: p->setPen(light);
Execution Count:17
17
333 int x1, y1, x2, y2;
executed (the execution status of this line is deduced): int x1, y1, x2, y2;
-
334 int i;
executed (the execution status of this line is deduced): int i;
-
335 x1 = x;
executed (the execution status of this line is deduced): x1 = x;
-
336 y1 = y2 = y;
executed (the execution status of this line is deduced): y1 = y2 = y;
-
337 x2 = x+w-2;
executed (the execution status of this line is deduced): x2 = x+w-2;
-
338 for (i=0; i<lineWidth; i++) { // top shadow
evaluated: i<lineWidth
TRUEFALSE
yes
Evaluation Count:139
yes
Evaluation Count:139
139
339 lines << QLineF(x1, y1++, x2--, y2++);
executed (the execution status of this line is deduced): lines << QLineF(x1, y1++, x2--, y2++);
-
340 }
executed: }
Execution Count:139
139
341 x2 = x1;
executed (the execution status of this line is deduced): x2 = x1;
-
342 y1 = y+h-2;
executed (the execution status of this line is deduced): y1 = y+h-2;
-
343 for (i=0; i<lineWidth; i++) { // left shado
evaluated: i<lineWidth
TRUEFALSE
yes
Evaluation Count:139
yes
Evaluation Count:139
139
344 lines << QLineF(x1++, y1, x2++, y2--);
executed (the execution status of this line is deduced): lines << QLineF(x1++, y1, x2++, y2--);
-
345 }
executed: }
Execution Count:139
139
346 p->drawLines(lines);
executed (the execution status of this line is deduced): p->drawLines(lines);
-
347 lines.clear();
executed (the execution status of this line is deduced): lines.clear();
-
348 if (sunken)
evaluated: sunken
TRUEFALSE
yes
Evaluation Count:122
yes
Evaluation Count:17
17-122
349 p->setPen(light);
executed: p->setPen(light);
Execution Count:122
122
350 else -
351 p->setPen(shade);
executed: p->setPen(shade);
Execution Count:17
17
352 x1 = x;
executed (the execution status of this line is deduced): x1 = x;
-
353 y1 = y2 = y+h-1;
executed (the execution status of this line is deduced): y1 = y2 = y+h-1;
-
354 x2 = x+w-1;
executed (the execution status of this line is deduced): x2 = x+w-1;
-
355 for (i=0; i<lineWidth; i++) { // bottom shadow
evaluated: i<lineWidth
TRUEFALSE
yes
Evaluation Count:139
yes
Evaluation Count:139
139
356 lines << QLineF(x1++, y1--, x2, y2--);
executed (the execution status of this line is deduced): lines << QLineF(x1++, y1--, x2, y2--);
-
357 }
executed: }
Execution Count:139
139
358 x1 = x2;
executed (the execution status of this line is deduced): x1 = x2;
-
359 y1 = y;
executed (the execution status of this line is deduced): y1 = y;
-
360 y2 = y+h-lineWidth-1;
executed (the execution status of this line is deduced): y2 = y+h-lineWidth-1;
-
361 for (i=0; i<lineWidth; i++) { // right shadow
evaluated: i<lineWidth
TRUEFALSE
yes
Evaluation Count:139
yes
Evaluation Count:139
139
362 lines << QLineF(x1--, y1++, x2--, y2);
executed (the execution status of this line is deduced): lines << QLineF(x1--, y1++, x2--, y2);
-
363 }
executed: }
Execution Count:139
139
364 p->drawLines(lines);
executed (the execution status of this line is deduced): p->drawLines(lines);
-
365 if (fill) // fill with fill color
evaluated: fill
TRUEFALSE
yes
Evaluation Count:120
yes
Evaluation Count:19
19-120
366 p->fillRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2, *fill);
executed: p->fillRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2, *fill);
Execution Count:120
120
367 p->setPen(oldPen); // restore pen
executed (the execution status of this line is deduced): p->setPen(oldPen);
-
368}
executed: }
Execution Count:139
139
369 -
370 -
371/*! -
372 \internal -
373 This function draws a rectangle with two pixel line width. -
374 It is called from qDrawWinButton() and qDrawWinPanel(). -
375 -
376 c1..c4 and fill are used: -
377 -
378 1 1 1 1 1 2 -
379 1 3 3 3 4 2 -
380 1 3 F F 4 2 -
381 1 3 F F 4 2 -
382 1 4 4 4 4 2 -
383 2 2 2 2 2 2 -
384*/ -
385 -
386static void qDrawWinShades(QPainter *p, -
387 int x, int y, int w, int h, -
388 const QColor &c1, const QColor &c2, -
389 const QColor &c3, const QColor &c4, -
390 const QBrush *fill) -
391{ -
392 if (w < 2 || h < 2) // can't do anything with that
evaluated: w < 2
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:15276
evaluated: h < 2
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:15272
2-15276
393 return;
executed: return;
Execution Count:6
6
394 QPen oldPen = p->pen();
executed (the execution status of this line is deduced): QPen oldPen = p->pen();
-
395 QPoint a[3] = { QPoint(x, y+h-2), QPoint(x, y), QPoint(x+w-2, y) };
executed (the execution status of this line is deduced): QPoint a[3] = { QPoint(x, y+h-2), QPoint(x, y), QPoint(x+w-2, y) };
-
396 p->setPen(c1);
executed (the execution status of this line is deduced): p->setPen(c1);
-
397 p->drawPolyline(a, 3);
executed (the execution status of this line is deduced): p->drawPolyline(a, 3);
-
398 QPoint b[3] = { QPoint(x, y+h-1), QPoint(x+w-1, y+h-1), QPoint(x+w-1, y) };
executed (the execution status of this line is deduced): QPoint b[3] = { QPoint(x, y+h-1), QPoint(x+w-1, y+h-1), QPoint(x+w-1, y) };
-
399 p->setPen(c2);
executed (the execution status of this line is deduced): p->setPen(c2);
-
400 p->drawPolyline(b, 3);
executed (the execution status of this line is deduced): p->drawPolyline(b, 3);
-
401 if (w > 4 && h > 4) {
evaluated: w > 4
TRUEFALSE
yes
Evaluation Count:15266
yes
Evaluation Count:6
evaluated: h > 4
TRUEFALSE
yes
Evaluation Count:15263
yes
Evaluation Count:3
3-15266
402 QPoint c[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) };
executed (the execution status of this line is deduced): QPoint c[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) };
-
403 p->setPen(c3);
executed (the execution status of this line is deduced): p->setPen(c3);
-
404 p->drawPolyline(c, 3);
executed (the execution status of this line is deduced): p->drawPolyline(c, 3);
-
405 QPoint d[3] = { QPoint(x+1, y+h-2), QPoint(x+w-2, y+h-2), QPoint(x+w-2, y+1) };
executed (the execution status of this line is deduced): QPoint d[3] = { QPoint(x+1, y+h-2), QPoint(x+w-2, y+h-2), QPoint(x+w-2, y+1) };
-
406 p->setPen(c4);
executed (the execution status of this line is deduced): p->setPen(c4);
-
407 p->drawPolyline(d, 3);
executed (the execution status of this line is deduced): p->drawPolyline(d, 3);
-
408 if (fill)
evaluated: fill
TRUEFALSE
yes
Evaluation Count:12944
yes
Evaluation Count:2319
2319-12944
409 p->fillRect(QRect(x+2, y+2, w-4, h-4), *fill);
executed: p->fillRect(QRect(x+2, y+2, w-4, h-4), *fill);
Execution Count:12944
12944
410 }
executed: }
Execution Count:15263
15263
411 p->setPen(oldPen);
executed (the execution status of this line is deduced): p->setPen(oldPen);
-
412}
executed: }
Execution Count:15272
15272
413 -
414 -
415/*! -
416 \fn void qDrawWinButton(QPainter *painter, int x, int y, int width, int height, -
417 const QPalette &palette, bool sunken, -
418 const QBrush *fill) -
419 \relates <qdrawutil.h> -
420 -
421 Draws the Windows-style button specified by the given point (\a x, -
422 \a y}, \a width and \a height using the provided \a painter with a -
423 line width of 2 pixels. The button's interior is filled with the -
424 \a{fill} brush unless \a fill is 0. -
425 -
426 The given \a palette specifies the shading colors (\l -
427 {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l -
428 {QPalette::mid()}{middle} colors). -
429 -
430 The button appears sunken if \a sunken is true, otherwise raised. -
431 -
432 \warning This function does not look at QWidget::style() or -
433 QApplication::style()-> Use the drawing functions in QStyle to make -
434 widgets that follow the current GUI style. -
435 -
436 \sa qDrawWinPanel(), QStyle -
437*/ -
438 -
439void qDrawWinButton(QPainter *p, int x, int y, int w, int h, -
440 const QPalette &pal, bool sunken, -
441 const QBrush *fill) -
442{ -
443 if (sunken)
evaluated: sunken
TRUEFALSE
yes
Evaluation Count:88
yes
Evaluation Count:12567
88-12567
444 qDrawWinShades(p, x, y, w, h,
executed: qDrawWinShades(p, x, y, w, h, pal.shadow().color(), pal.light().color(), pal.dark().color(), pal.button().color(), fill);
Execution Count:88
88
445 pal.shadow().color(), pal.light().color(), pal.dark().color(),
executed: qDrawWinShades(p, x, y, w, h, pal.shadow().color(), pal.light().color(), pal.dark().color(), pal.button().color(), fill);
Execution Count:88
88
446 pal.button().color(), fill);
executed: qDrawWinShades(p, x, y, w, h, pal.shadow().color(), pal.light().color(), pal.dark().color(), pal.button().color(), fill);
Execution Count:88
88
447 else -
448 qDrawWinShades(p, x, y, w, h,
executed: qDrawWinShades(p, x, y, w, h, pal.light().color(), pal.shadow().color(), pal.button().color(), pal.dark().color(), fill);
Execution Count:12567
12567
449 pal.light().color(), pal.shadow().color(), pal.button().color(),
executed: qDrawWinShades(p, x, y, w, h, pal.light().color(), pal.shadow().color(), pal.button().color(), pal.dark().color(), fill);
Execution Count:12567
12567
450 pal.dark().color(), fill);
executed: qDrawWinShades(p, x, y, w, h, pal.light().color(), pal.shadow().color(), pal.button().color(), pal.dark().color(), fill);
Execution Count:12567
12567
451} -
452 -
453/*! -
454 \fn void qDrawWinPanel(QPainter *painter, int x, int y, int width, int height, -
455 const QPalette &palette, bool sunken, -
456 const QBrush *fill) -
457 \relates <qdrawutil.h> -
458 -
459 Draws the Windows-style panel specified by the given point(\a x, -
460 \a y), \a width and \a height using the provided \a painter with a -
461 line width of 2 pixels. The button's interior is filled with the -
462 \a fill brush unless \a fill is 0. -
463 -
464 The given \a palette specifies the shading colors. The panel -
465 appears sunken if \a sunken is true, otherwise raised. -
466 -
467 \warning This function does not look at QWidget::style() or -
468 QApplication::style(). Use the drawing functions in QStyle to make -
469 widgets that follow the current GUI style. -
470 -
471 Alternatively you can use a QFrame widget and apply the -
472 QFrame::setFrameStyle() function to display a shaded panel: -
473 -
474 \snippet code/src_gui_painting_qdrawutil.cpp 3 -
475 -
476 \sa qDrawShadePanel(), qDrawWinButton(), QStyle -
477*/ -
478 -
479void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, -
480 const QPalette &pal, bool sunken, -
481 const QBrush *fill) -
482{ -
483 if (sunken)
evaluated: sunken
TRUEFALSE
yes
Evaluation Count:2171
yes
Evaluation Count:452
452-2171
484 qDrawWinShades(p, x, y, w, h,
executed: qDrawWinShades(p, x, y, w, h, pal.dark().color(), pal.light().color(), pal.shadow().color(), pal.midlight().color(), fill);
Execution Count:2171
2171
485 pal.dark().color(), pal.light().color(), pal.shadow().color(),
executed: qDrawWinShades(p, x, y, w, h, pal.dark().color(), pal.light().color(), pal.shadow().color(), pal.midlight().color(), fill);
Execution Count:2171
2171
486 pal.midlight().color(), fill);
executed: qDrawWinShades(p, x, y, w, h, pal.dark().color(), pal.light().color(), pal.shadow().color(), pal.midlight().color(), fill);
Execution Count:2171
2171
487 else -
488 qDrawWinShades(p, x, y, w, h,
executed: qDrawWinShades(p, x, y, w, h, pal.light().color(), pal.shadow().color(), pal.midlight().color(), pal.dark().color(), fill);
Execution Count:452
452
489 pal.light().color(), pal.shadow().color(), pal.midlight().color(),
executed: qDrawWinShades(p, x, y, w, h, pal.light().color(), pal.shadow().color(), pal.midlight().color(), pal.dark().color(), fill);
Execution Count:452
452
490 pal.dark().color(), fill);
executed: qDrawWinShades(p, x, y, w, h, pal.light().color(), pal.shadow().color(), pal.midlight().color(), pal.dark().color(), fill);
Execution Count:452
452
491} -
492 -
493/*! -
494 \fn void qDrawPlainRect(QPainter *painter, int x, int y, int width, int height, const QColor &lineColor, -
495 int lineWidth, const QBrush *fill) -
496 \relates <qdrawutil.h> -
497 -
498 Draws the plain rectangle beginning at (\a x, \a y) with the given -
499 \a width and \a height, using the specified \a painter, \a lineColor -
500 and \a lineWidth. The rectangle's interior is filled with the \a -
501 fill brush unless \a fill is 0. -
502 -
503 \warning This function does not look at QWidget::style() or -
504 QApplication::style(). Use the drawing functions in QStyle to make -
505 widgets that follow the current GUI style. -
506 -
507 Alternatively you can use a QFrame widget and apply the -
508 QFrame::setFrameStyle() function to display a plain rectangle: -
509 -
510 \snippet code/src_gui_painting_qdrawutil.cpp 4 -
511 -
512 \sa qDrawShadeRect(), QStyle -
513*/ -
514 -
515void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c, -
516 int lineWidth, const QBrush *fill) -
517{ -
518 if (w == 0 || h == 0)
partially evaluated: w == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:198
partially evaluated: h == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:198
0-198
519 return;
never executed: return;
0
520 if (!(w > 0 && h > 0 && lineWidth >= 0)) {
partially evaluated: w > 0
TRUEFALSE
yes
Evaluation Count:198
no
Evaluation Count:0
partially evaluated: h > 0
TRUEFALSE
yes
Evaluation Count:198
no
Evaluation Count:0
partially evaluated: lineWidth >= 0
TRUEFALSE
yes
Evaluation Count:198
no
Evaluation Count:0
0-198
521 qWarning("qDrawPlainRect: Invalid parameters");
never executed (the execution status of this line is deduced): QMessageLogger("styles/qdrawutil.cpp", 521, __PRETTY_FUNCTION__).warning("qDrawPlainRect: Invalid parameters");
-
522 }
never executed: }
0
523 QPen oldPen = p->pen();
executed (the execution status of this line is deduced): QPen oldPen = p->pen();
-
524 QBrush oldBrush = p->brush();
executed (the execution status of this line is deduced): QBrush oldBrush = p->brush();
-
525 p->setPen(c);
executed (the execution status of this line is deduced): p->setPen(c);
-
526 p->setBrush(Qt::NoBrush);
executed (the execution status of this line is deduced): p->setBrush(Qt::NoBrush);
-
527 for (int i=0; i<lineWidth; i++)
evaluated: i<lineWidth
TRUEFALSE
yes
Evaluation Count:198
yes
Evaluation Count:198
198
528 p->drawRect(x+i, y+i, w-i*2 - 1, h-i*2 - 1);
executed: p->drawRect(x+i, y+i, w-i*2 - 1, h-i*2 - 1);
Execution Count:198
198
529 if (fill) { // fill with fill color
partially evaluated: fill
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:198
0-198
530 p->setPen(Qt::NoPen);
never executed (the execution status of this line is deduced): p->setPen(Qt::NoPen);
-
531 p->setBrush(*fill);
never executed (the execution status of this line is deduced): p->setBrush(*fill);
-
532 p->drawRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2);
never executed (the execution status of this line is deduced): p->drawRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2);
-
533 }
never executed: }
0
534 p->setPen(oldPen);
executed (the execution status of this line is deduced): p->setPen(oldPen);
-
535 p->setBrush(oldBrush);
executed (the execution status of this line is deduced): p->setBrush(oldBrush);
-
536}
executed: }
Execution Count:198
198
537 -
538/***************************************************************************** -
539 Overloaded functions. -
540 *****************************************************************************/ -
541 -
542/*! -
543 \fn void qDrawShadeLine(QPainter *painter, const QPoint &p1, const QPoint &p2, -
544 const QPalette &palette, bool sunken, int lineWidth, int midLineWidth) -
545 \relates <qdrawutil.h> -
546 \overload -
547 -
548 Draws a horizontal or vertical shaded line between \a p1 and \a p2 -
549 using the given \a painter. Note that nothing is drawn if the line -
550 between the points would be neither horizontal nor vertical. -
551 -
552 The provided \a palette specifies the shading colors (\l -
553 {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l -
554 {QPalette::mid()}{middle} colors). The given \a lineWidth -
555 specifies the line width for each of the lines; it is not the -
556 total line width. The given \a midLineWidth specifies the width of -
557 a middle line drawn in the QPalette::mid() color. -
558 -
559 The line appears sunken if \a sunken is true, otherwise raised. -
560 -
561 \warning This function does not look at QWidget::style() or -
562 QApplication::style(). Use the drawing functions in QStyle to -
563 make widgets that follow the current GUI style. -
564 -
565 -
566 Alternatively you can use a QFrame widget and apply the -
567 QFrame::setFrameStyle() function to display a shaded line: -
568 -
569 \snippet code/src_gui_painting_qdrawutil.cpp 5 -
570 -
571 \sa qDrawShadeRect(), qDrawShadePanel(), QStyle -
572*/ -
573 -
574void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2, -
575 const QPalette &pal, bool sunken, -
576 int lineWidth, int midLineWidth) -
577{ -
578 qDrawShadeLine(p, p1.x(), p1.y(), p2.x(), p2.y(), pal, sunken,
never executed (the execution status of this line is deduced): qDrawShadeLine(p, p1.x(), p1.y(), p2.x(), p2.y(), pal, sunken,
-
579 lineWidth, midLineWidth);
never executed (the execution status of this line is deduced): lineWidth, midLineWidth);
-
580}
never executed: }
0
581 -
582/*! -
583 \fn void qDrawShadeRect(QPainter *painter, const QRect &rect, const QPalette &palette, -
584 bool sunken, int lineWidth, int midLineWidth, const QBrush *fill) -
585 \relates <qdrawutil.h> -
586 \overload -
587 -
588 Draws the shaded rectangle specified by \a rect using the given \a painter. -
589 -
590 The provide \a palette specifies the shading colors (\l -
591 {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l -
592 {QPalette::mid()}{middle} colors. The given \a lineWidth -
593 specifies the line width for each of the lines; it is not the -
594 total line width. The \a midLineWidth specifies the width of a -
595 middle line drawn in the QPalette::mid() color. The rectangle's -
596 interior is filled with the \a fill brush unless \a fill is 0. -
597 -
598 The rectangle appears sunken if \a sunken is true, otherwise -
599 raised. -
600 -
601 \warning This function does not look at QWidget::style() or -
602 QApplication::style(). Use the drawing functions in QStyle to make -
603 widgets that follow the current GUI style. -
604 -
605 Alternatively you can use a QFrame widget and apply the -
606 QFrame::setFrameStyle() function to display a shaded rectangle: -
607 -
608 \snippet code/src_gui_painting_qdrawutil.cpp 6 -
609 -
610 \sa qDrawShadeLine(), qDrawShadePanel(), qDrawPlainRect(), QStyle -
611*/ -
612 -
613void qDrawShadeRect(QPainter *p, const QRect &r, -
614 const QPalette &pal, bool sunken, -
615 int lineWidth, int midLineWidth, -
616 const QBrush *fill) -
617{ -
618 qDrawShadeRect(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
executed (the execution status of this line is deduced): qDrawShadeRect(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
-
619 lineWidth, midLineWidth, fill);
executed (the execution status of this line is deduced): lineWidth, midLineWidth, fill);
-
620}
executed: }
Execution Count:11
11
621 -
622/*! -
623 \fn void qDrawShadePanel(QPainter *painter, const QRect &rect, const QPalette &palette, -
624 bool sunken, int lineWidth, const QBrush *fill) -
625 \relates <qdrawutil.h> -
626 \overload -
627 -
628 Draws the shaded panel at the rectangle specified by \a rect using the -
629 given \a painter and the given \a lineWidth. -
630 -
631 The given \a palette specifies the shading colors (\l -
632 {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l -
633 {QPalette::mid()}{middle} colors). The panel's interior is filled -
634 with the \a fill brush unless \a fill is 0. -
635 -
636 The panel appears sunken if \a sunken is true, otherwise raised. -
637 -
638 \warning This function does not look at QWidget::style() or -
639 QApplication::style(). Use the drawing functions in QStyle to make -
640 widgets that follow the current GUI style. -
641 -
642 Alternatively you can use a QFrame widget and apply the -
643 QFrame::setFrameStyle() function to display a shaded panel: -
644 -
645 \snippet code/src_gui_painting_qdrawutil.cpp 7 -
646 -
647 \sa qDrawWinPanel(), qDrawShadeLine(), qDrawShadeRect(), QStyle -
648*/ -
649 -
650void qDrawShadePanel(QPainter *p, const QRect &r, -
651 const QPalette &pal, bool sunken, -
652 int lineWidth, const QBrush *fill) -
653{ -
654 qDrawShadePanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
executed (the execution status of this line is deduced): qDrawShadePanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
-
655 lineWidth, fill);
executed (the execution status of this line is deduced): lineWidth, fill);
-
656}
executed: }
Execution Count:127
127
657 -
658/*! -
659 \fn void qDrawWinButton(QPainter *painter, const QRect &rect, const QPalette &palette, -
660 bool sunken, const QBrush *fill) -
661 \relates <qdrawutil.h> -
662 \overload -
663 -
664 Draws the Windows-style button at the rectangle specified by \a rect using -
665 the given \a painter with a line width of 2 pixels. The button's interior -
666 is filled with the \a{fill} brush unless \a fill is 0. -
667 -
668 The given \a palette specifies the shading colors (\l -
669 {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l -
670 {QPalette::mid()}{middle} colors). -
671 -
672 The button appears sunken if \a sunken is true, otherwise raised. -
673 -
674 \warning This function does not look at QWidget::style() or -
675 QApplication::style()-> Use the drawing functions in QStyle to make -
676 widgets that follow the current GUI style. -
677 -
678 \sa qDrawWinPanel(), QStyle -
679*/ -
680 -
681void qDrawWinButton(QPainter *p, const QRect &r, -
682 const QPalette &pal, bool sunken, const QBrush *fill) -
683{ -
684 qDrawWinButton(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
executed (the execution status of this line is deduced): qDrawWinButton(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
-
685}
executed: }
Execution Count:12655
12655
686 -
687/*! -
688 \fn void qDrawWinPanel(QPainter *painter, const QRect &rect, const QPalette &palette, -
689 bool sunken, const QBrush *fill) -
690 \overload -
691 -
692 Draws the Windows-style panel at the rectangle specified by \a rect using -
693 the given \a painter with a line width of 2 pixels. The button's interior -
694 is filled with the \a fill brush unless \a fill is 0. -
695 -
696 The given \a palette specifies the shading colors. The panel -
697 appears sunken if \a sunken is true, otherwise raised. -
698 -
699 \warning This function does not look at QWidget::style() or -
700 QApplication::style(). Use the drawing functions in QStyle to make -
701 widgets that follow the current GUI style. -
702 -
703 Alternatively you can use a QFrame widget and apply the -
704 QFrame::setFrameStyle() function to display a shaded panel: -
705 -
706 \snippet code/src_gui_painting_qdrawutil.cpp 8 -
707 -
708 \sa qDrawShadePanel(), qDrawWinButton(), QStyle -
709*/ -
710 -
711void qDrawWinPanel(QPainter *p, const QRect &r, -
712 const QPalette &pal, bool sunken, const QBrush *fill) -
713{ -
714 qDrawWinPanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
executed (the execution status of this line is deduced): qDrawWinPanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
-
715}
executed: }
Execution Count:2619
2619
716 -
717/*! -
718 \fn void qDrawPlainRect(QPainter *painter, const QRect &rect, const QColor &lineColor, int lineWidth, const QBrush *fill) -
719 \relates <qdrawutil.h> -
720 \overload -
721 -
722 Draws the plain rectangle specified by \a rect using the given \a painter, -
723 \a lineColor and \a lineWidth. The rectangle's interior is filled with the -
724 \a fill brush unless \a fill is 0. -
725 -
726 \warning This function does not look at QWidget::style() or -
727 QApplication::style(). Use the drawing functions in QStyle to make -
728 widgets that follow the current GUI style. -
729 -
730 Alternatively you can use a QFrame widget and apply the -
731 QFrame::setFrameStyle() function to display a plain rectangle: -
732 -
733 \snippet code/src_gui_painting_qdrawutil.cpp 9 -
734 -
735 \sa qDrawShadeRect(), QStyle -
736*/ -
737 -
738void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &c, -
739 int lineWidth, const QBrush *fill) -
740{ -
741 qDrawPlainRect(p, r.x(), r.y(), r.width(), r.height(), c,
executed (the execution status of this line is deduced): qDrawPlainRect(p, r.x(), r.y(), r.width(), r.height(), c,
-
742 lineWidth, fill);
executed (the execution status of this line is deduced): lineWidth, fill);
-
743}
executed: }
Execution Count:198
198
744 -
745 -
746/*! -
747 \class QTileRules -
748 \since 4.6 -
749 -
750 \inmodule QtWidgets -
751 -
752 \brief The QTileRules class provides the rules used to draw a -
753 pixmap or image split into nine segments. -
754 -
755 Spliiting is similar to \l{http://www.w3.org/TR/css3-background/}{CSS3 border-images}. -
756 -
757 \sa Qt::TileRule, QMargins -
758*/ -
759 -
760/*! \fn QTileRules::QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule) -
761 Constructs a QTileRules with the given \a horizontalRule and -
762 \a verticalRule. -
763 */ -
764 -
765/*! \fn QTileRules::QTileRules(Qt::TileRule rule) -
766 Constructs a QTileRules with the given \a rule used for both -
767 the horizontal rule and the vertical rule. -
768 */ -
769 -
770/*! -
771 \fn void qDrawBorderPixmap(QPainter *painter, const QRect &target, const QMargins &margins, const QPixmap &pixmap) -
772 \relates <qdrawutil.h> -
773 \since 4.6 -
774 \overload -
775 -
776 \brief The qDrawBorderPixmap function is for drawing a pixmap into -
777 the margins of a rectangle. -
778 -
779 Draws the given \a pixmap into the given \a target rectangle, using the -
780 given \a painter. The pixmap will be split into nine segments and drawn -
781 according to the \a margins structure. -
782*/ -
783 -
784typedef QVarLengthArray<QPainter::PixmapFragment, 16> QPixmapFragmentsArray; -
785 -
786/*! -
787 \since 4.6 -
788 -
789 Draws the indicated \a sourceRect rectangle from the given \a pixmap into -
790 the given \a targetRect rectangle, using the given \a painter. The pixmap -
791 will be split into nine segments according to the given \a targetMargins -
792 and \a sourceMargins structures. Finally, the pixmap will be drawn -
793 according to the given \a rules. -
794 -
795 This function is used to draw a scaled pixmap, similar to -
796 \l{http://www.w3.org/TR/css3-background/}{CSS3 border-images} -
797 -
798 \sa Qt::TileRule, QTileRules, QMargins -
799*/ -
800 -
801void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins, -
802 const QPixmap &pixmap, const QRect &sourceRect,const QMargins &sourceMargins, -
803 const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints) -
804{ -
805 QPainter::PixmapFragment d;
executed (the execution status of this line is deduced): QPainter::PixmapFragment d;
-
806 d.opacity = 1.0;
executed (the execution status of this line is deduced): d.opacity = 1.0;
-
807 d.rotation = 0.0;
executed (the execution status of this line is deduced): d.rotation = 0.0;
-
808 -
809 QPixmapFragmentsArray opaqueData;
executed (the execution status of this line is deduced): QPixmapFragmentsArray opaqueData;
-
810 QPixmapFragmentsArray translucentData;
executed (the execution status of this line is deduced): QPixmapFragmentsArray translucentData;
-
811 -
812 // source center -
813 const int sourceCenterTop = sourceRect.top() + sourceMargins.top();
executed (the execution status of this line is deduced): const int sourceCenterTop = sourceRect.top() + sourceMargins.top();
-
814 const int sourceCenterLeft = sourceRect.left() + sourceMargins.left();
executed (the execution status of this line is deduced): const int sourceCenterLeft = sourceRect.left() + sourceMargins.left();
-
815 const int sourceCenterBottom = sourceRect.bottom() - sourceMargins.bottom() + 1;
executed (the execution status of this line is deduced): const int sourceCenterBottom = sourceRect.bottom() - sourceMargins.bottom() + 1;
-
816 const int sourceCenterRight = sourceRect.right() - sourceMargins.right() + 1;
executed (the execution status of this line is deduced): const int sourceCenterRight = sourceRect.right() - sourceMargins.right() + 1;
-
817 const int sourceCenterWidth = sourceCenterRight - sourceCenterLeft;
executed (the execution status of this line is deduced): const int sourceCenterWidth = sourceCenterRight - sourceCenterLeft;
-
818 const int sourceCenterHeight = sourceCenterBottom - sourceCenterTop;
executed (the execution status of this line is deduced): const int sourceCenterHeight = sourceCenterBottom - sourceCenterTop;
-
819 // target center -
820 const int targetCenterTop = targetRect.top() + targetMargins.top();
executed (the execution status of this line is deduced): const int targetCenterTop = targetRect.top() + targetMargins.top();
-
821 const int targetCenterLeft = targetRect.left() + targetMargins.left();
executed (the execution status of this line is deduced): const int targetCenterLeft = targetRect.left() + targetMargins.left();
-
822 const int targetCenterBottom = targetRect.bottom() - targetMargins.bottom() + 1;
executed (the execution status of this line is deduced): const int targetCenterBottom = targetRect.bottom() - targetMargins.bottom() + 1;
-
823 const int targetCenterRight = targetRect.right() - targetMargins.right() + 1;
executed (the execution status of this line is deduced): const int targetCenterRight = targetRect.right() - targetMargins.right() + 1;
-
824 const int targetCenterWidth = targetCenterRight - targetCenterLeft;
executed (the execution status of this line is deduced): const int targetCenterWidth = targetCenterRight - targetCenterLeft;
-
825 const int targetCenterHeight = targetCenterBottom - targetCenterTop;
executed (the execution status of this line is deduced): const int targetCenterHeight = targetCenterBottom - targetCenterTop;
-
826 -
827 QVarLengthArray<qreal, 16> xTarget; // x-coordinates of target rectangles
executed (the execution status of this line is deduced): QVarLengthArray<qreal, 16> xTarget;
-
828 QVarLengthArray<qreal, 16> yTarget; // y-coordinates of target rectangles
executed (the execution status of this line is deduced): QVarLengthArray<qreal, 16> yTarget;
-
829 -
830 int columns = 3;
executed (the execution status of this line is deduced): int columns = 3;
-
831 int rows = 3;
executed (the execution status of this line is deduced): int rows = 3;
-
832 if (rules.horizontal != Qt::StretchTile && sourceCenterWidth != 0)
partially evaluated: rules.horizontal != Qt::StretchTile
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
never evaluated: sourceCenterWidth != 0
0-2
833 columns = qMax(3, 2 + qCeil(targetCenterWidth / qreal(sourceCenterWidth)));
never executed: columns = qMax(3, 2 + qCeil(targetCenterWidth / qreal(sourceCenterWidth)));
0
834 if (rules.vertical != Qt::StretchTile && sourceCenterHeight != 0)
partially evaluated: rules.vertical != Qt::StretchTile
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
never evaluated: sourceCenterHeight != 0
0-2
835 rows = qMax(3, 2 + qCeil(targetCenterHeight / qreal(sourceCenterHeight)));
never executed: rows = qMax(3, 2 + qCeil(targetCenterHeight / qreal(sourceCenterHeight)));
0
836 -
837 xTarget.resize(columns + 1);
executed (the execution status of this line is deduced): xTarget.resize(columns + 1);
-
838 yTarget.resize(rows + 1);
executed (the execution status of this line is deduced): yTarget.resize(rows + 1);
-
839 -
840 bool oldAA = painter->testRenderHint(QPainter::Antialiasing);
executed (the execution status of this line is deduced): bool oldAA = painter->testRenderHint(QPainter::Antialiasing);
-
841 if (painter->paintEngine()->type() != QPaintEngine::OpenGL
partially evaluated: painter->paintEngine()->type() != QPaintEngine::OpenGL
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
842 && painter->paintEngine()->type() != QPaintEngine::OpenGL2
partially evaluated: painter->paintEngine()->type() != QPaintEngine::OpenGL2
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
843 && oldAA && painter->combinedTransform().type() != QTransform::TxNone) {
partially evaluated: oldAA
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
never evaluated: painter->combinedTransform().type() != QTransform::TxNone
0-2
844 painter->setRenderHint(QPainter::Antialiasing, false);
never executed (the execution status of this line is deduced): painter->setRenderHint(QPainter::Antialiasing, false);
-
845 }
never executed: }
0
846 -
847 xTarget[0] = targetRect.left();
executed (the execution status of this line is deduced): xTarget[0] = targetRect.left();
-
848 xTarget[1] = targetCenterLeft;
executed (the execution status of this line is deduced): xTarget[1] = targetCenterLeft;
-
849 xTarget[columns - 1] = targetCenterRight;
executed (the execution status of this line is deduced): xTarget[columns - 1] = targetCenterRight;
-
850 xTarget[columns] = targetRect.left() + targetRect.width();
executed (the execution status of this line is deduced): xTarget[columns] = targetRect.left() + targetRect.width();
-
851 -
852 yTarget[0] = targetRect.top();
executed (the execution status of this line is deduced): yTarget[0] = targetRect.top();
-
853 yTarget[1] = targetCenterTop;
executed (the execution status of this line is deduced): yTarget[1] = targetCenterTop;
-
854 yTarget[rows - 1] = targetCenterBottom;
executed (the execution status of this line is deduced): yTarget[rows - 1] = targetCenterBottom;
-
855 yTarget[rows] = targetRect.top() + targetRect.height();
executed (the execution status of this line is deduced): yTarget[rows] = targetRect.top() + targetRect.height();
-
856 -
857 qreal dx = targetCenterWidth;
executed (the execution status of this line is deduced): qreal dx = targetCenterWidth;
-
858 qreal dy = targetCenterHeight;
executed (the execution status of this line is deduced): qreal dy = targetCenterHeight;
-
859 -
860 switch (rules.horizontal) { -
861 case Qt::StretchTile: -
862 dx = targetCenterWidth;
executed (the execution status of this line is deduced): dx = targetCenterWidth;
-
863 break;
executed: break;
Execution Count:2
2
864 case Qt::RepeatTile: -
865 dx = sourceCenterWidth;
never executed (the execution status of this line is deduced): dx = sourceCenterWidth;
-
866 break;
never executed: break;
0
867 case Qt::RoundTile: -
868 dx = targetCenterWidth / qreal(columns - 2);
never executed (the execution status of this line is deduced): dx = targetCenterWidth / qreal(columns - 2);
-
869 break;
never executed: break;
0
870 } -
871 -
872 for (int i = 2; i < columns - 1; ++i)
partially evaluated: i < columns - 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
873 xTarget[i] = xTarget[i - 1] + dx;
never executed: xTarget[i] = xTarget[i - 1] + dx;
0
874 -
875 switch (rules.vertical) { -
876 case Qt::StretchTile: -
877 dy = targetCenterHeight;
executed (the execution status of this line is deduced): dy = targetCenterHeight;
-
878 break;
executed: break;
Execution Count:2
2
879 case Qt::RepeatTile: -
880 dy = sourceCenterHeight;
never executed (the execution status of this line is deduced): dy = sourceCenterHeight;
-
881 break;
never executed: break;
0
882 case Qt::RoundTile: -
883 dy = targetCenterHeight / qreal(rows - 2);
never executed (the execution status of this line is deduced): dy = targetCenterHeight / qreal(rows - 2);
-
884 break;
never executed: break;
0
885 } -
886 -
887 for (int i = 2; i < rows - 1; ++i)
partially evaluated: i < rows - 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
888 yTarget[i] = yTarget[i - 1] + dy;
never executed: yTarget[i] = yTarget[i - 1] + dy;
0
889 -
890 // corners -
891 if (targetMargins.top() > 0 && targetMargins.left() > 0 && sourceMargins.top() > 0 && sourceMargins.left() > 0) { // top left
partially evaluated: targetMargins.top() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: targetMargins.left() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: sourceMargins.top() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: sourceMargins.left() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
892 d.x = (0.5 * (xTarget[1] + xTarget[0]));
executed (the execution status of this line is deduced): d.x = (0.5 * (xTarget[1] + xTarget[0]));
-
893 d.y = (0.5 * (yTarget[1] + yTarget[0]));
executed (the execution status of this line is deduced): d.y = (0.5 * (yTarget[1] + yTarget[0]));
-
894 d.sourceLeft = sourceRect.left();
executed (the execution status of this line is deduced): d.sourceLeft = sourceRect.left();
-
895 d.sourceTop = sourceRect.top();
executed (the execution status of this line is deduced): d.sourceTop = sourceRect.top();
-
896 d.width = sourceMargins.left();
executed (the execution status of this line is deduced): d.width = sourceMargins.left();
-
897 d.height = sourceMargins.top();
executed (the execution status of this line is deduced): d.height = sourceMargins.top();
-
898 d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
executed (the execution status of this line is deduced): d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
-
899 d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
executed (the execution status of this line is deduced): d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
-
900 if (hints & QDrawBorderPixmap::OpaqueTopLeft)
partially evaluated: hints & QDrawBorderPixmap::OpaqueTopLeft
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
901 opaqueData.append(d);
never executed: opaqueData.append(d);
0
902 else -
903 translucentData.append(d);
executed: translucentData.append(d);
Execution Count:2
2
904 } -
905 if (targetMargins.top() > 0 && targetMargins.right() > 0 && sourceMargins.top() > 0 && sourceMargins.right() > 0) { // top right
partially evaluated: targetMargins.top() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: targetMargins.right() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: sourceMargins.top() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: sourceMargins.right() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
906 d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
executed (the execution status of this line is deduced): d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
-
907 d.y = (0.5 * (yTarget[1] + yTarget[0]));
executed (the execution status of this line is deduced): d.y = (0.5 * (yTarget[1] + yTarget[0]));
-
908 d.sourceLeft = sourceCenterRight;
executed (the execution status of this line is deduced): d.sourceLeft = sourceCenterRight;
-
909 d.sourceTop = sourceRect.top();
executed (the execution status of this line is deduced): d.sourceTop = sourceRect.top();
-
910 d.width = sourceMargins.right();
executed (the execution status of this line is deduced): d.width = sourceMargins.right();
-
911 d.height = sourceMargins.top();
executed (the execution status of this line is deduced): d.height = sourceMargins.top();
-
912 d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
executed (the execution status of this line is deduced): d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
-
913 d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
executed (the execution status of this line is deduced): d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
-
914 if (hints & QDrawBorderPixmap::OpaqueTopRight)
partially evaluated: hints & QDrawBorderPixmap::OpaqueTopRight
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
915 opaqueData.append(d);
never executed: opaqueData.append(d);
0
916 else -
917 translucentData.append(d);
executed: translucentData.append(d);
Execution Count:2
2
918 } -
919 if (targetMargins.bottom() > 0 && targetMargins.left() > 0 && sourceMargins.bottom() > 0 && sourceMargins.left() > 0) { // bottom left
partially evaluated: targetMargins.bottom() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: targetMargins.left() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: sourceMargins.bottom() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: sourceMargins.left() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
920 d.x = (0.5 * (xTarget[1] + xTarget[0]));
executed (the execution status of this line is deduced): d.x = (0.5 * (xTarget[1] + xTarget[0]));
-
921 d.y =(0.5 * (yTarget[rows] + yTarget[rows - 1]));
executed (the execution status of this line is deduced): d.y =(0.5 * (yTarget[rows] + yTarget[rows - 1]));
-
922 d.sourceLeft = sourceRect.left();
executed (the execution status of this line is deduced): d.sourceLeft = sourceRect.left();
-
923 d.sourceTop = sourceCenterBottom;
executed (the execution status of this line is deduced): d.sourceTop = sourceCenterBottom;
-
924 d.width = sourceMargins.left();
executed (the execution status of this line is deduced): d.width = sourceMargins.left();
-
925 d.height = sourceMargins.bottom();
executed (the execution status of this line is deduced): d.height = sourceMargins.bottom();
-
926 d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
executed (the execution status of this line is deduced): d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
-
927 d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
executed (the execution status of this line is deduced): d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
-
928 if (hints & QDrawBorderPixmap::OpaqueBottomLeft)
partially evaluated: hints & QDrawBorderPixmap::OpaqueBottomLeft
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
929 opaqueData.append(d);
never executed: opaqueData.append(d);
0
930 else -
931 translucentData.append(d);
executed: translucentData.append(d);
Execution Count:2
2
932 } -
933 if (targetMargins.bottom() > 0 && targetMargins.right() > 0 && sourceMargins.bottom() > 0 && sourceMargins.right() > 0) { // bottom right
partially evaluated: targetMargins.bottom() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: targetMargins.right() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: sourceMargins.bottom() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: sourceMargins.right() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
934 d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
executed (the execution status of this line is deduced): d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
-
935 d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
executed (the execution status of this line is deduced): d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
-
936 d.sourceLeft = sourceCenterRight;
executed (the execution status of this line is deduced): d.sourceLeft = sourceCenterRight;
-
937 d.sourceTop = sourceCenterBottom;
executed (the execution status of this line is deduced): d.sourceTop = sourceCenterBottom;
-
938 d.width = sourceMargins.right();
executed (the execution status of this line is deduced): d.width = sourceMargins.right();
-
939 d.height = sourceMargins.bottom();
executed (the execution status of this line is deduced): d.height = sourceMargins.bottom();
-
940 d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
executed (the execution status of this line is deduced): d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
-
941 d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
executed (the execution status of this line is deduced): d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
-
942 if (hints & QDrawBorderPixmap::OpaqueBottomRight)
partially evaluated: hints & QDrawBorderPixmap::OpaqueBottomRight
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
943 opaqueData.append(d);
never executed: opaqueData.append(d);
0
944 else -
945 translucentData.append(d);
executed: translucentData.append(d);
Execution Count:2
2
946 } -
947 -
948 // horizontal edges -
949 if (targetCenterWidth > 0 && sourceCenterWidth > 0) {
evaluated: targetCenterWidth > 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
partially evaluated: sourceCenterWidth > 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
950 if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top
partially evaluated: targetMargins.top() > 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: sourceMargins.top() > 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
951 QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueTop ? opaqueData : translucentData;
partially evaluated: hints & QDrawBorderPixmap::OpaqueTop
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
952 d.sourceLeft = sourceCenterLeft;
executed (the execution status of this line is deduced): d.sourceLeft = sourceCenterLeft;
-
953 d.sourceTop = sourceRect.top();
executed (the execution status of this line is deduced): d.sourceTop = sourceRect.top();
-
954 d.width = sourceCenterWidth;
executed (the execution status of this line is deduced): d.width = sourceCenterWidth;
-
955 d.height = sourceMargins.top();
executed (the execution status of this line is deduced): d.height = sourceMargins.top();
-
956 d.y = (0.5 * (yTarget[1] + yTarget[0]));
executed (the execution status of this line is deduced): d.y = (0.5 * (yTarget[1] + yTarget[0]));
-
957 d.scaleX = dx / d.width;
executed (the execution status of this line is deduced): d.scaleX = dx / d.width;
-
958 d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
executed (the execution status of this line is deduced): d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
-
959 for (int i = 1; i < columns - 1; ++i) {
evaluated: i < columns - 1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
960 d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
executed (the execution status of this line is deduced): d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
-
961 data.append(d);
executed (the execution status of this line is deduced): data.append(d);
-
962 }
executed: }
Execution Count:1
1
963 if (rules.horizontal == Qt::RepeatTile)
partially evaluated: rules.horizontal == Qt::RepeatTile
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
964 data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
never executed: data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
0
965 }
executed: }
Execution Count:1
1
966 if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom
partially evaluated: targetMargins.bottom() > 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: sourceMargins.bottom() > 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
967 QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueBottom ? opaqueData : translucentData;
partially evaluated: hints & QDrawBorderPixmap::OpaqueBottom
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
968 d.sourceLeft = sourceCenterLeft;
executed (the execution status of this line is deduced): d.sourceLeft = sourceCenterLeft;
-
969 d.sourceTop = sourceCenterBottom;
executed (the execution status of this line is deduced): d.sourceTop = sourceCenterBottom;
-
970 d.width = sourceCenterWidth;
executed (the execution status of this line is deduced): d.width = sourceCenterWidth;
-
971 d.height = sourceMargins.bottom();
executed (the execution status of this line is deduced): d.height = sourceMargins.bottom();
-
972 d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
executed (the execution status of this line is deduced): d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
-
973 d.scaleX = dx / d.width;
executed (the execution status of this line is deduced): d.scaleX = dx / d.width;
-
974 d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
executed (the execution status of this line is deduced): d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
-
975 for (int i = 1; i < columns - 1; ++i) {
evaluated: i < columns - 1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
976 d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
executed (the execution status of this line is deduced): d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
-
977 data.append(d);
executed (the execution status of this line is deduced): data.append(d);
-
978 }
executed: }
Execution Count:1
1
979 if (rules.horizontal == Qt::RepeatTile)
partially evaluated: rules.horizontal == Qt::RepeatTile
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
980 data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
never executed: data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
0
981 }
executed: }
Execution Count:1
1
982 }
executed: }
Execution Count:1
1
983 -
984 // vertical edges -
985 if (targetCenterHeight > 0 && sourceCenterHeight > 0) {
partially evaluated: targetCenterHeight > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: sourceCenterHeight > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
986 if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left
partially evaluated: targetMargins.left() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: sourceMargins.left() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
987 QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueLeft ? opaqueData : translucentData;
partially evaluated: hints & QDrawBorderPixmap::OpaqueLeft
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
988 d.sourceLeft = sourceRect.left();
executed (the execution status of this line is deduced): d.sourceLeft = sourceRect.left();
-
989 d.sourceTop = sourceCenterTop;
executed (the execution status of this line is deduced): d.sourceTop = sourceCenterTop;
-
990 d.width = sourceMargins.left();
executed (the execution status of this line is deduced): d.width = sourceMargins.left();
-
991 d.height = sourceCenterHeight;
executed (the execution status of this line is deduced): d.height = sourceCenterHeight;
-
992 d.x = (0.5 * (xTarget[1] + xTarget[0]));
executed (the execution status of this line is deduced): d.x = (0.5 * (xTarget[1] + xTarget[0]));
-
993 d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
executed (the execution status of this line is deduced): d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
-
994 d.scaleY = dy / d.height;
executed (the execution status of this line is deduced): d.scaleY = dy / d.height;
-
995 for (int i = 1; i < rows - 1; ++i) {
evaluated: i < rows - 1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
996 d.y = (0.5 * (yTarget[i + 1] + yTarget[i]));
executed (the execution status of this line is deduced): d.y = (0.5 * (yTarget[i + 1] + yTarget[i]));
-
997 data.append(d);
executed (the execution status of this line is deduced): data.append(d);
-
998 }
executed: }
Execution Count:2
2
999 if (rules.vertical == Qt::RepeatTile)
partially evaluated: rules.vertical == Qt::RepeatTile
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1000 data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
never executed: data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
0
1001 }
executed: }
Execution Count:2
2
1002 if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right
partially evaluated: targetMargins.right() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: sourceMargins.right() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1003 QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueRight ? opaqueData : translucentData;
partially evaluated: hints & QDrawBorderPixmap::OpaqueRight
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1004 d.sourceLeft = sourceCenterRight;
executed (the execution status of this line is deduced): d.sourceLeft = sourceCenterRight;
-
1005 d.sourceTop = sourceCenterTop;
executed (the execution status of this line is deduced): d.sourceTop = sourceCenterTop;
-
1006 d.width = sourceMargins.right();
executed (the execution status of this line is deduced): d.width = sourceMargins.right();
-
1007 d.height = sourceCenterHeight;
executed (the execution status of this line is deduced): d.height = sourceCenterHeight;
-
1008 d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
executed (the execution status of this line is deduced): d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
-
1009 d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
executed (the execution status of this line is deduced): d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
-
1010 d.scaleY = dy / d.height;
executed (the execution status of this line is deduced): d.scaleY = dy / d.height;
-
1011 for (int i = 1; i < rows - 1; ++i) {
evaluated: i < rows - 1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
1012 d.y = (0.5 * (yTarget[i + 1] + yTarget[i]));
executed (the execution status of this line is deduced): d.y = (0.5 * (yTarget[i + 1] + yTarget[i]));
-
1013 data.append(d);
executed (the execution status of this line is deduced): data.append(d);
-
1014 }
executed: }
Execution Count:2
2
1015 if (rules.vertical == Qt::RepeatTile)
partially evaluated: rules.vertical == Qt::RepeatTile
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1016 data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
never executed: data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
0
1017 }
executed: }
Execution Count:2
2
1018 }
executed: }
Execution Count:2
2
1019 -
1020 // center -
1021 if (targetCenterWidth > 0 && targetCenterHeight > 0 && sourceCenterWidth > 0 && sourceCenterHeight > 0) {
evaluated: targetCenterWidth > 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
partially evaluated: targetCenterHeight > 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: sourceCenterWidth > 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: sourceCenterHeight > 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1022 QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueCenter ? opaqueData : translucentData;
partially evaluated: hints & QDrawBorderPixmap::OpaqueCenter
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1023 d.sourceLeft = sourceCenterLeft;
executed (the execution status of this line is deduced): d.sourceLeft = sourceCenterLeft;
-
1024 d.sourceTop = sourceCenterTop;
executed (the execution status of this line is deduced): d.sourceTop = sourceCenterTop;
-
1025 d.width = sourceCenterWidth;
executed (the execution status of this line is deduced): d.width = sourceCenterWidth;
-
1026 d.height = sourceCenterHeight;
executed (the execution status of this line is deduced): d.height = sourceCenterHeight;
-
1027 d.scaleX = dx / d.width;
executed (the execution status of this line is deduced): d.scaleX = dx / d.width;
-
1028 d.scaleY = dy / d.height;
executed (the execution status of this line is deduced): d.scaleY = dy / d.height;
-
1029 -
1030 qreal repeatWidth = (xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX;
executed (the execution status of this line is deduced): qreal repeatWidth = (xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX;
-
1031 qreal repeatHeight = (yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY;
executed (the execution status of this line is deduced): qreal repeatHeight = (yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY;
-
1032 -
1033 for (int j = 1; j < rows - 1; ++j) {
evaluated: j < rows - 1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1034 d.y = (0.5 * (yTarget[j + 1] + yTarget[j]));
executed (the execution status of this line is deduced): d.y = (0.5 * (yTarget[j + 1] + yTarget[j]));
-
1035 for (int i = 1; i < columns - 1; ++i) {
evaluated: i < columns - 1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1036 d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
executed (the execution status of this line is deduced): d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
-
1037 data.append(d);
executed (the execution status of this line is deduced): data.append(d);
-
1038 }
executed: }
Execution Count:1
1
1039 if (rules.horizontal == Qt::RepeatTile)
partially evaluated: rules.horizontal == Qt::RepeatTile
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1040 data[data.size() - 1].width = repeatWidth;
never executed: data[data.size() - 1].width = repeatWidth;
0
1041 }
executed: }
Execution Count:1
1
1042 if (rules.vertical == Qt::RepeatTile) {
partially evaluated: rules.vertical == Qt::RepeatTile
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1043 for (int i = 1; i < columns - 1; ++i)
never evaluated: i < columns - 1
0
1044 data[data.size() - i].height = repeatHeight;
never executed: data[data.size() - i].height = repeatHeight;
0
1045 }
never executed: }
0
1046 }
executed: }
Execution Count:1
1
1047 -
1048 if (opaqueData.size())
partially evaluated: opaqueData.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1049 painter->drawPixmapFragments(opaqueData.data(), opaqueData.size(), pixmap, QPainter::OpaqueHint);
never executed: painter->drawPixmapFragments(opaqueData.data(), opaqueData.size(), pixmap, QPainter::OpaqueHint);
0
1050 if (translucentData.size())
partially evaluated: translucentData.size()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1051 painter->drawPixmapFragments(translucentData.data(), translucentData.size(), pixmap);
executed: painter->drawPixmapFragments(translucentData.data(), translucentData.size(), pixmap);
Execution Count:2
2
1052 -
1053 if (oldAA)
partially evaluated: oldAA
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1054 painter->setRenderHint(QPainter::Antialiasing, true);
never executed: painter->setRenderHint(QPainter::Antialiasing, true);
0
1055}
executed: }
Execution Count:2
2
1056 -
1057QT_END_NAMESPACE -
1058 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial