qdrawutil.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9