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, bool scriptl, bool scriptr);
29 /// create inset with given nucleus
30 InsetMathSideset(Buffer * buf, bool scriptl, bool scriptr,
33 mode_type currentMode() const { return MATH_MODE; }
35 void metrics(MetricsInfo & mi, Dimension & dim) const;
37 void draw(PainterInfo & pi, int x, int y) const;
39 void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
41 void drawT(TextPainter & pi, int x, int y) const;
43 /// move cursor backwards
44 bool idxBackward(Cursor & cur) const;
45 /// move cursor forward
46 bool idxForward(Cursor & cur) const;
47 /// move cursor up or down
48 bool idxUpDown(Cursor & cur, bool up) const;
49 /// The index of the cell entered while moving backward
50 size_type lastIdx() const { return 0; }
52 /// write LaTeX and Lyx code
53 void write(WriteStream & os) const;
54 /// write normalized content
55 void normalize(NormalStream &) const;
56 /// write content as MathML
57 void mathmlize(MathStream &) const;
58 /// write content as HTML
59 void htmlize(HtmlStream &) const;
62 MathData const & nuc() const { return cell(0); }
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;
84 InsetCode lyxCode() const { return MATH_SCRIPT_CODE; }
86 void validate(LaTeXFeatures &features) const;
88 virtual Inset * clone() const;
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
109 /// Whether there are two right scripts or one single cell