]> git.lyx.org Git - lyx.git/blob - src/mathed/formulabase.h
Standardise the header blurb in mathed.
[lyx.git] / src / mathed / formulabase.h
1 // -*- C++ -*-
2 /**
3  * \file formulabase.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  *
11  * Common parts of the math LyX insets.
12  */
13
14 #ifndef INSET_FORMULABASE_H
15 #define INSET_FORMULABASE_H
16
17 #include "insets/updatableinset.h"
18 #include "dimension.h"
19
20 #include <boost/weak_ptr.hpp>
21 #include <iosfwd>
22
23 class Buffer;
24 class BufferView;
25 class MathAtom;
26
27
28 /// An abstract base class for all math related LyX insets
29 class InsetFormulaBase : public UpdatableInset {
30 public:
31         ///
32         InsetFormulaBase();
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;
41
42 public:
43         ///
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;
47         ///
48         virtual InsetOld::Code lyxCode() const;
49         /// what appears in the minibuffer when opening
50         virtual string const editMessage() const;
51         ///
52         virtual void fitInsetCursor(BufferView *) const;
53         /// FIXME
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;
57         ///
58         virtual void toggleInsetSelection(BufferView * bv);
59         ///
60         virtual void insetUnlock(BufferView *);
61
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 &);
66
67         ///
68         virtual MathAtom const & par() const = 0;
69         ///
70         virtual MathAtom & par() = 0;
71         ///
72         // And shouldn't this really return a shared_ptr<BufferView> instead?
73         BufferView * view() const;
74
75         ///
76         virtual bool searchForward(BufferView *, string const &,
77                                    bool = true, bool = false);
78         ///
79         virtual bool searchBackward(BufferView *, string const &,
80                                     bool = true, bool = false);
81         ///
82         virtual bool isTextInset() const { return true; }
83         ///
84         virtual void mutateToText();
85         ///
86         virtual void revealCodes(BufferView *) const;
87         ///
88         virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
89         ///
90         bool display() const;
91         // return the selection as string
92         string selectionAsString() const;
93
94 private:
95         /// unimplemented
96         void operator=(const InsetFormulaBase &);
97         /// common base for handling accents
98         void handleAccent(BufferView * bv, string const & arg, string const & name);
99         /// lfun handler
100         dispatch_result lfunMousePress(FuncRequest const &);
101         ///
102         dispatch_result lfunMouseRelease(FuncRequest const &);
103         ///
104         dispatch_result lfunMouseMotion(FuncRequest const &);
105
106 protected:
107         ///
108         //mutable boost::weak_ptr<BufferView> view_;
109         mutable BufferView * view_;
110
111 protected:
112         ///
113         void handleFont(BufferView * bv, string const & arg, string const & font);
114
115         ///
116         mutable int xo_;
117         ///
118         mutable int yo_;
119 };
120
121 // We don't really mess want around with mathed stuff outside mathed.
122 // So do it here.
123 void mathDispatch(FuncRequest const &);
124
125 ///
126 void releaseMathCursor(BufferView * bv);
127
128 #endif