summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativerectangle.cpp
diff options
context:
space:
mode:
authorDavid Boddie <david.boddie@nokia.com>2010-12-14 13:01:13 (GMT)
committerDavid Boddie <david.boddie@nokia.com>2010-12-14 13:01:13 (GMT)
commit086a010a63895c6e6d178c1de9434483f11b2d34 (patch)
treebb2542f04438b42ae5c61b1c3a6330f011700474 /src/declarative/graphicsitems/qdeclarativerectangle.cpp
parent0fe36ac832abf8f8d438b21fce0177b65b3bbf3a (diff)
parent5cb2226ddf96555417f08c9bfe35addfc93f6acd (diff)
downloadQt-086a010a63895c6e6d178c1de9434483f11b2d34.zip
Qt-086a010a63895c6e6d178c1de9434483f11b2d34.tar.gz
Qt-086a010a63895c6e6d178c1de9434483f11b2d34.tar.bz2
Merge branch 'qdoc-simplified' into mimir-simplified
Conflicts: tools/qdoc3/atom.h tools/qdoc3/qdoc3.pro
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativerectangle.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativerectangle.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
index dedb3f7..969027e 100644
--- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
@@ -131,9 +131,7 @@ void QDeclarativeGradientStop::updateGradient()
\section1 Example Usage
- \beginfloatright
- \inlineimage qml-gradient.png
- \endfloat
+ \floatright qml-gradient.png
The following example declares a \l Rectangle item with a gradient starting
with red, blending to yellow at one third of the height of the rectangle,
@@ -217,9 +215,7 @@ void QDeclarativeGradient::doUpdate()
\section1 Example Usage
- \beginfloatright
- \inlineimage declarative-rect.png
- \endfloat
+ \floatright declarative-rect.png
The following example shows the effects of some of the common properties on a
Rectangle item, which in this case is used to create a square:
@@ -269,9 +265,7 @@ void QDeclarativeRectangle::doUpdate()
rectangle (as documented for QRect rendering). This can cause unintended effects if
\c border.width is 1 and the rectangle is \l{Item::clip}{clipped} by a parent item:
- \beginfloatright
- \inlineimage rect-border-width.png
- \endfloat
+ \floatright rect-border-width.png
\snippet doc/src/snippets/declarative/rectangle/rect-border-width.qml 0
@@ -293,9 +287,7 @@ QDeclarativePen *QDeclarativeRectangle::border()
This property allows for the construction of simple vertical gradients.
Other gradients may by formed by adding rotation to the rectangle.
- \beginfloatleft
- \inlineimage declarative-rect_gradient.png
- \endfloat
+ \floatleft declarative-rect_gradient.png
\snippet doc/src/snippets/declarative/rectangle/rectangle-gradient.qml rectangles
\clearfloat
@@ -361,9 +353,7 @@ void QDeclarativeRectangle::setRadius(qreal radius)
The default color is white.
- \beginfloatright
- \inlineimage rect-color.png
- \endfloat
+ \floatright rect-color.png
The following example shows rectangles with colors specified
using hexadecimal and named color notation:
@@ -470,6 +460,8 @@ void QDeclarativeRectangle::generateBorderedRect()
void QDeclarativeRectangle::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
Q_D(QDeclarativeRectangle);
+ if (width() <= 0 || height() <= 0)
+ return;
if (d->radius > 0 || (d->pen && d->pen->isValid())
|| (d->gradient && d->gradient->gradient()) ) {
drawRect(*p);
@@ -539,6 +531,12 @@ void QDeclarativeRectangle::drawRect(QPainter &p)
Q_ASSERT(d->rectImage.width() == 2*xOffset + 1);
Q_ASSERT(d->rectImage.height() == 2*yOffset + 1);
+ // check whether we've eliminated the center completely
+ if (2*xOffset > width()+pw)
+ xOffset = (width()+pw)/2;
+ if (2*yOffset > height()+pw)
+ yOffset = (height()+pw)/2;
+
QMargins margins(xOffset, yOffset, xOffset, yOffset);
QTileRules rules(Qt::StretchTile, Qt::StretchTile);
//NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects