]> git.lyx.org Git - lyx.git/blob - src/mathed/formula.h
fix #1073
[lyx.git] / src / mathed / formula.h
1 // -*- C++ -*-
2
3 /**
4  *  \file formula.h
5  *
6  *  This file is part of LyX, the document processor.
7  *  Licence details can be found in the file COPYING.
8  *
9  *  \author Alejandro Aguilar Sierra
10  *  \author André Pönitz
11  *
12  *  Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef INSET_FORMULA_H
16 #define INSET_FORMULA_H
17
18
19 #include "formulabase.h"
20 #include "math_atom.h"
21
22 #include <boost/scoped_ptr.hpp>
23
24 /// The main LyX math inset
25 class InsetFormula : public InsetFormulaBase {
26 public:
27         ///
28         InsetFormula();
29         ///
30         explicit InsetFormula(BufferView *);
31         ///
32         explicit InsetFormula(const string & data);
33         ///
34         InsetFormula(InsetFormula const &);
35         ///
36         ~InsetFormula();
37         ///
38         int ascent(BufferView *, LyXFont const &) const;
39         ///
40         int descent(BufferView *, LyXFont const &) const;
41         ///
42         int width(BufferView *, LyXFont const &) const;
43         ///
44         void draw(BufferView *, LyXFont const &, int, float &) const;
45
46         ///
47         void write(Buffer const *, std::ostream &) const;
48         ///
49         void read(Buffer const *, LyXLex & lex);
50         ///
51         int latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const;
52         ///
53         int ascii(Buffer const *, std::ostream &, int linelen) const;
54         ///
55         int linuxdoc(Buffer const *, std::ostream &) const;
56         ///
57         int docbook(Buffer const *, std::ostream &, bool mixcont) const;
58
59         ///
60         Inset * clone(Buffer const &, bool same_id = false) const;
61         ///
62         void validate(LaTeXFeatures & features) const;
63         ///
64         Inset::Code lyxCode() const;
65         ///
66         bool insetAllowed(Inset::Code code) const;
67         ///
68         std::vector<string> const getLabelList() const;
69         ///
70         MathAtom const & par() const { return par_; }
71         ///
72         MathAtom & par() { return par_; }
73         ///
74         void generatePreview() const;
75         ///
76         void addPreview(grfx::PreviewLoader &) const;
77         ///
78         //void mutate(string const & type);
79
80 private:
81         /// available in AMS only?
82         bool ams() const;
83
84         /// contents
85         MathAtom par_;
86
87         /// Use the Pimpl idiom to hide the internals of the previewer.
88         class PreviewImpl;
89         friend class PreviewImpl;
90         /// The pointer never changes although *preview_'s contents may.
91         boost::scoped_ptr<PreviewImpl> const preview_;
92 };
93 #endif