]> git.lyx.org Git - features.git/blob - src/mathed/formula.h
some using changes small changes in lyxfont and some other things, read the Changelog
[features.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 using std::ostream;
29
30 class MathParInset;
31 class MathedCursor;
32
33 ///
34 class InsetFormula: public UpdatableInset {
35 public:
36         ///
37         InsetFormula(bool display = false);
38         ///
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(ostream &) const;
52         ///
53         void Read(LyXLex & lex);
54         ///
55         int Latex(ostream &, signed char fragile, bool free_spc) const;
56         ///
57         int Linuxdoc(ostream &) const;
58         ///
59         int DocBook(ostream &) const;
60         ///
61         void Validate(LaTeXFeatures &) const;
62         ///
63         Inset * Clone() const;
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         const char * EditMessage() const {return _("Math editor mode");}
75         ///
76         void Edit(BufferView *, int x, int y, unsigned int button);
77         ///
78         bool display() const { return (disp_flag) ? true: false; }
79         ///
80         void display(bool);
81         ///
82         void ToggleInsetCursor(BufferView *);
83         ///
84         void ShowInsetCursor(BufferView *);
85         ///
86         void HideInsetCursor(BufferView *);
87         ///
88         void GetCursorPos(int &, int &) const;
89         ///
90         void ToggleInsetSelection(BufferView * bv);
91         ///
92         void InsetButtonPress(BufferView *, int x, int y, int button);
93         ///
94         void InsetButtonRelease(BufferView *, int x, int y, int button);
95         ///
96         void InsetKeyPress(XKeyEvent * ev);
97         ///
98         void InsetMotionNotify(BufferView *, int x, int y, int state);
99         ///
100         void InsetUnlock(BufferView *);
101    
102         ///  To allow transparent use of math editing functions
103         virtual RESULT LocalDispatch(BufferView *, int, string const &);
104     
105         ///
106         void InsertSymbol(BufferView *, char const *);
107         ///
108         bool SetNumber(bool);
109         ///
110         int GetNumberOfLabels() const;
111         ///
112         string getLabel(int) const;
113    
114 protected:
115         void UpdateLocal(BufferView * bv);
116         MathParInset * par;
117         static MathedCursor * mathcursor;
118     
119 private:
120         bool disp_flag;
121         string label;
122 };
123
124
125 // If a mathinset exist at cursor pos, just lock it.
126 // Otherwise create a new one, and lock it.
127 bool OpenMathInset(Buffer *);
128
129 #endif