]> git.lyx.org Git - lyx.git/blob - src/mathed/formulabase.h
enable direct input of #1...#9; some whitespace changes
[lyx.git] / src / mathed / formulabase.h
1 // -*- C++ -*-
2 /*
3  *  File:        formulabase.h
4  *  Purpose:     Common parts of the math LyX insets
5  *  Author:      André Pönitz
6  *  Created:     May 2001
7  *  Description: Allows the edition of math paragraphs inside Lyx. 
8  *
9  *  Copyright: 2001, The LyX Project
10  *
11  *   You are free to use and modify this code under the terms of
12  *   the GNU General Public Licence version 2 or later.
13  */
14
15 #ifndef INSET_FORMULABASE_H 
16 #define INSET_FORMULABASE_H
17
18 #ifdef __GNUG__
19 #pragma interface
20 #endif
21
22 #include <iosfwd>
23 #include "insets/inset.h"
24 #include "lyxfont.h"
25
26 // only for getType():
27 #include "math_defs.h"
28
29 class Buffer;
30 class BufferView;
31 class MathAtom;
32
33 ///
34 class InsetFormulaBase : public UpdatableInset {
35 public:
36         ///
37         InsetFormulaBase();
38         ///
39         virtual int ascent(BufferView *, LyXFont const &) const = 0;
40         ///
41         virtual int descent(BufferView *, LyXFont const &) const = 0;
42         ///
43         virtual int width(BufferView *, LyXFont const &) const = 0;
44         ///
45         virtual void draw(BufferView *,LyXFont const &, int, float &, bool) const = 0;
46         ///
47         virtual MathInsetTypes getType() const = 0;
48         /// lowest x coordinate
49         virtual int xlow() const;
50         /// highest x coordinate
51         virtual int xhigh() const;
52         /// lowest y coordinate
53         virtual int ylow() const;
54         /// highest y coordinate
55         virtual int yhigh() const;
56
57 public:
58         ///
59         virtual void validate(LaTeXFeatures &) const;
60         ///
61         virtual Inset * clone(Buffer const &, bool same_id = false) const = 0;
62         ///
63         virtual Inset::Code lyxCode() const;
64         /// what appears in the minibuffer when opening
65         virtual string const editMessage() const;
66         ///
67         virtual void edit(BufferView *, int x, int y, unsigned int button);
68         ///
69         virtual void edit(BufferView *, bool front = true);
70         ///
71         virtual void toggleInsetCursor(BufferView *);
72         ///
73         virtual void showInsetCursor(BufferView *, bool show = true);
74         ///
75         virtual void hideInsetCursor(BufferView *);
76         ///
77         virtual void getCursorPos(BufferView *, int &, int &) const;
78         ///
79         virtual void toggleInsetSelection(BufferView * bv);
80         ///
81         virtual void insetButtonPress(BufferView *, int x, int y, int button);
82         ///
83         virtual bool insetButtonRelease(BufferView *, int x, int y, int button);
84         ///
85         virtual void insetKeyPress(XKeyEvent * ev);
86         ///
87         virtual void insetMotionNotify(BufferView *, int x, int y, int state);
88         ///
89         virtual void insetUnlock(BufferView *);
90    
91         /// To allow transparent use of math editing functions
92         virtual RESULT localDispatch(BufferView *, kb_action, string const &);
93     
94         ///
95         virtual std::vector<string> const getLabelList() const;
96         ///
97         virtual MathAtom const & par() const = 0;
98         ///
99         virtual MathAtom & par() = 0;
100         ///
101         virtual void updateLocal(BufferView * bv, bool mark_dirty);
102         ///
103         BufferView * view() const { return view_; }
104
105         ///
106         virtual bool searchForward(BufferView *, string const &,
107                                    bool const & = true, bool const & = false);
108         ///
109         virtual bool searchBackward(BufferView *, string const &,
110                                     bool const & = true, bool const & = false);
111         ///
112         virtual bool isTextInset() const { return true; }
113
114
115 private:
116         /// unimplemented
117         void operator=(const InsetFormulaBase &);
118
119         ///
120         mutable BufferView * view_;     
121         ///
122         mutable LyXFont font_;
123
124 protected:
125         ///
126         void metrics(BufferView * bv, LyXFont const & font) const;
127         ///
128         void metrics(BufferView * bv = 0) const;
129
130         ///
131         mutable int xo_;
132         ///
133         mutable int yo_;
134 };
135
136 // We don't really mess want around with mathed stuff outside mathed.
137 // So do it here.
138 //
139 void mathDispatchCreation(BufferView *, string const &, bool);
140 //
141 void mathDispatchMathDisplay(BufferView *, string const &);
142 //
143 void mathDispatchMathMode(BufferView *, string const &);
144 //
145 void mathDispatchMathMacro(BufferView *, string const &);
146 //
147 void mathDispatchMathDelim(BufferView *, string const &);
148 //
149 void mathDispatchInsertMath(BufferView *, string const &);
150 //
151 void mathDispatchInsertMatrix(BufferView *, string const &);
152 //
153 void mathDispatchGreek(BufferView *, string const &);
154 //
155 void mathDispatchMathImportSelection(BufferView *, string const &);
156 //
157 void mathDispatch(BufferView *, kb_action, string const &);
158
159 #endif