* kerning may depend on the BufferView because the metrics of some insets (e.g. math macros) depend on the cursor position in the view

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22259 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stefan Schimanski 2007-12-22 14:39:22 +00:00
parent e32c8c5bad
commit 9ac321f28f
12 changed files with 18 additions and 18 deletions

View File

@ -199,7 +199,7 @@ public:
virtual bool allowedIn(mode_type mode) const { return mode == MATH_MODE; }
/// superscript kerning
virtual int kerning() const { return 0; }
virtual int kerning(BufferView const * bv) const { return 0; }
};
///

View File

@ -30,7 +30,7 @@ public:
///
void drawT(TextPainter &, int x, int y) const;
///
int kerning() const { return kerning_; }
int kerning(BufferView const * bv) const { return kerning_; }
///
void write(WriteStream & os) const;

View File

@ -46,7 +46,7 @@ public:
///
void infoize(odocstream & os) const;
///
int kerning() const { return cell(0).kerning(); }
int kerning(BufferView const * bv) const { return cell(0).kerning(bv); }
private:
virtual Inset * clone() const;

View File

@ -44,7 +44,7 @@ public:
///
void infoize(odocstream & os) const;
///
int kerning() const { return cell(0).kerning(); }
int kerning(BufferView const * bv) const { return cell(0).kerning(bv); }
private:
virtual Inset * clone() const;

View File

@ -253,7 +253,7 @@ int InsetMathScript::dx1(BufferView const & bv) const
{
BOOST_ASSERT(hasUp());
Dimension const dim = dimension(bv);
return hasLimits() ? (dim.wid - up().dimension(bv).width()) / 2 : nwid(bv) + nker();
return hasLimits() ? (dim.wid - up().dimension(bv).width()) / 2 : nwid(bv) + nker(&bv);
}
@ -282,10 +282,10 @@ int InsetMathScript::ndes(BufferView const & bv) const
}
int InsetMathScript::nker() const
int InsetMathScript::nker(BufferView const * bv) const
{
if (nuc().size()) {
int kerning = nuc().kerning();
int kerning = nuc().kerning(bv);
return kerning > 0 ? kerning : 0;
}
return 0;
@ -322,7 +322,7 @@ void InsetMathScript::metrics(MetricsInfo & mi, Dimension & dim) const
dim.wid = max(dim.wid, dimdown.width());
} else {
if (hasUp())
dim.wid = max(dim.wid, nker() + dimup.width());
dim.wid = max(dim.wid, nker(mi.base.bv) + dimup.width());
if (hasDown())
dim.wid = max(dim.wid, dimdown.width());
dim.wid += nwid(bv);

View File

@ -125,7 +125,7 @@ private:
/// returns descent of nucleus if any
int ndes(BufferView const &) const;
/// returns superscript kerning of nucleus if any
int nker() const;
int nker(BufferView const * bv) const;
/// where do we have to draw the scripts?
bool hasLimits() const;
/// clean up empty cells and return true if a cell has been deleted.

View File

@ -35,7 +35,7 @@ public:
///
void draw(PainterInfo &, int x, int y) const;
///
int kerning() const { return kerning_; }
int kerning(BufferView const * bv) const { return kerning_; }
///
bool isRelOp() const;

View File

@ -52,7 +52,7 @@ public:
///
bool final() const;
///
int kerning() const { return kerning_; }
int kerning(BufferView const * bv) const { return kerning_; }
private:
virtual Inset * clone() const;
///

View File

@ -260,7 +260,7 @@ void MathData::metrics(MetricsInfo & mi, Dimension & dim) const
atom_dims_.push_back(d);
dim += d;
if (i == n - 1)
kerning_ = at->kerning();
kerning_ = at->kerning(mi.base.bv);
}
// Cache the dimension.
mi.base.bv->coordCache().arrays().add(this, dim);

View File

@ -152,7 +152,7 @@ public:
/// additional super/subscript shift
int sshift() const { return sshift_; }
/// superscript kerning
int kerning() const { return kerning_; }
int kerning(BufferView const * bv) const { return kerning_; }
///
void swap(MathData & ar) { base_type::swap(ar); }

View File

@ -82,7 +82,7 @@ public:
///
size_t idx() const { return idx_; }
///
int kerning() const { return mathMacro_.cell(idx_).kerning(); }
int kerning(BufferView const * bv) const { return mathMacro_.cell(idx_).kerning(bv); }
private:
///
@ -204,9 +204,9 @@ void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const
}
int MathMacro::kerning() const {
if (displayMode_ == DISPLAY_NORMAL)
return expanded_.kerning();
int MathMacro::kerning(BufferView const * bv) const {
if (displayMode_ == DISPLAY_NORMAL && !editing(bv))
return expanded_.kerning(bv);
else
return 0;
}

View File

@ -41,7 +41,7 @@ public:
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
int kerning() const;
int kerning(BufferView const * bv) const;
/// get cursor position
void cursorPos(BufferView const & bv, CursorSlice const & sl,
bool boundary, int & x, int & y) const;