]> git.lyx.org Git - lyx.git/blob - src/mathed/formulabase.h
fix pullArg when pressing <Delete> at the end of an cell
[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
25 class Buffer;
26 class BufferView;
27 class MathInset;
28
29 ///
30 class InsetFormulaBase : public UpdatableInset {
31 public:
32         /// 
33         InsetFormulaBase(InsetFormulaBase const & p);
34         ///
35         explicit InsetFormulaBase(MathInset *);
36         ///
37         virtual ~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         /// These are just wrappers taking the unused Buffer * dummy parameter
48         /// 
49         virtual void write(Buffer const *, std::ostream &) const;
50         ///
51         virtual void read(Buffer const *, LyXLex & lex);
52         ///
53         virtual int latex(Buffer const *, std::ostream &,
54                   bool fragile, bool free_spc) const;
55         ///
56         virtual int ascii(Buffer const *, std::ostream &, int linelen) const;
57         ///
58         virtual int linuxdoc(Buffer const *, std::ostream &) const;
59         ///
60         virtual int docBook(Buffer const *, std::ostream &) const;
61
62 protected:
63         /// the actual functions don't use the Buffer * parameter
64         ///
65         virtual void write(std::ostream &) const = 0;
66         ///
67         virtual void read(LyXLex & lex) = 0;
68         ///
69         virtual int latex(std::ostream &, bool fragile, bool free_spc) const = 0;
70         ///
71         virtual int ascii(std::ostream &, int linelen) const = 0;
72         ///
73         virtual int linuxdoc(std::ostream &) const = 0;
74         ///
75         virtual int docBook(std::ostream &) const = 0;
76
77 public:
78         ///
79         virtual void validate(LaTeXFeatures &) const;
80         ///
81         virtual Inset * clone(Buffer const &, bool same_id = false) const = 0;
82         ///
83         virtual Inset::Code lyxCode() const;
84         ///
85         virtual LyXFont const convertFont(LyXFont const & f) const;
86         /// what appears in the minibuffer when opening
87         virtual string const editMessage() const;
88         ///
89         virtual void edit(BufferView *, int x, int y, unsigned int button);
90         virtual void edit(BufferView *, bool front = true);
91         ///
92         virtual void toggleInsetCursor(BufferView *);
93         ///
94         virtual void showInsetCursor(BufferView *, bool show = true);
95         ///
96         virtual void hideInsetCursor(BufferView *);
97         ///
98         virtual void getCursorPos(BufferView *, int &, int &) const;
99         ///
100         virtual void toggleInsetSelection(BufferView * bv);
101         ///
102         virtual void insetButtonPress(BufferView *, int x, int y, int button);
103         ///
104         virtual void insetButtonRelease(BufferView *, int x, int y, int button);
105         ///
106         virtual void insetKeyPress(XKeyEvent * ev);
107         ///
108         virtual void insetMotionNotify(BufferView *, int x, int y, int state);
109         ///
110         virtual void insetUnlock(BufferView *);
111    
112         /// To allow transparent use of math editing functions
113         virtual RESULT localDispatch(BufferView *, kb_action, string const &);
114     
115         ///
116         virtual std::vector<string> const getLabelList() const;
117         ///
118         MathInset * par() const;
119         ///
120         virtual void Metrics() const;
121 protected:
122         ///
123         virtual void updateLocal(BufferView * bv, bool mark_dirty);
124
125         ///
126         MathInset * par_;
127 };
128
129 // We don't really mess want around with mathed stuff outside mathed.
130 // So do it here.
131 //
132 void mathDispatchCreation(BufferView *, string const &, bool);
133 //
134 void mathDispatchMathDisplay(BufferView *, string const &);
135 //
136 void mathDispatchMathMode(BufferView *, string const &);
137 //
138 void mathDispatchMathMacro(BufferView *, string const &);
139 //
140 void mathDispatchMathDelim(BufferView *, string const &);
141 //
142 void mathDispatchInsertMath(BufferView *, string const &);
143 //
144 void mathDispatchInsertMatrix(BufferView *, string const &);
145 //
146 void mathDispatchMathImportSelection(BufferView *, string const &);
147
148 #endif