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>
* 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 fitCursor();
void fitCursor(LyXText *);
///
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
// inset there otherwise this is a illegal function now
if (the_locking_inset) {
if (the_locking_inset->InsertInsetAllowed(inset) &&
the_locking_inset->InsertInset(this, inset))
return true;
if (the_locking_inset->InsertInsetAllowed(inset))
return the_locking_inset->InsertInset(this, inset);
return false;
}
@ -252,19 +251,6 @@ bool BufferView::insertInset(Inset * inset, string const & lout,
}
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);
text->UnFreezeUndo();
@ -394,8 +380,7 @@ void BufferView::allFloats(char flag, char figmar)
text->SetCursorIntern(this, cursor.par(), cursor.pos());
redraw();
fitCursor();
//updateScrollbar();
fitCursor(text);
}
#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
// without a valid screen.
bool ret = screen_->FitCursor(bv_->text);
if (ret) updateScrollbar();
bool ret = screen_->FitCursor(text);
if (ret)
updateScrollbar();
return ret;
}
@ -541,7 +542,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
bv_->text->SetSelection();
screen_->ToggleToggle(bv_->text);
fitCursor();
fitCursor(bv_->text);
screen_->ShowCursor(bv_->text);
}
return;
@ -634,7 +635,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
bv_->text->cursor.x_fix(bv_->text->cursor.x());
owner_->updateLayoutChoice();
if (fitCursor()) {
if (fitCursor(bv_->text)) {
selection_possible = false;
}
@ -976,7 +977,7 @@ void BufferView::Pimpl::workAreaExpose()
// fitCursor() ensures we don't jump back
// to the start of the document on vertical
// resize
fitCursor();
fitCursor(bv_->text);
// The main window size has changed, repaint most stuff
redraw();
@ -1052,7 +1053,7 @@ void BufferView::Pimpl::update(BufferView::UpdateCodes f)
update();
if ((f & FITCUR)) {
fitCursor();
fitCursor(bv_->text);
}
if ((f & CHANGE)) {

View File

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

View File

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

View File

@ -106,7 +106,7 @@ public:
///
void redraw() {
users->redraw();
users->fitCursor();
users->fitCursor(users->text);
//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:
if (a || (result & LaTeX::ERRORS)){
bv->redraw();
bv->fitCursor();
//bv->updateScrollbar();
bv->fitCursor(bv->text);
}
// check return value from latex.run().

View File

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

View File

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

View File

@ -53,7 +53,7 @@ using std::swap;
struct tabular_features {
int action;
LyXTabular::Feature action;
string feature;
};
@ -85,7 +85,6 @@ static tabular_features tabularFeatures[] =
{ LyXTabular::M_VALIGN_TOP, "m-valign-top" },
{ LyXTabular::M_VALIGN_BOTTOM, "m-valign-bottom" },
{ LyXTabular::M_VALIGN_CENTER, "m-valign-center" },
{ LyXTabular::DELETE_TABULAR, "delete-tabular" },
{ LyXTabular::MULTICOLUMN, "multicolumn" },
{ LyXTabular::SET_ALL_LINES, "set-all-lines" },
{ LyXTabular::UNSET_ALL_LINES, "unset-all-lines" },
@ -255,45 +254,18 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
return;
bool dodraw;
x += ADD_TO_TABULAR_WIDTH;
if (cleared || (need_update == FULL) || (need_update == CELL)) {
if (cleared) {
for(i = 0; i < tabular->rows(); ++i) {
nx = int(x);
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) {
if (tabular->IsPartOfMultiColumn(i, j))
continue;
cx = nx + tabular->GetBeginningOfTextInCell(cell);
if (hasSelection())
DrawCellSelection(pain, nx, baseline, i, j, cell);
if (dodraw && !cleared && locked && the_locking_inset) {
if (the_locking_inset == tabular->GetCellInset(cell)) {
LyXText::text_status st = bv->text->status;
do {
bv->text->status = st;
if (need_update == CELL) {
// clear before the inset
pain.fillRectangle(
nx + 1,
baseline - tabular->GetAscentOfRow(i) + 1,
int(cx - nx - 1),
tabular->GetAscentOfRow(i) +
tabular->GetDescentOfRow(i) - 1);
// clear behind the inset
pain.fillRectangle(
int(cx + the_locking_inset->width(bv,font) + 1),
baseline - tabular->GetAscentOfRow(i) + 1,
tabular->GetWidthOfColumn(cell) -
tabular->GetBeginningOfTextInCell(cell) -
the_locking_inset->width(bv,font) - 1,
tabular->GetAscentOfRow(i) +
tabular->GetDescentOfRow(i) - 1);
}
tabular->GetCellInset(cell)->draw(
bv, font, baseline, cx, false);
} while(bv->text->status == LyXText::CHANGED_IN_DRAW);
}
} else if (dodraw) {
if (dodraw) {
if (hasSelection())
DrawCellSelection(pain, nx, baseline, i, j, cell);
tabular->GetCellInset(cell)->draw(bv, font, baseline, cx,
cleared);
DrawCellLines(pain, nx, baseline, i, cell);
@ -303,7 +275,47 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
}
baseline += tabular->GetDescentOfRow(i) +
tabular->GetAscentOfRow(i + 1) +
tabular->GetAdditionalHeight(cell + 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)) {
cx = nx + tabular->GetBeginningOfTextInCell(cell);
LyXText::text_status st = bv->text->status;
do {
bv->text->status = st;
if (need_update == CELL) {
// clear before the inset
pain.fillRectangle(
nx + 1,
baseline - tabular->GetAscentOfRow(i) + 1,
int(cx - nx - 1),
tabular->GetAscentOfRow(i) +
tabular->GetDescentOfRow(i) - 1);
// clear behind the inset
pain.fillRectangle(
int(cx + the_locking_inset->width(bv,font) + 1),
baseline - tabular->GetAscentOfRow(i) + 1,
tabular->GetWidthOfColumn(cell) -
tabular->GetBeginningOfTextInCell(cell) -
the_locking_inset->width(bv,font) - 1,
tabular->GetAscentOfRow(i) +
tabular->GetDescentOfRow(i) - 1);
}
tabular->GetCellInset(cell)->draw(bv,font,baseline, cx, false);
} while(bv->text->status == LyXText::CHANGED_IN_DRAW);
}
}
x -= ADD_TO_TABULAR_WIDTH;
@ -384,8 +396,12 @@ void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit)
owner()->update(bv, font, true);
return;
}
if (the_locking_inset)
if (the_locking_inset) {
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) {
case INIT:
case FULL:
@ -815,22 +831,12 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
if (hs)
UpdateLocal(bv, SELECTION, false);
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:
{
dialogs_ = bv->owner()->getDialogs();
dialogs_->showTabular(this);
}
break;
#endif
case LFUN_TABULAR_FEATURE:
if (!TabularFeatures(bv, arg))
result = UNDISPATCHED;
@ -1197,7 +1203,7 @@ void InsetTabular::SetFont(BufferView * bv, LyXFont const & font, bool tall)
bool InsetTabular::TabularFeatures(BufferView * bv, string const & what)
{
int action = LyXTabular::LAST_ACTION;
LyXTabular::Feature action = LyXTabular::LAST_ACTION;
int i = 0;
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)
{
int i;
@ -1231,6 +1238,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature,
int sel_row_end;
int setLines = 0;
LyXAlignment setAlign = LYX_ALIGN_LEFT;
LyXTabular::VAlignment setVAlign = LyXTabular::LYX_VALIGN_TOP;
int lineSet;
bool what;
@ -1249,15 +1257,15 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature,
break;
case LyXTabular::M_VALIGN_TOP:
case LyXTabular::VALIGN_TOP:
setAlign=LyXTabular::LYX_VALIGN_TOP;
setVAlign=LyXTabular::LYX_VALIGN_TOP;
break;
case LyXTabular::M_VALIGN_BOTTOM:
case LyXTabular::VALIGN_BOTTOM:
setAlign=LyXTabular::LYX_VALIGN_BOTTOM;
setVAlign=LyXTabular::LYX_VALIGN_BOTTOM;
break;
case LyXTabular::M_VALIGN_CENTER:
case LyXTabular::VALIGN_CENTER:
setAlign=LyXTabular::LYX_VALIGN_CENTER;
setVAlign=LyXTabular::LYX_VALIGN_CENTER;
break;
default:
break;
@ -1422,8 +1430,8 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature,
case LyXTabular::VALIGN_CENTER:
for(i = sel_row_start; i <= sel_row_end; ++i)
for(j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetVAlignment(tabular->GetCellNumber(i, j), setAlign,
flag);
tabular->SetVAlignment(tabular->GetCellNumber(i, j),
setVAlign, flag);
if (hasSelection())
UpdateLocal(bv, INIT, true);
else
@ -1527,6 +1535,9 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature,
what = !tabular->GetLTNewPage(actcell);
tabular->SetLTNewPage(actcell, what);
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);
///
void TabularFeatures(BufferView * bv, int feature,
void TabularFeatures(BufferView * bv, LyXTabular::Feature feature,
string const & val = string());
///
int GetActCell() const { return actcell; }

View File

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

View File

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

View File

@ -53,9 +53,9 @@ LyXTabular::cellstruct::cellstruct()
multicolumn = LyXTabular::CELL_NORMAL;
alignment = LYX_ALIGN_CENTER;
valignment = LYX_VALIGN_TOP;
top_line = false;
top_line = true;
bottom_line = false;
left_line = false;
left_line = true;
right_line = false;
usebox = BOX_NONE;
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].cellno = cellno++;
}
cell_info[i][columns_-1].right_line = true;
}
//row_info[i - 1].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 column = 0;
@ -359,6 +360,14 @@ void LyXTabular::set_row_column_number_info()
for (column = 0; column<columns_; ++column) {
if (IsPartOfMultiColumn(row,column))
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(
!GetPWidth(GetCellNumber(row, column)).empty());
}
@ -473,9 +482,8 @@ int LyXTabular::GetAdditionalHeight(int cell) const
int const row = row_of_cell(cell);
if (!row) return 0;
#warning Jürgen, should the types change? (Lgb)
int top = 1; // bool top = true; ??
int bottom = 1; // bool bottom = true; ??
bool top = true;
bool bottom = true;
for (int column = 0; column < columns_ - 1 && bottom; ++column) {
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)
{
#warning Please fix align type. (Lgb)
if (!IsMultiColumn(cell) || onlycolumn)
column_info[column_of_cell(cell)].alignment = align;
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)
column_info[column_of_cell(cell)].valignment = align;
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)
cellinfo_of_cell(cell)->align_special = special;
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))
return cellinfo_of_cell(cell)->alignment;
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))
return cellinfo_of_cell(cell)->valignment;
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
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, '"');
is >> ch; // skip '"'
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].right_line = c;
column_info[i].p_width = s1;
@ -1289,17 +1325,19 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
is >> ch; // skip '"'
getline(is, s2, '"');
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].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].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].p_width = s2;
}
}
}
set_row_column_number_info();
set_row_column_number_info(true);
LyXParagraph * par = new LyXParagraph;
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;
}
@ -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() &&
!(IsMultiColumn(cell) && !cellinfo_of_cell(cell)->p_width.empty()))
return BOX_NONE;
@ -1884,7 +1920,6 @@ bool LyXTabular::IsPartOfMultiColumn(int row, int column) const
int LyXTabular::TeXTopHLine(ostream & os, int row) const
{
#warning should this return a bool? (Lgb)
int const fcell = GetFirstCellInRow(row);
int const n = NumberOfCellsInRow(fcell) + fcell;
int tmp = 0;
@ -1916,7 +1951,6 @@ int LyXTabular::TeXTopHLine(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 n = NumberOfCellsInRow(fcell) + fcell;
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;
for(; par; par = par->next) {
for(int i = 0; i < par->Last(); ++i) {
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 {
public:
///
enum {
enum Feature {
///
APPEND_ROW = 0,
///
@ -83,8 +83,6 @@ public:
///
M_VALIGN_CENTER,
///
DELETE_TABULAR,
///
MULTICOLUMN,
///
SET_ALL_LINES,
@ -218,19 +216,19 @@ public:
/// Returns true if a complete update is necessary, otherwise false
bool SetRightLine(int cell, bool line, bool onlycolumn=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
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 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;
///
@ -305,7 +303,7 @@ public:
///
int right_column_of_cell(int cell) const;
///
void SetLongTabular(int what);
void SetLongTabular(bool);
///
bool IsLongTabular() const;
///
@ -333,7 +331,7 @@ public:
///
void SetUsebox(int cell, BoxType);
///
int GetUsebox(int cell) const;
BoxType GetUsebox(int cell) const;
//
// Long Tabular Options
///
@ -375,9 +373,9 @@ private: //////////////////////////////////////////////////////////////////
///
int multicolumn;
///
int alignment;
LyXAlignment alignment;
///
int valignment;
VAlignment valignment;
///
bool top_line;
///
@ -387,7 +385,7 @@ private: //////////////////////////////////////////////////////////////////
///
bool right_line;
///
int usebox;
BoxType usebox;
///
bool rotate;
///
@ -425,9 +423,9 @@ private: //////////////////////////////////////////////////////////////////
///
columnstruct();
///
int alignment;
LyXAlignment alignment;
///
int valignment;
VAlignment valignment;
///
bool left_line;
///
@ -482,7 +480,7 @@ private: //////////////////////////////////////////////////////////////////
///
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
bool SetWidthOfMulticolCell(int cell, int new_width);
///
@ -500,7 +498,7 @@ private: //////////////////////////////////////////////////////////////////
///
int cells_in_multicolumn(int cell) const;
///
bool UseParbox(int cell) const;
BoxType UseParbox(int cell) const;
};
#endif

View File

@ -3402,7 +3402,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
GetFont(bview->buffer(),
row_ptr->par(), 0));
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,
w, y_offset + y_top,
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(),
par, par->Last() - 1));
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,
w, y_offset + y_bottom,
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.
* The character will not be inserted a
* 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
}