2010-11-18 19:50:29 +00:00
|
|
|
// -*- 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"
|
|
|
|
|
2016-06-02 22:49:36 +00:00
|
|
|
#include "support/unique_ptr.h"
|
|
|
|
|
2010-11-18 19:50:29 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2020-11-22 22:23:39 +00:00
|
|
|
class Dimension;
|
2021-10-08 01:14:18 +00:00
|
|
|
class MacroNameSet;
|
2010-11-18 19:50:29 +00:00
|
|
|
class RenderPreview;
|
|
|
|
|
|
|
|
namespace graphics {
|
|
|
|
class PreviewLoader;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// An inset with an instant preview
|
|
|
|
class InsetPreview : public InsetText {
|
2016-05-23 14:44:29 +00:00
|
|
|
|
2010-11-18 19:50:29 +00:00
|
|
|
public:
|
|
|
|
///
|
2019-09-17 21:06:18 +00:00
|
|
|
explicit InsetPreview(Buffer *);
|
2010-11-18 19:50:29 +00:00
|
|
|
///
|
|
|
|
~InsetPreview();
|
|
|
|
///
|
|
|
|
InsetPreview(InsetPreview const & other);
|
2015-10-11 09:16:09 +00:00
|
|
|
///
|
|
|
|
InsetPreview & operator=(InsetPreview const & other);
|
2010-11-18 19:50:29 +00:00
|
|
|
|
|
|
|
/// \name Methods inherited from Inset class
|
|
|
|
//@{
|
2020-10-01 07:42:11 +00:00
|
|
|
Inset * clone() const override { return new InsetPreview(*this); }
|
2010-11-18 19:50:29 +00:00
|
|
|
|
2020-10-01 07:42:11 +00:00
|
|
|
bool neverIndent() const override { return true; }
|
2016-05-23 14:44:29 +00:00
|
|
|
|
2020-10-01 07:42:11 +00:00
|
|
|
InsetCode lyxCode() const override { return PREVIEW_CODE; }
|
2016-05-23 14:44:29 +00:00
|
|
|
|
2020-10-01 07:42:11 +00:00
|
|
|
docstring layoutName() const override { return from_ascii("Preview"); }
|
2016-05-23 14:44:29 +00:00
|
|
|
|
2020-10-01 07:42:11 +00:00
|
|
|
bool descendable(BufferView const & /*bv*/) const override { return true; }
|
2010-11-18 19:50:29 +00:00
|
|
|
|
2020-10-01 07:42:11 +00:00
|
|
|
std::string contextMenuName() const override
|
2011-10-29 14:48:55 +00:00
|
|
|
{ return "context-preview"; }
|
2010-11-18 19:50:29 +00:00
|
|
|
|
2020-10-01 07:42:11 +00:00
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const override;
|
2010-11-18 19:50:29 +00:00
|
|
|
|
2020-10-01 07:42:11 +00:00
|
|
|
Inset * editXY(Cursor & cur, int x, int y) override;
|
2010-11-18 19:50:29 +00:00
|
|
|
|
2020-10-01 07:42:11 +00:00
|
|
|
void draw(PainterInfo & pi, int x, int y) const override;
|
2010-11-18 19:50:29 +00:00
|
|
|
|
|
|
|
void addPreview(DocIterator const & inset_pos,
|
2020-10-01 07:42:11 +00:00
|
|
|
graphics::PreviewLoader & ploader) const override;
|
2010-11-18 19:50:29 +00:00
|
|
|
|
2020-10-01 07:42:11 +00:00
|
|
|
bool notifyCursorLeaves(Cursor const & old, Cursor & cur) override;
|
2010-11-18 19:50:29 +00:00
|
|
|
|
2020-10-01 07:42:11 +00:00
|
|
|
void write(std::ostream & os) const override;
|
2010-11-18 19:50:29 +00:00
|
|
|
|
2020-10-01 07:42:11 +00:00
|
|
|
void edit(Cursor & cur, bool front, EntryDirection entry_from) override;
|
2016-05-23 14:44:29 +00:00
|
|
|
|
2021-09-28 08:21:45 +00:00
|
|
|
bool canPaintChange(BufferView const &) const override { return true; }
|
2010-11-18 19:50:29 +00:00
|
|
|
//@}
|
2016-05-23 14:44:29 +00:00
|
|
|
|
2010-11-18 19:50:29 +00:00
|
|
|
protected:
|
|
|
|
/// Retrieves the preview state. Returns true if preview
|
Run codespell on src/insets
Command was
codespell -w -i 3 -S Makefile.in -L mathed,afe,tthe,ue,fro,uint,larg,alph,te,thes,alle,Claus,pres,pass-thru src/insets/
2020-06-25 21:46:16 +00:00
|
|
|
/// is enabled and the preview image is available.
|
2010-11-18 19:50:29 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
///
|
2016-06-02 22:49:36 +00:00
|
|
|
unique_ptr<RenderPreview> preview_;
|
2010-11-18 19:50:29 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-10-08 01:14:18 +00:00
|
|
|
/// gathers the list of macro definitions used in the given inset
|
|
|
|
MacroNameSet gatherMacroDefinitions(const Buffer* buffer, const Inset * inset);
|
2021-10-13 01:01:54 +00:00
|
|
|
/// returns the LaTeX snippet to compute the preview of the given inset
|
|
|
|
docstring insetToLaTeXSnippet(const Buffer* buffer, const Inset * inset);
|
2021-10-08 01:14:18 +00:00
|
|
|
|
|
|
|
|
2010-11-18 19:50:29 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|