Qt 4.8
Public Functions | Properties | List of all members
QSvgGradientStyle Class Reference

#include <qsvgstyle_p.h>

Inheritance diagram for QSvgGradientStyle:
QSvgFillStyleProperty QSvgStyleProperty QSvgRefCounted

Public Functions

QBrush brush (QPainter *, QSvgExtraStates &)
 
bool gradientStopsSet () const
 
QGradientqgradient () const
 
QMatrix qmatrix () const
 
 QSvgGradientStyle (QGradient *grad)
 
void resolveStops ()
 
void setGradientStopsSet (bool set)
 
void setMatrix (const QMatrix &matrix)
 
void setStopLink (const QString &link, QSvgTinyDocument *doc)
 
QString stopLink () const
 
virtual Type type () const
 
 ~QSvgGradientStyle ()
 
- Public Functions inherited from QSvgFillStyleProperty
virtual void apply (QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
 
virtual void revert (QPainter *p, QSvgExtraStates &states)
 
- Public Functions inherited from QSvgStyleProperty
virtual ~QSvgStyleProperty ()
 
- Public Functions inherited from QSvgRefCounted
void deref ()
 
 QSvgRefCounted ()
 
void ref ()
 
virtual ~QSvgRefCounted ()
 

Properties

QSvgTinyDocumentm_doc
 
QGradientm_gradient
 
bool m_gradientStopsSet
 
QString m_link
 
QMatrix m_matrix
 

Additional Inherited Members

- Public Types inherited from QSvgStyleProperty
enum  Type {
  QUALITY, FILL, VIEWPORT_FILL, FONT,
  STROKE, SOLID_COLOR, GRADIENT, TRANSFORM,
  ANIMATE_TRANSFORM, ANIMATE_COLOR, OPACITY, COMP_OP
}
 

Detailed Description

Definition at line 574 of file qsvgstyle_p.h.

Constructors and Destructors

◆ QSvgGradientStyle()

QSvgGradientStyle::QSvgGradientStyle ( QGradient grad)

Definition at line 410 of file qsvgstyle.cpp.

411  : m_gradient(grad), m_gradientStopsSet(false)
412 {
413 }
QGradient * m_gradient
Definition: qsvgstyle_p.h:608

◆ ~QSvgGradientStyle()

QSvgGradientStyle::~QSvgGradientStyle ( )
inline

Definition at line 578 of file qsvgstyle_p.h.

578 { delete m_gradient; }
QGradient * m_gradient
Definition: qsvgstyle_p.h:608

Functions

◆ brush()

QBrush QSvgGradientStyle::brush ( QPainter ,
QSvgExtraStates  
)
virtual

Implements QSvgFillStyleProperty.

Definition at line 415 of file qsvgstyle.cpp.

416 {
417  if (!m_link.isEmpty()) {
418  resolveStops();
419  }
420 
421  // If the gradient is marked as empty, insert transparent black
422  if (!m_gradientStopsSet) {
423  m_gradient->setStops(QGradientStops() << QGradientStop(0.0, QColor(0, 0, 0, 0)));
424  m_gradientStopsSet = true;
425  }
426 
427  QBrush b(*m_gradient);
428 
429  if (!m_matrix.isIdentity())
430  b.setMatrix(m_matrix);
431 
432  return b;
433 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QGradient * m_gradient
Definition: qsvgstyle_p.h:608
QVector< QGradientStop > QGradientStops
Definition: qbrush.h:199
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
QPair< qreal, QColor > QGradientStop
Definition: qbrush.h:196
void setStops(const QGradientStops &stops)
Replaces the current set of stop points with the given stopPoints.
Definition: qbrush.cpp:1504
bool isIdentity() const
Returns true if the matrix is the identity matrix, otherwise returns false.
Definition: qmatrix.h:166

◆ gradientStopsSet()

bool QSvgGradientStyle::gradientStopsSet ( ) const
inline

Definition at line 596 of file qsvgstyle_p.h.

Referenced by parseBaseGradient(), parseStopNode(), and resolveStops().

597  {
598  return m_gradientStopsSet;
599  }

◆ qgradient()

QGradient* QSvgGradientStyle::qgradient ( ) const
inline

Definition at line 591 of file qsvgstyle_p.h.

Referenced by parseBaseGradient(), parseStopNode(), and resolveStops().

592  {
593  return m_gradient;
594  }
QGradient * m_gradient
Definition: qsvgstyle_p.h:608

◆ qmatrix()

QMatrix QSvgGradientStyle::qmatrix ( ) const
inline

Definition at line 586 of file qsvgstyle_p.h.

Referenced by parseBaseGradient().

587  {
588  return m_matrix;
589  }

◆ resolveStops()

void QSvgGradientStyle::resolveStops ( )

Definition at line 937 of file qsvgstyle.cpp.

Referenced by brush(), and resolveStops().

938 {
939  if (!m_link.isEmpty() && m_doc) {
941  if (prop) {
942  if (prop->type() == QSvgStyleProperty::GRADIENT) {
944  static_cast<QSvgGradientStyle*>(prop);
945  st->resolveStops();
946  m_gradient->setStops(st->qgradient()->stops());
948  }
949  } else {
950  qWarning("Could not resolve property : %s", qPrintable(m_link));
951  }
952  m_link = QString();
953  }
954 }
QGradient * qgradient() const
Definition: qsvgstyle_p.h:591
The QString class provides a Unicode character string.
Definition: qstring.h:83
QGradientStops stops() const
Returns the stop points for this gradient.
Definition: qbrush.cpp:1520
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
Q_CORE_EXPORT void qWarning(const char *,...)
QGradient * m_gradient
Definition: qsvgstyle_p.h:608
QSvgStyleProperty * styleProperty(QSvgStyleProperty::Type type) const
Definition: qsvgnode.cpp:128
virtual Type type() const =0
#define st(var, type, card)
void setStops(const QGradientStops &stops)
Replaces the current set of stop points with the given stopPoints.
Definition: qbrush.cpp:1504
bool gradientStopsSet() const
Definition: qsvgstyle_p.h:596
QSvgTinyDocument * m_doc
Definition: qsvgstyle_p.h:611
#define qPrintable(string)
Definition: qglobal.h:1750

◆ setGradientStopsSet()

void QSvgGradientStyle::setGradientStopsSet ( bool  set)
inline

Definition at line 601 of file qsvgstyle_p.h.

Referenced by parseBaseGradient(), and parseStopNode().

602  {
603  m_gradientStopsSet = set;
604  }

◆ setMatrix()

void QSvgGradientStyle::setMatrix ( const QMatrix matrix)

Definition at line 436 of file qsvgstyle.cpp.

Referenced by parseBaseGradient().

437 {
438  m_matrix = mat;
439 }

◆ setStopLink()

void QSvgGradientStyle::setStopLink ( const QString link,
QSvgTinyDocument doc 
)

Definition at line 931 of file qsvgstyle.cpp.

Referenced by parseBaseGradient().

932 {
933  m_link = link;
934  m_doc = doc;
935 }
QSvgTinyDocument * m_doc
Definition: qsvgstyle_p.h:611

◆ stopLink()

QString QSvgGradientStyle::stopLink ( ) const
inline

Definition at line 582 of file qsvgstyle_p.h.

Referenced by parseBaseGradient().

582 { return m_link; }

◆ type()

QSvgStyleProperty::Type QSvgGradientStyle::type ( ) const
virtual

Implements QSvgStyleProperty.

Definition at line 487 of file qsvgstyle.cpp.

488 {
489  return GRADIENT;
490 }

Properties

◆ m_doc

QSvgTinyDocument* QSvgGradientStyle::m_doc
private

Definition at line 611 of file qsvgstyle_p.h.

◆ m_gradient

QGradient* QSvgGradientStyle::m_gradient
private

Definition at line 608 of file qsvgstyle_p.h.

Referenced by brush().

◆ m_gradientStopsSet

bool QSvgGradientStyle::m_gradientStopsSet
private

Definition at line 613 of file qsvgstyle_p.h.

Referenced by brush().

◆ m_link

QString QSvgGradientStyle::m_link
private

Definition at line 612 of file qsvgstyle_p.h.

Referenced by brush().

◆ m_matrix

QMatrix QSvgGradientStyle::m_matrix
private

Definition at line 609 of file qsvgstyle_p.h.

Referenced by brush(), and setMatrix().


The documentation for this class was generated from the following files: