lyx_mirror/src/mathed/InsetMathSymbol.h
Abdelrazak Younes 24c8ca10d2 Trying to solve bug-2452, I optimized some of the most significant problems outlined in the profile report attached in there.
This commit avoids unnecessary metrics recalculations by caching the last LyXFont used. I had to cleanup the width(), ascent() and descend() redundancies by transferring that to InsetBase.

InsetMathDim should go now as it is not really needed.

* InsetBase: properly handle inset Dimension.

* InsetOld: get rid of redundant width(), ascent() and descent()

* InsetMathDim: ditto

* InsetMathChar::metrics(): avoid metrics recalculation if font is unchanged.

* InsetMathSymbol::metrics(): ditto

* InsetMathKern: use InsetBase::dim_ instead of local ones.

* InsetMathSpace:
  - use InsetBase::dim_ instead of local ones.
  - space to width transformation transferred to anonymous namespace.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17899 a592a061-630c-0410-9148-cb99ea01b6c8
2007-04-22 08:26:06 +00:00

91 lines
1.9 KiB
C++

// -*- C++ -*-
/**
* \file InsetMathSymbol.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#ifndef MATH_SYMBOLINSET_H
#define MATH_SYMBOLINSET_H
#include "InsetMath.h"
#include "lyxfont.h"
namespace lyx {
class latexkeys;
/** "normal" symbols that don't take limits and don't grow in displayed
* formulae.
*/
class InsetMathSymbol : public InsetMath {
public:
///
explicit InsetMathSymbol(latexkeys const * l);
///
explicit InsetMathSymbol(char const * name);
///
explicit InsetMathSymbol(docstring const & name);
///
bool metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo &, int x, int y) const;
///
int kerning() const { return kerning_; }
///
bool isRelOp() const;
///
bool isOrdAlpha() const;
/// do we take scripts?
bool isScriptable() const;
/// do we take \limits or \nolimits?
bool takesLimits() const;
/// identifies SymbolInset as such
InsetMathSymbol const * asSymbolInset() const { return this; }
/// the LaTeX name of the symbol (without the backslash)
docstring name() const;
/// request "external features"
void validate(LaTeXFeatures & features) const;
///
void normalize(NormalStream &) const;
///
void maple(MapleStream &) const;
///
void maxima(MaximaStream &) const;
///
void mathematica(MathematicaStream &) const;
///
void mathmlize(MathStream &) const;
///
void octave(OctaveStream &) const;
///
void write(WriteStream & os) const;
///
void infoize2(odocstream & os) const;
private:
virtual std::auto_ptr<InsetBase> doClone() const;
///
latexkeys const * sym_;
///
mutable int h_;
/// cached superscript kerning
mutable int kerning_;
///
mutable bool scriptable_;
///
mutable LyXFont font_cache_;
};
} // namespace lyx
#endif