]> git.lyx.org Git - features.git/commitdiff
use stream-like syntax for LaTeX output
authorAndré Pönitz <poenitz@gmx.net>
Fri, 19 Oct 2001 11:25:48 +0000 (11:25 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 19 Oct 2001 11:25:48 +0000 (11:25 +0000)
 (instead of inset.write(stream) functions)

prepare fix for proper font sizes in chapter heading etc...

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2899 a592a061-630c-0410-9148-cb99ea01b6c8

75 files changed:
src/mathed/ChangeLog
src/mathed/Makefile.am
src/mathed/array.C
src/mathed/array.h
src/mathed/formula.C
src/mathed/formula.h
src/mathed/formulabase.C
src/mathed/formulabase.h
src/mathed/formulamacro.C
src/mathed/formulamacro.h
src/mathed/math_arrayinset.C
src/mathed/math_arrayinset.h
src/mathed/math_binominset.C
src/mathed/math_binominset.h
src/mathed/math_boxinset.C [new file with mode: 0644]
src/mathed/math_boxinset.h [new file with mode: 0644]
src/mathed/math_charinset.C
src/mathed/math_charinset.h
src/mathed/math_cursor.C
src/mathed/math_decorationinset.C
src/mathed/math_decorationinset.h
src/mathed/math_deliminset.C
src/mathed/math_deliminset.h
src/mathed/math_dotsinset.C
src/mathed/math_dotsinset.h
src/mathed/math_factory.C
src/mathed/math_fracinset.C
src/mathed/math_fracinset.h
src/mathed/math_funcinset.C
src/mathed/math_funcinset.h
src/mathed/math_funcliminset.C
src/mathed/math_funcliminset.h
src/mathed/math_gridinset.C
src/mathed/math_gridinset.h
src/mathed/math_hash.C
src/mathed/math_inset.C
src/mathed/math_inset.h
src/mathed/math_kerninset.C
src/mathed/math_kerninset.h
src/mathed/math_lefteqninset.C
src/mathed/math_lefteqninset.h
src/mathed/math_macro.C
src/mathed/math_macro.h
src/mathed/math_macroarg.C
src/mathed/math_macroarg.h
src/mathed/math_macrotemplate.C
src/mathed/math_macrotemplate.h
src/mathed/math_matrixinset.C
src/mathed/math_matrixinset.h
src/mathed/math_nestinset.C
src/mathed/math_nestinset.h
src/mathed/math_notinset.C
src/mathed/math_notinset.h
src/mathed/math_parser.C
src/mathed/math_parser.h
src/mathed/math_rootinset.C
src/mathed/math_rootinset.h
src/mathed/math_scriptinset.C
src/mathed/math_scriptinset.h
src/mathed/math_sizeinset.C
src/mathed/math_sizeinset.h
src/mathed/math_spaceinset.C
src/mathed/math_spaceinset.h
src/mathed/math_specialcharinset.C
src/mathed/math_specialcharinset.h
src/mathed/math_splitinset.C
src/mathed/math_splitinset.h
src/mathed/math_sqrtinset.C
src/mathed/math_sqrtinset.h
src/mathed/math_stackrelinset.C
src/mathed/math_stackrelinset.h
src/mathed/math_symbolinset.C
src/mathed/math_symbolinset.h
src/mathed/xarray.C
src/mathed/xarray.h

index 9aef0b27634b6eb504706de28f4f0345cc91aecd..550d77e4eb24bb071899bbc6455606661afeb586 100644 (file)
@@ -1,11 +1,16 @@
 
+2001-10-17  André Pönitz  <poenitz@gmx.net>
+
+       * math_inset.h:
+       * *.[Ch]: make output more stream-like
+
 2001-10-17  André Pönitz  <poenitz@gmx.net>
 
        * formula.C:
        * array.C: add missing/broken  writeNormal()
 
        * math_lefteqn.[Ch]: some visual support for \lefteqn
-       
+
 
 2001-10-10  André Pönitz  <poenitz@gmx.net>
 
index 15fadc46a06263354691a88e43d50181114beead..8b9a43e04a02eeca991ea7d7b43346fcba74f3e5 100644 (file)
@@ -24,6 +24,8 @@ libmathed_la_SOURCES = \
        math_atom.h \
        math_binominset.C \
        math_binominset.h \
+       math_boxinset.C \
+       math_boxinset.h \
        math_charinset.C \
        math_charinset.h \
        math_cursor.C \
index c91d52ed84626a27048c3b5d9d349d68ed60425c..2c87130997e6e6ce9ec0d638aa722cd467529701 100644 (file)
@@ -171,7 +171,7 @@ string charSequence(MathArray::const_iterator it, MathArray::const_iterator end)
 }
 
 
-void MathArray::write(ostream & os, bool fragile) const
+void MathArray::write(MathWriteInfo & wi) const
 {
        for (const_iterator it = begin(); it != end(); ++it) {  
                MathInset * p = it->nucleus();
@@ -190,10 +190,10 @@ void MathArray::write(ostream & os, bool fragile) const
                } else
 */
                if (MathScriptInset const * q = asScript(it)) {
-                       q->write(p, os, fragile);
+                       q->write(p, wi);
                        ++it;
                } else {
-                       p->write(os, fragile);
+                       p->write(wi);
                }
        }
 }
index 2f7cbe65588055ddcaaf1f769fbe9000b3c138f8..db0f1d4ea5840f37ad044815c19a5c024c81958b 100644 (file)
@@ -22,6 +22,8 @@
 
 class MathScriptInset;
 class MathMacro;
+class MathWriteInfo;
+class MathMetricsInfo;
 class LaTeXFeatures;
 
 #ifdef __GNUG__
@@ -96,7 +98,7 @@ public:
        ///
        MathAtom const & at(size_type pos) const;
        ///
-       void write(std::ostream &, bool) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
index 6a427b9c4131288b7c6635f37287981e9ee4aa6c..400bbaf813ad5acc4f30e7703b6b70ad49fb081e 100644 (file)
@@ -90,16 +90,19 @@ void InsetFormula::write(Buffer const * buf, ostream & os) const
 }
 
 
-int InsetFormula::latex(Buffer const *, ostream & os, bool fragile, bool) const
+int InsetFormula::latex(Buffer const * buf, ostream & os, bool fragil, bool)
+       const
 {
-       par_->write(os, fragile);
+       MathWriteInfo wi(buf, os, fragil);
+       par_->write(wi);
        return 1;
 }
 
 
-int InsetFormula::ascii(Buffer const *, ostream & os, int) const
+int InsetFormula::ascii(Buffer const * buf, ostream & os, int) const
 {
-       par_->write(os, false);
+       MathWriteInfo wi(buf, os, false);
+       par_->write(wi);
        return 1;
 }
 
@@ -123,7 +126,7 @@ void InsetFormula::read(Buffer const *, LyXLex & lex)
 }
 
 
-void InsetFormula::draw(BufferView * bv, LyXFont const &,
+void InsetFormula::draw(BufferView * bv, LyXFont const & font,
                        int y, float & xx, bool) const
 {
        int x = int(xx) - 1;
@@ -132,7 +135,7 @@ void InsetFormula::draw(BufferView * bv, LyXFont const &,
        MathInset::workwidth = bv->workWidth();
        Painter & pain = bv->painter();
 
-       metrics();
+       metrics(bv, &font);
        int w = par_->width();
        int h = par_->height();
        int a = par_->ascent();
@@ -150,12 +153,6 @@ void InsetFormula::draw(BufferView * bv, LyXFont const &,
 }
 
 
-void InsetFormula::metrics() const 
-{
-       par_->metrics(display() ? LM_ST_DISPLAY : LM_ST_TEXT);
-}
-
-
 vector<string> const InsetFormula::getLabelList() const
 {
        return mat()->getLabelList();
@@ -302,7 +299,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
 }
 
 
-void InsetFormula::handleExtern(const string & arg, BufferView *)
+void InsetFormula::handleExtern(const string & arg, BufferView * bv)
 {
        // where are we?
        MathArray & ar = mathcursor->cursor().cell();
@@ -337,7 +334,7 @@ void InsetFormula::handleExtern(const string & arg, BufferView *)
        mathcursor->end();
 
        // re-compute inset dimension
-       metrics();
+       metrics(bv);
 }
 
 
@@ -391,9 +388,9 @@ int InsetFormula::descent(BufferView *, LyXFont const &) const
 }
 
 
-int InsetFormula::width(BufferView *, LyXFont const &) const
+int InsetFormula::width(BufferView * bv, LyXFont const & font) const
 {
-       metrics();
+       metrics(bv, &font);
        return par_->width();
 }
 
index 501f1db2b10767f5075b4d24809b48253089cfa9..659c80a1cae23c36e706e40f162f5c0864533b4e 100644 (file)
@@ -44,8 +44,6 @@ public:
        int width(BufferView *, LyXFont const &) const;
        ///
        void draw(BufferView *, LyXFont const &, int, float &, bool) const;
-       ///
-       void metrics() const;
 
        ///
        void write(Buffer const *, std::ostream &) const;
index f233c7851dbf1dc4b91414ff19ce48e7a41ad167..f7b9e49b3364d2f59e9e25fda2dc6df101c3324c 100644 (file)
@@ -104,6 +104,7 @@ MathArrayInset * matrixpar(MathInset::idx_type & idx)
 
 
 InsetFormulaBase::InsetFormulaBase()
+       : view_(0), font_(0)
 {
        // This is needed as long the math parser is not re-entrant
        MathMacroTable::builtinMacros();
@@ -116,6 +117,17 @@ void InsetFormulaBase::validate(LaTeXFeatures &) const
 {}
 
 
+void InsetFormulaBase::metrics(BufferView * bv, LyXFont const * f) const 
+{
+       if (bv)
+               view_ = bv;
+       if (f)
+               font_ = f;
+       MathMetricsInfo mi(view_, font_, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
+       par()->metrics(mi);
+}
+
+
 string const InsetFormulaBase::editMessage() const
 {
        return _("Math editor mode");
@@ -128,7 +140,7 @@ void InsetFormulaBase::edit(BufferView * bv, int x, int /*y*/, unsigned int)
                lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
 
        mathcursor = new MathCursor(this, x == 0);
-       metrics();
+       metrics(bv);
        // if that is removed, we won't get the magenta box when entering an
        // inset for the first time
        bv->updateInset(this, false);
@@ -233,7 +245,7 @@ vector<string> const InsetFormulaBase::getLabelList() const
 
 void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
 {
-       metrics();
+       metrics(bv);
        bv->updateInset(this, dirty);
 }
 
@@ -677,8 +689,7 @@ void mathDispatchCreation(BufferView * bv, string const & arg, bool display)
                //      sel = "";
                //else
 
-               string sel = bv->getLyXText()->selectionAsString(bv->buffer(),
-                                                                false);
+               string sel = bv->getLyXText()->selectionAsString(bv->buffer(), false);
 
                InsetFormulaBase * f;
                if (sel.empty()) {
index f35889641ec9c380e16a349d305d92684f508e1f..3d45a7814fbc6ba7ee1519344091c30d9d8ef890 100644 (file)
@@ -89,12 +89,16 @@ public:
        ///
        virtual MathAtom & par() = 0;
        ///
-       virtual void metrics() const = 0;
+       virtual void metrics(BufferView * bv = 0, LyXFont const * font = 0) const;
        ///
        virtual void updateLocal(BufferView * bv, bool mark_dirty);
 private:
        /// unimplemented
        void operator=(const InsetFormulaBase &);
+       ///
+       mutable BufferView * view_;     
+       ///
+       mutable LyXFont const * font_;
 };
 
 // We don't really mess want around with mathed stuff outside mathed.
index d8b620d87d9eb0c75520380924ac2f957f9c0a89..b0188770d3f9e68a99085877f71b190e4da2b00a 100644 (file)
@@ -61,7 +61,10 @@ InsetFormulaMacro::InsetFormulaMacro(string const & s)
 {
        string name = mathed_parse_macro(s);
        setInsetName(name);
-       metrics();
+#ifdef WITH_WARNINGS
+#warning "metrics disabled"
+#endif
+       //metrics();
 }
 
 
@@ -71,23 +74,27 @@ Inset * InsetFormulaMacro::clone(Buffer const &, bool) const
 }
 
 
-void InsetFormulaMacro::write(Buffer const *, ostream & os) const
+void InsetFormulaMacro::write(Buffer const * buf, ostream & os) const
 {
        os << "FormulaMacro ";
-       par()->write(os, false);
+       MathWriteInfo wi(buf, os, false);
+       par()->write(wi);
 }
 
 
-int InsetFormulaMacro::latex(Buffer const *, ostream & os, bool fragile, 
+int InsetFormulaMacro::latex(Buffer const * buf, ostream & os, bool fragile, 
                             bool /*free_spacing*/) const
 {
-       par()->write(os, fragile);
+       MathWriteInfo wi(buf, os, fragile);
+       par()->write(wi);
        return 2;
 }
 
-int InsetFormulaMacro::ascii(Buffer const *, ostream & os, int) const
+
+int InsetFormulaMacro::ascii(Buffer const * buf, ostream & os, int) const
 {
-       par()->write(os, false);
+       MathWriteInfo wi(buf, os, false);
+       par()->write(wi);
        return 0;
 }
 
@@ -108,6 +115,7 @@ void InsetFormulaMacro::read(Buffer const *, LyXLex & lex)
 {
        string name = mathed_parse_macro(lex);
        setInsetName(name);
+       lyxerr << "metrics disabled";
        metrics();
 }
 
@@ -130,9 +138,9 @@ int InsetFormulaMacro::descent(BufferView *, LyXFont const &) const
 }
 
 
-int InsetFormulaMacro::width(BufferView *, LyXFont const & f) const
+int InsetFormulaMacro::width(BufferView * bv, LyXFont const & f) const
 {
-       metrics();
+       metrics(bv, &f);
        return 10 + lyxfont::width(prefix(), f) + par()->width();
 }
 
@@ -193,12 +201,6 @@ MathInsetTypes InsetFormulaMacro::getType() const
 }
 
 
-void InsetFormulaMacro::metrics() const
-{
-       par()->metrics(LM_ST_TEXT);
-}
-
-
 void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
                             int baseline, float & x, bool /*cleared*/) const
 {
index fdf37e37fabfe1ea33531e1a39da6a5554a2a597..19734215f2f2ecf9ece64f4e0b4f10ba5a675b6e 100644 (file)
@@ -68,8 +68,6 @@ public:
        ///
        MathInsetTypes getType() const;
        ///
-       void metrics() const;
-       ///
        MathAtom const & par() const;
        ///
        MathAtom & par();
index ae9cfabbf491f82c744572b33616b1375b0565ba..25c63eb7ce527baf7c246b83b884ad546f6cd4e5 100644 (file)
@@ -22,9 +22,9 @@ MathInset * MathArrayInset::clone() const
 }
 
 
-void MathArrayInset::write(std::ostream & os, bool fragile) const
+void MathArrayInset::write(MathWriteInfo & os) const
 {
-       if (fragile)
+       if (os.fragile)
                os << "\\protect";
        os << "\\begin{array}";
 
@@ -36,16 +36,19 @@ void MathArrayInset::write(std::ostream & os, bool fragile) const
                os << colinfo_[col].align_;
        os << "}\n";
 
-       MathGridInset::write(os, fragile);
+       MathGridInset::write(os);
 
-       if (fragile)
+       if (os.fragile)
                os << "\\protect";
        os << "\\end{array}\n";
 }
 
 
-void MathArrayInset::metrics(MathStyles st) const
+void MathArrayInset::metrics(MathMetricsInfo const & st) const
 {
-       MathGridInset::metrics(st == LM_ST_DISPLAY ? LM_ST_TEXT : st);
+       MathMetricsInfo m = st;
+       if (m.size == LM_ST_DISPLAY)
+               m.size = LM_ST_TEXT;
+       MathGridInset::metrics(m);
 }
 
index ee7341d84372398a9f748445fa4d44a39d124c80..79fa2130dabad47dee6bc63ab4c5bd9f271c7a0b 100644 (file)
@@ -18,9 +18,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        MathArrayInset * asArrayInset() { return this; }
 };
index 57857776159cd0af9fa5e101b65e9cff19c38996..1f04084c26370cd542054441b3d4cfca5458f229 100644 (file)
@@ -28,11 +28,12 @@ int MathBinomInset::dw() const
 }
 
 
-void MathBinomInset::metrics(MathStyles st) const
+void MathBinomInset::metrics(MathMetricsInfo const & st) const
 {
-       size_    = smallerStyleFrac(st);
-       xcell(0).metrics(size_);
-       xcell(1).metrics(size_);
+       MathMetricsInfo m = st;
+       m.size   = smallerStyleFrac(m.size);
+       xcell(0).metrics(m);
+       xcell(1).metrics(m);
        ascent_  = xcell(0).height() + 4 + 5;
        descent_ = xcell(1).height() + 4 - 5; 
        width_   = std::max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4; 
@@ -51,13 +52,9 @@ void MathBinomInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathBinomInset::write(std::ostream & os, bool fragile) const
+void MathBinomInset::write(MathWriteInfo & os) const
 {
-       os << '{';
-       cell(0).write(os, fragile);
-       os << " \\choose ";
-       cell(1).write(os, fragile);
-       os << '}';
+       os << '{' << cell(0) << " \\choose " << cell(1) << '}';
 }
 
 
index 2bb97451dd175d9d51b8d17b066c38cfa1ca5ea2..b991a2700ab8c32ea8870480d55b844410e6e0f4 100644 (file)
@@ -18,11 +18,11 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
 private:
diff --git a/src/mathed/math_boxinset.C b/src/mathed/math_boxinset.C
new file mode 100644 (file)
index 0000000..fa2a619
--- /dev/null
@@ -0,0 +1,81 @@
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "math_boxinset.h"
+#include "support/LOstream.h"
+#include "LColor.h"
+#include "debug.h"
+#include "Painter.h"
+#include "math_cursor.h"
+#include "insets/insettext.h"
+
+
+MathBoxInset::MathBoxInset(string const & name)
+       : MathDimInset(), name_(name), text_(new InsetText), buffer_(0)
+{
+       lyxerr << "creating new " << name << endl;
+}
+
+
+MathBoxInset::MathBoxInset(MathBoxInset const & m)
+       :       MathDimInset(*this), name_(m.name_), text_(0), buffer_(m.buffer_)
+{
+       if (!m.buffer_)
+               cerr << "no buffer\n";
+       else
+               text_ = static_cast<InsetText *>(m.text_->clone(*m.buffer_, false));
+}
+
+
+MathBoxInset::~MathBoxInset()
+{
+       delete text_;
+}
+
+
+MathInset * MathBoxInset::clone() const
+{
+       return new MathBoxInset(*this);
+}
+
+
+void MathBoxInset::write(MathWriteInfo & os) const
+{
+       os << "\\" << name_ << "{" << cell(0) << "}";
+}
+
+
+void MathBoxInset::writeNormal(std::ostream & os) const
+{
+       os << "[mbox ";
+       //text_->write(buffer(), os);
+       os << "] ";
+}
+
+
+void MathBoxInset::metrics(MathMetricsInfo const & st) const
+{
+       size_ = st;
+       if (text_ && st.view && st.font) {
+               ascent_  = text_->ascent(st.view, *st.font)  + 2;
+               descent_ = text_->descent(st.view, *st.font) + 2;
+               width_   = text_->width(st.view, *st.font)   + 4;
+       } else {
+               ascent_  = 10;
+               descent_ = 0;
+               width_   = 10;
+       }
+}
+
+
+void MathBoxInset::draw(Painter & pain, int x, int y) const
+{
+       float fx = x + 2;
+
+       if (text_ && size_.view && size_.font)
+               text_->draw(size_.view, *(size_.font), y, fx, false);
+       if (mathcursor && mathcursor->isInside(this))
+               pain.rectangle(x, y - ascent(), xcell(0).width(), height(),
+                       LColor::mathframe);
+}
diff --git a/src/mathed/math_boxinset.h b/src/mathed/math_boxinset.h
new file mode 100644 (file)
index 0000000..9b0bd58
--- /dev/null
@@ -0,0 +1,51 @@
+// -*- C++ -*-
+#ifndef MATH_BOXINSET_H
+#define MATH_BOXINSET_H
+
+#include "math_diminset.h"
+#include "LString.h"
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+class InsetText;
+class BufferView;
+class Buffer;
+class LyXFont;
+
+/// Support for \\mbox
+
+class MathBoxInset : public MathDimInset {
+public:
+       ///
+       explicit MathBoxInset(string const &);
+       ///
+       MathBoxInset(MathBoxInset const &);
+       ///
+       ~MathBoxInset();
+       ///
+       MathInset * clone() const;
+       ///
+       void draw(Painter &, int x, int y) const;
+       ///
+       void write(MathWriteInfo & os) const;
+       ///
+       void writeNormal(std::ostream &) const;
+       ///
+       void metrics(MathMetricsInfo const & st) const;
+       /// identifies BoxInsets
+       MathBoxInset * asBoxInset() { return this; }
+
+private:
+       /// unimplemented
+       void operator=(MathBoxInset const &);
+
+       ///
+       string name_;
+       ///
+       InsetText * text_;
+       ///
+       mutable Buffer * buffer_;       
+};
+#endif
index 8c1ca673b471622479b59a6d132ad8aaa4c5c7e6..44d6884541e8ecfd12001f19e40df801db87e0bc 100644 (file)
@@ -76,7 +76,7 @@ int MathCharInset::width() const
 }
 
 
-void MathCharInset::metrics(MathStyles st) const
+void MathCharInset::metrics(MathMetricsInfo const & st) const
 {
        size_ = st;
 }
@@ -87,7 +87,7 @@ void MathCharInset::draw(Painter & pain, int x, int y) const
        xo(x);
        yo(y);
        //lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
-       drawChar(pain, code_, size_, x, y, char_);
+       drawChar(pain, code_, size_.size, x, y, char_);
 }
 
 
@@ -111,11 +111,11 @@ void MathCharInset::writeRaw(std::ostream & os) const
 }
 
 
-void MathCharInset::write(std::ostream & os, bool) const
+void MathCharInset::write(MathWriteInfo & os) const
 {
-       writeHeader(os);
-       writeRaw(os);
-       writeTrailer(os);
+       writeHeader(os.os);
+       writeRaw(os.os);
+       writeTrailer(os.os);
 }
 
 
index 37f6029e079a91ace6131b4587e2496d597ade1e..fc024338fee7be83b7a87d591457a09b0e13a876 100644 (file)
@@ -23,11 +23,11 @@ public:
        ///
        MathTextCodes nativeCode(char c) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeHeader(std::ostream &) const;
        ///
index 5c4840ba13a9247178693e3b0226886994de14ce..9623694133608c81de4f15056b94d30dd027e686 100644 (file)
@@ -460,7 +460,10 @@ void MathCursor::niceInsert(MathAtom const & t)
                right();  // do not push for e.g. MathSymbolInset
                selPaste();
        }
-       p->metrics(p->size());
+#ifdef WITH_WARNINGS
+#warning "redraw disabled"
+#endif
+       //p->metrics(p->size());
 }
 
 
@@ -936,7 +939,8 @@ void MathCursor::normalize() const
                lyxerr << "this should not really happen - 2: "
                        << pos() << " " << size() <<  " in idx: " << it->idx()
                        << " in atom: '";
-               it->par()->write(lyxerr, false);
+               MathWriteInfo wi(0, lyxerr, false);
+               it->par()->write(wi);
                lyxerr << "\n";
                dump("error 4");
        }
index 4b35c789f36e33481c32ac9377392acf70a79b95..becc4183f45efe1600740d1d3e4d60e30ca38802 100644 (file)
@@ -62,7 +62,7 @@ bool MathDecorationInset::wide() const
 }
 
 
-void MathDecorationInset::metrics(MathStyles st) const
+void MathDecorationInset::metrics(MathMetricsInfo const & st) const
 {
        xcell(0).metrics(st);
        size_    = st;
@@ -96,13 +96,11 @@ void MathDecorationInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathDecorationInset::write(ostream & os, bool fragile) const
+void MathDecorationInset::write(MathWriteInfo & os) const
 {
-       if (fragile && protect())
+       if (os.fragile && protect())
                os << "\\protect";
-       os << '\\' << name_ << '{';
-       cell(0).write(os, fragile);  
-       os << '}';
+       os << '\\' << name_ << '{' << cell(0) << '}';
 }
 
 
index 200b8ea99844625460896267ed9168e1ac1e7bb8..a7a8effa821a2b15850cdf2655cb2461f42cd7ea 100644 (file)
@@ -22,9 +22,9 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void writeNormal(std::ostream & os) const;
        ///
index a4f7efafd1c8598ea2b68c13ca6024965322f01a..dfa88844698cbeb6042ff9e44fc23251be673bac 100644 (file)
@@ -42,11 +42,10 @@ string MathDelimInset::latexName(string const & name)
 }
 
 
-void MathDelimInset::write(std::ostream & os, bool fragile) const
+void MathDelimInset::write(MathWriteInfo & os) const
 {
-       os << "\\left"  << latexName(left_);
-       cell(0).write(os, fragile);
-       os << "\\right" << latexName(right_);
+       os << "\\left" << latexName(left_) << cell(0)
+          << "\\right" << latexName(right_);
 }
 
 
@@ -61,12 +60,12 @@ int MathDelimInset::dw() const
 }
 
 
-void MathDelimInset::metrics(MathStyles st) const
+void MathDelimInset::metrics(MathMetricsInfo const & st) const
 {
        xcell(0).metrics(st);
        size_    = st;
        int a, d, w;
-       mathed_char_dim(LM_TC_VAR, st,'I', a, d, w);
+       mathed_char_dim(LM_TC_VAR, size_.size,'I', a, d, w);
        int h0   = (a + d) / 2;
        int a0   = std::max(xcell(0).ascent(), a)   - h0;
        int d0   = std::max(xcell(0).descent(), d)  + h0;
index 23cf45e376b2d985afaece5e3d6999cadac89544..89240db8cbfa722315481f3596ef54049152d104 100644 (file)
@@ -22,9 +22,9 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
 private:
        ///
        int dw() const;
index f7b6238dc0f704bc9daa0bba8219e0a595812fd8..4c142c34c883bbdffa317c5af3e93532629100d8 100644 (file)
@@ -32,9 +32,9 @@ void MathDotsInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathDotsInset::metrics(MathStyles st) const
+void MathDotsInset::metrics(MathMetricsInfo const & st) const
 {
-       size(st);
+       size_ = st;
        mathed_char_dim(LM_TC_VAR, size(), 'M', ascent_, descent_, width_);
        switch (name_[0]) {
                case 'l': dh_ = 0; break;
@@ -45,7 +45,7 @@ void MathDotsInset::metrics(MathStyles st) const
 } 
 
 
-void MathDotsInset::write(ostream & os, bool /* fragile */) const
+void MathDotsInset::write(MathWriteInfo & os) const
 {
        os << '\\' << name_ << ' ';
 }
index cda4a77f7a335c6fe2b030d4724b9c1c65bfbb14..2fcc333c2511ed571fe340d7b211815a29590d6c 100644 (file)
@@ -19,11 +19,11 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
 protected:
        /// cache for the thing's heigth
        mutable int dh_;
index 280b48f5d7ccb4c5f081b27c7bd0bfb649c294ff..88b8472848335ab84369bb68ddeb6428b45dc8ca 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "math_parser.h"
 #include "math_binominset.h"
+//#include "math_boxinset.h"
 #include "math_decorationinset.h"
 #include "math_dotsinset.h"
 #include "math_funcinset.h"
@@ -62,6 +63,8 @@ MathAtom createMathInset(latexkeys const * l)
                return MathAtom(new MathSpaceInset(l->id));
        case LM_TK_DOTS:
                return MathAtom(new MathDotsInset(l->name));
+       //case LM_TK_BOX:
+       //      return MathAtom(new MathBoxInset(l->name));
        }
        return MathAtom(new MathFuncInset(l->name));
 }
index e4e08935ed0e250fa757ad7c20b6a1ebdb307717..057366ba7bc3be4c4261b0decaad0ce480050b6d 100644 (file)
@@ -19,9 +19,10 @@ MathInset * MathFracInset::clone() const
 }
 
 
-void MathFracInset::metrics(MathStyles st) const
+void MathFracInset::metrics(MathMetricsInfo const & st) const
 {
-       size_    = smallerStyleFrac(st);
+       size_    = st;
+       size_.size = smallerStyleFrac(size_.size);
        xcell(0).metrics(size_);
        xcell(1).metrics(size_);
        width_   = std::max(xcell(0).width(), xcell(1).width()) + 4; 
@@ -42,21 +43,12 @@ void MathFracInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathFracInset::write(std::ostream & os, bool fragile) const
+void MathFracInset::write(MathWriteInfo & os) const
 {
-       if (atop_) {
-               os << "{";
-               cell(0).write(os, fragile);
-               os << "\\atop ";
-               cell(1).write(os, fragile);
-               os << '}';
-       } else {
-               os << "\\frac{";
-               cell(0).write(os, fragile);
-               os << "}{";
-               cell(1).write(os, fragile);
-               os << '}';
-       }
+       if (atop_)
+               os << '{' << cell(0) << "\\atop " << cell(1) << '}';
+       else
+               os << "\\frac{" << cell(0) << "}{" << cell(1) << '}';
 }
 
 
index d60ca9bd08fd5778d42db28beb2f41c5d0b8d591..0c227c6f8cb8547994ab81e8318d1df03a0069e2 100644 (file)
@@ -18,11 +18,11 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
 public:
index 9932510580690f8b7c20a19e9c358265c50c3986..b5651b9df79b9488eb277d4b18972e80b6824aff 100644 (file)
@@ -37,7 +37,7 @@ void MathFuncInset::setName(string const & n)
 }
 
 
-void MathFuncInset::write(std::ostream & os, bool /* fragile */) const
+void MathFuncInset::write(MathWriteInfo & os) const
 {
        os << "\\" << name_ << ' ';
 }
@@ -49,10 +49,10 @@ void MathFuncInset::writeNormal(std::ostream & os) const
 }
 
 
-void MathFuncInset::metrics(MathStyles st) const 
+void MathFuncInset::metrics(MathMetricsInfo const & st) const 
 {
        size_ = st;
-       mathed_string_dim(LM_TC_TEX, size_, name_, ascent_, descent_, width_);
+       mathed_string_dim(LM_TC_TEX, size_.size, name_, ascent_, descent_, width_);
 }
 
 
@@ -60,5 +60,5 @@ void MathFuncInset::draw(Painter & pain, int x, int y) const
 { 
        xo(x);
        yo(y);
-       drawStr(pain, LM_TC_TEX, size_, x, y, name_);
+       drawStr(pain, LM_TC_TEX, size_.size, x, y, name_);
 }
index 3a773df15f1acde56b06431d22918da3549bed2d..b81cc60907468ae46a26e8324ced5b6046276a33 100644 (file)
@@ -20,11 +20,11 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
index d281b9e23b5d8c55b69b54742a9ea127fe3ebc6b..f8f03cda1c00f81f96348c960fdf04ed2fa03403 100644 (file)
@@ -19,11 +19,11 @@ MathInset * MathFuncLimInset::clone() const
 
 bool MathFuncLimInset::isScriptable() const
 {
-       return size_ == LM_ST_DISPLAY;
+       return size_.size == LM_ST_DISPLAY;
 }
 
 
-void MathFuncLimInset::write(ostream & os, bool /* fragile */) const
+void MathFuncLimInset::write(MathWriteInfo & os) const
 {
        os << '\\' << sym_->name << ' ';
 }
@@ -35,10 +35,11 @@ void MathFuncLimInset::writeNormal(ostream & os) const
 }
 
 
-void MathFuncLimInset::metrics(MathStyles st) const
+void MathFuncLimInset::metrics(MathMetricsInfo const & st) const
 {
-       size(st);
-       mathed_string_dim(LM_TC_TEXTRM, size(), sym_->name, ascent_, descent_, width_);
+       size_ = st;
+       mathed_string_dim(LM_TC_TEXTRM, size_.size, sym_->name,
+               ascent_, descent_, width_);
 }
 
 
@@ -46,5 +47,5 @@ void MathFuncLimInset::draw(Painter & pain, int x, int y) const
 {  
        xo(x);
        yo(y);
-       drawStr(pain, LM_TC_TEXTRM, size_, x, y, sym_->name);
+       drawStr(pain, LM_TC_TEXTRM, size_.size, x, y, sym_->name);
 }
index dce77a090ab2589dc0052c58e95f49d5181c15a8..70f0e992b8729dc1258dd9a2bc2753658645e6dc 100644 (file)
@@ -16,11 +16,11 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
        ///
index c7edf132a50203b90918ccdd608aeeb30f82c8b7..4b3c16d606522c2c76d048f9048c866894276d19 100644 (file)
@@ -132,7 +132,7 @@ LyXLength MathGridInset::vskip(row_type row) const
 }
 
 
-void MathGridInset::metrics(MathStyles st) const
+void MathGridInset::metrics(MathMetricsInfo const & st) const
 {
        // let the cells adjust themselves
        MathNestInset::metrics(st);
@@ -264,13 +264,11 @@ void MathGridInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathGridInset::write(std::ostream & os, bool fragile) const
+void MathGridInset::write(MathWriteInfo & os) const
 {
        for (row_type row = 0; row < nrows(); ++row) {
-               for (col_type col = 0; col < ncols(); ++col) {
-                       cell(index(row, col)).write(os, fragile);
-                       os << eocString(col);
-               }
+               for (col_type col = 0; col < ncols(); ++col) 
+                       os << cell(index(row, col)) << eocString(col);
                os << eolString(row);
        }
 }
index 8253ec30663bf7c4fb2b92fdbf552114a4300ae9..c0b64f03e7c8154031470f468b2d375c098b078d 100644 (file)
@@ -64,11 +64,11 @@ public:
        ///
        MathGridInset(int m, int n, char valign, string const & halign);
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
        ///
index 80f5dbfe63bf928edcbedf545353ec3879fe6490..888ff8748a1cc128df5f4bf987050475162dc6f6 100644 (file)
@@ -94,6 +94,7 @@ latexkeys_a wordlist_array[] =
        {"mathsf",  LM_TK_FONT, LM_TC_SF},
        {"mathtt",  LM_TK_FONT, LM_TC_TT},
        {"max",  LM_TK_FUNCLIM, 0},
+       //{"mbox",  LM_TK_BOX, 0},
        {"min",  LM_TK_FUNCLIM, 0},
        {"newcommand",  LM_TK_NEWCOMMAND, 0 },
        {"nolimits",  LM_TK_LIMIT, static_cast<unsigned>(-1)},
@@ -154,6 +155,7 @@ MathTokenEnum tokenEnum(const string & font)
        return LM_TK_SYM;
 }
 
+
 MathSymbolTypes symbolType(const string & type)
 {
        if (type == "mathrel")
index b4e340b5086c9cee2ede07458ca95a14fdce3924..0620aefdbda638ba4f1cdf729664a63441f4e697 100644 (file)
@@ -28,7 +28,7 @@ int MathInset::workwidth;
 
 
 MathInset::MathInset()
-       : size_(LM_ST_DISPLAY), xo_(0), yo_(0)
+       : xo_(0), yo_(0)
 {}
 
 
@@ -44,19 +44,14 @@ int MathInset::height() const
 
 MathStyles MathInset::size() const
 {
-       return size_;
-}
-
-
-void MathInset::size(MathStyles s) const
-{
-       size_ = s;
+       return size_.size;
 }
 
 
 std::ostream & operator<<(std::ostream & os, MathInset const & inset)
 {
-       inset.write(os, false);
+       MathWriteInfo wi(0, os, false);
+       inset.write(wi);
        return os;
 }
 
@@ -216,7 +211,8 @@ void MathInset::userSetSize(MathStyles sz)
 void MathInset::writeNormal(std::ostream & os) const
 {
        os << "[unknown ";
-       write(os, false);
+       MathWriteInfo wi(0, os, false);
+       write(wi);
        os << "] ";
 }
 
@@ -224,7 +220,8 @@ void MathInset::writeNormal(std::ostream & os) const
 void MathInset::dump() const
 {
        lyxerr << "---------------------------------------------\n";
-       write(lyxerr, false);
+       MathWriteInfo wi(0, lyxerr, false);
+       write(wi);
        lyxerr << "\n---------------------------------------------\n";
 }
 
@@ -267,7 +264,7 @@ std::vector<MathInset::idx_type>
 }
 
 
-void MathInset::metrics(MathStyles st) const
+void MathInset::metrics(MathMetricsInfo const & st) const
 {
        lyxerr << "MathInset::metrics() called directly!\n";
        size_ = st;
@@ -280,7 +277,7 @@ void MathInset::draw(Painter &, int, int) const
 }
 
 
-void MathInset::write(std::ostream &, bool) const
+void MathInset::write(MathWriteInfo &) const
 {
        lyxerr << "MathInset::write() called directly!\n";
 }
index 9894c9ee732239118158f925717d7f1ce59bd838..323deadb75e97a7642d22d578bd4e34e23df2a7c 100644 (file)
 */
 
 
-class LaTeXFeatures;
 class MathArrayInset;
+class MathBoxInset;
 class MathCharInset;
 class MathGridInset;
 class MathNestInset;
-class MathScriptInset;
 class MathMatrixInset;
+class MathScriptInset;
 class MathSpaceInset;
 class MathMacroTemplate;
 
+class LaTeXFeatures;
+class Buffer;
+class BufferView;
+class LyXFont;
+
+
+struct MathMetricsInfo {
+       ///
+       MathMetricsInfo()
+               : view(0), font(0), size(LM_ST_TEXT)
+       {}
+       ///
+       MathMetricsInfo(BufferView * v, LyXFont const * f, MathStyles s)
+               : view(v), font(f), size(s)
+       {}
+
+       ///
+       BufferView * view;
+       ///
+       LyXFont const * font;
+       ///
+       MathStyles size;
+};
+
+
+struct MathWriteInfo {
+       ///
+       MathWriteInfo(Buffer const * buffer_, std::ostream & os_, bool fragile_)
+               : buffer(buffer_), os(os_), fragile(fragile_)
+       {}
+       ///
+       explicit MathWriteInfo(std::ostream & os_)
+               : buffer(0), os(os_), fragile(false)
+       {}
+
+       ///
+       template <class T>
+       MathWriteInfo & operator<<(T const & T)
+       {
+               os << T;
+               return *this;
+       }
+       ///
+       MathWriteInfo & operator<<(MathArray const & ar)
+       {
+               ar.write(*this);
+               return *this;
+       }
+
+
+       ///
+       Buffer const * buffer;
+       ///
+       std::ostream & os;
+       ///
+       bool fragile;
+};
+
+
 class MathInset {
 public: 
        /// short of anything else reasonable
@@ -68,7 +127,7 @@ public:
        /// draw the object, sets xo_ and yo_ cached values 
        virtual void draw(Painter &, int x, int y) const;
        /// write LaTeX and Lyx code
-       virtual void write(std::ostream &, bool fragile) const;
+       virtual void write(MathWriteInfo & os) const;
        /// write normalized content
        virtual void writeNormal(std::ostream &) const;
        /// reproduce itself
@@ -76,7 +135,7 @@ public:
        ///substitutes macro arguments if necessary
        virtual void substitute(MathMacro const & macro);
        /// compute the size of the object, sets ascend_, descend_ and width_
-       virtual void metrics(MathStyles st) const;
+       virtual void metrics(MathMetricsInfo const & st) const;
        /// 
        virtual int ascent() const { return 1; }
        ///
@@ -191,6 +250,8 @@ public:
        virtual MathGridInset * asGridInset() { return 0; }
        /// identifies ArrayInsets
        virtual MathArrayInset * asArrayInset() { return 0; }
+       /// identifies BoxInsets
+       virtual MathBoxInset * asBoxInset() { return 0; }
        /// identifies macro templates
        virtual MathMacroTemplate * asMacroTemplate() { return 0; }
 
@@ -226,10 +287,8 @@ public:
        static int workwidth;
 
 protected:
-       /// _sets_ style
-       void size(MathStyles s) const;
        /// the used font size
-       mutable MathStyles size_;
+       mutable MathMetricsInfo size_;
 
 private:
        /// the following are used for positioning the cursor with the mouse
index 37e24e93a564c6a53d5c7b93044fe07ea8bbfe82..6a282351774fe46ae9f0cbd94cf47d1cbfb7bc3a 100644 (file)
@@ -31,7 +31,7 @@ void MathKernInset::draw(Painter &, int, int) const
 {}
 
 
-void MathKernInset::write(std::ostream & os, bool) const
+void MathKernInset::write(MathWriteInfo & os) const
 {
        os << "\\kern" << wid_.asLatexString() << " ";
 }
@@ -43,12 +43,14 @@ void MathKernInset::writeNormal(std::ostream & os) const
 }
 
 
-void MathKernInset::metrics(MathStyles) const
+void MathKernInset::metrics(MathMetricsInfo const &) const
 {
        ascent_  = 0;
        descent_ = 0;
 #ifdef WITH_WARNINGS
 #warning fix this once the interface to LyXLength has improved
 #endif
+       // this uses the numerical valu in pixels, even if the unit is cm or ex!
        width_   = static_cast<int>(wid_.value());
+       //cerr << "handling kern of width " << wid_.value() << "\n";
 }
index 978dd10409174ed1b85e166e1223d4b1ca4d2d76..0a707cae7f214ad3d74398beb9bf7a83033c6d35 100644 (file)
@@ -25,11 +25,11 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
 private:
        /// width in em
        LyXLength wid_;
index 162c2ab88d931e732100a48532aa5ce8e6913f9c..9c22c442a4af453c9913c28d907c128e1e6b8915 100644 (file)
@@ -30,23 +30,22 @@ void MathLefteqnInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathLefteqnInset::write(std::ostream & os, bool fragile) const
+void MathLefteqnInset::write(MathWriteInfo & os) const
 {
-       os << "\\lefteqn{";
-       cell(0).write(os, fragile);
-       os << "}";
+       os << "\\lefteqn{" << cell(0) << "}";
 }
 
 
 void MathLefteqnInset::writeNormal(std::ostream & os) const
 {
        os << "[lefteqn ";
-       cell(0).write(os, false);
+       MathWriteInfo wi(os);
+       cell(0).write(wi);
        os << "] ";
 }
 
 
-void MathLefteqnInset::metrics(MathStyles st) const
+void MathLefteqnInset::metrics(MathMetricsInfo const & st) const
 {
        MathNestInset::metrics(st);
        size_    = st;
index de99a1273aaccaee2b092bb52635c2de65002ad0..15c37262a973cd176ccc5383e170760f7c0b46ec 100644 (file)
@@ -8,7 +8,7 @@
 #pragma interface
 #endif
 
-/// The \kern primitive
+/// Support for LaTeX's \\lefteqn command
 
 class MathLefteqnInset : public MathNestInset {
 public:
@@ -19,10 +19,10 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
 };
 #endif
index afd872b9a789df704bad187e03996ef5b2f9bf63..7e17da748cd20b867aa2a422b9411043e194fa92 100644 (file)
@@ -69,11 +69,11 @@ bool MathMacro::editing() const
 }
 
 
-void MathMacro::metrics(MathStyles st) const
+void MathMacro::metrics(MathMetricsInfo const & st) const
 {
        if (defining()) {
                size_ = st;
-               mathed_string_dim(LM_TC_TEX, size_, name(), ascent_, descent_, width_);
+               mathed_string_dim(LM_TC_TEX, size_.size, name(), ascent_, descent_, width_);
                return;
        }
 
@@ -85,12 +85,12 @@ void MathMacro::metrics(MathStyles st) const
                ascent_  = expanded_.ascent()  + 2;
                descent_ = expanded_.descent() + 2;
 
-               width_ +=  mathed_string_width(LM_TC_TEXTRM, size_, name()) + 10;
+               width_ +=  mathed_string_width(LM_TC_TEXTRM, size_.size, name()) + 10;
 
                int lasc;
                int ldes;
                int lwid;
-               mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid);
+               mathed_string_dim(LM_TC_TEXTRM, size_.size, "#1: ", lasc, ldes, lwid);
 
                for (idx_type i = 0; i < nargs(); ++i) {
                        MathXArray const & c = xcell(i);
@@ -117,25 +117,25 @@ void MathMacro::draw(Painter & pain, int x, int y) const
        xo(x);
        yo(y);
 
-       metrics(size());
+       metrics(size_);
 
        if (defining()) {
-               drawStr(pain, LM_TC_TEX, size_, x, y, name());
+               drawStr(pain, LM_TC_TEX, size_.size, x, y, name());
                return;
        }
 
        if (editing()) {
                int h = y - ascent() + 2 + expanded_.ascent();
-               drawStr(pain, LM_TC_TEXTRM, size(), x + 3, h, name());
+               drawStr(pain, LM_TC_TEXTRM, size_.size, x + 3, h, name());
 
-               int const w = mathed_string_width(LM_TC_TEXTRM, size(), name());
+               int const w = mathed_string_width(LM_TC_TEXTRM, size_.size, name());
                expanded_.draw(pain, x + w + 12, h);
                h += expanded_.descent();
 
                int lasc;
                int ldes;
                int lwid;
-               mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid);
+               mathed_string_dim(LM_TC_TEXTRM, size_.size, "#1: ", lasc, ldes, lwid);
 
                for (idx_type i = 0; i < nargs(); ++i) {
                        MathXArray const & c = xcell(i);
@@ -143,7 +143,7 @@ void MathMacro::draw(Painter & pain, int x, int y) const
                        c.draw(pain, x + lwid, h);
                        char str[] = "#1:";
                        str[1] += static_cast<char>(i);
-                       drawStr(pain, LM_TC_TEX, size(), x + 3, h, str);
+                       drawStr(pain, LM_TC_TEX, size_.size, x + 3, h, str);
                        h += std::max(c.descent(), ldes) + 5;
                }
                return;
@@ -158,18 +158,18 @@ void MathMacro::dump() const
        MathMacroTable::dump();
        lyxerr << "\n macro: '" << this << "'\n";
        lyxerr << " name: '" << name() << "'\n";
-       lyxerr << " template: '"; tmplate_->write(lyxerr, false); lyxerr << "'\n";
+       lyxerr << " template: '";
+       MathWriteInfo wi(lyxerr);
+       tmplate_->write(wi);
+       lyxerr << "'\n";
 }
 
 
-void MathMacro::write(std::ostream & os, bool fragile) const
+void MathMacro::write(MathWriteInfo & os) const
 {
        os << '\\' << name();
-       for (idx_type i = 0; i < nargs(); ++i) {
-               os << '{';
-               cell(i).write(os, fragile);
-               os << '}';
-       }
+       for (idx_type i = 0; i < nargs(); ++i)
+               os << '{' << cell(i) << '}';
        if (nargs() == 0) 
                os << ' ';
 }
index 05362ee2a0d4c9f3dba45159b08cca99cacefdc3..4460f0bfd5d54c352cf0aba3ee66d91f7915e4e0 100644 (file)
@@ -44,11 +44,11 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        MathInset * clone() const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
index d7a777954d5f6b86e84341f08316b56fc46998a5..ab1b2179572793dac30320d6fb229ec08110ea1a 100644 (file)
@@ -29,13 +29,13 @@ MathInset * MathMacroArgument::clone() const
 }
 
 
-void MathMacroArgument::write(std::ostream & os, bool /*fragile*/) const
+void MathMacroArgument::write(MathWriteInfo & os) const
 {
        os << '#' << number_;
 }
 
 
-void MathMacroArgument::metrics(MathStyles st) const
+void MathMacroArgument::metrics(MathMetricsInfo const & st) const
 {
        if (expanded_) {
                xcell(0).metrics(st);
@@ -43,7 +43,7 @@ void MathMacroArgument::metrics(MathStyles st) const
                ascent_  = xcell(0).ascent();
                descent_ = xcell(0).descent();
        } else
-               mathed_string_dim(LM_TC_TEX, size(), str_, ascent_, descent_, width_);
+               mathed_string_dim(LM_TC_TEX, size_.size, str_, ascent_, descent_, width_);
 }
 
 
@@ -52,7 +52,7 @@ void MathMacroArgument::draw(Painter & pain, int x, int y) const
        if (expanded_)
                xcell(0).draw(pain, x, y);
        else
-               drawStr(pain, LM_TC_TEX, size(), x, y, str_);
+               drawStr(pain, LM_TC_TEX, size_.size, x, y, str_);
 }
 
 
index 0982ada0d12c440b571b1b37a5a753f5b1f32347..c8855d9a87d1d177703ceef742d94c9117ae95ca 100644 (file)
@@ -18,11 +18,11 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
index 822d0e92114ee8e15c4f7d116168975f69ac644f..c217cd1b57c8bbc49056521b9d840bca2b91c24a 100644 (file)
@@ -47,20 +47,16 @@ string const & MathMacroTemplate::name() const
 }
 
 
-void MathMacroTemplate::write(std::ostream & os, bool fragile) const
+void MathMacroTemplate::write(MathWriteInfo & os) const
 {
-       os << "\n\\newcommand{\\" << name_ << "}";
-
+       os << "\n\\newcommand{\\" << name_ << '}';
        if (numargs_ > 0)
-               os << "[" << numargs_ << "]";
-
-       os << "{";
-       cell(0).write(os, fragile);
-       os << "}\n";
+               os << '[' << numargs_ << ']';
+       os << '{' << cell(0) << "}\n";
 }
 
 
-void MathMacroTemplate::metrics(MathStyles st) const
+void MathMacroTemplate::metrics(MathMetricsInfo const & st) const
 {
        xcell(0).metrics(st);
        size_    = st;
index aeefe5a2ce71746c685b0d57faf6d4a1febdc44b..4cbe5106ee3bafbd96631fc3fd615aaf888bb8e7 100644 (file)
@@ -25,7 +25,7 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        /// Number of arguments
        int numargs() const;
        ///
@@ -35,7 +35,7 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        /// identifies macro templates
        MathMacroTemplate * asMacroTemplate() { return this; }
 private:
index 5e61d8671e24023ddaf973a7d2a7ed2595a6e7d3..690dc0acad3fe3c4c1d9ca5a1e8018e0cf6a6834 100644 (file)
@@ -140,9 +140,10 @@ int MathMatrixInset::defaultColSpace(col_type col)
 }
 
 
-void MathMatrixInset::metrics(MathStyles) const
+void MathMatrixInset::metrics(MathMetricsInfo const & st) const
 {
-       size_ = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY;
+       size_ = st;
+       size_.size = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY;
 
        // let the cells adjust themselves
        MathGridInset::metrics(size_);
@@ -187,17 +188,15 @@ void MathMatrixInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathMatrixInset::write(std::ostream & os, bool fragile) const
+void MathMatrixInset::write(MathWriteInfo & os) const
 {
-  header_write(os);
+  header_write(os.os);
 
        bool n = numberedType();
 
        for (row_type row = 0; row < nrows(); ++row) {
-               for (col_type col = 0; col < ncols(); ++col) {
-                       cell(index(row, col)).write(os, fragile);
-                       os << eocString(col);
-               }
+               for (col_type col = 0; col < ncols(); ++col) 
+                       os << cell(index(row, col)) << eocString(col);
                if (n) {
                        if (!label_[row].empty())
                                os << "\\label{" << label_[row] << "}";
@@ -207,7 +206,7 @@ void MathMatrixInset::write(std::ostream & os, bool fragile) const
                os << eolString(row);
        }
 
-  footer_write(os);
+  footer_write(os.os);
 }
 
 
index 32c5fa43e862bbe6ff776771840c5ea95a10470f..c28020b549d96d232ce52628a92ff727f3b78127 100644 (file)
@@ -27,11 +27,11 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
        ///
index 5dccb4b5595670d1e2746dc1362ff1ec6c234c71..9b8a411002adc960bb51ce5d94f350d6de3b2f1f 100644 (file)
@@ -48,7 +48,7 @@ void MathNestInset::substitute(MathMacro const & m)
 }
 
 
-void MathNestInset::metrics(MathStyles st) const
+void MathNestInset::metrics(MathMetricsInfo const & st) const
 {
        size_ = st;
        for (idx_type i = 0; i < nargs(); ++i)
@@ -139,12 +139,13 @@ bool MathNestInset::idxEnd(idx_type & idx, pos_type & pos) const
 
 void MathNestInset::dump() const
 {
-       lyxerr << "---------------------------------------------\n";
-       write(lyxerr, false);
-       lyxerr << "\n";
+       MathWriteInfo os(lyxerr);
+       os << "---------------------------------------------\n";
+       write(os);
+       os << "\n";
        for (idx_type i = 0; i < nargs(); ++i)
-               lyxerr << cell(i) << "\n";
-       lyxerr << "---------------------------------------------\n";
+               os << cell(i) << "\n";
+       os << "---------------------------------------------\n";
 }
 
 
index 5cf17786de0f11c708c2817b4efda77840831dc5..8bf33e0038ad0aba5e594121dc47237236e6b557 100644 (file)
@@ -19,7 +19,7 @@ public:
        explicit MathNestInset(idx_type ncells);
 
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        /// draw the object, sets xo_ and yo_ cached values 
        void draw(Painter &, int x, int y) const;
        /// appends itself with macro arguments substituted
index a187a3173fc91269ff38f90b9d268eb42f75b57a..9ebbb3f1bfb008c3a0bc9f383b33d502e78fe0f2 100644 (file)
@@ -16,7 +16,7 @@ MathInset * MathNotInset::clone() const
 }
 
 
-void MathNotInset::write(ostream & os, bool /* fragile */) const
+void MathNotInset::write(MathWriteInfo & os) const
 {
        os << "\\not ";
 }
@@ -28,15 +28,13 @@ void MathNotInset::writeNormal(ostream & os) const
 }
 
 
-void MathNotInset::metrics(MathStyles st) const
+void MathNotInset::metrics(MathMetricsInfo const & st) const
 {
-       size(st);
+       size_ = st;
        if (math_font_available(LM_TC_CMSY))
-               mathed_char_dim(LM_TC_CMSY, size_, 54,
-                               ascent_, descent_, width_);
-               else
-                       mathed_char_dim(LM_TC_VAR, size_, '/',
-                                       ascent_, descent_, width_);
+               mathed_char_dim(LM_TC_CMSY, size(), 54, ascent_, descent_, width_);
+       else
+               mathed_char_dim(LM_TC_VAR, size(), '/', ascent_, descent_, width_);
        width_ = 0;
 }
 
@@ -47,7 +45,7 @@ void MathNotInset::draw(Painter & pain, int x, int y) const
        yo(y);
 
        if (math_font_available(LM_TC_CMSY))
-               drawChar(pain, LM_TC_CMSY, size_, x, y, 54);
+               drawChar(pain, LM_TC_CMSY, size(), x, y, 54);
        else
-               drawChar(pain, LM_TC_VAR, size_, x, y, '/');
+               drawChar(pain, LM_TC_VAR, size(), x, y, '/');
 }
index b97d565ffcb9541a25ec525d5cce853359c2f191..cc0dca081bad65389d3e4d58ac15145018dab8d2 100644 (file)
@@ -13,11 +13,11 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
 };
index 66d455e4b93e55cf2008dfe45cc3aae525764baa..ba706459302a2ca2d962958d2382851a35d72ab9 100644 (file)
@@ -889,6 +889,17 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
                        }
                        array.push_back(MathAtom(p));
                }
+
+/*
+               // Disabled
+               else if (t.cs() == "mbox") {
+                       array.push_back(createMathInset(t.cs()));
+                       // slurp in the argument of mbox
+       
+                       MathBoxInset * p = array.back()->asBoxInset();
+                       //lyx::assert(p);
+               }
+*/
        
                else if (t.cs().size()) {
                        latexkeys const * l = in_word_set(t.cs());
index 7acfa475d9388e85d512f34a9315b9507c0ec333..e49a4f7ce6c44616097c7180d34fd0dc8088a05c 100644 (file)
@@ -38,6 +38,8 @@ enum MathTokenEnum
        ///
        LM_TK_SYM = 256,
        ///
+       LM_TK_BOX,
+       ///
        LM_TK_CHOOSE,
        ///
        LM_TK_BINOM,
index 4760854461e16b54c97c023e0b39a413623f466d..c9bd8e618877cd06dea1d8e7aca5315378a3b8aa 100644 (file)
@@ -30,7 +30,7 @@ MathInset * MathRootInset::clone() const
 }
 
 
-void MathRootInset::metrics(MathStyles st) const
+void MathRootInset::metrics(MathMetricsInfo const & st) const
 {
        MathNestInset::metrics(st);
        size_    = st;
@@ -60,13 +60,9 @@ void MathRootInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathRootInset::write(std::ostream & os, bool fragile) const
+void MathRootInset::write(MathWriteInfo & os) const
 {
-       os << "\\sqrt[";
-       cell(0).write(os, fragile);  
-       os << "]{";
-       cell(1).write(os, fragile);
-       os << '}';
+       os << "\\sqrt[" << cell(0) << "]{" << cell(1) << '}';
 }
 
 
index 5649d0a8f72e76fabe3ad2f51546f9b291bde0ae..95174881c759533b815f0b6214b3c6f9adc5063a 100644 (file)
@@ -34,11 +34,11 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        bool idxUp(int & idx, int & pos) const;
        ///
index a0ce5ebbc59c65d36bc701a5c9f6cf92b8bf624b..cc9c481bdbb4f0c80b97e341d1da11b59efee07a 100644 (file)
@@ -180,13 +180,14 @@ int MathScriptInset::ndes(MathInset const * nuc) const
 }
 
 
-void MathScriptInset::metrics(MathStyles st) const
+void MathScriptInset::metrics(MathMetricsInfo const & st) const
 {      
        metrics(0, st);
 }
 
 
-void MathScriptInset::metrics(MathInset const * nuc, MathStyles st) const
+void MathScriptInset::metrics(MathInset const * nuc,
+       MathMetricsInfo const & st) const
 {      
        MathNestInset::metrics(st);
        if (nuc)
@@ -221,18 +222,17 @@ void MathScriptInset::draw(MathInset const * nuc, Painter & pain,
 }
 
 
-void MathScriptInset::write(std::ostream & os, bool fragile) const
+void MathScriptInset::write(MathWriteInfo & os) const
 {  
        //lyxerr << "unexpected call to MathScriptInset::write()\n";
-       write(0, os, fragile);
+       write(0, os);
 }
 
 
-void MathScriptInset::write(MathInset const * nuc, std::ostream & os,
-       bool fragile) const
+void MathScriptInset::write(MathInset const * nuc, MathWriteInfo & os) const
 {
        if (nuc) {
-               nuc->write(os, fragile);
+               nuc->write(os);
                if (nuc->takesLimits()) {
                        if (limits_ == -1)
                                os << "\\nolimits ";
@@ -243,17 +243,11 @@ void MathScriptInset::write(MathInset const * nuc, std::ostream & os,
        else
                os << "{}";
 
-       if (hasDown() && down().data_.size()) {
-               os << "_{";
-               down().data_.write(os, fragile);
-               os << "}";
-       }
+       if (hasDown() && down().data_.size())
+               os << "_{" << down().data_ << '}';
 
-       if (hasUp() && up().data_.size()) {
-               os << "^{";
-               up().data_.write(os, fragile);
-               os << "}";
-       }
+       if (hasUp() && up().data_.size())
+               os << "^{" << up().data_ << '}';
 }
 
 
index 59e0535a68472b67926d57ef98e5c4e99e1199eb..49337fa80a10956a6f19590a3459c5e05aa98e0f 100644 (file)
@@ -21,16 +21,16 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
 
        ///
-       void write(MathInset const * nucleus, std::ostream &, bool fragile) const;
+       void write(MathInset const *, MathWriteInfo & os) const;
        ///
-       void metrics(MathInset const * nucleus, MathStyles st) const;
+       void metrics(MathInset const * nucleus, MathMetricsInfo const & st) const;
        ///
        void draw(MathInset const * nucleus, Painter &, int x, int y) const;
        ///
index 8587e570479198cd474c7dce735cfe57e29a9308..389b233597ce63cd4124e7b270c72fef3b8f48c0 100644 (file)
@@ -26,20 +26,20 @@ void MathSizeInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathSizeInset::metrics(MathStyles /* st */) const
+void MathSizeInset::metrics(MathMetricsInfo const & st) const
 {
-       xcell(0).metrics(MathStyles(key_->id));
+       size_ = st;
+       size_.size = MathStyles(key_->id);
+       xcell(0).metrics(size_);
        ascent_   = xcell(0).ascent_;
        descent_  = xcell(0).descent_;
        width_    = xcell(0).width_;
 }
 
 
-void MathSizeInset::write(std::ostream & os, bool fragile) const
+void MathSizeInset::write(MathWriteInfo & os) const
 {
-       os << "{\\" << key_->name << " ";
-       cell(0).write(os, fragile);
-       os << "}";
+       os << "{\\" << key_->name << ' ' << cell(0) << '}';
 }
 
 
index c72ce5e64e1f88124fce95bb8132d0278c38c9ad..b4e25958c71a2397a76f5fcda0c8ae801ea01ebf 100644 (file)
@@ -22,11 +22,11 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
 
index 46408f177e2f8e6e49c3d6c8a0ab2dfbf39f7960..87b752e8846368970715e28a1e06374a61ebdc53 100644 (file)
@@ -40,7 +40,7 @@ void MathSpaceInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathSpaceInset::write(std::ostream & os, bool /* fragile */) const
+void MathSpaceInset::write(MathWriteInfo & os) const
 {
        if (space_ >= 0 && space_ < 6)
                os << '\\' << latex_mathspace[space_] << ' ';
@@ -53,7 +53,7 @@ void MathSpaceInset::writeNormal(std::ostream & os) const
 }
 
 
-void MathSpaceInset::metrics(MathStyles st) const
+void MathSpaceInset::metrics(MathMetricsInfo const & st) const
 {
        size_  = st;
        width_ = space_ ? space_ * 2 : 2;
index 96b43441f969a35960a9533b31d242193280b369..fddaed61301a878f467044814133039182d4ac1b 100644 (file)
@@ -19,11 +19,11 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        MathSpaceInset const * asSpaceInset() const { return this; }
        ///
index 4fe90e80fc118595687c708e3bc28104baee304b..05c34659b793db3b781d7823aea6472fd73d3e40 100644 (file)
@@ -36,7 +36,7 @@ int MathSpecialCharInset::width() const
 }
 
 
-void MathSpecialCharInset::metrics(MathStyles st) const
+void MathSpecialCharInset::metrics(MathMetricsInfo const & st) const
 {
        size_ = st;
 }
@@ -46,11 +46,11 @@ void MathSpecialCharInset::draw(Painter & pain, int x, int y) const
 { 
        xo(x);
        yo(y);
-       drawChar(pain, LM_TC_CONST, size_, x, y, char_);
+       drawChar(pain, LM_TC_CONST, size(), x, y, char_);
 }
 
 
-void MathSpecialCharInset::write(std::ostream & os, bool) const
+void MathSpecialCharInset::write(MathWriteInfo & os) const
 {
        os << "\\" << char_;
 }
index 6582868f6d961d4914bf31f45230c84ebb17e02d..8fcfbb32c96d8277ba59c61fe8ca3056b651c56a 100644 (file)
@@ -20,11 +20,11 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        /// 
index e7b5c18f182746cd3b83b0d0e9b205b8a4d4f30a..46eab1d065dc1286d2d7bc05e866e9fd7056ae75 100644 (file)
@@ -19,13 +19,13 @@ MathInset * MathSplitInset::clone() const
 }
 
 
-void MathSplitInset::write(std::ostream & os, bool fragile) const
+void MathSplitInset::write(MathWriteInfo & os) const
 {
-       if (fragile)
+       if (os.fragile)
                os << "\\protect";
        os << "\\begin{split}";
-       MathGridInset::write(os, fragile);
-       if (fragile)
+       MathGridInset::write(os);
+       if (os.fragile)
                os << "\\protect";
        os << "\\end{split}\n";
 }
index 2ef9348db95443419ce257c390ac2f0634f4c528..7c188eca937f2e8183e42a4d90f0c0e1aba47cc4 100644 (file)
@@ -16,7 +16,7 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        int defaultColSpace(int) { return 0; }
        ///
index 956fbb28b9fcd35669414fca47ef31771fca0b18..27cdc56c2c13a99c478f5b0c46a42fd2b2ce41cf 100644 (file)
@@ -19,7 +19,7 @@ MathInset * MathSqrtInset::clone() const
 }
 
 
-void MathSqrtInset::metrics(MathStyles st) const
+void MathSqrtInset::metrics(MathMetricsInfo const & st) const
 {
        xcell(0).metrics(st);
        size_    = st;
@@ -46,11 +46,9 @@ void MathSqrtInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathSqrtInset::write(std::ostream & os, bool fragile) const
+void MathSqrtInset::write(MathWriteInfo & os) const
 {
-       os << "\\sqrt{";
-       cell(0).write(os, fragile); 
-       os << '}';
+       os << "\\sqrt{" << cell(0) << '}';
 }
 
 
index cf7c5d89c27d24b87029f2f52127109f1f693c6a..78e3ecedcebdf3a5be204011f16cd16da68ffdb2 100644 (file)
@@ -20,10 +20,10 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
 };
 #endif
index 081c3b4c6d85c38fbfbb8fe8b63312f4d3f1b023..162a8bdf6400079859d86da312fc4732b6569737 100644 (file)
@@ -17,9 +17,10 @@ MathInset * MathStackrelInset::clone() const
 }
 
 
-void MathStackrelInset::metrics(MathStyles st) const
+void MathStackrelInset::metrics(MathMetricsInfo const & st) const
 {
-       size_    = smallerStyleFrac(st);
+       size_    = st;
+       size_.size = smallerStyleFrac(size_.size);
        xcell(0).metrics(size_);
        xcell(1).metrics(st);
        width_   = std::max(xcell(0).width(), xcell(1).width()) + 4; 
@@ -38,13 +39,9 @@ void MathStackrelInset::draw(Painter & pain, int x, int y) const
 }
 
 
-void MathStackrelInset::write(std::ostream & os, bool fragile) const
+void MathStackrelInset::write(MathWriteInfo & os) const
 {
-       os << "\\stackrel{";
-       cell(0).write(os, fragile);
-       os << "}{";
-       cell(1).write(os, fragile);
-       os << '}';
+       os << "\\stackrel{" << cell(0) << "}{" << cell(1) << '}';
 }
 
 
index 3de330a50f9b3f02dbaef996f0402f73c776c9fe..5c66bdcb79ea6ef4fdbac2ff8b09b393b382fd22 100644 (file)
@@ -18,11 +18,11 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
 };
index 10520453ec46f7793493d41ec6c57930277b73ea..dd7915780d3f628404d7cea75513126bdde1b8cc 100644 (file)
@@ -16,7 +16,7 @@ MathInset * MathSymbolInset::clone() const
 }
 
 
-void MathSymbolInset::write(ostream & os, bool /* fragile */) const
+void MathSymbolInset::write(MathWriteInfo & os) const
 {
        os << '\\' << sym_->name << ' ';
 }
@@ -58,25 +58,25 @@ MathTextCodes MathSymbolInset::code2() const
 }
 
 
-void MathSymbolInset::metrics(MathStyles st) const
+void MathSymbolInset::metrics(MathMetricsInfo const & st) const
 {
        size_ = st;
        MathTextCodes Code = code();
        if (sym_->latex_font_id > 0 && math_font_available(Code)) {
-               mathed_char_dim(Code, size_, sym_->latex_font_id,
+               mathed_char_dim(Code, size(), sym_->latex_font_id,
                                ascent_, descent_, width_);
                if (Code == LM_TC_CMEX) {
                        h_ = 4*descent_/5;
                        ascent_  += h_;
                        descent_ -= h_;
                }
-       } else if (sym_->id > 0 && sym_->id < 255 &&
-                  math_font_available(LM_TC_SYMB)) {
-               mathed_char_dim(code2(), size_, sym_->id,
-                               ascent_, descent_, width_);
-       } else {
-               mathed_string_dim(LM_TC_TEX, size_, sym_->name, ascent_, descent_, width_);
+               return;
        }
+
+       if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
+               mathed_char_dim(code2(), size(), sym_->id, ascent_, descent_, width_);
+       else
+               mathed_string_dim(LM_TC_TEX, size(), sym_->name, ascent_, descent_, width_);
 }
 
 
@@ -86,12 +86,11 @@ void MathSymbolInset::draw(Painter & pain, int x, int y) const
        yo(y);
        MathTextCodes Code = code();
        if (sym_->latex_font_id > 0 && math_font_available(Code))
-               drawChar(pain, Code, size_, x, y - h_, sym_->latex_font_id);
-       else if (sym_->id > 0 && sym_->id < 255 &&
-                math_font_available(LM_TC_SYMB))
-               drawChar(pain, code2(), size_, x, y, sym_->id);
+               drawChar(pain, Code, size(), x, y - h_, sym_->latex_font_id);
+       else if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
+               drawChar(pain, code2(), size(), x, y, sym_->id);
        else
-               drawStr(pain, LM_TC_TEX, size_, x, y, sym_->name);
+               drawStr(pain, LM_TC_TEX, size(), x, y, sym_->name);
 }
 
 
@@ -103,7 +102,7 @@ bool MathSymbolInset::isRelOp() const
 
 bool MathSymbolInset::isScriptable() const
 {
-       return size_ == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
+       return size() == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
 }
 
 
index fa2b5bbf4bc6d05946f05dfb487534535df46a43..a42f01ba59d21f933c9a7b8c2074d427eef8fe41 100644 (file)
@@ -16,11 +16,11 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void write(std::ostream &, bool fragile) const;
+       void write(MathWriteInfo & os) const;
        ///
        void writeNormal(std::ostream &) const;
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter &, int x, int y) const;
        ///
index 6f3ff8b3ca8fc9adb9ad93e9b3279027e777ba87..ffeee12e3a624518a5976db0933355b45f342996 100644 (file)
@@ -18,15 +18,15 @@ MathXArray::MathXArray()
 {}
 
 
-void MathXArray::metrics(MathStyles st) const
+void MathXArray::metrics(MathMetricsInfo const & st) const
 {
-       style_   = st;
-       mathed_char_dim(LM_TC_VAR, st, 'I', ascent_, descent_, width_);
+       style_ = st.size;
+       mathed_char_dim(LM_TC_VAR, style_, 'I', ascent_, descent_, width_);
 
        if (data_.empty()) 
                return;
 
-       math_font_max_dim(LM_TC_TEXTRM, st, ascent_, descent_); 
+       math_font_max_dim(LM_TC_TEXTRM, style_, ascent_, descent_);     
        width_   = 0;
 
        //lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
index 8627f5e62ea8fffeacc3d3e9f8b8855040ff7417..b09d6af34492814f1bf94041000d35f6c246187c 100644 (file)
@@ -24,7 +24,7 @@ public:
        ///
        MathXArray();
        ///
-       void metrics(MathStyles st) const;
+       void metrics(MathMetricsInfo const & st) const;
        ///
        void draw(Painter & pain, int x, int y) const;