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