]> git.lyx.org Git - lyx.git/blob - src/insets/InsetScript.h
Use new rowFlags() values to remove some inset hardcoding.
[lyx.git] / src / insets / InsetScript.h
1 // -*- C++ -*-
2 /**
3  * \file InsetScript.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Georg Baum
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_SCRIPT_H
13 #define INSET_SCRIPT_H
14
15 #include "InsetText.h"
16
17
18 namespace lyx {
19
20 class InsetScriptParams
21 {
22 public:
23         enum Type {
24                 Subscript,
25                 Superscript
26         };
27         /// \c type defaults to Subscript
28         InsetScriptParams();
29         ///
30         void write(std::ostream & os) const;
31         ///
32         void read(Lexer & lex);
33         ///
34         int shift(FontInfo const & font) const;
35         ///
36         Type type;
37 };
38
39
40 /////////////////////////////////////////////////////////////////////////
41 //
42 // InsetScript
43 //
44 /////////////////////////////////////////////////////////////////////////
45
46 /// The subscript and superscript inset
47 class InsetScript : public InsetText
48 {
49 public:
50         ///
51         InsetScript(Buffer *, InsetScriptParams const & = InsetScriptParams());
52         ///
53         InsetScript(Buffer *, std::string const &);
54         ///
55         ~InsetScript();
56         ///
57         static std::string params2string(InsetScriptParams const &);
58         ///
59         static void string2params(std::string const &, InsetScriptParams &);
60         ///
61         InsetScriptParams const & params() const { return params_; }
62
63         /// \name Public functions inherited from Inset class
64         //@{
65         ///
66         InsetCode lyxCode() const { return SCRIPT_CODE; }
67         ///
68         docstring layoutName() const;
69
70         ///
71         int topOffset(BufferView const *) const { return 0; }
72         ///
73         int bottomOffset(BufferView const *) const { return 0; }
74         ///
75         int leftOffset(BufferView const *) const { return 0; }
76         ///
77         int rightOffset(BufferView const *) const { return 0; }
78
79         ///
80         void metrics(MetricsInfo &, Dimension &) const;
81         ///
82         void draw(PainterInfo & pi, int x, int y) const;
83         ///
84         void cursorPos(BufferView const & bv,
85                 CursorSlice const & sl, bool boundary, int & x, int & y) const;
86         ///
87         void write(std::ostream &) const;
88         ///
89         void read(Lexer & lex);
90         ///
91         bool forcePlainLayout(idx_type = 0) const { return true; }
92         ///
93         bool allowParagraphCustomization(idx_type = 0) const { return false; }
94         ///
95         bool neverIndent() const { return true; }
96         ///
97         bool inheritFont() const { return true; }
98         ///
99         int plaintext(odocstringstream & ods, OutputParams const & op,
100                       size_t max_length = INT_MAX) const;
101         ///
102         int docbook(odocstream &, OutputParams const &) const;
103         ///
104         void edit(Cursor & cur, bool front,
105                   EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
106         ///
107         Inset * editXY(Cursor & cur, int x, int y);
108         ///
109         bool insetAllowed(InsetCode code) const;
110         ///
111         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
112         ///
113         docstring toolTip(BufferView const & bv, int x, int y) const;
114         ///
115         Inset * clone() const { return new InsetScript(*this); }
116         ///
117         std::string contextMenuName() const;
118         //@}
119
120         /// \name Public functions inherited from InsetText class
121         //@{
122         ///
123         bool allowMultiPar() const { return false; }
124         //@}
125
126 protected:
127         /// \name Protected functions inherited from Inset class
128         //@{
129         ///
130         void doDispatch(Cursor & cur, FuncRequest & cmd);
131         //@}
132
133 private:
134         /// used by the constructors
135         void init();
136         ///
137         friend class InsetScriptParams;
138         ///
139         InsetScriptParams params_;
140         /// The font of containing inset; this is necessary to compute shift
141         mutable FontInfo outer_font_;
142 };
143
144
145 } // namespace lyx
146
147 #endif