]> git.lyx.org Git - features.git/commitdiff
fix a few of the recent width cache related problems
authorAndré Pönitz <poenitz@gmx.net>
Tue, 3 Feb 2004 11:21:08 +0000 (11:21 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 3 Feb 2004 11:21:08 +0000 (11:21 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8388 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_charinset.C
src/mathed/math_charinset.h
src/mathed/math_diminset.h
src/mathed/math_hullinset.C
src/mathed/math_symbolinset.C
src/mathed/math_symbolinset.h
src/mathed/math_unknowninset.C

index d6c2331cb338975b2bb04435c137150afb285cfb..8578aa81486d7eec75be2960c4da77436dd69d2b 100644 (file)
@@ -84,7 +84,7 @@ void MathCharInset::metrics(MetricsInfo & mi, Dimension & dim) const
                width_ += 2 * font_metrics::width(' ', font_);
        lyxerr << "MathCharInset::metrics: " << dim << endl;
 #endif
-       dim_ = dim;
+       width_ = dim.wid;
 }
 
 
index 1cad4cf94fa515c653a22ceb946cdc38e17eccee..76a1feab001a61fb5476971bf6ae88a0504ad211 100644 (file)
 #ifndef MATH_CHARINSET_H
 #define MATH_CHARINSET_H
 
-#include "math_diminset.h"
+#include "math_inset.h"
 
-#warning this should not derive from the fat MathDimInset
 
 /// The base character inset.
-class MathCharInset : public MathDimInset {
+class MathCharInset : public MathInset {
 public:
        ///
        explicit MathCharInset(char c);
@@ -31,6 +30,8 @@ public:
        void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
        ///
        void drawT(TextPainter &, int x, int y) const;
+       ///
+       int width() const { return width_; }
 
        ///
        void write(WriteStream & os) const;
@@ -48,5 +49,7 @@ public:
 private:
        /// the character
        char char_;
+       /// cached width
+       mutable int width_;
 };
 #endif
index 636baeeb9aa731405ddd02374d096a01d3b28b01..908b23f01aecb87c6dff6e84e7efc03973c5c965 100644 (file)
@@ -48,4 +48,5 @@ protected:
        ///
        mutable int yo_;
 };
+
 #endif
index 0d3dadbccd3d8f85addf4f9bcddc6de4c3e91803..11d53bbdca919f4ac666a3beee153510dc7612ca 100644 (file)
@@ -810,7 +810,7 @@ MathHullInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                                else
                                        for (row_type row = 0; row < nrows(); ++row)
                                                numbered(row, !old);
-                               //cur.bv()->owner()->message(old ? _("No number") : _("Number"));
+                               cur.message(old ? _("No number") : _("Number"));
                        }
                        return DispatchResult(true, true);
 
@@ -819,7 +819,7 @@ MathHullInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                                row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
                                ////recordUndo(cur, Undo::INSERT);
                                bool old = numbered(r);
-                               //cur.bv()->owner()->message(old ? _("No number") : _("Number"));
+                               cur.message(old ? _("No number") : _("Number"));
                                numbered(r, !old);
                        }
                        return DispatchResult(true, true);
@@ -1152,7 +1152,7 @@ void MathHullInset::revealCodes(LCursor & cur) const
                return;
        ostringstream os;
        cur.info(os);
-       cur.bv().owner()->message(os.str());
+       cur.message(os.str());
 /*
        // write something to the minibuffer
        // translate to latex
@@ -1177,7 +1177,7 @@ void MathHullInset::revealCodes(LCursor & cur) const
                res = res.substr(pos - 30);
        if (res.size() > 60)
                res = res.substr(0, 60);
-       bv.owner()->message(res);
+       cur.message(res);
 */
 }
 
@@ -1372,7 +1372,7 @@ void mathDispatchCreation(LCursor & cur, FuncRequest const & cmd,
                cur.bv().getLyXText()->cutSelection(true, false);
                openNewInset(cur, f);
        }
-       cmd.message(N_("Math editor mode"));
+       cur.message(N_("Math editor mode"));
 }
 
 } // namespace anon
index 995acee314642552d71a37df15a94f3e446e1e86..8a4359cff5fc60abd1bcd79ef12b7c7717271ac3 100644 (file)
@@ -91,6 +91,8 @@ void MathSymbolInset::metrics(MetricsInfo & mi, Dimension & dim) const
        if (mi.base.style == LM_ST_DISPLAY)
                if (sym_->inset == "cmex" || sym_->extra == "funclim")
                        scriptable_ = true;
+
+       width_ = dim.wid;
 }
 
 
index f8f2fb276b487dbad784925a3cb06e3fd77ae0d7..ebda7fc20f2d4e9ab8d67aeb4c04f60cbdce1fd8 100644 (file)
@@ -34,6 +34,9 @@ public:
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
        void draw(PainterInfo &, int x, int y) const;
+       ///
+       int width() const { return width_; }
+
        ///
        bool isRelOp() const;
        /// do we take scripts?
@@ -69,6 +72,8 @@ private:
        latexkeys const * sym_;
        ///
        mutable int h_;
+       /// cached width
+       mutable int width_;
        ///
        mutable bool scriptable_;
 };
index a4075d2b3d3dab47940b9ac954b0e2e6b7003d29..dd1284027fecb92811963f7bf72b9bec715c5470 100644 (file)
@@ -16,7 +16,6 @@
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
 
-
 using std::string;
 using std::auto_ptr;
 
@@ -53,6 +52,7 @@ void MathUnknownInset::normalize(NormalStream & os) const
 void MathUnknownInset::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        mathed_string_dim(mi.base.font, name_, dim);
+       dim_ = dim;
 }
 
 
@@ -62,6 +62,8 @@ void MathUnknownInset::draw(PainterInfo & pi, int x, int y) const
                drawStrBlack(pi, x, y, name_);
        else
                drawStrRed(pi, x, y, name_);
+       xo_ = x;
+       yo_ = y;
 }