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