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