]> git.lyx.org Git - lyx.git/blob - src/mathed/formulabase.h
Turn LyX into a singleton class. Kill the BufferView cache.
[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 fitInsetCursor(BufferView *) const;
49         /// FIXME
50         virtual void getCursorPos(BufferView *, 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 dispatch_result localDispatch(FuncRequest const &);
60         /// To allow transparent use of math editing functions
61         //virtual void status(FuncRequest const &);
62
63         ///
64         virtual MathAtom const & par() const = 0;
65         ///
66         virtual MathAtom & par() = 0;
67         ///
68         ///
69         virtual bool searchForward(BufferView *, std::string const &,
70                                    bool = true, bool = false);
71         ///
72         virtual bool searchBackward(BufferView *, std::string const &,
73                                     bool = true, bool = false);
74         ///
75         virtual bool isTextInset() const { return true; }
76         ///
77         virtual void mutateToText();
78         ///
79         virtual void revealCodes(BufferView *) const;
80         ///
81         virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
82         ///
83         bool display() const;
84         // return the selection as std::string
85         std::string selectionAsString() const;
86
87 private:
88         /// unimplemented
89         void operator=(const InsetFormulaBase &);
90         /// common base for handling accents
91         void handleAccent(BufferView * bv, std::string const & arg, std::string const & name);
92         /// lfun handler
93         dispatch_result lfunMousePress(FuncRequest const &);
94         ///
95         dispatch_result lfunMouseRelease(FuncRequest const &);
96         ///
97         dispatch_result lfunMouseMotion(FuncRequest const &);
98
99 protected:
100
101         /** Find the PreviewLoader, add a LaTeX snippet to it and
102          *  start the loading process.
103          *
104          *  Most insets have no interest in this capability, so the method
105          *  defaults to empty.
106          */
107         virtual void generatePreview(Buffer const &) const {}
108
109         ///
110         void handleFont(BufferView * bv, std::string const & arg, std::string const & font);
111         ///
112         void handleFont2(BufferView * bv, std::string const & arg);
113
114         ///
115         mutable int xo_;
116         ///
117         mutable int yo_;
118 };
119
120 // We don't really mess want around with mathed stuff outside mathed.
121 // So do it here.
122 void mathDispatch(FuncRequest const &);
123
124 ///
125 void releaseMathCursor(BufferView * bv);
126
127 #endif