]> git.lyx.org Git - lyx.git/blob - src/mathed/formula.h
merge from the string-switch branch and ready for a prelease.
[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: (c) 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 "definitions.h"
25 #include "insets/lyxinset.h"
26
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(LyXFont const &font) const;
42         ///
43         int Descent(LyXFont const &font) const;
44         ///
45         int Width(LyXFont const &font) const;
46         ///
47         void Draw(LyXFont font, LyXScreen &scr, int baseline, float &x);
48         ///
49         void Write(FILE *file);
50         ///
51         void Read(LyXLex &lex);
52         ///
53         int Latex(FILE *file, signed char fragile);
54         ///
55         int Latex(string &file, signed char fragile);
56         ///
57         int Linuxdoc(string &file);
58         ///
59         int DocBook(string &file);
60         ///
61         void Validate(LaTeXFeatures &) const;
62         ///
63         Inset* Clone();
64         ///
65         Inset::Code LyxCode() const { return Inset::MATH_CODE; }
66         ///
67         LyXFont ConvertFont(LyXFont font) {
68                 // We have already discussed what was here
69                 font.setLatex(LyXFont::OFF);
70                 return font;
71         }
72
73         /// what appears in the minibuffer when opening
74         char const* EditMessage() {return _("Math editor mode");}
75         ///
76         void Edit(int x, int y);
77         ///
78         bool Display() const { return (disp_flag) ? true: false; }
79         ///
80         void SetDisplay(bool);
81         ///
82         void ToggleInsetCursor();
83         ///
84         void ShowInsetCursor();
85         ///
86         void HideInsetCursor();
87         ///
88         void GetCursorPos(int&, int&);
89         ///
90         void ToggleInsetSelection();
91         ///
92         void InsetButtonPress(int x, int y, int button);
93         ///
94         void InsetButtonRelease(int x, int y, int button);
95         ///
96         void InsetKeyPress(XKeyEvent *ev);
97         ///
98         void InsetMotionNotify(int x, int y, int state);
99         ///
100         void InsetUnlock();
101    
102         ///  To allow transparent use of math editing functions
103         virtual bool LocalDispatch(int, char const*);
104     
105         ///
106         void InsertSymbol(char const*);
107         ///
108         bool SetNumber(bool);
109         ///
110         int GetNumberOfLabels() const;
111         ///
112         string getLabel(int) const;
113    
114 protected:
115         void UpdateLocal();
116         MathParInset* par;
117         static MathedCursor* mathcursor;
118     
119 private:
120         bool disp_flag;
121         //char *label;
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
131