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(BufferView & bv, 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 & bv);
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 & bv) const;
80 virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
83 // return the selection as std::string
84 std::string selectionAsString(BufferView & bv) const;
86 void edit(BufferView * bv, bool);
88 void edit(BufferView * bv, int, int);
90 /// To allow transparent use of math editing functions
92 DispatchResult priv_dispatch(BufferView & bv, FuncRequest const & cmd);
95 void operator=(const InsetFormulaBase &);
96 /// common base for handling accents
97 void handleAccent(BufferView & bv, std::string const & arg, std::string const & name);
99 DispatchResult lfunMousePress(BufferView &, FuncRequest const &);
101 DispatchResult lfunMouseRelease(BufferView &, FuncRequest const &);
103 DispatchResult lfunMouseMotion(BufferView &, FuncRequest const &);
107 /** Find the PreviewLoader, add a LaTeX snippet to it and
108 * start the loading process.
110 * Most insets have no interest in this capability, so the method
113 virtual void generatePreview(Buffer const &) const {}
116 void handleFont(BufferView & bv, std::string const & arg, std::string const & font);
118 void handleFont2(BufferView & bv, std::string const & arg);
121 // We don't really mess want around with mathed stuff outside mathed.
123 void mathDispatch(BufferView & bv, FuncRequest const & cmd);
126 void releaseMathCursor(BufferView & bv);