Qt 4.8
|
The QGradient class is used in combination with QBrush to specify gradient fills. More...
#include <qbrush.h>
Public Types | |
enum | CoordinateMode { LogicalMode, StretchToDeviceMode, ObjectBoundingMode } |
This enum specifies how gradient coordinates map to the paint device on which the gradient is used. More... | |
enum | InterpolationMode { ColorInterpolation, ComponentInterpolation } |
enum | Spread { PadSpread, ReflectSpread, RepeatSpread } |
Specifies how the area outside the gradient area should be filled. More... | |
enum | Type { LinearGradient, RadialGradient, ConicalGradient, NoGradient } |
Specifies the type of gradient. More... | |
Public Functions | |
CoordinateMode | coordinateMode () const |
Returns the coordinate mode of this gradient. More... | |
InterpolationMode | interpolationMode () const |
Returns the interpolation mode of this gradient. More... | |
bool | operator!= (const QGradient &other) const |
Returns true if the gradient is the same as the other gradient specified; otherwise returns false. More... | |
bool | operator== (const QGradient &gradient) const |
Returns true if the gradient is the same as the other gradient specified; otherwise returns false. More... | |
bool | operator== (const QGradient &gradient) |
QGradient () | |
void | setColorAt (qreal pos, const QColor &color) |
Creates a stop point at the given position with the given color. More... | |
void | setCoordinateMode (CoordinateMode mode) |
Sets the coordinate mode of this gradient to mode. More... | |
void | setInterpolationMode (InterpolationMode mode) |
Sets the interpolation mode of this gradient to mode. More... | |
void | setSpread (Spread spread) |
Specifies the spread method that should be used for this gradient. More... | |
void | setStops (const QGradientStops &stops) |
Replaces the current set of stop points with the given stopPoints. More... | |
Spread | spread () const |
Returns the spread method use by this gradient. More... | |
QGradientStops | stops () const |
Returns the stop points for this gradient. More... | |
Type | type () const |
Returns the type of gradient. More... | |
Properties | |
void * | dummy |
union { | |
struct { | |
qreal angle | |
qreal cx | |
qreal cy | |
} conical | |
struct { | |
qreal x1 | |
qreal x2 | |
qreal y1 | |
qreal y2 | |
} linear | |
struct { | |
qreal cradius | |
qreal cx | |
qreal cy | |
qreal fx | |
qreal fy | |
} radial | |
} | m_data |
Spread | m_spread |
QGradientStops | m_stops |
Type | m_type |
Friends | |
class | QBrush |
class | QConicalGradient |
class | QLinearGradient |
class | QRadialGradient |
Related Functions | |
(Note that these are not member functions.) | |
QGradientStop | |
Typedef for QPair<qreal , QColor>. More... | |
QGradientStops | |
Typedef for QVector<QGradientStop>. More... | |
The QGradient class is used in combination with QBrush to specify gradient fills.
Qt currently supports three types of gradient fills:
A gradient's type can be retrieved using the type() function. Each of the types is represented by a subclass of QGradient:
QLinearGradient | QRadialGradient | QConicalGradient |
The colors in a gradient are defined using stop points of the QGradientStop type; i.e., a position and a color. Use the setColorAt() function to define a single stop point. Alternatively, use the setStops() function to define several stop points in one go. Note that the latter function replaces the current set of stop points.
It is the gradient's complete set of stop points (accessible through the stops() function) that describes how the gradient area should be filled. If no stop points have been specified, a gradient of black at 0 to white at 1 is used.
A diagonal linear gradient from black at (100, 100) to white at (200, 200) could be specified like this:
A gradient can have an arbitrary number of stop points. The following would create a radial gradient starting with red in the center, blue and then green on the edges:
It is possible to repeat or reflect the gradient outside its area by specifiying the QGradient::Spread{spread method} using the setSpread() function. The default is to pad the outside area with the color at the closest stop point. The currently set QGradient::Spread can be retrieved using the spread() function. The QGradient::Spread enum defines three different methods:
QGradient::PadSpread{PadSpread} | QGradient::RepeatSpread{RepeatSpread} | QGradient::ReflectSpread{ReflectSpread} |
Note that the setSpread() function only has effect for linear and radial gradients. The reason is that the conical gradient is closed by definition, i.e. the conical gradient fills the entire circle from 0 - 360 degrees, while the boundary of a radial or a linear gradient can be specified through its radius or final stop points, respectively.
The gradient coordinates can be specified in logical coordinates, relative to device coordinates, or relative to object bounding box coordinates. The QGradient::CoordinateMode{coordinate mode} can be set using the setCoordinateMode() function. The default is LogicalMode, where the gradient coordinates are specified in the same way as the object coordinates. To retrieve the currently set QGradient::CoordinateMode {coordinate mode} use coordinateMode().
This enum specifies how gradient coordinates map to the paint device on which the gradient is used.
Enumerator | |
---|---|
LogicalMode | |
StretchToDeviceMode | |
ObjectBoundingMode |
Enumerator | |
---|---|
ColorInterpolation | |
ComponentInterpolation |
Definition at line 225 of file qbrush.h.
enum QGradient::Spread |
Specifies how the area outside the gradient area should be filled.
Enumerator | |
---|---|
PadSpread | |
ReflectSpread | |
RepeatSpread |
enum QGradient::Type |
Specifies the type of gradient.
Enumerator | |
---|---|
LinearGradient | |
RadialGradient | |
ConicalGradient | |
NoGradient |
QGradient::QGradient | ( | ) |
Definition at line 1380 of file qbrush.cpp.
QGradient::CoordinateMode QGradient::coordinateMode | ( | ) | const |
Returns the coordinate mode of this gradient.
The default mode is LogicalMode.
Definition at line 1563 of file qbrush.cpp.
Referenced by QPainterPrivate::checkEmulation(), coordinateMode(), QEmulationPaintEngine::drawTextItem(), QEmulationPaintEngine::fill(), QPainter::fillPath(), QPainter::fillRect(), fillRegion(), needsResolving(), operator<<(), QSvgPaintEngine::saveGradientUnits(), QEmulationPaintEngine::stroke(), and QPainter::strokePath().
QGradient::InterpolationMode QGradient::interpolationMode | ( | ) | const |
Returns the interpolation mode of this gradient.
The default mode is ColorInterpolation.
Definition at line 1607 of file qbrush.cpp.
Referenced by QGL2GradientCache::addCacheElement(), QGLGradientCache::addCacheElement(), QGradientCache::addCacheElement(), QGL2GradientCache::generateGradientColorTable(), QGLGradientCache::generateGradientColorTable(), QGradientCache::generateGradientColorTable(), QGL2GradientCache::getBuffer(), QGLGradientCache::getBuffer(), QGradientCache::getBuffer(), operator<<(), and QSvgPaintEngine::saveGradientStops().
|
inline |
Returns true if the gradient is the same as the other gradient specified; otherwise returns false.
Definition at line 249 of file qbrush.h.
bool QGradient::operator== | ( | const QGradient & | gradient | ) | const |
Returns true if the gradient is the same as the other gradient specified; otherwise returns false.
Definition at line 1650 of file qbrush.cpp.
bool QGradient::operator== | ( | const QGradient & | gradient | ) |
Definition at line 1682 of file qbrush.cpp.
Creates a stop point at the given position with the given color.
The given position must be in the range 0 to 1.
Definition at line 1475 of file qbrush.cpp.
Referenced by QPlastiqueStyle::drawComplexControl(), QCleanlooksStyle::drawComplexControl(), QWindowsVistaStyle::drawControl(), QCommonStyle::drawControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QMacStyle::drawControl(), QStyleHelper::drawDial(), QWindowsCEStyle::drawPrimitive(), QPlastiqueStyle::drawPrimitive(), QMacStyle::drawPrimitive(), drawTabBase(), drawTabShape(), QScriptEdit::extraAreaPaintEvent(), parseStopNode(), qt_cleanlooks_draw_buttongradient(), qt_cleanlooks_draw_gradient(), qt_cleanlooks_draw_mdibutton(), qt_plastique_draw_gradient(), and setStops().
void QGradient::setCoordinateMode | ( | CoordinateMode | mode | ) |
Sets the coordinate mode of this gradient to mode.
The default mode is LogicalMode.
Definition at line 1578 of file qbrush.cpp.
Referenced by QEmulationPaintEngine::drawTextItem(), operator>>(), parseBaseGradient(), and stretchGradientToUserSpace().
void QGradient::setInterpolationMode | ( | InterpolationMode | mode | ) |
Sets the interpolation mode of this gradient to mode.
The default mode is ColorInterpolation.
Definition at line 1623 of file qbrush.cpp.
Referenced by createLinearGradientNode(), createRadialGradientNode(), and operator>>().
|
inline |
Specifies the spread method that should be used for this gradient.
Note that this function only has effect for linear and radial gradients.
Definition at line 277 of file qbrush.h.
Referenced by operator>>(), and parseBaseGradient().
void QGradient::setStops | ( | const QGradientStops & | stopPoints | ) |
Replaces the current set of stop points with the given stopPoints.
The positions of the points must be in the range 0 to 1, and must be sorted with the lowest point first.
Definition at line 1504 of file qbrush.cpp.
Referenced by QSvgGradientStyle::brush(), QCleanlooksStyle::drawComplexControl(), QCleanlooksStyle::drawControl(), operator>>(), parseBaseGradient(), parseStopNode(), qBrushDark(), qBrushLight(), qBrushSetAlphaF(), qMapGradientToRect(), qt_cleanlooks_draw_buttongradient(), and qt_cleanlooks_draw_gradient().
|
inline |
Returns the spread method use by this gradient.
The default is PadSpread.
Definition at line 235 of file qbrush.h.
Referenced by cgColorForQColor(), QOpenGLPaintEnginePrivate::createGradientPaletteTexture(), operator<<(), QPdf::patternForBrush(), QCoreGraphicsPaintEnginePrivate::setFillBrush(), QSpanData::setup(), QVGPaintEnginePrivate::setupColorRamp(), and QGL2PaintEngineExPrivate::updateBrushTexture().
QGradientStops QGradient::stops | ( | ) | const |
Returns the stop points for this gradient.
If no stop points have been specified, a gradient of black at 0 to white at 1 is used.
Definition at line 1520 of file qbrush.cpp.
Referenced by QGL2GradientCache::addCacheElement(), QGLGradientCache::addCacheElement(), QGradientCache::addCacheElement(), cgColorForQColor(), QCleanlooksStyle::drawComplexControl(), QCleanlooksStyle::drawControl(), QGL2GradientCache::generateGradientColorTable(), QGLGradientCache::generateGradientColorTable(), QGradientCache::generateGradientColorTable(), QGL2GradientCache::getBuffer(), QGLGradientCache::getBuffer(), QGradientCache::getBuffer(), QBrush::isOpaque(), operator<<(), operator==(), parseBaseGradient(), parseStopNode(), QPdf::patternForBrush(), qMapGradientToRect(), rasterFallbackWarn(), QSvgGradientStyle::resolveStops(), QSvgPaintEngine::saveGradientStops(), QVGPaintEnginePrivate::setupColorRamp(), and QPdfEnginePrivate::~QPdfEnginePrivate().
|
inline |
Returns the type of gradient.
Definition at line 232 of file qbrush.h.
Referenced by QOpenGLPaintEnginePrivate::createGradientPaletteTexture(), operator<<(), QBrush::QBrush(), QVGPaintEnginePrivate::setBrush(), QGL2PaintEngineExPrivate::updateBrushTexture(), and QPdfEnginePrivate::~QPdfEnginePrivate().
|
friend |
|
related |
Typedef for QPair<qreal , QColor>.
Referenced by setColorAt(), and stops().
|
related |
Typedef for QVector<QGradientStop>.
|
friend |
|
friend |
qreal QGradient::angle |
Definition at line 271 of file qbrush.h.
Referenced by QConicalGradient::QConicalGradient(), and QConicalGradient::setAngle().
struct { ... } QGradient::conical |
Referenced by operator==().
qreal QGradient::cx |
Definition at line 268 of file qbrush.h.
Referenced by QConicalGradient::QConicalGradient(), and QRadialGradient::QRadialGradient().
qreal QGradient::cy |
Definition at line 268 of file qbrush.h.
Referenced by QConicalGradient::QConicalGradient(), and QRadialGradient::QRadialGradient().
|
private |
Definition at line 274 of file qbrush.h.
Referenced by operator==(), setCoordinateMode(), QRadialGradient::setFocalRadius(), and setInterpolationMode().
qreal QGradient::fx |
Definition at line 268 of file qbrush.h.
Referenced by QRadialGradient::QRadialGradient().
qreal QGradient::fy |
Definition at line 268 of file qbrush.h.
Referenced by QRadialGradient::QRadialGradient().
struct { ... } QGradient::linear |
Referenced by operator==().
union { ... } QGradient::m_data |
Referenced by QConicalGradient::angle(), QRadialGradient::center(), QConicalGradient::center(), QRadialGradient::centerRadius(), QLinearGradient::finalStop(), QRadialGradient::focalPoint(), operator==(), QConicalGradient::QConicalGradient(), QLinearGradient::QLinearGradient(), QRadialGradient::QRadialGradient(), QRadialGradient::radius(), QConicalGradient::setAngle(), QRadialGradient::setCenter(), QConicalGradient::setCenter(), QRadialGradient::setCenterRadius(), QLinearGradient::setFinalStop(), QRadialGradient::setFocalPoint(), QRadialGradient::setRadius(), QLinearGradient::setStart(), and QLinearGradient::start().
|
private |
Definition at line 261 of file qbrush.h.
Referenced by operator==(), QConicalGradient::QConicalGradient(), QLinearGradient::QLinearGradient(), and QRadialGradient::QRadialGradient().
|
private |
Definition at line 262 of file qbrush.h.
Referenced by setColorAt(), setStops(), and stops().
|
private |
Definition at line 260 of file qbrush.h.
Referenced by QConicalGradient::angle(), QRadialGradient::center(), QConicalGradient::center(), QRadialGradient::centerRadius(), QLinearGradient::finalStop(), QRadialGradient::focalPoint(), QRadialGradient::focalRadius(), operator==(), QConicalGradient::QConicalGradient(), QLinearGradient::QLinearGradient(), QRadialGradient::QRadialGradient(), QRadialGradient::radius(), QConicalGradient::setAngle(), QRadialGradient::setCenter(), QConicalGradient::setCenter(), QRadialGradient::setCenterRadius(), QLinearGradient::setFinalStop(), QRadialGradient::setFocalPoint(), QRadialGradient::setFocalRadius(), QRadialGradient::setRadius(), QLinearGradient::setStart(), and QLinearGradient::start().
struct { ... } QGradient::radial |
Referenced by operator==().