get rid of several friends small cleanup

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1519 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-02-15 12:22:01 +00:00
parent 50be761b25
commit d5905fabf6
29 changed files with 1597 additions and 1487 deletions

View File

@ -1,3 +1,9 @@
2001-02-15 Lars Gullik Bjønnes <larsbj@lyx.org>
* matriz.C: clean up a bit.
* several files: changes so that several friends can be removed
2001-02-14 André Pönitz <poenitz@htwm.de> 2001-02-14 André Pönitz <poenitz@htwm.de>
* formula.C: reformatting * formula.C: reformatting

File diff suppressed because it is too large Load Diff

View File

@ -14,10 +14,9 @@
*/ */
#include <config.h> #include <config.h>
#include <cstdlib>
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "formulamacro.h" #pragma implementation
#endif #endif
#include "formulamacro.h" #include "formulamacro.h"
@ -40,34 +39,34 @@ using std::ostream;
using std::istream; using std::istream;
InsetFormulaMacro::InsetFormulaMacro() InsetFormulaMacro::InsetFormulaMacro()
: InsetFormula(true) : InsetFormula(true)
{ {
tmacro = 0; tmacro = 0;
opened = false; opened = false;
} }
InsetFormulaMacro::InsetFormulaMacro(string nm, int na, bool /*e*/) InsetFormulaMacro::InsetFormulaMacro(string nm, int na, bool /*e*/)
: InsetFormula(true), name(nm) : InsetFormula(true), name(nm)
{ {
tmacro = MathMacroTable::mathMTable.getTemplate(name); tmacro = MathMacroTable::mathMTable.getTemplate(name);
if (!tmacro) { if (!tmacro) {
tmacro = new MathMacroTemplate(name.c_str(), na); tmacro = new MathMacroTemplate(name.c_str(), na);
MathMacroTable::mathMTable.addTemplate(tmacro); MathMacroTable::mathMTable.addTemplate(tmacro);
} }
opened = false; opened = false;
} }
InsetFormulaMacro::~InsetFormulaMacro() InsetFormulaMacro::~InsetFormulaMacro()
{ {
par = 0; par = 0;
} }
Inset * InsetFormulaMacro::Clone(Buffer const &) const Inset * InsetFormulaMacro::Clone(Buffer const &) const
{ {
return new InsetFormulaMacro(name); return new InsetFormulaMacro(name);
} }
@ -88,13 +87,13 @@ int InsetFormulaMacro::Latex(Buffer const *, ostream & os, bool /*fragile*/,
int InsetFormulaMacro::Linuxdoc(Buffer const * buf, ostream & os) const int InsetFormulaMacro::Linuxdoc(Buffer const * buf, ostream & os) const
{ {
return Ascii(buf, os, 0); return Ascii(buf, os, 0);
} }
int InsetFormulaMacro::DocBook(Buffer const * buf, ostream & os) const int InsetFormulaMacro::DocBook(Buffer const * buf, ostream & os) const
{ {
return Ascii(buf, os, 0); return Ascii(buf, os, 0);
} }
@ -121,33 +120,33 @@ void InsetFormulaMacro::Read(Buffer const *, LyXLex & lex)
int InsetFormulaMacro::ascent(BufferView * pain, LyXFont const & f) const int InsetFormulaMacro::ascent(BufferView * pain, LyXFont const & f) const
{ {
if (opened) { if (opened) {
tmacro->update(); tmacro->update();
return InsetFormula::ascent(pain, f); return InsetFormula::ascent(pain, f);
} }
return lyxfont::maxAscent(f) + 3; return lyxfont::maxAscent(f) + 3;
} }
int InsetFormulaMacro::descent(BufferView * pain, LyXFont const & f) const int InsetFormulaMacro::descent(BufferView * pain, LyXFont const & f) const
{ {
if (opened) { if (opened) {
tmacro->update(); tmacro->update();
return InsetFormula::descent(pain, f); return InsetFormula::descent(pain, f);
} }
return lyxfont::maxDescent(f) + 1; return lyxfont::maxDescent(f) + 1;
} }
int InsetFormulaMacro::width(BufferView * bv, LyXFont const & f) const int InsetFormulaMacro::width(BufferView * bv, LyXFont const & f) const
{ {
if (opened) { if (opened) {
tmacro->update(); tmacro->update();
return InsetFormula::width(bv, f); return InsetFormula::width(bv, f);
} }
string ilabel(_("Macro: ")); string ilabel(_("Macro: "));
ilabel += name; ilabel += name;
return 6 + lyxfont::width(ilabel, f); return 6 + lyxfont::width(ilabel, f);
} }
@ -164,10 +163,9 @@ void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
} else { } else {
font.setColor(LColor::math); font.setColor(LColor::math);
int y = baseline - ascent(bv, font) + 1; int const y = baseline - ascent(bv, font) + 1;
int w = width(bv, font) - 2; int const w = width(bv, font) - 2;
int h = (ascent(bv, font) + descent(bv, font) - 2); int const h = (ascent(bv, font) + descent(bv, font) - 2);
pain.fillRectangle(int(x), y, w, h, LColor::mathbg); pain.fillRectangle(int(x), y, w, h, LColor::mathbg);
pain.rectangle(int(x), y, w, h, LColor::mathframe); pain.rectangle(int(x), y, w, h, LColor::mathframe);
@ -188,21 +186,21 @@ string const InsetFormulaMacro::EditMessage() const
void InsetFormulaMacro::Edit(BufferView * bv, int x, int y,unsigned int button) void InsetFormulaMacro::Edit(BufferView * bv, int x, int y,unsigned int button)
{ {
opened = true; opened = true;
par = static_cast<MathParInset*>(tmacro->Clone()); par = static_cast<MathParInset*>(tmacro->Clone());
InsetFormula::Edit(bv, x, y, button); InsetFormula::Edit(bv, x, y, button);
} }
void InsetFormulaMacro::InsetUnlock(BufferView * bv) void InsetFormulaMacro::InsetUnlock(BufferView * bv)
{ {
opened = false; opened = false;
MathedArray * tarray = tmacro->GetData(); MathedArray * tarray = tmacro->GetData();
MathedIter it(tarray); MathedIter it(tarray);
it.Clear(); it.Clear();
tmacro->SetData(par->GetData()); tmacro->SetData(par->GetData());
tmacro->setEditMode(false); tmacro->setEditMode(false);
InsetFormula::InsetUnlock(bv); InsetFormula::InsetUnlock(bv);
} }
@ -210,19 +208,20 @@ UpdatableInset::RESULT
InsetFormulaMacro::LocalDispatch(BufferView * bv, InsetFormulaMacro::LocalDispatch(BufferView * bv,
int action, string const & arg) int action, string const & arg)
{ {
if (action == LFUN_MATH_MACROARG) { if (action == LFUN_MATH_MACROARG) {
int i = lyx::atoi(arg) - 1; int i = lyx::atoi(arg) - 1;
if (i >= 0 && i < tmacro->getNoArgs()) { if (i >= 0 && i < tmacro->getNoArgs()) {
mathcursor->Insert(tmacro->getMacroPar(i), LM_TC_INSET); mathcursor->Insert(tmacro->getMacroPar(i),
InsetFormula::UpdateLocal(bv); LM_TC_INSET);
} InsetFormula::UpdateLocal(bv);
}
return DISPATCHED; return DISPATCHED;
} }
tmacro->setEditMode(true); tmacro->setEditMode(true);
tmacro->Metrics(); tmacro->Metrics();
RESULT result = InsetFormula::LocalDispatch(bv, action, arg); RESULT result = InsetFormula::LocalDispatch(bv, action, arg);
tmacro->setEditMode(false); tmacro->setEditMode(false);
return result; return result;
} }

View File

@ -48,7 +48,7 @@ MathAccentInset::draw(Painter & pain, int x, int y)
else { else {
string s; string s;
s += c; s += c;
drawStr(pain, fn, size, x, y, s); drawStr(pain, fn, size(), x, y, s);
} }
x += (code == LM_not) ? (width-dw) / 2 : 2; x += (code == LM_not) ? (width-dw) / 2 : 2;
mathed_draw_deco(pain, x, y - dy, dw, dh, code); mathed_draw_deco(pain, x, y - dy, dw, dh, code);
@ -65,9 +65,9 @@ MathAccentInset::Metrics()
width = inset->Width(); width = inset->Width();
dh = ascent; dh = ascent;
} else { } else {
mathed_char_height(fn, size, c, ascent, descent); mathed_char_height(fn, size(), c, ascent, descent);
width = mathed_char_width(fn, size, c); width = mathed_char_width(fn, size(), c);
dh = (width-2)/2; dh = (width - 2) / 2;
} }
if (code == LM_not) { if (code == LM_not) {
ascent += dh; ascent += dh;

View File

@ -57,7 +57,7 @@ MathBigopInset::draw(Painter & pain, int x, int y)
LColor::mathline); LColor::mathline);
++x; ++x;
} }
pain.text(x, y, s, mathed_get_font(t, size)); pain.text(x, y, s, mathed_get_font(t, size()));
} }
@ -76,8 +76,8 @@ MathBigopInset::Metrics()
s = name; s = name;
t = LM_TC_TEXTRM; t = LM_TC_TEXTRM;
} }
mathed_string_height(t, size, s, ascent, descent); mathed_string_height(t, size(), s, ascent, descent);
width = mathed_string_width(t, size, s); width = mathed_string_width(t, size(), s);
if (sym == LM_oint) width += 2; if (sym == LM_oint) width += 2;
} }

View File

@ -42,19 +42,20 @@ MathDecorationInset::draw(Painter & pain, int x, int y)
void void
MathDecorationInset::Metrics() MathDecorationInset::Metrics()
{ {
int h = 2*mathed_char_height(LM_TC_VAR, size, 'I', ascent, descent); int h = 2 * mathed_char_height(LM_TC_VAR, size(), 'I',
ascent, descent);
MathParInset::Metrics(); MathParInset::Metrics();
int w = Width()+4; int w = Width() + 4;
if (w<16) w = 16; if (w < 16) w = 16;
dh = w/5; dh = w / 5;
if (dh>h) dh = h; if (dh > h) dh = h;
if (upper) { if (upper) {
ascent += dh+2; ascent += dh + 2;
dy = -ascent; dy = -ascent;
} else { } else {
dy = descent+2; dy = descent + 2;
descent += dh+4; descent += dh + 4;
} }
dw = width; dw = width;
width = w; width = w;

View File

@ -19,7 +19,6 @@
#include FORMS_H_LOCATION #include FORMS_H_LOCATION
#include <algorithm> #include <algorithm>
#include <cstdlib>
#include "symbol_def.h" #include "symbol_def.h"
#include "math_inset.h" #include "math_inset.h"
#include "LColor.h" #include "LColor.h"

View File

@ -57,37 +57,38 @@ void MathDelimInset::Write(ostream & os, bool fragile)
void void
MathDelimInset::draw(Painter & pain, int x, int y) MathDelimInset::draw(Painter & pain, int x, int y)
{ {
xo = x; yo = y; xo(x);
yo(y);
MathParInset::draw(pain, x + dw + 2, y - dh); MathParInset::draw(pain, x + dw + 2, y - dh);
if (left == '.') { if (left == '.') {
pain.line(x + 4, yo - ascent, pain.line(x + 4, yo() - ascent,
x + 4, yo + descent, x + 4, yo() + descent,
LColor::mathcursor, Painter::line_onoffdash); LColor::mathcursor, Painter::line_onoffdash);
} else } else
mathed_draw_deco(pain, x, y - ascent, dw, Height(), left); mathed_draw_deco(pain, x, y - ascent, dw, Height(), left);
x += Width() - dw - 2; x += Width() - dw - 2;
if (right == '.') { if (right == '.') {
pain.line(x + 4, yo - ascent, pain.line(x + 4, yo() - ascent,
x + 4, yo + descent, x + 4, yo() + descent,
LColor::mathcursor, Painter::line_onoffdash); LColor::mathcursor, Painter::line_onoffdash);
} else } else
mathed_draw_deco(pain, x, y-ascent, dw, Height(), right); mathed_draw_deco(pain, x, y - ascent, dw, Height(), right);
} }
void void
MathDelimInset::Metrics() MathDelimInset::Metrics()
{ {
MathParInset::Metrics(); MathParInset::Metrics();
int d; int d;
mathed_char_height(LM_TC_CONST, size, 'I', d, dh); mathed_char_height(LM_TC_CONST, size(), 'I', d, dh);
dh /= 2; dh /= 2;
ascent += 2 + dh; ascent += 2 + dh;
descent += 2 - dh; descent += 2 - dh;
dw = Height()/5; dw = Height()/5;
if (dw > 15) dw = 15; if (dw > 15) dw = 15;
if (dw<6) dw = 6; if (dw < 6) dw = 6;
width += 2*dw+4; width += 2 * dw + 4;
} }

View File

@ -30,8 +30,8 @@ MathDotsInset::draw(Painter & pain, int x, int y)
void void
MathDotsInset::Metrics() MathDotsInset::Metrics()
{ {
mathed_char_height(LM_TC_VAR, size, 'M', ascent, descent); mathed_char_height(LM_TC_VAR, size(), 'M', ascent, descent);
width = mathed_char_width(LM_TC_VAR, size, 'M'); width = mathed_char_width(LM_TC_VAR, size(), 'M');
switch (code) { switch (code) {
case LM_ldots: dh = 0; break; case LM_ldots: dh = 0; break;
case LM_cdots: dh = ascent/2; break; case LM_cdots: dh = ascent/2; break;

View File

@ -56,9 +56,9 @@ void MathFracInset::SetStyle(short st)
{ {
MathParInset::SetStyle(st); MathParInset::SetStyle(st);
dh = 0; dh = 0;
den->SetStyle((size == LM_ST_DISPLAY) ? den->SetStyle((size() == LM_ST_DISPLAY) ?
static_cast<short>(LM_ST_TEXT) static_cast<short>(LM_ST_TEXT)
: size); : size());
} }
@ -99,16 +99,19 @@ MathedArray * MathFracInset::GetData()
bool MathFracInset::Inside(int x, int y) bool MathFracInset::Inside(int x, int y)
{ {
int xx = xo - (width - w0) / 2; int xx = xo() - (width - w0) / 2;
return x >= xx && x <= xx + width && y <= yo + descent && y >= yo - ascent; return x >= xx
&& x <= xx + width
&& y <= yo() + descent
&& y >= yo() - ascent;
} }
void MathFracInset::SetFocus(int /*x*/, int y) void MathFracInset::SetFocus(int /*x*/, int y)
{ {
// lyxerr << "y " << y << " " << yo << " " << den->yo << " "; // lyxerr << "y " << y << " " << yo << " " << den->yo << " ";
idx = (y > yo) ? 1: 0; idx = (y > yo()) ? 1: 0;
} }
@ -116,13 +119,13 @@ void
MathFracInset::draw(Painter & pain, int x, int y) MathFracInset::draw(Painter & pain, int x, int y)
{ {
short idxp = idx; short idxp = idx;
short sizex = size; short sizex = size();
idx = 0; idx = 0;
if (size == LM_ST_DISPLAY) ++size; if (size() == LM_ST_DISPLAY) incSize();
MathParInset::draw(pain, x + (width - w0) / 2, y - des0); MathParInset::draw(pain, x + (width - w0) / 2, y - des0);
den->draw(pain, x + (width - w1) / 2, y + den->Ascent() + 2 - dh); den->draw(pain, x + (width - w1) / 2, y + den->Ascent() + 2 - dh);
size = sizex; size(sizex);
if (objtype == LM_OT_FRAC) if (objtype == LM_OT_FRAC)
pain.line(x + 2, y - dh, x + width - 4, y - dh, LColor::mathline); pain.line(x + 2, y - dh, x + width - 4, y - dh, LColor::mathline);
idx = idxp; idx = idxp;
@ -134,14 +137,14 @@ MathFracInset::Metrics()
{ {
if (!dh) { if (!dh) {
int a, b; int a, b;
dh = mathed_char_height(LM_TC_CONST, size, 'I', a, b)/2; dh = mathed_char_height(LM_TC_CONST, size(), 'I', a, b) / 2;
} }
short idxp = idx; short idxp = idx;
short sizex = size; short sizex = size();
idx = 0; idx = 0;
if (size == LM_ST_DISPLAY) ++size; if (size() == LM_ST_DISPLAY) incSize();
MathParInset::Metrics(); MathParInset::Metrics();
size = sizex; size(sizex);
w0 = width; w0 = width;
int as = Height() + 2 + dh; int as = Height() + 2 + dh;
des0 = Descent() + 2 + dh; des0 = Descent() + 2 + dh;

View File

@ -54,7 +54,7 @@ void
MathFuncInset::draw(Painter & pain, int x, int y) MathFuncInset::draw(Painter & pain, int x, int y)
{ {
if (!name.empty() && name[0] > ' ') { if (!name.empty() && name[0] > ' ') {
LyXFont font = WhichFont(LM_TC_TEXTRM, size); LyXFont font = WhichFont(LM_TC_TEXTRM, size());
font.setLatex(LyXFont::ON); font.setLatex(LyXFont::ON);
x += (lyxfont::width('I', font) + 3) / 4; x += (lyxfont::width('I', font) + 3) / 4;
pain.text(x, y, name, font); pain.text(x, y, name, font);
@ -66,7 +66,7 @@ MathFuncInset::draw(Painter & pain, int x, int y)
void MathFuncInset::Metrics() void MathFuncInset::Metrics()
{ {
//ln = (name) ? strlen(name): 0; //ln = (name) ? strlen(name): 0;
LyXFont font = WhichFont(LM_TC_TEXTRM, size); LyXFont font = WhichFont(LM_TC_TEXTRM, size());
font.setLatex(LyXFont::ON); font.setLatex(LyXFont::ON);
if (name.empty()) { if (name.empty()) {
width = df_width; width = df_width;
@ -75,6 +75,6 @@ void MathFuncInset::Metrics()
} else { } else {
width = lyxfont::width(name, font) width = lyxfont::width(name, font)
+ lyxfont::width('I', font) / 2; + lyxfont::width('I', font) / 2;
mathed_string_height(LM_TC_TEXTRM, size, name, ascent, descent); mathed_string_height(LM_TC_TEXTRM, size(), name, ascent, descent);
} }
} }

View File

@ -2,7 +2,6 @@
/* Command-line: gperf -a -p -o -t -G -D keywords */ /* Command-line: gperf -a -p -o -t -G -D keywords */
#include <config.h> #include <config.h>
#include <cstdlib>
#include <cstring> #include <cstring>
#include "math_defs.h" #include "math_defs.h"
@ -18,300 +17,301 @@ int const MAX_HASH_VALUE = 490;
static static
unsigned int unsigned int
math_hash (register char const *str, register int len) math_hash (register char const * str, register int len)
{ {
static unsigned short asso_values[] = static unsigned short asso_values[] =
{ {
491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
491, 491, 491, 491, 491, 491, 491, 491, 95, 491, 491, 491, 491, 491, 491, 491, 491, 491, 95, 491,
491, 45, 491, 10, 491, 491, 255, 491, 491, 65, 491, 45, 491, 10, 491, 491, 255, 491, 491, 65,
30, 491, 0, 70, 80, 70, 15, 491, 10, 491, 30, 491, 0, 70, 80, 70, 15, 491, 10, 491,
491, 491, 491, 491, 491, 491, 491, 50, 200, 140, 491, 491, 491, 491, 491, 491, 491, 50, 200, 140,
219, 35, 135, 237, 230, 69, 0, 20, 10, 180, 219, 35, 135, 237, 230, 69, 0, 20, 10, 180,
105, 247, 55, 208, 125, 0, 25, 42, 255, 75, 105, 247, 55, 208, 125, 0, 25, 42, 255, 75,
5, 0, 0, 491, 491, 491, 491, 491, 5, 0, 0, 491, 491, 491, 491, 491,
}; };
return len + asso_values[str[len - 1]] + asso_values[str[0]]; return len + asso_values[str[len - 1]] + asso_values[str[0]];
} }
static static
latexkeys wordlist[] = latexkeys wordlist[] =
{ {
{"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0},
{"setminus", LM_TK_SYM, LM_setminus}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0},
{"ldots", LM_TK_DOTS, LM_ldots}, {"setminus", LM_TK_SYM, LM_setminus},
{"limits", LM_TK_LIMIT, 1 }, {"ldots", LM_TK_DOTS, LM_ldots},
{"stackrel", LM_TK_STACK, 0}, {"limits", LM_TK_LIMIT, 1 },
{"ll", LM_TK_SYM, LM_ll}, {"stackrel", LM_TK_STACK, 0},
{"label", LM_TK_LABEL, 0}, {"ll", LM_TK_SYM, LM_ll},
{"lceil", LM_TK_SYM, LM_lceil}, {"label", LM_TK_LABEL, 0},
{"sqrt", LM_TK_SQRT, 0}, {"lceil", LM_TK_SYM, LM_lceil},
{"times", LM_TK_SYM, LM_times}, {"sqrt", LM_TK_SQRT, 0},
{"subset", LM_TK_SYM, LM_subset}, {"times", LM_TK_SYM, LM_times},
{"supset", LM_TK_SYM, LM_supset}, {"subset", LM_TK_SYM, LM_subset},
{"spadesuit", LM_TK_SYM, LM_spadesuit}, {"supset", LM_TK_SYM, LM_supset},
{"Re", LM_TK_SYM, LM_Re}, {"spadesuit", LM_TK_SYM, LM_spadesuit},
{"left", LM_TK_LEFT, 0}, {"Re", LM_TK_SYM, LM_Re},
{"smile", LM_TK_SYM, LM_smile}, {"left", LM_TK_LEFT, 0},
{"exists", LM_TK_SYM, LM_exists}, {"smile", LM_TK_SYM, LM_smile},
{"Vert", LM_TK_SYM, LM_Vert}, {"exists", LM_TK_SYM, LM_exists},
{"scriptstyle", LM_TK_STY, LM_ST_SCRIPT}, {"Vert", LM_TK_SYM, LM_Vert},
{"uplus", LM_TK_SYM, LM_uplus}, {"scriptstyle", LM_TK_STY, LM_ST_SCRIPT},
{"ell", LM_TK_SYM, LM_ell}, {"uplus", LM_TK_SYM, LM_uplus},
{"langle", LM_TK_SYM, LM_langle}, {"ell", LM_TK_SYM, LM_ell},
{"scriptscriptstyle", LM_TK_STY, LM_ST_SCRIPTSCRIPT}, {"langle", LM_TK_SYM, LM_langle},
{"zeta", LM_TK_SYM, LM_zeta}, {"scriptscriptstyle", LM_TK_STY, LM_ST_SCRIPTSCRIPT},
{"sigma", LM_TK_SYM, LM_sigma}, {"zeta", LM_TK_SYM, LM_zeta},
{"arccos", LM_TK_FUNC, 0}, {"sigma", LM_TK_SYM, LM_sigma},
{"sup", LM_TK_FUNCLIM, 0}, {"arccos", LM_TK_FUNC, 0},
{"sharp", LM_TK_SYM, LM_sharp}, {"sup", LM_TK_FUNCLIM, 0},
{"sqcup", LM_TK_SYM, LM_sqcup}, {"sharp", LM_TK_SYM, LM_sharp},
{"sqcap", LM_TK_SYM, LM_sqcap}, {"sqcup", LM_TK_SYM, LM_sqcup},
{"approx", LM_TK_SYM, LM_approx}, {"sqcap", LM_TK_SYM, LM_sqcap},
{"triangleleft", LM_TK_SYM, LM_triangleleft}, {"approx", LM_TK_SYM, LM_approx},
{"triangleright", LM_TK_SYM, LM_triangleright}, {"triangleleft", LM_TK_SYM, LM_triangleleft},
{"tilde", LM_TK_ACCENT, LM_tilde}, {"triangleright", LM_TK_SYM, LM_triangleright},
{"lambda", LM_TK_SYM, LM_lambda}, {"tilde", LM_TK_ACCENT, LM_tilde},
{"emptyset", LM_TK_MACRO, LM_emptyset}, {"lambda", LM_TK_SYM, LM_lambda},
{"triangle", LM_TK_SYM, LM_triangle}, {"emptyset", LM_TK_MACRO, LM_emptyset},
{"textstyle", LM_TK_STY, LM_ST_TEXT}, {"triangle", LM_TK_SYM, LM_triangle},
{"tau", LM_TK_SYM, LM_tau}, {"textstyle", LM_TK_STY, LM_ST_TEXT},
{"limsup", LM_TK_FUNCLIM, 0}, {"tau", LM_TK_SYM, LM_tau},
{"partial", LM_TK_SYM, LM_partial}, {"limsup", LM_TK_FUNCLIM, 0},
{"parallel", LM_TK_SYM, LM_parallel}, {"partial", LM_TK_SYM, LM_partial},
{"infty", LM_TK_SYM, LM_infty}, {"parallel", LM_TK_SYM, LM_parallel},
{"kappa", LM_TK_SYM, LM_kappa}, {"infty", LM_TK_SYM, LM_infty},
{"xi", LM_TK_SYM, LM_xi}, {"kappa", LM_TK_SYM, LM_kappa},
{"leftharpoonup", LM_TK_SYM, LM_leftharpoonup}, {"xi", LM_TK_SYM, LM_xi},
{"theta", LM_TK_SYM, LM_theta}, {"leftharpoonup", LM_TK_SYM, LM_leftharpoonup},
{"Xi", LM_TK_SYM, LM_Xi}, {"theta", LM_TK_SYM, LM_theta},
{"searrow", LM_TK_SYM, LM_searrow}, {"Xi", LM_TK_SYM, LM_Xi},
{"swarrow", LM_TK_SYM, LM_swarrow}, {"searrow", LM_TK_SYM, LM_searrow},
{"top", LM_TK_SYM, LM_top}, {"swarrow", LM_TK_SYM, LM_swarrow},
{"Rightarrow", LM_TK_SYM, LM_Rightarrow}, {"top", LM_TK_SYM, LM_top},
{"underline", LM_TK_WIDE, LM_underline}, {"Rightarrow", LM_TK_SYM, LM_Rightarrow},
{"underbrace", LM_TK_WIDE, LM_underbrace}, {"underline", LM_TK_WIDE, LM_underline},
{"eta", LM_TK_SYM, LM_eta}, {"underbrace", LM_TK_WIDE, LM_underbrace},
{"acute", LM_TK_ACCENT, LM_acute}, {"eta", LM_TK_SYM, LM_eta},
{"angle", LM_TK_SYM, LM_angle}, {"acute", LM_TK_ACCENT, LM_acute},
{"exp", LM_TK_FUNC, 0}, {"angle", LM_TK_SYM, LM_angle},
{"leftarrow", LM_TK_SYM, LM_leftarrow}, {"exp", LM_TK_FUNC, 0},
{"prime", LM_TK_SYM, LM_prime}, {"leftarrow", LM_TK_SYM, LM_leftarrow},
{"int", LM_TK_BIGSYM, LM_int}, {"prime", LM_TK_SYM, LM_prime},
{"longleftarrow", LM_TK_SYM, LM_longleftarrow}, {"int", LM_TK_BIGSYM, LM_int},
{"leftrightarrow", LM_TK_SYM, LM_leftrightarrow}, {"longleftarrow", LM_TK_SYM, LM_longleftarrow},
{"longrightarrow", LM_TK_SYM, LM_longrightarrow}, {"leftrightarrow", LM_TK_SYM, LM_leftrightarrow},
{"Gamma", LM_TK_SYM, LM_Gamma}, {"longrightarrow", LM_TK_SYM, LM_longrightarrow},
{"Pi", LM_TK_SYM, LM_Pi}, {"Gamma", LM_TK_SYM, LM_Gamma},
{"Phi", LM_TK_SYM, LM_Phi}, {"Pi", LM_TK_SYM, LM_Pi},
{"Psi", LM_TK_SYM, LM_Psi}, {"Phi", LM_TK_SYM, LM_Phi},
{"longleftrightarrow", LM_TK_SYM, LM_longleftrightarrow}, {"Psi", LM_TK_SYM, LM_Psi},
{"alpha", LM_TK_SYM, LM_alpha}, {"longleftrightarrow", LM_TK_SYM, LM_longleftrightarrow},
{"widehat", LM_TK_WIDE, LM_widehat}, {"alpha", LM_TK_SYM, LM_alpha},
{"sin", LM_TK_FUNC, 0}, {"widehat", LM_TK_WIDE, LM_widehat},
{"asymp", LM_TK_SYM, LM_asymp}, {"sin", LM_TK_FUNC, 0},
{"nolimits", LM_TK_LIMIT, 0 }, {"asymp", LM_TK_SYM, LM_asymp},
{"perp", LM_TK_MACRO, LM_perp}, {"nolimits", LM_TK_LIMIT, 0 },
{"wedge", LM_TK_SYM, LM_wedge}, {"perp", LM_TK_MACRO, LM_perp},
{"ln", LM_TK_FUNC, 0}, {"wedge", LM_TK_SYM, LM_wedge},
{"widetilde", LM_TK_WIDE, LM_widetilde}, {"ln", LM_TK_FUNC, 0},
{"Omega", LM_TK_SYM, LM_Omega}, {"widetilde", LM_TK_WIDE, LM_widetilde},
{"natural", LM_TK_SYM, LM_natural}, {"Omega", LM_TK_SYM, LM_Omega},
{"iota", LM_TK_SYM, LM_iota}, {"natural", LM_TK_SYM, LM_natural},
{"uparrow", LM_TK_SYM, LM_uparrow}, {"iota", LM_TK_SYM, LM_iota},
{"Sigma", LM_TK_SYM, LM_Sigma}, {"uparrow", LM_TK_SYM, LM_uparrow},
{"pi", LM_TK_SYM, LM_pi}, {"Sigma", LM_TK_SYM, LM_Sigma},
{"phi", LM_TK_SYM, LM_phi}, {"pi", LM_TK_SYM, LM_pi},
{"psi", LM_TK_SYM, LM_psi}, {"phi", LM_TK_SYM, LM_phi},
{"updownarrow", LM_TK_SYM, LM_updownarrow}, {"psi", LM_TK_SYM, LM_psi},
{"star", LM_TK_SYM, LM_star}, {"updownarrow", LM_TK_SYM, LM_updownarrow},
{"leftharpoondown", LM_TK_SYM, LM_leftharpoondown}, {"star", LM_TK_SYM, LM_star},
{"wp", LM_TK_SYM, LM_wp}, {"leftharpoondown", LM_TK_SYM, LM_leftharpoondown},
{"not", LM_TK_ACCENT, LM_not}, {"wp", LM_TK_SYM, LM_wp},
{"tan", LM_TK_FUNC, 0}, {"not", LM_TK_ACCENT, LM_not},
{"Theta", LM_TK_SYM, LM_Theta}, {"tan", LM_TK_FUNC, 0},
{"rceil", LM_TK_SYM, LM_rceil}, {"Theta", LM_TK_SYM, LM_Theta},
{"lfloor", LM_TK_SYM, LM_lfloor}, {"rceil", LM_TK_SYM, LM_rceil},
{"rightleftharpoons", LM_TK_SYM, LM_rightleftharpoons}, {"lfloor", LM_TK_SYM, LM_lfloor},
{"cos", LM_TK_FUNC, 0}, {"rightleftharpoons", LM_TK_SYM, LM_rightleftharpoons},
{"sec", LM_TK_FUNC, 0}, {"cos", LM_TK_FUNC, 0},
{"succ", LM_TK_SYM, LM_succ}, {"sec", LM_TK_FUNC, 0},
{"cdots", LM_TK_DOTS, LM_cdots}, {"succ", LM_TK_SYM, LM_succ},
{"epsilon", LM_TK_SYM, LM_epsilon}, {"cdots", LM_TK_DOTS, LM_cdots},
{"ker", LM_TK_FUNC, 0}, {"epsilon", LM_TK_SYM, LM_epsilon},
{"nu", LM_TK_SYM, LM_nu}, {"ker", LM_TK_FUNC, 0},
{"Delta", LM_TK_SYM, LM_Delta}, {"nu", LM_TK_SYM, LM_nu},
{"forall", LM_TK_SYM, LM_forall}, {"Delta", LM_TK_SYM, LM_Delta},
{"liminf", LM_TK_FUNCLIM, 0}, {"forall", LM_TK_SYM, LM_forall},
{"Uparrow", LM_TK_SYM, LM_Uparrow}, {"liminf", LM_TK_FUNCLIM, 0},
{"upsilon", LM_TK_SYM, LM_upsilon}, {"Uparrow", LM_TK_SYM, LM_Uparrow},
{"right", LM_TK_RIGHT, 0}, {"upsilon", LM_TK_SYM, LM_upsilon},
{"Updownarrow", LM_TK_SYM, LM_Updownarrow}, {"right", LM_TK_RIGHT, 0},
{"Pr", LM_TK_FUNCLIM, 0}, {"Updownarrow", LM_TK_SYM, LM_Updownarrow},
{"nabla", LM_TK_SYM, LM_nabla}, {"Pr", LM_TK_FUNCLIM, 0},
{"arcsin", LM_TK_FUNC, 0}, {"nabla", LM_TK_SYM, LM_nabla},
{"arctan", LM_TK_FUNC, 0}, {"arcsin", LM_TK_FUNC, 0},
{"flat", LM_TK_SYM, LM_flat}, {"arctan", LM_TK_FUNC, 0},
{"check", LM_TK_ACCENT, LM_check}, {"flat", LM_TK_SYM, LM_flat},
{"rangle", LM_TK_SYM, LM_rangle}, {"check", LM_TK_ACCENT, LM_check},
{"cot", LM_TK_FUNC, 0}, {"rangle", LM_TK_SYM, LM_rangle},
{"cdot", LM_TK_SYM, LM_cdot}, {"cot", LM_TK_FUNC, 0},
{"clubsuit", LM_TK_SYM, LM_clubsuit}, {"cdot", LM_TK_SYM, LM_cdot},
{"in", LM_TK_SYM, LM_in}, {"clubsuit", LM_TK_SYM, LM_clubsuit},
{"ni", LM_TK_SYM, LM_ni}, {"in", LM_TK_SYM, LM_in},
{"Downarrow", LM_TK_SYM, LM_Downarrow}, {"ni", LM_TK_SYM, LM_ni},
{"Upsilon", LM_TK_SYM, LM_Upsilon}, {"Downarrow", LM_TK_SYM, LM_Downarrow},
{"sim", LM_TK_SYM, LM_sim}, {"Upsilon", LM_TK_SYM, LM_Upsilon},
{"sum", LM_TK_BIGSYM, LM_sum}, {"sim", LM_TK_SYM, LM_sim},
{"models", LM_TK_SYM, LM_models}, {"sum", LM_TK_BIGSYM, LM_sum},
{"nearrow", LM_TK_SYM, LM_nearrow}, {"models", LM_TK_SYM, LM_models},
{"nwarrow", LM_TK_SYM, LM_nwarrow}, {"nearrow", LM_TK_SYM, LM_nearrow},
{"max", LM_TK_FUNCLIM, 0}, {"nwarrow", LM_TK_SYM, LM_nwarrow},
{"Im", LM_TK_SYM, LM_Im}, {"max", LM_TK_FUNCLIM, 0},
{"lim", LM_TK_FUNCLIM, 0}, {"Im", LM_TK_SYM, LM_Im},
{"rightharpoonup", LM_TK_SYM, LM_rightharpoonup}, {"lim", LM_TK_FUNCLIM, 0},
{"mathcal", LM_TK_FONT, LM_TC_CAL}, {"rightharpoonup", LM_TK_SYM, LM_rightharpoonup},
{"cap", LM_TK_SYM, LM_cap}, {"mathcal", LM_TK_FONT, LM_TC_CAL},
{"cup", LM_TK_SYM, LM_cup}, {"cap", LM_TK_SYM, LM_cap},
{"prec", LM_TK_SYM, LM_prec}, {"cup", LM_TK_SYM, LM_cup},
{"mathnormal", LM_TK_FONT, LM_TC_VAR}, {"prec", LM_TK_SYM, LM_prec},
{"wr", LM_TK_SYM, LM_wr}, {"mathnormal", LM_TK_FONT, LM_TC_VAR},
{"inf", LM_TK_FUNCLIM, 0}, {"wr", LM_TK_SYM, LM_wr},
{"bigoplus", LM_TK_BIGSYM, LM_oplus}, {"inf", LM_TK_FUNCLIM, 0},
{"biguplus", LM_TK_BIGSYM, LM_biguplus}, {"bigoplus", LM_TK_BIGSYM, LM_oplus},
{"bigotimes", LM_TK_BIGSYM, LM_otimes}, {"biguplus", LM_TK_BIGSYM, LM_biguplus},
{"rightarrow", LM_TK_SYM, LM_rightarrow}, {"bigotimes", LM_TK_BIGSYM, LM_otimes},
{"mathit", LM_TK_FONT, LM_TC_IT}, {"rightarrow", LM_TK_SYM, LM_rightarrow},
{"textrm", LM_TK_FONT, LM_TC_TEXTRM}, {"mathit", LM_TK_FONT, LM_TC_IT},
{"mathtt", LM_TK_FONT, LM_TC_TT}, {"textrm", LM_TK_FONT, LM_TC_TEXTRM},
{"chi", LM_TK_SYM, LM_chi}, {"mathtt", LM_TK_FONT, LM_TC_TT},
{"simeq", LM_TK_SYM, LM_simeq}, {"chi", LM_TK_SYM, LM_chi},
{"succeq", LM_TK_SYM, LM_succeq}, {"simeq", LM_TK_SYM, LM_simeq},
{"notin", LM_TK_MACRO, LM_notin}, {"succeq", LM_TK_SYM, LM_succeq},
{"subseteq", LM_TK_SYM, LM_subseteq}, {"notin", LM_TK_MACRO, LM_notin},
{"supseteq", LM_TK_SYM, LM_supseteq}, {"subseteq", LM_TK_SYM, LM_subseteq},
{"sqsubseteq", LM_TK_SYM, LM_sqsubseteq}, {"supseteq", LM_TK_SYM, LM_supseteq},
{"sqsupseteq", LM_TK_SYM, LM_sqsupseteq}, {"sqsubseteq", LM_TK_SYM, LM_sqsubseteq},
{"leq", LM_TK_SYM, LM_leq}, {"sqsupseteq", LM_TK_SYM, LM_sqsupseteq},
{"surd", LM_TK_SYM, LM_surd}, {"leq", LM_TK_SYM, LM_leq},
{"ddots", LM_TK_DOTS, LM_ddots}, {"surd", LM_TK_SYM, LM_surd},
{"mu", LM_TK_SYM, LM_mu}, {"ddots", LM_TK_DOTS, LM_ddots},
{"bot", LM_TK_SYM, LM_bot}, {"mu", LM_TK_SYM, LM_mu},
{"bullet", LM_TK_SYM, LM_bullet}, {"bot", LM_TK_SYM, LM_bot},
{"bigodot", LM_TK_BIGSYM, LM_bigodot}, {"bullet", LM_TK_SYM, LM_bullet},
{"sinh", LM_TK_FUNC, 0}, {"bigodot", LM_TK_BIGSYM, LM_bigodot},
{"jmath", LM_TK_SYM, LM_jmath}, {"sinh", LM_TK_FUNC, 0},
{"mp", LM_TK_SYM, LM_mp}, {"jmath", LM_TK_SYM, LM_jmath},
{"pm", LM_TK_SYM, LM_pm}, {"mp", LM_TK_SYM, LM_mp},
{"nonumber", LM_TK_NONUM, 0}, {"pm", LM_TK_SYM, LM_pm},
{"breve", LM_TK_ACCENT, LM_breve}, {"nonumber", LM_TK_NONUM, 0},
{"bigvee", LM_TK_BIGSYM, LM_vee}, {"breve", LM_TK_ACCENT, LM_breve},
{"bowtie", LM_TK_SYM, LM_bowtie}, {"bigvee", LM_TK_BIGSYM, LM_vee},
{"bigwedge", LM_TK_BIGSYM, LM_wedge}, {"bowtie", LM_TK_SYM, LM_bowtie},
{"frown", LM_TK_SYM, LM_frown}, {"bigwedge", LM_TK_BIGSYM, LM_wedge},
{"rightharpoondown", LM_TK_SYM, LM_rightharpoondown}, {"frown", LM_TK_SYM, LM_frown},
{"det", LM_TK_FUNCLIM, 0}, {"rightharpoondown", LM_TK_SYM, LM_rightharpoondown},
{"dot", LM_TK_ACCENT, LM_dot}, {"det", LM_TK_FUNCLIM, 0},
{"ddot", LM_TK_ACCENT, LM_ddot}, {"dot", LM_TK_ACCENT, LM_dot},
{"lg", LM_TK_FUNC, 0}, {"ddot", LM_TK_ACCENT, LM_ddot},
{"log", LM_TK_FUNC, 0}, {"lg", LM_TK_FUNC, 0},
{"oplus", LM_TK_SYM, LM_oplus}, {"log", LM_TK_FUNC, 0},
{"ominus", LM_TK_SYM, LM_ominus}, {"oplus", LM_TK_SYM, LM_oplus},
{"otimes", LM_TK_SYM, LM_otimes}, {"ominus", LM_TK_SYM, LM_ominus},
{"beta", LM_TK_SYM, LM_beta}, {"otimes", LM_TK_SYM, LM_otimes},
{"diamondsuit", LM_TK_SYM, LM_diamondsuit}, {"beta", LM_TK_SYM, LM_beta},
{"rfloor", LM_TK_SYM, LM_rfloor}, {"diamondsuit", LM_TK_SYM, LM_diamondsuit},
{"end", LM_TK_END, 0}, {"rfloor", LM_TK_SYM, LM_rfloor},
{"hat", LM_TK_ACCENT, LM_hat}, {"end", LM_TK_END, 0},
{"tanh", LM_TK_FUNC, 0}, {"hat", LM_TK_ACCENT, LM_hat},
{"vdots", LM_TK_DOTS, LM_vdots}, {"tanh", LM_TK_FUNC, 0},
{"bigcap", LM_TK_BIGSYM, LM_cap}, {"vdots", LM_TK_DOTS, LM_vdots},
{"bigcup", LM_TK_BIGSYM, LM_cup}, {"bigcap", LM_TK_BIGSYM, LM_cap},
{"bigsqcup", LM_TK_BIGSYM, LM_bigsqcup}, {"bigcup", LM_TK_BIGSYM, LM_cup},
{"heartsuit", LM_TK_SYM, LM_heartsuit}, {"bigsqcup", LM_TK_BIGSYM, LM_bigsqcup},
{"displaystyle", LM_TK_STY, LM_ST_DISPLAY}, {"heartsuit", LM_TK_SYM, LM_heartsuit},
{"longmapsto", LM_TK_SYM, LM_longmapsto}, {"displaystyle", LM_TK_STY, LM_ST_DISPLAY},
{"bigtriangleup", LM_TK_SYM, LM_bigtriangleup}, {"longmapsto", LM_TK_SYM, LM_longmapsto},
{"preceq", LM_TK_SYM, LM_preceq}, {"bigtriangleup", LM_TK_SYM, LM_bigtriangleup},
{"delta", LM_TK_SYM, LM_delta}, {"preceq", LM_TK_SYM, LM_preceq},
{"odot", LM_TK_SYM, LM_odot}, {"delta", LM_TK_SYM, LM_delta},
{"oint", LM_TK_BIGSYM, LM_oint}, {"odot", LM_TK_SYM, LM_odot},
{"grave", LM_TK_ACCENT, LM_grave}, {"oint", LM_TK_BIGSYM, LM_oint},
{"pmod", LM_TK_PMOD, 0}, {"grave", LM_TK_ACCENT, LM_grave},
{"prod", LM_TK_BIGSYM, LM_prod}, {"pmod", LM_TK_PMOD, 0},
{"frac", LM_TK_FRAC, 0}, {"prod", LM_TK_BIGSYM, LM_prod},
{"csc", LM_TK_FUNC, 0}, {"frac", LM_TK_FRAC, 0},
{"circ", LM_TK_SYM, LM_circ}, {"csc", LM_TK_FUNC, 0},
{"aleph", LM_TK_SYM, LM_aleph}, {"circ", LM_TK_SYM, LM_circ},
{"min", LM_TK_FUNCLIM, 0}, {"aleph", LM_TK_SYM, LM_aleph},
{"overline", LM_TK_WIDE, LM_overline}, {"min", LM_TK_FUNCLIM, 0},
{"arg", LM_TK_FUNC, 0}, {"overline", LM_TK_WIDE, LM_overline},
{"overbrace", LM_TK_WIDE, LM_overbrace}, {"arg", LM_TK_FUNC, 0},
{"amalg", LM_TK_SYM, LM_amalg}, {"overbrace", LM_TK_WIDE, LM_overbrace},
{"gamma", LM_TK_SYM, LM_gamma}, {"amalg", LM_TK_SYM, LM_amalg},
{"vee", LM_TK_SYM, LM_vee}, {"gamma", LM_TK_SYM, LM_gamma},
{"equiv", LM_TK_SYM, LM_equiv}, {"vee", LM_TK_SYM, LM_vee},
{"omega", LM_TK_SYM, LM_omega}, {"equiv", LM_TK_SYM, LM_equiv},
{"downarrow", LM_TK_SYM, LM_downarrow}, {"omega", LM_TK_SYM, LM_omega},
{"imath", LM_TK_SYM, LM_imath}, {"downarrow", LM_TK_SYM, LM_downarrow},
{"propto", LM_TK_SYM, LM_propto}, {"imath", LM_TK_SYM, LM_imath},
{"begin", LM_TK_BEGIN, 0}, {"propto", LM_TK_SYM, LM_propto},
{"Lambda", LM_TK_SYM, LM_Lambda}, {"begin", LM_TK_BEGIN, 0},
{"varsigma", LM_TK_SYM, LM_varsigma}, {"Lambda", LM_TK_SYM, LM_Lambda},
{"vartheta", LM_TK_SYM, LM_vartheta}, {"varsigma", LM_TK_SYM, LM_varsigma},
{"neq", LM_TK_SYM, LM_neq}, {"vartheta", LM_TK_SYM, LM_vartheta},
{"hookleftarrow", LM_TK_SYM, LM_hookleftarrow}, {"neq", LM_TK_SYM, LM_neq},
{"hookrightarrow", LM_TK_SYM, LM_hookrightarrow}, {"hookleftarrow", LM_TK_SYM, LM_hookleftarrow},
{"bigtriangledown", LM_TK_SYM, LM_bigtriangledown}, {"hookrightarrow", LM_TK_SYM, LM_hookrightarrow},
{"mathbf", LM_TK_FONT, LM_TC_BF}, {"bigtriangledown", LM_TK_SYM, LM_bigtriangledown},
{"mathsf", LM_TK_FONT, LM_TC_SF}, {"mathbf", LM_TK_FONT, LM_TC_BF},
{"bar", LM_TK_ACCENT, LM_bar}, {"mathsf", LM_TK_FONT, LM_TC_SF},
{"varpi", LM_TK_SYM, LM_varpi}, {"bar", LM_TK_ACCENT, LM_bar},
{"varphi", LM_TK_SYM, LM_varphi}, {"varpi", LM_TK_SYM, LM_varpi},
{"newcommand", LM_TK_NEWCOMMAND, 0 }, {"varphi", LM_TK_SYM, LM_varphi},
{"overleftarrow", LM_TK_WIDE, LM_overleftarrow}, {"newcommand", LM_TK_NEWCOMMAND, 0 },
{"overrightarrow", LM_TK_WIDE, LM_overightarrow}, {"overleftarrow", LM_TK_WIDE, LM_overleftarrow},
{"Leftarrow", LM_TK_SYM, LM_Leftarrow}, {"overrightarrow", LM_TK_WIDE, LM_overightarrow},
{"Longleftarrow", LM_TK_SYM, LM_Longleftarrow}, {"Leftarrow", LM_TK_SYM, LM_Leftarrow},
{"Leftrightarrow", LM_TK_SYM, LM_Leftrightarrow}, {"Longleftarrow", LM_TK_SYM, LM_Longleftarrow},
{"Longrightarrow", LM_TK_SYM, LM_Longrightarrow}, {"Leftrightarrow", LM_TK_SYM, LM_Leftrightarrow},
{"neg", LM_TK_SYM, LM_neg}, {"Longrightarrow", LM_TK_SYM, LM_Longrightarrow},
{"bigcirc", LM_TK_SYM, LM_bigcirc}, {"neg", LM_TK_SYM, LM_neg},
{"Longleftrightarrow", LM_TK_SYM, LM_Longleftrightarrow}, {"bigcirc", LM_TK_SYM, LM_bigcirc},
{"dagger", LM_TK_SYM, LM_dagger}, {"Longleftrightarrow", LM_TK_SYM, LM_Longleftrightarrow},
{"ddagger", LM_TK_SYM, LM_ddagger}, {"dagger", LM_TK_SYM, LM_dagger},
{"hbar", LM_TK_SYM, LM_hbar}, {"ddagger", LM_TK_SYM, LM_ddagger},
{"coprod", LM_TK_BIGSYM, LM_coprod}, {"hbar", LM_TK_SYM, LM_hbar},
{"mathrm", LM_TK_FONT, LM_TC_RM}, {"coprod", LM_TK_BIGSYM, LM_coprod},
{"varepsilon", LM_TK_SYM, LM_varepsilon}, {"mathrm", LM_TK_FONT, LM_TC_RM},
{"cosh", LM_TK_FUNC, 0}, {"varepsilon", LM_TK_SYM, LM_varepsilon},
{"coth", LM_TK_FUNC, 0}, {"cosh", LM_TK_FUNC, 0},
{"rho", LM_TK_SYM, LM_rho}, {"coth", LM_TK_FUNC, 0},
{"cong", LM_TK_SYM, LM_cong}, {"rho", LM_TK_SYM, LM_rho},
{"vec", LM_TK_ACCENT, LM_vec}, {"cong", LM_TK_SYM, LM_cong},
{"dim", LM_TK_FUNC, 0}, {"vec", LM_TK_ACCENT, LM_vec},
{"mid", LM_TK_SYM, LM_mid}, {"dim", LM_TK_FUNC, 0},
{"hom", LM_TK_FUNC, 0}, {"mid", LM_TK_SYM, LM_mid},
{"bmod", LM_TK_FUNC, 0}, {"hom", LM_TK_FUNC, 0},
{"quad", LM_TK_SPACE, LM_quad}, {"bmod", LM_TK_FUNC, 0},
{"doteq", LM_TK_SYM, LM_doteq}, {"quad", LM_TK_SPACE, LM_quad},
{"qquad", LM_TK_SPACE, LM_qquad}, {"doteq", LM_TK_SYM, LM_doteq},
{"mapsto", LM_TK_SYM, LM_mapsto}, {"qquad", LM_TK_SPACE, LM_qquad},
{"backslash", LM_TK_SYM, LM_backslash}, {"mapsto", LM_TK_SYM, LM_mapsto},
{"diamond", LM_TK_SYM, LM_diamond}, {"backslash", LM_TK_SYM, LM_backslash},
{"geq", LM_TK_SYM, LM_geq}, {"diamond", LM_TK_SYM, LM_diamond},
{"deg", LM_TK_FUNC, 0}, {"geq", LM_TK_SYM, LM_geq},
{"gcd", LM_TK_FUNCLIM, 0}, {"deg", LM_TK_FUNC, 0},
{"gg", LM_TK_SYM, LM_gg}, {"gcd", LM_TK_FUNCLIM, 0},
{"div", LM_TK_SYM, LM_div}, {"gg", LM_TK_SYM, LM_gg},
{"dashv", LM_TK_SYM, LM_dashv}, {"div", LM_TK_SYM, LM_div},
{"oslash", LM_TK_SYM, LM_oslash}, {"dashv", LM_TK_SYM, LM_dashv},
{"vdash", LM_TK_SYM, LM_vdash}, {"oslash", LM_TK_SYM, LM_oslash},
{"vdash", LM_TK_SYM, LM_vdash},
}; };
static short lookup[] = static short lookup[] =
@ -326,43 +326,43 @@ static short lookup[] =
68, 565, 71, 72, 499, 75, -1, 76, -1, 77, 78, -1, 79, -73, 68, 565, 71, 72, 499, 75, -1, 76, -1, 77, 78, -1, 79, -73,
-2, 80, 81, 82, -1, 83, -1, 84, 85, -1, 86, 87, 88, 89, -2, 80, 81, 82, -1, 83, -1, 84, 85, -1, 86, 87, 88, 89,
90, 501, 93, 94, 95, -1, 96, 493, -1, 99, -97, -2, -91, -2, 90, 501, 93, 94, 95, -1, 96, 493, -1, 99, -97, -2, -91, -2,
100, 101, 102, 517, 105, 106, -1, 107, 108, 109, 110, 497, 113, -1, 100, 101, 102, 517, 105, 106, -1, 107, 108, 109, 110, 497, 113, -1,
114, 115, 116, 117,-111, -2, 118, 491,-119, -2, 121, 122, 123, -1, 114, 115, 116, 117,-111, -2, 118, 491,-119, -2, 121, 122, 123, -1,
124, 125,-103, -2, -1, 126, -69, -2, 491,-127, -2, 129, -55, -2, 124, 125,-103, -2, -1, 126, -69, -2, 491,-127, -2, 129, -55, -2,
130, 491,-131, -2, 133, 492, 136,-134, -2, -1, 137, 138, 139, -42, 130, 491,-131, -2, 133, 492, 136,-134, -2, -1, 137, 138, 139, -42,
-2, 140, 495, 143, 144, -1, 145,-141, -2, -34, -3, 146, 613, 149, -2, 140, 495, 143, 144, -1, 145,-141, -2, -34, -3, 146, 613, 149,
150, 605, 154, 155, 156, 157, 503, -1, 491,-160, -2, 162, -1, 163, 150, 605, 154, 155, 156, 157, 503, -1, 491,-160, -2, 162, -1, 163,
491,-164, -2, -1, 166,-158, -2, 167, 168, -1, 169, 170, -1, 577, 491,-164, -2, -1, 166,-158, -2, 167, 168, -1, 169, 170, -1, 577,
173, -1, 174, 554, -1, 177, -1, 178, 179, 543, 182, 183, 184, -1, 173, -1, 174, 554, -1, 177, -1, 178, 179, 543, 182, 183, 184, -1,
185, 509, 188, 189, 190, 191, 192, 193, 194, 499, -1, 197, 198, -1, 185, 509, 188, 189, 190, 191, 192, 193, 194, 499, -1, 197, 198, -1,
199, 200, 201, 202,-195, -2,-186, -2, 203, -1, 500, 206, 492, 209, 199, 200, 201, 202,-195, -2,-186, -2, 203, -1, 500, 206, 492, 209,
-207, -2, -1, 210, 211, 212,-204, -2, 213, -1, 498, 216, 494, 219, -207, -2, -1, 210, 211, 212,-204, -2, 213, -1, 498, 216, 494, 219,
-1, 220,-217, -2,-214, -2,-180, -2, 221, 222, 223,-175, -2, -1, -1, 220,-217, -2,-214, -2,-180, -2, 221, 222, 223,-175, -2, -1,
224, -1, 225, 226, -1, 491,-227, -2, 229, -1, 230, 231, 232, 491, 224, -1, 225, 226, -1, 491,-227, -2, 229, -1, 230, 231, 232, 491,
-233, -2,-171, -2,-151, -3, 235, 236, 237,-147, -2, -1, 238, 239, -233, -2,-171, -2,-151, -3, 235, 236, 237,-147, -2, -1, 238, 239,
240, -1, -1, 241, -1, -1, -1, 242, 498, 245, -1, 246, 247, -1, 240, -1, -1, 241, -1, -1, -1, 242, 498, 245, -1, 246, 247, -1,
248, 249,-243, -2, -1, -1, -1, -1, -1, 250, -1, -1, -1, -1, 248, 249,-243, -2, -1, -1, -1, -1, -1, 250, -1, -1, -1, -1,
-1, 251, 252, -1, -1, -1, 253, -1, -1, -1, 492, 256,-254, -2, -1, 251, 252, -1, -1, -1, 253, -1, -1, -1, 492, 256,-254, -2,
-1, -1, -1, 257, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 257, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 258, -1, -1, -1, 491,-259, -2, -1, -1, -1, -1, -1, -1, -1, 258, -1, -1, -1, 491,-259, -2, -1,
-1, -1, -1, -1, -1, -1, -1, 261, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 261, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 262, -1, -1, -1, -1, -1, -1, -1, 263, 492, 266, -1, -1, -1, 262, -1, -1, -1, -1, -1, -1, -1, 263, 492, 266,
-264, -2, -1, -1, -1, 267, -1, -1, -1, -1, -1, 268, -1, -1, -264, -2, -1, -1, -1, 267, -1, -1, -1, -1, -1, 268, -1, -1,
269, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 491,-270, -2, 269, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 491,-270, -2,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
272, 273, -1, 274, -1, -1, -1, 275, -1, -1, -1, -1, -1, -1, 272, 273, -1, 274, -1, -1, -1, 275, -1, -1, -1, -1, -1, -1,
276, 276,
}; };
latexkeys * latexkeys *
in_word_set (register char const *str, register int len) in_word_set (register char const * str, register int len)
{ {
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) {
int key = math_hash (str, len); int const key = math_hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0) { if (key <= MAX_HASH_VALUE && key >= 0) {
int idx = lookup[key]; int const idx = lookup[key];
if (idx >= 0 && idx < MAX_HASH_VALUE) { if (idx >= 0 && idx < MAX_HASH_VALUE) {
char const * s = wordlist[idx].name; char const * s = wordlist[idx].name;
@ -372,7 +372,7 @@ in_word_set (register char const *str, register int len)
} else if (idx < 0 && idx >= -MAX_HASH_VALUE) { } else if (idx < 0 && idx >= -MAX_HASH_VALUE) {
return 0; return 0;
} else { } else {
int offset = key + idx + (idx > 0 ? -MAX_HASH_VALUE : MAX_HASH_VALUE); int const offset = key + idx + (idx > 0 ? -MAX_HASH_VALUE : MAX_HASH_VALUE);
latexkeys * base = &wordlist[-lookup[offset]]; latexkeys * base = &wordlist[-lookup[offset]];
latexkeys * ptr = base + -lookup[offset + 1]; latexkeys * ptr = base + -lookup[offset + 1];
@ -392,22 +392,22 @@ latexkeys * in_word_set(string const & str)
} }
latexkeys *lm_get_key_by_id(int t, short tk) latexkeys * lm_get_key_by_id(int t, short tk)
{ {
latexkeys * l = &wordlist[MIN_HASH_VALUE+TOTAL_KEYWORDS]; latexkeys * l = &wordlist[MIN_HASH_VALUE+TOTAL_KEYWORDS];
latexkeys * base = &wordlist[MIN_HASH_VALUE]; latexkeys * base = &wordlist[MIN_HASH_VALUE];
while (--l >= base) { while (--l >= base) {
if (t == l->id && tk == l->token) if (t == l->id && tk == l->token)
return l; return l;
} }
return 0; return 0;
} }
latexkeys *lm_get_key_by_index(int i) latexkeys * lm_get_key_by_index(int i)
{ {
if (i > 0 && i < TOTAL_KEYWORDS + 2) if (i > 0 && i < TOTAL_KEYWORDS + 2)
return &wordlist[i]; return &wordlist[i];
else else
return 0; return 0;
} }

View File

@ -36,26 +36,26 @@ int MathedInset::workWidth;
MathedInset::MathedInset(MathedInset * inset) MathedInset::MathedInset(MathedInset * inset)
{ {
if (inset) { if (inset) {
name = inset->GetName(); name = inset->GetName();
objtype = inset->GetType(); objtype = inset->GetType();
size = inset->GetStyle(); size_ = inset->GetStyle();
width = inset->Width(); width = inset->Width();
ascent = inset->Ascent(); ascent = inset->Ascent();
descent = inset->Descent(); descent = inset->Descent();
} else { } else {
objtype = LM_OT_UNDEF; objtype = LM_OT_UNDEF;
size = LM_ST_TEXT; size_ = LM_ST_TEXT;
width = ascent = descent = 0; width = ascent = descent = 0;
//name = 0; //name = 0;
} }
} }
MathedInset::MathedInset(string const & nm, short ot, short st): MathedInset::MathedInset(string const & nm, short ot, short st)
name(nm), objtype(ot), size(st) : name(nm), objtype(ot), size_(st)
{ {
width = ascent = descent = 0; width = ascent = descent = 0;
} }
@ -65,15 +65,104 @@ void MathedInset::drawStr(Painter & pain, short type, int siz,
{ {
string st; string st;
if (MathIsBinary(type)) if (MathIsBinary(type))
for (string::const_iterator it = s.begin(); it != s.end(); ++it) { for (string::const_iterator it = s.begin();
it != s.end(); ++it) {
st += ' '; st += ' ';
st += *it; st += *it;
st += ' '; st += ' ';
} }
else else
st = s; st = s;
LyXFont const mf = mathed_get_font(type, siz); LyXFont const mf = mathed_get_font(type, siz);
pain.text(x, y, st, mf); pain.text(x, y, st, mf);
} }
int MathedInset::Ascent() const
{
return ascent;
}
int MathedInset::Descent() const
{
return descent;
}
int MathedInset::Width() const
{
return width;
}
int MathedInset::Height() const
{
return ascent + descent;
}
bool MathedInset::GetLimits() const
{
return false;
}
void MathedInset::SetLimits(bool) {}
string const & MathedInset::GetName() const
{
return name;
}
short MathedInset::GetType() const
{
return objtype;
}
short MathedInset::GetStyle() const
{
return size_;
}
void MathedInset::SetType(short t)
{
objtype = t;
}
void MathedInset::SetStyle(short st)
{
size_ = st;
}
void MathedInset::SetName(string const & n)
{
name = n;
}
void MathedInset::defaultAscent(int da)
{
df_asc = da;
}
void MathedInset::defaultDescent(int dd)
{
df_des = dd;
}
void MathedInset::defaultWidth(int dw)
{
df_width = dw;
}

View File

@ -35,75 +35,91 @@ class Painter;
A math insets is for use of the math editor only, it isn't a A math insets is for use of the math editor only, it isn't a
general LyX inset. It's used to represent all the math objects. general LyX inset. It's used to represent all the math objects.
The formulaInset (a LyX inset) encapsulates a math inset. The formulaInset (a LyX inset) encapsulates a math inset.
*/ */
class MathedInset { class MathedInset {
public: public:
/// A math inset has a name (usually its LaTeX name), type and font-size /** A math inset has a name (usually its LaTeX name),
MathedInset(string const & nm, short ot, short st); type and font-size
/// */
explicit MathedInset(string const & nm, short ot, short st);
MathedInset(MathedInset *); ///
/// explicit
virtual ~MathedInset() {} MathedInset(MathedInset *);
/// Draw the object ///
virtual void draw(Painter &, int x, int baseline) = 0; virtual ~MathedInset() {}
/// Write LaTeX and Lyx code /// Draw the object
virtual void Write(std::ostream &, bool fragile) = 0; virtual void draw(Painter &, int x, int baseline) = 0;
/// Reproduces itself /// Write LaTeX and Lyx code
virtual MathedInset * Clone() = 0; virtual void Write(std::ostream &, bool fragile) = 0;
/// Compute the size of the object /// Reproduces itself
virtual void Metrics() = 0; virtual MathedInset * Clone() = 0;
/// /// Compute the size of the object
virtual int Ascent() const { return ascent; } virtual void Metrics() = 0;
/// ///
virtual int Descent() const { return descent; } virtual int Ascent() const;
/// ///
virtual int Width() const { return width; } virtual int Descent() const;
/// ///
virtual int Height() const { return ascent + descent; } virtual int Width() const;
/// ///
virtual bool GetLimits() const { return false; } virtual int Height() const;
/// ///
virtual void SetLimits(bool) {} virtual bool GetLimits() const;
/// ///
string const & GetName() const { return name; } virtual void SetLimits(bool);
/// ///
short GetType() const { return objtype; } string const & GetName() const;
/// ///
short GetStyle() const { return size; } short GetType() const;
//Man: Avoid to use these functions if it's not strictly necessary ///
/// short GetStyle() const;
virtual void SetType(short t) { objtype = t; } //Man: Avoid to use these functions if it's not strictly necessary
/// ///
virtual void SetStyle(short st) { size = st; } // Metrics(); virtual void SetType(short t);
/// ///
virtual void SetName(string const & n) { name = n; } virtual void SetStyle(short st);
/// ///
static int workWidth; virtual void SetName(string const & n);
protected: ///
/// static int workWidth;
string name; ///
/// static void defaultAscent(int da);
short objtype; ///
/// static void defaultDescent(int dd);
int width; ///
/// static void defaultWidth(int dw);
int ascent; ///
/// short size() const {
int descent; return size_;
/// }
short size; protected:
/// Default metrics ///
static int df_asc; string name;
/// ///
static int df_des; short objtype;
/// ///
static int df_width; int width;
/// In a near future maybe we use a better fonts renderer than X ///
void drawStr(Painter &, short, int, int, int, string const &); int ascent;
/// ///
friend class MathedCursor; int descent;
/// /// Default metrics
friend void mathed_init_fonts(); static int df_asc;
///
static int df_des;
///
static int df_width;
/// In a near future maybe we use a better fonts renderer than X
void drawStr(Painter &, short, int, int, int, string const &);
///
void size(short s) {
size_ = s;
}
void incSize() {
++size_;
}
private:
///
short size_;
}; };
#endif #endif

View File

@ -45,29 +45,29 @@ ostream & operator<<(ostream & o, MathedTextCodes mtc)
MathMacro::MathMacro(MathMacroTemplate * t): MathMacro::MathMacro(MathMacroTemplate * t):
MathParInset(LM_ST_TEXT, "", LM_OT_MACRO), tmplate(t) MathParInset(LM_ST_TEXT, "", LM_OT_MACRO), tmplate_(t)
{ {
nargs = tmplate->getNoArgs(); nargs_ = tmplate_->getNoArgs();
tcode = tmplate->getTCode(); tcode_ = tmplate_->getTCode();
args_.resize(nargs); args_.resize(nargs_);
for (int i = 0; i < nargs; ++i) { for (int i = 0; i < nargs_; ++i) {
args_[i].row = 0; args_[i].row = 0;
} }
idx = 0; idx_ = 0;
SetName(tmplate->GetName()); SetName(tmplate_->GetName());
} }
MathMacro::MathMacro(MathMacro * m): MathMacro::MathMacro(MathMacro * m):
MathParInset(LM_ST_TEXT, m->GetName(), LM_OT_MACRO) MathParInset(LM_ST_TEXT, m->GetName(), LM_OT_MACRO)
{ {
tmplate = m->tmplate; tmplate_ = m->tmplate_;
nargs = tmplate->getNoArgs(); nargs_ = tmplate_->getNoArgs();
tcode = tmplate->getTCode(); tcode_ = tmplate_->getTCode();
args_.resize(nargs); args_.resize(nargs_);
idx = 0; idx_ = 0;
SetName(tmplate->GetName()); SetName(tmplate_->GetName());
for (int i = 0; i < tmplate->nargs; ++i) { for (int i = 0; i < tmplate_->getNoArgs(); ++i) {
m->setArgumentIdx(i); m->setArgumentIdx(i);
MathedIter it(m->GetData()); MathedIter it(m->GetData());
args_[i].row = m->args_[i].row; args_[i].row = m->args_[i].row;
@ -78,10 +78,10 @@ MathMacro::MathMacro(MathMacro * m):
MathMacro::~MathMacro() MathMacro::~MathMacro()
{ {
for (idx = 0; idx < nargs; ++idx) { for (idx_ = 0; idx_ < nargs_; ++idx_) {
MathedIter it(args_[idx].array); MathedIter it(args_[idx_].array);
it.Clear(); it.Clear();
delete args_[idx].row; delete args_[idx_].row;
} }
} }
@ -94,34 +94,34 @@ MathedInset * MathMacro::Clone()
void MathMacro::Metrics() void MathMacro::Metrics()
{ {
if (nargs > 0) if (nargs_ > 0)
tmplate->update(this); tmplate_->update(this);
tmplate->SetStyle(size); tmplate_->SetStyle(size());
tmplate->Metrics(); tmplate_->Metrics();
width = tmplate->Width(); width = tmplate_->Width();
ascent = tmplate->Ascent(); ascent = tmplate_->Ascent();
descent = tmplate->Descent(); descent = tmplate_->Descent();
} }
void MathMacro::draw(Painter & pain, int x, int y) void MathMacro::draw(Painter & pain, int x, int y)
{ {
xo = x; xo(x);
yo = y; yo(y);
Metrics(); Metrics();
tmplate->update(this); tmplate_->update(this);
tmplate->SetStyle(size); tmplate_->SetStyle(size());
tmplate->draw(pain, x, y); tmplate_->draw(pain, x, y);
for (int i = 0; i < nargs; ++i) { for (int i = 0; i < nargs_; ++i) {
tmplate->GetMacroXY(i, args_[i].x, args_[i].y); tmplate_->GetMacroXY(i, args_[i].x, args_[i].y);
} }
} }
bool MathMacro::setArgumentIdx(int i) bool MathMacro::setArgumentIdx(int i)
{ {
if (i >= 0 && i < nargs) { if (i >= 0 && i < nargs_) {
idx = i; idx_ = i;
return true; return true;
} else } else
return false; return false;
@ -130,52 +130,52 @@ bool MathMacro::setArgumentIdx(int i)
int MathMacro::getArgumentIdx() const int MathMacro::getArgumentIdx() const
{ {
return idx; return idx_;
} }
int MathMacro::getMaxArgumentIdx() const int MathMacro::getMaxArgumentIdx() const
{ {
return nargs - 1; return nargs_ - 1;
} }
MathedArray * MathMacro::GetData() MathedArray * MathMacro::GetData()
{ {
return args_[idx].array; return args_[idx_].array;
} }
int MathMacro::GetColumns() const int MathMacro::GetColumns() const
{ {
return tmplate->getMacroPar(idx)->GetColumns(); return tmplate_->getMacroPar(idx_)->GetColumns();
} }
void MathMacro::GetXY(int & x, int & y) const void MathMacro::GetXY(int & x, int & y) const
{ {
x = args_[idx].x; x = args_[idx_].x;
y = args_[idx].y; y = args_[idx_].y;
} }
bool MathMacro::Permit(short f) const bool MathMacro::Permit(short f) const
{ {
return (nargs > 0) ? return (nargs_ > 0) ?
tmplate->getMacroPar(idx)->Permit(f) : MathParInset::Permit(f); tmplate_->getMacroPar(idx_)->Permit(f) : MathParInset::Permit(f);
} }
void MathMacro::SetFocus(int x, int y) void MathMacro::SetFocus(int x, int y)
{ {
tmplate->update(this); tmplate_->update(this);
tmplate->SetMacroFocus(idx, x, y); tmplate_->SetMacroFocus(idx_, x, y);
} }
void MathMacro::SetData(MathedArray * a) void MathMacro::SetData(MathedArray * a)
{ {
args_[idx].array = a; args_[idx_].array = a;
} }
@ -183,25 +183,25 @@ void MathMacro::SetData(MathedArray * a)
MathedRowSt * MathMacro::getRowSt() const MathedRowSt * MathMacro::getRowSt() const
{ {
return args_[idx].row; return args_[idx_].row;
} }
MathedTextCodes MathMacro::getTCode() const MathedTextCodes MathMacro::getTCode() const
{ {
return tcode; return tcode_;
} }
void MathMacro::Write(ostream & os, bool fragile) void MathMacro::Write(ostream & os, bool fragile)
{ {
if (tmplate->flags & MMF_Exp) { if (tmplate_->flags() & MMF_Exp) {
lyxerr[Debug::MATHED] << "Expand " << tmplate->flags lyxerr[Debug::MATHED] << "Expand " << tmplate_->flags()
<< ' ' << MMF_Exp << endl; << ' ' << MMF_Exp << endl;
tmplate->update(this); tmplate_->update(this);
tmplate->Write(os, fragile); tmplate_->Write(os, fragile);
} else { } else {
if (tmplate->flags & MMF_Env) { if (tmplate_->flags() & MMF_Env) {
os << "\\begin{" os << "\\begin{"
<< name << name
<< "} "; << "} ";
@ -214,21 +214,21 @@ void MathMacro::Write(ostream & os, bool fragile)
// file += ']'; // file += ']';
// } // }
if (!(tmplate->flags & MMF_Env) && nargs > 0) if (!(tmplate_->flags() & MMF_Env) && nargs_ > 0)
os << '{'; os << '{';
for (int i = 0; i < nargs; ++i) { for (int i = 0; i < nargs_; ++i) {
array = args_[i].array; array = args_[i].array;
MathParInset::Write(os, fragile); MathParInset::Write(os, fragile);
if (i < nargs - 1) if (i < nargs_ - 1)
os << "}{"; os << "}{";
} }
if (tmplate->flags & MMF_Env) { if (tmplate_->flags() & MMF_Env) {
os << "\\end{" os << "\\end{"
<< name << name
<< '}'; << '}';
} else { } else {
if (nargs > 0) if (nargs_ > 0)
os << '}'; os << '}';
else else
os << ' '; os << ' ';

View File

@ -71,7 +71,7 @@ public:
bool Permit(short) const; bool Permit(short) const;
private: private:
/// ///
MathMacroTemplate * tmplate; MathMacroTemplate * tmplate_;
/// ///
struct MacroArgumentBase { struct MacroArgumentBase {
/// Position of the macro /// Position of the macro
@ -83,16 +83,16 @@ private:
/// ///
MathedArray * array; MathedArray * array;
/// ///
MacroArgumentBase() { x = y = 0; array = 0; row = 0; } MacroArgumentBase()
: x(0), y(0), row(0), array(0)
{}
}; };
std::vector<MacroArgumentBase> args_; std::vector<MacroArgumentBase> args_;
/// ///
int idx; int idx_;
/// ///
int nargs; int nargs_;
/// ///
MathedTextCodes tcode; MathedTextCodes tcode_;
///
friend class MathMacroTemplate;
}; };
#endif #endif

View File

@ -53,11 +53,10 @@ void MathMacroArgument::draw(Painter & pain, int x, int baseline)
{ {
if (expnd_mode_) { if (expnd_mode_) {
MathParInset::draw(pain, x, baseline); MathParInset::draw(pain, x, baseline);
} } else {
else {
std::ostringstream ost; std::ostringstream ost;
ost << '#' << number_; ost << '#' << number_;
drawStr(pain, LM_TC_TEX, size, x, baseline, ost.str().c_str()); drawStr(pain, LM_TC_TEX, size(), x, baseline, ost.str().c_str());
} }
} }
@ -68,8 +67,8 @@ void MathMacroArgument::Metrics()
} else { } else {
std::ostringstream ost; std::ostringstream ost;
ost << '#' << number_; ost << '#' << number_;
width = mathed_string_width(LM_TC_TEX, size, ost.str().c_str()); width = mathed_string_width(LM_TC_TEX, size(), ost.str().c_str());
mathed_string_height(LM_TC_TEX, size, ost.str().c_str(), mathed_string_height(LM_TC_TEX, size(), ost.str().c_str(),
ascent, descent); ascent, descent);
} }
} }

View File

@ -10,34 +10,34 @@ using std::ostream;
void MathMacroTemplate::setTCode(MathedTextCodes t) void MathMacroTemplate::setTCode(MathedTextCodes t)
{ {
tcode = t; tcode_ = t;
} }
MathedTextCodes MathMacroTemplate::getTCode() const MathedTextCodes MathMacroTemplate::getTCode() const
{ {
return tcode; return tcode_;
} }
int MathMacroTemplate::getNoArgs() const int MathMacroTemplate::getNoArgs() const
{ {
return nargs; return nargs_;
} }
MathMacroTemplate::MathMacroTemplate(string const & nm, int na, int flg): MathMacroTemplate::MathMacroTemplate(string const & nm, int na, int flg):
MathParInset(LM_ST_TEXT, nm, LM_OT_MACRO), MathParInset(LM_ST_TEXT, nm, LM_OT_MACRO),
flags(flg), nargs(na) flags_(flg), nargs_(na)
{ {
if (nargs > 0) { if (nargs_ > 0) {
tcode = LM_TC_ACTIVE_INSET; tcode_ = LM_TC_ACTIVE_INSET;
args_.resize(nargs); args_.resize(nargs_);
for (int i = 0; i < nargs; ++i) { for (int i = 0; i < nargs_; ++i) {
args_[i].setNumber(i + 1); args_[i].setNumber(i + 1);
} }
} else { } else {
tcode = LM_TC_INSET; tcode_ = LM_TC_INSET;
// Here is nargs != args_.size() // Here is nargs != args_.size()
//args = 0; //args = 0;
} }
@ -47,7 +47,7 @@ MathMacroTemplate::MathMacroTemplate(string const & nm, int na, int flg):
MathMacroTemplate::~MathMacroTemplate() MathMacroTemplate::~MathMacroTemplate()
{ {
// prevent to delete already deleted objects // prevent to delete already deleted objects
for (int i = 0; i < nargs; ++i) { for (int i = 0; i < nargs_; ++i) {
args_[i].SetData(0); args_[i].SetData(0);
} }
} }
@ -56,14 +56,14 @@ MathMacroTemplate::~MathMacroTemplate()
void MathMacroTemplate::setEditMode(bool ed) void MathMacroTemplate::setEditMode(bool ed)
{ {
if (ed) { if (ed) {
flags |= MMF_Edit; flags_ |= MMF_Edit;
for (int i = 0; i < nargs; ++i) { for (int i = 0; i < nargs_; ++i) {
args_[i].setExpand(false); args_[i].setExpand(false);
} }
} }
else { else {
flags &= ~MMF_Edit; flags_ &= ~MMF_Edit;
for (int i = 0; i < nargs; ++i) { for (int i = 0; i < nargs_; ++i) {
args_[i].setExpand(true); args_[i].setExpand(true);
} }
} }
@ -72,23 +72,27 @@ void MathMacroTemplate::setEditMode(bool ed)
void MathMacroTemplate::draw(Painter & pain, int x, int y) void MathMacroTemplate::draw(Painter & pain, int x, int y)
{ {
int x2, y2; int x2;
bool expnd = (nargs > 0) ? args_[0].getExpand(): false; int y2;
if (flags & MMF_Edit) { bool expnd = (nargs_ > 0) ? args_[0].getExpand(): false;
for (int i = 0; i < nargs; ++i) { if (flags_ & MMF_Edit) {
for (int i = 0; i < nargs_; ++i) {
args_[i].setExpand(false); args_[i].setExpand(false);
} }
x2 = x; y2 = y; x2 = x;
y2 = y;
} else { } else {
for (int i = 0; i < nargs; ++i) { for (int i = 0; i < nargs_; ++i) {
args_[i].setExpand(true); args_[i].setExpand(true);
} }
x2 = xo; y2 = yo; x2 = xo();
y2 = yo();
} }
MathParInset::draw(pain, x, y); MathParInset::draw(pain, x, y);
xo = x2; yo = y2; xo(x2);
yo(y2);
for (int i = 0; i < nargs; ++i) { for (int i = 0; i < nargs_; ++i) {
args_[i].setExpand(expnd); args_[i].setExpand(expnd);
} }
} }
@ -96,20 +100,20 @@ void MathMacroTemplate::draw(Painter & pain, int x, int y)
void MathMacroTemplate::Metrics() void MathMacroTemplate::Metrics()
{ {
bool expnd = (nargs > 0) ? args_[0].getExpand(): false; bool expnd = (nargs_ > 0) ? args_[0].getExpand(): false;
if (flags & MMF_Edit) { if (flags_ & MMF_Edit) {
for (int i = 0; i < nargs; ++i) { for (int i = 0; i < nargs_; ++i) {
args_[i].setExpand(false); args_[i].setExpand(false);
} }
} else { } else {
for (int i = 0; i < nargs; ++i) { for (int i = 0; i < nargs_; ++i) {
args_[i].setExpand(true); args_[i].setExpand(true);
} }
} }
MathParInset::Metrics(); MathParInset::Metrics();
for (int i = 0; i < nargs; ++i) { for (int i = 0; i < nargs_; ++i) {
args_[i].setExpand(expnd); args_[i].setExpand(expnd);
} }
} }
@ -118,7 +122,7 @@ void MathMacroTemplate::Metrics()
void MathMacroTemplate::update(MathMacro * macro) void MathMacroTemplate::update(MathMacro * macro)
{ {
int idx = (macro) ? macro->getArgumentIdx() : 0; int idx = (macro) ? macro->getArgumentIdx() : 0;
for (int i = 0; i < nargs; ++i) { for (int i = 0; i < nargs_; ++i) {
if (macro) { if (macro) {
macro->setArgumentIdx(i); macro->setArgumentIdx(i);
args_[i].SetData(macro->GetData()); args_[i].SetData(macro->GetData());
@ -135,15 +139,15 @@ void MathMacroTemplate::WriteDef(ostream & os, bool fragile)
{ {
os << "\n\\newcommand{\\" << name << "}"; os << "\n\\newcommand{\\" << name << "}";
if (nargs > 0 ) if (nargs_ > 0 )
os << "[" << nargs << "]"; os << "[" << nargs_ << "]";
os << "{"; os << "{";
for (int i = 0; i < nargs; ++i) { for (int i = 0; i < nargs_; ++i) {
args_[i].setExpand(false); args_[i].setExpand(false);
} }
Write(os, fragile); Write(os, fragile);
os << "}\n"; os << "}\n";
} }
@ -162,7 +166,7 @@ void MathMacroTemplate::GetMacroXY(int i, int & x, int & y) const
MathParInset * MathMacroTemplate::getMacroPar(int i) const MathParInset * MathMacroTemplate::getMacroPar(int i) const
{ {
if (i >= 0 && i < nargs) if (i >= 0 && i < nargs_)
return const_cast<MathParInset *> return const_cast<MathParInset *>
(static_cast<MathParInset const *>(&args_[i])); (static_cast<MathParInset const *>(&args_[i]));
else else
@ -172,7 +176,7 @@ MathParInset * MathMacroTemplate::getMacroPar(int i) const
void MathMacroTemplate::SetMacroFocus(int &idx, int x, int y) void MathMacroTemplate::SetMacroFocus(int &idx, int x, int y)
{ {
for (int i = 0; i < nargs; ++i) { for (int i = 0; i < nargs_; ++i) {
if (args_[i].Inside(x, y)) { if (args_[i].Inside(x, y)) {
idx = i; idx = i;
break; break;

View File

@ -10,48 +10,50 @@
class MathMacro; class MathMacro;
/// This class contains the macro definition /// This class contains the macro definition
class MathMacroTemplate: public MathParInset { class MathMacroTemplate : public MathParInset {
public: public:
/// A template constructor needs all the data /// A template constructor needs all the data
explicit explicit
MathMacroTemplate(string const &, int na = 0, int f = 0); MathMacroTemplate(string const &, int na = 0, int f = 0);
/// ///
~MathMacroTemplate(); ~MathMacroTemplate();
/// ///
void draw(Painter &, int, int); void draw(Painter &, int, int);
/// ///
void Metrics(); void Metrics();
/// ///
void WriteDef(std::ostream &, bool fragile); void WriteDef(std::ostream &, bool fragile);
/// useful for special insets /// useful for special insets
void setTCode(MathedTextCodes t); void setTCode(MathedTextCodes t);
/// ///
MathedTextCodes getTCode() const; MathedTextCodes getTCode() const;
/// ///
void setArgument(MathedArray *, int i= 0); void setArgument(MathedArray *, int i= 0);
/// Number of arguments /// Number of arguments
int getNoArgs() const; int getNoArgs() const;
/// ///
void GetMacroXY(int, int &, int &) const; void GetMacroXY(int, int &, int &) const;
/// ///
MathParInset * getMacroPar(int) const; MathParInset * getMacroPar(int) const;
/// ///
void SetMacroFocus(int &, int, int); void SetMacroFocus(int &, int, int);
/// ///
void setEditMode(bool); void setEditMode(bool);
/// Replace the appropriate arguments with a specific macro's data /// Replace the appropriate arguments with a specific macro's data
void update(MathMacro * m = 0); void update(MathMacro * m = 0);
///
short flags() const {
return flags_;
}
private: private:
/// ///
short flags; short flags_;
/// ///
MathedTextCodes tcode; MathedTextCodes tcode_;
/// ///
std::vector<MathMacroArgument> args_; std::vector<MathMacroArgument> args_;
/// ///
int nargs; int nargs_;
///
friend class MathMacro;
}; };
#endif #endif

View File

@ -25,113 +25,125 @@
/// ///
enum SomeMathValues { enum SomeMathValues {
/// ///
MM_GREEK, MM_GREEK,
/// ///
MM_ARROW, MM_ARROW,
/// ///
MM_BOP, MM_BOP,
/// ///
MM_BRELATS, MM_BRELATS,
/// ///
MM_VARSIZE, MM_VARSIZE,
/// ///
MM_MISC, MM_MISC,
/// ///
MM_FRAC, MM_FRAC,
/// ///
MM_SQRT, MM_SQRT,
/// ///
MM_DELIM, MM_DELIM,
/// ///
MM_MATRIX, MM_MATRIX,
/// ///
MM_EQU, MM_EQU,
/// ///
MM_DECO, MM_DECO,
/// ///
MM_SPACE, MM_SPACE,
/// ///
MM_DOTS, MM_DOTS,
/// ///
MM_FUNC, MM_FUNC,
/// ///
MM_MAX, MM_MAX,
/// ///
MM_CLOSE = 1024, MM_CLOSE = 1024,
/// ///
MM_APPLY, MM_APPLY,
/// ///
MM_OK MM_OK
}; };
/// ///
/// Class to manage bitmap menu bars /// Class to manage bitmap menu bars
class BitmapMenu { class BitmapMenu {
/// ///
static BitmapMenu * active; static BitmapMenu * active;
/// ///
friend int peek_event(FL_FORM *, void *); friend int peek_event(FL_FORM *, void *);
/// ///
typedef std::vector<FL_OBJECT *> bitmaps_type; typedef std::vector<FL_OBJECT *> bitmaps_type;
/// ///
typedef bitmaps_type::size_type size_type; typedef bitmaps_type::size_type size_type;
/// ///
BitmapMenu * next, * prev; BitmapMenu * next, * prev;
/// Current bitmap /// Current bitmap
size_type current_; size_type current_;
/// Border width /// Border width
int ww; int ww;
/// ///
int x, y, w, h; int x;
/// ///
FL_FORM * form; int y;
/// ///
bitmaps_type bitmaps_; int w;
/// ///
FL_OBJECT * button; int h;
public: ///
/// FL_FORM * form;
BitmapMenu(int n, FL_OBJECT * bt, BitmapMenu * prevx= 0); ///
/// bitmaps_type bitmaps_;
~BitmapMenu(); ///
/// FL_OBJECT * button;
FL_OBJECT * AddBitmap(int id, public:
int nx, int ny, int bw, int bh, ///
unsigned char const * data, BitmapMenu(int n, FL_OBJECT * bt, BitmapMenu * prevx= 0);
Bool vert= True); // Why Bool? ///
/// ~BitmapMenu();
void Create(); ///
/// FL_OBJECT * AddBitmap(int id,
void Hide(); int nx, int ny, int bw, int bh,
/// unsigned char const * data,
void Show(); Bool vert = True); // Why Bool?
/// ///
void Prev(); void Create();
/// ///
void Next(); void Hide();
/// ///
int GetIndex(FL_OBJECT * ob); void Show();
///
void Prev();
///
void Next();
///
int GetIndex(FL_OBJECT * ob);
}; };
/// This is just a wrapper around peek_event() /// This is just a wrapper around peek_event()
extern "C" int C_peek_event(FL_FORM * form, void * ptr); extern "C" int C_peek_event(FL_FORM * form, void * ptr);
inline inline
void BitmapMenu::Prev() { void BitmapMenu::Prev()
Hide(); {
if (prev) Hide();
prev->Show(); if (prev)
prev->Show();
} }
inline inline
void BitmapMenu::Next() { void BitmapMenu::Next()
Hide(); {
if (next) Hide();
next->Show(); if (next)
next->Show();
} }
#include "math_forms.h" #include "math_forms.h"
/// ///

View File

@ -85,10 +85,12 @@ MathParInset::draw(Painter & pain, int x, int y)
{ {
byte cxp = 0; byte cxp = 0;
int xp = 0; int xp = 0;
int asc = df_asc, des = 0; int asc = df_asc;
int des = 0;
bool limits = false; bool limits = false;
xo = x; yo = y; xo_ = x;
yo_ = y;
if (!array || array->empty()) { if (!array || array->empty()) {
if (array) { if (array) {
MathedXIter data(this); MathedXIter data(this);
@ -104,8 +106,8 @@ MathParInset::draw(Painter & pain, int x, int y)
byte cx = data.GetChar(); byte cx = data.GetChar();
if (cx >= ' ') { if (cx >= ' ') {
string s = data.GetString(); string s = data.GetString();
drawStr(pain, data.FCode(), size, x, y, s); drawStr(pain, data.FCode(), size(), x, y, s);
mathed_char_height(LM_TC_CONST, size, 'y', asc, des); mathed_char_height(LM_TC_CONST, size(), 'y', asc, des);
limits = false; limits = false;
} }
else { else {
@ -195,15 +197,16 @@ MathParInset::Metrics()
cx = data.GetChar(); cx = data.GetChar();
if (cx >= ' ') { if (cx >= ' ') {
string s = data.GetString(); string s = data.GetString();
mathed_string_height(data.FCode(), size, s, asc, des); mathed_string_height(data.FCode(),
size(), s, asc, des);
if (asc > ascent) ascent = asc; if (asc > ascent) ascent = asc;
if (des > descent) descent = des; if (des > descent) descent = des;
limits = false; limits = false;
mathed_char_height(LM_TC_CONST, size, 'y', asc, des); mathed_char_height(LM_TC_CONST, size(), 'y', asc, des);
} else } else
if (MathIsInset(cx)) { if (MathIsInset(cx)) {
MathedInset * p = data.GetInset(); MathedInset * p = data.GetInset();
p->SetStyle(size); p->SetStyle(size());
p->Metrics(); p->Metrics();
if (cx == LM_TC_UP) { if (cx == LM_TC_UP) {
asc += (limits) ? p->Height() + 4: p->Ascent() + asc += (limits) ? p->Height() + 4: p->Ascent() +
@ -290,7 +293,7 @@ void MathParInset::Write(ostream & os, bool fragile)
data.Reset(); data.Reset();
if (!Permit(LMPF_FIXED_SIZE)) { if (!Permit(LMPF_FIXED_SIZE)) {
l = lm_get_key_by_id(size, LM_TK_STY); l = lm_get_key_by_id(size(), LM_TK_STY);
if (l) { if (l) {
os << '\\' << l->name << ' '; os << '\\' << l->name << ' ';
} }
@ -397,22 +400,22 @@ void MathParInset::Write(ostream & os, bool fragile)
bool MathParInset::Inside(int x, int y) bool MathParInset::Inside(int x, int y)
{ {
return (x >= xo && x <= xo + width return (x >= xo() && x <= xo() + width
&& y <= yo + descent && y >= yo - ascent); && y <= yo() + descent && y >= yo() - ascent);
} }
void MathParInset::GetXY(int & x, int & y) const void MathParInset::GetXY(int & x, int & y) const
{ {
x = xo; x = xo();
y = yo; y = yo();
} }
void MathParInset::UserSetSize(short sz) void MathParInset::UserSetSize(short sz)
{ {
if (sz >= 0) { if (sz >= 0) {
size = sz; size(sz);
flag = flag & ~LMPF_FIXED_SIZE; flag = flag & ~LMPF_FIXED_SIZE;
} }
} }
@ -431,12 +434,6 @@ void MathParInset::SetStyle(short sz)
} }
void MathParInset::setFlag(MathedParFlag f)
{
flag |= f;
}
bool MathParInset::Permit(short f) const bool MathParInset::Permit(short f) const
{ {
return bool(f & flag); return bool(f & flag);
@ -451,6 +448,6 @@ MathedArray * MathParInset::GetData()
void MathParInset::setXY(int x, int y) void MathParInset::setXY(int x, int y)
{ {
xo = x; xo_ = x;
yo = y; yo_ = y;
} }

View File

@ -11,86 +11,88 @@ class MathedArray;
/** The math paragraph base class, base to all editable math objects */ /** The math paragraph base class, base to all editable math objects */
class MathParInset: public MathedInset { class MathParInset: public MathedInset {
public: public:
/// ///
MathParInset(short st = LM_ST_TEXT, string const & nm = string(), MathParInset(short st = LM_ST_TEXT, string const & nm = string(),
short ot = LM_OT_MIN); short ot = LM_OT_MIN);
/// ///
explicit explicit
MathParInset(MathParInset *); MathParInset(MathParInset *);
/// ///
virtual ~MathParInset(); virtual ~MathParInset();
/// ///
virtual MathedInset * Clone(); virtual MathedInset * Clone();
/// Draw the object on a drawable /// Draw the object on a drawable
virtual void draw(Painter &, int x, int baseline); virtual void draw(Painter &, int x, int baseline);
/// Write LaTeX code /// Write LaTeX code
virtual void Write(std::ostream &, bool fragile); virtual void Write(std::ostream &, bool fragile);
/// ///
virtual void Metrics(); virtual void Metrics();
/// ///
virtual void UserSetSize(short); virtual void UserSetSize(short);
/// Data is stored in a LyXArray /// Data is stored in a LyXArray
virtual void SetData(MathedArray *); virtual void SetData(MathedArray *);
/// ///
virtual MathedArray * GetData(); virtual MathedArray * GetData();
/// Paragraph position /// Paragraph position
virtual void GetXY(int &, int &) const; virtual void GetXY(int &, int &) const;
/// ///
virtual void setXY(int x, int y); virtual void setXY(int x, int y);
/// ///
virtual void SetFocus(int, int) {} virtual void SetFocus(int, int) {}
/// ///
virtual bool Inside(int, int); virtual bool Inside(int, int);
// Tab stuff used by Matrix. // Tab stuff used by Matrix.
/// ///
virtual void SetAlign(char, string const &) {} virtual void SetAlign(char, string const &) {}
/// ///
virtual int GetColumns() const { return 1; } virtual int GetColumns() const { return 1; }
/// ///
virtual int GetRows() const { return 1; } virtual int GetRows() const { return 1; }
/// ///
virtual bool isMatrix() const { return false; } virtual bool isMatrix() const { return false; }
// Vertical switching // Vertical switching
/// ///
virtual bool setArgumentIdx(int i) { return (i == 0); } virtual bool setArgumentIdx(int i) { return (i == 0); }
/// ///
virtual bool setNextArgIdx() { return false; } virtual bool setNextArgIdx() { return false; }
/// ///
virtual int getArgumentIdx() const { return 0; } virtual int getArgumentIdx() const { return 0; }
/// ///
virtual int getMaxArgumentIdx() const { return 0; } virtual int getMaxArgumentIdx() const { return 0; }
/// ///
virtual void SetStyle(short); virtual void SetStyle(short);
/// ///
virtual MathedRowSt * getRowSt() const; virtual MathedRowSt * getRowSt() const;
/// ///
virtual void setRowSt(MathedRowSt *) {} virtual void setRowSt(MathedRowSt *) {}
/// ///
virtual bool Permit(short f) const; virtual bool Permit(short f) const;
protected: ///
/// Paragraph data is stored here int xo() const {
MathedArray * array; return xo_;
/// Cursor start position }
int xo; ///
/// int yo() const {
int yo; return yo_;
/// }
short flag; protected:
private: /// Paragraph data is stored here
/// MathedArray * array;
virtual void setFlag(MathedParFlag f); ///
/// short flag;
friend class InsetFormula; ///
/// void xo(int tx) {
friend class MathedXIter; xo_ = tx;
/// }
friend class MathedCursor; ///
/// void yo(int ty) {
friend MathedArray * mathed_parse(unsigned flags = 0, yo_ = ty;
MathedArray * a = 0, }
MathParInset ** p = 0); private:
/// Cursor start position
int xo_;
///
int yo_;
}; };
#endif #endif

View File

@ -390,8 +390,8 @@ MathedInset * doAccent(MathedInset * p)
} }
MathedArray * mathed_parse(unsigned flags, MathedArray * array, MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
MathParInset ** mtx) MathParInset ** mtx = 0)
{ {
int t = yylex(); int t = yylex();
int tprev = 0; int tprev = 0;

View File

@ -28,113 +28,113 @@ using std::ostream;
MathRootInset::MathRootInset(short st) MathRootInset::MathRootInset(short st)
: MathSqrtInset(st) : MathSqrtInset(st)
{ {
idx = 1; idx = 1;
uroot = new MathParInset(LM_ST_TEXT); uroot = new MathParInset(LM_ST_TEXT);
} }
MathRootInset::~MathRootInset() MathRootInset::~MathRootInset()
{ {
delete uroot; delete uroot;
} }
MathedInset * MathRootInset::Clone() MathedInset * MathRootInset::Clone()
{ {
MathRootInset * p = new MathRootInset(GetStyle()); MathRootInset * p = new MathRootInset(GetStyle());
MathedIter it(array), itr(uroot->GetData()); MathedIter it(array), itr(uroot->GetData());
p->SetData(it.Copy()); p->SetData(it.Copy());
p->setArgumentIdx(0); p->setArgumentIdx(0);
p->SetData(itr.Copy()); p->SetData(itr.Copy());
return p; return p;
} }
void MathRootInset::SetData(MathedArray * d) void MathRootInset::SetData(MathedArray * d)
{ {
if (idx == 1) if (idx == 1)
MathParInset::SetData(d); MathParInset::SetData(d);
else { else {
uroot->SetData(d); uroot->SetData(d);
} }
} }
bool MathRootInset::setArgumentIdx(int i) bool MathRootInset::setArgumentIdx(int i)
{ {
if (i == 0 || i == 1) { if (i == 0 || i == 1) {
idx = i; idx = i;
return true; return true;
} else } else
return false; return false;
} }
void MathRootInset::GetXY(int & x, int & y) const void MathRootInset::GetXY(int & x, int & y) const
{ {
if (idx == 1) if (idx == 1)
MathParInset::GetXY(x, y); MathParInset::GetXY(x, y);
else else
uroot->GetXY(x, y); uroot->GetXY(x, y);
} }
MathedArray * MathRootInset::GetData() MathedArray * MathRootInset::GetData()
{ {
if (idx == 1) if (idx == 1)
return array; return array;
else else
return uroot->GetData(); return uroot->GetData();
} }
bool MathRootInset::Inside(int x, int y) bool MathRootInset::Inside(int x, int y)
{ {
return (uroot->Inside(x, y) || MathSqrtInset::Inside(x, y)); return (uroot->Inside(x, y) || MathSqrtInset::Inside(x, y));
} }
void MathRootInset::Metrics() void MathRootInset::Metrics()
{ {
int idxp = idx; int idxp = idx;
idx = 1; idx = 1;
MathSqrtInset::Metrics(); MathSqrtInset::Metrics();
uroot->Metrics(); uroot->Metrics();
wroot = uroot->Width(); wroot = uroot->Width();
dh = Height()/2; dh = Height()/2;
width += wroot; width += wroot;
// if (uroot->Ascent() > dh) // if (uroot->Ascent() > dh)
if (uroot->Height() > dh) if (uroot->Height() > dh)
ascent += uroot->Height() - dh; ascent += uroot->Height() - dh;
dh -= descent - uroot->Descent(); dh -= descent - uroot->Descent();
idx = idxp; idx = idxp;
} }
void MathRootInset::draw(Painter & pain, int x, int y) void MathRootInset::draw(Painter & pain, int x, int y)
{ {
int idxp = idx; int idxp = idx;
idx = 1; idx = 1;
uroot->draw(pain, x, y - dh); uroot->draw(pain, x, y - dh);
MathSqrtInset::draw(pain, x + wroot, y); MathSqrtInset::draw(pain, x + wroot, y);
idx = idxp; idx = idxp;
} }
void MathRootInset::SetStyle(short st) void MathRootInset::SetStyle(short st)
{ {
MathSqrtInset::SetStyle(st); MathSqrtInset::SetStyle(st);
uroot->SetStyle((size<LM_ST_SCRIPTSCRIPT) ? size+1: size); uroot->SetStyle((size() < LM_ST_SCRIPTSCRIPT) ? size() + 1 : size());
} }
void MathRootInset::SetFocus(int x, int) void MathRootInset::SetFocus(int x, int)
{ {
idx = (x > xo + wroot) ? 1: 0; idx = (x > xo() + wroot) ? 1: 0;
} }

View File

@ -24,10 +24,10 @@ MathedInset * MathSqrtInset::Clone()
bool MathSqrtInset::Inside(int x, int y) bool MathSqrtInset::Inside(int x, int y)
{ {
return x >= xo - hmax return x >= xo() - hmax
&& x <= xo + width - hmax && x <= xo() + width - hmax
&& y <= yo + descent && y <= yo() + descent
&& y >= yo - ascent; && y >= yo() - ascent;
} }
@ -55,7 +55,7 @@ MathSqrtInset::Metrics()
ascent += 4; ascent += 4;
descent += 2; descent += 2;
int a, b; int a, b;
hmax = mathed_char_height(LM_TC_VAR, size, 'I', a, b); hmax = mathed_char_height(LM_TC_VAR, size(), 'I', a, b);
if (hmax < 10) hmax = 10; if (hmax < 10) hmax = 10;
wbody = width + 4; wbody = width + 4;
width += hmax + 4; width += hmax + 4;

View File

@ -103,7 +103,6 @@ protected:
/// ///
MathedRowSt * crow; MathedRowSt * crow;
private:
/// ///
friend class MathedCursor; friend class MathedCursor;
}; };

View File

@ -4,57 +4,55 @@
#include "matriz.h" #include "matriz.h"
inline static inline
int odd(int x) { return ((x) & 1); } int odd(int x) { return ((x) & 1); }
typedef float matriz_data[2][2];
const matriz_data MATIDEN= { {1, 0}, {0, 1}};
#define mateq(m1, m2) memcpy(m1, m2, sizeof(matriz_data)) #define mateq(m1, m2) memcpy(m1, m2, sizeof(matriz_data))
Matriz::matriz_data const Matriz::MATIDEN = { {1, 0}, {0, 1}};
Matriz::Matriz() Matriz::Matriz()
{ {
mateq(m, MATIDEN); mateq(m_, MATIDEN);
} }
void Matriz::rota(int code) void Matriz::rota(int code)
{ {
float cs, sn; matriz_data r;
mateq(r, MATIDEN);
matriz_data r; float const cs = (odd(code)) ? 0 : (1 - code);
mateq(r, MATIDEN); float const sn = (odd(code)) ? (2 - code) : 0;
cs = (odd(code)) ? 0: 1 - code; r[0][0] = cs; r[0][1] = sn;
sn = (odd(code)) ? 2 - code: 0; r[1][0] = -r[0][1]; r[1][1] = r[0][0];
r[0][0] = cs; r[0][1] = sn; matmat(r);
r[1][0] = -r[0][1]; r[1][1] = r[0][0];
matmat(r);
} }
void Matriz::escala(float x, float y) void Matriz::escala(float x, float y)
{ {
matriz_data s; matriz_data s;
mateq(s, MATIDEN); mateq(s, MATIDEN);
s[0][0] = x; s[1][1] = y; s[0][0] = x; s[1][1] = y;
matmat(s); matmat(s);
} }
void Matriz::matmat(matriz_data & a) void Matriz::matmat(matriz_data & a)
{ {
matriz_data c; matriz_data c;
for (int i = 0;i < 2; ++i) { for (int i = 0; i < 2; ++i) {
c[0][i] = a[0][0] * m[0][i] + a[0][1] * m[1][i]; c[0][i] = a[0][0] * m_[0][i] + a[0][1] * m_[1][i];
c[1][i] = a[1][0] * m[0][i] + a[1][1] * m[1][i]; c[1][i] = a[1][0] * m_[0][i] + a[1][1] * m_[1][i];
} }
mateq(m, c); mateq(m_, c);
} }
void Matriz::transf(float xp, float yp, float & x, float & y) void Matriz::transf(float xp, float yp, float & x, float & y)
{ {
x = m[0][0] * xp + m[0][1] * yp; x = m_[0][0] * xp + m_[0][1] * yp;
y = m[1][0] * xp + m[1][1] * yp; y = m_[1][0] * xp + m_[1][1] * yp;
} }

View File

@ -3,17 +3,26 @@
#ifndef MATH_MATRIZ_H #ifndef MATH_MATRIZ_H
#define MATH_MATRIZ_H #define MATH_MATRIZ_H
typedef float matriz_data[2][2]; ///
class Matriz { class Matriz {
public: public:
Matriz(); ///
void rota(int); typedef float matriz_data[2][2];
void escala(float, float); ///
void transf(float, float, float &, float &); Matriz();
protected: ///
matriz_data m; void rota(int);
void matmat(matriz_data & a); ///
void escala(float, float);
///
void transf(float, float, float &, float &);
private:
///
matriz_data m_;
///
void matmat(matriz_data & a);
///
static matriz_data const MATIDEN;
}; };
#endif #endif

View File

@ -376,7 +376,7 @@ void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code)
mt.rota(r); mt.rota(r);
mt.escala(w, h); mt.escala(w, h);
int n = (w < h) ? w: h; int n = (w < h) ? w : h;
sqmt.rota(r); sqmt.rota(r);
sqmt.escala(n, n); sqmt.escala(n, n);
if (r > 0 && r < 3) y += h; if (r > 0 && r < 3) y += h;