From 04296d3738e954982e9c087cc1ca7aaa792392ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Tue, 3 Feb 2004 11:21:08 +0000 Subject: [PATCH] fix a few of the recent width cache related problems git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8388 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_charinset.C | 2 +- src/mathed/math_charinset.h | 9 ++++++--- src/mathed/math_diminset.h | 1 + src/mathed/math_hullinset.C | 10 +++++----- src/mathed/math_symbolinset.C | 2 ++ src/mathed/math_symbolinset.h | 5 +++++ src/mathed/math_unknowninset.C | 4 +++- 7 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/mathed/math_charinset.C b/src/mathed/math_charinset.C index d6c2331cb3..8578aa8148 100644 --- a/src/mathed/math_charinset.C +++ b/src/mathed/math_charinset.C @@ -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; } diff --git a/src/mathed/math_charinset.h b/src/mathed/math_charinset.h index 1cad4cf94f..76a1feab00 100644 --- a/src/mathed/math_charinset.h +++ b/src/mathed/math_charinset.h @@ -12,12 +12,11 @@ #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 diff --git a/src/mathed/math_diminset.h b/src/mathed/math_diminset.h index 636baeeb9a..908b23f01a 100644 --- a/src/mathed/math_diminset.h +++ b/src/mathed/math_diminset.h @@ -48,4 +48,5 @@ protected: /// mutable int yo_; }; + #endif diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 0d3dadbccd..11d53bbdca 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -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 diff --git a/src/mathed/math_symbolinset.C b/src/mathed/math_symbolinset.C index 995acee314..8a4359cff5 100644 --- a/src/mathed/math_symbolinset.C +++ b/src/mathed/math_symbolinset.C @@ -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; } diff --git a/src/mathed/math_symbolinset.h b/src/mathed/math_symbolinset.h index f8f2fb276b..ebda7fc20f 100644 --- a/src/mathed/math_symbolinset.h +++ b/src/mathed/math_symbolinset.h @@ -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_; }; diff --git a/src/mathed/math_unknowninset.C b/src/mathed/math_unknowninset.C index a4075d2b3d..dd1284027f 100644 --- a/src/mathed/math_unknowninset.C +++ b/src/mathed/math_unknowninset.C @@ -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; }