2 * \file InsetMathTextsize.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Enrico Forestieri
8 * Full author contact details are available in file CREDITS.
13 #include "InsetMathTextsize.h"
16 #include "MathParser.h"
17 #include "MathStream.h"
18 #include "MathSupport.h"
19 #include "MetricsInfo.h"
21 #include "support/gettext.h"
22 #include "support/lassert.h"
23 #include "support/lstrings.h"
27 using namespace lyx::support;
31 InsetMathTextsize::InsetMathTextsize(Buffer * buf, latexkeys const * key)
32 : InsetMathNest(buf, 1), key_(key), current_mode_(TEXT_MODE)
37 Inset * InsetMathTextsize::clone() const
39 return new InsetMathTextsize(*this);
43 void InsetMathTextsize::metrics(MetricsInfo & mi, Dimension & dim) const
45 current_mode_ = isTextFont(mi.base.fontname) ? TEXT_MODE : MATH_MODE;
47 // size changing commands are noops in math mode
48 bool mathmode = current_mode_ == MATH_MODE;
50 Changer dummy = mi.base.changeFontSize(to_ascii(key_->name), mathmode);
51 cell(0).metrics(mi, dim);
55 void InsetMathTextsize::draw(PainterInfo & pi, int x, int y) const
57 current_mode_ = isTextFont(pi.base.fontname) ? TEXT_MODE : MATH_MODE;
59 // size changing commands are noops in math mode
60 bool mathmode = current_mode_ == MATH_MODE;
62 Changer dummy = pi.base.changeFontSize(to_ascii(key_->name), mathmode);
63 cell(0).draw(pi, x, y);
67 void InsetMathTextsize::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
69 cell(0).metricsT(mi, dim);
73 void InsetMathTextsize::drawT(TextPainter & pain, int x, int y) const
75 cell(0).drawT(pain, x, y);
79 void InsetMathTextsize::write(TeXMathStream & os) const
81 os << "{\\" << key_->name << ' ' << cell(0) << '}';
85 void InsetMathTextsize::normalize(NormalStream & os) const
87 os << "[size " << key_->name << ' ' << cell(0) << ']';
91 void InsetMathTextsize::infoize(odocstream & os) const
93 os << bformat(_("Size: %1$s"), key_->name);