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

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