4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
11 * Common parts of the math LyX insets.
14 #ifndef INSET_FORMULABASE_H
15 #define INSET_FORMULABASE_H
17 #include "insets/updatableinset.h"
25 /// An abstract base class for all math related LyX insets
26 class InsetFormulaBase : public UpdatableInset {
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;
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;
45 virtual InsetOld::Code lyxCode() const;
46 /// what appears in the minibuffer when opening
47 virtual std::string const editMessage() const;
49 virtual void getCursorPos(int cell, int & x, int & y) const;
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;
55 virtual void toggleInsetSelection(BufferView * bv);
57 virtual void insetUnlock(BufferView *);
59 /// To allow transparent use of math editing functions
60 //virtual void status(FuncRequest const &);
63 virtual MathAtom const & par() const = 0;
65 virtual MathAtom & par() = 0;
68 virtual bool searchForward(BufferView *, std::string const &,
69 bool = true, bool = false);
71 virtual bool searchBackward(BufferView *, std::string const &,
72 bool = true, bool = false);
74 virtual bool isTextInset() const { return true; }
76 virtual void mutateToText();
78 virtual void revealCodes(BufferView *) const;
80 virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
83 // return the selection as std::string
84 std::string selectionAsString() const;
86 void edit(BufferView * bv, bool);
88 void edit(BufferView * bv, int, int);
90 /// To allow transparent use of math editing functions
93 priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
96 void operator=(const InsetFormulaBase &);
97 /// common base for handling accents
98 void handleAccent(BufferView * bv, std::string const & arg, std::string const & name);
100 DispatchResult lfunMousePress(FuncRequest const &);
102 DispatchResult lfunMouseRelease(FuncRequest const &);
104 DispatchResult lfunMouseMotion(FuncRequest const &);
108 /** Find the PreviewLoader, add a LaTeX snippet to it and
109 * start the loading process.
111 * Most insets have no interest in this capability, so the method
114 virtual void generatePreview(Buffer const &) const {}
117 void handleFont(BufferView * bv, std::string const & arg, std::string const & font);
119 void handleFont2(BufferView * bv, std::string const & arg);
122 // We don't really mess want around with mathed stuff outside mathed.
124 void mathDispatch(FuncRequest const &);
127 void releaseMathCursor(BufferView * bv);