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