Various fixes and some "missing features" from Dekels Mail in insettext/

tabular fixe.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1052 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2000-09-28 14:05:24 +00:00
parent 87a0dbbbe0
commit 74a46e0474
19 changed files with 212 additions and 148 deletions

View File

@ -1,3 +1,21 @@
2000-09-28 Juergen Vigna <jug@sad.it>
* src/insets/insettabular.C (update): fixed cursor setting when
the_locking_inset changed.
(draw): made this a bit cleaner.
* various files: added LyXText Parameter to fitCursor call.
* src/BufferView.C (fitCursor): added LyXText parameter.
* src/insets/insettabular.C (draw): small draw fix.
* src/tabular.C: right setting of left/right celllines.
* src/tabular.[Ch]: fixed various types in funcions and structures.
* src/insets/insettabular.C: ditto
* src/frontends/xforms/FormTabular.C: ditto
2000-09-28 Allan Rae <rae@lyx.org> 2000-09-28 Allan Rae <rae@lyx.org>
* src/paragraph.C (TeXOnePar): fixed output of '\n'. The problem was * src/paragraph.C (TeXOnePar): fixed output of '\n'. The problem was

View File

@ -99,9 +99,9 @@ void BufferView::redraw()
} }
void BufferView::fitCursor() void BufferView::fitCursor(LyXText * text)
{ {
pimpl_->fitCursor(); pimpl_->fitCursor(text);
} }

View File

@ -63,7 +63,7 @@ public:
/// ///
void redraw(); void redraw();
/// ///
void fitCursor(); void fitCursor(LyXText *);
/// ///
void update(); void update();
// //

View File

@ -203,9 +203,8 @@ bool BufferView::insertInset(Inset * inset, string const & lout,
// if we are in a locking inset we should try to insert the // if we are in a locking inset we should try to insert the
// inset there otherwise this is a illegal function now // inset there otherwise this is a illegal function now
if (the_locking_inset) { if (the_locking_inset) {
if (the_locking_inset->InsertInsetAllowed(inset) && if (the_locking_inset->InsertInsetAllowed(inset))
the_locking_inset->InsertInset(this, inset)) return the_locking_inset->InsertInset(this, inset);
return true;
return false; return false;
} }
@ -252,19 +251,6 @@ bool BufferView::insertInset(Inset * inset, string const & lout,
} }
text->InsertInset(this, inset); text->InsertInset(this, inset);
#if 1
// if we enter a text-inset the cursor should be to the left side
// of it! This couldn't happen before as Undo was not handled inside
// inset now after the Undo LyX tries to call inset->Edit(...) again
// and cannot do this as the cursor is behind the inset and GetInset
// does not return the inset!
if (inset->IsTextInset()) {
if (text->cursor.par()->isRightToLeftPar(buffer()->params))
text->CursorRight(this);
else
text->CursorLeft(this);
}
#endif
update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
text->UnFreezeUndo(); text->UnFreezeUndo();
@ -394,8 +380,7 @@ void BufferView::allFloats(char flag, char figmar)
text->SetCursorIntern(this, cursor.par(), cursor.pos()); text->SetCursorIntern(this, cursor.par(), cursor.pos());
redraw(); redraw();
fitCursor(); fitCursor(text);
//updateScrollbar();
} }
#endif #endif

View File

@ -208,12 +208,13 @@ void BufferView::Pimpl::redraw()
} }
bool BufferView::Pimpl::fitCursor() bool BufferView::Pimpl::fitCursor(LyXText * text)
{ {
Assert(screen_); // it is a programming error to call fitCursor Assert(screen_); // it is a programming error to call fitCursor
// without a valid screen. // without a valid screen.
bool ret = screen_->FitCursor(bv_->text); bool ret = screen_->FitCursor(text);
if (ret) updateScrollbar(); if (ret)
updateScrollbar();
return ret; return ret;
} }
@ -541,7 +542,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
bv_->text->SetSelection(); bv_->text->SetSelection();
screen_->ToggleToggle(bv_->text); screen_->ToggleToggle(bv_->text);
fitCursor(); fitCursor(bv_->text);
screen_->ShowCursor(bv_->text); screen_->ShowCursor(bv_->text);
} }
return; return;
@ -634,7 +635,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
bv_->text->cursor.x_fix(bv_->text->cursor.x()); bv_->text->cursor.x_fix(bv_->text->cursor.x());
owner_->updateLayoutChoice(); owner_->updateLayoutChoice();
if (fitCursor()) { if (fitCursor(bv_->text)) {
selection_possible = false; selection_possible = false;
} }
@ -976,7 +977,7 @@ void BufferView::Pimpl::workAreaExpose()
// fitCursor() ensures we don't jump back // fitCursor() ensures we don't jump back
// to the start of the document on vertical // to the start of the document on vertical
// resize // resize
fitCursor(); fitCursor(bv_->text);
// The main window size has changed, repaint most stuff // The main window size has changed, repaint most stuff
redraw(); redraw();
@ -1052,7 +1053,7 @@ void BufferView::Pimpl::update(BufferView::UpdateCodes f)
update(); update();
if ((f & FITCUR)) { if ((f & FITCUR)) {
fitCursor(); fitCursor(bv_->text);
} }
if ((f & CHANGE)) { if ((f & CHANGE)) {

View File

@ -36,7 +36,7 @@ struct BufferView::Pimpl : public Object {
/// ///
void redraw(); void redraw();
/// Return true if the cursor was fitted. /// Return true if the cursor was fitted.
bool fitCursor(); bool fitCursor(LyXText *);
/// ///
void redoCurrentBuffer(); void redoCurrentBuffer();
/// ///

View File

@ -3386,7 +3386,7 @@ int Buffer::runLiterate()
// error insets after we ran LaTeX this must be run: // error insets after we ran LaTeX this must be run:
if (removedErrorInsets || (res & Literate::ERRORS)){ if (removedErrorInsets || (res & Literate::ERRORS)){
users->redraw(); users->redraw();
users->fitCursor(); users->fitCursor(users->text);
//users->updateScrollbar(); //users->updateScrollbar();
} }
AllowInput(users); AllowInput(users);
@ -3457,7 +3457,7 @@ int Buffer::buildProgram()
// must be run: // must be run:
if (removedErrorInsets || (res & Literate::ERRORS)){ if (removedErrorInsets || (res & Literate::ERRORS)){
users->redraw(); users->redraw();
users->fitCursor(); users->fitCursor(users->text);
//users->updateScrollbar(); //users->updateScrollbar();
} }
AllowInput(users); AllowInput(users);
@ -3509,8 +3509,7 @@ int Buffer::runChktex()
// error insets after we ran chktex, this must be run: // error insets after we ran chktex, this must be run:
if (removedErrorInsets || res){ if (removedErrorInsets || res){
users->redraw(); users->redraw();
users->fitCursor(); users->fitCursor(users->text);
//users->updateScrollbar();
} }
AllowInput(users); AllowInput(users);

View File

@ -106,7 +106,7 @@ public:
/// ///
void redraw() { void redraw() {
users->redraw(); users->redraw();
users->fitCursor(); users->fitCursor(users->text);
//users->updateScrollbar(); //users->updateScrollbar();
} }

View File

@ -462,8 +462,7 @@ bool Converter::runLaTeX(Buffer * buffer, string const & command)
// error insets after we ran LaTeX this must be run: // error insets after we ran LaTeX this must be run:
if (a || (result & LaTeX::ERRORS)){ if (a || (result & LaTeX::ERRORS)){
bv->redraw(); bv->redraw();
bv->fitCursor(); bv->fitCursor(bv->text);
//bv->updateScrollbar();
} }
// check return value from latex.run(). // check return value from latex.run().

View File

@ -490,8 +490,9 @@ void FormTabular::SetTabularOptions(FL_OBJECT * ob, long)
* tabular = inset_->tabular; * tabular = inset_->tabular;
int int
cell, cell,
s, s;
num = 0; LyXTabular::Feature
num = LyXTabular::LAST_ACTION;
string string
special, special,
str; str;

View File

@ -57,8 +57,7 @@ void InsetLabel::Edit(BufferView * bv, int, int, unsigned int)
bv->text->RedoParagraph(bv); bv->text->RedoParagraph(bv);
if (flag) { if (flag) {
bv->redraw(); bv->redraw();
bv->fitCursor(); bv->fitCursor(getLyXText(bv));
//bv->updateScrollbar();
} else } else
bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
} }

View File

@ -53,7 +53,7 @@ using std::swap;
struct tabular_features { struct tabular_features {
int action; LyXTabular::Feature action;
string feature; string feature;
}; };
@ -85,7 +85,6 @@ static tabular_features tabularFeatures[] =
{ LyXTabular::M_VALIGN_TOP, "m-valign-top" }, { LyXTabular::M_VALIGN_TOP, "m-valign-top" },
{ LyXTabular::M_VALIGN_BOTTOM, "m-valign-bottom" }, { LyXTabular::M_VALIGN_BOTTOM, "m-valign-bottom" },
{ LyXTabular::M_VALIGN_CENTER, "m-valign-center" }, { LyXTabular::M_VALIGN_CENTER, "m-valign-center" },
{ LyXTabular::DELETE_TABULAR, "delete-tabular" },
{ LyXTabular::MULTICOLUMN, "multicolumn" }, { LyXTabular::MULTICOLUMN, "multicolumn" },
{ LyXTabular::SET_ALL_LINES, "set-all-lines" }, { LyXTabular::SET_ALL_LINES, "set-all-lines" },
{ LyXTabular::UNSET_ALL_LINES, "unset-all-lines" }, { LyXTabular::UNSET_ALL_LINES, "unset-all-lines" },
@ -255,19 +254,45 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
return; return;
bool dodraw; bool dodraw;
x += ADD_TO_TABULAR_WIDTH; x += ADD_TO_TABULAR_WIDTH;
if (cleared || (need_update == FULL) || (need_update == CELL)) { if (cleared) {
for(i = 0; i < tabular->rows(); ++i) { for(i = 0; i < tabular->rows(); ++i) {
nx = int(x); nx = int(x);
dodraw = ((baseline + tabular->GetDescentOfRow(i)) > 0) && dodraw = ((baseline + tabular->GetDescentOfRow(i)) > 0) &&
(baseline - tabular->GetAscentOfRow(i)) < pain.paperHeight(); (baseline - tabular->GetAscentOfRow(i))<pain.paperHeight();
for(j = 0; j < tabular->columns(); ++j) { for(j = 0; j < tabular->columns(); ++j) {
if (tabular->IsPartOfMultiColumn(i, j)) if (tabular->IsPartOfMultiColumn(i, j))
continue; continue;
cx = nx + tabular->GetBeginningOfTextInCell(cell); cx = nx + tabular->GetBeginningOfTextInCell(cell);
if (dodraw) {
if (hasSelection()) if (hasSelection())
DrawCellSelection(pain, nx, baseline, i, j, cell); DrawCellSelection(pain, nx, baseline, i, j, cell);
if (dodraw && !cleared && locked && the_locking_inset) { tabular->GetCellInset(cell)->draw(bv, font, baseline, cx,
cleared);
DrawCellLines(pain, nx, baseline, i, cell);
}
nx += tabular->GetWidthOfColumn(cell);
++cell;
}
baseline += tabular->GetDescentOfRow(i) +
tabular->GetAscentOfRow(i + 1) +
tabular->GetAdditionalHeight(cell);
}
} else if (need_update == CELL) {
nx = int(x);
for(i = 0; (cell < actcell) && (i < tabular->rows()); ++i) {
nx = int(x);
for(j = 0; (cell < actcell) && (j < tabular->columns()); ++j) {
if (tabular->IsPartOfMultiColumn(i, j))
continue;
nx += tabular->GetWidthOfColumn(cell);
++cell;
}
baseline += tabular->GetDescentOfRow(i) +
tabular->GetAscentOfRow(i + 1) +
tabular->GetAdditionalHeight(cell);
}
if (the_locking_inset == tabular->GetCellInset(cell)) { if (the_locking_inset == tabular->GetCellInset(cell)) {
cx = nx + tabular->GetBeginningOfTextInCell(cell);
LyXText::text_status st = bv->text->status; LyXText::text_status st = bv->text->status;
do { do {
bv->text->status = st; bv->text->status = st;
@ -289,22 +314,9 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
tabular->GetAscentOfRow(i) + tabular->GetAscentOfRow(i) +
tabular->GetDescentOfRow(i) - 1); tabular->GetDescentOfRow(i) - 1);
} }
tabular->GetCellInset(cell)->draw( tabular->GetCellInset(cell)->draw(bv,font,baseline, cx, false);
bv, font, baseline, cx, false);
} while(bv->text->status == LyXText::CHANGED_IN_DRAW); } while(bv->text->status == LyXText::CHANGED_IN_DRAW);
} }
} else if (dodraw) {
tabular->GetCellInset(cell)->draw(bv, font, baseline, cx,
cleared);
DrawCellLines(pain, nx, baseline, i, cell);
}
nx += tabular->GetWidthOfColumn(cell);
++cell;
}
baseline += tabular->GetDescentOfRow(i) +
tabular->GetAscentOfRow(i + 1) +
tabular->GetAdditionalHeight(cell + 1);
}
} }
x -= ADD_TO_TABULAR_WIDTH; x -= ADD_TO_TABULAR_WIDTH;
x += width(bv, font); x += width(bv, font);
@ -384,8 +396,12 @@ void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit)
owner()->update(bv, font, true); owner()->update(bv, font, true);
return; return;
} }
if (the_locking_inset) if (the_locking_inset) {
the_locking_inset->update(bv, font, reinit); the_locking_inset->update(bv, font, reinit);
resetPos(bv);
inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
inset_y = cursor.y();
}
switch(need_update) { switch(need_update) {
case INIT: case INIT:
case FULL: case FULL:
@ -815,22 +831,12 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
if (hs) if (hs)
UpdateLocal(bv, SELECTION, false); UpdateLocal(bv, SELECTION, false);
break; break;
#if 0
case LFUN_LAYOUT_TABLE:
{
dialogs_ = bv->owner()->getDialogs();
dialogs_->showTabular(this);
}
break;
#else
#warning Jürgen, have a look. Is this correct? (Lgb)
case LFUN_LAYOUT_TABULAR: case LFUN_LAYOUT_TABULAR:
{ {
dialogs_ = bv->owner()->getDialogs(); dialogs_ = bv->owner()->getDialogs();
dialogs_->showTabular(this); dialogs_->showTabular(this);
} }
break; break;
#endif
case LFUN_TABULAR_FEATURE: case LFUN_TABULAR_FEATURE:
if (!TabularFeatures(bv, arg)) if (!TabularFeatures(bv, arg))
result = UNDISPATCHED; result = UNDISPATCHED;
@ -1197,7 +1203,7 @@ void InsetTabular::SetFont(BufferView * bv, LyXFont const & font, bool tall)
bool InsetTabular::TabularFeatures(BufferView * bv, string const & what) bool InsetTabular::TabularFeatures(BufferView * bv, string const & what)
{ {
int action = LyXTabular::LAST_ACTION; LyXTabular::Feature action = LyXTabular::LAST_ACTION;
int i = 0; int i = 0;
for(; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) { for(; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) {
@ -1220,7 +1226,8 @@ bool InsetTabular::TabularFeatures(BufferView * bv, string const & what)
} }
void InsetTabular::TabularFeatures(BufferView * bv, int feature, void InsetTabular::TabularFeatures(BufferView * bv,
LyXTabular::Feature feature,
string const & value) string const & value)
{ {
int i; int i;
@ -1231,6 +1238,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature,
int sel_row_end; int sel_row_end;
int setLines = 0; int setLines = 0;
LyXAlignment setAlign = LYX_ALIGN_LEFT; LyXAlignment setAlign = LYX_ALIGN_LEFT;
LyXTabular::VAlignment setVAlign = LyXTabular::LYX_VALIGN_TOP;
int lineSet; int lineSet;
bool what; bool what;
@ -1249,15 +1257,15 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature,
break; break;
case LyXTabular::M_VALIGN_TOP: case LyXTabular::M_VALIGN_TOP:
case LyXTabular::VALIGN_TOP: case LyXTabular::VALIGN_TOP:
setAlign=LyXTabular::LYX_VALIGN_TOP; setVAlign=LyXTabular::LYX_VALIGN_TOP;
break; break;
case LyXTabular::M_VALIGN_BOTTOM: case LyXTabular::M_VALIGN_BOTTOM:
case LyXTabular::VALIGN_BOTTOM: case LyXTabular::VALIGN_BOTTOM:
setAlign=LyXTabular::LYX_VALIGN_BOTTOM; setVAlign=LyXTabular::LYX_VALIGN_BOTTOM;
break; break;
case LyXTabular::M_VALIGN_CENTER: case LyXTabular::M_VALIGN_CENTER:
case LyXTabular::VALIGN_CENTER: case LyXTabular::VALIGN_CENTER:
setAlign=LyXTabular::LYX_VALIGN_CENTER; setVAlign=LyXTabular::LYX_VALIGN_CENTER;
break; break;
default: default:
break; break;
@ -1422,8 +1430,8 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature,
case LyXTabular::VALIGN_CENTER: case LyXTabular::VALIGN_CENTER:
for(i = sel_row_start; i <= sel_row_end; ++i) for(i = sel_row_start; i <= sel_row_end; ++i)
for(j = sel_col_start; j <= sel_col_end; ++j) for(j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetVAlignment(tabular->GetCellNumber(i, j), setAlign, tabular->SetVAlignment(tabular->GetCellNumber(i, j),
flag); setVAlign, flag);
if (hasSelection()) if (hasSelection())
UpdateLocal(bv, INIT, true); UpdateLocal(bv, INIT, true);
else else
@ -1527,6 +1535,9 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature,
what = !tabular->GetLTNewPage(actcell); what = !tabular->GetLTNewPage(actcell);
tabular->SetLTNewPage(actcell, what); tabular->SetLTNewPage(actcell, what);
break; break;
// dummy stuff just to avoid warnings
case LyXTabular::LAST_ACTION:
break;
} }
} }

View File

@ -152,7 +152,7 @@ public:
/// ///
bool TabularFeatures(BufferView * bv, string const & what); bool TabularFeatures(BufferView * bv, string const & what);
/// ///
void TabularFeatures(BufferView * bv, int feature, void TabularFeatures(BufferView * bv, LyXTabular::Feature feature,
string const & val = string()); string const & val = string());
/// ///
int GetActCell() const { return actcell; } int GetActCell() const { return actcell; }

View File

@ -1190,10 +1190,13 @@ bool InsetText::InsertInset(BufferView * bv, Inset * inset)
UpdatableInset * i = static_cast<UpdatableInset *>(inset); UpdatableInset * i = static_cast<UpdatableInset *>(inset);
i->setOwner(static_cast<UpdatableInset *>(this)); i->setOwner(static_cast<UpdatableInset *>(this));
} }
HideInsetCursor(bv);
TEXT(bv)->InsertInset(bv, inset); TEXT(bv)->InsertInset(bv, inset);
TEXT(bv)->selection = 0; TEXT(bv)->selection = 0;
bv->fitCursor(TEXT(bv));
UpdateLocal(bv, CURSOR_PAR, true); UpdateLocal(bv, CURSOR_PAR, true);
static_cast<UpdatableInset*>(inset)->Edit(bv, 0, 0, 0); static_cast<UpdatableInset*>(inset)->Edit(bv, 0, 0, 0);
ShowInsetCursor(bv);
return true; return true;
} }

View File

@ -1081,8 +1081,7 @@ string const LyXFunc::Dispatch(int ac,
case LFUN_REMOVEERRORS: case LFUN_REMOVEERRORS:
if (owner->view()->removeAutoInsets()) { if (owner->view()->removeAutoInsets()) {
owner->view()->redraw(); owner->view()->redraw();
owner->view()->fitCursor(); owner->view()->fitCursor(owner->view()->text);
//owner->view()->updateScrollbar();
} }
break; break;
@ -1565,13 +1564,17 @@ string const LyXFunc::Dispatch(int ac,
bool is_rtl = txt->cursor.par()->isRightToLeftPar(owner->buffer()->params); bool is_rtl = txt->cursor.par()->isRightToLeftPar(owner->buffer()->params);
if(!txt->mark_set) owner->view()->beforeChange(); if(!txt->mark_set) owner->view()->beforeChange();
owner->view()->update(BufferView::SELECT|BufferView::FITCUR); owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
LyXCursor cur = txt->cursor;
if (!is_rtl) if (!is_rtl)
txt->CursorLeft(owner->view(), false); txt->CursorLeft(owner->view(), false);
if (txt->cursor.pos() < txt->cursor.par()->Last() if ((cur != txt->cursor) && // only if really moved!
&& txt->cursor.par()->GetChar(txt->cursor.pos()) txt->cursor.pos() < txt->cursor.par()->Last() &&
== LyXParagraph::META_INSET (txt->cursor.par()->GetChar(txt->cursor.pos()) ==
&& txt->cursor.par()->GetInset(txt->cursor.pos()) LyXParagraph::META_INSET) &&
&& txt->cursor.par()->GetInset(txt->cursor.pos())->Editable() == Inset::HIGHLY_EDITABLE) { txt->cursor.par()->GetInset(txt->cursor.pos()) &&
(txt->cursor.par()->GetInset(txt->cursor.pos())->Editable()
== Inset::HIGHLY_EDITABLE))
{
Inset * tmpinset = txt->cursor.par()->GetInset(txt->cursor.pos()); Inset * tmpinset = txt->cursor.par()->GetInset(txt->cursor.pos());
setMessage(tmpinset->EditMessage()); setMessage(tmpinset->EditMessage());
LyXFont font = txt->GetFont(owner->view()->buffer(), LyXFont font = txt->GetFont(owner->view()->buffer(),

View File

@ -53,9 +53,9 @@ LyXTabular::cellstruct::cellstruct()
multicolumn = LyXTabular::CELL_NORMAL; multicolumn = LyXTabular::CELL_NORMAL;
alignment = LYX_ALIGN_CENTER; alignment = LYX_ALIGN_CENTER;
valignment = LYX_VALIGN_TOP; valignment = LYX_VALIGN_TOP;
top_line = false; top_line = true;
bottom_line = false; bottom_line = false;
left_line = false; left_line = true;
right_line = false; right_line = false;
usebox = BOX_NONE; usebox = BOX_NONE;
rotate = false; rotate = false;
@ -172,6 +172,7 @@ void LyXTabular::Init(int rows_arg, int columns_arg)
cell_info[i][j].inset.SetDrawFrame(0, InsetText::LOCKED); cell_info[i][j].inset.SetDrawFrame(0, InsetText::LOCKED);
cell_info[i][j].cellno = cellno++; cell_info[i][j].cellno = cellno++;
} }
cell_info[i][columns_-1].right_line = true;
} }
//row_info[i - 1].bottom_line = true; //row_info[i - 1].bottom_line = true;
//row_info[0].bottom_line = true; //row_info[0].bottom_line = true;
@ -318,7 +319,7 @@ void LyXTabular::Reinit()
} }
void LyXTabular::set_row_column_number_info() void LyXTabular::set_row_column_number_info(bool oldformat)
{ {
int c = 0; int c = 0;
int column = 0; int column = 0;
@ -359,6 +360,14 @@ void LyXTabular::set_row_column_number_info()
for (column = 0; column<columns_; ++column) { for (column = 0; column<columns_; ++column) {
if (IsPartOfMultiColumn(row,column)) if (IsPartOfMultiColumn(row,column))
continue; continue;
// now set the right line of multicolumns right for oldformat read
if (oldformat &&
cell_info[row][column].multicolumn==CELL_BEGIN_OF_MULTICOLUMN)
{
int cn=cells_in_multicolumn(cell_info[row][column].cellno);
cell_info[row][column].right_line =
cell_info[row][column+cn-1].right_line;
}
cell_info[row][column].inset.SetAutoBreakRows( cell_info[row][column].inset.SetAutoBreakRows(
!GetPWidth(GetCellNumber(row, column)).empty()); !GetPWidth(GetCellNumber(row, column)).empty());
} }
@ -473,9 +482,8 @@ int LyXTabular::GetAdditionalHeight(int cell) const
int const row = row_of_cell(cell); int const row = row_of_cell(cell);
if (!row) return 0; if (!row) return 0;
#warning Jürgen, should the types change? (Lgb) bool top = true;
int top = 1; // bool top = true; ?? bool bottom = true;
int bottom = 1; // bool bottom = true; ??
for (int column = 0; column < columns_ - 1 && bottom; ++column) { for (int column = 0; column < columns_ - 1 && bottom; ++column) {
switch (cell_info[row - 1][column].multicolumn) { switch (cell_info[row - 1][column].multicolumn) {
@ -621,7 +629,6 @@ bool LyXTabular::SetWidthOfCell(int cell, int new_width)
bool LyXTabular::SetAlignment(int cell, LyXAlignment align, bool onlycolumn) bool LyXTabular::SetAlignment(int cell, LyXAlignment align, bool onlycolumn)
{ {
#warning Please fix align type. (Lgb)
if (!IsMultiColumn(cell) || onlycolumn) if (!IsMultiColumn(cell) || onlycolumn)
column_info[column_of_cell(cell)].alignment = align; column_info[column_of_cell(cell)].alignment = align;
if (!onlycolumn) if (!onlycolumn)
@ -630,9 +637,8 @@ bool LyXTabular::SetAlignment(int cell, LyXAlignment align, bool onlycolumn)
} }
bool LyXTabular::SetVAlignment(int cell, char align, bool onlycolumn) bool LyXTabular::SetVAlignment(int cell, VAlignment align, bool onlycolumn)
{ {
#warning Please fix align type. (Lgb)
if (!IsMultiColumn(cell) || onlycolumn) if (!IsMultiColumn(cell) || onlycolumn)
column_info[column_of_cell(cell)].valignment = align; column_info[column_of_cell(cell)].valignment = align;
if (!onlycolumn) if (!onlycolumn)
@ -671,9 +677,9 @@ bool LyXTabular::SetMColumnPWidth(int cell, string const & width)
} }
bool LyXTabular::SetAlignSpecial(int cell, string const & special, int what) bool LyXTabular::SetAlignSpecial(int cell, string const & special,
LyXTabular::Feature what)
{ {
#warning Fix the "what" type. (Lgb)
if (what == SET_SPECIAL_MULTI) if (what == SET_SPECIAL_MULTI)
cellinfo_of_cell(cell)->align_special = special; cellinfo_of_cell(cell)->align_special = special;
else else
@ -734,9 +740,8 @@ bool LyXTabular::SetRightLine(int cell, bool line, bool onlycolumn)
} }
char LyXTabular::GetAlignment(int cell, bool onlycolumn) const LyXAlignment LyXTabular::GetAlignment(int cell, bool onlycolumn) const
{ {
#warning Fix return type. (Lgb)
if (!onlycolumn && IsMultiColumn(cell)) if (!onlycolumn && IsMultiColumn(cell))
return cellinfo_of_cell(cell)->alignment; return cellinfo_of_cell(cell)->alignment;
else else
@ -744,9 +749,8 @@ char LyXTabular::GetAlignment(int cell, bool onlycolumn) const
} }
char LyXTabular::GetVAlignment(int cell, bool onlycolumn) const LyXTabular::VAlignment LyXTabular::GetVAlignment(int cell, bool onlycolumn) const
{ {
#warning Fix return type. (Lgb)
if (!onlycolumn && IsMultiColumn(cell)) if (!onlycolumn && IsMultiColumn(cell))
return cellinfo_of_cell(cell)->valignment; return cellinfo_of_cell(cell)->valignment;
else else
@ -1048,6 +1052,38 @@ bool getTokenValue(string const str, const char * token, int & num)
} }
static
bool getTokenValue(string const str, const char * token, LyXAlignment & num)
{
int tmp;
bool ret = getTokenValue(str, token, tmp);
num = static_cast<LyXAlignment>(tmp);
return ret;
}
static
bool getTokenValue(string const str, const char * token,
LyXTabular::VAlignment & num)
{
int tmp;
bool ret = getTokenValue(str, token, tmp);
num = static_cast<LyXTabular::VAlignment>(tmp);
return ret;
}
static
bool getTokenValue(string const str, const char * token,
LyXTabular::BoxType & num)
{
int tmp;
bool ret = getTokenValue(str, token, tmp);
num = static_cast<LyXTabular::BoxType>(tmp);
return ret;
}
static static
bool getTokenValue(string const str, const char * token, bool & flag) bool getTokenValue(string const str, const char * token, bool & flag)
{ {
@ -1272,7 +1308,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
getline(is, s1, '"'); getline(is, s1, '"');
is >> ch; // skip '"' is >> ch; // skip '"'
getline(is, s2, '"'); getline(is, s2, '"');
column_info[i].alignment = static_cast<char>(a); column_info[i].alignment = static_cast<LyXAlignment>(a);
column_info[i].left_line = b; column_info[i].left_line = b;
column_info[i].right_line = c; column_info[i].right_line = c;
column_info[i].p_width = s1; column_info[i].p_width = s1;
@ -1289,17 +1325,19 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
is >> ch; // skip '"' is >> ch; // skip '"'
getline(is, s2, '"'); getline(is, s2, '"');
cell_info[i][j].multicolumn = static_cast<char>(a); cell_info[i][j].multicolumn = static_cast<char>(a);
cell_info[i][j].alignment = static_cast<char>(b); cell_info[i][j].alignment = static_cast<LyXAlignment>(b);
cell_info[i][j].top_line = static_cast<char>(c); cell_info[i][j].top_line = static_cast<char>(c);
cell_info[i][j].bottom_line = static_cast<char>(d); cell_info[i][j].bottom_line = static_cast<char>(d);
cell_info[i][j].left_line = column_info[j].left_line;
cell_info[i][j].right_line = column_info[j].right_line;
cell_info[i][j].rotate = static_cast<bool>(f); cell_info[i][j].rotate = static_cast<bool>(f);
cell_info[i][j].usebox = static_cast<bool>(g); cell_info[i][j].usebox = static_cast<BoxType>(g);
cell_info[i][j].align_special = s1; cell_info[i][j].align_special = s1;
cell_info[i][j].p_width = s2; cell_info[i][j].p_width = s2;
} }
} }
} }
set_row_column_number_info(); set_row_column_number_info(true);
LyXParagraph * par = new LyXParagraph; LyXParagraph * par = new LyXParagraph;
LyXParagraph * return_par = 0; LyXParagraph * return_par = 0;
@ -1615,9 +1653,8 @@ int LyXTabular::UnsetMultiColumn(int cell)
} }
void LyXTabular::SetLongTabular(int what) void LyXTabular::SetLongTabular(bool what)
{ {
#warning Should what be bool? (Lgb)
is_long_tabular = what; is_long_tabular = what;
} }
@ -1731,9 +1768,8 @@ void LyXTabular::SetUsebox(int cell, BoxType type)
} }
int LyXTabular::GetUsebox(int cell) const LyXTabular::BoxType LyXTabular::GetUsebox(int cell) const
{ {
#warning should the return type change? (Lgb)
if (column_info[column_of_cell(cell)].p_width.empty() && if (column_info[column_of_cell(cell)].p_width.empty() &&
!(IsMultiColumn(cell) && !cellinfo_of_cell(cell)->p_width.empty())) !(IsMultiColumn(cell) && !cellinfo_of_cell(cell)->p_width.empty()))
return BOX_NONE; return BOX_NONE;
@ -1884,7 +1920,6 @@ bool LyXTabular::IsPartOfMultiColumn(int row, int column) const
int LyXTabular::TeXTopHLine(ostream & os, int row) const int LyXTabular::TeXTopHLine(ostream & os, int row) const
{ {
#warning should this return a bool? (Lgb)
int const fcell = GetFirstCellInRow(row); int const fcell = GetFirstCellInRow(row);
int const n = NumberOfCellsInRow(fcell) + fcell; int const n = NumberOfCellsInRow(fcell) + fcell;
int tmp = 0; int tmp = 0;
@ -1916,7 +1951,6 @@ int LyXTabular::TeXTopHLine(ostream & os, int row) const
int LyXTabular::TeXBottomHLine(ostream & os, int row) const int LyXTabular::TeXBottomHLine(ostream & os, int row) const
{ {
#warning should this return a bool? (Lgb)
int const fcell = GetFirstCellInRow(row); int const fcell = GetFirstCellInRow(row);
int const n = NumberOfCellsInRow(fcell) + fcell; int const n = NumberOfCellsInRow(fcell) + fcell;
int tmp = 0; int tmp = 0;
@ -2217,15 +2251,15 @@ void LyXTabular::Validate(LaTeXFeatures & features) const
} }
bool LyXTabular::UseParbox(int cell) const LyXTabular::BoxType LyXTabular::UseParbox(int cell) const
{ {
LyXParagraph * par = GetCellInset(cell)->par; LyXParagraph * par = GetCellInset(cell)->par;
for(; par; par = par->next) { for(; par; par = par->next) {
for(int i = 0; i < par->Last(); ++i) { for(int i = 0; i < par->Last(); ++i) {
if (par->GetChar(i) == LyXParagraph::META_NEWLINE) if (par->GetChar(i) == LyXParagraph::META_NEWLINE)
return true; return BOX_PARBOX;
} }
} }
return false; return BOX_NONE;
} }

View File

@ -33,7 +33,7 @@ class Buffer;
class LyXTabular { class LyXTabular {
public: public:
/// ///
enum { enum Feature {
/// ///
APPEND_ROW = 0, APPEND_ROW = 0,
/// ///
@ -83,8 +83,6 @@ public:
/// ///
M_VALIGN_CENTER, M_VALIGN_CENTER,
/// ///
DELETE_TABULAR,
///
MULTICOLUMN, MULTICOLUMN,
/// ///
SET_ALL_LINES, SET_ALL_LINES,
@ -218,19 +216,19 @@ public:
/// Returns true if a complete update is necessary, otherwise false /// Returns true if a complete update is necessary, otherwise false
bool SetRightLine(int cell, bool line, bool onlycolumn=false); bool SetRightLine(int cell, bool line, bool onlycolumn=false);
/// Returns true if a complete update is necessary, otherwise false /// Returns true if a complete update is necessary, otherwise false
bool SetAlignment(int cell, char align, bool onlycolumn = false); bool SetAlignment(int cell, LyXAlignment align, bool onlycolumn = false);
/// Returns true if a complete update is necessary, otherwise false /// Returns true if a complete update is necessary, otherwise false
bool SetVAlignment(int cell, char align, bool onlycolumn = false); bool SetVAlignment(int cell, VAlignment align, bool onlycolumn = false);
/// ///
bool SetColumnPWidth(int cell, string const & width); bool SetColumnPWidth(int cell, string const & width);
/// ///
bool SetMColumnPWidth(int cell, string const & width); bool SetMColumnPWidth(int cell, string const & width);
/// ///
bool SetAlignSpecial(int cell, string const & special, int what); bool SetAlignSpecial(int cell, string const & special, Feature what);
/// ///
char GetAlignment(int cell, bool onlycolumn = false) const; LyXAlignment GetAlignment(int cell, bool onlycolumn = false) const;
/// ///
char GetVAlignment(int cell, bool onlycolumn = false) const; VAlignment GetVAlignment(int cell, bool onlycolumn = false) const;
/// ///
string const GetPWidth(int cell) const; string const GetPWidth(int cell) const;
/// ///
@ -305,7 +303,7 @@ public:
/// ///
int right_column_of_cell(int cell) const; int right_column_of_cell(int cell) const;
/// ///
void SetLongTabular(int what); void SetLongTabular(bool);
/// ///
bool IsLongTabular() const; bool IsLongTabular() const;
/// ///
@ -333,7 +331,7 @@ public:
/// ///
void SetUsebox(int cell, BoxType); void SetUsebox(int cell, BoxType);
/// ///
int GetUsebox(int cell) const; BoxType GetUsebox(int cell) const;
// //
// Long Tabular Options // Long Tabular Options
/// ///
@ -375,9 +373,9 @@ private: //////////////////////////////////////////////////////////////////
/// ///
int multicolumn; int multicolumn;
/// ///
int alignment; LyXAlignment alignment;
/// ///
int valignment; VAlignment valignment;
/// ///
bool top_line; bool top_line;
/// ///
@ -387,7 +385,7 @@ private: //////////////////////////////////////////////////////////////////
/// ///
bool right_line; bool right_line;
/// ///
int usebox; BoxType usebox;
/// ///
bool rotate; bool rotate;
/// ///
@ -425,9 +423,9 @@ private: //////////////////////////////////////////////////////////////////
/// ///
columnstruct(); columnstruct();
/// ///
int alignment; LyXAlignment alignment;
/// ///
int valignment; VAlignment valignment;
/// ///
bool left_line; bool left_line;
/// ///
@ -482,7 +480,7 @@ private: //////////////////////////////////////////////////////////////////
/// ///
void Reinit(); void Reinit();
/// ///
void set_row_column_number_info(); void set_row_column_number_info(bool oldformat=false);
/// Returns true if a complete update is necessary, otherwise false /// Returns true if a complete update is necessary, otherwise false
bool SetWidthOfMulticolCell(int cell, int new_width); bool SetWidthOfMulticolCell(int cell, int new_width);
/// ///
@ -500,7 +498,7 @@ private: //////////////////////////////////////////////////////////////////
/// ///
int cells_in_multicolumn(int cell) const; int cells_in_multicolumn(int cell) const;
/// ///
bool UseParbox(int cell) const; BoxType UseParbox(int cell) const;
}; };
#endif #endif

View File

@ -3402,7 +3402,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
GetFont(bview->buffer(), GetFont(bview->buffer(),
row_ptr->par(), 0)); row_ptr->par(), 0));
int w = (inset_owner ? inset_owner->width(bview, font) : ww); int w = (inset_owner ? inset_owner->width(bview, font) : ww);
int xp = (inset_owner ? x : 0); int xp = static_cast<int>(inset_owner ? x : 0);
pain.line(xp, y_offset + y_top, pain.line(xp, y_offset + y_top,
w, y_offset + y_top, w, y_offset + y_top,
LColor::topline, LColor::topline,
@ -3583,7 +3583,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
y_bottom -= lyxfont::ascent('x', GetFont(bview->buffer(), y_bottom -= lyxfont::ascent('x', GetFont(bview->buffer(),
par, par->Last() - 1)); par, par->Last() - 1));
int w = (inset_owner ? inset_owner->width(bview, font) : ww); int w = (inset_owner ? inset_owner->width(bview, font) : ww);
int xp = (inset_owner ? x : 0); int xp = static_cast<int>(inset_owner ? x : 0);
pain.line(xp, y_offset + y_bottom, pain.line(xp, y_offset + y_bottom,
w, y_offset + y_bottom, w, y_offset + y_bottom,
LColor::topline, Painter::line_solid, LColor::topline, Painter::line_solid,

View File

@ -2140,6 +2140,19 @@ void LyXText::InsertInset(BufferView * bview, Inset * inset)
InsertChar(bview, LyXParagraph::META_INSET); /* just to rebreak and refresh correctly. InsertChar(bview, LyXParagraph::META_INSET); /* just to rebreak and refresh correctly.
* The character will not be inserted a * The character will not be inserted a
* second time */ * second time */
#if 1
// if we enter a text-inset the cursor should be to the left side
// of it! This couldn't happen before as Undo was not handled inside
// inset now after the Undo LyX tries to call inset->Edit(...) again
// and cannot do this as the cursor is behind the inset and GetInset
// does not return the inset!
if (inset->IsTextInset()) {
if (cursor.par()->isRightToLeftPar(bview->buffer()->params))
CursorRight(bview);
else
CursorLeft(bview);
}
#endif
} }