[Kst] extragear/graphics/kst/kst
George Staikos
staikos at kde.org
Fri Jul 8 03:54:06 CEST 2005
SVN commit 432635 by staikos:
Add support for tabs
M +1 -1 kstviewlabel.cpp
M +6 -3 labelparser.cpp
M +1 -0 labelparser.h
M +5 -1 labelrenderer.cpp
M +2 -2 labelrenderer.h
--- trunk/extragear/graphics/kst/kst/kstviewlabel.cpp #432634:432635
@@ -38,7 +38,6 @@
/*
TODO:
-- \t
- Better dialog - perhaps make a property editor for view objects
- Optimize
- Rendering testcases
@@ -253,6 +252,7 @@
p.translate(tx, ty);
p.rotate(_rotation);
+ rc.xStart = rc.x;
renderLabel(rc, lp->chunk);
}
--- trunk/extragear/graphics/kst/kst/labelparser.cpp #432634:432635
@@ -25,7 +25,7 @@
using namespace Label;
Chunk::Chunk(Chunk *parent, VOffset dir, bool group)
-: next(0L), prev(0L), up(0L), down(0L), symbol(false), scalar(false), group(group), linebreak(false), vOffset(dir) {
+: next(0L), prev(0L), up(0L), down(0L), symbol(false), scalar(false), group(group), linebreak(false), tab(false), vOffset(dir) {
assert(parent || vOffset == None);
if (parent) { // attach and inherit
switch (vOffset) {
@@ -70,7 +70,7 @@
bool Chunk::locked() const {
- return scalar || group || linebreak;
+ return scalar || group || linebreak || tab;
}
@@ -185,7 +185,10 @@
return true;
} else {
*skip = 1;
- setNormalChar('\t', tail);
+ if (!*tail || !(*tail)->text.isEmpty() || (*tail)->locked() || (*tail)->symbol) {
+ *tail = new Chunk(*tail);
+ }
+ (*tail)->tab = true;
return true;
}
break;
--- trunk/extragear/graphics/kst/kst/labelparser.h #432634:432635
@@ -51,6 +51,7 @@
bool scalar : 1;
bool group : 1;
bool linebreak : 1;
+ bool tab : 1;
VOffset vOffset : 2;
QString text;
};
--- trunk/extragear/graphics/kst/kst/labelrenderer.cpp #432634:432635
@@ -21,6 +21,7 @@
#include "kstdatacollection.h"
#include "labelparser.h"
+#include <kdebug.h>
#include <kglobal.h>
@@ -50,7 +51,7 @@
if (fi->linebreak) {
rc.x = oldX;
- rc.y += rc.fontAscent() + rc.fontDescent() + 3;
+ rc.y += rc.fontAscent() + rc.fontDescent() + 1;
fi = fi->next;
}
@@ -90,6 +91,9 @@
rc.p->drawText(rc.x, rc.y, txt);
}
rc.x += rc.fontWidth(txt);
+ } else if (fi->tab) {
+ int tabWidth = rc.fontWidth("MMMMMMMM");
+ rc.x += tabWidth - (rc.x - rc.xStart) % tabWidth;
} else {
if (rc.p) {
rc.p->drawText(rc.x, rc.y, fi->text);
--- trunk/extragear/graphics/kst/kst/labelrenderer.h #432634:432635
@@ -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 = xMax = 0;
+ x = y = xMax = xStart = 0;
ascent = descent = 0;
if (p) {
p->setFont(QFont(fontName, fontSize));
@@ -86,7 +86,7 @@
}
int x, y; // Coordinates we're rendering at
- int xMax;
+ int xMax, xStart;
int ascent, descent;
QString fontName, symbolFontName;
int size;
More information about the Kst
mailing list