42 #include "private/qdeclarativerectangle_p.h" 43 #include "private/qdeclarativerectangle_p_p.h" 46 #include <QStringBuilder> 47 #include <QtCore/qmath.h> 192 if (!m_gradient && !m_stops.isEmpty()) {
194 for (
int i = 0; i < m_stops.count(); ++i) {
271 const int pw =
d->pen &&
d->pen->isValid() ?
d->pen->width() : 0;
272 d->setPaintMargin((pw+1)/2);
343 if (
d->gradient == gradient)
345 static int updatedSignalIdx = -1;
346 if (updatedSignalIdx < 0)
348 if (
d->doUpdateSlotIdx < 0)
379 if (
d->radius == radius)
432 if (
d->rectImage.isNull()) {
433 const int pw =
d->pen &&
d->pen->isValid() ?
d->pen->width() : 0;
437 if (
d->pen &&
d->pen->isValid())
441 d->rectImage =
QPixmap(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2);
445 if (
d->pen &&
d->pen->isValid()) {
468 if (
d->rectImage.isNull()) {
469 const int pw =
d->pen &&
d->pen->isValid() ?
d->pen->width() : 0;
472 if (
d->pen &&
d->pen->isValid())
478 d->rectImage =
QPixmap(pw*2 + 5, pw*2 + 5);
482 if (
d->pen &&
d->pen->isValid()) {
508 if (
d->radius > 0 || (
d->pen &&
d->pen->isValid())
509 || (
d->gradient &&
d->gradient->gradient()) ) {
525 if ((
d->gradient &&
d->gradient->gradient())
533 if (
d->pen &&
d->pen->isValid()) {
540 if (
d->gradient &&
d->gradient->gradient())
544 const int pw =
d->pen &&
d->pen->isValid() ?
d->pen->width() : 0;
565 const int pw =
d->pen &&
d->pen->isValid() ? (
d->pen->width()+1)/2*2 : 0;
572 int xOffset = (
d->rectImage.width()-1)/2;
573 int yOffset = (
d->rectImage.height()-1)/2;
574 Q_ASSERT(
d->rectImage.width() == 2*xOffset + 1);
575 Q_ASSERT(
d->rectImage.height() == 2*yOffset + 1);
578 if (2*xOffset >
width()+pw)
579 xOffset = (
width()+pw)/2;
580 if (2*yOffset >
height()+pw)
581 yOffset = (
height()+pw)/2;
583 QMargins margins(xOffset, yOffset, xOffset, yOffset);
617 return QRectF(-
d->paintmargin, -
d->paintmargin,
d->width()+
d->paintmargin*2,
d->height()+
d->paintmargin*2);
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QPainter class performs low-level painting on widgets and other paint devices.
The QColor class provides colors based on RGB, HSV or CMYK values.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
QDeclarativeParserStatus ** d
void setRadius(qreal radius)
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QDeclarativePen * border()
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
bool testRenderHint(RenderHint hint) const
Returns true if hint is set; otherwise returns false.
The QString class provides a Unicode character string.
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
The QPen class defines how a QPainter should draw lines and outlines of shapes.
static QPixmap * find(const QString &key)
QRectF boundingRect() const
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QRectF class defines a rectangle in the plane using floating point precision. ...
The QDeclarativeItem class provides the most basic of all visual items in QML.
const QGradient * gradient() const
void setColor(const QColor &)
void setGradient(QDeclarativeGradient *gradient)
void setJoinStyle(Qt::PenJoinStyle pcs)
Sets the pen's join style to the given style.
void setColor(const QColor &c)
void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins, const QPixmap &pixmap, const QRect &sourceRect, const QMargins &sourceMargins, const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints)
Draws the indicated sourceRect rectangle from the given pixmap into the given targetRect rectangle...
QDeclarativeRectangle(QDeclarativeItem *parent=0)
void setRenderHints(RenderHints hints, bool on=true)
Sets the given render hints on the painter if on is true; otherwise clears the render hints...
void generateBorderedRect()
static int doUpdateSlotIdx
ushort alpha
Returns the alpha color component of this color.
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush...
The QGradient class is used in combination with QBrush to specify gradient fills. ...
Holds the rules used to draw a pixmap or image split into nine segments, similar to [CSS3 border-imag...
QObject * parent() const
Returns a pointer to the parent object.
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
void generateRoundedRect()
void setPen(const QColor &color)
Sets the painter's pen to have style Qt::SolidLine, width 0 and the specified color.
The QRect class defines a rectangle in the plane using integer precision.
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
The QPixmap class is an off-screen image representation that can be used as a paint device...
QDeclarativeGradient * gradient() const
The QDeclarativePen class provides a pen used for drawing rectangle borders on a QDeclarativeView.
The QMargins class defines the four margins of a rectangle.
void drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
Draws the given rectangle rect with rounded corners.
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
void drawRect(QPainter &painter)
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.