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