]> git.lyx.org Git - lyx.git/blob - src/mathed/formula.h
b891c0d297455b12537015ce3ff68682fd6a3d08
[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
31 ///
32 class InsetFormula: public UpdatableInset {
33 public:
34         ///
35         InsetFormula(bool display = false);
36         ///
37         InsetFormula(MathParInset *);
38         ///
39         ~InsetFormula();
40         ///
41         int ascent(Painter &, LyXFont const &) const;
42         ///
43         int descent(Painter &, LyXFont const &) const;
44         ///
45         int width(Painter &, LyXFont const &) const;
46         ///
47         void draw(Painter &, LyXFont const &, int baseline, float & x) const;
48         ///
49         void Write(std::ostream &) const;
50         ///
51         void Read(LyXLex & lex);
52         ///
53         int Latex(std::ostream &, signed char fragile, bool free_spc) const;
54         ///
55         int Linuxdoc(std::ostream &) const;
56         ///
57         int DocBook(std::ostream &) const;
58         ///
59         void Validate(LaTeXFeatures &) const;
60         ///
61         Inset * Clone() const;
62         ///
63         Inset::Code LyxCode() const { return Inset::MATH_CODE; }
64         ///
65         LyXFont ConvertFont(LyXFont font) {
66                 // We have already discussed what was here
67                 font.setLatex(LyXFont::OFF);
68                 return font;
69         }
70
71         /// what appears in the minibuffer when opening
72         char const * EditMessage() const;
73         ///
74         void Edit(BufferView *, int x, int y, unsigned int button);
75         ///
76         bool display() const { return (disp_flag) ? true: false; }
77         ///
78         void display(bool);
79         ///
80         void ToggleInsetCursor(BufferView *);
81         ///
82         void ShowInsetCursor(BufferView *);
83         ///
84         void HideInsetCursor(BufferView *);
85         ///
86         void GetCursorPos(int &, int &) const;
87         ///
88         void ToggleInsetSelection(BufferView * bv);
89         ///
90         void InsetButtonPress(BufferView *, int x, int y, int button);
91         ///
92         void InsetButtonRelease(BufferView *, int x, int y, int button);
93         ///
94         void InsetKeyPress(XKeyEvent * ev);
95         ///
96         void InsetMotionNotify(BufferView *, int x, int y, int state);
97         ///
98         void InsetUnlock(BufferView *);
99    
100         ///  To allow transparent use of math editing functions
101         virtual RESULT LocalDispatch(BufferView *, int, string const &);
102     
103         ///
104         void InsertSymbol(BufferView *, char const *);
105         ///
106         bool SetNumber(bool);
107         ///
108         int GetNumberOfLabels() const;
109         ///
110         string getLabel(int) const;
111    
112 protected:
113         void UpdateLocal(BufferView * bv);
114         MathParInset * par;
115         static MathedCursor * mathcursor;
116     
117 private:
118         bool disp_flag;
119         string label;
120 };
121
122
123 // If a mathinset exist at cursor pos, just lock it.
124 // Otherwise create a new one, and lock it.
125 bool OpenMathInset(Buffer *);
126
127 #endif