4 * Purpose: Common parts of the math LyX insets
7 * Description: Allows the edition of math paragraphs inside Lyx.
9 * Copyright: 2001, The LyX Project
11 * You are free to use and modify this code under the terms of
12 * the GNU General Public Licence version 2 or later.
15 #ifndef INSET_FORMULABASE_H
16 #define INSET_FORMULABASE_H
23 #include <boost/smart_ptr.hpp>
25 #include "insets/inset.h"
32 class InsetFormulaBase : public UpdatableInset {
35 InsetFormulaBase(InsetFormulaBase const & p);
37 explicit InsetFormulaBase(MathInset *);
39 virtual ~InsetFormulaBase();
41 virtual int ascent(BufferView *, LyXFont const &) const = 0;
43 virtual int descent(BufferView *, LyXFont const &) const = 0;
45 virtual int width(BufferView *, LyXFont const &) const = 0;
47 virtual void draw(BufferView *,LyXFont const &, int, float &, bool) const = 0;
49 /// These are just wrappers taking the unused Buffer * dummy parameter
51 virtual void write(Buffer const *, std::ostream &) const;
53 virtual void read(Buffer const *, LyXLex & lex);
55 virtual int latex(Buffer const *, std::ostream &,
56 bool fragile, bool free_spc) const;
58 virtual int ascii(Buffer const *, std::ostream &, int linelen) const;
60 virtual int linuxdoc(Buffer const *, std::ostream &) const;
62 virtual int docBook(Buffer const *, std::ostream &) const;
65 /// the actual functions don't use the Buffer * parameter
67 virtual void write(std::ostream &) const = 0;
69 virtual void read(LyXLex & lex) = 0;
71 virtual int latex(std::ostream &, bool fragile, bool free_spc) const = 0;
73 virtual int ascii(std::ostream &, int linelen) const = 0;
75 virtual int linuxdoc(std::ostream &) const = 0;
77 virtual int docBook(std::ostream &) const = 0;
81 virtual void validate(LaTeXFeatures &) const;
83 virtual Inset * clone(Buffer const &, bool same_id = false) const = 0;
85 virtual Inset::Code lyxCode() const;
87 virtual LyXFont const convertFont(LyXFont const & f) const;
88 /// what appears in the minibuffer when opening
89 virtual string const editMessage() const;
91 virtual void edit(BufferView *, int x, int y, unsigned int button);
93 virtual void toggleInsetCursor(BufferView *);
95 virtual void showInsetCursor(BufferView *, bool show = true);
97 virtual void hideInsetCursor(BufferView *);
99 virtual void getCursorPos(BufferView *, int &, int &) const;
101 virtual void toggleInsetSelection(BufferView * bv);
103 virtual void insetButtonPress(BufferView *, int x, int y, int button);
105 virtual void insetButtonRelease(BufferView *, int x, int y, int button);
107 virtual void insetKeyPress(XKeyEvent * ev);
109 virtual void insetMotionNotify(BufferView *, int x, int y, int state);
111 virtual void insetUnlock(BufferView *);
113 /// To allow transparent use of math editing functions
114 virtual RESULT localDispatch(BufferView *, kb_action, string const &);
117 virtual std::vector<string> const getLabelList() const;
119 MathInset * par() const;
122 virtual void updateLocal(BufferView * bv);
128 // We don't really mess want around with mathed stuff outside mathed.
131 void mathDispatchCreation(BufferView *, string const &, bool);
133 void mathDispatchMathDisplay(BufferView *, string const &);
135 void mathDispatchMathMode(BufferView *, string const &);
137 void mathDispatchMathMacro(BufferView *, string const &);
139 void mathDispatchMathDelim(BufferView *, string const &);
141 void mathDispatchInsertMath(BufferView *, string const &);
143 void mathDispatchInsertMatrix(BufferView *, string const &);
145 void mathDispatchMathImportSelection(BufferView *, string const &);