Added stretched paint mode for background painting

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=709407
This commit is contained in:
Ivan Čukić 2007-09-07 13:05:28 +00:00
parent f2cf7e782a
commit 45f7769d44

View File

@ -210,41 +210,49 @@ public:
background->paint(&p, QRect(leftOffset, bottomOffset, leftWidth, bottomHeight), "bottomleft"); background->paint(&p, QRect(leftOffset, bottomOffset, leftWidth, bottomHeight), "bottomleft");
background->paint(&p, QRect(rightOffset, bottomOffset, rightWidth, bottomHeight), "bottomright"); background->paint(&p, QRect(rightOffset, bottomOffset, rightWidth, bottomHeight), "bottomright");
QPixmap left(leftWidth, leftHeight); if (stretchBackgroundBorders) {
left.fill(Qt::transparent); background->paint(&p, QRect(leftOffset, contentTop, leftWidth, contentHeight), "left");
{ background->paint(&p, QRect(rightOffset, contentTop, rightWidth, contentHeight), "right");
QPainter sidePainter(&left); background->paint(&p, QRect(contentLeft, topOffset, contentWidth, topHeight), "top");
sidePainter.setCompositionMode(QPainter::CompositionMode_Source); background->paint(&p, QRect(contentLeft, bottomOffset, contentWidth, bottomHeight), "bottom");
background->paint(&sidePainter, QPoint(0, 0), "left"); } else {
}
p.drawTiledPixmap(QRect(leftOffset, contentTop, leftWidth, contentHeight), left);
QPixmap right(rightWidth, leftHeight); QPixmap left(leftWidth, leftHeight);
right.fill(Qt::transparent); left.fill(Qt::transparent);
{ {
QPainter sidePainter(&right); QPainter sidePainter(&left);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source); sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
background->paint(&sidePainter, QPoint(0, 0), "right"); background->paint(&sidePainter, QPoint(0, 0), "left");
} }
p.drawTiledPixmap(QRect(rightOffset, contentTop, rightWidth, contentHeight), right); p.drawTiledPixmap(QRect(leftOffset, contentTop, leftWidth, contentHeight), left);
QPixmap top(topWidth, topHeight); QPixmap right(rightWidth, leftHeight);
top.fill(Qt::transparent); right.fill(Qt::transparent);
{ {
QPainter sidePainter(&top); QPainter sidePainter(&right);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source); sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
background->paint(&sidePainter, QPoint(0, 0), "top"); background->paint(&sidePainter, QPoint(0, 0), "right");
} }
p.drawTiledPixmap(QRect(contentLeft, topOffset, contentWidth, topHeight), top); p.drawTiledPixmap(QRect(rightOffset, contentTop, rightWidth, contentHeight), right);
QPixmap bottom(topWidth, bottomHeight); QPixmap top(topWidth, topHeight);
bottom.fill(Qt::transparent); top.fill(Qt::transparent);
{ {
QPainter sidePainter(&bottom); QPainter sidePainter(&top);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source); sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
background->paint(&sidePainter, QPoint(0, 0), "bottom"); background->paint(&sidePainter, QPoint(0, 0), "top");
}
p.drawTiledPixmap(QRect(contentLeft, topOffset, contentWidth, topHeight), top);
QPixmap bottom(topWidth, bottomHeight);
bottom.fill(Qt::transparent);
{
QPainter sidePainter(&bottom);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
background->paint(&sidePainter, QPoint(0, 0), "bottom");
}
p.drawTiledPixmap(QRect(contentLeft, bottomOffset, contentWidth, bottomHeight), bottom);
} }
p.drawTiledPixmap(QRect(contentLeft, bottomOffset, contentWidth, bottomHeight), bottom);
background->paint(&p, QRect(contentLeft, contentTop, contentWidth + 1, contentHeight + 1), "center"); background->paint(&p, QRect(contentLeft, contentTop, contentWidth + 1, contentHeight + 1), "center");
p.end(); p.end();
@ -319,6 +327,7 @@ public:
QStringList loadedEngines; QStringList loadedEngines;
static uint s_maxAppletId; static uint s_maxAppletId;
Plasma::Svg *background; Plasma::Svg *background;
bool stretchBackgroundBorders;
Plasma::LineEdit *failureText; Plasma::LineEdit *failureText;
ScriptEngine* scriptEngine; ScriptEngine* scriptEngine;
ConfigXml* configXml; ConfigXml* configXml;
@ -526,6 +535,7 @@ void Applet::setDrawStandardBackground(bool drawBackground)
if (!d->background) { if (!d->background) {
prepareGeometryChange(); prepareGeometryChange();
d->background = new Plasma::Svg("widgets/background"); d->background = new Plasma::Svg("widgets/background");
d->stretchBackgroundBorders = d->background->elementExists("hint-stretch-borders");
} }
} else if (d->background) { } else if (d->background) {
prepareGeometryChange(); prepareGeometryChange();