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 "dimension.h"
20 #include <boost/weak_ptr.hpp>
28 /// An abstract base class for all math related LyX insets
29 class InsetFormulaBase : public UpdatableInset {
33 /// lowest x coordinate
34 virtual int xlow() const;
35 /// highest x coordinate
36 virtual int xhigh() const;
37 /// lowest y coordinate
38 virtual int ylow() const;
39 /// highest y coordinate
40 virtual int yhigh() const;
44 // Don't use this for AMS validation as long as there is no
45 // user-accessible way to override "false positives"
46 virtual void validate(LaTeXFeatures &) const;
48 virtual InsetOld::Code lyxCode() const;
49 /// what appears in the minibuffer when opening
50 virtual string const editMessage() const;
52 virtual void fitInsetCursor(BufferView *) const;
54 virtual void getCursorPos(BufferView *, int &, int &) const;
55 /// get the absolute document x,y of the cursor
56 virtual void getCursor(BufferView & bv, int & x, int & y) const;
58 virtual void toggleInsetSelection(BufferView * bv);
60 virtual void insetUnlock(BufferView *);
62 /// To allow transparent use of math editing functions
63 virtual dispatch_result localDispatch(FuncRequest const &);
64 /// To allow transparent use of math editing functions
65 //virtual void status(FuncRequest const &);
68 virtual MathAtom const & par() const = 0;
70 virtual MathAtom & par() = 0;
72 // And shouldn't this really return a shared_ptr<BufferView> instead?
73 BufferView * view() const;
76 virtual bool searchForward(BufferView *, string const &,
77 bool = true, bool = false);
79 virtual bool searchBackward(BufferView *, string const &,
80 bool = true, bool = false);
82 virtual bool isTextInset() const { return true; }
84 virtual void mutateToText();
86 virtual void revealCodes(BufferView *) const;
88 virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
91 // return the selection as string
92 string selectionAsString() const;
96 void operator=(const InsetFormulaBase &);
97 /// common base for handling accents
98 void handleAccent(BufferView * bv, string const & arg, string const & name);
100 dispatch_result lfunMousePress(FuncRequest const &);
102 dispatch_result lfunMouseRelease(FuncRequest const &);
104 dispatch_result lfunMouseMotion(FuncRequest const &);
108 //mutable boost::weak_ptr<BufferView> view_;
109 mutable BufferView * view_;
113 void handleFont(BufferView * bv, string const & arg, string const & font);
121 // We don't really mess want around with mathed stuff outside mathed.
123 void mathDispatch(FuncRequest const &);
126 void releaseMathCursor(BufferView * bv);