return nextInset(pos);
}
-byte MathArray::GetChar(int pos) const
+unsigned char MathArray::GetChar(int pos) const
{
return pos < size() ? bf_[pos + 1] : '\0';
}
memcpy(&bf_[pos + 1], &p, sizeof(p));
}
-void MathArray::insert(int pos, byte b, MathTextCodes t)
+void MathArray::insert(int pos, unsigned char b, MathTextCodes t)
{
bf_.insert(bf_.begin() + pos, 3, t);
bf_[pos + 1] = b;
insert(size(), p);
}
-void MathArray::push_back(byte b, MathTextCodes c)
+void MathArray::push_back(unsigned char b, MathTextCodes c)
{
insert(size(), b, c);
}
} else {
MathTextCodes fcode = GetCode(pos);
- byte c = GetChar(pos);
+ unsigned char c = GetChar(pos);
if (MathIsSymbol(fcode)) {
latexkeys const * l = lm_get_key_by_id(c, LM_TK_SYM);
///
void insert(int pos, MathInset * inset);
///
- void insert(int pos, byte, MathTextCodes);
+ void insert(int pos, unsigned char, MathTextCodes);
///
void insert(int pos, MathArray const &);
///
void push_back(MathInset * inset);
///
- void push_back(byte, MathTextCodes);
+ void push_back(unsigned char, MathTextCodes);
///
void push_back(MathArray const &);
///
///
MathInset * prevInset(int pos) const;
///
- byte GetChar(int pos) const;
+ unsigned char GetChar(int pos) const;
/// read subsequent chars of the same kind.
// pos is afterwards one behind the last char belonging to the string
string GetString(int & pos) const;
void WriteNormal(std::ostream &) const;
private:
///
- typedef std::vector<byte> buffer_type;
+ typedef std::vector<unsigned char> buffer_type;
///
- typedef byte value_type;
+ typedef unsigned char value_type;
///
int item_size(int pos) const;
{
istringstream is(s.c_str());
par(mathed_parse(is));
+ Metrics();
}
void InsetFormula::read(LyXLex & lex)
{
par(mathed_parse(lex));
+ Metrics();
}
pain.fillRectangle(int(x), y - a, w, h, LColor::mathbg);
if (mathcursor) {
- par()->Metrics(LM_ST_TEXT);
+ Metrics();
if (mathcursor->formula() == this) {
if (mathcursor->Selection()) {
}
+void InsetFormula::Metrics() const
+{
+ const_cast<MathInset *>(par_)->Metrics(display() ? LM_ST_DISPLAY : LM_ST_TEXT);
+}
+
vector<string> const InsetFormula::getLabelList() const
{
return par()->getLabelList();
ifstream is(outfile.c_str());
par(mathed_parse(is));
+ Metrics();
}
bool InsetFormula::display() const
int InsetFormula::ascent(BufferView *, LyXFont const &) const
{
- return par()->ascent() + 4;
+ return par()->ascent();
}
int InsetFormula::width(BufferView *, LyXFont const &) const
{
- par()->Metrics(LM_ST_TEXT);
return par()->width();
}
int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
+ ///
+ void Metrics() const;
///
void write(std::ostream &) const;
break;
case LM_TK_SYM:
- if (l->id < 255) {
- insert(static_cast<byte>(l->id),
- MathIsBOPS(l->id) ?
- LM_TC_BOPS : LM_TC_SYMB);
-
- } else {
+ if (l->id < 255)
+ insert(l->id, MathIsBOPS(l->id) ? LM_TC_BOPS : LM_TC_SYMB);
+ else
p = new MathFuncInset(l->name);
- }
break;
case LM_TK_STACK:
}
-void MathInset::push_back(byte ch, MathTextCodes fcode)
+void MathInset::push_back(unsigned char ch, MathTextCodes fcode)
{
if (nargs())
cells_.back().data_.push_back(ch, fcode);
///
void push_back(MathInset *);
///
- void push_back(byte ch, MathTextCodes fcode);
+ void push_back(unsigned char ch, MathTextCodes fcode);
///
void dump() const;
using std::endl;
using std::max;
+
+bool MathIsInset(short x)
+{
+ return LM_TC_INSET == x;
+}
+
+
+bool MathIsAlphaFont(short x)
+{
+ return LM_TC_VAR <= x && x <= LM_TC_TEXTRM;
+}
+
+
+bool MathIsBOPS(short x)
+{
+ return MathLookupBOP(x) > LMB_NONE;
+}
+
+
+bool MathIsBinary(short x)
+{
+ return x == LM_TC_BOP || x == LM_TC_BOPS;
+}
+
+
+bool MathIsSymbol(short x)
+{
+ return x == LM_TC_SYMB || x == LM_TC_BOPS || x == LM_TC_BSYM;
+}
+
+
+
///
class Matrix {
public:
} // namespace anon
-void mathed_char_dim (short type, int size, byte c, int & asc, int & des, int & wid)
+void mathed_char_dim (short type, int size, unsigned char c,
+ int & asc, int & des, int & wid)
{
LyXFont const font = WhichFont(type, size);
des = lyxfont::descent(c, font);
wid = mathed_char_width(type, size, c);
}
-int mathed_char_height(short type, int size, byte c, int & asc, int & des)
+int mathed_char_height(short type, int size, unsigned char c,
+ int & asc, int & des)
{
LyXFont const font = WhichFont(type, size);
des = lyxfont::descent(c, font);
}
-int mathed_char_width(short type, int size, byte c)
+int mathed_char_width(short type, int size, unsigned char c)
{
if (MathIsBinary(type)) {
string s;
-bool MathIsInset(short x)
-{
- return LM_TC_INSET == x;
-}
-
-
-bool MathIsAlphaFont(short x)
-{
- return LM_TC_VAR <= x && x <= LM_TC_TEXTRM;
-}
-
-
-bool MathIsBOPS(short x)
-{
- return MathLookupBOP(x) > LMB_NONE;
-}
-
-
-bool MathIsBinary(short x)
-{
- return x == LM_TC_BOP || x == LM_TC_BOPS;
-}
-
-
-bool MathIsSymbol(short x)
-{
- return x == LM_TC_SYMB || x == LM_TC_BOPS || x == LM_TC_BSYM;
-}
-
-
-bool is_matrix_type(short int type)
-{
- return type == LM_OT_MATRIX;
-}
-
// In a near future maybe we use a better fonts renderer
void drawStr(Painter & pain, short type, int siz,
int x, int y, string const & s)
return st;
}
-bool MathIsRelOp(byte c, MathTextCodes f)
+bool MathIsRelOp(unsigned char c, MathTextCodes f)
{
if (f == LM_TC_BOP && (c == '=' || c == '<' || c == '>'))
return true;
#include "lyxfont.h"
#include "math_defs.h"
-#ifndef byte
-#define byte unsigned char
-#endif
-
class Painter;
class MathArray;
class MathMatrixInset;
extern char const * math_font_name[];
extern char const * latex_mathspace[];
-int mathed_char_height(short type, int size, byte c, int & asc, int & des);
-int mathed_char_width(short type, int size, byte c);
-void mathed_char_dim(short type, int size, byte c, int & asc, int & des, int & wid);
+int mathed_char_height(short type, int size, unsigned char c,
+ int & asc, int & des);
+int mathed_char_width(short type, int size, unsigned char c);
+void mathed_char_dim(short type, int size, unsigned char c,
+ int & asc, int & des, int & wid);
void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code);
bool MathIsInset(short x);
bool MathIsAlphaFont(short x);
bool MathIsBOPS(short x);
-bool MathIsBinary(short x);
bool MathIsSymbol(short x);
-bool MathIsRelOp(byte c, MathTextCodes f);
+bool MathIsRelOp(unsigned char c, MathTextCodes f);
void drawStr(Painter & pain, short type, int siz,
int x, int y, string const & s);