- get rid of the cached Dimension. Text inset dimensions are saved in ParagraphMetrics and mathed maintain their own dimension where needed.
- width(), ascent(), descent(): deleted.
- dimension(): now needs a valid BufferView.
- metrics(): now void.

* BufferView::getCoveringInset(): simplify.

* ParagraphMetrics(): now cache inset dimensions.




git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20420 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-09-21 20:39:47 +00:00
parent 24a74bdb53
commit 237c132c1e
176 changed files with 354 additions and 548 deletions

View File

@ -1045,49 +1045,30 @@ void BufferView::resize(int width, int height)
Inset const * BufferView::getCoveringInset(Text const & text, int x, int y)
{
pit_type pit = text_metrics_[&text].getPitNearY(y);
BOOST_ASSERT(pit != -1);
Paragraph const & par = text.getPar(pit);
TextMetrics & tm = text_metrics_[&text];
Inset * inset = tm.checkInsetHit(x, y);
if (!inset)
return 0;
LYXERR(Debug::DEBUG)
<< BOOST_CURRENT_FUNCTION
<< ": x: " << x
<< " y: " << y
<< " pit: " << pit
<< endl;
InsetList::const_iterator iit = par.insetlist.begin();
InsetList::const_iterator iend = par.insetlist.end();
for (; iit != iend; ++iit) {
Inset * const inset = iit->inset;
if (inset->covers(*this, x, y)) {
if (!inset->descendable())
// No need to go further down if the inset is not
// descendable.
return inset;
if (!inset->descendable())
// No need to go further down if the inset is not
// descendable.
return inset;
size_t cell_number = inset->nargs();
// Check all the inner cell.
for (size_t i = 0; i != cell_number; ++i) {
Text const * inner_text = inset->getText(i);
if (inner_text) {
// Try deeper.
Inset const * inset_deeper =
getCoveringInset(*inner_text, x, y);
if (inset_deeper)
return inset_deeper;
}
}
LYXERR(Debug::DEBUG)
<< BOOST_CURRENT_FUNCTION
<< ": Hit inset: " << inset << endl;
return inset;
size_t cell_number = inset->nargs();
// Check all the inner cell.
for (size_t i = 0; i != cell_number; ++i) {
Text const * inner_text = inset->getText(i);
if (inner_text) {
// Try deeper.
Inset const * inset_deeper =
getCoveringInset(*inner_text, x, y);
if (inset_deeper)
return inset_deeper;
}
}
LYXERR(Debug::DEBUG)
<< BOOST_CURRENT_FUNCTION
<< ": No inset hit. " << endl;
return 0;
return inset;
}

View File

@ -118,6 +118,24 @@ void ParagraphMetrics::setPosition(int position)
}
Dimension const & ParagraphMetrics::insetDimension(Inset const * inset) const
{
InsetDims::const_iterator it = inset_dims_.find(inset);
if (it != inset_dims_.end())
return it->second;
static Dimension dummy;
return dummy;
}
void ParagraphMetrics::setInsetDimension(Inset const * inset,
Dimension const & dim)
{
inset_dims_[inset] = dim;
}
Row & ParagraphMetrics::getRow(pos_type pos, bool boundary)
{
BOOST_ASSERT(!rows().empty());
@ -200,7 +218,7 @@ int ParagraphMetrics::singleWidth(pos_type pos, Font const & font) const
// The most special cases are handled first.
if (c == Paragraph::META_INSET)
return par_->getInset(pos)->width();
return insetDimension(par_->getInset(pos)).wid;
if (!isPrintable(c))
return theFontMetrics(font).width(c);

View File

@ -21,6 +21,8 @@
#include "Paragraph.h"
#include "Row.h"
#include <map>
namespace lyx {
/**
@ -86,6 +88,10 @@ public:
int position() const { return position_; }
void setPosition(int position);
///
Dimension const & insetDimension(Inset const * inset) const;
///
void setInsetDimension(Inset const *, Dimension const & dim);
private:
///
@ -96,6 +102,10 @@ private:
Dimension dim_;
///
Paragraph const * par_;
typedef std::map<Inset const *, Dimension> InsetDims;
///
InsetDims inset_dims_;
};
} // namespace lyx

View File

@ -385,7 +385,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
&& cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
}
} else
cur.setCurrentFont();
break;
case LFUN_CHAR_BACKWARD:
@ -401,7 +402,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
&& cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_LEFT);
}
} else
cur.setCurrentFont();
break;
case LFUN_UP_SELECT:

View File

@ -387,14 +387,15 @@ bool TextMetrics::redoParagraph(pit_type const pit)
InsetList::const_iterator ii = par.insetlist.begin();
InsetList::const_iterator iend = par.insetlist.end();
for (; ii != iend; ++ii) {
Dimension old_dim = ii->inset->dimension();
Dimension dim;
int const w = max_width_ - leftMargin(max_width_, pit, ii->pos)
- right_margin;
Font const & font = ii->inset->noFontChange() ?
bufferfont : getDisplayFont(pit, ii->pos);
MetricsInfo mi(bv_, font, w);
changed |= ii->inset->metrics(mi, dim);
ii->inset->metrics(mi, dim);
Dimension const old_dim = pm.insetDimension(ii->inset);
pm.setInsetDimension(ii->inset, dim);
changed |= (old_dim != dim);
}
@ -862,12 +863,14 @@ boost::tuple<int, int> TextMetrics::rowHeight(pit_type const pit, pos_type const
int maxdesc = int(fontmetrics.maxDescent() * spacing_val);
// insets may be taller
ParagraphMetrics const & pm = par_metrics_[pit];
InsetList::const_iterator ii = par.insetlist.begin();
InsetList::const_iterator iend = par.insetlist.end();
for ( ; ii != iend; ++ii) {
Dimension const & dim = pm.insetDimension(ii->inset);
if (ii->pos >= first && ii->pos < end) {
maxasc = max(maxasc, ii->inset->ascent());
maxdesc = max(maxdesc, ii->inset->descent());
maxasc = max(maxasc, dim.ascent());
maxdesc = max(maxdesc, dim.descent());
}
}
@ -1400,6 +1403,7 @@ Inset * TextMetrics::checkInsetHit(int x, int y)
BOOST_ASSERT(pit != -1);
Paragraph const & par = text_->paragraphs()[pit];
ParagraphMetrics const & pm = par_metrics_[pit];
LYXERR(Debug::DEBUG)
<< BOOST_CURRENT_FUNCTION
@ -1411,32 +1415,37 @@ Inset * TextMetrics::checkInsetHit(int x, int y)
InsetList::const_iterator iend = par.insetlist.end();
for (; iit != iend; ++iit) {
Inset * inset = iit->inset;
#if 1
LYXERR(Debug::DEBUG)
<< BOOST_CURRENT_FUNCTION
<< ": examining inset " << inset << endl;
if (bv_->coordCache().getInsets().has(inset))
LYXERR(Debug::DEBUG)
<< BOOST_CURRENT_FUNCTION
<< ": xo: " << inset->xo(*bv_) << "..."
<< inset->xo(*bv_) + inset->width()
<< " yo: " << inset->yo(*bv_) - inset->ascent()
<< "..."
<< inset->yo(*bv_) + inset->descent()
<< endl;
else
if (!bv_->coordCache().getInsets().has(inset)) {
LYXERR(Debug::DEBUG)
<< BOOST_CURRENT_FUNCTION
<< ": inset has no cached position" << endl;
#endif
if (inset->covers(*bv_, x, y)) {
return 0;
}
Dimension const & dim = pm.insetDimension(inset);
Point p = bv_->coordCache().getInsets().xy(inset);
LYXERR(Debug::DEBUG)
<< BOOST_CURRENT_FUNCTION
<< ": xo: " << p.x_ << "..." << p.x_ + dim.wid
<< " yo: " << p.y_ - dim.asc << "..." << p.y_ + dim.des
<< endl;
if (x >= p.x_ && p.x_ + dim.wid
&& y >= p.y_ - dim.asc
&& y <= p.y_ + dim.des) {
LYXERR(Debug::DEBUG)
<< BOOST_CURRENT_FUNCTION
<< ": Hit inset: " << inset << endl;
return inset;
}
}
LYXERR(Debug::DEBUG)
<< BOOST_CURRENT_FUNCTION
<< ": No inset hit. " << endl;

View File

@ -181,7 +181,8 @@ Point coordOffset(BufferView const & bv, DocIterator const & dit,
}
// remember width for the case that sl.inset() is positioned in an RTL inset
lastw = sl.inset().width();
Dimension const dim = sl.inset().dimension(bv);
lastw = dim.wid;
//lyxerr << "Cursor::getPos, i: "
// << i << " x: " << xx << " y: " << y << endl;

View File

@ -35,6 +35,9 @@
#include "frontends/Painter.h"
#include "support/convert.h"
#include "support/ExceptionMessage.h"
#include <boost/current_function.hpp>
#include <map>
@ -116,12 +119,18 @@ static TranslatorMap const build_translator()
}
/// pretty arbitrary dimensions
Inset::Inset()
: dim_(10, 10, 10)
{}
Dimension const Inset::dimension(BufferView const &) const
{
docstring const id = convert<docstring>(int(lyxCode())) + " " + name();
throw support::ExceptionMessage(support::ErrorException,
_("Inset::dimension(): unimplemented method"), id);
}
Inset::Code Inset::translate(std::string const & name)
{
static TranslatorMap const translator = build_translator();
@ -278,8 +287,10 @@ void Inset::drawMarkers(PainterInfo & pi, int x, int y) const
Color::color pen_color = mouseHovered() || editing(pi.base.bv)?
Color::mathframe : Color::mathcorners;
int const t = x + width() - 1;
int const d = y + descent();
Dimension const dim = dimension(*pi.base.bv);
int const t = x + dim.width() - 1;
int const d = y + dim.descent();
pi.pain.line(x, d - 3, x, d, pen_color);
pi.pain.line(t, d - 3, t, d, pen_color);
pi.pain.line(x, d, x + 3, d, pen_color);
@ -294,8 +305,9 @@ void Inset::drawMarkers2(PainterInfo & pi, int x, int y) const
Color::mathframe : Color::mathcorners;
drawMarkers(pi, x, y);
int const t = x + width() - 1;
int const a = y - ascent();
Dimension const dim = dimension(*pi.base.bv);
int const t = x + dim.width() - 1;
int const a = y - dim.ascent();
pi.pain.line(x, a + 3, x, a, pen_color);
pi.pain.line(t, a + 3, t, a, pen_color);
pi.pain.line(x, a, x + 3, a, pen_color);
@ -329,11 +341,14 @@ bool Inset::covers(BufferView const & bv, int x, int y) const
// << " x1: " << xo(bv) << " x2: " << xo() + width()
// << " y1: " << yo(bv) - ascent() << " y2: " << yo() + descent()
// << std::endl;
Dimension const dim = dimension(bv);
return bv.coordCache().getInsets().has(this)
&& x >= xo(bv)
&& x <= xo(bv) + width()
&& y >= yo(bv) - ascent()
&& y <= yo(bv) + descent();
&& x <= xo(bv) + dim.width()
&& y >= yo(bv) - dim.ascent()
&& y <= yo(bv) + dim.descent();
}

View File

@ -120,7 +120,7 @@ public:
/// compute the size of the object returned in dim
/// \retval true if metrics changed.
virtual bool metrics(MetricsInfo & mi, Dimension & dim) const = 0;
virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
/// draw inset and update (xo, yo)-cache
virtual void draw(PainterInfo & pi, int x, int y) const = 0;
/// draw inset selection if necessary
@ -478,14 +478,8 @@ public:
/// reject the changes within the inset
virtual void rejectChanges(BufferParams const &) {};
/// FIXME: move dim_ out of Inset!
Dimension const & dimension() { return dim_; }
/// inset width.
int width() const { return dim_.wid; }
/// inset ascent.
int ascent() const { return dim_.asc; }
/// inset descent.
int descent() const { return dim_.des; }
///
virtual Dimension const dimension(BufferView const &) const;
///
int scroll() const { return 0; }
///
@ -520,9 +514,6 @@ protected:
* \sa getStatus
*/
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
/// Cached dimensions of the inset.
mutable Dimension dim_;
};

View File

@ -171,7 +171,7 @@ bool InsetBox::hasFixedWidth() const
}
bool InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
void InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
{
// back up textwidth.
int textwidth_backup = m.base.textwidth;
@ -180,9 +180,6 @@ bool InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
InsetCollapsable::metrics(m, dim);
// retore textwidth.
m.base.textwidth = textwidth_backup;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -72,7 +72,7 @@ public:
///
void setButtonLabel();
///
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
/// show the Box dialog
bool showInsetDialog(BufferView * bv) const;
///

View File

@ -125,7 +125,7 @@ void InsetCaption::addToToc(TocList & toclist, Buffer const & buf, ParConstItera
}
bool InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const
{
labelwidth_ = theFontMetrics(mi.base.font).width(full_label_);
// add some space to separate the label from the inset text
@ -139,9 +139,6 @@ bool InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const
dim.des = std::max(dim.des - textdim.asc + dim.asc, textdim.des);
dim.asc = textdim.asc;
dim.wid += textdim.wid;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -45,7 +45,7 @@ public:
///
bool descendable() const { return true; }
///
virtual bool metrics(MetricsInfo & mi, Dimension & dim) const;
virtual void metrics(MetricsInfo & mi, Dimension & dim) const;
///
virtual void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -170,7 +170,7 @@ Dimension InsetCollapsable::dimensionCollapsed() const
}
bool InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
{
autoOpen_ = mi.base.bv->cursor().isInside(this);
@ -196,7 +196,8 @@ bool InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
docstring s = layout_.labelstring;
theFontMetrics(font).rectText(s, w, a, d);
dim.wid = max(dim.wid, w);
dim.des += ascent();
// FIXME
//dim.des += ascent();
break;
}
case TopButton:
@ -220,10 +221,6 @@ bool InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
}
break;
}
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}
@ -288,9 +285,9 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
InsetText::draw(pi, textx, texty);
const_cast<InsetCollapsable *>(this)->setDrawFrame(true);
int desc = InsetText::descent();
int desc = textdim.descent();
if (geometry() == SubLabel)
desc -= ascent();
desc -= 0; // ascent();
else
desc -= 3;
@ -333,7 +330,8 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
// a visual cue when the cursor is inside the inset
Cursor & cur = pi.base.bv->cursor();
if (cur.isInside(this)) {
y -= ascent();
// FIXME
//y -= ascent();
y += 3;
pi.pain.line(xx1, y + 4, xx1, y, layout_.labelfont.color());
pi.pain.line(xx1 + 4, y, xx1, y, layout_.labelfont.color());

View File

@ -54,7 +54,7 @@ public:
///
void write(Buffer const &, std::ostream &) const;
///
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;

View File

@ -48,7 +48,7 @@ InsetCommand::~InsetCommand()
}
bool InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
{
if (updateButtonLabel_) {
updateButtonLabel_ = false;
@ -56,9 +56,6 @@ bool InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
editable() != NOT_EDITABLE);
}
button_.metrics(mi, dim);
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -38,7 +38,9 @@ public:
///
~InsetCommand();
///
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
///
Dimension const dimension(BufferView const &) const { return button_.dimension(); }
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -405,16 +405,13 @@ bool InsetERT::insetAllowed(Inset::Code /* code */) const
}
bool InsetERT::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetERT::metrics(MetricsInfo & mi, Dimension & dim) const
{
Font tmpfont = mi.base.font;
getDrawFont(mi.base.font);
mi.base.font.realize(tmpfont);
InsetCollapsable::metrics(mi, dim);
mi.base.font = tmpfont;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -65,7 +65,7 @@ public:
///
void validate(LaTeXFeatures &) const {}
///
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -506,12 +506,9 @@ void InsetExternal::edit(Cursor & cur, bool)
}
bool InsetExternal::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetExternal::metrics(MetricsInfo & mi, Dimension & dim) const
{
renderer_->metrics(mi, dim);
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -117,7 +117,7 @@ public:
virtual EDITABLE editable() const { return IS_EDITABLE; }
///
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -96,15 +96,14 @@ void InsetFlex::read(Buffer const & buf, Lexer & lex)
}
bool InsetFlex::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetFlex::metrics(MetricsInfo & mi, Dimension & dim) const
{
Font tmpfont = mi.base.font;
getDrawFont(mi.base.font);
mi.base.font.reduce(Font(Font::ALL_SANE));
mi.base.font.realize(tmpfont);
bool changed = InsetCollapsable::metrics(mi, dim);
InsetCollapsable::metrics(mi, dim);
mi.base.font = tmpfont;
return changed;
}

View File

@ -54,7 +54,7 @@ public:
///
void read(Buffer const & buf, Lexer & lex);
///
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
///
void draw(PainterInfo &, int, int) const;
///

View File

@ -31,15 +31,12 @@ InsetFootlike::InsetFootlike(InsetFootlike const & in)
{}
bool InsetFootlike::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetFootlike::metrics(MetricsInfo & mi, Dimension & dim) const
{
Font tmpfont = mi.base.font;
mi.base.font = mi.base.bv->buffer().params().getFont();
InsetCollapsable::metrics(mi, dim);
mi.base.font = tmpfont;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -27,7 +27,7 @@ public:
///
InsetFootlike(InsetFootlike const &);
///
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -257,12 +257,9 @@ void InsetGraphics::edit(Cursor & cur, bool)
}
bool InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const
{
graphic_->metrics(mi, dim);
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -34,7 +34,7 @@ public:
///
~InsetGraphics();
///
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
///
EDITABLE editable() const;
///

View File

@ -30,14 +30,11 @@ Inset * InsetHFill::clone() const
}
bool InsetHFill::metrics(MetricsInfo &, Dimension & dim) const
void InsetHFill::metrics(MetricsInfo &, Dimension & dim) const
{
dim.wid = 3;
dim.asc = 3;
dim.des = 3;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -23,7 +23,7 @@ public:
///
InsetHFill();
///
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
///
docstring const getScreenLabel(Buffer const &) const;
///

View File

@ -783,7 +783,7 @@ InsetInclude::getBibfilesCache(Buffer const & buffer) const
}
bool InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
{
BOOST_ASSERT(mi.base.bv);
@ -807,10 +807,6 @@ bool InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
Box b(0, dim.wid, -dim.asc, dim.des);
button_.setBox(b);
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -40,7 +40,7 @@ public:
~InsetInclude();
/// Override these InsetButton methods if Previewing
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -41,21 +41,18 @@ void InsetLine::write(Buffer const &, ostream & os) const
}
bool InsetLine::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetLine::metrics(MetricsInfo & mi, Dimension & dim) const
{
dim.asc = 3;
dim.des = 3;
dim.wid = mi.base.textwidth;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}
void InsetLine::draw(PainterInfo & pi, int x, int y) const
{
pi.pain.line(x, y, x + dim_.wid, y, Color::topline, Painter::line_solid,
Painter::line_thick);
pi.pain.line(x, y, x + pi.base.textwidth, y, Color::topline,
Painter::line_solid, Painter::line_thick);
}

View File

@ -25,7 +25,7 @@ public:
Inset::Code lyxCode() const { return Inset::LINE_CODE; }
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
void draw(PainterInfo & pi, int x, int y) const;

View File

@ -269,16 +269,13 @@ void InsetListings::setButtonLabel()
}
bool InsetListings::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetListings::metrics(MetricsInfo & mi, Dimension & dim) const
{
Font tmpfont = mi.base.font;
getDrawFont(mi.base.font);
mi.base.font.realize(tmpfont);
InsetCollapsable::metrics(mi, dim);
mi.base.font = tmpfont;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -49,7 +49,7 @@ public:
///
void validate(LaTeXFeatures &) const;
///
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -38,15 +38,12 @@ void InsetNewline::write(Buffer const &, ostream & os) const
}
bool InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const
{
frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
dim.asc = fm.maxAscent();
dim.des = fm.maxDescent();
dim.wid = fm.width('n');
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -25,7 +25,7 @@ public:
Inset::Code lyxCode() const { return Inset::NEWLINE_CODE; }
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
virtual void draw(PainterInfo & pi, int x, int y) const;

View File

@ -41,14 +41,11 @@ void InsetPagebreak::write(Buffer const &, std::ostream & os) const
}
bool InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
{
dim.asc = defaultRowHeight();
dim.des = defaultRowHeight();
dim.wid = mi.base.textwidth;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}
@ -63,7 +60,7 @@ void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
int d = 0;
theFontMetrics(font).rectText(insetLabel(), w, a, d);
int const text_start = int(x + (dim_.wid - w) / 2);
int const text_start = int(x + (pi.base.textwidth - w) / 2);
int const text_end = text_start + w;
pi.pain.rectText(text_start, y + d, insetLabel(), font,
@ -71,7 +68,7 @@ void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
pi.pain.line(x, y, text_start, y,
Color::pagebreak, Painter::line_onoffdash);
pi.pain.line(text_end, y, int(x + dim_.wid), y,
pi.pain.line(text_end, y, int(x + pi.base.textwidth), y,
Color::pagebreak, Painter::line_onoffdash);
}

View File

@ -25,7 +25,7 @@ public:
Inset::Code lyxCode() const { return Inset::PAGEBREAK_CODE; }
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
void draw(PainterInfo & pi, int x, int y) const;

View File

@ -214,7 +214,7 @@ docstring const InsetQuotes::dispString(Language const * loclang) const
}
bool InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const
{
Font & font = mi.base.font;
frontend::FontMetrics const & fm =
@ -232,9 +232,6 @@ bool InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const
else
dim.wid += fm.width(',');
}
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -76,7 +76,7 @@ public:
///
docstring name() const { return from_ascii("Quotes"); }
///
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;
#if 0

View File

@ -47,7 +47,7 @@ InsetSpace::Kind InsetSpace::kind() const
}
bool InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
{
frontend::FontMetrics const & fm =
theFontMetrics(mi.base.font);
@ -74,15 +74,12 @@ bool InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
dim.wid = 10;
break;
}
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}
void InsetSpace::draw(PainterInfo & pi, int x, int y) const
{
int const w = width();
int const w = dim_.wid;
int const h = theFontMetrics(pi.base.font)
.ascent('x');
int xp[4], yp[4];

View File

@ -56,7 +56,9 @@ public:
///
Kind kind() const;
///
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
///
Dimension const dimension(BufferView const &) const { return dim_; };
///
void draw(PainterInfo & pi, int x, int y) const;
///
@ -92,6 +94,8 @@ private:
/// And which kind is this?
Kind kind_;
///
mutable Dimension dim_;
};

View File

@ -41,7 +41,7 @@ InsetSpecialChar::Kind InsetSpecialChar::kind() const
}
bool InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
{
frontend::FontMetrics const & fm =
theFontMetrics(mi.base.font);
@ -60,9 +60,6 @@ bool InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
dim.wid = fm.width(ds);
if (kind_ == HYPHENATION && dim.wid > 5)
dim.wid -= 2; // to make it look shorter
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -48,7 +48,7 @@ public:
///
Kind kind() const;
///
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -2932,7 +2932,7 @@ void InsetTabular::read(Buffer const & buf, Lexer & lex)
}
bool InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
{
//lyxerr << "InsetTabular::metrics: " << mi.base.bv << " width: " <<
// mi.base.textwidth << "\n";
@ -2986,9 +2986,6 @@ bool InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
dim.asc = tabular.rowAscent(0);
dim.des = tabular.height() - dim.asc;
dim.wid = tabular.width() + 2 * ADD_TO_TABULAR_WIDTH;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -667,7 +667,7 @@ public:
///
void write(Buffer const &, std::ostream &) const;
///
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -166,7 +166,7 @@ void InsetText::read(Buffer const & buf, Lexer & lex)
}
bool InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
{
TextMetrics & tm = mi.base.bv->textMetrics(&text_);
@ -183,9 +183,6 @@ bool InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
dim.asc += TEXT_TO_INSET_OFFSET;
dim.des += TEXT_TO_INSET_OFFSET;
dim.wid += 2 * TEXT_TO_INSET_OFFSET;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -54,7 +54,7 @@ public:
///
void write(Buffer const & buf, std::ostream & os) const;
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -67,14 +67,11 @@ Inset * InsetTheorem::clone() const
}
bool Inset.heorem::metrics(MetricsInfo & mi, Dimension & dim) const
void Inset.heorem::metrics(MetricsInfo & mi, Dimension & dim) const
{
InsetCollapsable::metrics(mi, dim);
center_indent_ = (mi.base.textwidth - dim.wid) / 2;
dim.wid = mi.base.textwidth;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -30,7 +30,7 @@ public:
///
Inset::Code lyxCode() const { return Inset::THEOREM_CODE; }
///
bool metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo &, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -118,7 +118,7 @@ int const arrow_size = 4;
}
bool InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const
{
int height = 3 * arrow_size;
if (space_.length().len().value() >= 0.0)
@ -138,9 +138,7 @@ bool InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const
dim.asc = height / 2 + (a - d) / 2; // align cursor with the
dim.des = height - dim.asc; // label text
dim.wid = ADD_TO_VSPACE_WIDTH + 2 * arrow_size + 5 + w;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -29,7 +29,9 @@ public:
///
~InsetVSpace();
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
Dimension const dimension(BufferView const &) const { return dim_; };
///
void draw(PainterInfo & pi, int x, int y) const;
///
@ -61,6 +63,8 @@ private:
///
VSpace space_;
///
mutable Dimension dim_;
};

View File

@ -36,9 +36,12 @@ public:
/// compute the size of the object returned in dim.
/// \retval true if the metrics has changed.
virtual bool metrics(MetricsInfo & mi, Dimension & dim) const = 0;
virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
/// draw inset and update (xo, yo)-cache
virtual void draw(PainterInfo & pi, int x, int y) const = 0;
///
Dimension const & dimension() const { return dim_; };
/// render state, exact meaning of state is render-specific
void setRenderState(int state) { state_ = state; }
/// get render state

View File

@ -40,7 +40,7 @@ void RenderButton::update(docstring const & text, bool editable)
}
bool RenderButton::metrics(MetricsInfo &, Dimension & dim) const
void RenderButton::metrics(MetricsInfo &, Dimension & dim) const
{
Font font(Font::ALL_SANE);
font.decSize();
@ -53,10 +53,7 @@ bool RenderButton::metrics(MetricsInfo &, Dimension & dim) const
fm.rectText(text_, dim.wid, dim.asc, dim.des);
dim.wid += 4;
if (dim_ == dim)
return false;
dim_ = dim;
return true;
}

View File

@ -28,7 +28,7 @@ public:
RenderBase * clone(Inset const *) const;
/// compute the size of the object returned in dim
virtual bool metrics(MetricsInfo & mi, Dimension & dim) const;
virtual void metrics(MetricsInfo & mi, Dimension & dim) const;
/// draw inset and update (xo, yo)-cache
virtual void draw(PainterInfo & pi, int x, int y) const;

View File

@ -139,7 +139,7 @@ bool readyToDisplay(graphics::Loader const & loader)
} // namespace anon
bool RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const
void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const
{
bool image_ready = displayGraphic(params_) && readyToDisplay(loader_);
@ -174,9 +174,7 @@ bool RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const
dim.wid = std::max(50, font_width + 15);
}
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -29,7 +29,7 @@ public:
RenderBase * clone(Inset const *) const;
/// compute the size of the object returned in dim
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
/// draw inset
void draw(PainterInfo & pi, int x, int y) const;

View File

@ -119,7 +119,7 @@ RenderPreview::getPreviewImage(Buffer const & buffer) const
}
bool RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const
void RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const
{
BOOST_ASSERT(mi.base.bv);
@ -141,9 +141,7 @@ bool RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const
dim.wid = 15 + theFontMetrics(font).width(stat);
}
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -53,7 +53,7 @@ public:
RenderBase * clone(Inset const *) const;
/// Compute the size of the object, returned in dim
bool metrics(MetricsInfo &, Dimension & dim) const;
void metrics(MetricsInfo &, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;

View File

@ -36,17 +36,14 @@ Inset * CommandInset::clone() const
}
bool CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const
void CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const
{
if (!set_label_) {
set_label_ = true;
button_.update(screenLabel(), true);
}
button_.metrics(mi, dim);
if (dim_ == dim)
return false;
dim_ = dim;
return true;
}

View File

@ -27,7 +27,7 @@ public:
///
explicit CommandInset(docstring const & name);
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -124,16 +124,14 @@ string InsetFormulaMacro::prefix() const
}
bool InsetFormulaMacro::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetFormulaMacro::metrics(MetricsInfo & mi, Dimension & dim) const
{
//lyxerr << "InsetFormulaMacro: " << this << " -- " << &tmpl() << endl;
tmpl()->metrics(mi, dim);
dim.asc += 5;
dim.des += 5;
dim.wid += 10 + theFontMetrics(mi.base.font).width(prefix());
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -35,7 +35,7 @@ public:
/// constructs a mocro from its LaTeX definition
explicit InsetFormulaMacro(docstring const & s);
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;

View File

@ -78,14 +78,12 @@ char const * InsetMathAMSArray::name_right() const
}
bool InsetMathAMSArray::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathAMSArray::metrics(MetricsInfo & mi, Dimension & dim) const
{
ArrayChanger dummy(mi.base);
InsetMathGrid::metrics(mi, dim);
dim.wid += 14;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -25,7 +25,7 @@ public:
///
InsetMathAMSArray(docstring const & name);
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pain, int x, int y) const;
///

View File

@ -78,14 +78,12 @@ Inset * InsetMathArray::clone() const
}
bool InsetMathArray::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathArray::metrics(MetricsInfo & mi, Dimension & dim) const
{
ArrayChanger dummy(mi.base);
InsetMathGrid::metrics(mi, dim);
dim.wid += 6;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -31,7 +31,7 @@ public:
/// convenience constructor from whitespace/newline separated data
InsetMathArray(docstring const &, docstring const & str);
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -60,17 +60,14 @@ double InsetMathBig::increase() const
}
bool InsetMathBig::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathBig::metrics(MetricsInfo & mi, Dimension & dim) const
{
double const h = theFontMetrics(mi.base.font).ascent('I');
double const f = increase();
dim.wid = 6;
dim.asc = int(h + f * h);
dim.des = int(f * h);
if (dim_ == dim)
return false;
dim_ = dim;
return true;
}

View File

@ -27,7 +27,9 @@ public:
///
docstring name() const;
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
Dimension const dimension(BufferView const &) const { return dim_; };
///
void draw(PainterInfo & pi, int x, int y) const;
///
@ -50,6 +52,8 @@ private:
docstring const name_;
/// ( or [ or \\Vert...
docstring const delim_;
///
mutable Dimension dim_;
};

View File

@ -40,7 +40,7 @@ int InsetMathBinom::dw() const
}
bool InsetMathBinom::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathBinom::metrics(MetricsInfo & mi, Dimension & dim) const
{
ScriptChanger dummy(mi.base);
cell(0).metrics(mi);
@ -49,9 +49,7 @@ bool InsetMathBinom::metrics(MetricsInfo & mi, Dimension & dim) const
dim.des = cell(1).height() + 4 - 5;
dim.wid = std::max(cell(0).width(), cell(1).width()) + 2 * dw() + 4;
metricsMarkers2(dim);
bool const changed = dim_ != dim;
dim_ = dim;
return changed;
}

View File

@ -28,7 +28,7 @@ public:
///
void normalize(NormalStream &) const;
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo &, int x, int y) const;
/// draw decorations.

View File

@ -30,16 +30,13 @@ Inset * InsetMathBoldSymbol::clone() const
}
bool InsetMathBoldSymbol::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathBoldSymbol::metrics(MetricsInfo & mi, Dimension & dim) const
{
//FontSetChanger dummy(mi.base, "mathbf");
cell(0).metrics(mi, dim);
metricsMarkers(dim);
++dim.wid; // for 'double stroke'
if (dim_ == dim)
return false;
dim_ = dim;
return true;
}

View File

@ -24,7 +24,7 @@ public:
///
InsetMathBoldSymbol();
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -44,15 +44,12 @@ void InsetMathBox::normalize(NormalStream & os) const
}
bool InsetMathBox::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathBox::metrics(MetricsInfo & mi, Dimension & dim) const
{
FontSetChanger dummy(mi.base, "textnormal");
cell(0).metrics(mi, dim);
metricsMarkers(dim);
if (dim_ == dim)
return false;
dim_ = dim;
return true;
}

View File

@ -31,7 +31,7 @@ public:
///
mode_type currentMode() const { return TEXT_MODE; }
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -33,14 +33,11 @@ Inset * InsetMathBoxed::clone() const
}
bool InsetMathBoxed::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathBoxed::metrics(MetricsInfo & mi, Dimension & dim) const
{
cell(0).metrics(mi, dim);
metricsMarkers2(dim, 3); // 1 pixel space, 1 frame, 1 space
if (dim_ == dim)
return false;
dim_ = dim;
return true;
}

View File

@ -26,7 +26,7 @@ public:
///
void validate(LaTeXFeatures & features) const;
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -41,7 +41,7 @@ Inset * InsetMathBrace::clone() const
}
bool InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const
{
cell(0).metrics(mi);
Dimension t = theFontMetrics(mi.base.font).dimension('{');
@ -49,10 +49,7 @@ bool InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const
dim.des = std::max(cell(0).descent(), t.des);
dim.wid = cell(0).width() + 2 * t.wid;
metricsMarkers(dim);
if (dim_ == dim)
return false;
dim_ = dim;
return true;
}

View File

@ -30,7 +30,7 @@ public:
/// we write extra braces in any case...
bool extraBraces() const { return true; }
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo &, int x, int y) const;
///

View File

@ -43,16 +43,11 @@ Inset * InsetMathCases::clone() const
}
bool InsetMathCases::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathCases::metrics(MetricsInfo & mi, Dimension & dim) const
{
dim = dim_;
InsetMathGrid::metrics(mi);
dim_.wid += 8;
if (dim_ == dim)
return false;
dim = dim_;
return true;
}

View File

@ -25,7 +25,7 @@ public:
///
explicit InsetMathCases(row_type rows = 1u);
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -56,7 +56,7 @@ Inset * InsetMathChar::clone() const
}
bool InsetMathChar::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathChar::metrics(MetricsInfo & mi, Dimension & dim) const
{
#if 1
if (char_ == '=' && has_math_fonts) {
@ -85,12 +85,6 @@ bool InsetMathChar::metrics(MetricsInfo & mi, Dimension & dim) const
dim.wid += 2 * theFontMetrics(font_).width(' ');
lyxerr << "InsetMathChar::metrics: " << dim << endl;
#endif
if (dim_ == dim)
return false;
dim_ = dim;
return true;
}

View File

@ -24,7 +24,7 @@ public:
///
explicit InsetMathChar(char_type c);
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -38,14 +38,11 @@ Inset * InsetMathColor::clone() const
}
bool InsetMathColor::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathColor::metrics(MetricsInfo & mi, Dimension & dim) const
{
cell(0).metrics(mi, dim);
metricsMarkers(dim);
if (dim_ == dim)
return false;
dim_ = dim;
return true;
}

View File

@ -29,7 +29,7 @@ public:
/// Create a color inset from LaTeX color name
explicit InsetMathColor(bool oldstyle, docstring const & color);
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
/// we write extra braces in any case...
/// FIXME Why? Are they necessary if oldstyle_ == false?
bool extraBraces() const { return true; }

View File

@ -38,14 +38,11 @@ Inset * InsetMathComment::clone() const
}
bool InsetMathComment::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathComment::metrics(MetricsInfo & mi, Dimension & dim) const
{
cell(0).metrics(mi, dim);
metricsMarkers(dim);
if (dim_ == dim)
return false;
dim_ = dim;
return true;
}

View File

@ -27,7 +27,7 @@ public:
///
explicit InsetMathComment(docstring const &);
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///

View File

@ -31,17 +31,14 @@ Inset * InsetMathDFrac::clone() const
}
bool InsetMathDFrac::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathDFrac::metrics(MetricsInfo & mi, Dimension & dim) const
{
cell(0).metrics(mi);
cell(1).metrics(mi);
dim.wid = std::max(cell(0).width(), cell(1).width()) + 2;
dim.asc = cell(0).height() + 2 + 5;
dim.des = cell(1).height() + 2 - 5;
if (dim_ == dim)
return false;
dim_ = dim;
return true;
}

View File

@ -24,7 +24,7 @@ public:
///
InsetMathDFrac();
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo &, int x, int y) const;
///

View File

@ -101,7 +101,7 @@ bool InsetMathDecoration::ams() const
}
bool InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const
{
cell(0).metrics(mi, dim);
@ -117,10 +117,7 @@ bool InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const
}
metricsMarkers(dim);
if (dim_ == dim)
return false;
dim_ = dim;
return true;
}

View File

@ -30,7 +30,7 @@ public:
///
void write(WriteStream & os) const;
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void normalize(NormalStream & os) const;
///

View File

@ -67,7 +67,7 @@ void InsetMathDelim::normalize(NormalStream & os) const
}
bool InsetMathDelim::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathDelim::metrics(MetricsInfo & mi, Dimension & dim) const
{
using std::max;
cell(0).metrics(mi);
@ -83,10 +83,7 @@ bool InsetMathDelim::metrics(MetricsInfo & mi, Dimension & dim) const
dim.wid = cell(0).width() + 2 * dw_ + 8;
dim.asc = max(a0, d0) + h0;
dim.des = max(a0, d0) - h0;
if (dim_ == dim)
return false;
dim_ = dim;
return true;
}

View File

@ -40,7 +40,7 @@ public:
///
mode_type currentMode() const { return MATH_MODE; }
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo &, int x, int y) const;

View File

@ -47,10 +47,9 @@ void InsetMathDiff::normalize(NormalStream & os) const
}
bool InsetMathDiff::metrics(MetricsInfo &, Dimension &) const
void InsetMathDiff::metrics(MetricsInfo &, Dimension &) const
{
lyxerr << "should not happen" << endl;
return true;
}

View File

@ -28,7 +28,7 @@ public:
///
void addDer(MathData const & der);
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;

View File

@ -32,7 +32,7 @@ Inset * InsetMathDots::clone() const
}
bool InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const
{
dim = theFontMetrics(mi.base.font).dimension('M');
dh_ = 0;
@ -47,10 +47,7 @@ bool InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const
}
else if (key_->name == "ddots")
dh_ = dim.asc;
if (dim_ == dim)
return false;
dim_ = dim;
return true;
dim = dim_;
}

View File

@ -25,7 +25,9 @@ public:
///
explicit InsetMathDots(latexkeys const * l);
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
Dimension const dimension(BufferView const &) const { return dim_; };
///
void draw(PainterInfo & pi, int x, int y) const;
///
@ -37,6 +39,8 @@ protected:
latexkeys const * key_;
private:
virtual Inset * clone() const;
///
mutable Dimension dim_;
};
} // namespace lyx

View File

@ -30,14 +30,11 @@ Inset * InsetMathEnv::clone() const
}
bool InsetMathEnv::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathEnv::metrics(MetricsInfo & mi, Dimension & dim) const
{
cell(0).metrics(mi, dim);
metricsMarkers(dim);
if (dim_ == dim)
return false;
dim_ = dim;
return true;
}

View File

@ -32,7 +32,7 @@ public:
/// write normalized content
void normalize(NormalStream & ns) const;
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void infoize(odocstream & os) const;

View File

@ -40,13 +40,10 @@ Inset * InsetMathExFunc::clone() const
}
bool InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & dim) const
{
mathed_string_dim(mi.base.font, name_, dim);
if (dim_ == dim)
return false;
dim_ = dim;
return true;
}

Some files were not shown because too many files have changed in this diff Show More