git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8900 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2004-08-13 13:19:58 +00:00
parent d2f9e0a569
commit 5fc3d2b0af
5 changed files with 33 additions and 29 deletions

View File

@ -26,7 +26,7 @@ public:
/// ///
explicit MathBoxInset(std::string const & name); explicit MathBoxInset(std::string const & name);
/// ///
virtual std::auto_ptr<InsetBase> clone() const; std::auto_ptr<InsetBase> clone() const;
/// ///
mode_type currentMode() const { return TEXT_MODE; } mode_type currentMode() const { return TEXT_MODE; }
/// ///

View File

@ -253,12 +253,12 @@ MathAtom createMathInset(string const & s)
return MathAtom(new MathSpaceInset(l->name)); return MathAtom(new MathSpaceInset(l->name));
if (inset == "dots") if (inset == "dots")
return MathAtom(new MathDotsInset(l)); return MathAtom(new MathDotsInset(l));
if (inset == "mbox") // if (inset == "mbox")
return MathAtom(new MathBoxInset(l->name)); // return MathAtom(new MathBoxInset(l->name));
// if (inset == "parbox") // if (inset == "parbox")
// return MathAtom(new MathParboxInset); // return MathAtom(new MathParboxInset);
if (inset == "fbox") // if (inset == "fbox")
return MathAtom(new MathFboxInset(l)); // return MathAtom(new MathFboxInset(l));
if (inset == "style") if (inset == "style")
return MathAtom(new MathSizeInset(l)); return MathAtom(new MathSizeInset(l));
if (inset == "font") if (inset == "font")
@ -275,6 +275,10 @@ MathAtom createMathInset(string const & s)
if (s.size() == 3 && s[0] == '\\' && s[1] == '#' if (s.size() == 3 && s[0] == '\\' && s[1] == '#'
&& s[2] >= '1' && s[2] <= '9') && s[2] >= '1' && s[2] <= '9')
return MathAtom(new MathMacroArgument(s[2] - '0')); return MathAtom(new MathMacroArgument(s[2] - '0'));
if (s == "mbox")
return MathAtom(new MathBoxInset("mbox"));
if (s == "fbox")
return MathAtom(new MathFboxInset());
if (s == "framebox") if (s == "framebox")
return MathAtom(new MathFrameboxInset); return MathAtom(new MathFrameboxInset);
if (s == "makebox") if (s == "makebox")

View File

@ -16,13 +16,15 @@
#include "math_parser.h" #include "math_parser.h"
#include "math_streamstr.h" #include "math_streamstr.h"
#include "LColor.h" #include "LColor.h"
#include "support/std_ostream.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
using std::auto_ptr; using std::auto_ptr;
MathFboxInset::MathFboxInset(latexkeys const * key) MathFboxInset::MathFboxInset()
: MathNestInset(1), key_(key) : MathNestInset(1)
{} {}
@ -34,20 +36,14 @@ auto_ptr<InsetBase> MathFboxInset::clone() const
MathInset::mode_type MathFboxInset::currentMode() const MathInset::mode_type MathFboxInset::currentMode() const
{ {
if (key_->name == "fbox")
return TEXT_MODE; return TEXT_MODE;
return MATH_MODE;
} }
void MathFboxInset::metrics(MetricsInfo & mi, Dimension & dim) const void MathFboxInset::metrics(MetricsInfo & mi, Dimension & dim) const
{ {
if (key_->name == "fbox") {
FontSetChanger dummy(mi.base, "textnormal"); FontSetChanger dummy(mi.base, "textnormal");
cell(0).metrics(mi, dim); cell(0).metrics(mi, dim);
} else {
cell(0).metrics(mi, dim);
}
metricsMarkers(dim, 5); // 5 pixels margin metricsMarkers(dim, 5); // 5 pixels margin
dim_ = dim; dim_ = dim;
} }
@ -57,23 +53,26 @@ void MathFboxInset::draw(PainterInfo & pi, int x, int y) const
{ {
pi.pain.rectangle(x + 1, y - dim_.ascent() + 1, pi.pain.rectangle(x + 1, y - dim_.ascent() + 1,
dim_.width() - 2, dim_.height() - 2, LColor::foreground); dim_.width() - 2, dim_.height() - 2, LColor::foreground);
if (key_->name == "fbox") {
FontSetChanger dummy(pi.base, "textnormal"); FontSetChanger dummy(pi.base, "textnormal");
cell(0).draw(pi, x + 5, y); cell(0).draw(pi, x + 5, y);
} else {
cell(0).draw(pi, x + 5, y);
}
setPosCache(pi, x, y); setPosCache(pi, x, y);
} }
void MathFboxInset::write(WriteStream & os) const void MathFboxInset::write(WriteStream & os) const
{ {
os << '\\' << key_->name << '{' << cell(0) << '}'; os << "\\fbox{" << cell(0) << '}';
} }
void MathFboxInset::normalize(NormalStream & os) const void MathFboxInset::normalize(NormalStream & os) const
{ {
os << '[' << key_->name << ' ' << cell(0) << ']'; os << "[fbox " << cell(0) << ']';
} }
void MathFboxInset::infoize(std::ostream & os) const
{
os << "FBox: ";
}

View File

@ -21,9 +21,9 @@ class latexkeys;
class MathFboxInset : public MathNestInset { class MathFboxInset : public MathNestInset {
public: public:
/// ///
MathFboxInset(latexkeys const * key); MathFboxInset();
/// ///
virtual std::auto_ptr<InsetBase> clone() const; std::auto_ptr<InsetBase> clone() const;
/// ///
mode_type currentMode() const; mode_type currentMode() const;
/// ///
@ -34,9 +34,8 @@ public:
void write(WriteStream & os) const; void write(WriteStream & os) const;
/// write normalized content /// write normalized content
void normalize(NormalStream & ns) const; void normalize(NormalStream & ns) const;
private:
/// ///
latexkeys const * key_; void infoize(std::ostream & os) const;
}; };
#endif #endif

View File

@ -1178,6 +1178,7 @@ void Parser::parse1(MathGridInset & grid, unsigned flags,
return; return;
} }
#if 0
else if (l->inset == "parbox") { else if (l->inset == "parbox") {
// read optional positioning and width // read optional positioning and width
string pos = parse_verbatim_option(); string pos = parse_verbatim_option();
@ -1187,6 +1188,7 @@ void Parser::parse1(MathGridInset & grid, unsigned flags,
cell->back().nucleus()->asParboxInset()->setPosition(pos); cell->back().nucleus()->asParboxInset()->setPosition(pos);
cell->back().nucleus()->asParboxInset()->setWidth(width); cell->back().nucleus()->asParboxInset()->setWidth(width);
} }
#endif
else { else {
MathAtom at = createMathInset(t.cs()); MathAtom at = createMathInset(t.cs());
@ -1214,7 +1216,7 @@ void Parser::parse1(MathGridInset & grid, unsigned flags,
//} //}
for (MathInset::idx_type i = start; i < at->nargs(); ++i) { for (MathInset::idx_type i = start; i < at->nargs(); ++i) {
parse(at.nucleus()->cell(i), FLAG_ITEM, m); parse(at.nucleus()->cell(i), FLAG_ITEM, m);
parse1(grid, FLAG_SKIPSPACE, mode, numbered); skipSpaces();
} }
cell->push_back(at); cell->push_back(at);
} }