]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_hullinset.C
oh well
[lyx.git] / src / mathed / math_hullinset.C
index 2c6bc57ef3c84a7ad5ce97352444b71a3fe39ba4..8e52adb9e0b86949f9e2d57e963cf49a760a706a 100644 (file)
@@ -10,6 +10,8 @@
 #include "math_support.h"
 #include "debug.h"
 #include "Painter.h"
+#include "textpainter.h"
+#include "Lsstream.h"
 #include "LaTeXFeatures.h"
 #include "support/LAssert.h"
 
@@ -65,7 +67,7 @@ namespace {
                if (s == "multline")  return LM_OT_MULTLINE;
                if (s == "gather")    return LM_OT_GATHER;
                return LM_OT_SIMPLE;
-       }       
+       }
 
 
        string normalName(MathInsetTypes t)
@@ -83,7 +85,7 @@ namespace {
                        default: break;
                }
                return "unknown";
-       }       
+       }
 
 } // end anon namespace
 
@@ -165,12 +167,13 @@ void MathHullInset::metrics(MathMetricsInfo const & mi) const
        if (display()) {
                ascent_  += 12;
                descent_ += 12;
-       }       
+       }
 
        if (numberedType()) {
+               whichFont(mi_.font, LM_TC_BF, mi_);
                int l = 0;
                for (row_type row = 0; row < nrows(); ++row)
-                       l = max(l, mathed_string_width(LM_TC_BF, mi_, nicelabel(row)));
+                       l = max(l, mathed_string_width(mi_.font, nicelabel(row)));
 
                if (l)
                        width_ += 30 + l;
@@ -179,7 +182,7 @@ void MathHullInset::metrics(MathMetricsInfo const & mi) const
        // make it at least as high as the current font
        int asc = 0;
        int des = 0;
-       math_font_max_dim(LM_TC_TEXTRM, mi_, asc, des);
+       math_font_max_dim(mi_.font, asc, des);
        ascent_  = max(ascent_,  asc);
        descent_ = max(descent_, des);
 }
@@ -193,23 +196,43 @@ void MathHullInset::draw(Painter & pain, int x, int y) const
                int const xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20;
                for (row_type row = 0; row < nrows(); ++row) {
                        int const yy = y + rowinfo_[row].offset_;
-                       drawStr(pain, LM_TC_BF, mi_, xx, yy, nicelabel(row));
+                       drawStr(pain, mi_.font, xx, yy, nicelabel(row));
                }
        }
 }
 
 
-void MathHullInset::metrics(TextMetricsInfo const &) const
+void MathHullInset::metricsT(TextMetricsInfo const &) const
 {
-       ascent_  = 1;
-       descent_ = 0;
-       width_   = normalName(objtype_).size();
+#if 0
+       if (display()) {
+               MathGridInset::metricsT(mi);
+       } else
+#endif
+       {
+               ostringstream os;
+               WriteStream wi(os, false, true);
+               write(wi);
+               width_   = os.str().size();
+               ascent_  = 1;
+               descent_ = 0;
+       }
 }
 
 
-void MathHullInset::draw(TextPainter & pain, int x, int y) const
+void MathHullInset::drawT(TextPainter & pain, int x, int y) const
 {
-       pain.draw(x, y, normalName(objtype_).c_str());
+#if 0
+       if (display()) {
+               MathGridInset::drawT(pain, x, y);
+       } else
+#endif
+       {
+               ostringstream os;
+               WriteStream wi(os, false, true);
+               write(wi);
+               pain.draw(x, y, os.str().c_str());
+       }
 }
 
 
@@ -223,13 +246,13 @@ string MathHullInset::label(row_type row) const
 
 void MathHullInset::label(row_type row, string const & label)
 {
-       label_[row] = label; 
+       label_[row] = label;
 }
 
 
 void MathHullInset::numbered(row_type row, bool num)
 {
-       nonum_[row] = !num; 
+       nonum_[row] = !num;
 }
 
 
@@ -243,7 +266,7 @@ bool MathHullInset::ams() const
 {
        return true;
 /*
-       return 
+       return
                objtype_ == LM_OT_ALIGN ||
                objtype_ == LM_OT_MULTLINE ||
                objtype_ == LM_OT_GATHER ||
@@ -312,9 +335,9 @@ void MathHullInset::header_write(WriteStream & os) const
 
                case LM_OT_EQUATION:
                        if (n)
-                               os << "\\begin{equation" << star(n) << "}\n"; 
+                               os << "\\begin{equation" << star(n) << "}\n";
                        else
-                               os << "\\[\n"; 
+                               os << "\\[\n";
                        break;
 
                case LM_OT_EQNARRAY:
@@ -336,7 +359,7 @@ void MathHullInset::header_write(WriteStream & os) const
                        break;
 
                case LM_OT_XXALIGNAT:
-                       os << "\\begin{xxalignat}" 
+                       os << "\\begin{xxalignat}"
                           << "{" << static_cast<unsigned int>(ncols()/2) << "}\n";
                        break;
 
@@ -365,9 +388,9 @@ void MathHullInset::footer_write(WriteStream & os) const
 
                case LM_OT_EQUATION:
                        if (n)
-                               os << "\\end{equation" << star(n) << "}\n"; 
+                               os << "\\end{equation" << star(n) << "}\n";
                        else
-                               os << "\\]\n"; 
+                               os << "\\]\n";
                        break;
 
                case LM_OT_EQNARRAY:
@@ -404,7 +427,7 @@ void MathHullInset::footer_write(WriteStream & os) const
 }
 
 
-void MathHullInset::addRow(row_type row) 
+void MathHullInset::addRow(row_type row)
 {
        nonum_.insert(nonum_.begin() + row + 1, !numberedType());
        label_.insert(label_.begin() + row + 1, string());
@@ -420,7 +443,7 @@ void MathHullInset::appendRow()
 }
 
 
-void MathHullInset::delRow(row_type row) 
+void MathHullInset::delRow(row_type row)
 {
        MathGridInset::delRow(row);
        nonum_.erase(nonum_.begin() + row);
@@ -538,7 +561,7 @@ void MathHullInset::mutate(MathInsetTypes newtype)
                                        setType(LM_OT_SIMPLE);
                                        break;
 
-                               case LM_OT_ALIGN: 
+                               case LM_OT_ALIGN:
                                case LM_OT_ALIGNAT:
                                case LM_OT_XALIGNAT:
                                case LM_OT_XXALIGNAT: {
@@ -546,7 +569,7 @@ void MathHullInset::mutate(MathInsetTypes newtype)
                                        MathGridInset::addCol(1);
 
                                        // split it "nicely"
-                                       pos_type pos = firstRelOp(cell(0));     
+                                       pos_type pos = firstRelOp(cell(0));
                                        cell(1) = cell(0);
                                        cell(0).erase(pos, cell(0).size());
                                        cell(1).erase(0, pos);
@@ -561,7 +584,7 @@ void MathHullInset::mutate(MathInsetTypes newtype)
                                        MathGridInset::addCol(1);
 
                                        // split it "nicely" on the firest relop
-                                       pos_type pos = firstRelOp(cell(0));     
+                                       pos_type pos = firstRelOp(cell(0));
                                        cell(1) = MathArray(cell(0), pos, cell(0).size());
                                        cell(0).erase(pos, cell(0).size());
 
@@ -630,7 +653,7 @@ void MathHullInset::mutate(MathInsetTypes newtype)
                                        setType(LM_OT_EQNARRAY);
                                        mutate(newtype);
                                        break;
-                               
+
                                case LM_OT_ALIGNAT:
                                case LM_OT_XALIGNAT:
                                case LM_OT_XXALIGNAT:
@@ -681,11 +704,11 @@ void MathHullInset::mutate(MathInsetTypes newtype)
 void MathHullInset::write(WriteStream & os) const
 {
        header_write(os);
-       
+
        bool n = numberedType();
-       
+
        for (row_type row = 0; row < nrows(); ++row) {
-               for (col_type col = 0; col < ncols(); ++col) 
+               for (col_type col = 0; col < ncols(); ++col)
                        os << cell(index(row, col)) << eocString(col);
                if (n) {
                        if (!label_[row].empty())
@@ -695,7 +718,7 @@ void MathHullInset::write(WriteStream & os) const
                }
                os << eolString(row);
        }
-       
+
        footer_write(os);
 }
 
@@ -719,5 +742,3 @@ void MathHullInset::check() const
        lyx::Assert(nonum_.size() == nrows());
        lyx::Assert(label_.size() == nrows());
 }
-
-