[Kst] branches/work/kst/viewpaint/kst/kst
George Staikos
staikos at kde.org
Sun Jan 29 06:03:01 CET 2006
SVN commit 503431 by staikos:
remove abuse of padding(), fixing flicker and missing borders
also note that dirty() is always false in paintSelf() now, so we need to find
a different solution
M +1 -1 kstplotdialog_i.cpp
M +18 -12 kstviewlegend.cpp
M +3 -0 kstviewlegend.h
--- branches/work/kst/viewpaint/kst/kst/kstplotdialog_i.cpp #503430:503431
@@ -604,7 +604,7 @@
vl->setBorderColor(legendColors->foreground());
vl->setTransparent(_transparent->isChecked());
vl->setBorderWidth(_border->value());
- vl->setPadding(_margin->value());
+ vl->setLegendMargin(_margin->value());
} else {
KstViewLegendPtr vl = plotExtra->legend();
if (vl) {
--- branches/work/kst/viewpaint/kst/kst/kstviewlegend.cpp #503430:503431
@@ -63,7 +63,7 @@
setBorderColor(KstSettings::globalSettings()->foregroundColor);
setBackgroundColor(KstSettings::globalSettings()->backgroundColor);
setBorderWidth(2);
- setPadding(5);
+ _legendMargin = 5;
_absFontSize = _fontSize+KstSettings::globalSettings()->plotFontSize;
_layoutActions &= ~(MoveTo | Copy | CopyTo);
_standardActions |= Delete | Edit;
@@ -82,6 +82,7 @@
_fontName = KstApp::inst()->defaultFont();
_fontSize = 0;
_vertical = true;
+ _legendMargin = 5;
_absFontSize = _fontSize+KstSettings::globalSettings()->plotFontSize;
_layoutActions &= ~(MoveTo | Copy | CopyTo);
_standardActions |= Delete | Edit;
@@ -175,7 +176,7 @@
for (KstBaseCurveList::Iterator it = _curves.begin(); it != _curves.end(); ++it) {
p.save();
if ((*it)->parsedLegendTag()) {
- p.translate(borderWidth() + padding()*_ascent/10, borderWidth() + padding()*_ascent/10 + (i)*(rc.fontHeight()+_ascent/4));
+ p.translate(borderWidth() + _legendMargin*_ascent/10, borderWidth() + _legendMargin*_ascent/10 + (i)*(rc.fontHeight()+_ascent/4));
QRect symbolBound(QPoint(0,0),
QSize(16*_ascent/4, rc.fontHeight()));
@@ -191,7 +192,7 @@
}
} else {
p.save();
- p.translate(borderWidth() + padding()*_ascent/10, borderWidth() + padding()*_ascent/10);
+ p.translate(borderWidth() + _legendMargin*_ascent/10, borderWidth() + _legendMargin*_ascent/10);
for (KstBaseCurveList::Iterator it = _curves.begin(); it != _curves.end(); ++it) {
if ((*it)->parsedLegendTag()) {
QRect symbolBound(QPoint(0,0),
@@ -259,8 +260,8 @@
p.save();
KstBorderedViewObject::paint(p, bounds);
adjustSizeForText(p.window());
- p.setViewport(geometry());
- p.setWindow(0,0,geometry().width(), geometry().height());
+ p.setViewport(contentsRect());
+ p.setWindow(0, 0,contentsRect().width(), contentsRect().height());
drawToPainter(p);
//setDirty();
p.restore();
@@ -276,7 +277,7 @@
}
}
- bool d = dirty();
+ bool d = dirty(); // FIXME: always false
if (d) {
adjustSizeForText(p.window()); // calls computeTextSize
}
@@ -284,10 +285,10 @@
if (_transparent) {
QRegion oldRegion = p.clipRegion();
p.setClipRegion(oldRegion & clipRegion());
- _backBuffer.paintInto(p, geometry());
+ _backBuffer.paintInto(p, contentsRect());
p.setClipRegion(oldRegion);
} else {
- _backBuffer.paintInto(p, geometry());
+ _backBuffer.paintInto(p, contentsRect());
}
}
}
@@ -301,7 +302,7 @@
if (_clipMask.isNull()) {
QBitmap bm = _backBuffer.buffer().createHeuristicMask(false); // slow but preserves antialiasing...
_clipMask = QRegion(bm);
- _clipMask.translate(geometry().topLeft().x(), geometry().topLeft().y());
+ _clipMask.translate(contentsRect().topLeft().x(), contentsRect().topLeft().y());
}
return _clipMask;
@@ -369,7 +370,7 @@
sz = r.intersect(_parent->geometry()).size();
}
- resize(sz + QSize((borderWidth()+padding()*_ascent/10)*2, (borderWidth()+padding()*_ascent/10)*2));
+ resize(sz + QSize((borderWidth()+_legendMargin*_ascent/10)*2, (borderWidth()+_legendMargin*_ascent/10)*2));
}
@@ -472,7 +473,7 @@
widget->_border->setValue(borderWidth());
widget->_boxColors->setForeground(borderColor());
widget->_boxColors->setBackground(backgroundColor());
- widget->_margin->setValue(padding());
+ widget->_margin->setValue(_legendMargin);
widget->_vertical->setChecked(vertical());
for (KstBaseCurveList::ConstIterator it = _curves.begin(); it != _curves.end(); ++it) {
(*it)->readLock();
@@ -506,7 +507,7 @@
setBorderWidth(widget->_border->value());
setBorderColor(widget->_boxColors->foreground());
setBackgroundColor(widget->_boxColors->background());
- setPadding(widget->_margin->value());
+ _legendMargin = widget->_margin->value();
setVertical(widget->_vertical->isChecked());
KstBaseCurveList allCurves = kstObjectSubList<KstDataObject, KstBaseCurve>(KST::dataObjectList);
@@ -541,6 +542,11 @@
}
+void KstViewLegend::setLegendMargin(int margin) {
+ _legendMargin = margin;
+}
+
+
KstBaseCurveList& KstViewLegend::curves() {
return _curves;
}
--- branches/work/kst/viewpaint/kst/kst/kstviewlegend.h #503430:503431
@@ -76,6 +76,8 @@
bool vertical() const;
void setVertical(bool vertical);
+ void setLegendMargin(int margin);
+
KstBaseCurveList& curves();
public slots:
void adjustSizeForText(QRect w);
@@ -101,6 +103,7 @@
int _absFontSize; // points
int _fontSize; // size relative to reference size.....
int _textWidth, _textHeight, _ascent;
+ int _legendMargin;
KstBackBuffer _backBuffer;
KstBaseCurveList _curves;
};
More information about the Kst
mailing list