[Kst] branches/work/kst/viewpaint/kst/kst
George Staikos
staikos at kde.org
Sun Jan 29 18:13:02 CET 2006
SVN commit 503599 by staikos:
more fixes for legend sizing - use the methods we want instead of trying to
duplicate the algorithm and being off-by-one sometimes.
M +8 -7 kstviewlabel.cpp
M +8 -6 kstviewlegend.cpp
--- branches/work/kst/viewpaint/kst/kst/kstviewlabel.cpp #503598:503599
@@ -212,7 +212,7 @@
void KstViewLabel::drawToBuffer(Label::Parsed *lp) {
setDirty(false);
- _backBuffer.buffer().resize(size());
+ _backBuffer.buffer().resize(contentsRect().size());
_backBuffer.buffer().fill(backgroundColor());
QPainter p(&_backBuffer.buffer());
drawToPainter(lp, p);
@@ -239,39 +239,40 @@
double abcos = fabs(cos(rotationRadians));
int tx = 0, ty = 0; // translation
+ const QRect cr(contentsRect());
switch (hJust) {
case KST_JUSTIFY_H_RIGHT:
rc.x = -_textWidth / 2;
- tx = size().width() - int(_textWidth * abcos + _textHeight * absin) / 2 - borderWidth() - _labelMargin*_ascent/10;
+ tx = cr.width() - int(_textWidth * abcos + _textHeight * absin) / 2 - _labelMargin*_ascent/10;
break;
case KST_JUSTIFY_H_CENTER:
rc.x = -_textWidth / 2;
- tx = size().width() / 2;
+ tx = cr.width() / 2;
break;
case KST_JUSTIFY_H_NONE:
abort(); // should never be able to happen
case KST_JUSTIFY_H_LEFT:
default:
rc.x = -_textWidth / 2;
- tx = int(_textWidth * abcos + _textHeight * absin) / 2 + borderWidth() + _labelMargin*_ascent/10;
+ tx = int(_textWidth * abcos + _textHeight * absin) / 2 + _labelMargin*_ascent/10;
break;
}
switch (KST_JUSTIFY_V(_justify)) {
case KST_JUSTIFY_V_BOTTOM:
rc.y = _ascent - _textHeight / 2;
- ty = size().height() - int(_textHeight * abcos + _textWidth * absin) / 2 - borderWidth() - _labelMargin*_ascent/10;
+ ty = cr.height() - int(_textHeight * abcos + _textWidth * absin) / 2 - _labelMargin*_ascent/10;
break;
case KST_JUSTIFY_V_CENTER:
rc.y = _ascent - _textHeight / 2;
- ty = size().height() / 2;
+ ty = cr.height() / 2;
break;
case KST_JUSTIFY_V_NONE:
case KST_JUSTIFY_V_TOP:
default:
rc.y = _ascent - _textHeight / 2;
- ty = int(_textHeight * abcos + _textWidth * absin) / 2 + borderWidth() + _labelMargin*_ascent/10;
+ ty = int(_textHeight * abcos + _textWidth * absin) / 2 + _labelMargin*_ascent/10;
break;
}
--- branches/work/kst/viewpaint/kst/kst/kstviewlegend.cpp #503598:503599
@@ -158,7 +158,7 @@
void KstViewLegend::drawToBuffer() {
setDirty(false);
- _backBuffer.buffer().resize(size());
+ _backBuffer.buffer().resize(contentsRect().size());
_backBuffer.buffer().fill(backgroundColor());
QPainter p(&_backBuffer.buffer());
QPen pen;
@@ -334,8 +334,8 @@
void KstViewLegend::adjustSizeForText(QRect w) {
- double x_s, y_s, s;
- int width, height;
+ double x_s, y_s;
+ int width;
x_s = y_s = _fontSize + (double)KstSettings::globalSettings()->plotFontSize;
@@ -350,7 +350,7 @@
x_s *= x_pix/748.0;
}
- s = (x_s + y_s)/2.0;
+ double s = (x_s + y_s)/2.0;
if (s < MIN_FONT_SIZE) {
s = MIN_FONT_SIZE;
@@ -367,7 +367,7 @@
} else {
width = _textWidth + 9*_ascent*_curves.count()/2 - _ascent;
}
- height = _textHeight;
+ double height = _textHeight;
QSize sz(width, height);
@@ -376,7 +376,9 @@
sz = r.intersect(_parent->geometry()).size();
}
- resize(sz + QSize((borderWidth()+_legendMargin*_ascent/10)*2, (borderWidth()+_legendMargin*_ascent/10)*2));
+ QRect cr(contentsRect());
+ cr.setSize(sz + QSize(2 * _legendMargin + _ascent / 5, 2 * _legendMargin + _ascent / 5));
+ setContentsRect(cr);
}
More information about the Kst
mailing list