]> git.lyx.org Git - features.git/blob - src/mathed/formulabase.h
Part of IU.
[features.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 class CursorSlice;
23 class LCursor;
24
25
26 /// An abstract base class for all math related LyX insets
27 class InsetFormulaBase : public UpdatableInset {
28 public:
29         ///
30         InsetFormulaBase();
31         /// lowest x coordinate
32         virtual int xlow() const;
33         /// highest x coordinate
34         virtual int xhigh() const;
35         /// lowest y coordinate
36         virtual int ylow() const;
37         /// highest y coordinate
38         virtual int yhigh() const;
39
40 public:
41         ///
42         // Don't use this for AMS validation as long as there is no
43         // user-accessible way to override "false positives"
44         virtual void validate(LaTeXFeatures &) const;
45         ///
46         virtual InsetOld::Code lyxCode() const;
47         /// what appears in the minibuffer when opening
48         virtual std::string const editMessage() const;
49         /// get the absolute document x,y of the cursor
50         virtual void getCursorPos(BufferView & bv, int & x, int & y) const;
51         ///
52         virtual void getCursorDim(int &, int &) const;
53         ///
54         virtual void insetUnlock(BufferView & bv);
55
56         /// To allow transparent use of math editing functions
57         //virtual void status(FuncRequest const &);
58
59         ///
60         virtual MathAtom const & par() const = 0;
61         ///
62         virtual MathAtom & par() = 0;
63         ///
64         ///
65         virtual bool searchForward(BufferView *, std::string const &,
66                                    bool = true, bool = false);
67         ///
68         virtual bool searchBackward(BufferView *, std::string const &,
69                                     bool = true, bool = false);
70         ///
71         virtual bool isTextInset() const { return true; }
72         ///
73         virtual void mutateToText();
74         ///
75         virtual void revealCodes(LCursor & cur) const;
76         ///
77         virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
78         ///
79         bool display() const;
80         // return the selection as std::string
81         std::string selectionAsString(BufferView & bv) const;
82         ///
83         void edit(LCursor & cur, bool);
84         ///
85         void edit(LCursor & cur, int, int);
86 protected:
87         /// To allow transparent use of math editing functions
88         DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
89 private:
90         /// unimplemented
91         void operator=(const InsetFormulaBase &);
92         /// common base for handling accents
93         void handleAccent(BufferView & bv, std::string const & arg, std::string const & name);
94         /// lfun handler
95         DispatchResult lfunMousePress(LCursor &, FuncRequest const &);
96         ///
97         DispatchResult lfunMouseRelease(LCursor &, FuncRequest const &);
98         ///
99         DispatchResult lfunMouseMotion(LCursor &, FuncRequest const &);
100
101 protected:
102
103         /** Find the PreviewLoader, add a LaTeX snippet to it and
104          *  start the loading process.
105          *
106          *  Most insets have no interest in this capability, so the method
107          *  defaults to empty.
108          */
109         virtual void generatePreview(Buffer const &) const {}
110
111         ///
112         void handleFont(LCursor &, std::string const & arg, std::string const & font);
113         ///
114         void handleFont2(LCursor &, std::string const & arg);
115 };
116
117 // We don't really mess want around with mathed stuff outside mathed.
118 // So do it here.
119 void mathDispatch(LCursor & cur, FuncRequest const & cmd);
120
121 ///
122 void releaseMathCursor(LCursor & cur);
123
124 #endif