X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetPreview.h;h=f0808d7246733fdc54352eb7b25ce6f51d3af46e;hb=e5c79a43ee78192f45a9ab34873f8bb426b5f37e;hp=b221d50b6031293247a944a11f43c19aa9a88d6f;hpb=f90f3d146b860ceafb36209cad79e3ad6938f80b;p=lyx.git diff --git a/src/insets/InsetPreview.h b/src/insets/InsetPreview.h index b221d50b60..f0808d7246 100644 --- a/src/insets/InsetPreview.h +++ b/src/insets/InsetPreview.h @@ -1,95 +1,97 @@ -// -*- 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 - -namespace lyx { - -class RenderPreview; - -namespace graphics { - class PreviewLoader; -} - -/// 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 "Dimension.h" + +#include "support/unique_ptr.h" + + +namespace lyx { + +class RenderPreview; + +namespace graphics { + class PreviewLoader; +} + +/// An inset with an instant preview +class InsetPreview : public InsetText { + +public: + /// + 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); } + + bool neverIndent() const { return true; } + + bool inheritFont() const { return false; } + + InsetCode lyxCode() const { return PREVIEW_CODE; } + + docstring layoutName() const { return from_ascii("Preview"); } + + bool descendable(BufferView const & /*bv*/) const { return true; } + + std::string contextMenuName() const + { return "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); + + bool canPaintChange(BufferView const &) const { return true; }; + //@} + +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; + + /// + unique_ptr preview_; + +}; + + +} // namespace lyx + + +#endif +