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"
26 /// An abstract base class for all math related LyX insets
27 class InsetFormulaBase : public UpdatableInset {
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;
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;
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;
52 virtual void getCursorDim(int &, int &) const;
54 virtual void insetUnlock(BufferView & bv);
56 /// To allow transparent use of math editing functions
57 //virtual void status(FuncRequest const &);
60 virtual MathAtom const & par() const = 0;
62 virtual MathAtom & par() = 0;
65 virtual bool searchForward(BufferView *, std::string const &,
66 bool = true, bool = false);
68 virtual bool searchBackward(BufferView *, std::string const &,
69 bool = true, bool = false);
71 virtual bool isTextInset() const { return true; }
73 virtual void mutateToText();
75 virtual void revealCodes(LCursor & cur) const;
77 virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
80 // return the selection as std::string
81 std::string selectionAsString(BufferView & bv) const;
83 void edit(LCursor & cur, bool);
85 void edit(LCursor & cur, int, int);
87 /// To allow transparent use of math editing functions
88 DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
91 void operator=(const InsetFormulaBase &);
92 /// common base for handling accents
93 void handleAccent(BufferView & bv, std::string const & arg, std::string const & name);
95 DispatchResult lfunMousePress(LCursor &, FuncRequest const &);
97 DispatchResult lfunMouseRelease(LCursor &, FuncRequest const &);
99 DispatchResult lfunMouseMotion(LCursor &, FuncRequest const &);
103 /** Find the PreviewLoader, add a LaTeX snippet to it and
104 * start the loading process.
106 * Most insets have no interest in this capability, so the method
109 virtual void generatePreview(Buffer const &) const {}
112 void handleFont(LCursor &, std::string const & arg, std::string const & font);
114 void handleFont2(LCursor &, std::string const & arg);
117 // We don't really mess want around with mathed stuff outside mathed.
119 void mathDispatch(LCursor & cur, FuncRequest const & cmd);
122 void releaseMathCursor(LCursor & cur);