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

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