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"
19 #include <boost/weak_ptr.hpp>
27 /// An abstract base class for all math related LyX insets
28 class InsetFormulaBase : public UpdatableInset {
33 Inset * clone(Buffer const &, bool same_id = false) const = 0;
35 virtual void draw(BufferView *,LyXFont const &, int, float &) const = 0;
36 /// lowest x coordinate
37 virtual int xlow() const;
38 /// highest x coordinate
39 virtual int xhigh() const;
40 /// lowest y coordinate
41 virtual int ylow() const;
42 /// highest y coordinate
43 virtual int yhigh() const;
47 // Don't use this for AMS validation as long as there is no
48 // user-accessible way to override "false positives"
49 virtual void validate(LaTeXFeatures &) const;
51 virtual Inset::Code lyxCode() const;
52 /// what appears in the minibuffer when opening
53 virtual string const editMessage() const;
55 virtual void fitInsetCursor(BufferView *) const;
57 virtual void getCursorPos(BufferView *, int &, int &) const;
58 /// get the absolute document x,y of the cursor
59 virtual void getCursor(BufferView & bv, int & x, int & y) const;
61 virtual void toggleInsetSelection(BufferView * bv);
63 virtual void insetUnlock(BufferView *);
65 /// To allow transparent use of math editing functions
66 virtual dispatch_result localDispatch(FuncRequest const &);
67 /// To allow transparent use of math editing functions
68 //virtual void status(FuncRequest const &);
71 virtual std::vector<string> const getLabelList() const;
73 virtual MathAtom const & par() const = 0;
75 virtual MathAtom & par() = 0;
77 // And shouldn't this really return a shared_ptr<BufferView> instead?
78 BufferView * view() const;
81 virtual bool searchForward(BufferView *, string const &,
82 bool = true, bool = false);
84 virtual bool searchBackward(BufferView *, string const &,
85 bool = true, bool = false);
87 virtual bool isTextInset() const { return true; }
89 virtual void mutateToText();
91 virtual void revealCodes(BufferView *) const;
93 virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
96 // return the selection as string
97 string selectionAsString() const;
101 void operator=(const InsetFormulaBase &);
102 /// common base for handling accents
103 void handleAccent(BufferView * bv, string const & arg, string const & name);
105 dispatch_result lfunMousePress(FuncRequest const &);
107 dispatch_result lfunMouseRelease(FuncRequest const &);
109 dispatch_result lfunMouseMotion(FuncRequest const &);
113 mutable boost::weak_ptr<BufferView> view_;
115 mutable LyXFont font_;
119 void metrics(BufferView * bv, LyXFont const & font) const;
121 void metrics(BufferView * bv = 0) const;
123 void handleFont(BufferView * bv, string const & arg, string const & font);
131 // We don't really mess want around with mathed stuff outside mathed.
133 void mathDispatch(FuncRequest const &);
136 void releaseMathCursor(BufferView * bv);