X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathSpace.cpp;h=f4c4d25f1ce117ab5fdbe58df7b9e7b0ea3109a2;hb=dc976c2b6f6e1f19ee4d884c12abafbdae9e5126;hp=2a3b6f45cb477657a4e988da12b4991e14d0be46;hpb=9c55af4a223ce4db29d643251109e245665344bd;p=lyx.git diff --git a/src/mathed/InsetMathSpace.cpp b/src/mathed/InsetMathSpace.cpp index 2a3b6f45cb..f4c4d25f1c 100644 --- a/src/mathed/InsetMathSpace.cpp +++ b/src/mathed/InsetMathSpace.cpp @@ -21,6 +21,7 @@ #include "FuncRequest.h" #include "FuncStatus.h" #include "LaTeXFeatures.h" +#include "MetricsInfo.h" #include "insets/InsetSpace.h" @@ -74,7 +75,7 @@ SpaceInfo space_info[] = { int const nSpace = sizeof(space_info)/sizeof(SpaceInfo); int const defaultSpace = 4; -} // anon namespace +} // namespace InsetMathSpace::InsetMathSpace() : space_(defaultSpace) @@ -120,12 +121,11 @@ Inset * InsetMathSpace::clone() const void InsetMathSpace::metrics(MetricsInfo & mi, Dimension & dim) const { + Changer dummy = mi.base.changeEnsureMath(); dim.asc = 4; dim.des = 0; if (space_info[space_].custom) - dim.wid = abs(length_.inPixels( - mi.base.textwidth, - mathed_char_width(mi.base.font, 'M'))); + dim.wid = abs(mi.base.inPixels(length_)); else dim.wid = space_info[space_].width; } @@ -133,6 +133,7 @@ void InsetMathSpace::metrics(MetricsInfo & mi, Dimension & dim) const void InsetMathSpace::draw(PainterInfo & pi, int x, int y) const { + Changer dummy = pi.base.changeEnsureMath(); // Sadly, HP-UX CC can't handle that kind of initialization. // XPoint p[4] = {{++x, y-3}, {x, y}, {x+width-2, y}, {x+width-2, y-3}}; if (!space_info[space_].visible) @@ -194,7 +195,7 @@ void InsetMathSpace::octave(OctaveStream & os) const } -void InsetMathSpace::mathmlize(MathStream & ms) const +void InsetMathSpace::mathmlize(MathMLStream & ms) const { SpaceInfo const & si = space_info[space_]; if (si.negative || !si.visible) @@ -207,14 +208,15 @@ void InsetMathSpace::mathmlize(MathStream & ms) const ss << si.width; l = ss.str() + "px"; } - - ms << ""; + attr = "width=\"" + l + "\""; + + ms << CTag("mspace", attr); } - + void InsetMathSpace::htmlize(HtmlStream & ms) const { SpaceInfo const & si = space_info[space_]; @@ -245,7 +247,7 @@ void InsetMathSpace::htmlize(HtmlStream & ms) const case InsetSpaceParams::CUSTOM: case InsetSpaceParams::CUSTOM_PROTECTED: { string l = length_.asHTMLString(); - ms << MTag("span", "width='" + l + "'") + ms << MTag("span", "width='" + l + "'") << from_ascii(" ") << ETag("span"); break; } @@ -258,16 +260,18 @@ void InsetMathSpace::htmlize(HtmlStream & ms) const } } - + void InsetMathSpace::normalize(NormalStream & os) const { os << "[space " << int(space_) << "] "; } -void InsetMathSpace::write(WriteStream & os) const +void InsetMathSpace::write(TeXMathStream & os) const { - // no MathEnsurer - all kinds work in text and math mode + // All kinds work in text and math mode, so simply suspend + // writing a possibly pending mode closing brace. + MathEnsurer ensurer(os, false); if (space_info[space_].escape) os << '\\'; os << space_info[space_].name.c_str(); @@ -302,8 +306,6 @@ bool InsetMathSpace::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_INSET_MODIFY: case LFUN_INSET_DIALOG_UPDATE: case LFUN_MOUSE_RELEASE: - case LFUN_MOUSE_PRESS: - case LFUN_MOUSE_MOTION: status.setEnabled(true); return true; default: @@ -320,8 +322,10 @@ void InsetMathSpace::doDispatch(Cursor & cur, FuncRequest & cmd) if (cmd.getArg(0) == "mathspace") { MathData ar; if (createInsetMath_fromDialogStr(cmd.argument(), ar)) { + Buffer * buf = buffer_; cur.recordUndo(); *this = *ar[0].nucleus()->asSpaceInset(); + buffer_ = buf; break; } } @@ -329,18 +333,13 @@ void InsetMathSpace::doDispatch(Cursor & cur, FuncRequest & cmd) break; case LFUN_MOUSE_RELEASE: - if (cmd.button() == mouse_button::button1) { + if (cmd.button() == mouse_button::button1 && !cur.selection()) { showInsetDialog(&cur.bv()); break; } cur.undispatched(); break; - case LFUN_MOUSE_PRESS: - case LFUN_MOUSE_MOTION: - // eat other mouse commands - break; - default: InsetMath::doDispatch(cur, cmd); break;