]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_dotsinset.C
Jean-Marc's fix for wrong descent
[lyx.git] / src / mathed / math_dotsinset.C
index 5f4e846a1812df2cc13b2131ed5300d9f4fb3c20..8251356cf7a589ba0202e0e1ce1437d5ee6ed858 100644 (file)
@@ -1,56 +1,54 @@
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
 
 #include "math_dotsinset.h"
-#include "mathed/support.h"
-#include "support/LOstream.h"
+#include "math_mathmlstream.h"
+#include "math_streamstr.h"
+#include "math_support.h"
+#include "math_parser.h"
 
-using std::ostream;
 
+MathDotsInset::MathDotsInset(latexkeys const * key)
+       : key_(key)
+{}
 
-MathDotsInset::MathDotsInset(string const & nam, int id, short st)
-       : MathedInset(nam, LM_OT_DOTS, st), code_(id) {}
 
-
-MathedInset * MathDotsInset::Clone()
+MathInset * MathDotsInset::clone() const
 {
-       return new MathDotsInset(name, code_, GetStyle());
-}     
-
-
-void MathDotsInset::draw(Painter & pain, int x, int y)
-{
-       mathed_draw_deco(pain, x + 2, y - dh_, width - 2, ascent, code_);
-       if (code_ == LM_vdots || code_ == LM_ddots)
-               ++x;
-       if (code_ != LM_vdots)
-               --y;
-       mathed_draw_deco(pain, x + 2, y - dh_, width - 2, ascent, code_);
+       return new MathDotsInset(*this);
 }
 
 
-void MathDotsInset::Metrics()
+void MathDotsInset::metrics(MathMetricsInfo & mi) const
 {
-       mathed_char_height(LM_TC_VAR, size(), 'M', ascent, descent);
-       width = mathed_char_width(LM_TC_VAR, size(), 'M');   
-       switch (code_) {
-               case LM_ldots: dh_ = 0; break;
-               case LM_cdots: dh_ = ascent/2; break;
-               case LM_vdots: width /= 2;
-               case LM_ddots: dh_ = ascent; break;
+       mathed_char_dim(mi.base.font, 'M', dim_);
+       dh_ = 0;
+       if (key_->name == "cdots" || key_->name == "dotsb"
+                       || key_->name == "dotsm" || key_->name == "dotsi")
+               dh_ = ascent() / 2;
+       else if (key_->name == "dotsc")
+               dh_ = ascent() / 4;
+       else if (key_->name == "vdots") {
+               dim_.w = (dim_.w / 2) + 1;
+               dh_ = ascent();
        }
-} 
+       else if (key_->name == "ddots")
+               dh_ = ascent();
+}
 
 
-void MathDotsInset::Write(ostream & os, bool /* fragile */)
+void MathDotsInset::draw(MathPainterInfo & pain, int x, int y) const
 {
-       os << '\\' << name << ' ';
+       mathed_draw_deco(pain, x + 2, y - dh_, width() - 2, ascent(), key_->name);
+       if (key_->name == "vdots" || key_->name == "ddots")
+               ++x;
+       if (key_->name != "vdots")
+               --y;
+       mathed_draw_deco(pain, x + 2, y - dh_, width() - 2, ascent(), key_->name);
 }
 
-void MathDotsInset::WriteNormal(ostream & os)
+
+string MathDotsInset::name() const
 {
-       os << "{" << name << "} ";
+       return key_->name;
 }