]> git.lyx.org Git - lyx.git/blob - src/mathed/formulabase.h
ws changes only
[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 <boost/weak_ptr.hpp>
19
20
21 class Buffer;
22 class BufferView;
23 class MathAtom;
24
25
26 /// An abstract base class for all math related LyX insets
27 class InsetFormulaBase : public UpdatableInset {
28 public:
29         ///
30         InsetFormulaBase();
31         /// lowest x coordinate
32         virtual int xlow() const;
33         /// highest x coordinate
34         virtual int xhigh() const;
35         /// lowest y coordinate
36         virtual int ylow() const;
37         /// highest y coordinate
38         virtual int yhigh() const;
39
40 public:
41         ///
42         // Don't use this for AMS validation as long as there is no
43         // user-accessible way to override "false positives"
44         virtual void validate(LaTeXFeatures &) const;
45         ///
46         virtual InsetOld::Code lyxCode() const;
47         /// what appears in the minibuffer when opening
48         virtual std::string const editMessage() const;
49         ///
50         virtual void fitInsetCursor(BufferView *) const;
51         /// FIXME
52         virtual void getCursorPos(BufferView *, int &, int &) const;
53         /// get the absolute document x,y of the cursor
54         virtual void getCursor(BufferView & bv, int & x, int & y) const;
55         ///
56         virtual void toggleInsetSelection(BufferView * bv);
57         ///
58         virtual void insetUnlock(BufferView *);
59
60         /// To allow transparent use of math editing functions
61         virtual dispatch_result localDispatch(FuncRequest const &);
62         /// To allow transparent use of math editing functions
63         //virtual void status(FuncRequest const &);
64
65         ///
66         virtual MathAtom const & par() const = 0;
67         ///
68         virtual MathAtom & par() = 0;
69         ///
70         ///
71         virtual bool searchForward(BufferView *, std::string const &,
72                                    bool = true, bool = false);
73         ///
74         virtual bool searchBackward(BufferView *, std::string const &,
75                                     bool = true, bool = false);
76         ///
77         virtual bool isTextInset() const { return true; }
78         ///
79         virtual void mutateToText();
80         ///
81         virtual void revealCodes(BufferView *) const;
82         ///
83         virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
84         ///
85         bool display() const;
86         // return the selection as std::string
87         std::string selectionAsString() const;
88
89 private:
90         /// unimplemented
91         void operator=(const InsetFormulaBase &);
92         /// common base for handling accents
93         void handleAccent(BufferView * bv, std::string const & arg, std::string const & name);
94         /// lfun handler
95         dispatch_result lfunMousePress(FuncRequest const &);
96         ///
97         dispatch_result lfunMouseRelease(FuncRequest const &);
98         ///
99         dispatch_result lfunMouseMotion(FuncRequest const &);
100
101 protected:
102         void cache(BufferView *) const;
103         BufferView * view() const;
104
105 protected:
106
107         /** Find the PreviewLoader, add a LaTeX snippet to it and
108          *  start the loading process.
109          *
110          *  Most insets have no interest in this capability, so the method
111          *  defaults to empty.
112          */
113         virtual void generatePreview(Buffer const &) const {}
114
115         ///
116         void handleFont(BufferView * bv, std::string const & arg, std::string const & font);
117         ///
118         void handleFont2(BufferView * bv, std::string const & arg);
119
120         ///
121         mutable int xo_;
122         ///
123         mutable int yo_;
124 private:
125         // Cache
126         mutable boost::weak_ptr<BufferView> view_;
127 };
128
129 // We don't really mess want around with mathed stuff outside mathed.
130 // So do it here.
131 void mathDispatch(FuncRequest const &);
132
133 ///
134 void releaseMathCursor(BufferView * bv);
135
136 #endif