]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathTextsize.cpp
Limit the nopassthurchars case in beamer to URL
[lyx.git] / src / mathed / InsetMathTextsize.cpp
1 /**
2  * \file InsetMathTextsize.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Enrico Forestieri
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetMathTextsize.h"
14
15 #include "MathData.h"
16 #include "MathParser.h"
17 #include "MathStream.h"
18 #include "MathSupport.h"
19 #include "MetricsInfo.h"
20
21 #include "support/gettext.h"
22 #include "support/lassert.h"
23 #include "support/lstrings.h"
24
25 #include <ostream>
26
27 using namespace lyx::support;
28
29 namespace lyx {
30
31 InsetMathTextsize::InsetMathTextsize(Buffer * buf, latexkeys const * key)
32         : InsetMathNest(buf, 1), key_(key), current_mode_(TEXT_MODE)
33 {
34 }
35
36
37 Inset * InsetMathTextsize::clone() const
38 {
39         return new InsetMathTextsize(*this);
40 }
41
42
43 void InsetMathTextsize::metrics(MetricsInfo & mi, Dimension & dim) const
44 {
45         current_mode_ = isTextFont(mi.base.fontname) ? TEXT_MODE : MATH_MODE;
46
47         // size changing commands are noops in math mode
48         bool mathmode = current_mode_ == MATH_MODE;
49
50         Changer dummy = mi.base.changeFontSize(to_ascii(key_->name), mathmode);
51         cell(0).metrics(mi, dim);
52 }
53
54
55 void InsetMathTextsize::draw(PainterInfo & pi, int x, int y) const
56 {
57         current_mode_ = isTextFont(pi.base.fontname) ? TEXT_MODE : MATH_MODE;
58
59         // size changing commands are noops in math mode
60         bool mathmode = current_mode_ == MATH_MODE;
61
62         Changer dummy = pi.base.changeFontSize(to_ascii(key_->name), mathmode);
63         cell(0).draw(pi, x, y);
64 }
65
66
67 void InsetMathTextsize::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
68 {
69         cell(0).metricsT(mi, dim);
70 }
71
72
73 void InsetMathTextsize::drawT(TextPainter & pain, int x, int y) const
74 {
75         cell(0).drawT(pain, x, y);
76 }
77
78
79 void InsetMathTextsize::write(TeXMathStream & os) const
80 {
81         os << "{\\" << key_->name << ' ' << cell(0) << '}';
82 }
83
84
85 void InsetMathTextsize::normalize(NormalStream & os) const
86 {
87         os << "[size " << key_->name << ' ' << cell(0) << ']';
88 }
89
90
91 void InsetMathTextsize::infoize(odocstream & os) const
92 {
93         os << bformat(_("Size: %1$s"), key_->name);
94 }
95
96
97 } // namespace lyx