X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathBig.cpp;h=889f8d4f97842e2e926a43fca3e2272e15a0da96;hb=59fa0b25928b43c8d32d19a6193dc3bd07716947;hp=634d5f3ce9d76a426ecdd8faa47630b26437d975;hpb=ed858d73e57ce7aa89e38c1bc4d799362edb0227;p=lyx.git diff --git a/src/mathed/InsetMathBig.cpp b/src/mathed/InsetMathBig.cpp index 634d5f3ce9..889f8d4f97 100644 --- a/src/mathed/InsetMathBig.cpp +++ b/src/mathed/InsetMathBig.cpp @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author André Pönitz + * \author André Pönitz * * Full author contact details are available in file CREDITS. */ @@ -11,12 +11,17 @@ #include #include "InsetMathBig.h" + +#include "Dimension.h" +#include "LaTeXFeatures.h" + #include "MathSupport.h" #include "MathStream.h" -#include "MathStream.h" +#include "MetricsInfo.h" #include "frontends/FontMetrics.h" +#include "support/docstream.h" #include "support/lstrings.h" @@ -34,6 +39,25 @@ docstring InsetMathBig::name() const } +MathClass InsetMathBig::mathClass() const +{ + /* The class of the delimiter depends on the type (l, m, r, nothing). + * For example, the definition of \bigl in LaTeX sources is + * \def\bigl{\mathopen\big} + */ + switch(name_.back()) { + case 'l': + return MC_OPEN; + case 'm': + return MC_REL; + case 'r': + return MC_CLOSE; + default: + return MC_ORD; + } +} + + Inset * InsetMathBig::clone() const { return new InsetMathBig(*this); @@ -44,9 +68,11 @@ InsetMathBig::size_type InsetMathBig::size() const { // order: big Big bigg Bigg biggg Biggg // 0 1 2 3 4 5 - return name_[0] == 'B' ? - 2 * (name_.size() - 4) + 1: - 2 * (name_.size() - 4); + char_type const c = name_.back(); + int const base_size = (c == 'l' || c == 'm' || c == 'r') ? 4 : 3; + return name_.front() == 'B' ? + 2 * (name_.size() - base_size) + 1: + 2 * (name_.size() - base_size); } @@ -60,36 +86,43 @@ double InsetMathBig::increase() const } -bool InsetMathBig::metrics(MetricsInfo & mi, Dimension & dim) const +void InsetMathBig::metrics(MetricsInfo & mi, Dimension & dim) const { + Changer dummy = mi.base.changeEnsureMath(); double const h = theFontMetrics(mi.base.font).ascent('I'); double const f = increase(); dim.wid = 6; dim.asc = int(h + f * h); dim.des = int(f * h); - if (dim_ == dim) - return false; - dim_ = dim; - return true; } -void InsetMathBig::draw(PainterInfo & pi, int x, int y) const +docstring InsetMathBig::word() const { // mathed_draw_deco does not use the leading backslash, so remove it // (but don't use ltrim if this is the backslash delimiter). // Replace \| by \Vert (equivalent in LaTeX), since mathed_draw_deco // would treat it as |. - docstring const delim = (delim_ == "\\|") ? from_ascii("Vert") : - (delim_ == "\\\\") ? from_ascii("\\") : support::ltrim(delim_, "\\"); - mathed_draw_deco(pi, x + 1, y - dim_.ascent(), 4, dim_.height(), - delim); - setPosCache(pi, x, y); + if (delim_ == "\\|") + return from_ascii("Vert"); + if (delim_ == "\\\\") + return from_ascii("\\"); + return support::ltrim(delim_, "\\"); +} + + +void InsetMathBig::draw(PainterInfo & pi, int x, int y) const +{ + Changer dummy = pi.base.changeEnsureMath(); + Dimension const dim = dimension(*pi.base.bv); + mathed_draw_deco(pi, x + 1, y - dim.ascent(), 4, dim.height(), + word()); } void InsetMathBig::write(WriteStream & os) const { + MathEnsurer ensurer(os); os << '\\' << name_ << delim_; if (delim_[0] == '\\') os.pendingSpace(true); @@ -102,6 +135,29 @@ void InsetMathBig::normalize(NormalStream & os) const } +void InsetMathBig::mathmlize(MathStream & os) const +{ + os << "" + << convertDelimToXMLEscape(delim_) + << ""; +} + + +void InsetMathBig::htmlize(HtmlStream & os) const +{ + std::string name; + switch (size()) { + case 0: case 1: name = "big"; break; + case 2: case 3: name = "bigg"; break; + case 4: case 5: name = "biggg"; break; + default: name = "big"; break; + } + os << MTag("span", "class='" + name + "symbol'") + << convertDelimToXMLEscape(delim_) + << ETag("span"); +} + + void InsetMathBig::infoize2(odocstream & os) const { os << name_; @@ -114,9 +170,10 @@ bool InsetMathBig::isBigInsetDelim(docstring const & delim) static char const * const delimiters[] = { "(", ")", "\\{", "\\}", "\\lbrace", "\\rbrace", "[", "]", "|", "/", "\\slash", "\\|", "\\vert", "\\Vert", "'", - "\\\\", "\\backslash", + "<", ">", "\\\\", "\\backslash", "\\langle", "\\lceil", "\\lfloor", "\\rangle", "\\rceil", "\\rfloor", + "\\llbracket", "\\rrbracket", "\\downarrow", "\\Downarrow", "\\uparrow", "\\Uparrow", "\\updownarrow", "\\Updownarrow", "" @@ -125,4 +182,15 @@ bool InsetMathBig::isBigInsetDelim(docstring const & delim) } +void InsetMathBig::validate(LaTeXFeatures & features) const +{ + validate_math_word(features, word()); + if (features.runparams().math_flavor == OutputParams::MathAsHTML) + features.addCSSSnippet( + "span.bigsymbol{font-size: 150%;}\n" + "span.biggsymbol{font-size: 200%;}\n" + "span.bigggsymbol{font-size: 225%;}"); +} + + } // namespace lyx