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