mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 13:48:59 +00:00
LyXText::rebuild -> LyXText::metrics
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7342 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
bd369211dc
commit
d16e9b926b
@ -275,16 +275,15 @@ void InsetText::read(Buffer const * buf, LyXLex & lex)
|
|||||||
|
|
||||||
void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
|
void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||||
{
|
{
|
||||||
//lyxerr << "InsetText::metrics: " << getInsetName()
|
//lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << "\n";
|
||||||
// << " width: " << mi.base.textwidth << "\n";
|
|
||||||
if (mi.base.textwidth)
|
if (mi.base.textwidth)
|
||||||
textwidth_ = mi.base.textwidth;
|
textwidth_ = mi.base.textwidth;
|
||||||
BufferView * bv = mi.base.bv;
|
BufferView * bv = mi.base.bv;
|
||||||
setViewCache(bv);
|
setViewCache(bv);
|
||||||
text_.rebuild(mi.base.textwidth);
|
text_.metrics(mi, dim);
|
||||||
dim.asc = text_.rows().begin()->ascent_of_text() + TEXT_TO_INSET_OFFSET;
|
dim.asc += TEXT_TO_INSET_OFFSET;
|
||||||
dim.des = text_.height - dim.asc + TEXT_TO_INSET_OFFSET;
|
dim.des += TEXT_TO_INSET_OFFSET;
|
||||||
dim.wid = max(textwidth_, int(text_.width)) + 2 * TEXT_TO_INSET_OFFSET;
|
dim.wid += 2 * TEXT_TO_INSET_OFFSET;
|
||||||
dim.wid = max(dim.wid, 10);
|
dim.wid = max(dim.wid, 10);
|
||||||
dim_ = dim;
|
dim_ = dim;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@ class UpdatableInset;
|
|||||||
class VSpace;
|
class VSpace;
|
||||||
class WordLangTuple;
|
class WordLangTuple;
|
||||||
class ParagraphList;
|
class ParagraphList;
|
||||||
|
class MetricsInfo;
|
||||||
|
class Dimension;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -163,8 +165,8 @@ public:
|
|||||||
void partialRebreak();
|
void partialRebreak();
|
||||||
/// a full rebreak of the whole text
|
/// a full rebreak of the whole text
|
||||||
void fullRebreak();
|
void fullRebreak();
|
||||||
/// rebuild RowList cache
|
/// compute text metrics
|
||||||
void rebuild(int maxwidth);
|
void metrics(MetricsInfo & mi, Dimension & dim);
|
||||||
|
|
||||||
///
|
///
|
||||||
RowList::iterator need_break_row;
|
RowList::iterator need_break_row;
|
||||||
|
28
src/text2.C
28
src/text2.C
@ -34,6 +34,7 @@
|
|||||||
#include "ParagraphParameters.h"
|
#include "ParagraphParameters.h"
|
||||||
#include "counters.h"
|
#include "counters.h"
|
||||||
#include "lyxrow_funcs.h"
|
#include "lyxrow_funcs.h"
|
||||||
|
#include "metricsinfo.h"
|
||||||
#include "paragraph_funcs.h"
|
#include "paragraph_funcs.h"
|
||||||
|
|
||||||
#include "insets/insetbibitem.h"
|
#include "insets/insetbibitem.h"
|
||||||
@ -47,6 +48,8 @@
|
|||||||
|
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace lyx::support;
|
using namespace lyx::support;
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
@ -692,8 +695,11 @@ void LyXText::fullRebreak()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::rebuild(int maxwidth)
|
void LyXText::metrics(MetricsInfo & mi, Dimension & dim)
|
||||||
{
|
{
|
||||||
|
lyxerr << "LyXText::metrics: width: " << mi.base.textwidth << "\n";
|
||||||
|
|
||||||
|
// rebuild row cache
|
||||||
rowlist_.clear();
|
rowlist_.clear();
|
||||||
need_break_row = rows().end();
|
need_break_row = rows().end();
|
||||||
width = height = 0;
|
width = height = 0;
|
||||||
@ -705,6 +711,15 @@ void LyXText::rebuild(int maxwidth)
|
|||||||
ParagraphList::iterator end = ownerParagraphs().end();
|
ParagraphList::iterator end = ownerParagraphs().end();
|
||||||
|
|
||||||
for (; pit != end; ++pit) {
|
for (; pit != end; ++pit) {
|
||||||
|
// compute inset metrics
|
||||||
|
for (int pos = 0; pos != pit->size(); ++pos) {
|
||||||
|
if (pit->isInset(pos)) {
|
||||||
|
Dimension dim;
|
||||||
|
MetricsInfo m = mi;
|
||||||
|
pit->getInset(pos)->metrics(m, dim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// insert a new row, starting at position 0
|
// insert a new row, starting at position 0
|
||||||
Row newrow(pit, 0);
|
Row newrow(pit, 0);
|
||||||
RowList::iterator rit = rowlist_.insert(rowlist_.end(), newrow);
|
RowList::iterator rit = rowlist_.insert(rowlist_.end(), newrow);
|
||||||
@ -713,6 +728,17 @@ void LyXText::rebuild(int maxwidth)
|
|||||||
appendParagraph(rit);
|
appendParagraph(rit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// compute height
|
||||||
|
//lyxerr << "height 0: " << height << "\n";
|
||||||
|
//for (RowList::iterator rit = rows().begin(); rit != rows().end(); ++rit) {
|
||||||
|
// height += rit->height();
|
||||||
|
//}
|
||||||
|
//lyxerr << "height 1: " << height << "\n";
|
||||||
|
|
||||||
|
// final dimension
|
||||||
|
dim.asc = rows().begin()->ascent_of_text();
|
||||||
|
dim.des = height - dim.asc;
|
||||||
|
dim.wid = std::max(mi.base.textwidth, int(width));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user