* src/insets/insetbase.h:
* src/insets/insetcollapsable.h:
- make isFixedWidth (former insetcollapsable member) a member of insetbase.
src/insets/insettext.h:
- make border_ public (needed by insetcollapsable).
src/insets/insettext.C (draw, drawSelection):
- adjust drawing for fixed width insets
* src/insets/insetcollapsable.C (metrics):
- adjust dimension for fixed width insets
src/insets/insetbox.C (metrics):
- properly calculate metrics for fixed width insets.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17879
a592a061-630c-0410-9148-
cb99ea01b6c8
/// if this inset has paragraphs should they be output all as default
/// paragraphs with the default layout of the text class?
virtual bool forceDefaultParagraphs(idx_type) const { return false; }
+ /// Is the width forced to some value?
+ virtual bool hasFixedWidth() const { return false; }
///
virtual docstring const & getInsetName() const;
#include "insetbox.h"
+#include "BufferView.h"
#include "cursor.h"
#include "dispatchresult.h"
#include "debug.h"
#include "lyxlex.h"
#include "metricsinfo.h"
#include "paragraph.h"
+#include "TextMetrics.h"
#include "support/translator.h"
bool InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
{
MetricsInfo mi = m;
+ // first round in order to know the minimum size.
+ InsetCollapsable::metrics(mi, dim);
+ TextMetrics & tm = mi.base.bv->textMetrics(&text_);
if (hasFixedWidth())
- mi.base.textwidth = params_.width.inPixels(m.base.textwidth);
+ mi.base.textwidth =
+ std::max(tm.width() + 2 * border_ + (int) (2.5 * TEXT_TO_INSET_OFFSET),
+ params_.width.inPixels(m.base.textwidth));
InsetCollapsable::metrics(mi, dim);
bool const changed = dim_ != dim;
dim_ = dim;
} 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);
}
}
}
InsetBase * editXY(LCursor & cur, int x, int y);
///
void setInlined() { status_ = Inlined; }
- /// Is the width forced to some value?
- virtual bool hasFixedWidth() const { return false; }
///
docstring floatName(std::string const & type, BufferParams const &) const;
int const w = tm.width() + 2 * border_;
int const a = tm.ascent() + border_;
int const h = a + tm.descent() + border_;
- pi.pain.rectangle(x, y - a, (wide() ? tm.maxWidth() : w), h,
- frameColor());
+ pi.pain.rectangle(x, y - a,
+ ((wide() || hasFixedWidth()) ? tm.maxWidth() : w),
+ h, frameColor());
}
}
int const w = tm.width() + 2 * border_;
int const a = tm.ascent() + border_;
int const h = a + tm.descent() + border_;
- pi.pain.fillRectangle(x, y - a, (wide() ? tm.maxWidth() : w), h,
- backgroundColor());
+ pi.pain.fillRectangle(x, y - a,
+ ((wide() || hasFixedWidth()) ? tm.maxWidth() : w),
+ h, backgroundColor());
text_.drawSelection(pi, x + border_, y);
}
///
mutable pit_type old_pit;
///
- static int border_;
- ///
bool wide_inset_;
public:
///
mutable LyXText text_;
///
mutable LyXFont font_;
+ ///
+ static int border_;
};
} // namespace lyx