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"
26 // only for getType():
27 #include "math_defs.h"
34 class InsetFormulaBase : public UpdatableInset {
39 virtual int ascent(BufferView *, LyXFont const &) const = 0;
41 virtual int descent(BufferView *, LyXFont const &) const = 0;
43 virtual int width(BufferView *, LyXFont const &) const = 0;
45 virtual void draw(BufferView *,LyXFont const &, int, float &, bool) const = 0;
47 virtual MathInsetTypes getType() const = 0;
51 virtual void validate(LaTeXFeatures &) const;
53 virtual Inset * clone(Buffer const &, bool same_id = false) const = 0;
55 virtual Inset::Code lyxCode() const;
56 /// what appears in the minibuffer when opening
57 virtual string const editMessage() const;
59 virtual void edit(BufferView *, int x, int y, unsigned int button);
61 virtual void edit(BufferView *, bool front = true);
63 virtual void toggleInsetCursor(BufferView *);
65 virtual void showInsetCursor(BufferView *, bool show = true);
67 virtual void hideInsetCursor(BufferView *);
69 virtual void getCursorPos(BufferView *, int &, int &) const;
71 virtual void toggleInsetSelection(BufferView * bv);
73 virtual void insetButtonPress(BufferView *, int x, int y, int button);
75 virtual void insetButtonRelease(BufferView *, int x, int y, int button);
77 virtual void insetKeyPress(XKeyEvent * ev);
79 virtual void insetMotionNotify(BufferView *, int x, int y, int state);
81 virtual void insetUnlock(BufferView *);
83 /// To allow transparent use of math editing functions
84 virtual RESULT localDispatch(BufferView *, kb_action, string const &);
87 virtual std::vector<string> const getLabelList() const;
89 virtual MathAtom const & par() const = 0;
91 virtual MathAtom & par() = 0;
93 virtual void metrics(BufferView * bv = 0, LyXFont const & font = LyXFont()) const;
95 virtual void updateLocal(BufferView * bv, bool mark_dirty);
98 void operator=(const InsetFormulaBase &);
100 mutable BufferView * view_;
102 mutable LyXFont font_;
105 // We don't really mess want around with mathed stuff outside mathed.
108 void mathDispatchCreation(BufferView *, string const &, bool);
110 void mathDispatchMathDisplay(BufferView *, string const &);
112 void mathDispatchMathMode(BufferView *, string const &);
114 void mathDispatchMathMacro(BufferView *, string const &);
116 void mathDispatchMathDelim(BufferView *, string const &);
118 void mathDispatchInsertMath(BufferView *, string const &);
120 void mathDispatchInsertMatrix(BufferView *, string const &);
122 void mathDispatchGreek(BufferView *, string const &);
124 void mathDispatchMathImportSelection(BufferView *, string const &);