X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetPreview.h;h=db2a2af96b1a1bd02b2e7ca5144137f6986113fc;hb=8124e6c02ea1fd6779bb6c47ffe2bca2c8bd2d97;hp=8a0332b1ec6012653bb5183d6b5daa733492c82d;hpb=6a1eb11563b1cb52d3e47af9ef8885c7ad7fcde2;p=lyx.git diff --git a/src/insets/InsetPreview.h b/src/insets/InsetPreview.h index 8a0332b1ec..db2a2af96b 100644 --- a/src/insets/InsetPreview.h +++ b/src/insets/InsetPreview.h @@ -1,92 +1,101 @@ -// -*- C++ -*- -/** - * \file InsetPreview.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Vincent van Ravesteijn - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef INSETPREVIEW_H -#define INSETPREVIEW_H - -#include "InsetText.h" - -#include "Dimension.h" -#include "RenderPreview.h" - -#include "graphics/PreviewLoader.h" - -#include - -namespace lyx { - -/// An inset with an instant preview -class InsetPreview : public InsetText { - -public: - /// - InsetPreview(Buffer *); - /// - ~InsetPreview(); - /// - InsetPreview(InsetPreview const & other); - - /// \name Methods inherited from Inset class - //@{ - Inset * clone() const { return new InsetPreview(*this); } - - 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; } - - docstring contextMenu(BufferView const &, int, int) const - { return from_ascii("context-preview"); } - - void metrics(MetricsInfo & mi, Dimension & dim) const; - - Inset * editXY(Cursor & cur, int x, int y); - - void draw(PainterInfo & pi, int x, int y) const; - - void addPreview(DocIterator const & inset_pos, - graphics::PreviewLoader & ploader) const; - - bool notifyCursorLeaves(Cursor const & old, Cursor & cur); - - void write(std::ostream & os) const; - - void edit(Cursor & cur, bool front, EntryDirection entry_from); - //@} - -protected: - /// Retrieves the preview state. Returns true if preview - /// is enabled and the preview image is availabled. - bool previewState(BufferView * bv) const; - /// Recreates the preview if preview is enabled. - void reloadPreview(DocIterator const & pos) const; - /// Prepare the preview if preview is enabled. - void preparePreview(DocIterator const & pos) const; - - /// - boost::scoped_ptr preview_; - /// - mutable bool use_preview_; - -private: - /// - mutable Dimension dim_; -}; - - -} // namespace lyx - - -#endif - +// -*- C++ -*- +/** + * \file InsetPreview.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Vincent van Ravesteijn + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef INSETPREVIEW_H +#define INSETPREVIEW_H + +#include "InsetText.h" + +#include "support/unique_ptr.h" + + +namespace lyx { + +class Dimension; +class MacroNameSet; +class RenderPreview; + +namespace graphics { + class PreviewLoader; +} + +/// An inset with an instant preview +class InsetPreview : public InsetText { + +public: + /// + explicit InsetPreview(Buffer *); + /// + ~InsetPreview(); + /// + InsetPreview(InsetPreview const & other); + /// + InsetPreview & operator=(InsetPreview const & other); + + /// \name Methods inherited from Inset class + //@{ + Inset * clone() const override { return new InsetPreview(*this); } + + bool neverIndent() const override { return true; } + + InsetCode lyxCode() const override { return PREVIEW_CODE; } + + docstring layoutName() const override { return from_ascii("Preview"); } + + bool descendable(BufferView const & /*bv*/) const override { return true; } + + std::string contextMenuName() const override + { return "context-preview"; } + + 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 override; + + bool notifyCursorLeaves(Cursor const & old, Cursor & cur) override; + + void write(std::ostream & os) const override; + + void edit(Cursor & cur, bool front, EntryDirection entry_from) override; + + bool canPaintChange(BufferView const &) const override { return true; } + //@} + +protected: + /// Retrieves the preview state. Returns true if preview + /// 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; + /// Prepare the preview if preview is enabled. + void preparePreview(DocIterator const & pos) const; + + /// + unique_ptr preview_; + +}; + + +/// 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 + + +#endif +