mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-23 16:52:02 +00:00
Fix InsetBox drawing and remove remnant of the wide() hack.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20334 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a81782869e
commit
516ff470d8
@ -182,7 +182,7 @@ int TextMetrics::parPosition(pit_type pit) const
|
||||
}
|
||||
|
||||
|
||||
bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim)
|
||||
bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim, int min_width)
|
||||
{
|
||||
BOOST_ASSERT(mi.base.textwidth);
|
||||
max_width_ = mi.base.textwidth;
|
||||
@ -190,6 +190,7 @@ bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim)
|
||||
Dimension const old_dim = dim_;
|
||||
// reset dimension.
|
||||
dim_ = Dimension();
|
||||
dim_.wid = min_width;
|
||||
pit_type const npar = text_->paragraphs().size();
|
||||
if (npar > 1)
|
||||
// If there is more than one row, expand the text to
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
|
||||
|
||||
/// compute text metrics.
|
||||
bool metrics(MetricsInfo & mi, Dimension & dim);
|
||||
bool metrics(MetricsInfo & mi, Dimension & dim, int min_width = 0);
|
||||
|
||||
///
|
||||
void newParMetricsDown();
|
||||
|
@ -174,13 +174,13 @@ bool InsetBox::hasFixedWidth() const
|
||||
|
||||
bool InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
|
||||
{
|
||||
MetricsInfo mi = m;
|
||||
// first round in order to know the minimum size.
|
||||
InsetCollapsable::metrics(mi, dim);
|
||||
// back up textwidth.
|
||||
int textwidth_backup = m.base.textwidth;
|
||||
if (hasFixedWidth())
|
||||
mi.base.textwidth = std::max(dim.width(),
|
||||
params_.width.inPixels(m.base.textwidth));
|
||||
InsetCollapsable::metrics(mi, dim);
|
||||
m.base.textwidth = params_.width.inPixels(m.base.textwidth);
|
||||
InsetCollapsable::metrics(m, dim);
|
||||
// retore textwidth.
|
||||
m.base.textwidth = textwidth_backup;
|
||||
bool const changed = dim_ != dim;
|
||||
dim_ = dim;
|
||||
return changed;
|
||||
|
@ -216,8 +216,6 @@ bool InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
} else {
|
||||
dim.des += textdim.height() + TEXT_TO_BOTTOM_OFFSET;
|
||||
dim.wid = max(dim.wid, textdim.wid);
|
||||
if (hasFixedWidth())
|
||||
dim.wid = max(dim.wid, mi.base.textwidth);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -175,7 +175,10 @@ bool InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
// Hand font through to contained lyxtext:
|
||||
tm.font_ = mi.base.font;
|
||||
mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
|
||||
tm.metrics(mi, dim);
|
||||
if (hasFixedWidth())
|
||||
tm.metrics(mi, dim, mi.base.textwidth);
|
||||
else
|
||||
tm.metrics(mi, dim);
|
||||
mi.base.textwidth += 2 * TEXT_TO_INSET_OFFSET;
|
||||
dim.asc += TEXT_TO_INSET_OFFSET;
|
||||
dim.des += TEXT_TO_INSET_OFFSET;
|
||||
@ -191,8 +194,7 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
|
||||
TextMetrics & tm = pi.base.bv->textMetrics(&text_);
|
||||
|
||||
if (drawFrame_ || pi.full_repaint) {
|
||||
int const w = hasFixedWidth() ?
|
||||
tm.maxWidth() : tm.width() + 2 * TEXT_TO_INSET_OFFSET;
|
||||
int const w = tm.width() + 2 * TEXT_TO_INSET_OFFSET;
|
||||
int const yframe = y - TEXT_TO_INSET_OFFSET - tm.ascent();
|
||||
int const h = tm.height() + 2 * TEXT_TO_INSET_OFFSET;
|
||||
if (pi.full_repaint)
|
||||
|
Loading…
x
Reference in New Issue
Block a user