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"
18 #include <boost/weak_ptr.hpp>
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;
50 virtual void fitInsetCursor(BufferView *) const;
52 virtual void getCursorPos(BufferView *, int &, int &) const;
53 /// get the absolute document x,y of the cursor
54 virtual void getCursor(BufferView & bv, int & x, int & y) const;
56 virtual void toggleInsetSelection(BufferView * bv);
58 virtual void insetUnlock(BufferView *);
60 /// To allow transparent use of math editing functions
61 virtual dispatch_result localDispatch(FuncRequest const &);
62 /// To allow transparent use of math editing functions
63 //virtual void status(FuncRequest const &);
66 virtual MathAtom const & par() const = 0;
68 virtual MathAtom & par() = 0;
71 virtual bool searchForward(BufferView *, std::string const &,
72 bool = true, bool = false);
74 virtual bool searchBackward(BufferView *, std::string const &,
75 bool = true, bool = false);
77 virtual bool isTextInset() const { return true; }
79 virtual void mutateToText();
81 virtual void revealCodes(BufferView *) const;
83 virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
86 // return the selection as std::string
87 std::string selectionAsString() const;
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 dispatch_result lfunMousePress(FuncRequest const &);
97 dispatch_result lfunMouseRelease(FuncRequest const &);
99 dispatch_result lfunMouseMotion(FuncRequest const &);
102 void cache(BufferView *) const;
103 BufferView * view() 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);
126 mutable boost::weak_ptr<BufferView> view_;
129 // We don't really mess want around with mathed stuff outside mathed.
131 void mathDispatch(FuncRequest const &);
134 void releaseMathCursor(BufferView * bv);