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 "insets/inset.h"
25 // only for getType():
26 #include "math_defs.h"
33 class InsetFormulaBase : public UpdatableInset {
38 virtual int ascent(BufferView *, LyXFont const &) const = 0;
40 virtual int descent(BufferView *, LyXFont const &) const = 0;
42 virtual int width(BufferView *, LyXFont const &) const = 0;
44 virtual void draw(BufferView *,LyXFont const &, int, float &, bool) const = 0;
46 /// These are just wrappers taking the unused Buffer * dummy parameter
48 virtual void write(Buffer const *, std::ostream &) const;
50 virtual void read(Buffer const *, LyXLex & lex);
52 virtual int latex(Buffer const *, std::ostream &,
53 bool fragile, bool free_spc) const;
55 virtual int ascii(Buffer const *, std::ostream &, int linelen) const;
57 virtual int linuxdoc(Buffer const *, std::ostream &) const;
59 virtual int docbook(Buffer const *, std::ostream &) const;
61 virtual MathInsetTypes getType() const = 0;
64 /// the actual functions don't use the Buffer * parameter
66 virtual void write(std::ostream &) const = 0;
68 virtual void read(LyXLex & lex) = 0;
70 virtual int latex(std::ostream &, bool fragile, bool free_spc) const = 0;
72 virtual int ascii(std::ostream &, int linelen) const = 0;
74 virtual int linuxdoc(std::ostream &) const = 0;
76 virtual int docbook(std::ostream &) const = 0;
80 virtual void validate(LaTeXFeatures &) const;
82 virtual Inset * clone(Buffer const &, bool same_id = false) const = 0;
84 virtual Inset::Code lyxCode() const;
85 /// what appears in the minibuffer when opening
86 virtual string const editMessage() const;
88 virtual void edit(BufferView *, int x, int y, unsigned int button);
90 virtual void edit(BufferView *, bool front = true);
92 virtual void toggleInsetCursor(BufferView *);
94 virtual void showInsetCursor(BufferView *, bool show = true);
96 virtual void hideInsetCursor(BufferView *);
98 virtual void getCursorPos(BufferView *, int &, int &) const;
100 virtual void toggleInsetSelection(BufferView * bv);
102 virtual void insetButtonPress(BufferView *, int x, int y, int button);
104 virtual void insetButtonRelease(BufferView *, int x, int y, int button);
106 virtual void insetKeyPress(XKeyEvent * ev);
108 virtual void insetMotionNotify(BufferView *, int x, int y, int state);
110 virtual void insetUnlock(BufferView *);
112 /// To allow transparent use of math editing functions
113 virtual RESULT localDispatch(BufferView *, kb_action, string const &);
116 virtual std::vector<string> const getLabelList() const;
118 virtual MathInset const * par() const = 0;
120 virtual void metrics() const = 0;
123 virtual void updateLocal(BufferView * bv, bool mark_dirty);
126 void operator=(const InsetFormulaBase &);
129 // We don't really mess want around with mathed stuff outside mathed.
132 void mathDispatchCreation(BufferView *, string const &, bool);
134 void mathDispatchMathDisplay(BufferView *, string const &);
136 void mathDispatchMathMode(BufferView *, string const &);
138 void mathDispatchMathMacro(BufferView *, string const &);
140 void mathDispatchMathDelim(BufferView *, string const &);
142 void mathDispatchInsertMath(BufferView *, string const &);
144 void mathDispatchInsertMatrix(BufferView *, string const &);
146 void mathDispatchGreek(BufferView *, string const &);
148 void mathDispatchMathImportSelection(BufferView *, string const &);