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;
48 /// upper y coordinate
49 virtual int upperY() const;
50 /// lower y coordinate
51 virtual int lowerY() const;
55 virtual void validate(LaTeXFeatures &) const;
57 virtual Inset * clone(Buffer const &, bool same_id = false) const = 0;
59 virtual Inset::Code lyxCode() const;
60 /// what appears in the minibuffer when opening
61 virtual string const editMessage() const;
63 virtual void edit(BufferView *, int x, int y, unsigned int button);
65 virtual void edit(BufferView *, bool front = true);
67 virtual void toggleInsetCursor(BufferView *);
69 virtual void showInsetCursor(BufferView *, bool show = true);
71 virtual void hideInsetCursor(BufferView *);
73 virtual void getCursorPos(BufferView *, int &, int &) const;
75 virtual void toggleInsetSelection(BufferView * bv);
77 virtual void insetButtonPress(BufferView *, int x, int y, int button);
79 virtual void insetButtonRelease(BufferView *, int x, int y, int button);
81 virtual void insetKeyPress(XKeyEvent * ev);
83 virtual void insetMotionNotify(BufferView *, int x, int y, int state);
85 virtual void insetUnlock(BufferView *);
87 /// To allow transparent use of math editing functions
88 virtual RESULT localDispatch(BufferView *, kb_action, string const &);
91 virtual std::vector<string> const getLabelList() const;
93 virtual MathAtom const & par() const = 0;
95 virtual MathAtom & par() = 0;
97 virtual void updateLocal(BufferView * bv, bool mark_dirty);
99 int xo() const { return xo_; }
101 int yo() const { return yo_; }
103 BufferView * view() const { return view_; }
107 void operator=(const InsetFormulaBase &);
110 mutable BufferView * view_;
112 mutable LyXFont font_;
116 void metrics(BufferView * bv, LyXFont const & font) const;
118 void metrics(BufferView * bv = 0) const;
126 // We don't really mess want around with mathed stuff outside mathed.
129 void mathDispatchCreation(BufferView *, string const &, bool);
131 void mathDispatchMathDisplay(BufferView *, string const &);
133 void mathDispatchMathMode(BufferView *, string const &);
135 void mathDispatchMathMacro(BufferView *, string const &);
137 void mathDispatchMathDelim(BufferView *, string const &);
139 void mathDispatchInsertMath(BufferView *, string const &);
141 void mathDispatchInsertMatrix(BufferView *, string const &);
143 void mathDispatchGreek(BufferView *, string const &);
145 void mathDispatchMathImportSelection(BufferView *, string const &);
147 void mathDispatch(BufferView *, kb_action, string const &);