6 * This file is part of LyX, the document processor.
7 * Licence details can be found in the file COPYING.
9 * \author Alejandro Aguilar Sierra
10 * \author André Pönitz
12 * Full author contact details are available in file CREDITS.
15 #ifndef INSET_FORMULA_H
16 #define INSET_FORMULA_H
19 #include "formulabase.h"
20 #include "math_atom.h"
22 #include <boost/scoped_ptr.hpp>
24 /// The main LyX math inset
25 class InsetFormula : public InsetFormulaBase {
28 InsetFormula(bool chemistry = false);
30 explicit InsetFormula(BufferView *);
32 explicit InsetFormula(const string & data);
34 InsetFormula(InsetFormula const &);
38 int ascent(BufferView *, LyXFont const &) const;
40 int descent(BufferView *, LyXFont const &) const;
42 int width(BufferView *, LyXFont const &) const;
44 void draw(BufferView *, LyXFont const &, int, float &) const;
47 void write(Buffer const *, std::ostream &) const;
49 void read(Buffer const *, LyXLex & lex);
51 int latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const;
53 int ascii(Buffer const *, std::ostream &, int linelen) const;
55 int linuxdoc(Buffer const *, std::ostream &) const;
57 int docbook(Buffer const *, std::ostream &, bool mixcont) const;
60 Inset * clone(Buffer const &, bool same_id = false) const;
62 void validate(LaTeXFeatures & features) const;
64 Inset::Code lyxCode() const;
66 bool insetAllowed(Inset::Code code) const;
68 std::vector<string> const getLabelList() const;
70 MathAtom const & par() const { return par_; }
72 MathAtom & par() { return par_; }
74 void generatePreview() const;
76 void addPreview(grfx::PreviewLoader &) const;
78 void mutate(string const & type);
81 /// available in AMS only?
87 /// Use the Pimpl idiom to hide the internals of the previewer.
89 friend class PreviewImpl;
90 /// The pointer never changes although *preview_'s contents may.
91 boost::scoped_ptr<PreviewImpl> const preview_;