InsetBase * MathHullInset::editXY(LCursor & cur, int x, int y)
{
- if (RenderPreview::status() == LyXRC::PREVIEW_ON) {
+ if (use_preview_) {
edit(cur, true);
return this;
}
char const * MathHullInset::standardFont() const
{
- if (type_ == "none")
- return "lyxnochange";
- return "mathnormal";
+ return type_ == "none" ? "lyxnochange" : "mathnormal";
}
-void MathHullInset::metrics(MetricsInfo & mi, Dimension & dim) const
+bool MathHullInset::previewState(BufferView * bv) const
{
- BOOST_ASSERT(mi.base.bv && mi.base.bv->buffer());
-
- bool use_preview = false;
- if (!editing(mi.base.bv) &&
- RenderPreview::status() == LyXRC::PREVIEW_ON) {
+ if (!editing(bv) && RenderPreview::status() == LyXRC::PREVIEW_ON) {
lyx::graphics::PreviewImage const * pimage =
- preview_->getPreviewImage(*mi.base.bv->buffer());
- use_preview = pimage && pimage->image();
+ preview_->getPreviewImage(*bv->buffer());
+ return pimage && pimage->image();
}
+ return false;
+}
- if (use_preview) {
+
+void MathHullInset::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+ if (previewState(mi.base.bv)) {
preview_->metrics(mi, dim);
// insert a one pixel gap in front of the formula
dim.wid += 1;
void MathHullInset::draw(PainterInfo & pi, int x, int y) const
{
- BOOST_ASSERT(pi.base.bv && pi.base.bv->buffer());
-
- bool use_preview = false;
- if (!editing(pi.base.bv) &&
- RenderPreview::status() == LyXRC::PREVIEW_ON) {
- lyx::graphics::PreviewImage const * pimage =
- preview_->getPreviewImage(*pi.base.bv->buffer());
- use_preview = pimage && pimage->image();
- }
+ use_preview_ = previewState(pi.base.bv);
- if (use_preview) {
+ if (use_preview_) {
// one pixel gap in front
preview_->draw(pi, x + 1, y);
setPosCache(pi, x, y);
std::vector<std::string> label_;
///
boost::scoped_ptr<RenderPreview> preview_;
+ ///
+ mutable bool use_preview_;
//
// Incorporate me
//
protected:
///
- void handleFont(LCursor &, std::string const & arg, std::string const & font);
+ void handleFont(LCursor & cur, std::string const & arg,
+ std::string const & font);
+ ///
+ void handleFont2(LCursor & cur, std::string const & arg);
///
- void handleFont2(LCursor &, std::string const & arg);
+ bool previewState(BufferView * bv) const;
};
#endif