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_);
lyxerr << "MathCharInset::metrics: " << dim << endl;
#endif
dim_ = dim;
width_ = dim.wid;
}

View File

@ -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

View File

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

View 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

View 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;
}

View 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_;
};

View 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;
}