]> git.lyx.org Git - features.git/commitdiff
support for AMS's \boxed{} command
authorAndré Pönitz <poenitz@gmx.net>
Tue, 30 Jul 2002 16:04:41 +0000 (16:04 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 30 Jul 2002 16:04:41 +0000 (16:04 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4807 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_factory.C
src/mathed/math_fboxinset.C
src/mathed/math_fboxinset.h

index f328ed3a5709b994b19e29a79d3d06c3f47c1977..f07ebda69e830b85389a585ac83f31b5c3d98d78 100644 (file)
@@ -69,7 +69,8 @@ bool math_font_available(string & name)
                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;
 }
 
@@ -233,7 +234,7 @@ MathAtom createMathInset(string const & s)
                if (inset == "parbox")
                        return MathAtom(new MathParboxInset);
                if (inset == "fbox")
-                       return MathAtom(new MathFboxInset);
+                       return MathAtom(new MathFboxInset(l));
                if (inset == "style")
                        return MathAtom(new MathSizeInset(l));
                if (inset == "font")
index 138e2fe40709eae6f348baadc15892ebf810f48e..b187cff13bd312f3227bcb4597d1ba1b979650bd 100644 (file)
@@ -7,12 +7,14 @@
 #include "math_fboxinset.h"
 #include "math_support.h"
 #include "math_mathmlstream.h"
+#include "math_streamstr.h"
+#include "math_parser.h"
 #include "frontends/Painter.h"
 
 
 
-MathFboxInset::MathFboxInset()
-       : MathNestInset(1)
+MathFboxInset::MathFboxInset(latexkeys const * key)
+       : 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
 {
-       MathFontSetChanger dummy(mi.base, "textnormal");
-       dim_ = xcell(0).metrics(mi);
-       metricsMarkers2(5); // 5 pixels margin
+       if (key_->name == "fbox") {
+               MathFontSetChanger dummy(mi.base, "textnormal");
+               dim_ = xcell(0).metrics(mi);
+               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
 {
-       MathFontSetChanger dummy(pi.base, "textnormal");
        pi.pain.rectangle(x + 1, y - ascent() + 1, width() - 2, height() - 2,
                        LColor::black);
-       xcell(0).draw(pi, x + 5, y);
+       if (key_->name == "fbox") {
+               MathFontSetChanger dummy(pi.base, "textnormal");
+               xcell(0).draw(pi, x + 5, y);
+       } else {
+               xcell(0).draw(pi, x + 5, y);
+       }
 }
 
 
 void MathFboxInset::write(WriteStream & os) const
 {
-       os << "\\fbox{" << cell(0) << '}';
+       os << '\\' << key_->name << '{' << cell(0) << '}';
 }
 
 
 void MathFboxInset::normalize(NormalStream & os) const
 {
-       os << "[fbox " << cell(0) << ']';
+       os << '[' << key_->name << ' ' << cell(0) << ']';
 }
index 9f1ea4a770d8f85586f52fb63158ac512edb610d..ac84e9a86939e6b8033c3051f848e8e7a6c2ac59 100644 (file)
     \author André Pönitz
 */
 
+class latexkeys;
+
 class MathFboxInset : public MathNestInset {
 public:
        ///
-       MathFboxInset();
+       MathFboxInset(latexkeys const * key);
        ///
        MathInset * clone() const;
        ///
-       mode_type currentMode() const { return TEXT_MODE; }
+       mode_type currentMode() const;
        ///
        void metrics(MathMetricsInfo & mi) const;
        ///
@@ -29,6 +31,9 @@ public:
        void write(WriteStream & os) const;
        /// write normalized content
        void normalize(NormalStream & ns) const;
+private:
+       ///
+       latexkeys const * key_;
 };
 
 #endif