]> git.lyx.org Git - features.git/blob - src/mathed/InsetMathSideset.h
Fix bug #1424: Native \sideset inset
[features.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);
29         /// create inset with given nucleus
30         InsetMathSideset(Buffer * buf, MathAtom const & at);
31         ///
32         mode_type currentMode() const { return MATH_MODE; }
33         ///
34         void metrics(MetricsInfo & mi, Dimension & dim) const;
35         ///
36         void draw(PainterInfo & pi, int x, int y) const;
37         ///
38         void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
39         ///
40         void drawT(TextPainter & pi, int x, int y) const;
41
42         /// move cursor backwards
43         bool idxBackward(Cursor & cur) const;
44         /// move cursor forward
45         bool idxForward(Cursor & cur) const;
46         /// move cursor up or down
47         bool idxUpDown(Cursor & cur, bool up) const;
48         /// Target pos when we enter the inset while moving forward
49         bool idxFirst(Cursor & cur) const;
50         /// Target pos when we enter the inset while moving backwards
51         bool idxLast(Cursor & cur) const;
52
53         /// write LaTeX and Lyx code
54         void write(WriteStream & os) const;
55         /// write normalized content
56         void normalize(NormalStream &) const;
57         /// write content as MathML
58         void mathmlize(MathStream &) const;
59         /// write content as HTML
60         void htmlize(HtmlStream &) const;
61
62         /// returns nucleus
63         MathData const & nuc() const { return cell(0); };
64         /// returns nucleus
65         MathData & nuc()             { return cell(0); };
66         /// bottom left index
67         MathData const & bl() const  { return cell(1); }
68         /// bottom left index
69         MathData & bl()              { return cell(1); }
70         /// top left index
71         MathData const & tl() const  { return cell(2); }
72         /// top left index
73         MathData & tl()              { return cell(2); }
74         /// bottom right index
75         MathData const & br() const  { return cell(3); }
76         /// bottom right index
77         MathData & br()              { return cell(3); }
78         /// top right index
79         MathData const & tr() const  { return cell(4); }
80         /// top right index
81         MathData & tr()              { return cell(4); }
82         /// say that we have scripts
83         void infoize(odocstream & os) const;
84         ///
85         InsetCode lyxCode() const { return MATH_SCRIPT_CODE; }
86         ///
87         void validate(LaTeXFeatures &features) const;
88 private:
89         virtual Inset * clone() const;
90         /// returns x offset of nucleus
91         int dxn(BufferView const & bv) const;
92         /// returns width of nucleus if any
93         int nwid(BufferView const &) const;
94         /// returns y offset for either superscript or subscript
95         int dybt(BufferView const &, int asc, int des, bool top) const;
96         /// returns y offset for superscript
97         int dyt(BufferView const &) const;
98         /// returns y offset for subscript
99         int dyb(BufferView const &) const;
100         /// returns x offset for right subscript and superscript
101         int dxr(BufferView const & bv) const;
102         /// returns ascent of nucleus if any
103         int nasc(BufferView const &) const;
104         /// returns descent of nucleus if any
105         int ndes(BufferView const &) const;
106         /// returns subscript and superscript kerning of nucleus if any
107         int nker(BufferView const * bv) const;
108 };
109
110
111 } // namespace lyx
112
113 #endif