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