]> git.lyx.org Git - lyx.git/blob - src/mathed/formulabase.h
remove public access to cached position
[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 void 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 private:
106         /// unimplemented
107         void operator=(const InsetFormulaBase &);
108
109         ///
110         mutable BufferView * view_;     
111         ///
112         mutable LyXFont font_;
113
114 protected:
115         ///
116         void metrics(BufferView * bv, LyXFont const & font) const;
117         ///
118         void metrics(BufferView * bv = 0) const;
119
120         ///
121         mutable int xo_;
122         ///
123         mutable int yo_;
124 };
125
126 // We don't really mess want around with mathed stuff outside mathed.
127 // So do it here.
128 //
129 void mathDispatchCreation(BufferView *, string const &, bool);
130 //
131 void mathDispatchMathDisplay(BufferView *, string const &);
132 //
133 void mathDispatchMathMode(BufferView *, string const &);
134 //
135 void mathDispatchMathMacro(BufferView *, string const &);
136 //
137 void mathDispatchMathDelim(BufferView *, string const &);
138 //
139 void mathDispatchInsertMath(BufferView *, string const &);
140 //
141 void mathDispatchInsertMatrix(BufferView *, string const &);
142 //
143 void mathDispatchGreek(BufferView *, string const &);
144 //
145 void mathDispatchMathImportSelection(BufferView *, string const &);
146 //
147 void mathDispatch(BufferView *, kb_action, string const &);
148
149 #endif