]> git.lyx.org Git - lyx.git/blob - src/mathed/formulabase.h
next step...
[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         /// upper y coordinate
49         virtual int upperY() const;
50         /// lower y coordinate
51         virtual int lowerY() const;
52
53 public:
54         ///
55         virtual void validate(LaTeXFeatures &) const;
56         ///
57         virtual Inset * clone(Buffer const &, bool same_id = false) const = 0;
58         ///
59         virtual Inset::Code lyxCode() const;
60         /// what appears in the minibuffer when opening
61         virtual string const editMessage() const;
62         ///
63         virtual void edit(BufferView *, int x, int y, unsigned int button);
64         ///
65         virtual void edit(BufferView *, bool front = true);
66         ///
67         virtual void toggleInsetCursor(BufferView *);
68         ///
69         virtual void showInsetCursor(BufferView *, bool show = true);
70         ///
71         virtual void hideInsetCursor(BufferView *);
72         ///
73         virtual void getCursorPos(BufferView *, int &, int &) const;
74         ///
75         virtual void toggleInsetSelection(BufferView * bv);
76         ///
77         virtual void insetButtonPress(BufferView *, int x, int y, int button);
78         ///
79         virtual void insetButtonRelease(BufferView *, int x, int y, int button);
80         ///
81         virtual void insetKeyPress(XKeyEvent * ev);
82         ///
83         virtual void insetMotionNotify(BufferView *, int x, int y, int state);
84         ///
85         virtual void insetUnlock(BufferView *);
86    
87         /// To allow transparent use of math editing functions
88         virtual RESULT localDispatch(BufferView *, kb_action, string const &);
89     
90         ///
91         virtual std::vector<string> const getLabelList() const;
92         ///
93         virtual MathAtom const & par() const = 0;
94         ///
95         virtual MathAtom & par() = 0;
96         ///
97         virtual void metrics(BufferView * bv = 0, LyXFont const & font = LyXFont()) const;
98         ///
99         virtual void updateLocal(BufferView * bv, bool mark_dirty);
100         ///
101         int xo() const { return xo_; }
102         ///
103         int yo() const { return yo_; }
104         ///
105         BufferView * view() const { return view_; }
106 private:
107         /// unimplemented
108         void operator=(const InsetFormulaBase &);
109         ///
110         mutable BufferView * view_;     
111         ///
112         mutable LyXFont font_;
113 protected:
114         ///
115         mutable int xo_;
116         ///
117         mutable int yo_;
118 };
119
120 // We don't really mess want around with mathed stuff outside mathed.
121 // So do it here.
122 //
123 void mathDispatchCreation(BufferView *, string const &, bool);
124 //
125 void mathDispatchMathDisplay(BufferView *, string const &);
126 //
127 void mathDispatchMathMode(BufferView *, string const &);
128 //
129 void mathDispatchMathMacro(BufferView *, string const &);
130 //
131 void mathDispatchMathDelim(BufferView *, string const &);
132 //
133 void mathDispatchInsertMath(BufferView *, string const &);
134 //
135 void mathDispatchInsertMatrix(BufferView *, string const &);
136 //
137 void mathDispatchGreek(BufferView *, string const &);
138 //
139 void mathDispatchMathImportSelection(BufferView *, string const &);
140
141 #endif