]> git.lyx.org Git - lyx.git/blob - src/mathed/formulabase.h
Georg Baum's vspace change
[lyx.git] / src / mathed / formulabase.h
1 // -*- C++ -*-
2 /**
3  * \file formulabase.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  *
11  * Common parts of the math LyX insets.
12  */
13
14 #ifndef INSET_FORMULABASE_H
15 #define INSET_FORMULABASE_H
16
17 #include "insets/updatableinset.h"
18
19 class Buffer;
20 class BufferView;
21 class MathAtom;
22
23
24 /// An abstract base class for all math related LyX insets
25 class InsetFormulaBase : public UpdatableInset {
26 public:
27         ///
28         InsetFormulaBase();
29         /// lowest x coordinate
30         virtual int xlow() const;
31         /// highest x coordinate
32         virtual int xhigh() const;
33         /// lowest y coordinate
34         virtual int ylow() const;
35         /// highest y coordinate
36         virtual int yhigh() const;
37
38 public:
39         ///
40         // Don't use this for AMS validation as long as there is no
41         // user-accessible way to override "false positives"
42         virtual void validate(LaTeXFeatures &) const;
43         ///
44         virtual InsetOld::Code lyxCode() const;
45         /// what appears in the minibuffer when opening
46         virtual std::string const editMessage() const;
47         ///
48         virtual void getCursorPos(int &, int &) const;
49         ///
50         virtual void getCursorDim(int &, int &) const;
51         /// get the absolute document x,y of the cursor
52         virtual void getCursor(BufferView & bv, int & x, int & y) const;
53         ///
54         virtual void toggleInsetSelection(BufferView * bv);
55         ///
56         virtual void insetUnlock(BufferView *);
57
58         /// To allow transparent use of math editing functions
59         //virtual void status(FuncRequest const &);
60
61         ///
62         virtual MathAtom const & par() const = 0;
63         ///
64         virtual MathAtom & par() = 0;
65         ///
66         ///
67         virtual bool searchForward(BufferView *, std::string const &,
68                                    bool = true, bool = false);
69         ///
70         virtual bool searchBackward(BufferView *, std::string const &,
71                                     bool = true, bool = false);
72         ///
73         virtual bool isTextInset() const { return true; }
74         ///
75         virtual void mutateToText();
76         ///
77         virtual void revealCodes(BufferView *) const;
78         ///
79         virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
80         ///
81         bool display() const;
82         // return the selection as std::string
83         std::string selectionAsString() const;
84         ///
85         void edit(BufferView * bv, bool);
86         ///
87         void edit(BufferView * bv, int, int);
88 protected:
89         /// To allow transparent use of math editing functions
90         virtual
91         DispatchResult
92         priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
93 private:
94         /// unimplemented
95         void operator=(const InsetFormulaBase &);
96         /// common base for handling accents
97         void handleAccent(BufferView * bv, std::string const & arg, std::string const & name);
98         /// lfun handler
99         DispatchResult lfunMousePress(FuncRequest const &);
100         ///
101         DispatchResult lfunMouseRelease(FuncRequest const &);
102         ///
103         DispatchResult lfunMouseMotion(FuncRequest const &);
104
105 protected:
106
107         /** Find the PreviewLoader, add a LaTeX snippet to it and
108          *  start the loading process.
109          *
110          *  Most insets have no interest in this capability, so the method
111          *  defaults to empty.
112          */
113         virtual void generatePreview(Buffer const &) const {}
114
115         ///
116         void handleFont(BufferView * bv, std::string const & arg, std::string const & font);
117         ///
118         void handleFont2(BufferView * bv, std::string const & arg);
119 };
120
121 // We don't really mess want around with mathed stuff outside mathed.
122 // So do it here.
123 void mathDispatch(FuncRequest const &);
124
125 ///
126 void releaseMathCursor(BufferView * bv);
127
128 #endif