#include "FuncRequest.h"
#include "FuncStatus.h"
#include "LaTeXFeatures.h"
+#include "MetricsInfo.h"
#include "insets/InsetSpace.h"
int const nSpace = sizeof(space_info)/sizeof(SpaceInfo);
int const defaultSpace = 4;
-} // anon namespace
+} // namespace
InsetMathSpace::InsetMathSpace()
: space_(defaultSpace)
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;
}
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)
}
-void InsetMathSpace::mathmlize(MathStream & ms) const
+void InsetMathSpace::mathmlize(MathMLStream & ms) const
{
SpaceInfo const & si = space_info[space_];
if (si.negative || !si.visible)
ss << si.width;
l = ss.str() + "px";
}
-
- ms << "<mspace";
+
+ std::string attr;
if (!l.empty())
- ms << " width=\"" << from_ascii(l) << "\"";
- ms << " />";
+ attr = "width=\"" + l + "\"";
+
+ ms << CTag("mspace", attr);
}
-
+
void InsetMathSpace::htmlize(HtmlStream & ms) const
{
SpaceInfo const & si = space_info[space_];
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;
}
}
}
-
+
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();
if (space_info[space_].custom)
os << '{' << length_.asLatexString().c_str() << '}';
- else if (space_info[space_].escape && space_info[space_].name != " ")
+ else if (space_info[space_].escape && space_info[space_].name.length() > 1)
os.pendingSpace(true);
}
InsetSpaceParams InsetMathSpace::params() const
{
- LASSERT(space_info[space_].visible, /**/);
InsetSpaceParams isp(true);
+ LASSERT(space_info[space_].visible, return isp);
isp.kind = space_info[space_].kind;
isp.length = GlueLength(length_);
return isp;
}
-docstring InsetMathSpace::contextMenuName() const
+string InsetMathSpace::contextMenuName() const
{
- return from_ascii("context-mathspace");
+ return "context-mathspace";
}
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:
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;
}
}
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;