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