small mathed change add the find_if

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1632 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-02-27 11:26:18 +00:00
parent 4541e746fe
commit d559de976f
6 changed files with 62 additions and 43 deletions

View File

@ -63,6 +63,7 @@ extern int greek_kb_flag;
using SigC::slot; using SigC::slot;
#endif #endif
using std::find_if;
using std::pair; using std::pair;
using std::endl; using std::endl;
using std::make_pair; using std::make_pair;

View File

@ -1,3 +1,7 @@
2001-02-27 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
* BufferView_pimpl.C: add using std::find_if
2001-02-27 José Matos <jamatos@fep.up.pt> 2001-02-27 José Matos <jamatos@fep.up.pt>
* LaTeXFeatures.C (getIncludedFiles): call to BasePath replaced * LaTeXFeatures.C (getIncludedFiles): call to BasePath replaced

View File

@ -1,3 +1,11 @@
2001-02-27 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
* math_parinset.C (draw): move MathedXiter data(this) up. and
remove it two other places.
* math_macro.C (MathMacro): use array directly, don't use
setArgumentIdx and GetData
2001-02-26 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com> 2001-02-26 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
* math_macroarg.C (MathMacroArgument): delete * math_macroarg.C (MathMacroArgument): delete

View File

@ -44,8 +44,8 @@ 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();
@ -58,8 +58,8 @@ MathMacro::MathMacro(MathMacroTemplate * t):
} }
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();
@ -68,9 +68,10 @@ MathMacro::MathMacro(MathMacro * m):
idx_ = 0; idx_ = 0;
SetName(tmplate_->GetName()); SetName(tmplate_->GetName());
for (int i = 0; i < tmplate_->getNoArgs(); ++i) { for (int i = 0; i < tmplate_->getNoArgs(); ++i) {
m->setArgumentIdx(i); //m->setArgumentIdx(i);
args_[i].row = m->args_[i].row; args_[i].row = m->args_[i].row;
args_[i].array = m->GetData(); //args_[i].array = m->GetData();
args_[i].array = m->args_[i].array;
} }
} }

View File

@ -59,8 +59,7 @@ void MathMacroTemplate::setEditMode(bool ed)
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);
@ -73,7 +72,7 @@ void MathMacroTemplate::draw(Painter & pain, int x, int y)
{ {
int x2; int x2;
int y2; int y2;
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);
@ -99,7 +98,7 @@ 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) {

View File

@ -35,6 +35,7 @@ MathParInset::MathParInset(short st, string const & nm, short ot)
} }
// This is virtual and needed.
MathParInset::~MathParInset() MathParInset::~MathParInset()
{ {
} }
@ -72,25 +73,26 @@ MathParInset::draw(Painter & pain, int x, int y)
bool limits = false; bool limits = false;
xo_ = x; xo_ = x;
yo_ = y; yo_ = y;
if (array.empty()) {
MathedXIter data(this);
data.GetPos(x, y);
pain.rectangle(x, y - df_asc, df_width, df_asc, LColor::mathline);
return;
}
MathedXIter data(this); MathedXIter data(this);
if (array.empty()) {
//MathedXIter data(this);
data.GetPos(x, y);
pain.rectangle(x, y - df_asc, df_width, df_asc,
LColor::mathline);
return;
}
//MathedXIter data(this);
data.GoBegin(); data.GoBegin();
while (data.OK()) { while (data.OK()) {
data.GetPos(x, y); data.GetPos(x, y);
byte cx = data.GetChar(); byte cx = data.GetChar();
if (cx >= ' ') { if (cx >= ' ') {
string s = data.GetString(); string const 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 {
if (cx == 0) if (cx == 0)
break; break;
if (MathIsInset(cx)) { if (MathIsInset(cx)) {
@ -98,46 +100,49 @@ MathParInset::draw(Painter & pain, int x, int y)
MathedInset * p = data.GetInset(); MathedInset * p = data.GetInset();
if (cx == LM_TC_UP) { if (cx == LM_TC_UP) {
if (limits) { if (limits) {
x -= (xp>p->Width()) ? p->Width()+(xp-p->Width())/2: xp; x -= (xp > p->Width()) ?
yy -= (asc + p->Descent()+4); p->Width() + (xp - p->Width()) / 2 : xp;
} yy -= (asc + p->Descent() + 4);
else } else
yy -= (p->Descent()>asc) ? p->Descent()+4: asc; yy -= (p->Descent() > asc) ?
} p->Descent() + 4 : asc;
else if (cx == LM_TC_DOWN) { } else if (cx == LM_TC_DOWN) {
if (limits) { if (limits) {
x -= (xp>p->Width()) ? p->Width()+(xp-p->Width())/2: xp; x -= (xp > p->Width()) ?
p->Width() + (xp - p->Width()) / 2 : xp;
yy += des + p->Ascent() + 2; yy += des + p->Ascent() + 2;
} else } else
yy += des + p->Ascent()/2; yy += des + p->Ascent() / 2;
} } else {
else {
asc = p->Ascent(); asc = p->Ascent();
des = p->Descent(); des = p->Descent();
} }
p->draw(pain, x, yy); p->draw(pain, x, yy);
if (cx!= LM_TC_UP && cx!= LM_TC_DOWN) { if (cx != LM_TC_UP && cx != LM_TC_DOWN) {
limits = p->GetLimits(); limits = p->GetLimits();
if (limits) if (limits)
xp = p->Width(); xp = p->Width();
} }
data.Next(); data.Next();
} } else if (cx == LM_TC_TAB) {
else if (cx == LM_TC_TAB) { if (cxp == cx
if (cxp == cx || cxp == LM_TC_CR || data.IsFirst()) { || cxp == LM_TC_CR || data.IsFirst()) {
pain.rectangle(x, y - df_asc, df_width, df_asc, LColor::mathline); pain.rectangle(x, y - df_asc,
df_width, df_asc,
LColor::mathline);
} }
data.Next(); data.Next();
limits = false; limits = false;
} } else if (cx == LM_TC_CR) {
else if (cx == LM_TC_CR) { if (cxp == LM_TC_TAB
if (cxp == LM_TC_TAB || cxp == LM_TC_CR || data.IsFirst()) { || cxp == LM_TC_CR || data.IsFirst()) {
pain.rectangle(x, y - df_asc, df_width, df_asc, LColor::mathline); pain.rectangle(x, y - df_asc,
df_width, df_asc,
LColor::mathline);
} }
data.Next(); data.Next();
limits = false; limits = false;
} } else {
else {
lyxerr << "GMathed Error: Unrecognized code[" << cx << "]" << endl; lyxerr << "GMathed Error: Unrecognized code[" << cx << "]" << endl;
break; break;
} }
@ -146,7 +151,8 @@ MathParInset::draw(Painter & pain, int x, int y)
} }
if (cxp == LM_TC_TAB || cxp == LM_TC_CR) { if (cxp == LM_TC_TAB || cxp == LM_TC_CR) {
data.GetPos(x, y); data.GetPos(x, y);
pain.rectangle(x, y - df_asc, df_width, df_asc, LColor::mathline); pain.rectangle(x, y - df_asc, df_width, df_asc,
LColor::mathline);
} }
} }