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
This commit is contained in:
André Pönitz 2004-02-03 11:21:08 +00:00
parent a436d4fcfb
commit 04296d3738
7 changed files with 23 additions and 10 deletions

View File

@ -84,7 +84,7 @@ void MathCharInset::metrics(MetricsInfo & mi, Dimension & dim) const
width_ += 2 * font_metrics::width(' ', font_); width_ += 2 * font_metrics::width(' ', font_);
lyxerr << "MathCharInset::metrics: " << dim << endl; lyxerr << "MathCharInset::metrics: " << dim << endl;
#endif #endif
dim_ = dim; width_ = dim.wid;
} }

View File

@ -12,12 +12,11 @@
#ifndef MATH_CHARINSET_H #ifndef MATH_CHARINSET_H
#define 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. /// The base character inset.
class MathCharInset : public MathDimInset { class MathCharInset : public MathInset {
public: public:
/// ///
explicit MathCharInset(char c); explicit MathCharInset(char c);
@ -31,6 +30,8 @@ public:
void metricsT(TextMetricsInfo const & mi, Dimension & dim) const; void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
/// ///
void drawT(TextPainter &, int x, int y) const; void drawT(TextPainter &, int x, int y) const;
///
int width() const { return width_; }
/// ///
void write(WriteStream & os) const; void write(WriteStream & os) const;
@ -48,5 +49,7 @@ public:
private: private:
/// the character /// the character
char char_; char char_;
/// cached width
mutable int width_;
}; };
#endif #endif

View File

@ -48,4 +48,5 @@ protected:
/// ///
mutable int yo_; mutable int yo_;
}; };
#endif #endif

View File

@ -810,7 +810,7 @@ MathHullInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
else else
for (row_type row = 0; row < nrows(); ++row) for (row_type row = 0; row < nrows(); ++row)
numbered(row, !old); numbered(row, !old);
//cur.bv()->owner()->message(old ? _("No number") : _("Number")); cur.message(old ? _("No number") : _("Number"));
} }
return DispatchResult(true, true); 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(); row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
////recordUndo(cur, Undo::INSERT); ////recordUndo(cur, Undo::INSERT);
bool old = numbered(r); bool old = numbered(r);
//cur.bv()->owner()->message(old ? _("No number") : _("Number")); cur.message(old ? _("No number") : _("Number"));
numbered(r, !old); numbered(r, !old);
} }
return DispatchResult(true, true); return DispatchResult(true, true);
@ -1152,7 +1152,7 @@ void MathHullInset::revealCodes(LCursor & cur) const
return; return;
ostringstream os; ostringstream os;
cur.info(os); cur.info(os);
cur.bv().owner()->message(os.str()); cur.message(os.str());
/* /*
// write something to the minibuffer // write something to the minibuffer
// translate to latex // translate to latex
@ -1177,7 +1177,7 @@ void MathHullInset::revealCodes(LCursor & cur) const
res = res.substr(pos - 30); res = res.substr(pos - 30);
if (res.size() > 60) if (res.size() > 60)
res = res.substr(0, 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); cur.bv().getLyXText()->cutSelection(true, false);
openNewInset(cur, f); openNewInset(cur, f);
} }
cmd.message(N_("Math editor mode")); cur.message(N_("Math editor mode"));
} }
} // namespace anon } // namespace anon

View File

@ -91,6 +91,8 @@ void MathSymbolInset::metrics(MetricsInfo & mi, Dimension & dim) const
if (mi.base.style == LM_ST_DISPLAY) if (mi.base.style == LM_ST_DISPLAY)
if (sym_->inset == "cmex" || sym_->extra == "funclim") if (sym_->inset == "cmex" || sym_->extra == "funclim")
scriptable_ = true; scriptable_ = true;
width_ = dim.wid;
} }

View File

@ -34,6 +34,9 @@ public:
void metrics(MetricsInfo & mi, Dimension & dim) const; void metrics(MetricsInfo & mi, Dimension & dim) const;
/// ///
void draw(PainterInfo &, int x, int y) const; void draw(PainterInfo &, int x, int y) const;
///
int width() const { return width_; }
/// ///
bool isRelOp() const; bool isRelOp() const;
/// do we take scripts? /// do we take scripts?
@ -69,6 +72,8 @@ private:
latexkeys const * sym_; latexkeys const * sym_;
/// ///
mutable int h_; mutable int h_;
/// cached width
mutable int width_;
/// ///
mutable bool scriptable_; mutable bool scriptable_;
}; };

View File

@ -16,7 +16,6 @@
#include "math_mathmlstream.h" #include "math_mathmlstream.h"
#include "math_streamstr.h" #include "math_streamstr.h"
using std::string; using std::string;
using std::auto_ptr; using std::auto_ptr;
@ -53,6 +52,7 @@ void MathUnknownInset::normalize(NormalStream & os) const
void MathUnknownInset::metrics(MetricsInfo & mi, Dimension & dim) const void MathUnknownInset::metrics(MetricsInfo & mi, Dimension & dim) const
{ {
mathed_string_dim(mi.base.font, name_, dim); 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_); drawStrBlack(pi, x, y, name_);
else else
drawStrRed(pi, x, y, name_); drawStrRed(pi, x, y, name_);
xo_ = x;
yo_ = y;
} }