]> git.lyx.org Git - lyx.git/blob - src/mathed/formula.h
Applied Angus patch to compile on DEC C++ and to avoid name clashes
[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 class Buffer;
31
32 ///
33 class InsetFormula: public UpdatableInset {
34 public:
35         ///
36         explicit
37         InsetFormula(bool display = false);
38         ///
39         explicit
40         InsetFormula(MathParInset *);
41         ///
42         ~InsetFormula();
43         ///
44         int ascent(BufferView *, LyXFont const &) const;
45         ///
46         int descent(BufferView *, LyXFont const &) const;
47         ///
48         int width(BufferView *, LyXFont const &) const;
49         ///
50         void draw(BufferView *,LyXFont const &, int, float &, bool) const;
51         ///
52         void Write(Buffer const *, std::ostream &) const;
53         ///
54         void Read(Buffer const *, LyXLex & lex);
55         ///
56         int Latex(Buffer const *, std::ostream &,
57                   bool fragile, bool free_spc) const;
58         ///
59         int Ascii(Buffer const *, std::ostream &, int linelen) const;
60         ///
61         int Linuxdoc(Buffer const *, std::ostream &) const;
62         ///
63         int DocBook(Buffer const *, std::ostream &) const;
64         ///
65         void Validate(LaTeXFeatures &) const;
66         ///
67         Inset * Clone(Buffer const &) const;
68         ///
69         Inset::Code LyxCode() const;
70         ///
71         LyXFont const ConvertFont(LyXFont const & f) const;
72         /// what appears in the minibuffer when opening
73         string const EditMessage() const;
74         ///
75         void Edit(BufferView *, int x, int y, unsigned int button);
76         ///
77         bool display() const;
78         ///
79         void display(bool);
80         ///
81         void ToggleInsetCursor(BufferView *);
82         ///
83         void ShowInsetCursor(BufferView *, bool show = true);
84         ///
85         void HideInsetCursor(BufferView *);
86         ///
87         void GetCursorPos(BufferView *, int &, int &) const;
88         ///
89         void ToggleInsetSelection(BufferView * bv);
90         ///
91         void InsetButtonPress(BufferView *, int x, int y, int button);
92         ///
93         void InsetButtonRelease(BufferView *, int x, int y, int button);
94         ///
95         void InsetKeyPress(XKeyEvent * ev);
96         ///
97         void InsetMotionNotify(BufferView *, int x, int y, int state);
98         ///
99         void InsetUnlock(BufferView *);
100    
101         ///  To allow transparent use of math editing functions
102         virtual RESULT LocalDispatch(BufferView *, kb_action, string const &);
103     
104         ///
105         void InsertSymbol(BufferView *, string const &);
106         ///
107         bool SetNumber(bool);
108         ///
109         std::vector<string> const getLabelList() const;
110    
111 protected:
112         ///
113         void UpdateLocal(BufferView * bv);
114         ///
115         MathParInset * par;
116         ///
117         static MathedCursor * mathcursor;
118     
119 private:
120         ///
121         bool disp_flag_;
122         ///
123         string label_;
124 };
125
126
127 inline
128 Inset::Code InsetFormula::LyxCode() const
129 {
130         return Inset::MATH_CODE;
131 }
132
133
134 inline
135 LyXFont const InsetFormula::ConvertFont(LyXFont const & f) const
136 {
137         // We have already discussed what was here
138         LyXFont font(f);
139         font.setLatex(LyXFont::OFF);
140         return font;
141 }
142
143
144 inline
145 bool InsetFormula::display() const
146 {
147         return (disp_flag_) ? true : false;
148 }
149 #endif