4 * Purpose: Declaration of formula inset
5 * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
6 * Created: January 1996
7 * Description: Allows the edition of math paragraphs inside Lyx.
9 * Copyright: (c) 1996, Alejandro Aguilar Sierra
11 * Version: 0.4, Lyx project.
13 * You are free to use and modify this code under the terms of
14 * the GNU General Public Licence version 2 or later.
17 #ifndef INSET_FORMULA_H
18 #define INSET_FORMULA_H
24 #include "insets/lyxinset.h"
25 #include "support/LOstream.h"
31 class InsetFormula: public UpdatableInset {
34 InsetFormula(bool display = false);
36 InsetFormula(MathParInset *);
40 int ascent(Painter &, LyXFont const &) const;
42 int descent(Painter &, LyXFont const &) const;
44 int width(Painter &, LyXFont const &) const;
46 void draw(Painter &, LyXFont const &, int baseline, float & x) const;
48 void Write(ostream &) const;
50 void Read(LyXLex & lex);
52 int Latex(ostream &, signed char fragile) const;
53 #ifndef USE_OSTREAM_ONLY
55 int Latex(string & file, signed char fragile) const;
58 int Linuxdoc(string & file) const;
60 int DocBook(string & file) const;
62 void Validate(LaTeXFeatures &) const;
64 Inset * Clone() const;
66 Inset::Code LyxCode() const { return Inset::MATH_CODE; }
68 LyXFont ConvertFont(LyXFont font) {
69 // We have already discussed what was here
70 font.setLatex(LyXFont::OFF);
74 /// what appears in the minibuffer when opening
75 const char * EditMessage() const {return _("Math editor mode");}
77 void Edit(BufferView *, int x, int y, unsigned int button);
79 bool display() const { return (disp_flag) ? true: false; }
83 void ToggleInsetCursor(BufferView *);
85 void ShowInsetCursor(BufferView *);
87 void HideInsetCursor(BufferView *);
89 void GetCursorPos(int &, int &) const;
91 void ToggleInsetSelection(BufferView * bv);
93 void InsetButtonPress(BufferView *, int x, int y, int button);
95 void InsetButtonRelease(BufferView *, int x, int y, int button);
97 void InsetKeyPress(XKeyEvent * ev);
99 void InsetMotionNotify(BufferView *, int x, int y, int state);
101 void InsetUnlock(BufferView *);
103 /// To allow transparent use of math editing functions
104 virtual RESULT LocalDispatch(BufferView *, int, string const &);
107 void InsertSymbol(BufferView *, char const *);
109 bool SetNumber(bool);
111 int GetNumberOfLabels() const;
113 string getLabel(int) const;
116 void UpdateLocal(BufferView * bv);
118 static MathedCursor * mathcursor;
126 // If a mathinset exist at cursor pos, just lock it.
127 // Otherwise create a new one, and lock it.
128 bool OpenMathInset(Buffer *);