| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #ifndef QBRUSH_H
|
|---|
| 43 | #define QBRUSH_H
|
|---|
| 44 |
|
|---|
| 45 | #include <QtCore/qpair.h>
|
|---|
| 46 | #include <QtCore/qpoint.h>
|
|---|
| 47 | #include <QtCore/qvector.h>
|
|---|
| 48 | #include <QtCore/qscopedpointer.h>
|
|---|
| 49 | #include <QtGui/qcolor.h>
|
|---|
| 50 | #include <QtGui/qmatrix.h>
|
|---|
| 51 | #include <QtGui/qtransform.h>
|
|---|
| 52 | #include <QtGui/qimage.h>
|
|---|
| 53 | #include <QtGui/qpixmap.h>
|
|---|
| 54 |
|
|---|
| 55 | #if defined(Q_OS_VXWORKS)
|
|---|
| 56 | # if defined(m_data)
|
|---|
| 57 | # undef m_data
|
|---|
| 58 | # endif
|
|---|
| 59 | # if defined(m_type)
|
|---|
| 60 | # undef m_type
|
|---|
| 61 | # endif
|
|---|
| 62 | #endif
|
|---|
| 63 |
|
|---|
| 64 | QT_BEGIN_HEADER
|
|---|
| 65 |
|
|---|
| 66 | QT_BEGIN_NAMESPACE
|
|---|
| 67 |
|
|---|
| 68 | QT_MODULE(Gui)
|
|---|
| 69 |
|
|---|
| 70 | struct QBrushData;
|
|---|
| 71 | class QPixmap;
|
|---|
| 72 | class QGradient;
|
|---|
| 73 | class QVariant;
|
|---|
| 74 | struct QBrushDataPointerDeleter;
|
|---|
| 75 |
|
|---|
| 76 | class Q_GUI_EXPORT QBrush
|
|---|
| 77 | {
|
|---|
| 78 | public:
|
|---|
| 79 | QBrush();
|
|---|
| 80 | QBrush(Qt::BrushStyle bs);
|
|---|
| 81 | QBrush(const QColor &color, Qt::BrushStyle bs=Qt::SolidPattern);
|
|---|
| 82 | QBrush(Qt::GlobalColor color, Qt::BrushStyle bs=Qt::SolidPattern);
|
|---|
| 83 |
|
|---|
| 84 | QBrush(const QColor &color, const QPixmap &pixmap);
|
|---|
| 85 | QBrush(Qt::GlobalColor color, const QPixmap &pixmap);
|
|---|
| 86 | QBrush(const QPixmap &pixmap);
|
|---|
| 87 | QBrush(const QImage &image);
|
|---|
| 88 |
|
|---|
| 89 | QBrush(const QBrush &brush);
|
|---|
| 90 |
|
|---|
| 91 | QBrush(const QGradient &gradient);
|
|---|
| 92 |
|
|---|
| 93 | ~QBrush();
|
|---|
| 94 | QBrush &operator=(const QBrush &brush);
|
|---|
| 95 | operator QVariant() const;
|
|---|
| 96 |
|
|---|
| 97 | inline Qt::BrushStyle style() const;
|
|---|
| 98 | void setStyle(Qt::BrushStyle);
|
|---|
| 99 |
|
|---|
| 100 | inline const QMatrix &matrix() const;
|
|---|
| 101 | void setMatrix(const QMatrix &mat);
|
|---|
| 102 |
|
|---|
| 103 | inline QTransform transform() const;
|
|---|
| 104 | void setTransform(const QTransform &);
|
|---|
| 105 |
|
|---|
| 106 | QPixmap texture() const;
|
|---|
| 107 | void setTexture(const QPixmap &pixmap);
|
|---|
| 108 |
|
|---|
| 109 | QImage textureImage() const;
|
|---|
| 110 | void setTextureImage(const QImage &image);
|
|---|
| 111 |
|
|---|
| 112 | inline const QColor &color() const;
|
|---|
| 113 | void setColor(const QColor &color);
|
|---|
| 114 | inline void setColor(Qt::GlobalColor color);
|
|---|
| 115 |
|
|---|
| 116 | const QGradient *gradient() const;
|
|---|
| 117 |
|
|---|
| 118 | bool isOpaque() const;
|
|---|
| 119 |
|
|---|
| 120 | bool operator==(const QBrush &b) const;
|
|---|
| 121 | inline bool operator!=(const QBrush &b) const { return !(operator==(b)); }
|
|---|
| 122 |
|
|---|
| 123 | #ifdef QT3_SUPPORT
|
|---|
| 124 | inline QT3_SUPPORT operator const QColor&() const;
|
|---|
| 125 | QT3_SUPPORT QPixmap *pixmap() const;
|
|---|
| 126 | inline QT3_SUPPORT void setPixmap(const QPixmap &pixmap) { setTexture(pixmap); }
|
|---|
| 127 | #endif
|
|---|
| 128 |
|
|---|
| 129 | private:
|
|---|
| 130 | #if defined(Q_WS_X11)
|
|---|
| 131 | friend class QX11PaintEngine;
|
|---|
| 132 | #endif
|
|---|
| 133 | friend class QRasterPaintEngine;
|
|---|
| 134 | friend class QRasterPaintEnginePrivate;
|
|---|
| 135 | friend struct QSpanData;
|
|---|
| 136 | friend class QPainter;
|
|---|
| 137 | friend bool Q_GUI_EXPORT qHasPixmapTexture(const QBrush& brush);
|
|---|
| 138 | void detach(Qt::BrushStyle newStyle);
|
|---|
| 139 | void init(const QColor &color, Qt::BrushStyle bs);
|
|---|
| 140 | QScopedPointer<QBrushData, QBrushDataPointerDeleter> d;
|
|---|
| 141 | void cleanUp(QBrushData *x);
|
|---|
| 142 |
|
|---|
| 143 | public:
|
|---|
| 144 | inline bool isDetached() const;
|
|---|
| 145 | typedef QScopedPointer<QBrushData, QBrushDataPointerDeleter> DataPtr;
|
|---|
| 146 | inline DataPtr &data_ptr() { return d; }
|
|---|
| 147 | };
|
|---|
| 148 |
|
|---|
| 149 | inline void QBrush::setColor(Qt::GlobalColor acolor)
|
|---|
| 150 | { setColor(QColor(acolor)); }
|
|---|
| 151 |
|
|---|
| 152 | Q_DECLARE_TYPEINFO(QBrush, Q_MOVABLE_TYPE);
|
|---|
| 153 | Q_DECLARE_SHARED(QBrush)
|
|---|
| 154 |
|
|---|
| 155 | /*****************************************************************************
|
|---|
| 156 | QBrush stream functions
|
|---|
| 157 | *****************************************************************************/
|
|---|
| 158 |
|
|---|
| 159 | #ifndef QT_NO_DATASTREAM
|
|---|
| 160 | Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QBrush &);
|
|---|
| 161 | Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QBrush &);
|
|---|
| 162 | #endif
|
|---|
| 163 |
|
|---|
| 164 | #ifndef QT_NO_DEBUG_STREAM
|
|---|
| 165 | Q_GUI_EXPORT QDebug operator<<(QDebug, const QBrush &);
|
|---|
| 166 | #endif
|
|---|
| 167 |
|
|---|
| 168 | struct QBrushData
|
|---|
| 169 | {
|
|---|
| 170 | QAtomicInt ref;
|
|---|
| 171 | Qt::BrushStyle style;
|
|---|
| 172 | QColor color;
|
|---|
| 173 | QTransform transform;
|
|---|
| 174 | };
|
|---|
| 175 |
|
|---|
| 176 | inline Qt::BrushStyle QBrush::style() const { return d->style; }
|
|---|
| 177 | inline const QColor &QBrush::color() const { return d->color; }
|
|---|
| 178 | inline const QMatrix &QBrush::matrix() const { return d->transform.toAffine(); }
|
|---|
| 179 | inline QTransform QBrush::transform() const { return d->transform; }
|
|---|
| 180 | inline bool QBrush::isDetached() const { return d->ref == 1; }
|
|---|
| 181 |
|
|---|
| 182 | #ifdef QT3_SUPPORT
|
|---|
| 183 | inline QBrush::operator const QColor&() const { return d->color; }
|
|---|
| 184 | #endif
|
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 | /*******************************************************************************
|
|---|
| 188 | * QGradients
|
|---|
| 189 | */
|
|---|
| 190 | class QGradientPrivate;
|
|---|
| 191 |
|
|---|
| 192 | typedef QPair<qreal, QColor> QGradientStop;
|
|---|
| 193 | typedef QVector<QGradientStop> QGradientStops;
|
|---|
| 194 |
|
|---|
| 195 | class Q_GUI_EXPORT QGradient
|
|---|
| 196 | {
|
|---|
| 197 | Q_GADGET
|
|---|
| 198 | Q_ENUMS(Type Spread CoordinateMode)
|
|---|
| 199 | public:
|
|---|
|
|---|