//}
+namespace {
+
+bool editing_inset(InsetFormula const & inset)
+{
+ return (mathcursor &&
+ mathcursor->formula() == const_cast<InsetFormula *>(&inset));
+}
+
+} // namespace anon
+
+
void InsetFormula::draw(PainterInfo & pi, int x, int y) const
{
cache(pi.base.bv);
// The previews are drawn only when we're not editing the inset.
- bool const editing_inset = mathcursor && mathcursor->formula() == this;
- bool const use_preview = !editing_inset && preview_->previewReady();
+ bool const use_preview = (!editing_inset(*this) &&
+ preview_->previewReady());
int const w = dim_.wid;
int const d = dim_.des;
!= lcolor.getX11Name(LColor::background))
p.pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
- if (editing_inset) {
+ if (editing_inset(*this)) {
mathcursor->drawSelection(pi);
//p.pain.rectangle(x, y - a, w, h, LColor::mathframe);
}
void InsetFormula::metrics(MetricsInfo & m, Dimension & dim) const
{
- bool const editing_inset = mathcursor && mathcursor->formula() == this;
- bool const use_preview = !editing_inset && preview_->previewReady();
+ bool const use_preview = (!editing_inset(*this) &&
+ preview_->previewReady());
if (use_preview) {
preview_->metrics(m, dim);
namespace {
-bool preview_wanted(InsetFormula const & inset, Buffer const &)
-{
- // Don't want a preview when we're editing the inset
- return !(mathcursor && mathcursor->formula() == &inset);
-}
-
-
string const latex_string(InsetFormula const & inset, Buffer const &)
{
ostringstream ls;
void InsetFormula::addPreview(lyx::graphics::PreviewLoader & ploader) const
{
- if (preview_wanted(*this, ploader.buffer())) {
- string const snippet = latex_string(*this, ploader.buffer());
- preview_->addPreview(snippet, ploader);
- }
+ string const snippet = latex_string(*this, ploader.buffer());
+ preview_->addPreview(snippet, ploader);
}
void InsetFormula::generatePreview(Buffer const & buffer) const
{
- if (preview_wanted(*this, buffer)) {
- string const snippet = latex_string(*this, buffer);
- preview_->generatePreview(snippet, buffer);
- }
+ string const snippet = latex_string(*this, buffer);
+ preview_->generatePreview(snippet, buffer);
}