support for AMS's \boxed{} command

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4807 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2002-07-30 16:04:41 +00:00
parent a794a45949
commit 6c57f7353f
3 changed files with 38 additions and 13 deletions

View File

@ -69,7 +69,8 @@ bool math_font_available(string & name)
return true; return true;
} }
lyxerr[Debug::MATHED] << "font " << name << " not available and I can't fake it\n"; lyxerr[Debug::MATHED]
<< "font " << name << " not available and I can't fake it\n";
return false; return false;
} }
@ -233,7 +234,7 @@ MathAtom createMathInset(string const & s)
if (inset == "parbox") if (inset == "parbox")
return MathAtom(new MathParboxInset); return MathAtom(new MathParboxInset);
if (inset == "fbox") if (inset == "fbox")
return MathAtom(new MathFboxInset); 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")

View File

@ -7,12 +7,14 @@
#include "math_fboxinset.h" #include "math_fboxinset.h"
#include "math_support.h" #include "math_support.h"
#include "math_mathmlstream.h" #include "math_mathmlstream.h"
#include "math_streamstr.h"
#include "math_parser.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
MathFboxInset::MathFboxInset() MathFboxInset::MathFboxInset(latexkeys const * key)
: MathNestInset(1) : MathNestInset(1), key_(key)
{} {}
@ -22,30 +24,47 @@ MathInset * MathFboxInset::clone() const
} }
MathInset::mode_type MathFboxInset::currentMode() const
{
if (key_->name == "fbox")
return TEXT_MODE;
return MATH_MODE;
}
void MathFboxInset::metrics(MathMetricsInfo & mi) const void MathFboxInset::metrics(MathMetricsInfo & mi) const
{ {
if (key_->name == "fbox") {
MathFontSetChanger dummy(mi.base, "textnormal"); MathFontSetChanger dummy(mi.base, "textnormal");
dim_ = xcell(0).metrics(mi); dim_ = xcell(0).metrics(mi);
metricsMarkers2(5); // 5 pixels margin metricsMarkers2(5); // 5 pixels margin
} else {
dim_ = xcell(0).metrics(mi);
metricsMarkers2(5); // 5 pixels margin
}
} }
void MathFboxInset::draw(MathPainterInfo & pi, int x, int y) const void MathFboxInset::draw(MathPainterInfo & pi, int x, int y) const
{ {
MathFontSetChanger dummy(pi.base, "textnormal");
pi.pain.rectangle(x + 1, y - ascent() + 1, width() - 2, height() - 2, pi.pain.rectangle(x + 1, y - ascent() + 1, width() - 2, height() - 2,
LColor::black); LColor::black);
if (key_->name == "fbox") {
MathFontSetChanger dummy(pi.base, "textnormal");
xcell(0).draw(pi, x + 5, y); xcell(0).draw(pi, x + 5, y);
} else {
xcell(0).draw(pi, x + 5, y);
}
} }
void MathFboxInset::write(WriteStream & os) const void MathFboxInset::write(WriteStream & os) const
{ {
os << "\\fbox{" << cell(0) << '}'; os << '\\' << key_->name << '{' << cell(0) << '}';
} }
void MathFboxInset::normalize(NormalStream & os) const void MathFboxInset::normalize(NormalStream & os) const
{ {
os << "[fbox " << cell(0) << ']'; os << '[' << key_->name << ' ' << cell(0) << ']';
} }

View File

@ -13,14 +13,16 @@
\author André Pönitz \author André Pönitz
*/ */
class latexkeys;
class MathFboxInset : public MathNestInset { class MathFboxInset : public MathNestInset {
public: public:
/// ///
MathFboxInset(); MathFboxInset(latexkeys const * key);
/// ///
MathInset * clone() const; MathInset * clone() const;
/// ///
mode_type currentMode() const { return TEXT_MODE; } mode_type currentMode() const;
/// ///
void metrics(MathMetricsInfo & mi) const; void metrics(MathMetricsInfo & mi) const;
/// ///
@ -29,6 +31,9 @@ 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_;
}; };
#endif #endif