-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include <config.h>
#include "math_scriptinset.h"
#include "math_support.h"
#include "support/LAssert.h"
#include "debug.h"
+using namespace lyx::support;
using std::max;
+using std::auto_ptr;
+using std::endl;
MathScriptInset::MathScriptInset()
-MathInset * MathScriptInset::clone() const
+auto_ptr<InsetBase> MathScriptInset::clone() const
{
- return new MathScriptInset(*this);
+ return auto_ptr<InsetBase>(new MathScriptInset(*this));
}
int MathScriptInset::dx0() const
{
- lyx::Assert(hasDown());
- return hasLimits() ? (dim_.w - down().width()) / 2 : nwid();
+ Assert(hasDown());
+ return hasLimits() ? (dim_.wid - down().width()) / 2 : nwid();
}
int MathScriptInset::dx1() const
{
- lyx::Assert(hasUp());
- return hasLimits() ? (dim_.w - up().width()) / 2 : nwid();
+ Assert(hasUp());
+ return hasLimits() ? (dim_.wid - up().width()) / 2 : nwid();
}
int MathScriptInset::dxx() const
{
- return hasLimits() ? (dim_.w - nwid()) / 2 : 0;
+ return hasLimits() ? (dim_.wid - nwid()) / 2 : 0;
}
}
-void MathScriptInset::metrics(MathMetricsInfo & mi) const
+void MathScriptInset::metrics(MetricsInfo & mi, Dimension & dim) const
{
cell(2).metrics(mi);
- MathScriptChanger dummy(mi.base);
+ ScriptChanger dummy(mi.base);
cell(0).metrics(mi);
cell(1).metrics(mi);
- dim_.w = 0;
+ dim_.wid = 0;
if (hasLimits()) {
- dim_.w = nwid();
+ dim_.wid = nwid();
if (hasUp())
- dim_.w = max(dim_.w, up().width());
+ dim_.wid = max(dim_.wid, up().width());
if (hasDown())
- dim_.w = max(dim_.w, down().width());
+ dim_.wid = max(dim_.wid, down().width());
} else {
if (hasUp())
- dim_.w = max(dim_.w, up().width());
+ dim_.wid = max(dim_.wid, up().width());
if (hasDown())
- dim_.w = max(dim_.w, down().width());
- dim_.w += nwid();
+ dim_.wid = max(dim_.wid, down().width());
+ dim_.wid += nwid();
}
- dim_.a = dy1() + (hasUp() ? up().ascent() : 0);
- dim_.d = dy0() + (hasDown() ? down().descent() : 0);
- metricsMarkers2();
+ dim_.asc = dy1() + (hasUp() ? up().ascent() : 0);
+ dim_.des = dy0() + (hasDown() ? down().descent() : 0);
+ metricsMarkers();
+ dim = dim_;
}
-void MathScriptInset::draw(MathPainterInfo & pi, int x, int y) const
+void MathScriptInset::draw(PainterInfo & pi, int x, int y) const
{
if (nuc().size())
nuc().draw(pi, x + dxx(), y);
if (editing())
drawStr(pi, pi.base.font, x + dxx(), y, ".");
}
- MathScriptChanger dummy(pi.base);
+ ScriptChanger dummy(pi.base);
if (hasUp())
up().draw(pi, x + dx1(), y - dy1());
if (hasDown())
down().draw(pi, x + dx0(), y + dy0());
- drawMarkers2(pi, x, y);
+ drawMarkers(pi, x, y);
}
-void MathScriptInset::metricsT(TextMetricsInfo const & mi) const
+void MathScriptInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
{
if (hasUp())
- up().metricsT(mi);
+ up().metricsT(mi, dim);
if (hasDown())
- down().metricsT(mi);
- nuc().metricsT(mi);
+ down().metricsT(mi, dim);
+ nuc().metricsT(mi, dim);
}
else {
// in nucleus
- // don't go up/down unless in last position
- if (pos != cell(2).size())
- return false;
// don't go up/down if there is no cell.
if (!has(up))
return false;
- // otherwise move into the first position
- idx = up;
- pos = 0;
+ // go up/down only if in the last position
+ // or in the first position of something with displayed limits
+ if (pos == cell(2).size() || (pos == 0 && hasLimits())) {
+ idx = up;
+ pos = 0;
+ return true;
+ }
+ return false;
}
return true;
}
//}
} else {
if (os.firstitem())
- lyxerr[Debug::MATHED] << "suppressing {} when writing\n";
+ lyxerr[Debug::MATHED] << "suppressing {} when writing"
+ << endl;
else
os << "{}";
}
}
-void MathScriptInset::maplize(MapleStream & os) const
+void MathScriptInset::maple(MapleStream & os) const
{
if (nuc().size())
os << nuc();
}
-void MathScriptInset::mathematicize(MathematicaStream & os) const
+void MathScriptInset::mathematica(MathematicaStream & os) const
{
bool d = hasDown() && down().size();
bool u = hasUp() && up().size();
}
-void MathScriptInset::octavize(OctaveStream & os) const
+void MathScriptInset::octave(OctaveStream & os) const
{
if (nuc().size())
os << nuc();
void MathScriptInset::infoize(std::ostream & os) const
{
os << "Scripts";
+}
+
+
+void MathScriptInset::infoize2(std::ostream & os) const
+{
if (limits_)
os << (limits_ == 1 ? ", Displayed limits" : ", Inlined limits");
}
}
-MathInset::result_type MathScriptInset::dispatch
+dispatch_result MathScriptInset::dispatch
(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
{
if (cmd.action == LFUN_MATH_LIMITS) {