fix two metrics bug + remove an extra metrics call

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19954 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Alfredo Braunstein 2007-08-31 17:32:27 +00:00
parent cc6fe67c35
commit d44c6722f0
3 changed files with 6 additions and 7 deletions

View File

@ -128,24 +128,22 @@ void InsetCaption::addToToc(TocList & toclist, Buffer const & buf, ParConstItera
bool InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const
{
int const width_offset = TEXT_TO_INSET_OFFSET / 2;
mi.base.textwidth -= width_offset;
labelwidth_ = theFontMetrics(mi.base.font).width(full_label_);
// add some space to separate the label from the inset text
labelwidth_ += 2 * TEXT_TO_INSET_OFFSET;
dim.wid = labelwidth_;
Dimension textdim;
InsetText::metrics(mi, textdim);
// Correct for button width, and re-fit
dim.wid += width_offset;
// Correct for button and label width
mi.base.textwidth -= dim.wid;
InsetText::metrics(mi, textdim);
mi.base.textwidth += dim.wid;
dim.des = std::max(dim.des - textdim.asc + dim.asc, textdim.des);
dim.asc = textdim.asc;
dim.wid += textdim.wid;
dim.asc += TEXT_TO_INSET_OFFSET;
dim.des += TEXT_TO_INSET_OFFSET;
dim.wid += width_offset;
mi.base.textwidth += width_offset;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;

View File

@ -219,6 +219,7 @@ bool InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
// Correct for button width, and re-fit
mi.base.textwidth -= dim.wid;
InsetText::metrics(mi, textdim_);
mi.base.textwidth += dim.wid;
dim.wid += textdim_.wid;
dim.des = max(dim.des - textdim_.asc + dim.asc, textdim_.des);
dim.asc = textdim_.asc;

View File

@ -170,15 +170,15 @@ bool InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
TextMetrics & tm = mi.base.bv->textMetrics(&text_);
//lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << endl;
mi.base.textwidth -= 2 * border_;
font_ = mi.base.font;
// Hand font through to contained lyxtext:
text_.font_ = mi.base.font;
mi.base.textwidth -= 2 * border_;
tm.metrics(mi, dim);
mi.base.textwidth += 2 * border_;
dim.asc += border_;
dim.des += border_;
dim.wid += 2 * border_;
mi.base.textwidth += 2 * border_;
bool const changed = dim_ != dim;
dim_ = dim;
return changed;