src/svg/qsvgstyle_p.h
changeset 30 5dc02b23752f
parent 18 2f34d5167611
child 33 3e2da88830cd
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
   170         OPACITY,
   170         OPACITY,
   171         COMP_OP
   171         COMP_OP
   172     };
   172     };
   173 public:
   173 public:
   174     virtual ~QSvgStyleProperty();
   174     virtual ~QSvgStyleProperty();
   175     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states)  =0;
   175     virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states) = 0;
   176     virtual void revert(QPainter *p, QSvgExtraStates &states) =0;
   176     virtual void revert(QPainter *p, QSvgExtraStates &states) =0;
   177     virtual Type type() const=0;
   177     virtual Type type() const=0;
   178 };
   178 };
   179 
   179 
   180 class QSvgFillStyleProperty : public QSvgStyleProperty
   180 class QSvgFillStyleProperty : public QSvgStyleProperty
   181 {
   181 {
   182 public:
   182 public:
   183     virtual QBrush brush(QPainter *p, QSvgExtraStates &states) = 0;
   183     virtual QBrush brush(QPainter *p, QSvgExtraStates &states) = 0;
   184     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
   184     virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
   185     virtual void revert(QPainter *p, QSvgExtraStates &states);
   185     virtual void revert(QPainter *p, QSvgExtraStates &states);
   186 };
   186 };
   187 
   187 
   188 class QSvgQualityStyle : public QSvgStyleProperty
   188 class QSvgQualityStyle : public QSvgStyleProperty
   189 {
   189 {
   190 public:
   190 public:
   191     QSvgQualityStyle(int color);
   191     QSvgQualityStyle(int color);
   192     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
   192     virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
   193     virtual void revert(QPainter *p, QSvgExtraStates &states);
   193     virtual void revert(QPainter *p, QSvgExtraStates &states);
   194     virtual Type type() const;
   194     virtual Type type() const;
   195 private:
   195 private:
   196     // color-render ing v 	v 	'auto' | 'optimizeSpeed' |
   196     // color-render ing v 	v 	'auto' | 'optimizeSpeed' |
   197     //                                  'optimizeQuality' | 'inherit'
   197     //                                  'optimizeQuality' | 'inherit'
   219 
   219 
   220 class QSvgOpacityStyle : public QSvgStyleProperty
   220 class QSvgOpacityStyle : public QSvgStyleProperty
   221 {
   221 {
   222 public:
   222 public:
   223     QSvgOpacityStyle(qreal opacity);
   223     QSvgOpacityStyle(qreal opacity);
   224     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
   224     virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
   225     virtual void revert(QPainter *p, QSvgExtraStates &states);
   225     virtual void revert(QPainter *p, QSvgExtraStates &states);
   226     virtual Type type() const;
   226     virtual Type type() const;
   227 private:
   227 private:
   228     qreal m_opacity;
   228     qreal m_opacity;
   229     qreal m_oldOpacity;
   229     qreal m_oldOpacity;
   231 
   231 
   232 class QSvgFillStyle : public QSvgStyleProperty
   232 class QSvgFillStyle : public QSvgStyleProperty
   233 {
   233 {
   234 public:
   234 public:
   235     QSvgFillStyle();
   235     QSvgFillStyle();
   236     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
   236     virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
   237     virtual void revert(QPainter *p, QSvgExtraStates &states);
   237     virtual void revert(QPainter *p, QSvgExtraStates &states);
   238     virtual Type type() const;
   238     virtual Type type() const;
   239 
   239 
   240     void setFillRule(Qt::FillRule f);
   240     void setFillRule(Qt::FillRule f);
   241     void setFillOpacity(qreal opacity);
   241     void setFillOpacity(qreal opacity);
   304 
   304 
   305 class QSvgViewportFillStyle : public QSvgStyleProperty
   305 class QSvgViewportFillStyle : public QSvgStyleProperty
   306 {
   306 {
   307 public:
   307 public:
   308     QSvgViewportFillStyle(const QBrush &brush);
   308     QSvgViewportFillStyle(const QBrush &brush);
   309     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
   309     virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
   310     virtual void revert(QPainter *p, QSvgExtraStates &states);
   310     virtual void revert(QPainter *p, QSvgExtraStates &states);
   311     virtual Type type() const;
   311     virtual Type type() const;
   312 
   312 
   313     const QBrush & qbrush() const
   313     const QBrush & qbrush() const
   314     {
   314     {
   328     static const int LIGHTER = -1;
   328     static const int LIGHTER = -1;
   329     static const int BOLDER = 1;
   329     static const int BOLDER = 1;
   330 
   330 
   331     QSvgFontStyle(QSvgFont *font, QSvgTinyDocument *doc);
   331     QSvgFontStyle(QSvgFont *font, QSvgTinyDocument *doc);
   332     QSvgFontStyle();
   332     QSvgFontStyle();
   333     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
   333     virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
   334     virtual void revert(QPainter *p, QSvgExtraStates &states);
   334     virtual void revert(QPainter *p, QSvgExtraStates &states);
   335     virtual Type type() const;
   335     virtual Type type() const;
   336 
   336 
   337     void setSize(qreal size)
   337     void setSize(qreal size)
   338     {
   338     {
   408 
   408 
   409 class QSvgStrokeStyle : public QSvgStyleProperty
   409 class QSvgStrokeStyle : public QSvgStyleProperty
   410 {
   410 {
   411 public:
   411 public:
   412     QSvgStrokeStyle();
   412     QSvgStrokeStyle();
   413     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
   413     virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
   414     virtual void revert(QPainter *p, QSvgExtraStates &states);
   414     virtual void revert(QPainter *p, QSvgExtraStates &states);
   415     virtual Type type() const;
   415     virtual Type type() const;
   416 
   416 
   417     void setStroke(QBrush brush)
   417     void setStroke(QBrush brush)
   418     {
   418     {
   615 
   615 
   616 class QSvgTransformStyle : public QSvgStyleProperty
   616 class QSvgTransformStyle : public QSvgStyleProperty
   617 {
   617 {
   618 public:
   618 public:
   619     QSvgTransformStyle(const QTransform &transform);
   619     QSvgTransformStyle(const QTransform &transform);
   620     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
   620     virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
   621     virtual void revert(QPainter *p, QSvgExtraStates &states);
   621     virtual void revert(QPainter *p, QSvgExtraStates &states);
   622     virtual Type type() const;
   622     virtual Type type() const;
   623 
   623 
   624     const QTransform & qtransform() const
   624     const QTransform & qtransform() const
   625     {
   625     {
   652 public:
   652 public:
   653     QSvgAnimateTransform(int startMs, int endMs, int by = 0);
   653     QSvgAnimateTransform(int startMs, int endMs, int by = 0);
   654     void setArgs(TransformType type, Additive additive, const QVector<qreal> &args);
   654     void setArgs(TransformType type, Additive additive, const QVector<qreal> &args);
   655     void setFreeze(bool freeze);
   655     void setFreeze(bool freeze);
   656     void setRepeatCount(qreal repeatCount);
   656     void setRepeatCount(qreal repeatCount);
   657     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
   657     virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
   658     virtual void revert(QPainter *p, QSvgExtraStates &states);
   658     virtual void revert(QPainter *p, QSvgExtraStates &states);
   659     virtual Type type() const;
   659     virtual Type type() const;
   660     QSvgAnimateTransform::Additive additiveType() const
   660     QSvgAnimateTransform::Additive additiveType() const
   661     {
   661     {
   662         return m_additive;
   662         return m_additive;
   686     {
   686     {
   687         m_transformApplied = false;
   687         m_transformApplied = false;
   688     }
   688     }
   689 
   689 
   690 protected:
   690 protected:
   691     void resolveMatrix(QSvgNode *node);
   691     void resolveMatrix(const QSvgNode *node);
   692 private:
   692 private:
   693     qreal m_from, m_to, m_by;
   693     qreal m_from, m_to, m_by;
   694     qreal m_totalRunningTime;
   694     qreal m_totalRunningTime;
   695     TransformType m_type;
   695     TransformType m_type;
   696     Additive m_additive;
   696     Additive m_additive;
   710 public:
   710 public:
   711     QSvgAnimateColor(int startMs, int endMs, int by = 0);
   711     QSvgAnimateColor(int startMs, int endMs, int by = 0);
   712     void setArgs(bool fill, const QList<QColor> &colors);
   712     void setArgs(bool fill, const QList<QColor> &colors);
   713     void setFreeze(bool freeze);
   713     void setFreeze(bool freeze);
   714     void setRepeatCount(qreal repeatCount);
   714     void setRepeatCount(qreal repeatCount);
   715     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
   715     virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
   716     virtual void revert(QPainter *p, QSvgExtraStates &states);
   716     virtual void revert(QPainter *p, QSvgExtraStates &states);
   717     virtual Type type() const;
   717     virtual Type type() const;
   718 private:
   718 private:
   719     qreal m_from, m_to, m_by;
   719     qreal m_from, m_to, m_by;
   720     qreal m_totalRunningTime;
   720     qreal m_totalRunningTime;
   730 
   730 
   731 class QSvgCompOpStyle : public QSvgStyleProperty
   731 class QSvgCompOpStyle : public QSvgStyleProperty
   732 {
   732 {
   733 public:
   733 public:
   734     QSvgCompOpStyle(QPainter::CompositionMode mode);
   734     QSvgCompOpStyle(QPainter::CompositionMode mode);
   735     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
   735     virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
   736     virtual void revert(QPainter *p, QSvgExtraStates &states);
   736     virtual void revert(QPainter *p, QSvgExtraStates &states);
   737     virtual Type type() const;
   737     virtual Type type() const;
   738 
   738 
   739     const QPainter::CompositionMode & compOp() const
   739     const QPainter::CompositionMode & compOp() const
   740     {
   740     {
   764           opacity(0),
   764           opacity(0),
   765           compop(0)
   765           compop(0)
   766     {}
   766     {}
   767     ~QSvgStyle();
   767     ~QSvgStyle();
   768 
   768 
   769     void apply(QPainter *p, const QRectF &rect, QSvgNode *node, QSvgExtraStates &states);
   769     void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
   770     void revert(QPainter *p, QSvgExtraStates &states);
   770     void revert(QPainter *p, QSvgExtraStates &states);
   771     QSvgRefCounter<QSvgQualityStyle>      quality;
   771     QSvgRefCounter<QSvgQualityStyle>      quality;
   772     QSvgRefCounter<QSvgFillStyle>         fill;
   772     QSvgRefCounter<QSvgFillStyle>         fill;
   773     QSvgRefCounter<QSvgViewportFillStyle> viewportFill;
   773     QSvgRefCounter<QSvgViewportFillStyle> viewportFill;
   774     QSvgRefCounter<QSvgFontStyle>         font;
   774     QSvgRefCounter<QSvgFontStyle>         font;