3 * \file InsetMathSideset.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
10 * Full author contact details are available in file CREDITS.
13 #ifndef MATH_SIDESETINSET_H
14 #define MATH_SIDESETINSET_H
16 #include "InsetMathNest.h"
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 {
28 InsetMathSideset(Buffer * buf);
29 /// create inset with given nucleus
30 InsetMathSideset(Buffer * buf, MathAtom const & at);
32 mode_type currentMode() const { return MATH_MODE; }
34 void metrics(MetricsInfo & mi, Dimension & dim) const;
36 void draw(PainterInfo & pi, int x, int y) const;
38 void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
40 void drawT(TextPainter & pi, int x, int y) const;
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;
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;
63 MathData const & nuc() const { return cell(0); };
65 MathData & nuc() { return cell(0); };
67 MathData const & bl() const { return cell(1); }
69 MathData & bl() { return cell(1); }
71 MathData const & tl() const { return cell(2); }
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); }
79 MathData const & tr() const { return cell(4); }
81 MathData & tr() { return cell(4); }
82 /// say that we have scripts
83 void infoize(odocstream & os) const;
85 InsetCode lyxCode() const { return MATH_SCRIPT_CODE; }
87 void validate(LaTeXFeatures &features) const;
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;