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 &) const = 0;
35 //Inset * clone(Buffer const &, bool same_id) const = 0;
37 virtual void draw(BufferView *,LyXFont const &, int, float &) const = 0;
38 /// lowest x coordinate
39 virtual int xlow() const;
40 /// highest x coordinate
41 virtual int xhigh() const;
42 /// lowest y coordinate
43 virtual int ylow() const;
44 /// highest y coordinate
45 virtual int yhigh() const;
49 // Don't use this for AMS validation as long as there is no
50 // user-accessible way to override "false positives"
51 virtual void validate(LaTeXFeatures &) const;
53 virtual Inset::Code lyxCode() const;
54 /// what appears in the minibuffer when opening
55 virtual string const editMessage() const;
57 virtual void fitInsetCursor(BufferView *) const;
59 virtual void getCursorPos(BufferView *, int &, int &) const;
60 /// get the absolute document x,y of the cursor
61 virtual void getCursor(BufferView & bv, int & x, int & y) const;
63 virtual void toggleInsetSelection(BufferView * bv);
65 virtual void insetUnlock(BufferView *);
67 /// To allow transparent use of math editing functions
68 virtual dispatch_result localDispatch(FuncRequest const &);
69 /// To allow transparent use of math editing functions
70 //virtual void status(FuncRequest const &);
73 virtual std::vector<string> const getLabelList() const;
75 virtual MathAtom const & par() const = 0;
77 virtual MathAtom & par() = 0;
79 // And shouldn't this really return a shared_ptr<BufferView> instead?
80 BufferView * view() const;
83 virtual bool searchForward(BufferView *, string const &,
84 bool = true, bool = false);
86 virtual bool searchBackward(BufferView *, string const &,
87 bool = true, bool = false);
89 virtual bool isTextInset() const { return true; }
91 virtual void mutateToText();
93 virtual void revealCodes(BufferView *) const;
95 virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
98 // return the selection as string
99 string selectionAsString() const;
103 void operator=(const InsetFormulaBase &);
104 /// common base for handling accents
105 void handleAccent(BufferView * bv, string const & arg, string const & name);
107 dispatch_result lfunMousePress(FuncRequest const &);
109 dispatch_result lfunMouseRelease(FuncRequest const &);
111 dispatch_result lfunMouseMotion(FuncRequest const &);
115 mutable boost::weak_ptr<BufferView> view_;
117 mutable LyXFont font_;
121 void metrics(BufferView * bv, LyXFont const & font, Dimension & dim) const;
123 void metrics(BufferView * bv = 0) const;
125 void handleFont(BufferView * bv, string const & arg, string const & font);
133 // We don't really mess want around with mathed stuff outside mathed.
135 void mathDispatch(FuncRequest const &);
138 void releaseMathCursor(BufferView * bv);