math_notinset.h \
math_numberinset.C \
math_numberinset.h \
+ math_parboxinset.C \
+ math_parboxinset.h \
+ math_parinset.C \
+ math_parinset.h \
math_parser.C \
math_parser.h \
math_pos.C \
return false;
if (par()->asFboxInset())
return false;
+ if (par()->asParboxInset())
+ return false;
if (par()->asParInset())
return false;
return true;
#include "math_macrotable.h"
#include "math_macroarg.h"
#include "math_notinset.h"
+#include "math_parboxinset.h"
#include "math_rootinset.h"
#include "math_sizeinset.h"
#include "math_spaceinset.h"
{"ldots", "dots", ""},
{"left", "left", ""},
{"limits", "limit", ""},
- {"lyxbox", "box", ""},
{"lyxnegspace", "space", ""},
{"lyxposspace", "space", ""},
{"mathbb", "font", ""},
{"mathsf", "font", ""},
{"mathtt", "font", ""},
{"matrix", "matrix", ""},
- {"mbox", "box", ""},
+ {"mbox", "mbox", ""},
{"newcommand", "newcommand", ""},
{"nolimits", "limit", ""},
{"nonumber", "nonum", ""},
{"overrightarrow", "decoration", ""},
{"overleftrightarrow", "decoration", ""},
{"pageref", "ref", ""},
+ {"parbox", "parbox", ""},
{"pmatrix", "matrix", ""},
{"prettyref", "ref", ""},
{"protect", "protect", ""},
{"scriptstyle", "style", ""},
{"text", "font", "mathtext"},
{"textbf", "font", "mathtext"},
+ {"textipa", "font", "mathtext"},
{"textit", "font", "mathtext"},
{"textmd", "font", "mathtext"},
{"textrm", "font", "mathtext"},
return MathAtom(new MathSpaceInset(l->name));
if (inset == "dots")
return MathAtom(new MathDotsInset(l->name));
- if (inset == "box")
+ if (inset == "mbox")
return MathAtom(new MathBoxInset(l->name));
+ if (inset == "parbox")
+ return MathAtom(new MathParboxInset);
if (inset == "fbox")
return MathAtom(new MathFboxInset);
if (inset == "style")
MathFontSetChanger dummy(mi.base, name_.c_str());
xcell(0).metrics(mi);
ascent_ = xcell(0).ascent();
- descent_ = xcell(0).descent() + 2;
+ descent_ = xcell(0).descent() + 1;
width_ = xcell(0).width() + 2;
}
lyx::Assert(nonum_.size() == nrows());
lyx::Assert(label_.size() == nrows());
}
-
-
-
-
-
-//
-// MathParInset
-//
-
-MathParInset::MathParInset()
-{
- lyxerr << "constructing MathParInset\n";
-}
-
-
-void MathParInset::metrics(MathMetricsInfo & mi) const
-{
- MathFontSetChanger dummy(mi.base, "textnormal");
- MathGridInset::metrics(mi);
-}
-
-
-void MathParInset::draw(MathPainterInfo & pi, int x, int y) const
-{
- MathFontSetChanger dummy(pi.base, "textnormal");
- MathGridInset::draw(pi, x, y);
-}
-
-
-void MathParInset::write(WriteStream & os) const
-{
- for (idx_type i = 0; i < nargs(); ++i)
- os << cell(i) << "\n";
-}
-
-
-void MathParInset::infoize(std::ostream & os) const
-{
- os << "Type: Paragraph ";
-}
-
std::vector<string> label_;
};
-
-class MathParInset : public MathHullInset {
-public:
- ///
- MathParInset();
- ///
- MathParInset * asParInset() { return this; }
- ///
- void metrics(MathMetricsInfo & mi) const;
- ///
- void draw(MathPainterInfo &, int x, int y) const;
- ///
- void infoize(std::ostream & os) const;
- ///
- void write(WriteStream & os) const;
-private:
- ///
- void rebreak();
-};
-
-
#endif
class MathMatrixInset;
class MathNestInset;
class MathParInset;
+class MathParboxInset;
class MathScriptInset;
class MathStringInset;
class MathSpaceInset;
virtual MathMatrixInset const * asMatrixInset() const { return 0; }
virtual MathNestInset * asNestInset() { return 0; }
virtual MathParInset * asParInset() { return 0; }
+ virtual MathParboxInset * asParboxInset() { return 0; }
virtual MathScriptInset * asScriptInset() { return 0; }
virtual MathScriptInset const * asScriptInset() const { return 0; }
virtual MathSpaceInset * asSpaceInset() { return 0; }
void MathKernInset::metrics(MathMetricsInfo & /*mi*/) const
{
-#ifdef WITH_WARNINGS
-#warning fix this once the interface to LyXLength has improved
-#endif
- // this uses the numerical valu in pixels, even if the unit is cm or ex!
- width_ = static_cast<int>(wid_.value());
- width_ = (width_*static_cast<int>(lyxrc.zoom))/150;
+ width_ = wid_.inBP();
ascent_ = 0;
descent_ = 0;
- //cerr << "handling kern of width " << wid_.value() << "\n";
}
#include "math_metricsinfo.h"
#include "math_support.h"
+#include "debug.h"
#include "frontends/Painter.h"
MathMetricsBase::MathMetricsBase()
- : font(), style(LM_ST_TEXT), fontname("mathnormal")
+ : font(), style(LM_ST_TEXT), fontname("mathnormal"),
+ restrictwidth(false), textwidth(0)
{}
orig_ = save_;
}
+
+MathWidthChanger::MathWidthChanger(MathMetricsBase & mb, int w)
+ : MathChanger<MathMetricsBase>(mb)
+{
+ save_ = mb;
+ mb.restrictwidth = true;
+ mb.textwidth = w;
+}
+
+
+MathWidthChanger::~MathWidthChanger()
+{
+ orig_ = save_;
+}
+
MathStyles style;
///
string fontname;
+ /// if this is set...
+ bool restrictwidth;
+ /// ... this is valid
+ int textwidth;
};
};
+struct MathWidthChanger : public MathChanger<MathMetricsBase>
+{
+ ///
+ MathWidthChanger(MathMetricsBase & mb, int width);
+ ///
+ ~MathWidthChanger();
+};
+
+
#endif
--- /dev/null
+
+#include "math_parboxinset.h"
+#include "math_mathmlstream.h"
+#include "math_streamstr.h"
+#include "lyxlength.h"
+#include "debug.h"
+
+
+MathParboxInset::MathParboxInset()
+ : MathNestInset(1), lyx_width_(0), tex_width_("0mm"),
+ position_('c')
+{
+ lyxerr << "constructing MathParboxInset\n";
+}
+
+
+MathInset * MathParboxInset::clone() const
+{
+ return new MathParboxInset(*this);
+}
+
+
+void MathParboxInset::setPosition(string const & p)
+{
+ position_ = p.size() > 0 ? p[0] : 'c';
+}
+
+
+void MathParboxInset::setWidth(string const & w)
+{
+ tex_width_ = w;
+ lyx_width_ = LyXLength(w).inBP();
+ lyxerr << "setting " << w << " to " << lyx_width_ << " pixel\n";
+}
+
+
+void MathParboxInset::metrics(MathMetricsInfo & mi) const
+{
+ MathFontSetChanger dummy1(mi.base, "textnormal");
+ MathWidthChanger dummy2(mi.base, lyx_width_);
+ xcell(0).metrics(mi);
+ ascent_ = xcell(0).ascent();
+ descent_ = xcell(0).descent() + 1;
+ width_ = xcell(0).width() + 2;
+}
+
+
+void MathParboxInset::draw(MathPainterInfo & pi, int x, int y) const
+{
+ MathFontSetChanger dummy1(pi.base, "textnormal");
+ MathWidthChanger dummy2(pi.base, lyx_width_);
+ xcell(0).draw(pi, x + 1, y);
+ drawMarkers(pi, x, y);
+}
+
+
+void MathParboxInset::write(WriteStream & os) const
+{
+ os << "\\parbox";
+ if (position_ != 'c')
+ os << '[' << position_ << ']';
+ os << '{' << tex_width_ << "}{" << cell(0) << '}';
+}
+
+
+void MathParboxInset::infoize(std::ostream & os) const
+{
+ os << "Box: Parbox " << tex_width_ << ' ';
+}
+
--- /dev/null
+#ifndef MATH_PARBOXINSET_H
+#define MATH_PARBOXINSET_H
+
+#include "math_nestinset.h"
+
+class MathParboxInset : public MathNestInset {
+public:
+ ///
+ MathParboxInset();
+ ///
+ MathParboxInset * asParboxInset() { return this; }
+ ///
+ MathInset * clone() const;
+ ///
+ void metrics(MathMetricsInfo & mi) const;
+ ///
+ void draw(MathPainterInfo &, int x, int y) const;
+ ///
+ void infoize(std::ostream & os) const;
+ ///
+ void write(WriteStream & os) const;
+ ///
+ void setWidth(string const & width);
+ ///
+ void setPosition(string const & pos);
+private:
+ ///
+ void rebreak();
+ /// width on screen
+ int lyx_width_;
+ /// width for TeX
+ string tex_width_;
+ ///
+ char position_;
+};
+
+#endif
#include "math_macrotable.h"
#include "math_macrotemplate.h"
#include "math_hullinset.h"
+#include "math_parboxinset.h"
+#include "math_parinset.h"
#include "math_rootinset.h"
#include "math_sizeinset.h"
#include "math_sqrtinset.h"
FLAG_BRACE_LAST = 1 << 1, // last closing brace ends the parsing
FLAG_RIGHT = 1 << 2, // next \\right ends the parsing process
FLAG_END = 1 << 3, // next \\end ends the parsing process
- FLAG_BRACK_END = 1 << 4, // next closing bracket ends the parsing
+ FLAG_BRACK_LAST = 1 << 4, // next closing bracket ends the parsing
FLAG_TEXTMODE = 1 << 5, // we are in a box
FLAG_ITEM = 1 << 6, // read a (possibly braced token)
FLAG_LEAVE = 1 << 7, // leave the loop at the end
FLAG_SIMPLE = 1 << 8, // next $ leaves the loop
FLAG_EQUATION = 1 << 9, // next \] leaves the loop
- FLAG_SIMPLE2 = 1 << 10 // next \) leaves the loop
+ FLAG_SIMPLE2 = 1 << 10, // next \) leaves the loop
+ FLAG_OPTION = 1 << 11 // read [...] style option
};
flags |= FLAG_LEAVE;
}
+
+ if (flags & FLAG_OPTION) {
+ if (t.cat() == catOther && t.character() == '[') {
+ // skip the bracket and collect everything to the clsing bracket
+ flags |= FLAG_BRACK_LAST;
+ continue;
+ }
+
+ // no option found, put back token and we are done
+ putback();
+ return;
+ }
+
//
// cat codes
//
limits = 0;
}
- else if (t.character() == ']' && (flags & FLAG_BRACK_END))
+ else if (t.character() == ']' && (flags & FLAG_BRACK_LAST))
return;
else if (t.cat() == catOther)
}
else if (t.cs() == "sqrt") {
- char c = getChar();
- if (c == '[') {
+ MathArray ar;
+ parse_into(ar, FLAG_OPTION, mathmode);
+ if (ar.size()) {
cell->push_back(MathAtom(new MathRootInset));
- parse_into(cell->back()->cell(0), FLAG_BRACK_END, mathmode);
+ cell->back()->cell(0) = ar;
parse_into(cell->back()->cell(1), FLAG_ITEM, mathmode);
} else {
- putback();
cell->push_back(MathAtom(new MathSqrtInset));
parse_into(cell->back()->cell(0), FLAG_ITEM, mathmode);
}
else if (t.cs() == "ref") {
cell->push_back(MathAtom(new RefInset));
- char c = getChar();
- if (c == '[')
- parse_into(cell->back()->cell(1), FLAG_BRACK_END, mathmode);
- else
- putback();
+ parse_into(cell->back()->cell(1), FLAG_OPTION, mathmode);
parse_into(cell->back()->cell(0), FLAG_ITEM, mathmode);
}
// Disabled
else if (1 && t.cs() == "ar") {
MathXYArrowInset * p = new MathXYArrowInset;
-
// try to read target
- char c = getChar();
- if (c == '[') {
- parse_into(p->cell(0), FLAG_BRACK_END, mathmode);
- //lyxerr << "read target: " << p->cell(0) << "\n";
- } else {
- putback();
- }
-
+ parse_into(p->cell(0), FLAG_OTPTION, mathmode);
// try to read label
if (nextToken().cat() == catSuper || nextToken().cat() == catSub) {
p->up_ = nextToken().cat() == catSuper;
return;
}
- else if (l->inset == "box") {
+ else if (l->inset == "mbox") {
// switch to text mode
cell->push_back(createMathInset(t.cs()));
parse_into(cell->back()->cell(0), FLAG_ITEM, mathmode);
return;
}
+ else if (l->inset == "parbox") {
+ // read optional positioning and width
+ MathArray pos, width;
+ parse_into(pos, FLAG_OPTION, false);
+ parse_into(width, FLAG_ITEM, false);
+ cell->push_back(createMathInset(t.cs()));
+ parse_into(cell->back()->cell(0), FLAG_ITEM, false);
+ cell->back()->asParboxInset()->setPosition(asString(pos));
+ cell->back()->asParboxInset()->setWidth(asString(width));
+ }
+
else {
MathAtom p = createMathInset(t.cs());
for (MathInset::idx_type i = 0; i < p->nargs(); ++i)
bool mathed_parse_macro(string & name, string const & str)
{
istringstream is(str.c_str());
- Parser parser(is);
- return parser.parse_macro(name);
+ return Parser(is).parse_macro(name);
}
+
bool mathed_parse_macro(string & name, istream & is)
{
- Parser parser(is);
- return parser.parse_macro(name);
+ return Parser(is).parse_macro(name);
}
+
bool mathed_parse_macro(string & name, LyXLex & lex)
{
- Parser parser(lex);
- return parser.parse_macro(name);
+ return Parser(lex).parse_macro(name);
}
bool mathed_parse_normal(MathAtom & t, string const & str)
{
istringstream is(str.c_str());
- Parser parser(is);
- return parser.parse_normal(t);
+ return Parser(is).parse_normal(t);
}
+
bool mathed_parse_normal(MathAtom & t, istream & is)
{
- Parser parser(is);
- return parser.parse_normal(t);
+ return Parser(is).parse_normal(t);
}
+
bool mathed_parse_normal(MathAtom & t, LyXLex & lex)
{
- Parser parser(lex);
- return parser.parse_normal(t);
+ return Parser(lex).parse_normal(t);
}
{"texttt", LyXFont::TYPEWRITER_FAMILY, inh_series, inh_shape, LColor::black},
{"textup", inh_family, inh_series, LyXFont::UP_SHAPE, LColor::black},
+ // TIPA support
+ {"textipa", inh_family, inh_series, inh_shape, LColor::black},
+
{"lyxtex", inh_family, inh_series, inh_shape, LColor::latex},
{"lyxsymbol", LyXFont::SYMBOL_FAMILY, inh_series, inh_shape, LColor::math},
{"lyxboldsymbol",
}
//lyxerr << "MathXArray::metrics(): '" << ascent_ << " "
// << descent_ << " " << width_ << "'\n";
+
+
+ //
+ // re-break paragraph
+ //
+ if (mi.base.restrictwidth) {
+ width_ = mi.base.textwidth;
+ lyxerr << "restricting width to " << width_ << " pixel\n";
+ }
}
x += p->width();
}
}
+
+ //
+ // re-break paragraph
+ //
+ if (pi.base.restrictwidth) {
+ }
}