]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathTFrac.cpp
Rename .C ==> .cpp for files in src/support, part two
[lyx.git] / src / mathed / InsetMathTFrac.cpp
1 /**
2  * \file InsetMathDFrac.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetMathTFrac.h"
14
15 #include "MathArray.h"
16 #include "MathStream.h"
17
18 #include "LaTeXFeatures.h"
19 #include "LColor.h"
20
21 #include "frontends/Painter.h"
22
23
24 namespace lyx {
25
26
27 using std::string;
28 using std::max;
29 using std::auto_ptr;
30
31
32 InsetMathTFrac::InsetMathTFrac()
33         : InsetMathFrac()
34 {}
35
36
37 auto_ptr<InsetBase> InsetMathTFrac::doClone() const
38 {
39         return auto_ptr<InsetBase>(new InsetMathTFrac(*this));
40 }
41
42
43 bool InsetMathTFrac::metrics(MetricsInfo & mi, Dimension & dim) const
44 {
45         StyleChanger dummy(mi.base, LM_ST_SCRIPT);
46         cell(0).metrics(mi);
47         cell(1).metrics(mi);
48         dim.wid = max(cell(0).width(), cell(1).width()) + 2;
49         dim.asc = cell(0).height() + 2 + 5;
50         dim.des = cell(1).height() + 2 - 5;
51         if (dim_ == dim)
52                 return false;
53         dim_ = dim;
54         return true;
55 }
56
57
58 void InsetMathTFrac::draw(PainterInfo & pi, int x, int y) const
59 {
60         StyleChanger dummy(pi.base, LM_ST_SCRIPT);
61         int m = x + dim_.wid / 2;
62         cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 2 - 5);
63         cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent()  + 2 - 5);
64         pi.pain.line(x + 1, y - 5, x + dim_.wid - 2, y - 5, LColor::math);
65         setPosCache(pi, x, y);
66 }
67
68
69 docstring InsetMathTFrac::name() const
70 {
71         return from_ascii("tfrac");
72 }
73
74
75 void InsetMathTFrac::mathmlize(MathStream & os) const
76 {
77         os << MTag("mtfrac") << cell(0) << cell(1) << ETag("mtfrac");
78 }
79
80
81 void InsetMathTFrac::validate(LaTeXFeatures & features) const
82 {
83         features.require("amsmath");
84         InsetMathNest::validate(features);
85 }
86
87
88 } // namespace lyx