]> git.lyx.org Git - lyx.git/blob - src/mathed/formulabase.h
fix typo that put too many include paths for most people
[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 /// An abstract base class for all math related LyX insets
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 = true, bool = false);
108         ///
109         virtual bool searchBackward(BufferView *, string const &,
110                                     bool = true, bool = false);
111         ///
112         virtual bool isTextInset() const { return true; }
113         ///
114         virtual void mutateToText();
115         ///
116         virtual void revealCodes(BufferView *) const;
117
118
119 private:
120         /// unimplemented
121         void operator=(const InsetFormulaBase &);
122         /// common base for handling accents
123         void handleAccent(BufferView * bv, string const & arg, string const & name);
124
125         ///
126         mutable BufferView * view_;
127         ///
128         mutable LyXFont font_;
129
130 protected:
131         ///
132         void metrics(BufferView * bv, LyXFont const & font) const;
133         ///
134         void metrics(BufferView * bv = 0) const;
135
136         ///
137         mutable int xo_;
138         ///
139         mutable int yo_;
140 };
141
142 // We don't really mess want around with mathed stuff outside mathed.
143 // So do it here.
144 //
145 void mathDispatchCreation(BufferView *, string const &, bool);
146 //
147 void mathDispatchMathDisplay(BufferView *, string const &);
148 //
149 void mathDispatchMathMode(BufferView *, string const &);
150 //
151 void mathDispatchMathMacro(BufferView *, string const &);
152 //
153 void mathDispatchMathDelim(BufferView *, string const &);
154 //
155 void mathDispatchInsertMath(BufferView *, string const &);
156 //
157 void mathDispatchInsertMatrix(BufferView *, string const &);
158 //
159 void mathDispatchGreek(BufferView *, string const &);
160 //
161 void mathDispatchMathImportSelection(BufferView *, string const &);
162 //
163 void mathDispatch(BufferView *, kb_action, string const &);
164
165 #endif