#include "InsetText.h"
-#include "Dimension.h"
+#include "support/unique_ptr.h"
-#include <boost/scoped_ptr.hpp>
namespace lyx {
+class Dimension;
+class MacroNameSet;
class RenderPreview;
namespace graphics {
/// An inset with an instant preview
class InsetPreview : public InsetText {
-
+
public:
///
- InsetPreview(Buffer *);
+ explicit InsetPreview(Buffer *);
///
~InsetPreview();
///
InsetPreview(InsetPreview const & other);
+ ///
+ InsetPreview & operator=(InsetPreview const & other);
/// \name Methods inherited from Inset class
//@{
- Inset * clone() const { return new InsetPreview(*this); }
+ Inset * clone() const override { return new InsetPreview(*this); }
+
+ bool neverIndent() const override { return true; }
- bool neverIndent() const { return true; }
-
- InsetCode lyxCode() const { return PREVIEW_CODE; }
-
- docstring name() const { return from_ascii("Preview"); }
-
- bool descendable(BufferView const & /*bv*/) const { return true; }
+ InsetCode lyxCode() const override { return PREVIEW_CODE; }
- docstring contextMenuName() const
- { return from_ascii("context-preview"); }
+ docstring layoutName() const override { return from_ascii("Preview"); }
- void metrics(MetricsInfo & mi, Dimension & dim) const;
+ bool descendable(BufferView const & /*bv*/) const override { return true; }
- Inset * editXY(Cursor & cur, int x, int y);
+ std::string contextMenuName() const override
+ { return "context-preview"; }
- void draw(PainterInfo & pi, int x, int y) const;
+ void metrics(MetricsInfo & mi, Dimension & dim) const override;
+
+ Inset * editXY(Cursor & cur, int x, int y) override;
+
+ void draw(PainterInfo & pi, int x, int y) const override;
void addPreview(DocIterator const & inset_pos,
- graphics::PreviewLoader & ploader) const;
+ graphics::PreviewLoader & ploader) const override;
+
+ bool notifyCursorLeaves(Cursor const & old, Cursor & cur) override;
- bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
+ void write(std::ostream & os) const override;
- void write(std::ostream & os) const;
+ void edit(Cursor & cur, bool front, EntryDirection entry_from) override;
- void edit(Cursor & cur, bool front, EntryDirection entry_from);
+ bool canPaintChange(BufferView const &) const override { return true; }
//@}
-
+
protected:
/// Retrieves the preview state. Returns true if preview
- /// is enabled and the preview image is availabled.
+ /// is enabled and the preview image is available.
bool previewState(BufferView * bv) const;
/// Recreates the preview if preview is enabled.
void reloadPreview(DocIterator const & pos) const;
void preparePreview(DocIterator const & pos) const;
///
- boost::scoped_ptr<RenderPreview> preview_;
- ///
- mutable bool use_preview_;
+ unique_ptr<RenderPreview> preview_;
-private:
- ///
- mutable Dimension dim_;
};
+/// gathers the list of macro definitions used in the given inset
+MacroNameSet gatherMacroDefinitions(const Buffer* buffer, const Inset * inset);
+/// returns the LaTeX snippet to compute the preview of the given inset
+docstring insetToLaTeXSnippet(const Buffer* buffer, const Inset * inset);
+
+
} // namespace lyx