]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_sizeinset.C
make \newcommand{\bb}[1]{\mathbf{#1}} work for read/write/display.
[lyx.git] / src / mathed / math_sizeinset.C
index f6dc71f82cfed4a74bed03fc98f5920a600b7455..0f4eb4667aa4e1dce1d685e410894a59eddec411 100644 (file)
@@ -5,30 +5,15 @@
 #endif
 
 #include "math_sizeinset.h"
-#include "support/LOstream.h"
+#include "math_parser.h"
+#include "math_mathmlstream.h"
+#include "math_streamstr.h"
+#include "math_support.h"
 
 
-MathSizeInset::MathSizeInset(MathStyles st)
-       : MathInset(1), style_(st)
-{
-       name_ = verbose();
-}
-
-
-char const * MathSizeInset::verbose() const
-{
-       switch (style_) {
-               case LM_ST_DISPLAY:
-                       return "displaystyle";
-               case LM_ST_TEXT:
-                       return "textstyle";
-               case LM_ST_SCRIPT:
-                       return "scriptstyle";
-               case LM_ST_SCRIPTSCRIPT:
-                       return "scriptscriptstyle";
-       }
-       return "unknownstyle";
-}
+MathSizeInset::MathSizeInset(latexkeys const * l)
+       : MathNestInset(1), key_(l)
+{}
 
 
 MathInset * MathSizeInset::clone() const
@@ -37,34 +22,31 @@ MathInset * MathSizeInset::clone() const
 }
 
 
-void MathSizeInset::draw(Painter & pain, int x, int y)
+void MathSizeInset::draw(Painter & pain, int x, int y) const
 {
-       xo(x);
-       yo(y);
-       xcell(0).draw(pain, x, y);
+       xcell(0).draw(pain, x + 1, y);
+       mathed_draw_framebox(pain, x, y, this);
 }
 
 
-void MathSizeInset::Metrics(MathStyles /* st */, int, int)
+void MathSizeInset::metrics(MathMetricsInfo const & mi) const
 {
-       xcell(0).Metrics(style_);
-       ascent_   = xcell(0).ascent_;
-       descent_  = xcell(0).descent_;
-       width_    = xcell(0).width_;
+       MathMetricsInfo m = mi;
+       m.style = MathStyles(key_->id);
+       xcell(0).metrics(m);
+       ascent_   = xcell(0).ascent_ + 1;
+       descent_  = xcell(0).descent_ + 1;
+       width_    = xcell(0).width_ + 2;
 }
 
 
-void MathSizeInset::Write(std::ostream & os, bool fragile) const
+void MathSizeInset::write(WriteStream & os) const
 {
-       os << "{\\" << name() << " ";
-       cell(0).Write(os, fragile);
-       os << "}";
+       os << "{\\" << key_->name << ' ' << cell(0) << '}';
 }
 
 
-void MathSizeInset::WriteNormal(std::ostream & os) const
+void MathSizeInset::normalize(NormalStream & os) const
 {
-       os << "[" << name() << " ";
-       cell(0).WriteNormal(os);
-       os << "]";
+       os << "[" << key_->name << ' ' << cell(0) << ']';
 }