mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-05 13:26:21 +00:00
move width_/ascent_/descent_ cache into seperate ABC.
sizeof(MathInset) == 24 on IA32 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2414 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
51e0c8bd1f
commit
244d75e942
@ -8,6 +8,14 @@
|
||||
* formula*.[Ch]: seperation of the "pimpl" MathInset * into
|
||||
MathMatrixInset * and MathMacroTemplate * to save a few casts
|
||||
|
||||
* all over the place: everything is an inset now
|
||||
|
||||
* math_nestinset.[Ch]: new abstract base class for insets containing
|
||||
other insets.
|
||||
|
||||
* math_diminset.[Ch]: new abstract base class for insets that need
|
||||
the width_/ascent_/descent_ cache
|
||||
|
||||
2001-07-25 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* formulabase.C: re-enable 'space enlargement' feature
|
||||
|
@ -29,6 +29,8 @@ libmathed_la_SOURCES = \
|
||||
math_defs.h \
|
||||
math_deliminset.C \
|
||||
math_deliminset.h \
|
||||
math_diminset.C \
|
||||
math_diminset.h \
|
||||
math_dotsinset.C \
|
||||
math_dotsinset.h \
|
||||
math_fracinset.C \
|
||||
|
@ -121,7 +121,7 @@ InsetFormulaBase::InsetFormulaBase()
|
||||
#warning This is needed as long the math parser is not re-entrant
|
||||
#endif
|
||||
MathMacroTable::builtinMacros();
|
||||
//lyxerr << "sizeof MathInset: " << sizeof(MathInset) << "\n";
|
||||
lyxerr << "sizeof MathInset: " << sizeof(MathInset) << "\n";
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#ifndef MATH_DOTSINSET_H
|
||||
#define MATH_DOTSINSET_H
|
||||
|
||||
#include "math_inset.h"
|
||||
#include "math_diminset.h"
|
||||
#include "math_defs.h"
|
||||
|
||||
#ifdef __GNUG__
|
||||
@ -12,7 +12,7 @@
|
||||
struct latexkeys;
|
||||
|
||||
/// The different kinds of ellipsis
|
||||
class MathDotsInset : public MathInset {
|
||||
class MathDotsInset : public MathDimInset {
|
||||
public:
|
||||
///
|
||||
explicit MathDotsInset(latexkeys const *);
|
||||
|
@ -15,8 +15,9 @@ extern LyXFont WhichFont(short type, int size);
|
||||
|
||||
|
||||
MathFuncInset::MathFuncInset(string const & nm)
|
||||
: MathInset(nm)
|
||||
{}
|
||||
{
|
||||
name_ = nm;
|
||||
}
|
||||
|
||||
|
||||
MathInset * MathFuncInset::clone() const
|
||||
|
@ -2,7 +2,7 @@
|
||||
#ifndef MATH_FUNCINSET_H
|
||||
#define MATH_FUNCINSET_H
|
||||
|
||||
#include "math_inset.h"
|
||||
#include "math_diminset.h"
|
||||
#include "math_defs.h"
|
||||
|
||||
#ifdef __GNUG__
|
||||
@ -12,19 +12,19 @@
|
||||
/**
|
||||
Functions or LaTeX names for objects that I don't know how to draw.
|
||||
*/
|
||||
class MathFuncInset : public MathInset {
|
||||
class MathFuncInset : public MathDimInset {
|
||||
public:
|
||||
///
|
||||
explicit MathFuncInset(string const & nm);
|
||||
///
|
||||
virtual MathInset * clone() const;
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void MathFuncInset::metrics(MathStyles st);
|
||||
///
|
||||
void draw(Painter &, int, int);
|
||||
///
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
void writeNormal(std::ostream &) const;
|
||||
///
|
||||
void metrics(MathStyles st);
|
||||
};
|
||||
#endif
|
||||
|
@ -27,32 +27,13 @@ int MathInset::workwidth;
|
||||
|
||||
|
||||
MathInset::MathInset(string const & name)
|
||||
: name_(name), width_(0), ascent_(0), descent_(0),
|
||||
size_(LM_ST_DISPLAY), code_(LM_TC_MIN), xo_(0), yo_(0)
|
||||
: name_(name), size_(LM_ST_DISPLAY), code_(LM_TC_MIN), xo_(0), yo_(0)
|
||||
{}
|
||||
|
||||
|
||||
int MathInset::ascent() const
|
||||
{
|
||||
return ascent_;
|
||||
}
|
||||
|
||||
|
||||
int MathInset::descent() const
|
||||
{
|
||||
return descent_;
|
||||
}
|
||||
|
||||
|
||||
int MathInset::width() const
|
||||
{
|
||||
return width_;
|
||||
}
|
||||
|
||||
|
||||
int MathInset::height() const
|
||||
{
|
||||
return ascent_ + descent_;
|
||||
return ascent() + descent();
|
||||
}
|
||||
|
||||
|
||||
@ -285,7 +266,7 @@ void MathInset::push_back(unsigned char, MathTextCodes)
|
||||
}
|
||||
|
||||
|
||||
void MathInset::push_back(MathInset * p)
|
||||
void MathInset::push_back(MathInset *)
|
||||
{
|
||||
lyxerr << "can't push without a cell\n";
|
||||
}
|
||||
@ -295,9 +276,9 @@ bool MathInset::covers(int x, int y) const
|
||||
{
|
||||
return
|
||||
x >= xo_ &&
|
||||
x <= xo_ + width_ &&
|
||||
y >= yo_ - ascent_ &&
|
||||
y <= yo_ + descent_;
|
||||
x <= xo_ + width() &&
|
||||
y >= yo_ - ascent() &&
|
||||
y <= yo_ + descent();
|
||||
}
|
||||
|
||||
|
||||
@ -324,3 +305,9 @@ void MathInset::code(MathTextCodes t)
|
||||
{
|
||||
code_ = t;
|
||||
}
|
||||
|
||||
|
||||
void MathInset::metrics(MathStyles st)
|
||||
{
|
||||
size_ = st;
|
||||
}
|
||||
|
@ -60,13 +60,13 @@ public:
|
||||
/// appends itself with macro arguments substituted
|
||||
virtual void substitute(MathArray & array, MathMacro const & macro) const;
|
||||
/// compute the size of the object, sets ascend_, descend_ and width_
|
||||
virtual void metrics(MathStyles st) = 0;
|
||||
virtual void metrics(MathStyles st);
|
||||
///
|
||||
virtual int ascent() const;
|
||||
virtual int ascent() const = 0;
|
||||
///
|
||||
virtual int descent() const;
|
||||
virtual int descent() const = 0;
|
||||
///
|
||||
virtual int width() const;
|
||||
virtual int width() const = 0;
|
||||
///
|
||||
virtual int height() const;
|
||||
///
|
||||
@ -203,13 +203,7 @@ public:
|
||||
protected:
|
||||
/// usually the LaTeX name of the thingy
|
||||
string name_;
|
||||
/// the width of this inset as computed by metrics()
|
||||
int width_;
|
||||
///
|
||||
int ascent_;
|
||||
///
|
||||
int descent_;
|
||||
///
|
||||
void size(MathStyles s);
|
||||
/// the used font size
|
||||
MathStyles size_;
|
||||
|
@ -17,6 +17,9 @@ MathMacroArgument::MathMacroArgument(int n)
|
||||
lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
|
||||
<< n << std::endl;
|
||||
}
|
||||
str_[0] = '#';
|
||||
str_[1] = '0' + n;
|
||||
str_[2] = '\0';
|
||||
}
|
||||
|
||||
|
||||
@ -28,18 +31,25 @@ MathInset * MathMacroArgument::clone() const
|
||||
|
||||
void MathMacroArgument::draw(Painter & pain, int x, int y)
|
||||
{
|
||||
char str[] = "#0";
|
||||
str[1] += number_;
|
||||
drawStr(pain, LM_TC_TEX, size(), x, y, str);
|
||||
drawStr(pain, LM_TC_TEX, size(), x, y, str_);
|
||||
}
|
||||
|
||||
|
||||
void MathMacroArgument::metrics(MathStyles st)
|
||||
int MathMacroArgument::ascent() const
|
||||
{
|
||||
char str[] = "#0";
|
||||
str[1] += number_;
|
||||
size_ = st;
|
||||
mathed_string_dim(LM_TC_TEX, size(), str, ascent_, descent_, width_);
|
||||
return mathed_char_ascent(LM_TC_TEX, size(), 'I');
|
||||
}
|
||||
|
||||
|
||||
int MathMacroArgument::descent() const
|
||||
{
|
||||
return mathed_char_descent(LM_TC_TEX, size(), 'I');
|
||||
}
|
||||
|
||||
|
||||
int MathMacroArgument::width() const
|
||||
{
|
||||
return mathed_string_width(LM_TC_TEX, size(), str_);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void metrics(MathStyles st);
|
||||
//void metrics(MathStyles st);
|
||||
///
|
||||
void draw(Painter &, int x, int baseline);
|
||||
///
|
||||
@ -27,10 +27,18 @@ public:
|
||||
void writeNormal(std::ostream &) const;
|
||||
///
|
||||
void substitute(MathArray & array, MathMacro const & macro) const;
|
||||
///
|
||||
int ascent() const;
|
||||
///
|
||||
int descent() const;
|
||||
///
|
||||
int width() const;
|
||||
|
||||
private:
|
||||
/// A number between 1 and 9
|
||||
int number_;
|
||||
///
|
||||
char str_[3];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -7,8 +7,10 @@
|
||||
|
||||
|
||||
MathNestInset::MathNestInset(int nargs, string const & name)
|
||||
: MathInset(name), cells_(nargs)
|
||||
{}
|
||||
: MathDimInset(), cells_(nargs)
|
||||
{
|
||||
name_ = name;
|
||||
}
|
||||
|
||||
|
||||
int MathNestInset::nargs() const
|
||||
|
@ -5,7 +5,7 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "math_inset.h"
|
||||
#include "math_diminset.h"
|
||||
|
||||
/** Abstract base class for all math objects that conatin nested items.
|
||||
*/
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
class LaTeXFeatures;
|
||||
|
||||
class MathNestInset : public MathInset {
|
||||
class MathNestInset : public MathDimInset {
|
||||
public:
|
||||
///
|
||||
explicit MathNestInset(int na = 0, string const & nm = string());
|
||||
|
@ -2,7 +2,7 @@
|
||||
#ifndef MATH_SPACEINSET_H
|
||||
#define MATH_SPACEINSET_H
|
||||
|
||||
#include "math_inset.h"
|
||||
#include "math_diminset.h"
|
||||
#include "math_defs.h"
|
||||
|
||||
#ifdef __GNUG__
|
||||
@ -10,7 +10,7 @@
|
||||
#endif
|
||||
|
||||
/// Smart spaces
|
||||
class MathSpaceInset : public MathInset {
|
||||
class MathSpaceInset : public MathDimInset {
|
||||
public:
|
||||
///
|
||||
explicit MathSpaceInset(int sp);
|
||||
|
@ -2,12 +2,12 @@
|
||||
#ifndef MATH_SYMBOLINSET_H
|
||||
#define MATH_SYMBOLINSET_H
|
||||
|
||||
#include "math_inset.h"
|
||||
#include "math_diminset.h"
|
||||
|
||||
struct latexkeys;
|
||||
|
||||
/// big operators
|
||||
class MathSymbolInset : public MathInset {
|
||||
class MathSymbolInset : public MathDimInset {
|
||||
public:
|
||||
///
|
||||
explicit MathSymbolInset(latexkeys const *);
|
||||
@ -23,6 +23,7 @@ public:
|
||||
void draw(Painter &, int, int);
|
||||
///
|
||||
bool isScriptable() const { return true; }
|
||||
|
||||
private:
|
||||
///
|
||||
latexkeys const * sym_;
|
||||
|
@ -513,7 +513,7 @@ static init_deco_table idt;
|
||||
|
||||
} // namespace anon
|
||||
|
||||
void mathed_char_dim (MathTextCodes type, MathStyles size, unsigned char c,
|
||||
void mathed_char_dim(MathTextCodes type, MathStyles size, unsigned char c,
|
||||
int & asc, int & des, int & wid)
|
||||
{
|
||||
LyXFont const font = WhichFont(type, size);
|
||||
@ -532,6 +532,27 @@ int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c,
|
||||
}
|
||||
|
||||
|
||||
int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c)
|
||||
{
|
||||
int asc;
|
||||
int des;
|
||||
return mathed_char_height(type, size, c, asc, des);
|
||||
}
|
||||
|
||||
int mathed_char_ascent(MathTextCodes type, MathStyles size, unsigned char c)
|
||||
{
|
||||
LyXFont const font = WhichFont(type, size);
|
||||
return lyxfont::ascent(c, font);
|
||||
}
|
||||
|
||||
int mathed_char_descent(MathTextCodes type, MathStyles size, unsigned char c)
|
||||
{
|
||||
LyXFont const font = WhichFont(type, size);
|
||||
return lyxfont::descent(c, font);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int mathed_char_width(MathTextCodes type, MathStyles size, unsigned char c)
|
||||
{
|
||||
if (MathIsBinary(type)) {
|
||||
|
@ -15,9 +15,11 @@ extern char const * latex_mathspace[];
|
||||
|
||||
int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c,
|
||||
int & asc, int & des);
|
||||
int mathed_char_width(MathTextCodes type, MathStyles size, unsigned char c);
|
||||
void mathed_char_dim(MathTextCodes type, MathStyles size, unsigned char c,
|
||||
int & asc, int & des, int & wid);
|
||||
int mathed_char_width(MathTextCodes type, MathStyles size, unsigned char c);
|
||||
int mathed_char_ascent(MathTextCodes type, MathStyles size, unsigned char c);
|
||||
int mathed_char_descent(MathTextCodes type, MathStyles size, unsigned char c);
|
||||
|
||||
void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code);
|
||||
|
||||
@ -25,7 +27,10 @@ void mathed_string_dim(MathTextCodes type, MathStyles size, string const & s,
|
||||
int & asc, int & des, int & wid);
|
||||
int mathed_string_height(MathTextCodes type, MathStyles size, string const & s,
|
||||
int & asc, int & des);
|
||||
|
||||
int mathed_string_width(MathTextCodes type, MathStyles size, string const & s);
|
||||
int mathed_string_ascent(MathTextCodes type, MathStyles size, string const & s);
|
||||
int mathed_string_descent(MathTextCodes type, MathStyles size, string const & s);
|
||||
|
||||
bool MathIsInset(MathTextCodes x);
|
||||
bool MathIsAlphaFont(MathTextCodes x);
|
||||
|
Loading…
Reference in New Issue
Block a user