4 * Common parts of the math LyX insets
7 * Full author contact details are available in file CREDITS
9 * You are free to use and modify this code under the terms of
10 * the GNU General Public Licence version 2 or later.
13 #ifndef INSET_FORMULABASE_H
14 #define INSET_FORMULABASE_H
16 #include "insets/updatableinset.h"
17 #include "dimension.h"
19 #include <boost/weak_ptr.hpp>
27 /// An abstract base class for all math related LyX insets
28 class InsetFormulaBase : public UpdatableInset {
32 /// lowest x coordinate
33 virtual int xlow() const;
34 /// highest x coordinate
35 virtual int xhigh() const;
36 /// lowest y coordinate
37 virtual int ylow() const;
38 /// highest y coordinate
39 virtual int yhigh() const;
43 // Don't use this for AMS validation as long as there is no
44 // user-accessible way to override "false positives"
45 virtual void validate(LaTeXFeatures &) const;
47 virtual InsetOld::Code lyxCode() const;
48 /// what appears in the minibuffer when opening
49 virtual string const editMessage() const;
51 virtual void fitInsetCursor(BufferView *) const;
53 virtual void getCursorPos(BufferView *, int &, int &) const;
54 /// get the absolute document x,y of the cursor
55 virtual void getCursor(BufferView & bv, int & x, int & y) const;
57 virtual void toggleInsetSelection(BufferView * bv);
59 virtual void insetUnlock(BufferView *);
61 /// To allow transparent use of math editing functions
62 virtual dispatch_result localDispatch(FuncRequest const &);
63 /// To allow transparent use of math editing functions
64 //virtual void status(FuncRequest const &);
67 virtual MathAtom const & par() const = 0;
69 virtual MathAtom & par() = 0;
71 // And shouldn't this really return a shared_ptr<BufferView> instead?
72 BufferView * view() const;
75 virtual bool searchForward(BufferView *, string const &,
76 bool = true, bool = false);
78 virtual bool searchBackward(BufferView *, string const &,
79 bool = true, bool = false);
81 virtual bool isTextInset() const { return true; }
83 virtual void mutateToText();
85 virtual void revealCodes(BufferView *) const;
87 virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
90 // return the selection as string
91 string selectionAsString() const;
95 void operator=(const InsetFormulaBase &);
96 /// common base for handling accents
97 void handleAccent(BufferView * bv, string const & arg, string const & name);
99 dispatch_result lfunMousePress(FuncRequest const &);
101 dispatch_result lfunMouseRelease(FuncRequest const &);
103 dispatch_result lfunMouseMotion(FuncRequest const &);
107 //mutable boost::weak_ptr<BufferView> view_;
108 mutable BufferView * view_;
112 void handleFont(BufferView * bv, string const & arg, string const & font);
120 // We don't really mess want around with mathed stuff outside mathed.
122 void mathDispatch(FuncRequest const &);
125 void releaseMathCursor(BufferView * bv);