[Kst] extragear/graphics/kst/kst
George Staikos
staikos at kde.org
Fri Jul 8 03:12:14 CEST 2005
SVN commit 432631 by staikos:
render carriage returns
M +1 -2 kstviewlabel.cpp
M +8 -0 labelrenderer.cpp
M +2 -1 labelrenderer.h
--- trunk/extragear/graphics/kst/kst/kstviewlabel.cpp #432630:432631
@@ -38,7 +38,6 @@
/*
TODO:
-- \n
- \t
- Better dialog - perhaps make a property editor for view objects
- Optimize
@@ -261,7 +260,7 @@
void KstViewLabel::computeTextSize(Label::Parsed *lp) {
RenderContext rc(_fontName, _symbolFontName, _fontSize, 0L);
renderLabel(rc, lp->chunk);
- _textWidth = rc.x;
+ _textWidth = rc.xMax;
_ascent = rc.ascent;
_textHeight = 1 + rc.ascent + rc.descent;
}
--- trunk/extragear/graphics/kst/kst/labelrenderer.cpp #432630:432631
@@ -28,6 +28,7 @@
// FIXME: RTL support
int oldSize = rc.size;
int oldY = rc.y;
+ int oldX = rc.x;
while (fi) {
if (fi->vOffset != Label::Chunk::None) {
if (fi->vOffset == Label::Chunk::Up) {
@@ -47,6 +48,12 @@
fi = fi->next;
}
+ if (fi->linebreak) {
+ rc.x = oldX;
+ rc.y += rc.fontAscent() + rc.fontDescent() + 3;
+ fi = fi->next;
+ }
+
if (rc.prevSym != fi->symbol) {
rc.prevSym = fi->symbol;
QFont f = rc.font();
@@ -112,6 +119,7 @@
}
rc.x = xNext;
+ rc.xMax = kMax(rc.xMax, rc.x);
fi = fi->next;
}
--- trunk/extragear/graphics/kst/kst/labelrenderer.h #432630:432631
@@ -26,7 +26,7 @@
struct RenderContext {
RenderContext(const QString& fontName, const QString& symbolFontName, int fontSize, QPainter *p)
: fontName(fontName), symbolFontName(symbolFontName), size(fontSize), p(p), prevSym(false), _fm(_font) {
- x = y = 0;
+ x = y = xMax = 0;
ascent = descent = 0;
if (p) {
p->setFont(QFont(fontName, fontSize));
@@ -86,6 +86,7 @@
}
int x, y; // Coordinates we're rendering at
+ int xMax;
int ascent, descent;
QString fontName, symbolFontName;
int size;
More information about the Kst
mailing list