]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathSideset.h
Fix CSS
[lyx.git] / src / mathed / InsetMathSideset.h
1 // -*- C++ -*-
2 /**
3  * \file InsetMathSideset.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  * \author Georg Baum
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef MATH_SIDESETINSET_H
14 #define MATH_SIDESETINSET_H
15
16 #include "InsetMathNest.h"
17
18
19 namespace lyx {
20
21
22 /// An inset for amsmath \sideset. The 'nucleus' is always cell 0.
23 /// cell(1) is the bottom left index, cell(2) is the top left index,
24 /// cell(3) is the bottom right index, and cell(4) is top right index.
25 class InsetMathSideset : public InsetMathNest {
26 public:
27         ///
28         InsetMathSideset(Buffer * buf, bool scriptl, bool scriptr);
29         /// create inset with given nucleus
30         InsetMathSideset(Buffer * buf, bool scriptl, bool scriptr,
31                          MathAtom const & at);
32         ///
33         mode_type currentMode() const override { return MATH_MODE; }
34         ///
35         void metrics(MetricsInfo & mi, Dimension & dim) const override;
36         ///
37         void draw(PainterInfo & pi, int x, int y) const override;
38         ///
39         void metricsT(TextMetricsInfo const & mi, Dimension & dim) const override;
40         ///
41         void drawT(TextPainter & pi, int x, int y) const override;
42
43         /// move cursor backwards
44         bool idxBackward(Cursor & cur) const override;
45         /// move cursor forward
46         bool idxForward(Cursor & cur) const override;
47         /// move cursor up or down
48         bool idxUpDown(Cursor & cur, bool up) const override;
49         /// The index of the cell entered while moving backward
50         size_type lastIdx() const override { return 0; }
51
52         /// write LaTeX and Lyx code
53         void write(TeXMathStream & os) const override;
54         /// write normalized content
55         void normalize(NormalStream &) const override;
56         /// write content as MathML
57         void mathmlize(MathMLStream &) const override;
58         /// write content as HTML
59         void htmlize(HtmlStream &) const override;
60
61         /// returns nucleus
62         MathData const & nuc() const { return cell(0); }
63         /// returns nucleus
64         MathData & nuc()             { return cell(0); }
65         /// bottom left index or single left cell
66         MathData const & bl() const  { return cell(1); }
67         /// bottom left index or single left cell
68         MathData & bl()              { return cell(1); }
69         /// top left index or single left cell
70         MathData const & tl() const  { return cell(1 + scriptl_); }
71         /// top left index or single left cell
72         MathData & tl()              { return cell(1 + scriptl_); }
73         /// bottom right index or single right cell
74         MathData const & br() const  { return cell(2 + scriptl_); }
75         /// bottom right index or single right cell
76         MathData & br()              { return cell(2 + scriptl_); }
77         /// top right index or single right cell
78         MathData const & tr() const  { return cell(2 + scriptl_ + scriptr_); }
79         /// top right index or single right cell
80         MathData & tr()              { return cell(2 + scriptl_ + scriptr_); }
81         /// say that we have scripts
82         void infoize(odocstream & os) const override;
83         ///
84         InsetCode lyxCode() const override { return MATH_SCRIPT_CODE; }
85         ///
86         void validate(LaTeXFeatures &features) const override;
87 private:
88         Inset * clone() const override;
89         /// returns x offset of nucleus
90         int dxn(BufferView const & bv) const;
91         /// returns width of nucleus if any
92         int nwid(BufferView const &) const;
93         /// returns y offset for either superscript or subscript
94         int dybt(BufferView const &, int asc, int des, bool top) const;
95         /// returns y offset for superscript
96         int dyt(BufferView const &) const;
97         /// returns y offset for subscript
98         int dyb(BufferView const &) const;
99         /// returns x offset for right subscript and superscript
100         int dxr(BufferView const & bv) const;
101         /// returns ascent of nucleus if any
102         int nasc(BufferView const &) const;
103         /// returns descent of nucleus if any
104         int ndes(BufferView const &) const;
105         /// Italic correction as described in InsetMathScript.h
106         int nker(BufferView const * bv) const;
107         /// Whether there are two left scripts or one single cell
108         bool scriptl_;
109         /// Whether there are two right scripts or one single cell
110         bool scriptr_;
111 };
112
113
114 } // namespace lyx
115
116 #endif