summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/CDrawBuffer.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-reader/CDrawBuffer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/CDrawBuffer.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/CDrawBuffer.cpp b/noncore/apps/opie-reader/CDrawBuffer.cpp
index 2ceb2d5..892456f 100644
--- a/noncore/apps/opie-reader/CDrawBuffer.cpp
+++ b/noncore/apps/opie-reader/CDrawBuffer.cpp
@@ -84,49 +84,49 @@ void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/)
segs.first().start = 0;
segs.first().style = _style;
}
else if (_style != segs.last().style)
{
int thissize = fc->getsize(_style);
if (thissize > m_maxstyle)
{
m_maxstyle = thissize;
m_ascent = fc->ascent(_style);
m_descent = fc->descent(_style);
m_lineSpacing = fc->lineSpacing(_style);
}
segs.push_back(textsegment(len, _style));
}
(*this)[len++] = ch;
}
void CDrawBuffer::truncate(int n)
{
len = n;
(*this)[n] = 0;
}
-int CDrawBuffer::width(int numchars = -1)
+int CDrawBuffer::width(int numchars)
{
int currentx = 0, end = 0;
QString text = toQString(data());
CList<textsegment>::iterator textstart = segs.begin();
CList<textsegment>::iterator textend = textstart;
do
{
textend++;
end = (textend != segs.end()) ? textend->start : length();
if (numchars >= 0 && end > numchars)
{
end = numchars;
}
CStyle currentstyle = textstart->style;
QFont f(fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) );
QString str = text.mid(textstart->start, end-textstart->start);
QFontMetrics fm(f);
currentx += fm.width(str);
textstart = textend;
}
while (textend != segs.end() && end != numchars);
return currentx;
}