]> git.lyx.org Git - lyx.git/blob - src/mathed/formulabase.h
Make lyx2lyx output the new external inset format.
[lyx.git] / src / mathed / formulabase.h
1 // -*- C++ -*-
2
3 /*
4  * Common parts of the math LyX insets
5  * \author  André Pönitz
6  *
7  * Full author contact details are available in file CREDITS
8  *
9  * You are free to use and modify this code under the terms of
10  * the GNU General Public Licence version 2 or later.
11  */
12
13 #ifndef INSET_FORMULABASE_H
14 #define INSET_FORMULABASE_H
15
16 #include "insets/updatableinset.h"
17 #include "dimension.h"
18
19 #include <boost/weak_ptr.hpp>
20 #include <iosfwd>
21
22 class Buffer;
23 class BufferView;
24 class MathAtom;
25
26
27 /// An abstract base class for all math related LyX insets
28 class InsetFormulaBase : public UpdatableInset {
29 public:
30         ///
31         InsetFormulaBase();
32         ///
33         Inset * clone() const = 0;
34         /// lowest x coordinate
35         virtual int xlow() const;
36         /// highest x coordinate
37         virtual int xhigh() const;
38         /// lowest y coordinate
39         virtual int ylow() const;
40         /// highest y coordinate
41         virtual int yhigh() const;
42
43 public:
44         ///
45         // Don't use this for AMS validation as long as there is no
46         // user-accessible way to override "false positives"
47         virtual void validate(LaTeXFeatures &) const;
48         ///
49         virtual Inset::Code lyxCode() const;
50         /// what appears in the minibuffer when opening
51         virtual string const editMessage() const;
52         ///
53         virtual void fitInsetCursor(BufferView *) const;
54         /// FIXME
55         virtual void getCursorPos(BufferView *, int &, int &) const;
56         /// get the absolute document x,y of the cursor
57         virtual void getCursor(BufferView & bv, int & x, int & y) const;
58         ///
59         virtual void toggleInsetSelection(BufferView * bv);
60         ///
61         virtual void insetUnlock(BufferView *);
62
63         /// To allow transparent use of math editing functions
64         virtual dispatch_result localDispatch(FuncRequest const &);
65         /// To allow transparent use of math editing functions
66         //virtual void status(FuncRequest const &);
67
68         ///
69         virtual std::vector<string> const getLabelList() const;
70         ///
71         virtual MathAtom const & par() const = 0;
72         ///
73         virtual MathAtom & par() = 0;
74         ///
75         // And shouldn't this really return a shared_ptr<BufferView> instead?
76         BufferView * view() const;
77
78         ///
79         virtual bool searchForward(BufferView *, string const &,
80                                    bool = true, bool = false);
81         ///
82         virtual bool searchBackward(BufferView *, string const &,
83                                     bool = true, bool = false);
84         ///
85         virtual bool isTextInset() const { return true; }
86         ///
87         virtual void mutateToText();
88         ///
89         virtual void revealCodes(BufferView *) const;
90         ///
91         virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
92         ///
93         bool display() const;
94         // return the selection as string
95         string selectionAsString() const;
96
97 private:
98         /// unimplemented
99         void operator=(const InsetFormulaBase &);
100         /// common base for handling accents
101         void handleAccent(BufferView * bv, string const & arg, string const & name);
102         /// lfun handler
103         dispatch_result lfunMousePress(FuncRequest const &);
104         ///
105         dispatch_result lfunMouseRelease(FuncRequest const &);
106         ///
107         dispatch_result lfunMouseMotion(FuncRequest const &);
108
109 protected:
110         ///
111         //mutable boost::weak_ptr<BufferView> view_;
112         mutable BufferView * view_;
113
114 protected:
115         ///
116         void handleFont(BufferView * bv, string const & arg, string const & font);
117
118         ///
119         mutable int xo_;
120         ///
121         mutable int yo_;
122         ///
123         mutable Dimension dim_;
124 };
125
126 // We don't really mess want around with mathed stuff outside mathed.
127 // So do it here.
128 void mathDispatch(FuncRequest const &);
129
130 ///
131 void releaseMathCursor(BufferView * bv);
132
133 #endif