00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "framesvg.h"
00022 #include "private/framesvg_p.h"
00023
00024 #include <QPainter>
00025 #include <QSize>
00026 #include <QBitmap>
00027 #include <QRegion>
00028 #include <QTimer>
00029 #include <QCryptographicHash>
00030
00031 #include <kdebug.h>
00032
00033 #include <plasma/theme.h>
00034 #include <plasma/applet.h>
00035
00036 namespace Plasma
00037 {
00038
00039 FrameSvg::FrameSvg(QObject *parent)
00040 : Svg(parent),
00041 d(new FrameSvgPrivate(this))
00042 {
00043 connect(this, SIGNAL(repaintNeeded()), this, SLOT(updateNeeded()));
00044 d->frames.insert(QString(), new FrameData());
00045 }
00046
00047 FrameSvg::~FrameSvg()
00048 {
00049 delete d;
00050 }
00051
00052 void FrameSvg::setImagePath(const QString &path)
00053 {
00054 if (path == imagePath()) {
00055 return;
00056 }
00057
00058 Svg::setImagePath(path);
00059 setContainsMultipleImages(true);
00060
00061 clearCache();
00062 d->updateAndSignalSizes();
00063 }
00064
00065 void FrameSvg::setEnabledBorders(const EnabledBorders borders)
00066 {
00067 if (borders == d->frames[d->prefix]->enabledBorders) {
00068 return;
00069 }
00070
00071 d->frames[d->prefix]->enabledBorders = borders;
00072 d->updateAndSignalSizes();
00073 }
00074
00075 FrameSvg::EnabledBorders FrameSvg::enabledBorders() const
00076 {
00077 QHash<QString, FrameData*>::const_iterator it = d->frames.constFind(d->prefix);
00078
00079 if (it != d->frames.constEnd()) {
00080 return it.value()->enabledBorders;
00081 } else {
00082 return NoBorder;
00083 }
00084 }
00085
00086 void FrameSvg::setElementPrefix(Plasma::Location location)
00087 {
00088 switch (location) {
00089 case TopEdge:
00090 setElementPrefix("north");
00091 break;
00092 case BottomEdge:
00093 setElementPrefix("south");
00094 break;
00095 case LeftEdge:
00096 setElementPrefix("west");
00097 break;
00098 case RightEdge:
00099 setElementPrefix("east");
00100 break;
00101 default:
00102 setElementPrefix(QString());
00103 break;
00104 }
00105
00106 d->location = location;
00107 }
00108
00109 void FrameSvg::setElementPrefix(const QString &prefix)
00110 {
00111 const QString oldPrefix(d->prefix);
00112
00113 if (!hasElement(prefix + "-center")) {
00114 d->prefix.clear();
00115 } else {
00116 d->prefix = prefix;
00117 if (!d->prefix.isEmpty()) {
00118 d->prefix += '-';
00119 }
00120 }
00121
00122 FrameData *oldFrameData = d->frames.value(oldPrefix);
00123 if (oldPrefix == d->prefix && oldFrameData) {
00124 return;
00125 }
00126
00127 if (!d->frames.contains(d->prefix)) {
00128 if (oldFrameData) {
00129 d->frames.insert(d->prefix, new FrameData(*oldFrameData));
00130 } else {
00131 d->frames.insert(d->prefix, new FrameData());
00132 }
00133
00134 d->updateSizes();
00135 }
00136
00137 if (!d->cacheAll) {
00138 delete d->frames[oldPrefix];
00139 d->frames.remove(oldPrefix);
00140 }
00141
00142 d->location = Floating;
00143 }
00144
00145 bool FrameSvg::hasElementPrefix(const QString & prefix) const
00146 {
00147
00148
00149 if (prefix.isEmpty()) {
00150 return hasElement("center");
00151 } else {
00152 return hasElement(prefix + "-center");
00153 }
00154 }
00155
00156 bool FrameSvg::hasElementPrefix(Plasma::Location location) const
00157 {
00158 switch (location) {
00159 case TopEdge:
00160 return hasElementPrefix("north");
00161 break;
00162 case BottomEdge:
00163 return hasElementPrefix("south");
00164 break;
00165 case LeftEdge:
00166 return hasElementPrefix("west");
00167 break;
00168 case RightEdge:
00169 return hasElementPrefix("east");
00170 break;
00171 default:
00172 return hasElementPrefix(QString());
00173 break;
00174 }
00175 }
00176
00177 QString FrameSvg::prefix()
00178 {
00179 if (d->prefix.isEmpty()) {
00180 return d->prefix;
00181 }
00182
00183 return d->prefix.left(d->prefix.size() - 1);
00184 }
00185
00186 void FrameSvg::resizeFrame(const QSizeF &size)
00187 {
00188 if (size.isEmpty()) {
00189 kWarning() << "Invalid size" << size;
00190 return;
00191 }
00192
00193 if (size == d->frames[d->prefix]->frameSize) {
00194 return;
00195 }
00196
00197 d->updateSizes();
00198 d->frames[d->prefix]->frameSize = size.toSize();
00199 }
00200
00201 QSizeF FrameSvg::frameSize() const
00202 {
00203 QHash<QString, FrameData*>::const_iterator it = d->frames.constFind(d->prefix);
00204
00205 if (it == d->frames.constEnd()) {
00206 return QSize(-1, -1);
00207 } else {
00208 return d->frameSize(it.value());
00209 }
00210 }
00211
00212 qreal FrameSvg::marginSize(const Plasma::MarginEdge edge) const
00213 {
00214 if (d->frames[d->prefix]->noBorderPadding) {
00215 return .0;
00216 }
00217
00218 switch (edge) {
00219 case Plasma::TopMargin:
00220 return d->frames[d->prefix]->topMargin;
00221 break;
00222
00223 case Plasma::LeftMargin:
00224 return d->frames[d->prefix]->leftMargin;
00225 break;
00226
00227 case Plasma::RightMargin:
00228 return d->frames[d->prefix]->rightMargin;
00229 break;
00230
00231
00232 default:
00233 return d->frames[d->prefix]->bottomMargin;
00234 break;
00235 }
00236 }
00237
00238 void FrameSvg::getMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const
00239 {
00240 FrameData *frame = d->frames[d->prefix];
00241
00242 if (!frame || frame->noBorderPadding) {
00243 left = top = right = bottom = 0;
00244 return;
00245 }
00246
00247 top = frame->topMargin;
00248 left = frame->leftMargin;
00249 right = frame->rightMargin;
00250 bottom = frame->bottomMargin;
00251 }
00252
00253 QRectF FrameSvg::contentsRect() const
00254 {
00255 QSizeF size(frameSize());
00256
00257 if (size.isValid()) {
00258 QRectF rect(QPointF(0, 0), size);
00259 FrameData *frame = d->frames[d->prefix];
00260
00261 return rect.adjusted(frame->leftMargin, frame->topMargin,
00262 -frame->rightMargin, -frame->bottomMargin);
00263 } else {
00264 return QRectF();
00265 }
00266 }
00267
00268 QPixmap FrameSvg::alphaMask() const
00269 {
00270 FrameData *frame = d->frames[d->prefix];
00271
00272 if (hasElement("mask-" + d->prefix + "center")) {
00273 QString oldPrefix = d->prefix;
00274
00275
00276
00277 d->prefix = "mask-" + oldPrefix;
00278
00279 if (!d->frames.contains(d->prefix)) {
00280 d->frames.insert(d->prefix, new FrameData(*(d->frames[oldPrefix])));
00281 d->updateSizes();
00282 }
00283
00284 FrameData *maskFrame = d->frames[d->prefix];
00285 if (maskFrame->cachedBackground.isNull() || maskFrame->frameSize != d->frameSize(frame)) {
00286 maskFrame->frameSize = d->frameSize(frame).toSize();
00287 maskFrame->cachedBackground = QPixmap();
00288
00289 d->generateBackground(maskFrame);
00290 if (maskFrame->cachedBackground.isNull()) {
00291 return QPixmap();
00292 }
00293 }
00294
00295 d->prefix = oldPrefix;
00296 return maskFrame->cachedBackground;
00297 } else {
00298 if (frame->cachedBackground.isNull()) {
00299 d->generateBackground(frame);
00300 if (frame->cachedBackground.isNull()) {
00301 return QPixmap();
00302 }
00303 }
00304 return frame->cachedBackground;
00305 }
00306 }
00307
00308 QRegion FrameSvg::mask() const
00309 {
00310 FrameData *frame = d->frames[d->prefix];
00311 frame->cachedMask = QRegion(QBitmap(alphaMask().alphaChannel().createMaskFromColor(Qt::black)));
00312 return frame->cachedMask;
00313 }
00314
00315 void FrameSvg::setCacheAllRenderedFrames(bool cache)
00316 {
00317 if (d->cacheAll && !cache) {
00318 clearCache();
00319 }
00320
00321 d->cacheAll = cache;
00322 }
00323
00324 bool FrameSvg::cacheAllRenderedFrames() const
00325 {
00326 return d->cacheAll;
00327 }
00328
00329 void FrameSvg::clearCache()
00330 {
00331 FrameData *frame = d->frames[d->prefix];
00332
00333
00334 QMutableHashIterator<QString, FrameData*> it(d->frames);
00335 while (it.hasNext()) {
00336 FrameData *p = it.next().value();
00337
00338 if (frame != p) {
00339
00340 delete p;
00341 it.remove();
00342 }
00343 }
00344 }
00345
00346 QPixmap FrameSvg::framePixmap()
00347 {
00348 FrameData *frame = d->frames[d->prefix];
00349 if (frame->cachedBackground.isNull()) {
00350 d->generateBackground(frame);
00351 if (frame->cachedBackground.isNull()) {
00352 return QPixmap();
00353 }
00354 }
00355
00356
00357 return frame->cachedBackground;
00358 }
00359
00360 void FrameSvg::paintFrame(QPainter *painter, const QRectF &target, const QRectF &source)
00361 {
00362 FrameData *frame = d->frames[d->prefix];
00363 if (frame->cachedBackground.isNull()) {
00364 d->generateBackground(frame);
00365 if (frame->cachedBackground.isNull()) {
00366 return;
00367 }
00368 }
00369
00370 painter->drawPixmap(target, frame->cachedBackground, source.isValid() ? source : target);
00371 }
00372
00373 void FrameSvg::paintFrame(QPainter *painter, const QPointF &pos)
00374 {
00375 FrameData *frame = d->frames[d->prefix];
00376 if (frame->cachedBackground.isNull()) {
00377 d->generateBackground(frame);
00378 if (frame->cachedBackground.isNull()) {
00379 return;
00380 }
00381 }
00382
00383 painter->drawPixmap(pos, frame->cachedBackground);
00384 }
00385
00386 void FrameSvgPrivate::generateBackground(FrameData *frame)
00387 {
00388 if (!frame->cachedBackground.isNull()) {
00389 return;
00390 }
00391
00392
00393 QSizeF size = frameSize(frame);
00394 QString id = QString::fromLatin1("%5_%4_%3_%2_%1_").
00395 arg(frame->enabledBorders).arg(size.width()).arg(size.height()).arg(prefix).arg(q->imagePath());
00396
00397
00398 Theme *theme = Theme::defaultTheme();
00399 if (q->isUsingRenderingCache()) {
00400 if (theme->findInCache(id, frame->cachedBackground) && !frame->cachedBackground.isNull()) {
00401 return;
00402 }
00403 }
00404
00405
00406 const int topWidth = q->elementSize(prefix + "top").width();
00407 const int leftHeight = q->elementSize(prefix + "left").height();
00408 const int topOffset = 0;
00409 const int leftOffset = 0;
00410
00411
00412 if (!size.isValid()) {
00413 kWarning() << "Invalid frame size" << size;
00414 return;
00415 }
00416
00417 const int contentWidth = size.width() - frame->leftWidth - frame->rightWidth;
00418 const int contentHeight = size.height() - frame->topHeight - frame->bottomHeight;
00419 int contentTop = 0;
00420 int contentLeft = 0;
00421 int rightOffset = contentWidth;
00422 int bottomOffset = contentHeight;
00423
00424 frame->cachedBackground = QPixmap(frame->leftWidth + contentWidth + frame->rightWidth,
00425 frame->topHeight + contentHeight + frame->bottomHeight);
00426 frame->cachedBackground.fill(Qt::transparent);
00427 QPainter p(&frame->cachedBackground);
00428 p.setCompositionMode(QPainter::CompositionMode_Source);
00429 p.setRenderHint(QPainter::SmoothPixmapTransform);
00430
00431
00432 if (frame->tileCenter) {
00433 if (contentHeight > 0 && contentWidth > 0) {
00434 const int centerTileHeight = q->elementSize(prefix + "center").height();
00435 const int centerTileWidth = q->elementSize(prefix + "center").width();
00436 QPixmap center(centerTileWidth, centerTileHeight);
00437 center.fill(Qt::transparent);
00438
00439 {
00440 QPainter centerPainter(¢er);
00441 centerPainter.setCompositionMode(QPainter::CompositionMode_Source);
00442 q->paint(¢erPainter, QRect(QPoint(0, 0), q->elementSize(prefix + "center")), prefix + "center");
00443 }
00444
00445 p.drawTiledPixmap(QRect(frame->leftWidth, frame->topHeight,
00446 contentWidth, contentHeight), center);
00447 }
00448 } else {
00449 if (contentHeight > 0 && contentWidth > 0) {
00450 q->paint(&p, QRect(frame->leftWidth, frame->topHeight,
00451 contentWidth, contentHeight),
00452 prefix + "center");
00453 }
00454 }
00455
00456 if (frame->enabledBorders & FrameSvg::LeftBorder && q->hasElement(prefix + "left")) {
00457 rightOffset += frame->leftWidth;
00458 }
00459
00460
00461 if (frame->enabledBorders & FrameSvg::TopBorder && q->hasElement(prefix + "top")) {
00462 contentTop = frame->topHeight;
00463 bottomOffset += frame->topHeight;
00464
00465 if (q->hasElement(prefix + "topleft") && frame->enabledBorders & FrameSvg::LeftBorder) {
00466 q->paint(&p, QRect(leftOffset, topOffset, frame->leftWidth, frame->topHeight), prefix + "topleft");
00467
00468 contentLeft = frame->leftWidth;
00469 }
00470
00471 if (q->hasElement(prefix + "topright") && frame->enabledBorders & FrameSvg::RightBorder) {
00472 q->paint(&p, QRect(rightOffset, topOffset, frame->rightWidth, frame->topHeight), prefix + "topright");
00473 }
00474 }
00475
00476 if (frame->enabledBorders & FrameSvg::BottomBorder && q->hasElement(prefix + "bottom")) {
00477 if (q->hasElement(prefix + "bottomleft") && frame->enabledBorders & FrameSvg::LeftBorder) {
00478 q->paint(&p, QRect(leftOffset, bottomOffset, frame->leftWidth, frame->bottomHeight), prefix + "bottomleft");
00479
00480 contentLeft = frame->leftWidth;
00481 }
00482
00483 if (frame->enabledBorders & FrameSvg::RightBorder && q->hasElement(prefix + "bottomright")) {
00484 q->paint(&p, QRect(rightOffset, bottomOffset, frame->rightWidth, frame->bottomHeight), prefix + "bottomright");
00485 }
00486 }
00487
00488
00489 if (frame->stretchBorders) {
00490 if (frame->enabledBorders & FrameSvg::LeftBorder || frame->enabledBorders & FrameSvg::RightBorder) {
00491 if (q->hasElement(prefix + "left") &&
00492 frame->enabledBorders & FrameSvg::LeftBorder) {
00493 q->paint(&p, QRect(leftOffset, contentTop, frame->leftWidth, contentHeight), prefix + "left");
00494 }
00495
00496 if (q->hasElement(prefix + "right") &&
00497 frame->enabledBorders & FrameSvg::RightBorder) {
00498 q->paint(&p, QRect(rightOffset, contentTop, frame->rightWidth, contentHeight), prefix + "right");
00499 }
00500 }
00501
00502 if (frame->enabledBorders & FrameSvg::TopBorder || frame->enabledBorders & FrameSvg::BottomBorder) {
00503 if (frame->enabledBorders & FrameSvg::TopBorder && q->hasElement(prefix + "top")) {
00504 q->paint(&p, QRect(contentLeft, topOffset, contentWidth, frame->topHeight), prefix + "top");
00505 }
00506
00507 if (frame->enabledBorders & FrameSvg::BottomBorder && q->hasElement(prefix + "bottom")) {
00508 q->paint(&p, QRect(contentLeft, bottomOffset, contentWidth, frame->bottomHeight), prefix + "bottom");
00509 }
00510 }
00511 } else {
00512 if (frame->enabledBorders & FrameSvg::LeftBorder && q->hasElement(prefix + "left")
00513 && leftHeight > 0 && frame->leftWidth > 0) {
00514 QPixmap left(frame->leftWidth, leftHeight);
00515 left.fill(Qt::transparent);
00516
00517 QPainter sidePainter(&left);
00518 sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
00519 q->paint(&sidePainter, QRect(QPoint(0, 0), left.size()), prefix + "left");
00520
00521 p.drawTiledPixmap(QRect(leftOffset, contentTop, frame->leftWidth, contentHeight), left);
00522 }
00523
00524 if (frame->enabledBorders & FrameSvg::RightBorder && q->hasElement(prefix + "right") &&
00525 leftHeight > 0 && frame->rightWidth > 0) {
00526 QPixmap right(frame->rightWidth, leftHeight);
00527 right.fill(Qt::transparent);
00528
00529 QPainter sidePainter(&right);
00530 sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
00531 q->paint(&sidePainter, QRect(QPoint(0, 0), right.size()), prefix + "right");
00532
00533 p.drawTiledPixmap(QRect(rightOffset, contentTop, frame->rightWidth, contentHeight), right);
00534 }
00535
00536 if (frame->enabledBorders & FrameSvg::TopBorder && q->hasElement(prefix + "top")
00537 && topWidth > 0 && frame->topHeight > 0) {
00538 QPixmap top(topWidth, frame->topHeight);
00539 top.fill(Qt::transparent);
00540
00541 QPainter sidePainter(&top);
00542 sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
00543 q->paint(&sidePainter, QRect(QPoint(0, 0), top.size()), prefix + "top");
00544
00545 p.drawTiledPixmap(QRect(contentLeft, topOffset, contentWidth, frame->topHeight), top);
00546 }
00547
00548 if (frame->enabledBorders & FrameSvg::BottomBorder && q->hasElement(prefix + "bottom")
00549 && topWidth > 0 && frame->bottomHeight > 0) {
00550 QPixmap bottom(topWidth, frame->bottomHeight);
00551 bottom.fill(Qt::transparent);
00552
00553 QPainter sidePainter(&bottom);
00554 sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
00555 q->paint(&sidePainter, QRect(QPoint(0, 0), bottom.size()), prefix + "bottom");
00556
00557 p.drawTiledPixmap(QRect(contentLeft, bottomOffset, contentWidth, frame->bottomHeight), bottom);
00558 }
00559 }
00560
00561
00562
00563
00564 QSize overlaySize;
00565 frame->cachedOverlay = QPixmap();
00566 if (!prefix.startsWith("mask-") && q->hasElement(prefix+"overlay") &&
00567 !theme->findInCache(id, frame->cachedOverlay) &&
00568 frame->cachedOverlay.isNull()) {
00569 QPoint pos = QPoint(0, 0);
00570 overlaySize = q->elementSize(prefix+"overlay");
00571
00572
00573 if (q->hasElement(prefix + "hint-overlay-random-pos")) {
00574 pos = overlayPos;
00575
00576 } else if (q->hasElement(prefix + "hint-overlay-stretch")) {
00577 overlaySize = frameSize(frame).toSize();
00578 } else {
00579 if (q->hasElement(prefix + "hint-overlay-tile-horizontal")) {
00580 overlaySize.setWidth(frameSize(frame).width());
00581 }
00582 if (q->hasElement(prefix + "hint-overlay-tile-vertical")) {
00583 overlaySize.setHeight(frameSize(frame).height());
00584 }
00585 }
00586
00587 frame->cachedOverlay = q->alphaMask();
00588 QPainter overlayPainter(&frame->cachedOverlay);
00589 overlayPainter.setCompositionMode(QPainter::CompositionMode_SourceIn);
00590
00591 if (q->hasElement(prefix+"hint-overlay-tile-horizontal") ||
00592 q->hasElement(prefix+"hint-overlay-tile-vertical")) {
00593
00594 QSize s = q->size();
00595 q->resize(q->elementSize(prefix+"overlay"));
00596
00597 overlayPainter.drawTiledPixmap(QRect(QPoint(0,0), overlaySize), q->pixmap(prefix+"overlay"));
00598 q->resize(s);
00599 } else {
00600 q->paint(&overlayPainter, QRect(overlayPos, overlaySize), prefix+"overlay");
00601 }
00602 overlayPainter.end();
00603 }
00604
00605 cacheFrame(prefix);
00606
00607 if (!frame->cachedOverlay.isNull()) {
00608 p.setCompositionMode(QPainter::CompositionMode_SourceOver);
00609 p.drawPixmap(overlayPos, frame->cachedOverlay, QRect(overlayPos, overlaySize));
00610 }
00611 }
00612
00613
00614 void FrameSvgPrivate::cacheFrame(const QString &prefixToSave)
00615 {
00616 if (!q->isUsingRenderingCache()) {
00617 return;
00618 }
00619
00620
00621 FrameData *frame = frames.value(prefixToSave);
00622
00623 if (!frame) {
00624 return;
00625 }
00626
00627 QSizeF size = frameSize(frame);
00628 QString id = QString::fromLatin1("%5_%4_%3_%2_%1_").
00629 arg(frame->enabledBorders).arg(size.width()).arg(size.height()).arg(prefixToSave).arg(q->imagePath());
00630
00631
00632
00633 Theme::defaultTheme()->insertIntoCache(id, frame->cachedBackground, QString::number((qint64)q, 16)+prefixToSave);
00634
00635
00636 id = QString::fromLatin1("overlay_%7_%6_%5_%4_%3_%2_%1_").
00637 arg(overlayPos.y()).arg(overlayPos.x()).arg(frame->enabledBorders).arg(size.width()).arg(size.height()).arg(prefixToSave).arg(q->imagePath());
00638
00639 Theme::defaultTheme()->insertIntoCache(id, frame->cachedOverlay, QString::number((qint64)q, 16)+prefixToSave+"overlay");
00640 }
00641
00642 void FrameSvgPrivate::updateSizes()
00643 {
00644
00645 FrameData *frame = frames[prefix];
00646 Q_ASSERT(frame);
00647
00648 QSize s = q->size();
00649 q->resize();
00650 frame->cachedBackground = QPixmap();
00651 frame->cachedMask = QRegion();
00652
00653 if (frame->enabledBorders & FrameSvg::TopBorder) {
00654 frame->topHeight = q->elementSize(prefix + "top").height();
00655
00656 if (q->hasElement(prefix + "hint-top-margin")) {
00657 frame->topMargin = q->elementSize(prefix + "hint-top-margin").height();
00658 } else {
00659 frame->topMargin = frame->topHeight;
00660 }
00661 } else {
00662 frame->topMargin = frame->topHeight = 0;
00663 }
00664
00665 if (frame->enabledBorders & FrameSvg::LeftBorder) {
00666 frame->leftWidth = q->elementSize(prefix + "left").width();
00667
00668 if (q->hasElement(prefix + "hint-left-margin")) {
00669 frame->leftMargin = q->elementSize(prefix + "hint-left-margin").width();
00670 } else {
00671 frame->leftMargin = frame->leftWidth;
00672 }
00673 } else {
00674 frame->leftMargin = frame->leftWidth = 0;
00675 }
00676
00677 if (frame->enabledBorders & FrameSvg::RightBorder) {
00678 frame->rightWidth = q->elementSize(prefix + "right").width();
00679
00680 if (q->hasElement(prefix + "hint-right-margin")) {
00681 frame->rightMargin = q->elementSize(prefix + "hint-right-margin").width();
00682 } else {
00683 frame->rightMargin = frame->rightWidth;
00684 }
00685 } else {
00686 frame->rightMargin = frame->rightWidth = 0;
00687 }
00688
00689 if (frame->enabledBorders & FrameSvg::BottomBorder) {
00690 frame->bottomHeight = q->elementSize(prefix + "bottom").height();
00691
00692 if (q->hasElement(prefix + "hint-bottom-margin")) {
00693 frame->bottomMargin = q->elementSize(prefix + "hint-bottom-margin").height();
00694 } else {
00695 frame->bottomMargin = frame->bottomHeight;
00696 }
00697 } else {
00698 frame->bottomMargin = frame->bottomHeight = 0;
00699 }
00700
00701
00702 frame->tileCenter = q->hasElement("hint-tile-center");
00703 frame->noBorderPadding = q->hasElement("hint-no-border-padding");
00704 frame->stretchBorders = q->hasElement("hint-stretch-borders");
00705 q->resize(s);
00706 }
00707
00708 void FrameSvgPrivate::updateNeeded()
00709 {
00710 q->clearCache();
00711 updateSizes();
00712 }
00713
00714 void FrameSvgPrivate::updateAndSignalSizes()
00715 {
00716 updateSizes();
00717 emit q->repaintNeeded();
00718 }
00719
00720 QSizeF FrameSvgPrivate::frameSize(FrameData *frame)
00721 {
00722 if (!frame->frameSize.isValid()) {
00723 updateSizes();
00724 frame->frameSize = q->size();
00725 }
00726
00727 return frame->frameSize;
00728 }
00729
00730
00731 }
00732
00733 #include "framesvg.moc"