]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathHull.cpp
Fix creationCode() of GuiPrintNomencl
[lyx.git] / src / mathed / InsetMathHull.cpp
index 3c72f4d6bda52e5e25a939cc658159f3165d4e04..0a7ddd6d005858caa476ba2c5e7dea6899f102bf 100644 (file)
@@ -35,8 +35,8 @@
 #include "LaTeXFeatures.h"
 #include "LyXRC.h"
 #include "MacroTable.h"
-#include "MathMacro.h"
-#include "MathMacroTemplate.h"
+#include "InsetMathMacro.h"
+#include "InsetMathMacroTemplate.h"
 #include "MetricsInfo.h"
 #include "output_xhtml.h"
 #include "Paragraph.h"
@@ -126,14 +126,14 @@ namespace {
                if (os.strikeoutMath()) {
                        if (os.ulemCmd() == WriteStream::UNDERLINE)
                                os << "\\raisebox{-\\belowdisplayshortskip}{"
-                                     "\\lyxmathsout{\\parbox[b]{\\columnwidth}{";
+                                     "\\lyxmathsout{\\parbox[b]{\\linewidth}{";
                        else
-                               os << "\\lyxmathsout{\\parbox{\\columnwidth}{";
+                               os << "\\lyxmathsout{\\parbox{\\linewidth}{";
                } else if (os.ulemCmd() == WriteStream::UNDERLINE)
                        os << "\\raisebox{-\\belowdisplayshortskip}{"
-                             "\\parbox[b]{\\columnwidth}{";
+                             "\\parbox[b]{\\linewidth}{";
                else if (os.ulemCmd() == WriteStream::STRIKEOUT)
-                       os << "\\parbox{\\columnwidth}{";
+                       os << "\\parbox{\\linewidth}{";
        }
 
 
@@ -151,7 +151,7 @@ namespace {
        }
 
 
-} // end anon namespace
+} // namespace
 
 
 HullType hullType(docstring const & s)
@@ -280,7 +280,7 @@ void InsetMathHull::setBuffer(Buffer & buffer)
 namespace {
        const char * counters_to_save[] = {"section", "chapter"};
        unsigned int const numcnts = sizeof(counters_to_save)/sizeof(char *);
-}
+} // namespace
 
 
 void InsetMathHull::updateBuffer(ParIterator const & it, UpdateType utype)
@@ -570,13 +570,6 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
 
        // reserve some space for marker.
        dim.wid += 2;
-
-       // make it at least as high as the current font
-       int asc = 0;
-       int des = 0;
-       math_font_max_dim(mi.base.font, asc, des);
-       dim.asc = max(dim.asc, asc);
-       dim.des = max(dim.des, des);
 }
 
 
@@ -599,6 +592,25 @@ ColorCode InsetMathHull::backgroundColor(PainterInfo const & pi) const
 }
 
 
+void InsetMathHull::drawMarkers(PainterInfo & pi, int x, int y) const
+{
+       ColorCode pen_color = mouseHovered(pi.base.bv) || editing(pi.base.bv)?
+               Color_mathframe : Color_mathcorners;
+       // If the corners have the same color as the background, do not paint them.
+       if (lcolor.getX11Name(Color_mathbg) == lcolor.getX11Name(pen_color))
+               return;
+
+       Inset::drawMarkers(pi, x, y);
+       Dimension const dim = dimension(*pi.base.bv);
+       int const t = x + dim.width() - 1;
+       int const a = y - dim.ascent();
+       pi.pain.line(x, a + 3, x, a, pen_color);
+       pi.pain.line(t, a + 3, t, a, pen_color);
+       pi.pain.line(x, a, x + 3, a, pen_color);
+       pi.pain.line(t - 3, a, t, a, pen_color);
+}
+
+
 void InsetMathHull::drawBackground(PainterInfo & pi, int x, int y) const
 {
        Dimension const dim = dimension(*pi.base.bv);
@@ -659,7 +671,7 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
        }
 
        InsetMathGrid::draw(pi, xmath + 1, y);
-       drawMarkers2(pi, x, y);
+       drawMarkers(pi, x, y);
 
        if (numberedType()) {
                Changer dummy = pi.base.changeFontSet("mathrm");
@@ -752,8 +764,8 @@ void InsetMathHull::usedMacros(MathData const & md, DocIterator const & pos,
        MacroNameSet::iterator const end = macros.end();
 
        for (size_t i = 0; i < md.size(); ++i) {
-               MathMacro const * mi = md[i].nucleus()->asMacro();
-               MathMacroTemplate const * mt = md[i].nucleus()->asMacroTemplate();
+               InsetMathMacro const * mi = md[i].nucleus()->asMacro();
+               InsetMathMacroTemplate const * mt = md[i].nucleus()->asMacroTemplate();
                InsetMathScript const * si = md[i].nucleus()->asScriptInset();
                InsetMathFracBase const * fi = md[i].nucleus()->asFracBaseInset();
                InsetMathGrid const * gi = md[i].nucleus()->asGridInset();
@@ -1026,7 +1038,7 @@ int InsetMathHull::indent(BufferView const & bv) const
 {
        // FIXME: set this in the textclass. This value is what the article class uses.
        static Length default_indent(2.5, Length::EM);
-       if (buffer().params().is_math_indent) {
+       if (display() != Inline && buffer().params().is_math_indent) {
                Length const & len = buffer().params().getMathIndent();
                if (len.empty())
                        return bv.inPixels(default_indent);
@@ -2020,7 +2032,7 @@ bool allowDisplayMath(Cursor const & cur)
        return tmpcur.getStatus(cmd, status) && status.enabled();
 }
 
-}
+} // namespace
 
 
 bool InsetMathHull::getStatus(Cursor & cur, FuncRequest const & cmd,
@@ -2248,7 +2260,7 @@ void InsetMathHull::revealCodes(Cursor & cur) const
        if (!cur.inMathed())
                return;
        odocstringstream os;
-       cur.info(os);
+       cur.info(os, false);
        cur.message(os.str());
 /*
        // write something to the minibuffer