]> git.lyx.org Git - features.git/commitdiff
halfway through fixing size of math in non-standard sizesd paragraohs like
authorAndré Pönitz <poenitz@gmx.net>
Fri, 19 Oct 2001 17:46:13 +0000 (17:46 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 19 Oct 2001 17:46:13 +0000 (17:46 +0000)
section headings...

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

31 files changed:
src/mathed/Makefile.am
src/mathed/formulabase.C
src/mathed/math_arrayinset.C
src/mathed/math_binominset.C
src/mathed/math_charinset.C
src/mathed/math_cursor.C
src/mathed/math_cursor.h
src/mathed/math_decorationinset.C
src/mathed/math_defs.h
src/mathed/math_deliminset.C
src/mathed/math_dotsinset.C
src/mathed/math_fracinset.C
src/mathed/math_funcinset.C
src/mathed/math_funcliminset.C
src/mathed/math_inset.C
src/mathed/math_inset.h
src/mathed/math_macro.C
src/mathed/math_macroarg.C
src/mathed/math_matrixinset.C
src/mathed/math_metricsinfo.C [new file with mode: 0644]
src/mathed/math_metricsinfo.h [new file with mode: 0644]
src/mathed/math_notinset.C
src/mathed/math_scriptinset.C
src/mathed/math_sizeinset.C
src/mathed/math_specialcharinset.C
src/mathed/math_stackrelinset.C
src/mathed/math_symbolinset.C
src/mathed/support.C
src/mathed/support.h
src/mathed/xarray.C
src/mathed/xarray.h

index 8b9a43e04a02eeca991ea7d7b43346fcba74f3e5..d9028062c75aeb2e21f0b226c1b641973c3dd582 100644 (file)
@@ -68,6 +68,8 @@ libmathed_la_SOURCES = \
        math_macrotable.h \
        math_matrixinset.C \
        math_matrixinset.h \
+       math_metricsinfo.h \
+       math_metricsinfo.C \
        math_nestinset.C \
        math_nestinset.h \
        math_notinset.C \
index f7b9e49b3364d2f59e9e25fda2dc6df101c3324c..eb67e308fc52f998305b5f3e9bc8fd2743bf075c 100644 (file)
@@ -123,6 +123,8 @@ void InsetFormulaBase::metrics(BufferView * bv, LyXFont const * f) const
                view_ = bv;
        if (f)
                font_ = f;
+       if (f)
+               lyxerr << "fontsize: " << f->size() << "\n";
        MathMetricsInfo mi(view_, font_, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
        par()->metrics(mi);
 }
@@ -194,9 +196,10 @@ void InsetFormulaBase::toggleInsetCursor(BufferView * bv)
                //x -= par()->xo();
                y -= par()->yo();
                y -= 3;
-               int asc;
-               int des;
-               math_font_max_dim(LM_TC_TEXTRM, LM_ST_TEXT, asc, des);
+               int asc = 0;
+               int des = 0;
+               MathMetricsInfo mi(bv, font_, LM_ST_TEXT);
+               math_font_max_dim(LM_TC_TEXTRM, mi, asc, des);
                bv->showLockedInsetCursor(x, y, asc, des);
        }
 
@@ -213,9 +216,10 @@ void InsetFormulaBase::showInsetCursor(BufferView * bv, bool)
                        mathcursor->getPos(x, y);
                        x -= par()->xo();
                        y -= par()->yo();
-                       int asc;
-                       int des;
-                       math_font_max_dim(LM_TC_TEXTRM, LM_ST_TEXT, asc, des);
+                       int asc = 0;
+                       int des = 0;
+                       MathMetricsInfo mi(bv, font_, LM_ST_TEXT);
+                       math_font_max_dim(LM_TC_TEXTRM, mi, asc, des);
                        bv->fitLockedInsetCursor(x, y, asc, des);
                }
                toggleInsetCursor(bv);
index 25c63eb7ce527baf7c246b83b884ad546f6cd4e5..0b06d00a5953ce723178fdccd1bc6ee1ccf8f543 100644 (file)
@@ -46,9 +46,9 @@ void MathArrayInset::write(MathWriteInfo & os) const
 
 void MathArrayInset::metrics(MathMetricsInfo const & st) const
 {
-       MathMetricsInfo m = st;
-       if (m.size == LM_ST_DISPLAY)
-               m.size = LM_ST_TEXT;
-       MathGridInset::metrics(m);
+       size_ = st;
+       if (size_.style == LM_ST_DISPLAY)
+               size_.style = LM_ST_TEXT;
+       MathGridInset::metrics(size_);
 }
 
index 1f04084c26370cd542054441b3d4cfca5458f229..a9f419a4922945bdedcfa3c984a0217f0c682ba6 100644 (file)
@@ -30,10 +30,10 @@ int MathBinomInset::dw() const
 
 void MathBinomInset::metrics(MathMetricsInfo const & st) const
 {
-       MathMetricsInfo m = st;
-       m.size   = smallerStyleFrac(m.size);
-       xcell(0).metrics(m);
-       xcell(1).metrics(m);
+       size_ = st;
+       smallerStyleFrac(size_);
+       xcell(0).metrics(size_);
+       xcell(1).metrics(size_);
        ascent_  = xcell(0).height() + 4 + 5;
        descent_ = xcell(1).height() + 4 - 5; 
        width_   = std::max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4; 
index 44d6884541e8ecfd12001f19e40df801db87e0bc..197f918525e1eb9cdc1e8e9eb25a1dfb874ed4f6 100644 (file)
@@ -60,19 +60,19 @@ MathInset * MathCharInset::clone() const
 
 int MathCharInset::ascent() const
 {
-       return mathed_char_ascent(code_, size(), char_);
+       return mathed_char_ascent(code_, size_, char_);
 }
 
 
 int MathCharInset::descent() const
 {
-       return mathed_char_descent(code_, size(), char_);
+       return mathed_char_descent(code_, size_, char_);
 }
 
 
 int MathCharInset::width() const
 {
-       return mathed_char_width(code_, size(), char_);
+       return mathed_char_width(code_, size_, char_);
 }
 
 
@@ -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_.size, x, y, char_);
+       drawChar(pain, code_, size_, x, y, char_);
 }
 
 
index 9623694133608c81de4f15056b94d30dd027e686..0fe0ef1dd6426c9bcc24906b1dd3d561452f5320 100644 (file)
@@ -915,12 +915,6 @@ void MathCursor::pullArg(bool goright)
 }
 
 
-MathStyles MathCursor::style() const
-{
-       return xarray().style();
-}
-
-
 void MathCursor::normalize() const
 {
 #ifdef WITH_WARNINGS
index ce9c89cc970261000833ac97303cb28cebd89e36..615d3cb7b93a1e0b5751aebbcb94ad1a7c5b44a1 100644 (file)
@@ -195,8 +195,6 @@ public:
        ///
        row_type row() const;
 
-       ///
-       MathStyles style() const;
        /// Make sure cursor position is valid
        void normalize() const;
 
index becc4183f45efe1600740d1d3e4d60e30ca38802..35a2515d6b07c57555e5b058544f684482abd497 100644 (file)
@@ -90,7 +90,7 @@ void MathDecorationInset::draw(Painter & pain, int x, int y) const
        if (wide()) 
                mathed_draw_deco(pain, x, y + dy_, width_, dh_, name_);
        else {
-               int w = 2 + mathed_char_width(LM_TC_VAR, size(), 'x'); 
+               int w = 2 + mathed_char_width(LM_TC_VAR, size_, 'x'); 
                mathed_draw_deco(pain, x + (width_ - w) / 2, y + dy_, w, dh_, name_);
        }
 }
index 51c6a7b28e232a5df4b83446b0de0868d0b1adff..6b49f5db9ddef9c22e46853ae8520678ea72662c 100644 (file)
 #endif
 
 
-/// Standard Math Sizes (Math mode styles)
-enum MathStyles {
-       ///
-       LM_ST_DISPLAY = 0,
-       ///
-       LM_ST_TEXT,
-       ///
-       LM_ST_SCRIPT,
-       ///
-       LM_ST_SCRIPTSCRIPT
-};
-
-// decrease math size for super- and subscripts
-MathStyles smallerStyleScript(MathStyles);
-
-// decrease math size for fractions
-MathStyles smallerStyleFrac(MathStyles st);
-
-
-
 /** The restrictions of a standard LaTeX math paragraph
   allows to get a small number of text codes (<30) */
 enum MathTextCodes  {
index dfa88844698cbeb6042ff9e44fc23251be673bac..cef56a13cc0f15ab3340ae896c93b4b2afdd1f8a 100644 (file)
@@ -65,7 +65,7 @@ void MathDelimInset::metrics(MathMetricsInfo const & st) const
        xcell(0).metrics(st);
        size_    = st;
        int a, d, w;
-       mathed_char_dim(LM_TC_VAR, size_.size,'I', a, d, w);
+       mathed_char_dim(LM_TC_VAR, 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 4c142c34c883bbdffa317c5af3e93532629100d8..40249eeff18bae8df1f36266da0da3811ff3640c 100644 (file)
@@ -35,7 +35,7 @@ void MathDotsInset::draw(Painter & pain, int x, int y) const
 void MathDotsInset::metrics(MathMetricsInfo const & st) const
 {
        size_ = st;
-       mathed_char_dim(LM_TC_VAR, size(), 'M', ascent_, descent_, width_);
+       mathed_char_dim(LM_TC_VAR, size_, 'M', ascent_, descent_, width_);
        switch (name_[0]) {
                case 'l': dh_ = 0; break;
                case 'c': dh_ = ascent_ / 2; break;
index 057366ba7bc3be4c4261b0decaad0ce480050b6d..e25adc5c0eb821fab3635623fc053e826f3e70bf 100644 (file)
@@ -22,7 +22,7 @@ MathInset * MathFracInset::clone() const
 void MathFracInset::metrics(MathMetricsInfo const & st) const
 {
        size_    = st;
-       size_.size = smallerStyleFrac(size_.size);
+       smallerStyleFrac(size_);
        xcell(0).metrics(size_);
        xcell(1).metrics(size_);
        width_   = std::max(xcell(0).width(), xcell(1).width()) + 4; 
index b5651b9df79b9488eb277d4b18972e80b6824aff..a255258670451e10cc09c6cb7678eb3dd186f88b 100644 (file)
@@ -52,7 +52,7 @@ void MathFuncInset::writeNormal(std::ostream & os) const
 void MathFuncInset::metrics(MathMetricsInfo const & st) const 
 {
        size_ = st;
-       mathed_string_dim(LM_TC_TEX, size_.size, name_, ascent_, descent_, width_);
+       mathed_string_dim(LM_TC_TEX, 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_.size, x, y, name_);
+       drawStr(pain, LM_TC_TEX, size_, x, y, name_);
 }
index f8f03cda1c00f81f96348c960fdf04ed2fa03403..2788b420516a14821675a29966394e8965d655de 100644 (file)
@@ -19,7 +19,7 @@ MathInset * MathFuncLimInset::clone() const
 
 bool MathFuncLimInset::isScriptable() const
 {
-       return size_.size == LM_ST_DISPLAY;
+       return size_.style == LM_ST_DISPLAY;
 }
 
 
@@ -38,7 +38,7 @@ void MathFuncLimInset::writeNormal(ostream & os) const
 void MathFuncLimInset::metrics(MathMetricsInfo const & st) const
 {
        size_ = st;
-       mathed_string_dim(LM_TC_TEXTRM, size_.size, sym_->name,
+       mathed_string_dim(LM_TC_TEXTRM, size_, sym_->name,
                ascent_, descent_, width_);
 }
 
@@ -47,5 +47,5 @@ void MathFuncLimInset::draw(Painter & pain, int x, int y) const
 {  
        xo(x);
        yo(y);
-       drawStr(pain, LM_TC_TEXTRM, size_.size, x, y, sym_->name);
+       drawStr(pain, LM_TC_TEXTRM, size_, x, y, sym_->name);
 }
index 0b43d32b91b4fb6b7e475c4261bf475313a84762..114ab8a4827442a96adb9d007727345b67505c9e 100644 (file)
@@ -42,12 +42,6 @@ int MathInset::height() const
 }
 
 
-MathStyles MathInset::size() const
-{
-       return size_.size;
-}
-
-
 std::ostream & operator<<(std::ostream & os, MathInset const & inset)
 {
        MathWriteInfo wi(0, os, false);
@@ -226,18 +220,6 @@ void MathInset::dump() const
 }
 
 
-void MathInset::push_back(unsigned char, MathTextCodes)
-{
-       lyxerr << "can't push without a cell\n";
-}
-
-
-void MathInset::push_back(MathInset *)
-{
-       lyxerr << "can't push without a cell\n";
-}
-
-
 bool MathInset::covers(int x, int y) const
 {
        //lyxerr << "cover? p: " << this << " x: " << x << " y: " <<  y
index 28a56d845b25d123eb41b25afb3905ab07bd4440..d72bcfa0a50cdb9d27dc9e456f79d5f15f44b83e 100644 (file)
@@ -29,6 +29,7 @@
 #endif
 
 #include "xarray.h"
+#include "math_defs.h"
 
 /** Abstract base class for all math objects.
     A math insets is for use of the math editor only, it isn't a
@@ -49,27 +50,6 @@ 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 {
@@ -144,8 +124,6 @@ public:
        virtual int width() const { return 2; }
        ///
        virtual int height() const;
-       ///
-       virtual MathStyles size() const;
 
        /// Where should we go when we press the up cursor key?
        virtual bool idxUp(idx_type & idx, pos_type & pos) const;
@@ -271,10 +249,6 @@ public:
        /// identifies things that can get \limits or \nolimits
        virtual bool takesLimits() const { return false; }
 
-       ///
-       virtual void push_back(MathInset *);
-       ///
-       virtual void push_back(unsigned char c, MathTextCodes code);
        ///
        virtual void dump() const;
 
index 7e17da748cd20b867aa2a422b9411043e194fa92..f7a327c3f2d1815f672daca7b6fdc0804166a9be 100644 (file)
@@ -73,7 +73,7 @@ void MathMacro::metrics(MathMetricsInfo const & st) const
 {
        if (defining()) {
                size_ = st;
-               mathed_string_dim(LM_TC_TEX, size_.size, name(), ascent_, descent_, width_);
+               mathed_string_dim(LM_TC_TEX, size_, name(), ascent_, descent_, width_);
                return;
        }
 
@@ -85,12 +85,12 @@ void MathMacro::metrics(MathMetricsInfo const & st) const
                ascent_  = expanded_.ascent()  + 2;
                descent_ = expanded_.descent() + 2;
 
-               width_ +=  mathed_string_width(LM_TC_TEXTRM, size_.size, name()) + 10;
+               width_ +=  mathed_string_width(LM_TC_TEXTRM, size_, name()) + 10;
 
                int lasc;
                int ldes;
                int lwid;
-               mathed_string_dim(LM_TC_TEXTRM, size_.size, "#1: ", lasc, ldes, lwid);
+               mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid);
 
                for (idx_type i = 0; i < nargs(); ++i) {
                        MathXArray const & c = xcell(i);
@@ -120,22 +120,22 @@ void MathMacro::draw(Painter & pain, int x, int y) const
        metrics(size_);
 
        if (defining()) {
-               drawStr(pain, LM_TC_TEX, size_.size, x, y, name());
+               drawStr(pain, LM_TC_TEX, size_, x, y, name());
                return;
        }
 
        if (editing()) {
                int h = y - ascent() + 2 + expanded_.ascent();
-               drawStr(pain, LM_TC_TEXTRM, size_.size, x + 3, h, name());
+               drawStr(pain, LM_TC_TEXTRM, size_, x + 3, h, name());
 
-               int const w = mathed_string_width(LM_TC_TEXTRM, size_.size, name());
+               int const w = mathed_string_width(LM_TC_TEXTRM, 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_.size, "#1: ", lasc, ldes, lwid);
+               mathed_string_dim(LM_TC_TEXTRM, 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_.size, x + 3, h, str);
+                       drawStr(pain, LM_TC_TEX, size_, x + 3, h, str);
                        h += std::max(c.descent(), ldes) + 5;
                }
                return;
index ab1b2179572793dac30320d6fb229ec08110ea1a..6ed3e3e04a1468e88b592cb2fe8ed88db78b1437 100644 (file)
@@ -43,7 +43,7 @@ void MathMacroArgument::metrics(MathMetricsInfo const & st) const
                ascent_  = xcell(0).ascent();
                descent_ = xcell(0).descent();
        } else
-               mathed_string_dim(LM_TC_TEX, size_.size, str_, ascent_, descent_, width_);
+               mathed_string_dim(LM_TC_TEX, 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_.size, x, y, str_);
+               drawStr(pain, LM_TC_TEX, size_, x, y, str_);
 }
 
 
index 690dc0acad3fe3c4c1d9ca5a1e8018e0cf6a6834..9c289572c6fd45d6f4bf555d4261904f914ef1e3 100644 (file)
@@ -143,7 +143,7 @@ int MathMatrixInset::defaultColSpace(col_type col)
 void MathMatrixInset::metrics(MathMetricsInfo const & st) const
 {
        size_ = st;
-       size_.size = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY;
+       size_.style = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY;
 
        // let the cells adjust themselves
        MathGridInset::metrics(size_);
@@ -156,7 +156,7 @@ void MathMatrixInset::metrics(MathMetricsInfo const & st) const
        if (numberedType()) {
                int l = 0;
                for (row_type row = 0; row < nrows(); ++row)
-                       l = std::max(l, mathed_string_width(LM_TC_BF, size(), nicelabel(row)));
+                       l = std::max(l, mathed_string_width(LM_TC_BF, size_, nicelabel(row)));
 
                if (l)
                        width_ += 30 + l;
@@ -165,7 +165,7 @@ void MathMatrixInset::metrics(MathMetricsInfo const & st) const
        // make it at least as high as the current font
        int asc = 0;
        int des = 0;
-       math_font_max_dim(LM_TC_TEXTRM, LM_ST_TEXT, asc, des);
+       math_font_max_dim(LM_TC_TEXTRM, size_, asc, des);
        ascent_  = std::max(ascent_,  asc);
        descent_ = std::max(descent_, des);
 }
@@ -179,10 +179,10 @@ void MathMatrixInset::draw(Painter & pain, int x, int y) const
        MathGridInset::draw(pain, x, y);
 
        if (numberedType()) {
-               int xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20;
+               int const xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20;
                for (row_type row = 0; row < nrows(); ++row) {
-                       int yy = y + rowinfo_[row].offset_;
-                       drawStr(pain, LM_TC_BF, size(), xx, yy, nicelabel(row));
+                       int const yy = y + rowinfo_[row].offset_;
+                       drawStr(pain, LM_TC_BF, size_, xx, yy, nicelabel(row));
                }
        }
 }
diff --git a/src/mathed/math_metricsinfo.C b/src/mathed/math_metricsinfo.C
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/mathed/math_metricsinfo.h b/src/mathed/math_metricsinfo.h
new file mode 100644 (file)
index 0000000..db5a3c2
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef MATH_METRICSINFO
+#define MATH_METRICSINFO
+
+class BufferView;
+class LyXFont;
+
+
+/// Standard Math Sizes (Math mode styles)
+enum MathStyles {
+       ///
+       LM_ST_DISPLAY = 0,
+       ///
+       LM_ST_TEXT,
+       ///
+       LM_ST_SCRIPT,
+       ///
+       LM_ST_SCRIPTSCRIPT
+};
+
+
+struct MathMetricsInfo {
+       ///
+       MathMetricsInfo()
+               : view(0), font(0), style(LM_ST_TEXT)
+       {}
+       ///
+       MathMetricsInfo(BufferView * v, LyXFont const * f, MathStyles s)
+               : view(v), font(f), style(s)
+       {}
+
+       ///
+       BufferView * view;
+       ///
+       LyXFont const * font;
+       ///
+       MathStyles style;
+};
+
+#endif
index 9ebbb3f1bfb008c3a0bc9f383b33d502e78fe0f2..5e72280b84c96dec0ff94dd292db186e5fed3371 100644 (file)
@@ -32,9 +32,9 @@ void MathNotInset::metrics(MathMetricsInfo const & st) const
 {
        size_ = st;
        if (math_font_available(LM_TC_CMSY))
-               mathed_char_dim(LM_TC_CMSY, size(), 54, 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_);
+               mathed_char_dim(LM_TC_VAR, size_, '/', ascent_, descent_, width_);
        width_ = 0;
 }
 
@@ -45,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 cc9c481bdbb4f0c80b97e341d1da11b59efee07a..f3622459120e3be47c2f907e88d5a6e7fc04eae3 100644 (file)
@@ -100,7 +100,7 @@ int MathScriptInset::dy1(MathInset const * nuc) const
                asc += na + 2;
        else 
                asc = std::max(asc, na);
-       asc = std::max(asc, mathed_char_ascent(LM_TC_VAR, LM_ST_TEXT, 'I'));
+       asc = std::max(asc, mathed_char_ascent(LM_TC_VAR, size_, 'I'));
        return asc;
 }
 
@@ -162,21 +162,21 @@ int MathScriptInset::nwid(MathInset const * nuc) const
 {
        return nuc ?
                nuc->width() :
-               mathed_char_width(LM_TC_TEX, LM_ST_TEXT, '.');
+               mathed_char_width(LM_TC_TEX, size_, '.');
 }
 
 
 int MathScriptInset::nasc(MathInset const * nuc) const
 {
        return nuc ? nuc->ascent()
-               : mathed_char_ascent(LM_TC_VAR, LM_ST_TEXT, 'I');
+               : mathed_char_ascent(LM_TC_VAR, size_, 'I');
 }
 
 
 int MathScriptInset::ndes(MathInset const * nuc) const
 {
        return nuc ? nuc->descent()
-               : mathed_char_descent(LM_TC_VAR, LM_ST_TEXT, 'I');
+               : mathed_char_descent(LM_TC_VAR, size_, 'I');
 }
 
 
@@ -211,12 +211,15 @@ void MathScriptInset::draw(MathInset const * nuc, Painter & pain,
 {  
        xo(x);
        yo(y);
+
        if (nuc)
                nuc->draw(pain, x + dxx(nuc), y);
        else
-               drawStr(pain, LM_TC_TEX, LM_ST_TEXT, x + dxx(nuc), y, ".");
+               drawStr(pain, LM_TC_TEX, size_, x + dxx(nuc), y, ".");
+
        if (hasUp())
                up().draw(pain, x + dx1(nuc), y - dy1(nuc));
+
        if (hasDown())
                down().draw(pain, x + dx0(nuc), y + dy0(nuc));
 }
index 389b233597ce63cd4124e7b270c72fef3b8f48c0..a7d6221c8cbc0aaaeb407e4ba11e71a7ca4388fd 100644 (file)
@@ -29,7 +29,7 @@ void MathSizeInset::draw(Painter & pain, int x, int y) const
 void MathSizeInset::metrics(MathMetricsInfo const & st) const
 {
        size_ = st;
-       size_.size = MathStyles(key_->id);
+       size_.style = MathStyles(key_->id);
        xcell(0).metrics(size_);
        ascent_   = xcell(0).ascent_;
        descent_  = xcell(0).descent_;
index 05c34659b793db3b781d7823aea6472fd73d3e40..0c9d76fec825bc45f834c214fa4dff82bbce3220 100644 (file)
@@ -20,19 +20,19 @@ MathInset * MathSpecialCharInset::clone() const
 
 int MathSpecialCharInset::ascent() const
 {
-       return mathed_char_ascent(LM_TC_CONST, size(), char_);
+       return mathed_char_ascent(LM_TC_CONST, size_, char_);
 }
 
 
 int MathSpecialCharInset::descent() const
 {
-       return mathed_char_descent(LM_TC_CONST, size(), char_);
+       return mathed_char_descent(LM_TC_CONST, size_, char_);
 }
 
 
 int MathSpecialCharInset::width() const
 {
-       return mathed_char_width(LM_TC_CONST, size(), char_);
+       return mathed_char_width(LM_TC_CONST, size_, char_);
 }
 
 
@@ -46,7 +46,7 @@ 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_);
 }
 
 
index 162a8bdf6400079859d86da312fc4732b6569737..3db27793445493a5b0f743b9d04018a612ccff4d 100644 (file)
@@ -20,7 +20,7 @@ MathInset * MathStackrelInset::clone() const
 void MathStackrelInset::metrics(MathMetricsInfo const & st) const
 {
        size_    = st;
-       size_.size = smallerStyleFrac(size_.size);
+       smallerStyleFrac(size_);
        xcell(0).metrics(size_);
        xcell(1).metrics(st);
        width_   = std::max(xcell(0).width(), xcell(1).width()) + 4; 
index dd7915780d3f628404d7cea75513126bdde1b8cc..f9170c1b2defc55b3b856a4e43f70e7211d108aa 100644 (file)
@@ -61,12 +61,11 @@ MathTextCodes MathSymbolInset::code2() 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,
-                               ascent_, descent_, width_);
-               if (Code == LM_TC_CMEX) {
-                       h_ = 4*descent_/5;
+       MathTextCodes c = code();
+       if (sym_->latex_font_id > 0 && math_font_available(c)) {
+               mathed_char_dim(c, size_, sym_->latex_font_id, ascent_, descent_, width_);
+               if (c == LM_TC_CMEX) {
+                       h_ = 4 * descent_ / 5;
                        ascent_  += h_;
                        descent_ -= h_;
                }
@@ -74,9 +73,9 @@ void MathSymbolInset::metrics(MathMetricsInfo const & st) const
        }
 
        if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
-               mathed_char_dim(code2(), size(), sym_->id, ascent_, descent_, width_);
+               mathed_char_dim(code2(), size_, sym_->id, ascent_, descent_, width_);
        else
-               mathed_string_dim(LM_TC_TEX, size(), sym_->name, ascent_, descent_, width_);
+               mathed_string_dim(LM_TC_TEX, size_, sym_->name, ascent_, descent_, width_);
 }
 
 
@@ -86,11 +85,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);
+               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, 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);
 }
 
 
@@ -102,7 +101,7 @@ bool MathSymbolInset::isRelOp() const
 
 bool MathSymbolInset::isScriptable() const
 {
-       return size() == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
+       return size_.style == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
 }
 
 
index 9cb0cd114e5775116baad1b792ea3ce3d434954a..513b8f96a1117be7d49f59165a0c51218899a813 100644 (file)
@@ -7,6 +7,7 @@
 #include "FontLoader.h"
 #include "font.h"
 #include "math_defs.h"
+#include "math_inset.h"
 #include "math_parser.h"
 #include "Painter.h"
 #include "debug.h"
@@ -188,11 +189,20 @@ LyXFont const & whichFontBase(MathTextCodes type)
 }
 
 
-LyXFont whichFont(MathTextCodes type, MathStyles size)
+LyXFont whichFont(MathTextCodes type, MathMetricsInfo const & size)
 {
        LyXFont f = whichFontBase(type);
+       if (size.font) {
+#ifdef WITH_WARNINGS 
+#warning Want to fix formula sizes in headings? Look here!
+#endif
+               // unfortunatly, size.font is sometimes nonzero and size.font->size()
+               // is huge...
+               //lyxerr << "setting font size to " << size.font->size() << "\n";
+               //f.setSize(size.font->size());
+       }
 
-       switch (size) {
+       switch (size.style) {
        case LM_ST_DISPLAY:
                if (type == LM_TC_BOLDSYMB || type == LM_TC_CMEX) {
                        f.incSize();
@@ -215,7 +225,7 @@ LyXFont whichFont(MathTextCodes type, MathStyles size)
                break;
 
        default:
-               lyxerr << "Math Error: wrong font size: " << size << endl;
+               lyxerr << "Math Error: wrong font size: " << size.style << endl;
                break;
        }
 
@@ -235,8 +245,7 @@ bool math_font_available(MathTextCodes type)
 {
        if (!font_available_initialized[type]) {
                font_available_initialized[type] = true;
-               font_available[type] =
-                       fontloader.available(whichFontBase(type));
+               font_available[type] = fontloader.available(whichFontBase(type));
        }
        return font_available[type];
 }
@@ -505,8 +514,8 @@ deco_struct const * search_deco(string const & name)
 } // namespace anon
 
 
-void mathed_char_dim(MathTextCodes type, MathStyles size, unsigned char c,
-       int & asc, int & des, int & wid)
+void mathed_char_dim(MathTextCodes type, MathMetricsInfo const & size,
+       unsigned char c, int & asc, int & des, int & wid)
 {
        LyXFont const font = whichFont(type, size);
        des = lyxfont::descent(c, font);
@@ -515,8 +524,8 @@ void mathed_char_dim(MathTextCodes type, MathStyles size, unsigned char c,
 }
 
 
-int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c,
-       int & asc, int & des)
+int mathed_char_height(MathTextCodes type, MathMetricsInfo const & size,
+       unsigned char c, int & asc, int & des)
 {
        LyXFont const font = whichFont(type, size);
        des = lyxfont::descent(c, font);
@@ -525,7 +534,8 @@ int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c,
 }
 
 
-int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c)
+int mathed_char_height(MathTextCodes type, MathMetricsInfo const & size,
+       unsigned char c)
 {
        int asc;
        int des;
@@ -533,21 +543,24 @@ int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c)
 }
 
 
-int mathed_char_ascent(MathTextCodes type, MathStyles size, unsigned char c)
+int mathed_char_ascent(MathTextCodes type, MathMetricsInfo const & size,
+       unsigned char c)
 {
        LyXFont const font = whichFont(type, size);
        return lyxfont::ascent(c, font);
 }
 
 
-int mathed_char_descent(MathTextCodes type, MathStyles size, unsigned char c)
+int mathed_char_descent(MathTextCodes type, MathMetricsInfo const & size,
+       unsigned char c)
 {
        LyXFont const font = whichFont(type, size);
        return lyxfont::descent(c, font);
 }
 
 
-int mathed_char_width(MathTextCodes type, MathStyles size, unsigned char c)
+int mathed_char_width(MathTextCodes type, MathMetricsInfo const & size,
+       unsigned char c)
 {
        LyXFont const font = whichFont(type, size);
        if (isBinaryOp(c, type))
@@ -557,16 +570,16 @@ int mathed_char_width(MathTextCodes type, MathStyles size, unsigned char c)
 }
 
 
-void mathed_string_dim(MathTextCodes type, MathStyles size, string const & s,
-                        int & asc, int & des, int & wid)
+void mathed_string_dim(MathTextCodes type, MathMetricsInfo const & size,
+       string const & s, int & asc, int & des, int & wid)
 {
        mathed_string_height(type, size, s, asc, des);
        wid = mathed_string_width(type, size, s);
 }
 
 
-int mathed_string_height(MathTextCodes type, MathStyles size, string const & s,
-                        int & asc, int & des)
+int mathed_string_height(MathTextCodes type, MathMetricsInfo const & size,
+       string const & s, int & asc, int & des)
 {
        LyXFont const font = whichFont(type, size);
        asc = des = 0;
@@ -578,7 +591,8 @@ int mathed_string_height(MathTextCodes type, MathStyles size, string const & s,
 }
 
 
-int mathed_string_width(MathTextCodes type, MathStyles size, string const & s)
+int mathed_string_width(MathTextCodes type, MathMetricsInfo const & size,
+       string const & s)
 {
        return lyxfont::width(s, whichFont(type, size));
 }
@@ -653,15 +667,15 @@ void mathed_draw_deco(Painter & pain, int x, int y, int w, int h,
 
 
 // In the future maybe we use a better fonts renderer
-void drawStr(Painter & pain, MathTextCodes type, MathStyles siz,
+void drawStr(Painter & pain, MathTextCodes type, MathMetricsInfo const & siz,
        int x, int y, string const & s)
 {
        pain.text(x, y, s, whichFont(type, siz));
 }
 
 
-void drawChar
-       (Painter & pain, MathTextCodes type, MathStyles siz, int x, int y, char c)
+void drawChar(Painter & pain, MathTextCodes type, MathMetricsInfo const & siz,
+       int x, int y, char c)
 {
        string s;
        if (isBinaryOp(c, type))
@@ -674,30 +688,29 @@ void drawChar
 
 
 // decrease math size for super- and subscripts
-MathStyles smallerStyleScript(MathStyles st)
+void smallerStyleScript(MathMetricsInfo & st)
 {
-       switch (st) {
+       switch (st.style) {
                case LM_ST_DISPLAY:
-               case LM_ST_TEXT:    st = LM_ST_SCRIPT; break;
-               default:            st = LM_ST_SCRIPTSCRIPT;
+               case LM_ST_TEXT:    st.style = LM_ST_SCRIPT; break;
+               default:            st.style = LM_ST_SCRIPTSCRIPT;
        }
-       return st;
 }
 
 
 // decrease math size for fractions
-MathStyles smallerStyleFrac(MathStyles st)
+void smallerStyleFrac(MathMetricsInfo & st)
 {
-       switch (st) {
-               case LM_ST_DISPLAY: st = LM_ST_TEXT; break;
-               case LM_ST_TEXT:    st = LM_ST_SCRIPT; break;
-               default:            st = LM_ST_SCRIPTSCRIPT;
+       switch (st.style) {
+               case LM_ST_DISPLAY: st.style = LM_ST_TEXT; break;
+               case LM_ST_TEXT:    st.style = LM_ST_SCRIPT; break;
+               default:            st.style = LM_ST_SCRIPTSCRIPT;
        }
-       return st;
 }
 
 
-void math_font_max_dim(MathTextCodes code, MathStyles siz, int & asc, int & des)
+void math_font_max_dim(MathTextCodes code, MathMetricsInfo const & siz,
+       int & asc, int & des)
 {
        LyXFont font = whichFont(code, siz);
        asc = lyxfont::maxAscent(font);
index 3352ec379f6e1a226f60b0bcb521d06687305dd9..44cbb93ddd614906c4e89fc8a41bdf476372ad7a 100644 (file)
@@ -8,37 +8,52 @@
 
 class Painter;
 class latexkeys;
+class MathMetricsInfo;
 
 extern char const * latex_mathspace[];
 
-int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c,
-       int & asc, int & des);
-void mathed_char_dim(MathTextCodes type, MathStyles size, unsigned char c,
-       int & asc, int & des, int & wid);
-int mathed_char_width(MathTextCodes type, MathStyles size, unsigned char c);
-int mathed_char_ascent(MathTextCodes type, MathStyles size, unsigned char c);
-int mathed_char_descent(MathTextCodes type, MathStyles size, unsigned char c);
+int mathed_char_height(MathTextCodes type, MathMetricsInfo const & size,
+       unsigned char c, int & asc, int & des);
+void mathed_char_dim(MathTextCodes type, MathMetricsInfo const & size,
+       unsigned char c, int & asc, int & des, int & wid);
+int mathed_char_width(MathTextCodes type, MathMetricsInfo const & size,
+       unsigned char c);
+int mathed_char_ascent(MathTextCodes type, MathMetricsInfo const & size,
+       unsigned char c);
+int mathed_char_descent(MathTextCodes type, MathMetricsInfo const & size,
+       unsigned char c);
 
 void mathed_draw_deco(Painter & pain, int x, int y, int w, int h,
        string const & name);
 
-void mathed_string_dim(MathTextCodes type, MathStyles size, string const & s,
-  int & asc, int & des, int & wid);
-int mathed_string_height(MathTextCodes type, MathStyles size, string const & s,
-  int & asc, int & des);
+void mathed_string_dim(MathTextCodes type, MathMetricsInfo const & size,
+       string const & s, int & asc, int & des, int & wid);
+int mathed_string_height(MathTextCodes type, MathMetricsInfo const & size,
+       string const & s, int & asc, int & des);
 
-int mathed_string_width(MathTextCodes type, MathStyles size, string const & s);
-int mathed_string_ascent(MathTextCodes type, MathStyles size, string const & s);
-int mathed_string_descent(MathTextCodes type, MathStyles size, string const & s);
+int mathed_string_width(MathTextCodes type, MathMetricsInfo const & size,
+       string const & s);
+int mathed_string_ascent(MathTextCodes type, MathMetricsInfo const & size,
+       string const & s);
+int mathed_string_descent(MathTextCodes type, MathMetricsInfo const & size,
+       string const & s);
 
-void drawStr(Painter & pain, MathTextCodes type, MathStyles siz,
+void drawStr(Painter & pain, MathTextCodes type, MathMetricsInfo const & siz,
        int x, int y, string const & s);
-void drawChar(Painter & pain, MathTextCodes type, MathStyles siz,
+void drawChar(Painter & pain, MathTextCodes type, MathMetricsInfo const & siz,
        int x, int y, char c);
 
-void math_font_max_dim
-       (MathTextCodes code, MathStyles siz, int & asc, int & desc);
+void math_font_max_dim(MathTextCodes code, MathMetricsInfo const & siz,
+       int & asc, int & desc);
 
 bool math_font_available(MathTextCodes code);
 
+// decrease math size for super- and subscripts
+void smallerStyleScript(MathMetricsInfo &);
+
+// decrease math size for fractions
+void smallerStyleFrac(MathMetricsInfo & st);
+
+
+
 #endif
index ffeee12e3a624518a5976db0933355b45f342996..54b83322bafa6f8ec9a74cb184c9aecd6ca98565 100644 (file)
 
 
 MathXArray::MathXArray()
-       : width_(0), ascent_(0), descent_(0), xo_(0), yo_(0), style_(LM_ST_TEXT)
+       : width_(0), ascent_(0), descent_(0), xo_(0), yo_(0), size_()
 {}
 
 
 void MathXArray::metrics(MathMetricsInfo const & st) const
 {
-       style_ = st.size;
-       mathed_char_dim(LM_TC_VAR, style_, 'I', ascent_, descent_, width_);
+       size_ = st;
+       mathed_char_dim(LM_TC_VAR, st, 'I', ascent_, descent_, width_);
 
        if (data_.empty()) 
                return;
 
-       math_font_max_dim(LM_TC_TEXTRM, style_, ascent_, descent_);     
-       width_   = 0;
+       math_font_max_dim(LM_TC_TEXTRM, st, ascent_, descent_); 
+       width_ = 0;
 
        //lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
        
index b09d6af34492814f1bf94041000d35f6c246187c..b67d3b96815d1409665d53cb53ec1be8ed29df45 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <iosfwd>
 #include "array.h"
-#include "math_defs.h"
+#include "math_metricsinfo.h"
 
 #ifdef __GNUG__
 #pragma interface
@@ -45,8 +45,6 @@ public:
        int height() const { return ascent_ + descent_; }
        ///
        int width() const { return width_; }
-       ///
-       MathStyles style() const { return style_; }
 
        ///
        const_iterator begin() const { return data_.begin(); }
@@ -67,7 +65,7 @@ public:
        ///
        mutable int yo_;
        ///
-       mutable MathStyles style_;
+       mutable MathMetricsInfo size_;
 };
 
 std::ostream & operator<<(std::ostream & os, MathXArray const & ar);