]> git.lyx.org Git - lyx.git/blob - src/mathed/formula.h
b2406d0578b8c4f4bb554ec6240a602e3cf46736
[lyx.git] / src / mathed / formula.h
1 // -*- C++ -*-
2 /*
3  *  File:        formula.h
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. 
8  *
9  *  Copyright: 1996, Alejandro Aguilar Sierra
10  *
11  *  Version: 0.4, Lyx project.
12  *
13  *   You are free to use and modify this code under the terms of
14  *   the GNU General Public Licence version 2 or later.
15  */
16
17 #ifndef INSET_FORMULA_H 
18 #define INSET_FORMULA_H
19
20 #ifdef __GNUG__
21 #pragma interface
22 #endif
23
24 #include <iosfwd>
25
26 #include "insets/lyxinset.h"
27
28 class MathParInset;
29 class MathedCursor;
30 class Buffer;
31
32 ///
33 class InsetFormula: public UpdatableInset {
34 public:
35         ///
36         explicit
37         InsetFormula(bool display = false);
38         ///
39         explicit
40         InsetFormula(MathParInset *);
41         ///
42         ~InsetFormula();
43         ///
44         int ascent(BufferView *, LyXFont const &) const;
45         ///
46         int descent(BufferView *, LyXFont const &) const;
47         ///
48         int width(BufferView *, LyXFont const &) const;
49         ///
50         void draw(BufferView *,LyXFont const &, int, float &, bool) const;
51         ///
52         void Write(Buffer const *, std::ostream &) const;
53         ///
54         void Read(Buffer const *, LyXLex & lex);
55         ///
56         int Latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const;
57         ///
58         int Ascii(Buffer const *, std::ostream &) const;
59         ///
60         int Linuxdoc(Buffer const *, std::ostream &) const;
61         ///
62         int DocBook(Buffer const *, std::ostream &) const;
63         ///
64         void Validate(LaTeXFeatures &) const;
65         ///
66         Inset * Clone() const;
67         ///
68         Inset::Code LyxCode() const { return Inset::MATH_CODE; }
69         ///
70         LyXFont ConvertFont(LyXFont font) {
71                 // We have already discussed what was here
72                 font.setLatex(LyXFont::OFF);
73                 return font;
74         }
75
76         /// what appears in the minibuffer when opening
77         char const * EditMessage() const;
78         ///
79         void Edit(BufferView *, int x, int y, unsigned int button);
80         ///
81         bool display() const { return (disp_flag) ? true: false; }
82         ///
83         void display(bool);
84         ///
85         void ToggleInsetCursor(BufferView *);
86         ///
87         void ShowInsetCursor(BufferView *);
88         ///
89         void HideInsetCursor(BufferView *);
90         ///
91         void GetCursorPos(BufferView *, int &, int &) const;
92         ///
93         void ToggleInsetSelection(BufferView * bv);
94         ///
95         void InsetButtonPress(BufferView *, int x, int y, int button);
96         ///
97         void InsetButtonRelease(BufferView *, int x, int y, int button);
98         ///
99         void InsetKeyPress(XKeyEvent * ev);
100         ///
101         void InsetMotionNotify(BufferView *, int x, int y, int state);
102         ///
103         void InsetUnlock(BufferView *);
104    
105         ///  To allow transparent use of math editing functions
106         virtual RESULT LocalDispatch(BufferView *, int, string const &);
107     
108         ///
109         void InsertSymbol(BufferView *, char const *);
110         ///
111         bool SetNumber(bool);
112         ///
113         std::vector<string> getLabelList() const;
114    
115 protected:
116         void UpdateLocal(BufferView * bv);
117         MathParInset * par;
118         static MathedCursor * mathcursor;
119     
120 private:
121         bool disp_flag;
122         string label;
123 };
124
125
126 // If a mathinset exist at cursor pos, just lock it.
127 // Otherwise create a new one, and lock it.
128 bool OpenMathInset(Buffer *);
129
130 #endif