qbrush.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qbrush.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 QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and 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 "qbrush.h"-
41#include "qpixmap.h"-
42#include "qbitmap.h"-
43#include "qpixmapcache.h"-
44#include <qpa/qplatformpixmap.h>-
45#include "qdatastream.h"-
46#include "qvariant.h"-
47#include "qline.h"-
48#include "qdebug.h"-
49#include <QtCore/qcoreapplication.h>-
50#include "private/qhexstring_p.h"-
51#include <QtCore/qnumeric.h>-
52-
53QT_BEGIN_NAMESPACE-
54-
55const uchar *qt_patternForBrush(int brushStyle, bool invert)-
56{-
57 Q_ASSERT(brushStyle > Qt::SolidPattern && brushStyle < Qt::LinearGradientPattern);-
58 static const uchar pat_tbl[][2][8] = {-
59 {-
60 /* dense1 */ { 0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00 },-
61 /*~dense1 */ { 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff },-
62 }, {-
63 /* dense2 */ { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 },-
64 /*~dense2 */ { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xdd, 0xff },-
65 }, {-
66 /* dense3 */ { 0xaa, 0x44, 0xaa, 0x11, 0xaa, 0x44, 0xaa, 0x11 },-
67 /*~dense3 */ { 0x55, 0xbb, 0x55, 0xee, 0x55, 0xbb, 0x55, 0xee },-
68 }, {-
69 /* dense4 */ { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa },-
70 /*~dense4 */ { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 },-
71 }, {-
72 /* dense5 */ { 0x55, 0xbb, 0x55, 0xee, 0x55, 0xbb, 0x55, 0xee },-
73 /*~dense5 */ { 0xaa, 0x44, 0xaa, 0x11, 0xaa, 0x44, 0xaa, 0x11 },-
74 }, {-
75 /* dense6 */ { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xdd, 0xff },-
76 /*~dense6 */ { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 },-
77 }, {-
78 /* dense7 */ { 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff },-
79 /*~dense7 */ { 0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00 },-
80 }, {-
81 /* hor */ { 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff },-
82 /*~hor */ { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 },-
83 }, {-
84 /* ver */ { 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef },-
85 /*~ver */ { 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 },-
86 }, {-
87 /* cross */ { 0xef, 0xef, 0xef, 0x00, 0xef, 0xef, 0xef, 0xef },-
88 /*~cross */ { 0x10, 0x10, 0x10, 0xff, 0x10, 0x10, 0x10, 0x10 },-
89 }, {-
90 /* bdiag */ { 0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe },-
91 /*~bdiag */ { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 },-
92 }, {-
93 /* fdiag */ { 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f },-
94 /*~fdiag */ { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 },-
95 }, {-
96 /* dcross */ { 0x7e, 0xbd, 0xdb, 0xe7, 0xe7, 0xdb, 0xbd, 0x7e },-
97 /*~dcross */ { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 },-
98 },-
99 };-
100 return pat_tbl[brushStyle - Qt::Dense1Pattern][invert];
never executed: return pat_tbl[brushStyle - Qt::Dense1Pattern][invert];
0
101}-
102-
103QPixmap qt_pixmapForBrush(int brushStyle, bool invert)-
104{-
105-
106 QPixmap pm;-
107 QString key = QLatin1String("$qt-brush$")-
108 % HexString<uint>(brushStyle)-
109 % QLatin1Char(invert ? '1' : '0');-
110 if (!QPixmapCache::find(key, pm)) {
!QPixmapCache::find(key, pm)Description
TRUEnever evaluated
FALSEnever evaluated
0
111 pm = QBitmap::fromData(QSize(8, 8), qt_patternForBrush(brushStyle, invert),-
112 QImage::Format_MonoLSB);-
113 QPixmapCache::insert(key, pm);-
114 }
never executed: end of block
0
115-
116 return pm;
never executed: return pm;
0
117}-
118-
119static void qt_cleanup_brush_pattern_image_cache();-
120class QBrushPatternImageCache-
121{-
122public:-
123 QBrushPatternImageCache()-
124 : m_initialized(false)-
125 {-
126 init();-
127 }
never executed: end of block
0
128-
129 void init()-
130 {-
131 qAddPostRoutine(qt_cleanup_brush_pattern_image_cache);-
132 for (int style = Qt::Dense1Pattern; style <= Qt::DiagCrossPattern; ++style) {
style <= Qt::DiagCrossPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
133 int i = style - Qt::Dense1Pattern;-
134 m_images[i][0] = QImage(qt_patternForBrush(style, 0), 8, 8, 1, QImage::Format_MonoLSB);-
135 m_images[i][1] = QImage(qt_patternForBrush(style, 1), 8, 8, 1, QImage::Format_MonoLSB);-
136 }
never executed: end of block
0
137 m_initialized = true;-
138 }
never executed: end of block
0
139-
140 QImage getImage(int brushStyle, bool invert) const-
141 {-
142 Q_ASSERT(brushStyle >= Qt::Dense1Pattern && brushStyle <= Qt::DiagCrossPattern);-
143 if (!m_initialized)
!m_initializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
144 const_cast<QBrushPatternImageCache*>(this)->init();
never executed: const_cast<QBrushPatternImageCache*>(this)->init();
0
145 return m_images[brushStyle - Qt::Dense1Pattern][invert];
never executed: return m_images[brushStyle - Qt::Dense1Pattern][invert];
0
146 }-
147-
148 void cleanup() {-
149 for (int style = Qt::Dense1Pattern; style <= Qt::DiagCrossPattern; ++style) {
style <= Qt::DiagCrossPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
150 int i = style - Qt::Dense1Pattern;-
151 m_images[i][0] = QImage();-
152 m_images[i][1] = QImage();-
153 }
never executed: end of block
0
154 m_initialized = false;-
155 }
never executed: end of block
0
156-
157private:-
158 QImage m_images[Qt::DiagCrossPattern - Qt::Dense1Pattern + 1][2];-
159 bool m_initialized;-
160};-
161-
162Q_GLOBAL_STATIC(QBrushPatternImageCache, qt_brushPatternImageCache)
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
163-
164static void qt_cleanup_brush_pattern_image_cache()-
165{-
166 qt_brushPatternImageCache()->cleanup();-
167}
never executed: end of block
0
168-
169Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert)-
170{-
171 return qt_brushPatternImageCache()->getImage(brushStyle, invert);
never executed: return qt_brushPatternImageCache()->getImage(brushStyle, invert);
0
172}-
173-
174struct QTexturedBrushData : public QBrushData-
175{-
176 QTexturedBrushData() {-
177 m_has_pixmap_texture = false;-
178 m_pixmap = 0;-
179 }
never executed: end of block
0
180 ~QTexturedBrushData() {-
181 delete m_pixmap;-
182 }
never executed: end of block
0
183-
184 void setPixmap(const QPixmap &pm) {-
185 delete m_pixmap;-
186-
187 if (pm.isNull()) {
pm.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
188 m_pixmap = 0;-
189 m_has_pixmap_texture = false;-
190 } else {
never executed: end of block
0
191 m_pixmap = new QPixmap(pm);-
192 m_has_pixmap_texture = true;-
193 }
never executed: end of block
0
194-
195 m_image = QImage();-
196 }
never executed: end of block
0
197-
198 void setImage(const QImage &image) {-
199 m_image = image;-
200 delete m_pixmap;-
201 m_pixmap = 0;-
202 m_has_pixmap_texture = false;-
203 }
never executed: end of block
0
204-
205 QPixmap &pixmap() {-
206 if (!m_pixmap) {
!m_pixmapDescription
TRUEnever evaluated
FALSEnever evaluated
0
207 m_pixmap = new QPixmap(QPixmap::fromImage(m_image));-
208 }
never executed: end of block
0
209 return *m_pixmap;
never executed: return *m_pixmap;
0
210 }-
211-
212 QImage &image() {-
213 if (m_image.isNull() && m_pixmap)
m_image.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
m_pixmapDescription
TRUEnever evaluated
FALSEnever evaluated
0
214 m_image = m_pixmap->toImage();
never executed: m_image = m_pixmap->toImage();
0
215 return m_image;
never executed: return m_image;
0
216 }-
217-
218 QPixmap *m_pixmap;-
219 QImage m_image;-
220 bool m_has_pixmap_texture;-
221};-
222-
223// returns true if the brush has a pixmap (or bitmap) set as the-
224// brush texture, false otherwise-
225bool Q_GUI_EXPORT qHasPixmapTexture(const QBrush& brush)-
226{-
227 if (brush.style() != Qt::TexturePattern)
brush.style() ...TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
228 return false;
never executed: return false;
0
229 QTexturedBrushData *tx_data = static_cast<QTexturedBrushData *>(brush.d.data());-
230 return tx_data->m_has_pixmap_texture;
never executed: return tx_data->m_has_pixmap_texture;
0
231}-
232-
233struct QGradientBrushData : public QBrushData-
234{-
235 QGradient gradient;-
236};-
237-
238struct QBrushDataPointerDeleter-
239{-
240 static inline void deleteData(QBrushData *d)-
241 {-
242 switch (d->style) {-
243 case Qt::TexturePattern:
never executed: case Qt::TexturePattern:
0
244 delete static_cast<QTexturedBrushData*>(d);-
245 break;
never executed: break;
0
246 case Qt::LinearGradientPattern:
never executed: case Qt::LinearGradientPattern:
0
247 case Qt::RadialGradientPattern:
never executed: case Qt::RadialGradientPattern:
0
248 case Qt::ConicalGradientPattern:
never executed: case Qt::ConicalGradientPattern:
0
249 delete static_cast<QGradientBrushData*>(d);-
250 break;
never executed: break;
0
251 default:
never executed: default:
0
252 delete d;-
253 }
never executed: end of block
0
254 }-
255-
256 static inline void cleanup(QBrushData *d)-
257 {-
258 if (d && !d->ref.deref()) {
dDescription
TRUEnever evaluated
FALSEnever evaluated
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
259 deleteData(d);-
260 }
never executed: end of block
0
261 }
never executed: end of block
0
262};-
263-
264/*!-
265 \class QBrush-
266 \ingroup painting-
267 \ingroup shared-
268 \inmodule QtGui-
269-
270 \brief The QBrush class defines the fill pattern of shapes drawn-
271 by QPainter.-
272-
273 A brush has a style, a color, a gradient and a texture.-
274-
275 The brush style() defines the fill pattern using the-
276 Qt::BrushStyle enum. The default brush style is Qt::NoBrush-
277 (depending on how you construct a brush). This style tells the-
278 painter to not fill shapes. The standard style for filling is-
279 Qt::SolidPattern. The style can be set when the brush is created-
280 using the appropriate constructor, and in addition the setStyle()-
281 function provides means for altering the style once the brush is-
282 constructed.-
283-
284 \image brush-styles.png Brush Styles-
285-
286 The brush color() defines the color of the fill pattern. The color-
287 can either be one of Qt's predefined colors, Qt::GlobalColor, or-
288 any other custom QColor. The currently set color can be retrieved-
289 and altered using the color() and setColor() functions,-
290 respectively.-
291-
292 The gradient() defines the gradient fill used when the current-
293 style is either Qt::LinearGradientPattern,-
294 Qt::RadialGradientPattern or Qt::ConicalGradientPattern. Gradient-
295 brushes are created by giving a QGradient as a constructor-
296 argument when creating the QBrush. Qt provides three different-
297 gradients: QLinearGradient, QConicalGradient, and QRadialGradient-
298 - all of which inherit QGradient.-
299-
300 \snippet brush/gradientcreationsnippet.cpp 0-
301-
302 The texture() defines the pixmap used when the current style is-
303 Qt::TexturePattern. You can create a brush with a texture by-
304 providing the pixmap when the brush is created or by using-
305 setTexture().-
306-
307 Note that applying setTexture() makes style() ==-
308 Qt::TexturePattern, regardless of previous style-
309 settings. Also, calling setColor() will not make a difference if-
310 the style is a gradient. The same is the case if the style is-
311 Qt::TexturePattern style unless the current texture is a QBitmap.-
312-
313 The isOpaque() function returns \c true if the brush is fully opaque-
314 otherwise false. A brush is considered opaque if:-
315-
316 \list-
317 \li The alpha component of the color() is 255.-
318 \li Its texture() does not have an alpha channel and is not a QBitmap.-
319 \li The colors in the gradient() all have an alpha component that is 255.-
320 \endlist-
321-
322 \table 100%-
323 \row-
324 \li \inlineimage brush-outline.png Outlines-
325 \li-
326-
327 To specify the style and color of lines and outlines, use the-
328 QPainter's \l {QPen}{pen} combined with Qt::PenStyle and-
329 Qt::GlobalColor:-
330-
331 \snippet code/src_gui_painting_qbrush.cpp 0-
332-
333 Note that, by default, QPainter renders the outline (using the-
334 currently set pen) when drawing shapes. Use \l {Qt::NoPen}{\c-
335 painter.setPen(Qt::NoPen)} to disable this behavior.-
336-
337 \endtable-
338-
339 For more information about painting in general, see the \l{Paint-
340 System}.-
341-
342 \sa Qt::BrushStyle, QPainter, QColor-
343*/-
344-
345class QNullBrushData-
346{-
347public:-
348 QBrushData *brush;-
349 QNullBrushData() : brush(new QBrushData)-
350 {-
351 brush->ref.store(1);-
352 brush->style = Qt::BrushStyle(0);-
353 brush->color = Qt::black;-
354 }
never executed: end of block
0
355 ~QNullBrushData()-
356 {-
357 if (!brush->ref.deref())
!brush->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
358 delete brush;
never executed: delete brush;
0
359 brush = 0;-
360 }
never executed: end of block
0
361};-
362-
363Q_GLOBAL_STATIC(QNullBrushData, nullBrushInstance_holder)
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
364static QBrushData *nullBrushInstance()-
365{-
366 return nullBrushInstance_holder()->brush;
never executed: return nullBrushInstance_holder()->brush;
0
367}-
368-
369static bool qbrush_check_type(Qt::BrushStyle style) {-
370 switch (style) {-
371 case Qt::TexturePattern:
never executed: case Qt::TexturePattern:
0
372 qWarning("QBrush: Incorrect use of TexturePattern");-
373 break;
never executed: break;
0
374 case Qt::LinearGradientPattern:
never executed: case Qt::LinearGradientPattern:
0
375 case Qt::RadialGradientPattern:
never executed: case Qt::RadialGradientPattern:
0
376 case Qt::ConicalGradientPattern:
never executed: case Qt::ConicalGradientPattern:
0
377 qWarning("QBrush: Wrong use of a gradient pattern");-
378 break;
never executed: break;
0
379 default:
never executed: default:
0
380 return true;
never executed: return true;
0
381 }-
382 return false;
never executed: return false;
0
383}-
384-
385/*!-
386 \internal-
387 Initializes the brush.-
388*/-
389-
390void QBrush::init(const QColor &color, Qt::BrushStyle style)-
391{-
392 switch(style) {-
393 case Qt::NoBrush:
never executed: case Qt::NoBrush:
0
394 d.reset(nullBrushInstance());-
395 d->ref.ref();-
396 if (d->color != color) setColor(color);
never executed: setColor(color);
d->color != colorDescription
TRUEnever evaluated
FALSEnever evaluated
0
397 return;
never executed: return;
0
398 case Qt::TexturePattern:
never executed: case Qt::TexturePattern:
0
399 d.reset(new QTexturedBrushData);-
400 break;
never executed: break;
0
401 case Qt::LinearGradientPattern:
never executed: case Qt::LinearGradientPattern:
0
402 case Qt::RadialGradientPattern:
never executed: case Qt::RadialGradientPattern:
0
403 case Qt::ConicalGradientPattern:
never executed: case Qt::ConicalGradientPattern:
0
404 d.reset(new QGradientBrushData);-
405 break;
never executed: break;
0
406 default:
never executed: default:
0
407 d.reset(new QBrushData);-
408 break;
never executed: break;
0
409 }-
410 d->ref.store(1);-
411 d->style = style;-
412 d->color = color;-
413}
never executed: end of block
0
414-
415/*!-
416 Constructs a default black brush with the style Qt::NoBrush-
417 (i.e. this brush will not fill shapes).-
418*/-
419-
420QBrush::QBrush()-
421 : d(nullBrushInstance())-
422{-
423 Q_ASSERT(d);-
424 d->ref.ref();-
425}
never executed: end of block
0
426-
427/*!-
428 Constructs a brush with a black color and a texture set to the-
429 given \a pixmap. The style is set to Qt::TexturePattern.-
430-
431 \sa setTexture()-
432*/-
433-
434QBrush::QBrush(const QPixmap &pixmap)-
435{-
436 init(Qt::black, Qt::TexturePattern);-
437 setTexture(pixmap);-
438}
never executed: end of block
0
439-
440-
441/*!-
442 Constructs a brush with a black color and a texture set to the-
443 given \a image. The style is set to Qt::TexturePattern.-
444-
445 \sa setTextureImage()-
446*/-
447-
448QBrush::QBrush(const QImage &image)-
449{-
450 init(Qt::black, Qt::TexturePattern);-
451 setTextureImage(image);-
452}
never executed: end of block
0
453-
454/*!-
455 Constructs a black brush with the given \a style.-
456-
457 \sa setStyle()-
458*/-
459-
460QBrush::QBrush(Qt::BrushStyle style)-
461{-
462 if (qbrush_check_type(style))
qbrush_check_type(style)Description
TRUEnever evaluated
FALSEnever evaluated
0
463 init(Qt::black, style);
never executed: init(Qt::black, style);
0
464 else {-
465 d.reset(nullBrushInstance());-
466 d->ref.ref();-
467 }
never executed: end of block
0
468}-
469-
470/*!-
471 Constructs a brush with the given \a color and \a style.-
472-
473 \sa setColor(), setStyle()-
474*/-
475-
476QBrush::QBrush(const QColor &color, Qt::BrushStyle style)-
477{-
478 if (qbrush_check_type(style))
qbrush_check_type(style)Description
TRUEnever evaluated
FALSEnever evaluated
0
479 init(color, style);
never executed: init(color, style);
0
480 else {-
481 d.reset(nullBrushInstance());-
482 d->ref.ref();-
483 }
never executed: end of block
0
484}-
485-
486/*!-
487 \fn QBrush::QBrush(Qt::GlobalColor color, Qt::BrushStyle style)-
488-
489 Constructs a brush with the given \a color and \a style.-
490-
491 \sa setColor(), setStyle()-
492*/-
493QBrush::QBrush(Qt::GlobalColor color, Qt::BrushStyle style)-
494{-
495 if (qbrush_check_type(style))
qbrush_check_type(style)Description
TRUEnever evaluated
FALSEnever evaluated
0
496 init(color, style);
never executed: init(color, style);
0
497 else {-
498 d.reset(nullBrushInstance());-
499 d->ref.ref();-
500 }
never executed: end of block
0
501}-
502-
503/*!-
504 Constructs a brush with the given \a color and the custom pattern-
505 stored in \a pixmap.-
506-
507 The style is set to Qt::TexturePattern. The color will only have-
508 an effect for QBitmaps.-
509-
510 \sa setColor(), setTexture()-
511*/-
512-
513QBrush::QBrush(const QColor &color, const QPixmap &pixmap)-
514{-
515 init(color, Qt::TexturePattern);-
516 setTexture(pixmap);-
517}
never executed: end of block
0
518-
519/*!-
520-
521 Constructs a brush with the given \a color and the custom pattern-
522 stored in \a pixmap.-
523-
524 The style is set to Qt::TexturePattern. The color will only have-
525 an effect for QBitmaps.-
526-
527 \sa setColor(), setTexture()-
528*/-
529QBrush::QBrush(Qt::GlobalColor color, const QPixmap &pixmap)-
530{-
531 init(color, Qt::TexturePattern);-
532 setTexture(pixmap);-
533}
never executed: end of block
0
534-
535/*!-
536 Constructs a copy of \a other.-
537*/-
538-
539QBrush::QBrush(const QBrush &other)-
540 : d(other.d.data())-
541{-
542 d->ref.ref();-
543}
never executed: end of block
0
544-
545/*!-
546 Constructs a brush based on the given \a gradient.-
547-
548 The brush style is set to the corresponding gradient style (either-
549 Qt::LinearGradientPattern, Qt::RadialGradientPattern or-
550 Qt::ConicalGradientPattern).-
551*/-
552QBrush::QBrush(const QGradient &gradient)-
553{-
554 Q_ASSERT_X(gradient.type() != QGradient::NoGradient, "QBrush::QBrush",-
555 "QGradient should not be used directly, use the linear, radial\n"-
556 "or conical gradients instead");-
557-
558 const Qt::BrushStyle enum_table[] = {-
559 Qt::LinearGradientPattern,-
560 Qt::RadialGradientPattern,-
561 Qt::ConicalGradientPattern-
562 };-
563-
564 init(QColor(), enum_table[gradient.type()]);-
565 QGradientBrushData *grad = static_cast<QGradientBrushData *>(d.data());-
566 grad->gradient = gradient;-
567}
never executed: end of block
0
568-
569/*!-
570 Destroys the brush.-
571*/-
572-
573QBrush::~QBrush()-
574{-
575}-
576-
577void QBrush::cleanUp(QBrushData *x)-
578{-
579 QBrushDataPointerDeleter::deleteData(x);-
580}
never executed: end of block
0
581-
582-
583void QBrush::detach(Qt::BrushStyle newStyle)-
584{-
585 if (newStyle == d->style && d->ref.load() == 1)
newStyle == d->styleDescription
TRUEnever evaluated
FALSEnever evaluated
d->ref.load() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
586 return;
never executed: return;
0
587-
588 QScopedPointer<QBrushData, QBrushDataPointerDeleter> x;-
589 switch(newStyle) {-
590 case Qt::TexturePattern: {
never executed: case Qt::TexturePattern:
0
591 QTexturedBrushData *tbd = new QTexturedBrushData;-
592 if (d->style == Qt::TexturePattern) {
d->style == Qt::TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
593 QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data());-
594 if (data->m_has_pixmap_texture)
data->m_has_pixmap_textureDescription
TRUEnever evaluated
FALSEnever evaluated
0
595 tbd->setPixmap(data->pixmap());
never executed: tbd->setPixmap(data->pixmap());
0
596 else-
597 tbd->setImage(data->image());
never executed: tbd->setImage(data->image());
0
598 }-
599 x.reset(tbd);-
600 break;
never executed: break;
0
601 }-
602 case Qt::LinearGradientPattern:
never executed: case Qt::LinearGradientPattern:
0
603 case Qt::RadialGradientPattern:
never executed: case Qt::RadialGradientPattern:
0
604 case Qt::ConicalGradientPattern: {
never executed: case Qt::ConicalGradientPattern:
0
605 QGradientBrushData *gbd = new QGradientBrushData;-
606 switch (d->style) {-
607 case Qt::LinearGradientPattern:
never executed: case Qt::LinearGradientPattern:
0
608 case Qt::RadialGradientPattern:
never executed: case Qt::RadialGradientPattern:
0
609 case Qt::ConicalGradientPattern:
never executed: case Qt::ConicalGradientPattern:
0
610 gbd->gradient =-
611 static_cast<QGradientBrushData *>(d.data())->gradient;-
612 break;
never executed: break;
0
613 default:
never executed: default:
0
614 break;
never executed: break;
0
615 }-
616 x.reset(gbd);-
617 break;
never executed: break;
0
618 }-
619 default:
never executed: default:
0
620 x.reset(new QBrushData);-
621 break;
never executed: break;
0
622 }-
623 x->ref.store(1); // must be first lest the QBrushDataPointerDeleter turns into a no-op-
624 x->style = newStyle;-
625 x->color = d->color;-
626 x->transform = d->transform;-
627 d.swap(x);-
628}
never executed: end of block
0
629-
630-
631/*!-
632 \fn QBrush &QBrush::operator=(const QBrush &brush)-
633-
634 Assigns the given \a brush to \e this brush and returns a-
635 reference to \e this brush.-
636*/-
637-
638QBrush &QBrush::operator=(const QBrush &b)-
639{-
640 if (d == b.d)
d == b.dDescription
TRUEnever evaluated
FALSEnever evaluated
0
641 return *this;
never executed: return *this;
0
642-
643 b.d->ref.ref();-
644 d.reset(b.d.data());-
645 return *this;
never executed: return *this;
0
646}-
647-
648/*!-
649 \fn QBrush &QBrush::operator=(QBrush &&other)-
650-
651 Move-assigns \a other to this QBrush instance.-
652-
653 \since 5.2-
654*/-
655-
656/*!-
657 \fn void QBrush::swap(QBrush &other)-
658 \since 4.8-
659-
660 Swaps brush \a other with this brush. This operation is very-
661 fast and never fails.-
662*/-
663-
664/*!-
665 Returns the brush as a QVariant-
666*/-
667QBrush::operator QVariant() const-
668{-
669 return QVariant(QVariant::Brush, this);
never executed: return QVariant(QVariant::Brush, this);
0
670}-
671-
672/*!-
673 \fn Qt::BrushStyle QBrush::style() const-
674-
675 Returns the brush style.-
676-
677 \sa setStyle()-
678*/-
679-
680/*!-
681 Sets the brush style to \a style.-
682-
683 \sa style()-
684*/-
685-
686void QBrush::setStyle(Qt::BrushStyle style)-
687{-
688 if (d->style == style)
d->style == styleDescription
TRUEnever evaluated
FALSEnever evaluated
0
689 return;
never executed: return;
0
690-
691 if (qbrush_check_type(style)) {
qbrush_check_type(style)Description
TRUEnever evaluated
FALSEnever evaluated
0
692 detach(style);-
693 d->style = style;-
694 }
never executed: end of block
0
695}
never executed: end of block
0
696-
697-
698/*!-
699 \fn const QColor &QBrush::color() const-
700-
701 Returns the brush color.-
702-
703 \sa setColor()-
704*/-
705-
706/*!-
707 \fn void QBrush::setColor(const QColor &color)-
708-
709 Sets the brush color to the given \a color.-
710-
711 Note that calling setColor() will not make a difference if the-
712 style is a gradient. The same is the case if the style is-
713 Qt::TexturePattern style unless the current texture is a QBitmap.-
714-
715 \sa color()-
716*/-
717-
718void QBrush::setColor(const QColor &c)-
719{-
720 if (d->color == c)
d->color == cDescription
TRUEnever evaluated
FALSEnever evaluated
0
721 return;
never executed: return;
0
722-
723 detach(d->style);-
724 d->color = c;-
725}
never executed: end of block
0
726-
727/*!-
728 \fn void QBrush::setColor(Qt::GlobalColor color)-
729 \overload-
730-
731 Sets the brush color to the given \a color.-
732*/-
733-
734/*!-
735 \fn QPixmap QBrush::texture() const-
736-
737 Returns the custom brush pattern, or a null pixmap if no custom brush pattern-
738 has been set.-
739-
740 \sa setTexture()-
741*/-
742QPixmap QBrush::texture() const-
743{-
744 return d->style == Qt::TexturePattern
never executed: return d->style == Qt::TexturePattern ? (static_cast<QTexturedBrushData *>(d.data()))->pixmap() : QPixmap();
0
745 ? (static_cast<QTexturedBrushData *>(d.data()))->pixmap()
never executed: return d->style == Qt::TexturePattern ? (static_cast<QTexturedBrushData *>(d.data()))->pixmap() : QPixmap();
0
746 : QPixmap();
never executed: return d->style == Qt::TexturePattern ? (static_cast<QTexturedBrushData *>(d.data()))->pixmap() : QPixmap();
0
747}-
748-
749/*!-
750 Sets the brush pixmap to \a pixmap. The style is set to-
751 Qt::TexturePattern.-
752-
753 The current brush color will only have an effect for monochrome-
754 pixmaps, i.e. for QPixmap::depth() == 1 (\l {QBitmap}{QBitmaps}).-
755-
756 \sa texture()-
757*/-
758-
759void QBrush::setTexture(const QPixmap &pixmap)-
760{-
761 if (!pixmap.isNull()) {
!pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
762 detach(Qt::TexturePattern);-
763 QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data());-
764 data->setPixmap(pixmap);-
765 } else {
never executed: end of block
0
766 detach(Qt::NoBrush);-
767 }
never executed: end of block
0
768}-
769-
770-
771/*!-
772 \since 4.2-
773-
774 Returns the custom brush pattern, or a null image if no custom-
775 brush pattern has been set.-
776-
777 If the texture was set as a QPixmap it will be converted to a-
778 QImage.-
779-
780 \sa setTextureImage()-
781*/-
782-
783QImage QBrush::textureImage() const-
784{-
785 return d->style == Qt::TexturePattern
never executed: return d->style == Qt::TexturePattern ? (static_cast<QTexturedBrushData *>(d.data()))->image() : QImage();
0
786 ? (static_cast<QTexturedBrushData *>(d.data()))->image()
never executed: return d->style == Qt::TexturePattern ? (static_cast<QTexturedBrushData *>(d.data()))->image() : QImage();
0
787 : QImage();
never executed: return d->style == Qt::TexturePattern ? (static_cast<QTexturedBrushData *>(d.data()))->image() : QImage();
0
788}-
789-
790-
791/*!-
792 \since 4.2-
793-
794 Sets the brush image to \a image. The style is set to-
795 Qt::TexturePattern.-
796-
797 Note the current brush color will \e not have any affect on-
798 monochrome images, as opposed to calling setTexture() with a-
799 QBitmap. If you want to change the color of monochrome image-
800 brushes, either convert the image to QBitmap with \c-
801 QBitmap::fromImage() and set the resulting QBitmap as a texture,-
802 or change the entries in the color table for the image.-
803-
804 \sa textureImage(), setTexture()-
805*/-
806-
807void QBrush::setTextureImage(const QImage &image)-
808{-
809 if (!image.isNull()) {
!image.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
810 detach(Qt::TexturePattern);-
811 QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data());-
812 data->setImage(image);-
813 } else {
never executed: end of block
0
814 detach(Qt::NoBrush);-
815 }
never executed: end of block
0
816}-
817-
818-
819/*!-
820 Returns the gradient describing this brush.-
821*/-
822const QGradient *QBrush::gradient() const-
823{-
824 if (d->style == Qt::LinearGradientPattern
d->style == Qt...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
825 || d->style == Qt::RadialGradientPattern
d->style == Qt...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
826 || d->style == Qt::ConicalGradientPattern) {
d->style == Qt...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
827 return &static_cast<const QGradientBrushData *>(d.data())->gradient;
never executed: return &static_cast<const QGradientBrushData *>(d.data())->gradient;
0
828 }-
829 return 0;
never executed: return 0;
0
830}-
831-
832Q_GUI_EXPORT bool qt_isExtendedRadialGradient(const QBrush &brush)-
833{-
834 if (brush.style() == Qt::RadialGradientPattern) {
brush.style() ...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
835 const QGradient *g = brush.gradient();-
836 const QRadialGradient *rg = static_cast<const QRadialGradient *>(g);-
837-
838 if (!qFuzzyIsNull(rg->focalRadius()))
!qFuzzyIsNull(...focalRadius())Description
TRUEnever evaluated
FALSEnever evaluated
0
839 return true;
never executed: return true;
0
840-
841 QPointF delta = rg->focalPoint() - rg->center();-
842 if (delta.x() * delta.x() + delta.y() * delta.y() > rg->radius() * rg->radius())
delta.x() * de...* rg->radius()Description
TRUEnever evaluated
FALSEnever evaluated
0
843 return true;
never executed: return true;
0
844 }
never executed: end of block
0
845-
846 return false;
never executed: return false;
0
847}-
848-
849/*!-
850 Returns \c true if the brush is fully opaque otherwise false. A brush-
851 is considered opaque if:-
852-
853 \list-
854 \li The alpha component of the color() is 255.-
855 \li Its texture() does not have an alpha channel and is not a QBitmap.-
856 \li The colors in the gradient() all have an alpha component that is 255.-
857 \li It is an extended radial gradient.-
858 \endlist-
859*/-
860-
861bool QBrush::isOpaque() const-
862{-
863 bool opaqueColor = d->color.alpha() == 255;-
864-
865 // Test awfully simple case first-
866 if (d->style == Qt::SolidPattern)
d->style == Qt::SolidPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
867 return opaqueColor;
never executed: return opaqueColor;
0
868-
869 if (qt_isExtendedRadialGradient(*this))
qt_isExtendedR...radient(*this)Description
TRUEnever evaluated
FALSEnever evaluated
0
870 return false;
never executed: return false;
0
871-
872 if (d->style == Qt::LinearGradientPattern
d->style == Qt...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
873 || d->style == Qt::RadialGradientPattern
d->style == Qt...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
874 || d->style == Qt::ConicalGradientPattern) {
d->style == Qt...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
875 QGradientStops stops = gradient()->stops();-
876 for (int i=0; i<stops.size(); ++i)
i<stops.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
877 if (stops.at(i).second.alpha() != 255)
stops.at(i).se...alpha() != 255Description
TRUEnever evaluated
FALSEnever evaluated
0
878 return false;
never executed: return false;
0
879 return true;
never executed: return true;
0
880 } else if (d->style == Qt::TexturePattern) {
d->style == Qt::TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
881 return qHasPixmapTexture(*this)
never executed: return qHasPixmapTexture(*this) ? !texture().hasAlphaChannel() && !texture().isQBitmap() : !textureImage().hasAlphaChannel();
0
882 ? !texture().hasAlphaChannel() && !texture().isQBitmap()
never executed: return qHasPixmapTexture(*this) ? !texture().hasAlphaChannel() && !texture().isQBitmap() : !textureImage().hasAlphaChannel();
0
883 : !textureImage().hasAlphaChannel();
never executed: return qHasPixmapTexture(*this) ? !texture().hasAlphaChannel() && !texture().isQBitmap() : !textureImage().hasAlphaChannel();
0
884 }-
885-
886 return false;
never executed: return false;
0
887}-
888-
889-
890/*!-
891 \since 4.2-
892-
893 Sets \a matrix as an explicit transformation matrix on the-
894 current brush. The brush transformation matrix is merged with-
895 QPainter transformation matrix to produce the final result.-
896-
897 \sa matrix()-
898*/-
899void QBrush::setMatrix(const QMatrix &matrix)-
900{-
901 setTransform(QTransform(matrix));-
902}
never executed: end of block
0
903-
904/*!-
905 \since 4.3-
906-
907 Sets \a matrix as an explicit transformation matrix on the-
908 current brush. The brush transformation matrix is merged with-
909 QPainter transformation matrix to produce the final result.-
910-
911 \sa transform()-
912*/-
913void QBrush::setTransform(const QTransform &matrix)-
914{-
915 detach(d->style);-
916 d->transform = matrix;-
917}
never executed: end of block
0
918-
919-
920/*!-
921 \fn void QBrush::matrix() const-
922 \since 4.2-
923-
924 Returns the current transformation matrix for the brush.-
925-
926 \sa setMatrix()-
927*/-
928-
929/*!-
930 \fn bool QBrush::operator!=(const QBrush &brush) const-
931-
932 Returns \c true if the brush is different from the given \a brush;-
933 otherwise returns \c false.-
934-
935 Two brushes are different if they have different styles, colors or-
936 transforms or different pixmaps or gradients depending on the style.-
937-
938 \sa operator==()-
939*/-
940-
941/*!-
942 \fn bool QBrush::operator==(const QBrush &brush) const-
943-
944 Returns \c true if the brush is equal to the given \a brush;-
945 otherwise returns \c false.-
946-
947 Two brushes are equal if they have equal styles, colors and-
948 transforms and equal pixmaps or gradients depending on the style.-
949-
950 \sa operator!=()-
951*/-
952-
953bool QBrush::operator==(const QBrush &b) const-
954{-
955 if (b.d == d)
b.d == dDescription
TRUEnever evaluated
FALSEnever evaluated
0
956 return true;
never executed: return true;
0
957 if (b.d->style != d->style || b.d->color != d->color || b.d->transform != d->transform)
b.d->style != d->styleDescription
TRUEnever evaluated
FALSEnever evaluated
b.d->color != d->colorDescription
TRUEnever evaluated
FALSEnever evaluated
b.d->transform != d->transformDescription
TRUEnever evaluated
FALSEnever evaluated
0
958 return false;
never executed: return false;
0
959 switch (d->style) {-
960 case Qt::TexturePattern:
never executed: case Qt::TexturePattern:
0
961 {-
962 // Note this produces false negatives if the textures have identical data,-
963 // but does not share the same data in memory. Since equality is likely to-
964 // be used to avoid iterating over the data for a texture update, this should-
965 // still be better than doing an accurate comparison.-
966 const QPixmap *us = 0, *them = 0;-
967 qint64 cacheKey1, cacheKey2;-
968 if (qHasPixmapTexture(*this)) {
qHasPixmapTexture(*this)Description
TRUEnever evaluated
FALSEnever evaluated
0
969 us = (static_cast<QTexturedBrushData *>(d.data()))->m_pixmap;-
970 cacheKey1 = us->cacheKey();-
971 } else
never executed: end of block
0
972 cacheKey1 = (static_cast<QTexturedBrushData *>(d.data()))->image().cacheKey();
never executed: cacheKey1 = (static_cast<QTexturedBrushData *>(d.data()))->image().cacheKey();
0
973-
974 if (qHasPixmapTexture(b)) {
qHasPixmapTexture(b)Description
TRUEnever evaluated
FALSEnever evaluated
0
975 them = (static_cast<QTexturedBrushData *>(b.d.data()))->m_pixmap;-
976 cacheKey2 = them->cacheKey();-
977 } else
never executed: end of block
0
978 cacheKey2 = (static_cast<QTexturedBrushData *>(b.d.data()))->image().cacheKey();
never executed: cacheKey2 = (static_cast<QTexturedBrushData *>(b.d.data()))->image().cacheKey();
0
979-
980 if (cacheKey1 != cacheKey2)
cacheKey1 != cacheKey2Description
TRUEnever evaluated
FALSEnever evaluated
0
981 return false;
never executed: return false;
0
982 if (!us == !them) // both images or both pixmaps
!us == !themDescription
TRUEnever evaluated
FALSEnever evaluated
0
983 return true;
never executed: return true;
0
984 // Only raster QPixmaps use the same cachekeys as QImages.-
985 if (us && us->handle()->classId() == QPlatformPixmap::RasterClass)
usDescription
TRUEnever evaluated
FALSEnever evaluated
us->handle()->...p::RasterClassDescription
TRUEnever evaluated
FALSEnever evaluated
0
986 return true;
never executed: return true;
0
987 if (them && them->handle()->classId() == QPlatformPixmap::RasterClass)
themDescription
TRUEnever evaluated
FALSEnever evaluated
them->handle()...p::RasterClassDescription
TRUEnever evaluated
FALSEnever evaluated
0
988 return true;
never executed: return true;
0
989 return false;
never executed: return false;
0
990 }-
991 case Qt::LinearGradientPattern:
never executed: case Qt::LinearGradientPattern:
0
992 case Qt::RadialGradientPattern:
never executed: case Qt::RadialGradientPattern:
0
993 case Qt::ConicalGradientPattern:
never executed: case Qt::ConicalGradientPattern:
0
994 {-
995 const QGradientBrushData *d1 = static_cast<QGradientBrushData *>(d.data());-
996 const QGradientBrushData *d2 = static_cast<QGradientBrushData *>(b.d.data());-
997 return d1->gradient == d2->gradient;
never executed: return d1->gradient == d2->gradient;
0
998 }-
999 default:
never executed: default:
0
1000 return true;
never executed: return true;
0
1001 }-
1002}-
1003-
1004#ifndef QT_NO_DEBUG_STREAM-
1005/*!-
1006 \internal-
1007*/-
1008QDebug operator<<(QDebug dbg, const QBrush &b)-
1009{-
1010 static const char *const BRUSH_STYLES[] = {-
1011 "NoBrush",-
1012 "SolidPattern",-
1013 "Dense1Pattern",-
1014 "Dense2Pattern",-
1015 "Dense3Pattern",-
1016 "Dense4Pattern",-
1017 "Dense5Pattern",-
1018 "Dense6Pattern",-
1019 "Dense7Pattern",-
1020 "HorPattern",-
1021 "VerPattern",-
1022 "CrossPattern",-
1023 "BDiagPattern",-
1024 "FDiagPattern",-
1025 "DiagCrossPattern",-
1026 "LinearGradientPattern",-
1027 "RadialGradientPattern",-
1028 "ConicalGradientPattern",-
1029 0, 0, 0, 0, 0, 0,-
1030 "TexturePattern" // 24-
1031 };-
1032-
1033 QDebugStateSaver saver(dbg);-
1034 dbg.nospace() << "QBrush(" << b.color() << ',' << BRUSH_STYLES[b.style()] << ')';-
1035 return dbg;
never executed: return dbg;
0
1036}-
1037#endif-
1038-
1039/*****************************************************************************-
1040 QBrush stream functions-
1041 *****************************************************************************/-
1042#ifndef QT_NO_DATASTREAM-
1043/*!-
1044 \fn QDataStream &operator<<(QDataStream &stream, const QBrush &brush)-
1045 \relates QBrush-
1046-
1047 Writes the given \a brush to the given \a stream and returns a-
1048 reference to the \a stream.-
1049-
1050 \sa {Serializing Qt Data Types}-
1051*/-
1052-
1053QDataStream &operator<<(QDataStream &s, const QBrush &b)-
1054{-
1055 quint8 style = (quint8) b.style();-
1056 bool gradient_style = false;-
1057-
1058 if (style == Qt::LinearGradientPattern || style == Qt::RadialGradientPattern
style == Qt::L...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
style == Qt::R...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
1059 || style == Qt::ConicalGradientPattern)
style == Qt::C...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
1060 gradient_style = true;
never executed: gradient_style = true;
0
1061-
1062 if (s.version() < QDataStream::Qt_4_0 && gradient_style)
s.version() < ...Stream::Qt_4_0Description
TRUEnever evaluated
FALSEnever evaluated
gradient_styleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1063 style = Qt::NoBrush;
never executed: style = Qt::NoBrush;
0
1064-
1065 s << style << b.color();-
1066 if (b.style() == Qt::TexturePattern) {
b.style() == Q...TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
1067 if (s.version() >= QDataStream::Qt_5_5)
s.version() >=...Stream::Qt_5_5Description
TRUEnever evaluated
FALSEnever evaluated
0
1068 s << b.textureImage();
never executed: s << b.textureImage();
0
1069 else-
1070 s << b.texture();
never executed: s << b.texture();
0
1071 } else if (s.version() >= QDataStream::Qt_4_0 && gradient_style) {
s.version() >=...Stream::Qt_4_0Description
TRUEnever evaluated
FALSEnever evaluated
gradient_styleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1072 const QGradient *gradient = b.gradient();-
1073 int type_as_int = int(gradient->type());-
1074 s << type_as_int;-
1075 if (s.version() >= QDataStream::Qt_4_3) {
s.version() >=...Stream::Qt_4_3Description
TRUEnever evaluated
FALSEnever evaluated
0
1076 s << int(gradient->spread());-
1077 s << int(gradient->coordinateMode());-
1078 }
never executed: end of block
0
1079-
1080 if (s.version() >= QDataStream::Qt_4_5)
s.version() >=...Stream::Qt_4_5Description
TRUEnever evaluated
FALSEnever evaluated
0
1081 s << int(gradient->interpolationMode());
never executed: s << int(gradient->interpolationMode());
0
1082-
1083 if (sizeof(qreal) == sizeof(double)) {
sizeof(qreal) ...sizeof(double)Description
TRUEnever evaluated
FALSEnever evaluated
0
1084 s << gradient->stops();-
1085 } else {
never executed: end of block
0
1086 // ensure that we write doubles here instead of streaming the stops-
1087 // directly; otherwise, platforms that redefine qreal might generate-
1088 // data that cannot be read on other platforms.-
1089 QVector<QGradientStop> stops = gradient->stops();-
1090 s << quint32(stops.size());-
1091 for (int i = 0; i < stops.size(); ++i) {
i < stops.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1092 const QGradientStop &stop = stops.at(i);-
1093 s << QPair<double, QColor>(double(stop.first), stop.second);-
1094 }
never executed: end of block
0
1095 }
never executed: end of block
0
1096-
1097 if (gradient->type() == QGradient::LinearGradient) {
gradient->type...LinearGradientDescription
TRUEnever evaluated
FALSEnever evaluated
0
1098 s << static_cast<const QLinearGradient *>(gradient)->start();-
1099 s << static_cast<const QLinearGradient *>(gradient)->finalStop();-
1100 } else if (gradient->type() == QGradient::RadialGradient) {
never executed: end of block
gradient->type...RadialGradientDescription
TRUEnever evaluated
FALSEnever evaluated
0
1101 s << static_cast<const QRadialGradient *>(gradient)->center();-
1102 s << static_cast<const QRadialGradient *>(gradient)->focalPoint();-
1103 s << (double) static_cast<const QRadialGradient *>(gradient)->radius();-
1104 } else { // type == Conical
never executed: end of block
0
1105 s << static_cast<const QConicalGradient *>(gradient)->center();-
1106 s << (double) static_cast<const QConicalGradient *>(gradient)->angle();-
1107 }
never executed: end of block
0
1108 }-
1109 if (s.version() >= QDataStream::Qt_4_3)
s.version() >=...Stream::Qt_4_3Description
TRUEnever evaluated
FALSEnever evaluated
0
1110 s << b.transform();
never executed: s << b.transform();
0
1111 return s;
never executed: return s;
0
1112}-
1113-
1114/*!-
1115 \fn QDataStream &operator>>(QDataStream &stream, QBrush &brush)-
1116 \relates QBrush-
1117-
1118 Reads the given \a brush from the given \a stream and returns a-
1119 reference to the \a stream.-
1120-
1121 \sa {Serializing Qt Data Types}-
1122*/-
1123-
1124QDataStream &operator>>(QDataStream &s, QBrush &b)-
1125{-
1126 quint8 style;-
1127 QColor color;-
1128 s >> style;-
1129 s >> color;-
1130 b = QBrush(color);-
1131 if (style == Qt::TexturePattern) {
style == Qt::TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
1132 if (s.version() >= QDataStream::Qt_5_5) {
s.version() >=...Stream::Qt_5_5Description
TRUEnever evaluated
FALSEnever evaluated
0
1133 QImage img;-
1134 s >> img;-
1135 b.setTextureImage(qMove(img));-
1136 } else {
never executed: end of block
0
1137 QPixmap pm;-
1138 s >> pm;-
1139 b.setTexture(qMove(pm));-
1140 }
never executed: end of block
0
1141 } else if (style == Qt::LinearGradientPattern
style == Qt::L...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
1142 || style == Qt::RadialGradientPattern
style == Qt::R...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
1143 || style == Qt::ConicalGradientPattern) {
style == Qt::C...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
1144-
1145 int type_as_int;-
1146 QGradient::Type type;-
1147 QGradientStops stops;-
1148 QGradient::CoordinateMode cmode = QGradient::LogicalMode;-
1149 QGradient::Spread spread = QGradient::PadSpread;-
1150 QGradient::InterpolationMode imode = QGradient::ColorInterpolation;-
1151-
1152 s >> type_as_int;-
1153 type = QGradient::Type(type_as_int);-
1154 if (s.version() >= QDataStream::Qt_4_3) {
s.version() >=...Stream::Qt_4_3Description
TRUEnever evaluated
FALSEnever evaluated
0
1155 s >> type_as_int;-
1156 spread = QGradient::Spread(type_as_int);-
1157 s >> type_as_int;-
1158 cmode = QGradient::CoordinateMode(type_as_int);-
1159 }
never executed: end of block
0
1160-
1161 if (s.version() >= QDataStream::Qt_4_5) {
s.version() >=...Stream::Qt_4_5Description
TRUEnever evaluated
FALSEnever evaluated
0
1162 s >> type_as_int;-
1163 imode = QGradient::InterpolationMode(type_as_int);-
1164 }
never executed: end of block
0
1165-
1166 if (sizeof(qreal) == sizeof(double)) {
sizeof(qreal) ...sizeof(double)Description
TRUEnever evaluated
FALSEnever evaluated
0
1167 s >> stops;-
1168 } else {
never executed: end of block
0
1169 quint32 numStops;-
1170 double n;-
1171 QColor c;-
1172-
1173 s >> numStops;-
1174 stops.reserve(numStops);-
1175 for (quint32 i = 0; i < numStops; ++i) {
i < numStopsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1176 s >> n >> c;-
1177 stops << QPair<qreal, QColor>(n, c);-
1178 }
never executed: end of block
0
1179 }
never executed: end of block
0
1180-
1181 if (type == QGradient::LinearGradient) {
type == QGradi...LinearGradientDescription
TRUEnever evaluated
FALSEnever evaluated
0
1182 QPointF p1, p2;-
1183 s >> p1;-
1184 s >> p2;-
1185 QLinearGradient lg(p1, p2);-
1186 lg.setStops(stops);-
1187 lg.setSpread(spread);-
1188 lg.setCoordinateMode(cmode);-
1189 lg.setInterpolationMode(imode);-
1190 b = QBrush(lg);-
1191 } else if (type == QGradient::RadialGradient) {
never executed: end of block
type == QGradi...RadialGradientDescription
TRUEnever evaluated
FALSEnever evaluated
0
1192 QPointF center, focal;-
1193 double radius;-
1194 s >> center;-
1195 s >> focal;-
1196 s >> radius;-
1197 QRadialGradient rg(center, radius, focal);-
1198 rg.setStops(stops);-
1199 rg.setSpread(spread);-
1200 rg.setCoordinateMode(cmode);-
1201 rg.setInterpolationMode(imode);-
1202 b = QBrush(rg);-
1203 } else { // type == QGradient::ConicalGradient
never executed: end of block
0
1204 QPointF center;-
1205 double angle;-
1206 s >> center;-
1207 s >> angle;-
1208 QConicalGradient cg(center, angle);-
1209 cg.setStops(stops);-
1210 cg.setSpread(spread);-
1211 cg.setCoordinateMode(cmode);-
1212 cg.setInterpolationMode(imode);-
1213 b = QBrush(cg);-
1214 }
never executed: end of block
0
1215 } else {-
1216 b = QBrush(color, (Qt::BrushStyle)style);-
1217 }
never executed: end of block
0
1218 if (s.version() >= QDataStream::Qt_4_3) {
s.version() >=...Stream::Qt_4_3Description
TRUEnever evaluated
FALSEnever evaluated
0
1219 QTransform transform;-
1220 s >> transform;-
1221 b.setTransform(transform);-
1222 }
never executed: end of block
0
1223 return s;
never executed: return s;
0
1224}-
1225#endif // QT_NO_DATASTREAM-
1226-
1227/*******************************************************************************-
1228 * QGradient implementations-
1229 */-
1230-
1231-
1232/*!-
1233 \class QGradient-
1234 \ingroup painting-
1235 \ingroup shared-
1236 \inmodule QtGui-
1237-
1238 \brief The QGradient class is used in combination with QBrush to-
1239 specify gradient fills.-
1240-
1241 Qt currently supports three types of gradient fills:-
1242-
1243 \list-
1244 \li \e Linear gradients interpolate colors between start and end points.-
1245 \li \e Simple radial gradients interpolate colors between a focal point-
1246 and end points on a circle surrounding it.-
1247 \li \e Extended radial gradients interpolate colors between a center and-
1248 a focal circle.-
1249 \li \e Conical gradients interpolate colors around a center point.-
1250 \endlist-
1251-
1252 A gradient's type can be retrieved using the type() function.-
1253 Each of the types is represented by a subclass of QGradient:-
1254-
1255 \table-
1256 \header-
1257 \li QLinearGradient-
1258 \li QRadialGradient-
1259 \li QConicalGradient-
1260 \row-
1261 \li \inlineimage qgradient-linear.png-
1262 \li \inlineimage qgradient-radial.png-
1263 \li \inlineimage qgradient-conical.png-
1264 \endtable-
1265-
1266 The colors in a gradient are defined using stop points of the-
1267 QGradientStop type; i.e., a position and a color. Use the setColorAt()-
1268 function to define a single stop point. Alternatively, use the-
1269 setStops() function to define several stop points in one go. Note that-
1270 the latter function \e replaces the current set of stop points.-
1271-
1272 It is the gradient's complete set of stop points (accessible-
1273 through the stops() function) that describes how the gradient area-
1274 should be filled. If no stop points have been specified, a gradient-
1275 of black at 0 to white at 1 is used.-
1276-
1277 A diagonal linear gradient from black at (100, 100) to white at-
1278 (200, 200) could be specified like this:-
1279-
1280 \snippet brush/brush.cpp 0-
1281-
1282 A gradient can have an arbitrary number of stop points. The-
1283 following would create a radial gradient starting with-
1284 red in the center, blue and then green on the edges:-
1285-
1286 \snippet brush/brush.cpp 1-
1287-
1288 It is possible to repeat or reflect the gradient outside its area-
1289 by specifiying the \l {QGradient::Spread}{spread method} using the-
1290 setSpread() function. The default is to pad the outside area with-
1291 the color at the closest stop point. The currently set \l-
1292 {QGradient::Spread}{spread method} can be retrieved using the-
1293 spread() function. The QGradient::Spread enum defines three-
1294 different methods:-
1295-
1296 \table-
1297 \row-
1298 \li \inlineimage qradialgradient-pad.png-
1299 \li \inlineimage qradialgradient-repeat.png-
1300 \li \inlineimage qradialgradient-reflect.png-
1301 \row-
1302 \li \l {QGradient::PadSpread}{PadSpread}-
1303 \li \l {QGradient::RepeatSpread}{RepeatSpread}-
1304 \li \l {QGradient::ReflectSpread}{ReflectSpread}-
1305 \endtable-
1306-
1307 Note that the setSpread() function only has effect for linear and-
1308 radial gradients. The reason is that the conical gradient is-
1309 closed by definition, i.e. the \e conical gradient fills the-
1310 entire circle from 0 - 360 degrees, while the boundary of a radial-
1311 or a linear gradient can be specified through its radius or final-
1312 stop points, respectively.-
1313-
1314 The gradient coordinates can be specified in logical coordinates,-
1315 relative to device coordinates, or relative to object bounding box coordinates.-
1316 The \l {QGradient::CoordinateMode}{coordinate mode} can be set using the-
1317 setCoordinateMode() function. The default is LogicalMode, where the-
1318 gradient coordinates are specified in the same way as the object-
1319 coordinates. To retrieve the currently set \l {QGradient::CoordinateMode}-
1320 {coordinate mode} use coordinateMode().-
1321-
1322-
1323 \sa {painting/gradients}{The Gradients Example}, QBrush-
1324*/-
1325-
1326/*!-
1327 \internal-
1328*/-
1329QGradient::QGradient()-
1330 : m_type(NoGradient), dummy(0)-
1331{-
1332}
never executed: end of block
0
1333-
1334-
1335/*!-
1336 \enum QGradient::Type-
1337-
1338 Specifies the type of gradient.-
1339-
1340 \value LinearGradient Interpolates colors between start and end points-
1341 (QLinearGradient).-
1342-
1343 \value RadialGradient Interpolate colors between a focal point and end-
1344 points on a circle surrounding it (QRadialGradient).-
1345-
1346 \value ConicalGradient Interpolate colors around a center point (QConicalGradient).-
1347 \value NoGradient No gradient is used.-
1348-
1349 \sa type()-
1350*/-
1351-
1352/*!-
1353 \enum QGradient::Spread-
1354-
1355 Specifies how the area outside the gradient area should be-
1356 filled.-
1357-
1358 \value PadSpread The area is filled with the closest stop-
1359 color. This is the default.-
1360-
1361 \value RepeatSpread The gradient is repeated outside the gradient-
1362 area.-
1363-
1364 \value ReflectSpread The gradient is reflected outside the-
1365 gradient area.-
1366-
1367 \sa spread(), setSpread()-
1368*/-
1369-
1370/*!-
1371 \fn void QGradient::setSpread(Spread method)-
1372-
1373 Specifies the spread \a method that should be used for this-
1374 gradient.-
1375-
1376 Note that this function only has effect for linear and radial-
1377 gradients.-
1378-
1379 \sa spread()-
1380*/-
1381-
1382/*!-
1383 \fn QGradient::Spread QGradient::spread() const-
1384-
1385 Returns the spread method use by this gradient. The default is-
1386 PadSpread.-
1387-
1388 \sa setSpread()-
1389*/-
1390-
1391/*!-
1392 \fn QGradient::Type QGradient::type() const-
1393-
1394 Returns the type of gradient.-
1395*/-
1396-
1397/*!-
1398 \fn void QGradient::setColorAt(qreal position, const QColor &color)-
1399-
1400 Creates a stop point at the given \a position with the given \a-
1401 color. The given \a position must be in the range 0 to 1.-
1402-
1403 \sa setStops(), stops()-
1404*/-
1405-
1406void QGradient::setColorAt(qreal pos, const QColor &color)-
1407{-
1408 if ((pos > 1 || pos < 0) && !qIsNaN(pos)) {
pos > 1Description
TRUEnever evaluated
FALSEnever evaluated
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
!qIsNaN(pos)Description
TRUEnever evaluated
FALSEnever evaluated
0
1409 qWarning("QGradient::setColorAt: Color position must be specified in the range 0 to 1");-
1410 return;
never executed: return;
0
1411 }-
1412-
1413 int index = 0;-
1414 if (!qIsNaN(pos))
!qIsNaN(pos)Description
TRUEnever evaluated
FALSEnever evaluated
0
1415 while (index < m_stops.size() && m_stops.at(index).first < pos) ++index;
never executed: ++index;
index < m_stops.size()Description
TRUEnever evaluated
FALSEnever evaluated
m_stops.at(index).first < posDescription
TRUEnever evaluated
FALSEnever evaluated
0
1416-
1417 if (index < m_stops.size() && m_stops.at(index).first == pos)
index < m_stops.size()Description
TRUEnever evaluated
FALSEnever evaluated
m_stops.at(index).first == posDescription
TRUEnever evaluated
FALSEnever evaluated
0
1418 m_stops[index].second = color;
never executed: m_stops[index].second = color;
0
1419 else-
1420 m_stops.insert(index, QGradientStop(pos, color));
never executed: m_stops.insert(index, QGradientStop(pos, color));
0
1421}-
1422-
1423/*!-
1424 \fn void QGradient::setStops(const QGradientStops &stopPoints)-
1425-
1426 Replaces the current set of stop points with the given \a-
1427 stopPoints. The positions of the points must be in the range 0 to-
1428 1, and must be sorted with the lowest point first.-
1429-
1430 \sa setColorAt(), stops()-
1431*/-
1432void QGradient::setStops(const QGradientStops &stops)-
1433{-
1434 m_stops.clear();-
1435 for (int i=0; i<stops.size(); ++i)
i<stops.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1436 setColorAt(stops.at(i).first, stops.at(i).second);
never executed: setColorAt(stops.at(i).first, stops.at(i).second);
0
1437}
never executed: end of block
0
1438-
1439-
1440/*!-
1441 Returns the stop points for this gradient.-
1442-
1443 If no stop points have been specified, a gradient of black at 0 to white-
1444 at 1 is used.-
1445-
1446 \sa setStops(), setColorAt()-
1447*/-
1448QGradientStops QGradient::stops() const-
1449{-
1450 if (m_stops.isEmpty()) {
m_stops.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1451 QGradientStops tmp;-
1452 tmp << QGradientStop(0, Qt::black) << QGradientStop(1, Qt::white);-
1453 return tmp;
never executed: return tmp;
0
1454 }-
1455 return m_stops;
never executed: return m_stops;
0
1456}-
1457-
1458#define Q_DUMMY_ACCESSOR union {void *p; uint i;}; p = dummy;-
1459-
1460/*!-
1461 \enum QGradient::CoordinateMode-
1462 \since 4.4-
1463-
1464 This enum specifies how gradient coordinates map to the paint-
1465 device on which the gradient is used.-
1466-
1467 \value LogicalMode This is the default mode. The gradient coordinates-
1468 are specified logical space just like the object coordinates.-
1469 \value StretchToDeviceMode In this mode the gradient coordinates-
1470 are relative to the bounding rectangle of the paint device,-
1471 with (0,0) in the top left corner, and (1,1) in the bottom right-
1472 corner of the paint device.-
1473 \value ObjectBoundingMode In this mode the gradient coordinates are-
1474 relative to the bounding rectangle of the object being drawn, with-
1475 (0,0) in the top left corner, and (1,1) in the bottom right corner-
1476 of the object's bounding rectangle.-
1477*/-
1478-
1479/*!-
1480 \since 4.4-
1481-
1482 Returns the coordinate mode of this gradient. The default mode is-
1483 LogicalMode.-
1484*/-
1485QGradient::CoordinateMode QGradient::coordinateMode() const-
1486{-
1487 Q_DUMMY_ACCESSOR-
1488 return CoordinateMode(i & 0x03);
never executed: return CoordinateMode(i & 0x03);
0
1489}-
1490-
1491/*!-
1492 \since 4.4-
1493-
1494 Sets the coordinate mode of this gradient to \a mode. The default-
1495 mode is LogicalMode.-
1496*/-
1497void QGradient::setCoordinateMode(CoordinateMode mode)-
1498{-
1499 Q_DUMMY_ACCESSOR-
1500 i &= ~0x03;-
1501 i |= uint(mode);-
1502 dummy = p;-
1503}
never executed: end of block
0
1504-
1505/*!-
1506 \enum QGradient::InterpolationMode-
1507 \since 4.5-
1508 \internal-
1509-
1510 \value ComponentInterpolation The color components and the alpha component are-
1511 independently linearly interpolated.-
1512 \value ColorInterpolation The colors are linearly interpolated in-
1513 premultiplied color space.-
1514*/-
1515-
1516/*!-
1517 \since 4.5-
1518 \internal-
1519-
1520 Returns the interpolation mode of this gradient. The default mode is-
1521 ColorInterpolation.-
1522*/-
1523QGradient::InterpolationMode QGradient::interpolationMode() const-
1524{-
1525 Q_DUMMY_ACCESSOR-
1526 return InterpolationMode((i >> 2) & 0x01);
never executed: return InterpolationMode((i >> 2) & 0x01);
0
1527}-
1528-
1529/*!-
1530 \since 4.5-
1531 \internal-
1532-
1533 Sets the interpolation mode of this gradient to \a mode. The default-
1534 mode is ColorInterpolation.-
1535*/-
1536void QGradient::setInterpolationMode(InterpolationMode mode)-
1537{-
1538 Q_DUMMY_ACCESSOR-
1539 i &= ~(1 << 2);-
1540 i |= (uint(mode) << 2);-
1541 dummy = p;-
1542}
never executed: end of block
0
1543-
1544/*!-
1545 \fn bool QGradient::operator!=(const QGradient &gradient) const-
1546 \since 4.2-
1547-
1548 Returns \c true if the gradient is the same as the other \a gradient-
1549 specified; otherwise returns \c false.-
1550-
1551 \sa operator==()-
1552*/-
1553-
1554/*!-
1555 Returns \c true if the gradient is the same as the other \a gradient-
1556 specified; otherwise returns \c false.-
1557-
1558 \sa operator!=()-
1559*/-
1560bool QGradient::operator==(const QGradient &gradient) const-
1561{-
1562 if (gradient.m_type != m_type
gradient.m_type != m_typeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1563 || gradient.m_spread != m_spread
gradient.m_spread != m_spreadDescription
TRUEnever evaluated
FALSEnever evaluated
0
1564 || gradient.dummy != dummy) return false;
never executed: return false;
gradient.dummy != dummyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1565-
1566 if (m_type == LinearGradient) {
m_type == LinearGradientDescription
TRUEnever evaluated
FALSEnever evaluated
0
1567 if (m_data.linear.x1 != gradient.m_data.linear.x1
m_data.linear....data.linear.x1Description
TRUEnever evaluated
FALSEnever evaluated
0
1568 || m_data.linear.y1 != gradient.m_data.linear.y1
m_data.linear....data.linear.y1Description
TRUEnever evaluated
FALSEnever evaluated
0
1569 || m_data.linear.x2 != gradient.m_data.linear.x2
m_data.linear....data.linear.x2Description
TRUEnever evaluated
FALSEnever evaluated
0
1570 || m_data.linear.y2 != gradient.m_data.linear.y2)
m_data.linear....data.linear.y2Description
TRUEnever evaluated
FALSEnever evaluated
0
1571 return false;
never executed: return false;
0
1572 } else if (m_type == RadialGradient) {
never executed: end of block
m_type == RadialGradientDescription
TRUEnever evaluated
FALSEnever evaluated
0
1573 if (m_data.radial.cx != gradient.m_data.radial.cx
m_data.radial....data.radial.cxDescription
TRUEnever evaluated
FALSEnever evaluated
0
1574 || m_data.radial.cy != gradient.m_data.radial.cy
m_data.radial....data.radial.cyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1575 || m_data.radial.fx != gradient.m_data.radial.fx
m_data.radial....data.radial.fxDescription
TRUEnever evaluated
FALSEnever evaluated
0
1576 || m_data.radial.fy != gradient.m_data.radial.fy
m_data.radial....data.radial.fyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1577 || m_data.radial.cradius != gradient.m_data.radial.cradius)
m_data.radial....radial.cradiusDescription
TRUEnever evaluated
FALSEnever evaluated
0
1578 return false;
never executed: return false;
0
1579 } else { // m_type == ConicalGradient
never executed: end of block
0
1580 if (m_data.conical.cx != gradient.m_data.conical.cx
m_data.conical...ata.conical.cxDescription
TRUEnever evaluated
FALSEnever evaluated
0
1581 || m_data.conical.cy != gradient.m_data.conical.cy
m_data.conical...ata.conical.cyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1582 || m_data.conical.angle != gradient.m_data.conical.angle)
m_data.conical....conical.angleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1583 return false;
never executed: return false;
0
1584 }
never executed: end of block
0
1585-
1586 return stops() == gradient.stops();
never executed: return stops() == gradient.stops();
0
1587}-
1588-
1589/*!-
1590 \class QLinearGradient-
1591 \ingroup painting-
1592 \inmodule QtGui-
1593-
1594 \brief The QLinearGradient class is used in combination with QBrush to-
1595 specify a linear gradient brush.-
1596-
1597 Linear gradients interpolate colors between start and end-
1598 points. Outside these points the gradient is either padded,-
1599 reflected or repeated depending on the currently set \l-
1600 {QGradient::Spread}{spread} method:-
1601-
1602 \table-
1603 \row-
1604 \li \inlineimage qlineargradient-pad.png-
1605 \li \inlineimage qlineargradient-reflect.png-
1606 \li \inlineimage qlineargradient-repeat.png-
1607 \row-
1608 \li \l {QGradient::PadSpread}{PadSpread} (default)-
1609 \li \l {QGradient::ReflectSpread}{ReflectSpread}-
1610 \li \l {QGradient::RepeatSpread}{RepeatSpread}-
1611 \endtable-
1612-
1613 The colors in a gradient is defined using stop points of the-
1614 QGradientStop type, i.e. a position and a color. Use the-
1615 QGradient::setColorAt() or the QGradient::setStops() function to-
1616 define the stop points. It is the gradient's complete set of stop-
1617 points that describes how the gradient area should be filled. If-
1618 no stop points have been specified, a gradient of black at 0 to-
1619 white at 1 is used.-
1620-
1621 In addition to the functions inherited from QGradient, the-
1622 QLinearGradient class provides the finalStop() function which-
1623 returns the final stop point of the gradient, and the start()-
1624 function returning the start point of the gradient.-
1625-
1626 \sa QRadialGradient, QConicalGradient, {painting/gradients}{The-
1627 Gradients Example}-
1628*/-
1629-
1630-
1631/*!-
1632 Constructs a default linear gradient with interpolation area-
1633 between (0, 0) and (1, 1).-
1634-
1635 \sa QGradient::setColorAt(), setStart(), setFinalStop()-
1636*/-
1637-
1638QLinearGradient::QLinearGradient()-
1639{-
1640 m_type = LinearGradient;-
1641 m_spread = PadSpread;-
1642 m_data.linear.x1 = 0;-
1643 m_data.linear.y1 = 0;-
1644 m_data.linear.x2 = 1;-
1645 m_data.linear.y2 = 1;-
1646}
never executed: end of block
0
1647-
1648-
1649/*!-
1650 Constructs a linear gradient with interpolation area between the-
1651 given \a start point and \a finalStop.-
1652-
1653 \note The expected parameter values are in pixels.-
1654-
1655 \sa QGradient::setColorAt(), QGradient::setStops()-
1656*/-
1657QLinearGradient::QLinearGradient(const QPointF &start, const QPointF &finalStop)-
1658{-
1659 m_type = LinearGradient;-
1660 m_spread = PadSpread;-
1661 m_data.linear.x1 = start.x();-
1662 m_data.linear.y1 = start.y();-
1663 m_data.linear.x2 = finalStop.x();-
1664 m_data.linear.y2 = finalStop.y();-
1665}
never executed: end of block
0
1666-
1667/*!-
1668 \fn QLinearGradient::QLinearGradient(qreal x1, qreal y1, qreal x2, qreal y2)-
1669-
1670 Constructs a linear gradient with interpolation area between (\a-
1671 x1, \a y1) and (\a x2, \a y2).-
1672-
1673 \note The expected parameter values are in pixels.-
1674-
1675 \sa QGradient::setColorAt(), QGradient::setStops()-
1676*/-
1677QLinearGradient::QLinearGradient(qreal xStart, qreal yStart, qreal xFinalStop, qreal yFinalStop)-
1678{-
1679 m_type = LinearGradient;-
1680 m_spread = PadSpread;-
1681 m_data.linear.x1 = xStart;-
1682 m_data.linear.y1 = yStart;-
1683 m_data.linear.x2 = xFinalStop;-
1684 m_data.linear.y2 = yFinalStop;-
1685}
never executed: end of block
0
1686-
1687-
1688/*!-
1689 Returns the start point of this linear gradient in logical coordinates.-
1690-
1691 \sa QGradient::stops()-
1692*/-
1693-
1694QPointF QLinearGradient::start() const-
1695{-
1696 Q_ASSERT(m_type == LinearGradient);-
1697 return QPointF(m_data.linear.x1, m_data.linear.y1);
never executed: return QPointF(m_data.linear.x1, m_data.linear.y1);
0
1698}-
1699-
1700/*!-
1701 \fn void QLinearGradient::setStart(qreal x, qreal y)-
1702 \overload-
1703 \since 4.2-
1704-
1705 Sets the start point of this linear gradient in logical-
1706 coordinates to \a x, \a y.-
1707-
1708 \sa start()-
1709*/-
1710-
1711/*!-
1712 \since 4.2-
1713-
1714 Sets the start point of this linear gradient in logical-
1715 coordinates to \a start.-
1716-
1717 \sa start()-
1718*/-
1719-
1720void QLinearGradient::setStart(const QPointF &start)-
1721{-
1722 Q_ASSERT(m_type == LinearGradient);-
1723 m_data.linear.x1 = start.x();-
1724 m_data.linear.y1 = start.y();-
1725}
never executed: end of block
0
1726-
1727-
1728/*!-
1729 \fn void QLinearGradient::setFinalStop(qreal x, qreal y)-
1730 \overload-
1731 \since 4.2-
1732-
1733 Sets the final stop point of this linear gradient in logical-
1734 coordinates to \a x, \a y.-
1735-
1736 \sa start()-
1737*/-
1738-
1739/*!-
1740 Returns the final stop point of this linear gradient in logical coordinates.-
1741-
1742 \sa QGradient::stops()-
1743*/-
1744-
1745QPointF QLinearGradient::finalStop() const-
1746{-
1747 Q_ASSERT(m_type == LinearGradient);-
1748 return QPointF(m_data.linear.x2, m_data.linear.y2);
never executed: return QPointF(m_data.linear.x2, m_data.linear.y2);
0
1749}-
1750-
1751-
1752/*!-
1753 \since 4.2-
1754-
1755 Sets the final stop point of this linear gradient in logical-
1756 coordinates to \a stop.-
1757-
1758 \sa finalStop()-
1759*/-
1760-
1761void QLinearGradient::setFinalStop(const QPointF &stop)-
1762{-
1763 Q_ASSERT(m_type == LinearGradient);-
1764 m_data.linear.x2 = stop.x();-
1765 m_data.linear.y2 = stop.y();-
1766}
never executed: end of block
0
1767-
1768-
1769/*!-
1770 \class QRadialGradient-
1771 \ingroup painting-
1772 \inmodule QtGui-
1773-
1774 \brief The QRadialGradient class is used in combination with QBrush to-
1775 specify a radial gradient brush.-
1776-
1777 Qt supports both simple and extended radial gradients.-
1778-
1779 Simple radial gradients interpolate colors between a focal point and end-
1780 points on a circle surrounding it. Extended radial gradients interpolate-
1781 colors between a focal circle and a center circle. Points outside the cone-
1782 defined by the two circles will be transparent. For simple radial gradients-
1783 the focal point is adjusted to lie inside the center circle, whereas the-
1784 focal point can have any position in an extended radial gradient.-
1785-
1786 Outside the end points the gradient is either padded, reflected or repeated-
1787 depending on the currently set \l {QGradient::Spread}{spread} method:-
1788-
1789 \table-
1790 \row-
1791 \li \inlineimage qradialgradient-pad.png-
1792 \li \inlineimage qradialgradient-reflect.png-
1793 \li \inlineimage qradialgradient-repeat.png-
1794 \row-
1795 \li \l {QGradient::PadSpread}{PadSpread} (default)-
1796 \li \l {QGradient::ReflectSpread}{ReflectSpread}-
1797 \li \l {QGradient::RepeatSpread}{RepeatSpread}-
1798 \endtable-
1799-
1800 The colors in a gradient is defined using stop points of the-
1801 QGradientStop type, i.e. a position and a color. Use the-
1802 QGradient::setColorAt() or the QGradient::setStops() function to-
1803 define the stop points. It is the gradient's complete set of stop-
1804 points that describes how the gradient area should be filled. If-
1805 no stop points have been specified, a gradient of black at 0 to-
1806 white at 1 is used.-
1807-
1808 In addition to the functions inherited from QGradient, the-
1809 QRadialGradient class provides the center(), focalPoint() and-
1810 radius() functions returning the gradient's center, focal point-
1811 and radius respectively.-
1812-
1813 \sa QLinearGradient, QConicalGradient, {painting/gradients}{The-
1814 Gradients Example}-
1815*/-
1816-
1817static QPointF qt_radial_gradient_adapt_focal_point(const QPointF &center,-
1818 qreal radius,-
1819 const QPointF &focalPoint)-
1820{-
1821 // We have a one pixel buffer zone to avoid numerical instability on the-
1822 // circle border-
1823 //### this is hacky because technically we should adjust based on current matrix-
1824 const qreal compensated_radius = radius - radius * qreal(0.001);-
1825 QLineF line(center, focalPoint);-
1826 if (line.length() > (compensated_radius))
line.length() ...nsated_radius)Description
TRUEnever evaluated
FALSEnever evaluated
0
1827 line.setLength(compensated_radius);
never executed: line.setLength(compensated_radius);
0
1828 return line.p2();
never executed: return line.p2();
0
1829}-
1830-
1831/*!-
1832 Constructs a simple radial gradient with the given \a center, \a-
1833 radius and \a focalPoint.-
1834-
1835 \note If the given focal point is outside the circle defined by the-
1836 \a center point and \a radius, it will be re-adjusted to lie at a point on-
1837 the circle where it intersects with the line from \a center to-
1838 \a focalPoint.-
1839-
1840 \sa QGradient::setColorAt(), QGradient::setStops()-
1841*/-
1842-
1843QRadialGradient::QRadialGradient(const QPointF &center, qreal radius, const QPointF &focalPoint)-
1844{-
1845 m_type = RadialGradient;-
1846 m_spread = PadSpread;-
1847 m_data.radial.cx = center.x();-
1848 m_data.radial.cy = center.y();-
1849 m_data.radial.cradius = radius;-
1850-
1851 QPointF adapted_focal = qt_radial_gradient_adapt_focal_point(center, radius, focalPoint);-
1852 m_data.radial.fx = adapted_focal.x();-
1853 m_data.radial.fy = adapted_focal.y();-
1854}
never executed: end of block
0
1855-
1856/*!-
1857 Constructs a simple radial gradient with the given \a center, \a-
1858 radius and the focal point in the circle center.-
1859-
1860 \sa QGradient::setColorAt(), QGradient::setStops()-
1861*/-
1862QRadialGradient::QRadialGradient(const QPointF &center, qreal radius)-
1863{-
1864 m_type = RadialGradient;-
1865 m_spread = PadSpread;-
1866 m_data.radial.cx = center.x();-
1867 m_data.radial.cy = center.y();-
1868 m_data.radial.cradius = radius;-
1869 m_data.radial.fx = center.x();-
1870 m_data.radial.fy = center.y();-
1871}
never executed: end of block
0
1872-
1873-
1874/*!-
1875 Constructs a simple radial gradient with the given center (\a cx, \a cy),-
1876 \a radius and focal point (\a fx, \a fy).-
1877-
1878 \note If the given focal point is outside the circle defined by the-
1879 center (\a cx, \a cy) and the \a radius it will be re-adjusted to-
1880 the intersection between the line from the center to the focal point-
1881 and the circle.-
1882-
1883 \sa QGradient::setColorAt(), QGradient::setStops()-
1884*/-
1885-
1886QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius, qreal fx, qreal fy)-
1887{-
1888 m_type = RadialGradient;-
1889 m_spread = PadSpread;-
1890 m_data.radial.cx = cx;-
1891 m_data.radial.cy = cy;-
1892 m_data.radial.cradius = radius;-
1893-
1894 QPointF adapted_focal = qt_radial_gradient_adapt_focal_point(QPointF(cx, cy),-
1895 radius,-
1896 QPointF(fx, fy));-
1897-
1898 m_data.radial.fx = adapted_focal.x();-
1899 m_data.radial.fy = adapted_focal.y();-
1900}
never executed: end of block
0
1901-
1902/*!-
1903 Constructs a simple radial gradient with the center at (\a cx, \a cy) and the-
1904 specified \a radius. The focal point lies at the center of the circle.-
1905-
1906 \sa QGradient::setColorAt(), QGradient::setStops()-
1907 */-
1908QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius)-
1909{-
1910 m_type = RadialGradient;-
1911 m_spread = PadSpread;-
1912 m_data.radial.cx = cx;-
1913 m_data.radial.cy = cy;-
1914 m_data.radial.cradius = radius;-
1915 m_data.radial.fx = cx;-
1916 m_data.radial.fy = cy;-
1917}
never executed: end of block
0
1918-
1919-
1920/*!-
1921 Constructs a simple radial gradient with the center and focal point at-
1922 (0, 0) with a radius of 1.-
1923*/-
1924QRadialGradient::QRadialGradient()-
1925{-
1926 m_type = RadialGradient;-
1927 m_spread = PadSpread;-
1928 m_data.radial.cx = 0;-
1929 m_data.radial.cy = 0;-
1930 m_data.radial.cradius = 1;-
1931 m_data.radial.fx = 0;-
1932 m_data.radial.fy = 0;-
1933}
never executed: end of block
0
1934-
1935/*!-
1936 \since 4.8-
1937-
1938 Constructs an extended radial gradient with the given \a center, \a-
1939 centerRadius, \a focalPoint, and \a focalRadius.-
1940*/-
1941QRadialGradient::QRadialGradient(const QPointF &center, qreal centerRadius, const QPointF &focalPoint, qreal focalRadius)-
1942{-
1943 m_type = RadialGradient;-
1944 m_spread = PadSpread;-
1945 m_data.radial.cx = center.x();-
1946 m_data.radial.cy = center.y();-
1947 m_data.radial.cradius = centerRadius;-
1948-
1949 m_data.radial.fx = focalPoint.x();-
1950 m_data.radial.fy = focalPoint.y();-
1951 setFocalRadius(focalRadius);-
1952}
never executed: end of block
0
1953-
1954/*!-
1955 \since 4.8-
1956-
1957 Constructs an extended radial gradient with the given center-
1958 (\a cx, \a cy), center radius, \a centerRadius, focal point, (\a fx, \a fy),-
1959 and focal radius \a focalRadius.-
1960*/-
1961QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal centerRadius, qreal fx, qreal fy, qreal focalRadius)-
1962{-
1963 m_type = RadialGradient;-
1964 m_spread = PadSpread;-
1965 m_data.radial.cx = cx;-
1966 m_data.radial.cy = cy;-
1967 m_data.radial.cradius = centerRadius;-
1968-
1969 m_data.radial.fx = fx;-
1970 m_data.radial.fy = fy;-
1971 setFocalRadius(focalRadius);-
1972}
never executed: end of block
0
1973-
1974/*!-
1975 Returns the center of this radial gradient in logical coordinates.-
1976-
1977 \sa QGradient::stops()-
1978*/-
1979-
1980QPointF QRadialGradient::center() const-
1981{-
1982 Q_ASSERT(m_type == RadialGradient);-
1983 return QPointF(m_data.radial.cx, m_data.radial.cy);
never executed: return QPointF(m_data.radial.cx, m_data.radial.cy);
0
1984}-
1985-
1986/*!-
1987 \fn void QRadialGradient::setCenter(qreal x, qreal y)-
1988 \overload-
1989 \since 4.2-
1990-
1991 Sets the center of this radial gradient in logical coordinates-
1992 to (\a x, \a y).-
1993-
1994 \sa center()-
1995*/-
1996-
1997/*!-
1998 \since 4.2-
1999-
2000 Sets the center of this radial gradient in logical coordinates-
2001 to \a center.-
2002-
2003 \sa center()-
2004*/-
2005-
2006void QRadialGradient::setCenter(const QPointF &center)-
2007{-
2008 Q_ASSERT(m_type == RadialGradient);-
2009 m_data.radial.cx = center.x();-
2010 m_data.radial.cy = center.y();-
2011}
never executed: end of block
0
2012-
2013-
2014/*!-
2015 Returns the radius of this radial gradient in logical coordinates.-
2016-
2017 Equivalent to centerRadius()-
2018-
2019 \sa QGradient::stops()-
2020*/-
2021-
2022qreal QRadialGradient::radius() const-
2023{-
2024 Q_ASSERT(m_type == RadialGradient);-
2025 return m_data.radial.cradius;
never executed: return m_data.radial.cradius;
0
2026}-
2027-
2028-
2029/*!-
2030 \since 4.2-
2031-
2032 Sets the radius of this radial gradient in logical coordinates-
2033 to \a radius-
2034-
2035 Equivalent to setCenterRadius()-
2036*/-
2037void QRadialGradient::setRadius(qreal radius)-
2038{-
2039 Q_ASSERT(m_type == RadialGradient);-
2040 m_data.radial.cradius = radius;-
2041}
never executed: end of block
0
2042-
2043/*!-
2044 \since 4.8-
2045-
2046 Returns the center radius of this radial gradient in logical-
2047 coordinates.-
2048-
2049 \sa QGradient::stops()-
2050*/-
2051qreal QRadialGradient::centerRadius() const-
2052{-
2053 Q_ASSERT(m_type == RadialGradient);-
2054 return m_data.radial.cradius;
never executed: return m_data.radial.cradius;
0
2055}-
2056-
2057/*!-
2058 \since 4.8-
2059-
2060 Sets the center radius of this radial gradient in logical coordinates-
2061 to \a radius-
2062*/-
2063void QRadialGradient::setCenterRadius(qreal radius)-
2064{-
2065 Q_ASSERT(m_type == RadialGradient);-
2066 m_data.radial.cradius = radius;-
2067}
never executed: end of block
0
2068-
2069/*!-
2070 \since 4.8-
2071-
2072 Returns the focal radius of this radial gradient in logical-
2073 coordinates.-
2074-
2075 \sa QGradient::stops()-
2076*/-
2077qreal QRadialGradient::focalRadius() const-
2078{-
2079 Q_ASSERT(m_type == RadialGradient);-
2080 Q_DUMMY_ACCESSOR-
2081-
2082 // mask away low three bits-
2083 union { float f; quint32 i; } u;-
2084 u.i = i & ~0x07;-
2085 return u.f;
never executed: return u.f;
0
2086}-
2087-
2088/*!-
2089 \since 4.8-
2090-
2091 Sets the focal radius of this radial gradient in logical coordinates-
2092 to \a radius-
2093*/-
2094void QRadialGradient::setFocalRadius(qreal radius)-
2095{-
2096 Q_ASSERT(m_type == RadialGradient);-
2097 Q_DUMMY_ACCESSOR-
2098-
2099 // Since there's no QGradientData, we only have the dummy void * to-
2100 // store additional data in. The three lowest bits are already-
2101 // taken, thus we cut the three lowest bits from the significand-
2102 // and store the radius as a float.-
2103 union { float f; quint32 i; } u;-
2104 u.f = float(radius);-
2105 // add 0x04 to round up when we drop the three lowest bits-
2106 i |= (u.i + 0x04) & ~0x07;-
2107 dummy = p;-
2108}
never executed: end of block
0
2109-
2110/*!-
2111 Returns the focal point of this radial gradient in logical-
2112 coordinates.-
2113-
2114 \sa QGradient::stops()-
2115*/-
2116-
2117QPointF QRadialGradient::focalPoint() const-
2118{-
2119 Q_ASSERT(m_type == RadialGradient);-
2120 return QPointF(m_data.radial.fx, m_data.radial.fy);
never executed: return QPointF(m_data.radial.fx, m_data.radial.fy);
0
2121}-
2122-
2123/*!-
2124 \fn void QRadialGradient::setFocalPoint(qreal x, qreal y)-
2125 \overload-
2126 \since 4.2-
2127-
2128 Sets the focal point of this radial gradient in logical-
2129 coordinates to (\a x, \a y).-
2130-
2131 \sa focalPoint()-
2132*/-
2133-
2134/*!-
2135 \since 4.2-
2136-
2137 Sets the focal point of this radial gradient in logical-
2138 coordinates to \a focalPoint.-
2139-
2140 \sa focalPoint()-
2141*/-
2142-
2143void QRadialGradient::setFocalPoint(const QPointF &focalPoint)-
2144{-
2145 Q_ASSERT(m_type == RadialGradient);-
2146 m_data.radial.fx = focalPoint.x();-
2147 m_data.radial.fy = focalPoint.y();-
2148}
never executed: end of block
0
2149-
2150-
2151-
2152/*!-
2153 \class QConicalGradient-
2154 \ingroup painting-
2155 \inmodule QtGui-
2156-
2157 \brief The QConicalGradient class is used in combination with QBrush to-
2158 specify a conical gradient brush.-
2159-
2160 Conical gradients interpolate interpolate colors counter-clockwise-
2161 around a center point.-
2162-
2163 \image qconicalgradient.png-
2164-
2165 The colors in a gradient is defined using stop points of the-
2166 QGradientStop type, i.e. a position and a color. Use the-
2167 QGradient::setColorAt() or the QGradient::setStops() function to-
2168 define the stop points. It is the gradient's complete set of stop-
2169 points that describes how the gradient area should be filled. If-
2170 no stop points have been specified, a gradient of black at 0 to-
2171 white at 1 is used.-
2172-
2173 In addition to the functions inherited from QGradient, the-
2174 QConicalGradient class provides the angle() and center() functions-
2175 returning the start angle and center of the gradient.-
2176-
2177 Note that the setSpread() function has no effect for conical-
2178 gradients. The reason is that the conical gradient is closed by-
2179 definition, i.e. the conical gradient fills the entire circle from-
2180 0 - 360 degrees, while the boundary of a radial or a linear-
2181 gradient can be specified through its radius or final stop points,-
2182 respectively.-
2183-
2184 \sa QLinearGradient, QRadialGradient, {painting/gradients}{The-
2185 Gradients Example}-
2186*/-
2187-
2188-
2189/*!-
2190 Constructs a conical gradient with the given \a center, starting-
2191 the interpolation at the given \a angle. The \a angle must be-
2192 specified in degrees between 0 and 360.-
2193-
2194 \sa QGradient::setColorAt(), QGradient::setStops()-
2195*/-
2196-
2197QConicalGradient::QConicalGradient(const QPointF &center, qreal angle)-
2198{-
2199 m_type = ConicalGradient;-
2200 m_spread = PadSpread;-
2201 m_data.conical.cx = center.x();-
2202 m_data.conical.cy = center.y();-
2203 m_data.conical.angle = angle;-
2204}
never executed: end of block
0
2205-
2206-
2207/*!-
2208 Constructs a conical gradient with the given center (\a cx, \a-
2209 cy), starting the interpolation at the given \a angle. The angle-
2210 must be specified in degrees between 0 and 360.-
2211-
2212 \sa QGradient::setColorAt(), QGradient::setStops()-
2213*/-
2214-
2215QConicalGradient::QConicalGradient(qreal cx, qreal cy, qreal angle)-
2216{-
2217 m_type = ConicalGradient;-
2218 m_spread = PadSpread;-
2219 m_data.conical.cx = cx;-
2220 m_data.conical.cy = cy;-
2221 m_data.conical.angle = angle;-
2222}
never executed: end of block
0
2223-
2224-
2225/*!-
2226 Constructs a conical with center at (0, 0) starting the-
2227 interpolation at angle 0.-
2228-
2229 \sa QGradient::setColorAt(), setCenter(), setAngle()-
2230*/-
2231-
2232QConicalGradient::QConicalGradient()-
2233{-
2234 m_type = ConicalGradient;-
2235 m_spread = PadSpread;-
2236 m_data.conical.cx = 0;-
2237 m_data.conical.cy = 0;-
2238 m_data.conical.angle = 0;-
2239}
never executed: end of block
0
2240-
2241-
2242/*!-
2243 Returns the center of the conical gradient in logical-
2244 coordinates.-
2245-
2246 \sa stops()-
2247*/-
2248-
2249QPointF QConicalGradient::center() const-
2250{-
2251 Q_ASSERT(m_type == ConicalGradient);-
2252 return QPointF(m_data.conical.cx, m_data.conical.cy);
never executed: return QPointF(m_data.conical.cx, m_data.conical.cy);
0
2253}-
2254-
2255-
2256/*!-
2257 \fn void QConicalGradient::setCenter(qreal x, qreal y)-
2258-
2259 \overload-
2260-
2261 Sets the center of this conical gradient in logical coordinates to-
2262 (\a x, \a y).-
2263-
2264 \sa center()-
2265*/-
2266-
2267/*!-
2268 Sets the center of this conical gradient in logical coordinates to-
2269 \a center.-
2270-
2271 \sa center()-
2272*/-
2273-
2274void QConicalGradient::setCenter(const QPointF &center)-
2275{-
2276 Q_ASSERT(m_type == ConicalGradient);-
2277 m_data.conical.cx = center.x();-
2278 m_data.conical.cy = center.y();-
2279}
never executed: end of block
0
2280-
2281/*!-
2282 Returns the start angle of the conical gradient in logical-
2283 coordinates.-
2284-
2285 \sa stops()-
2286*/-
2287-
2288qreal QConicalGradient::angle() const-
2289{-
2290 Q_ASSERT(m_type == ConicalGradient);-
2291 return m_data.conical.angle;
never executed: return m_data.conical.angle;
0
2292}-
2293-
2294-
2295/*!-
2296 \since 4.2-
2297-
2298 Sets \a angle to be the start angle for this conical gradient in-
2299 logical coordinates.-
2300-
2301 \sa angle()-
2302*/-
2303-
2304void QConicalGradient::setAngle(qreal angle)-
2305{-
2306 Q_ASSERT(m_type == ConicalGradient);-
2307 m_data.conical.angle = angle;-
2308}
never executed: end of block
0
2309-
2310/*!-
2311 \typedef QGradientStop-
2312 \relates QGradient-
2313-
2314 Typedef for QPair<\l qreal, QColor>.-
2315*/-
2316-
2317/*!-
2318 \typedef QGradientStops-
2319 \relates QGradient-
2320-
2321 Typedef for QVector<QGradientStop>.-
2322*/-
2323-
2324/*!-
2325 \typedef QBrush::DataPtr-
2326 \internal-
2327*/-
2328-
2329/*!-
2330 \fn DataPtr &QBrush::data_ptr()-
2331 \internal-
2332*/-
2333-
2334-
2335/*!-
2336 \fn bool QBrush::isDetached() const-
2337 \internal-
2338*/-
2339-
2340/*!-
2341 \fn QTransform QBrush::transform() const-
2342 \since 4.3-
2343-
2344 Returns the current transformation matrix for the brush.-
2345-
2346 \sa setTransform()-
2347*/-
2348-
2349#undef Q_DUMMY_ACCESSOR-
2350-
2351QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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