changes... read the changelog...

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1896 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-04-04 22:08:13 +00:00
parent b9655a2d25
commit bcd1410de1
6 changed files with 370 additions and 271 deletions

View File

@ -1,5 +1,42 @@
2001-04-05 Lars Gullik Bjønnes <larsbj@birdstep.com>
* insettext.h: reindent
* insettabular.h: make tabular a scoped_ptr
* insettext.C (init): adjust for cursor_visible
(ToggleInsetCursor): constify asc and desc, font, adjust for
cursor_visible
(ShowInsetCursor): constify asc and desc, font, adjust for
cursor_visible
(HideInsetCursor): adjust for cursor_visible
* insettabular.C: reindent some
(InsetTabular): adjust for scoped_ptr and cursor_visible
(InsetTabular): ditto
(~InsetTabular): delete delete
(Clone): adjust for scoped_ptr
(Read): constify old_format, adjust for scoped_ptr, move init of
token
(draw): constify tx, localize loop vars.
some other localization of variables, remove double initilizatons.
* insetfoot.C: remove using std::ostream, add ostream where needed
2001-04-04 Lars Gullik Bjønnes <larsbj@birdstep.com>
* lyxinset.h: some reindentaion, use initializer list for
constructro.
UpdatableInset: make cursor_visible a private var add
public isCursorVisible(), add protected toggleCursorVisible() and
proctected setCursorVisible(bool), make scroll call the Inset::scroll
* insettoc.C: remvoe using decl
(getScreenLabel): make cmdname donst
(LyxCode): ditto
(Ascii): ditto
(Ascii): don't use endl
* insetfootlike.C: remove using decl at file scope and add std::
where needed
* insetmarginal.C: ditto

View File

@ -23,8 +23,6 @@
#include "support/LOstream.h"
#include "debug.h"
using std::ostream;
InsetFoot::InsetFoot()
: InsetFootlike()
@ -51,7 +49,7 @@ string const InsetFoot::EditMessage() const
int InsetFoot::Latex(Buffer const * buf,
ostream & os, bool fragile, bool fp) const
std::ostream & os, bool fragile, bool fp) const
{
os << "\\footnote{%\n";

View File

@ -124,11 +124,15 @@ InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
rows = 1;
if (columns <= 0)
columns = 1;
tabular = new LyXTabular(this, rows,columns);
//tabular = new LyXTabular(this, rows,columns);
tabular.reset(new LyXTabular(this, rows,columns));
// for now make it always display as display() inset
// just for test!!!
the_locking_inset = 0;
locked = no_selection = cursor_visible = false;
locked = no_selection = false;
#if 0
cursor_visible = false;
#endif
oldcell = -1;
actrow = actcell = 0;
clearSelection();
@ -140,9 +144,13 @@ InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf)
: buffer(&buf)
{
tabular = new LyXTabular(this, *(tab.tabular));
//tabular = new LyXTabular(this, *(tab.tabular));
tabular.reset(new LyXTabular(this, *(tab.tabular)));
the_locking_inset = 0;
locked = no_selection = cursor_visible = false;
locked = no_selection = false;
#if 0
cursor_visible = false;
#endif
oldcell = -1;
actrow = actcell = 0;
sel_cell_start = sel_cell_end = 0;
@ -153,7 +161,7 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf)
InsetTabular::~InsetTabular()
{
delete tabular;
//delete tabular;
hideDialog();
}
@ -161,8 +169,9 @@ InsetTabular::~InsetTabular()
Inset * InsetTabular::Clone(Buffer const & buf) const
{
InsetTabular * t = new InsetTabular(*this, buf);
delete t->tabular;
t->tabular = tabular->Clone(t);
//delete t->tabular;
//t->tabular = tabular->Clone(t);
t->tabular.reset(tabular->Clone(t));
return t;
}
@ -176,12 +185,12 @@ void InsetTabular::Write(Buffer const * buf, ostream & os) const
void InsetTabular::Read(Buffer const * buf, LyXLex & lex)
{
bool old_format = (lex.GetString() == "\\LyXTable");
string token;
bool const old_format = (lex.GetString() == "\\LyXTable");
if (tabular)
delete tabular;
tabular = new LyXTabular(buf, this, lex);
//if (tabular)
//delete tabular;
//tabular = new LyXTabular(buf, this, lex);
tabular.reset(new LyXTabular(buf, this, lex));
need_update = INIT;
@ -189,7 +198,7 @@ void InsetTabular::Read(Buffer const * buf, LyXLex & lex)
return;
lex.nextToken();
token = lex.GetString();
string token = lex.GetString();
while (lex.IsOK() && (token != "\\end_inset")) {
lex.nextToken();
token = lex.GetString();
@ -234,7 +243,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
if (!cleared && ((need_update == INIT) || (need_update == FULL) ||
(top_x != int(x)) || (top_baseline != baseline))) {
int h = ascent(bv, font) + descent(bv, font);
int tx = display() || !owner() ? 0 : top_x;
int const tx = display() || !owner() ? 0 : top_x;
int w = tx ? width(bv, font) : pain.paperWidth();
int ty = baseline - ascent(bv, font);
@ -287,11 +296,13 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
nx = int(x);
if (the_locking_inset) {
Inset * inset = tabular->GetCellInset(cell);
for (i = 0; (inset != the_locking_inset) && (i < tabular->rows());
++i)
{
for (j = 0; (inset != the_locking_inset) && (j < tabular->columns()); ++j)
{
for (i = 0;
inset != the_locking_inset && i < tabular->rows();
++i) {
for (j = 0;
inset != the_locking_inset
&& j < tabular->columns();
++j) {
if (tabular->IsPartOfMultiColumn(i, j))
continue;
nx += tabular->GetWidthOfColumn(cell);
@ -306,7 +317,8 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
}
}
} else {
for (i = 0; (cell < actcell) && (i < tabular->rows()); ++i) {
for (i = 0;
cell < actcell && i < tabular->rows(); ++i) {
for (j = 0; (cell < actcell) && (j < tabular->columns()); ++j) {
if (tabular->IsPartOfMultiColumn(i, j))
continue;
@ -326,9 +338,9 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
lyxerr[Debug::INSETS] << "ERROR this shouldn't happen\n";
return;
}
float dx;
float cx;
cx = dx = nx + tabular->GetBeginningOfTextInCell(cell);
float dx = nx + tabular->GetBeginningOfTextInCell(cell);
float cx = dx;
//cx = dx = nx + tabular->GetBeginningOfTextInCell(cell);
tabular->GetCellInset(cell)->draw(bv,font,baseline, dx, false);
if (bv->text->status == LyXText::CHANGED_IN_DRAW)
return;
@ -520,7 +532,8 @@ void InsetTabular::UpdateLocal(BufferView * bv, UpdateCodes what,
bool InsetTabular::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
{
lyxerr[Debug::INSETS] << "InsetTabular::LockInsetInInset(" <<inset<< "): ";
lyxerr[Debug::INSETS] << "InsetTabular::LockInsetInInset("
<< inset << "): ";
if (!inset)
return false;
oldcell = -1;
@ -559,8 +572,7 @@ bool InsetTabular::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
}
if (the_locking_inset->UnlockInsetInInset(bv, inset, lr)) {
if (inset->LyxCode() == TABULAR_CODE &&
!the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE))
{
!the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE)) {
bv->owner()->getDialogs()->updateTabular(this);
oldcell = actcell;
}
@ -588,7 +600,7 @@ unsigned int InsetTabular::InsetInInsetY()
if (!the_locking_inset)
return 0;
return (inset_y + the_locking_inset->InsetInInsetY());
return inset_y + the_locking_inset->InsetInInsetY();
}
@ -650,7 +662,8 @@ void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
if ((ocell == actcell) && the_locking_inset && inset_hit) {
resetPos(bv);
the_locking_inset->InsetButtonPress(bv,
x - inset_x, y - inset_y, button);
x - inset_x, y - inset_y,
button);
return;
} else if (the_locking_inset) {
the_locking_inset->InsetUnlock(bv);
@ -662,8 +675,10 @@ void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
}
if (inset_hit && bv->theLockingInset()) {
if (ActivateCellInsetAbs(bv, x, y, button))
the_locking_inset->InsetButtonPress(bv, x - inset_x,
y - inset_y, button);
the_locking_inset->InsetButtonPress(bv,
x - inset_x,
y - inset_y,
button);
return;
}
ShowInsetCursor(bv);
@ -685,7 +700,9 @@ void InsetTabular::InsetButtonRelease(BufferView * bv,
return;
}
if (the_locking_inset) {
the_locking_inset->InsetButtonRelease(bv, x-inset_x, y-inset_y,button);
the_locking_inset->InsetButtonRelease(bv,
x - inset_x, y - inset_y,
button);
return;
}
no_selection = false;
@ -695,8 +712,10 @@ void InsetTabular::InsetButtonRelease(BufferView * bv,
void InsetTabular::InsetMotionNotify(BufferView * bv, int x, int y, int button)
{
if (the_locking_inset) {
the_locking_inset->InsetMotionNotify(bv, x - inset_x,
y - inset_y, button);
the_locking_inset->InsetMotionNotify(bv,
x - inset_x,
y - inset_y,
button);
return;
}
if (!no_selection) {
@ -722,7 +741,8 @@ void InsetTabular::InsetKeyPress(XKeyEvent * xke)
}
UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv,
UpdatableInset::RESULT
InsetTabular::LocalDispatch(BufferView * bv,
kb_action action,
string const & arg)
{
@ -791,7 +811,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv,
HideInsetCursor(bv);
result=DISPATCHED;
switch (action) {
// --- Cursor Movements ---------------------------------------------
// --- Cursor Movements ----------------------------------
case LFUN_RIGHTSEL:
if (tabular->IsLastCellInRow(actcell))
break;
@ -944,9 +964,8 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv,
unsigned int len = clip.length();
string::size_type p = 0;
while((p < len) &&
((p = clip.find_first_of("\t\n", p)) != string::npos))
{
while(p < len &&
((p = clip.find_first_of("\t\n", p)) != string::npos)) {
switch(clip[p]) {
case '\t':
++cols;
@ -968,8 +987,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv,
int cells = paste_tabular->GetNumberOfCells();
p = cols = 0;
while((cell < cells) && (p < len) &&
(p = clip.find_first_of("\t\n", p)) != string::npos)
{
(p = clip.find_first_of("\t\n", p)) != string::npos) {
if (p >= len)
break;
switch(clip[p]) {
@ -992,7 +1010,8 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv,
if ((cell < cells) && (op < len))
paste_tabular->GetCellInset(cell)->SetText(clip.substr(op, len-op));
} else {
// so that the clipboard is used and it goes on to default
// so that the clipboard is used and it goes on
// to default
// and executes LFUN_PASTESELECTION in insettext!
delete paste_tabular;
paste_tabular = 0;
@ -1022,7 +1041,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv,
break;
no_draw = true;
if (ActivateCellInset(bv)) {
result=the_locking_inset->LocalDispatch(bv, action, arg);
result = the_locking_inset->LocalDispatch(bv, action, arg);
if ((result == UNDISPATCHED) || (result == FINISHED)) {
UnlockInsetInInset(bv, the_locking_inset);
no_draw = false;
@ -1145,34 +1164,35 @@ void InsetTabular::ToggleInsetCursor(BufferView * bv)
int const asc = lyxfont::maxAscent(font);
int const desc = lyxfont::maxDescent(font);
if (cursor_visible)
if (isCursorVisible())
bv->hideLockedInsetCursor();
else
bv->showLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
cursor_visible = !cursor_visible;
toggleCursorVisible();
}
void InsetTabular::ShowInsetCursor(BufferView * bv, bool show)
{
if (!cursor_visible) {
if (!isCursorVisible()) {
LyXFont font; // = GetFont(par, cursor.pos);
int const asc = lyxfont::maxAscent(font);
int const desc = lyxfont::maxDescent(font);
bv->fitLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
if (show)
bv->showLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
cursor_visible = true;
bv->showLockedInsetCursor(cursor.x(), cursor.y(),
asc, desc);
setCursorVisible(true);
}
}
void InsetTabular::HideInsetCursor(BufferView * bv)
{
if (cursor_visible) {
if (isCursorVisible()) {
bv->hideLockedInsetCursor();
cursor_visible = false;
setCursorVisible(false);
}
// if (cursor_visible)
// ToggleInsetCursor(bv);
@ -1188,9 +1208,12 @@ void InsetTabular::setPos(BufferView * bv, int x, int y) const
// first search the right row
while((ly < y) && (actrow < tabular->rows())) {
cursor.y(cursor.y() + tabular->GetDescentOfRow(actrow) +
tabular->GetAscentOfRow(actrow + 1) +
tabular->GetAdditionalHeight(tabular->GetCellNumber(actrow + 1,
cursor.y(cursor.y()
+ tabular->GetDescentOfRow(actrow)
+ tabular->GetAscentOfRow(actrow + 1)
+ tabular->
GetAdditionalHeight(tabular->
GetCellNumber(actrow + 1,
actcol)));
++actrow;
ly = cursor.y() + tabular->GetDescentOfRow(actrow);
@ -1243,9 +1266,10 @@ void InsetTabular::resetPos(BufferView * bv) const
cursor.y(0);
for (; (cell < actcell) && !tabular->IsLastRow(cell); ++cell) {
if (tabular->IsLastCellInRow(cell)) {
cursor.y(cursor.y() + tabular->GetDescentOfRow(actrow) +
tabular->GetAscentOfRow(actrow + 1) +
tabular->GetAdditionalHeight(cell + 1));
cursor.y(cursor.y()
+ tabular->GetDescentOfRow(actrow)
+ tabular->GetAscentOfRow(actrow + 1)
+ tabular->GetAdditionalHeight(cell + 1));
++actrow;
}
}
@ -1258,8 +1282,7 @@ void InsetTabular::resetPos(BufferView * bv) const
if (scroll() && (tabular->GetWidthOfTabular() < bv->workWidth()-20))
scroll(bv, 0.0F);
else if (the_locking_inset &&
(tabular->GetWidthOfColumn(actcell) > bv->workWidth()-20))
{
(tabular->GetWidthOfColumn(actcell) > bv->workWidth()-20)) {
int xx = cursor.x() - offset + bv->text->GetRealCursorX(bv);
if (xx > (bv->workWidth()-20))
scroll(bv, -(xx - bv->workWidth() + 60));
@ -1270,22 +1293,21 @@ void InsetTabular::resetPos(BufferView * bv) const
xx = 60;
scroll(bv, xx);
}
} else if (((cursor.x() - offset) > 20) &&
((cursor.x()-offset+tabular->GetWidthOfColumn(actcell)) >
(bv->workWidth()-20)))
{
scroll(bv, -tabular->GetWidthOfColumn(actcell)-20);
} else if ((cursor.x() - offset) > 20 &&
(cursor.x() - offset + tabular->GetWidthOfColumn(actcell))
> (bv->workWidth() - 20)) {
scroll(bv, -tabular->GetWidthOfColumn(actcell) - 20);
UpdateLocal(bv, FULL, false);
} else if ((cursor.x() - offset) < 20) {
scroll(bv, 20 - cursor.x() + offset);
UpdateLocal(bv, FULL, false);
} else if (scroll() && (top_x > 20) &&
((top_x+tabular->GetWidthOfTabular()) > (bv->workWidth()-20))) {
} else if (scroll() && top_x > 20 &&
(top_x + tabular->GetWidthOfTabular()) > (bv->workWidth() - 20)) {
scroll(bv, old_x - cursor.x());
}
if ((!the_locking_inset ||
!the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE)) &&
(actcell != oldcell)) {
actcell != oldcell) {
InsetTabular * inset = const_cast<InsetTabular *>(this);
bv->owner()->getDialogs()->updateTabular(inset);
oldcell = actcell;
@ -1299,7 +1321,8 @@ UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
if (ActivateCellInset(bv))
return DISPATCHED;
} else {
bool moved = isRightToLeft(bv) ? movePrevCell(bv) : moveNextCell(bv);
bool moved = isRightToLeft(bv)
? movePrevCell(bv) : moveNextCell(bv);
if (!moved)
return FINISHED;
if (lock && ActivateCellInset(bv))
@ -1466,17 +1489,17 @@ void InsetTabular::TabularFeatures(BufferView * bv,
LyXTabular::Feature feature,
string const & value)
{
int i;
int j;
//int i;
//int j;
int sel_col_start;
int sel_col_end;
int sel_row_start;
int sel_row_end;
int setLines = 0;
bool setLines = false;
LyXAlignment setAlign = LYX_ALIGN_LEFT;
LyXTabular::VAlignment setVAlign = LyXTabular::LYX_VALIGN_TOP;
int lineSet;
bool what;
//int lineSet;
//bool what;
switch (feature) {
case LyXTabular::M_ALIGN_LEFT:
@ -1548,7 +1571,7 @@ void InsetTabular::TabularFeatures(BufferView * bv,
bool const update = (tabular->GetColumnPWidth(actcell) != value);
tabular->SetColumnPWidth(actcell,value);
if (update) {
for (int i=0; i < tabular->rows(); ++i) {
for (int i = 0; i < tabular->rows(); ++i) {
tabular->GetCellInset(tabular->GetCellNumber(i, column))->
resizeLyXText(bv);
}
@ -1561,7 +1584,7 @@ void InsetTabular::TabularFeatures(BufferView * bv,
bool const update = (tabular->GetPWidth(actcell) != value);
tabular->SetMColumnPWidth(actcell,value);
if (update) {
for (int i=0; i < tabular->rows(); ++i) {
for (int i = 0; i < tabular->rows(); ++i) {
tabular->GetCellInset(tabular->GetCellNumber(i, column))->
resizeLyXText(bv);
}
@ -1607,45 +1630,62 @@ void InsetTabular::TabularFeatures(BufferView * bv,
case LyXTabular::M_TOGGLE_LINE_TOP:
flag = false;
case LyXTabular::TOGGLE_LINE_TOP:
lineSet = !tabular->TopLine(actcell, flag);
for (i=sel_row_start; i<=sel_row_end; ++i)
for (j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetTopLine(tabular->GetCellNumber(i,j),lineSet, flag);
{
bool lineSet = !tabular->TopLine(actcell, flag);
for (int i = sel_row_start; i <= sel_row_end; ++i)
for (int j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetTopLine(
tabular->GetCellNumber(i, j),
lineSet, flag);
UpdateLocal(bv, INIT, true);
break;
}
case LyXTabular::M_TOGGLE_LINE_BOTTOM:
flag = false;
case LyXTabular::TOGGLE_LINE_BOTTOM:
lineSet = !tabular->BottomLine(actcell, flag);
for (i=sel_row_start; i<=sel_row_end; ++i)
for (j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetBottomLine(tabular->GetCellNumber(i,j),lineSet,
{
bool lineSet = !tabular->BottomLine(actcell, flag);
for (int i = sel_row_start; i <= sel_row_end; ++i)
for (int j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetBottomLine(
tabular->GetCellNumber(i, j),
lineSet,
flag);
UpdateLocal(bv, INIT, true);
break;
}
case LyXTabular::M_TOGGLE_LINE_LEFT:
flag = false;
case LyXTabular::TOGGLE_LINE_LEFT:
lineSet = !tabular->LeftLine(actcell, flag);
for (i=sel_row_start; i<=sel_row_end; ++i)
for (j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetLeftLine(tabular->GetCellNumber(i,j),lineSet,
{
bool lineSet = !tabular->LeftLine(actcell, flag);
for (int i = sel_row_start; i <= sel_row_end; ++i)
for (int j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetLeftLine(
tabular->GetCellNumber(i,j),
lineSet,
flag);
UpdateLocal(bv, INIT, true);
break;
}
case LyXTabular::M_TOGGLE_LINE_RIGHT:
flag = false;
case LyXTabular::TOGGLE_LINE_RIGHT:
lineSet = !tabular->RightLine(actcell, flag);
for (i=sel_row_start; i<=sel_row_end; ++i)
for (j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetRightLine(tabular->GetCellNumber(i,j),lineSet,
{
bool lineSet = !tabular->RightLine(actcell, flag);
for (int i = sel_row_start; i <= sel_row_end; ++i)
for (int j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetRightLine(
tabular->GetCellNumber(i,j),
lineSet,
flag);
UpdateLocal(bv, INIT, true);
break;
}
case LyXTabular::M_ALIGN_LEFT:
case LyXTabular::M_ALIGN_RIGHT:
case LyXTabular::M_ALIGN_CENTER:
@ -1653,9 +1693,11 @@ void InsetTabular::TabularFeatures(BufferView * bv,
case LyXTabular::ALIGN_LEFT:
case LyXTabular::ALIGN_RIGHT:
case LyXTabular::ALIGN_CENTER:
for (i = sel_row_start; i <= sel_row_end; ++i)
for (j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetAlignment(tabular->GetCellNumber(i, j), setAlign,
for (int i = sel_row_start; i <= sel_row_end; ++i)
for (int j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetAlignment(
tabular->GetCellNumber(i, j),
setAlign,
flag);
UpdateLocal(bv, INIT, true);
break;
@ -1666,9 +1708,10 @@ void InsetTabular::TabularFeatures(BufferView * bv,
case LyXTabular::VALIGN_TOP:
case LyXTabular::VALIGN_BOTTOM:
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),
for (int i = sel_row_start; i <= sel_row_end; ++i)
for (int j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetVAlignment(
tabular->GetCellNumber(i, j),
setVAlign, flag);
UpdateLocal(bv, INIT, true);
break;
@ -1711,11 +1754,12 @@ void InsetTabular::TabularFeatures(BufferView * bv,
break;
}
case LyXTabular::SET_ALL_LINES:
setLines = 1;
setLines = true;
case LyXTabular::UNSET_ALL_LINES:
for (i=sel_row_start; i<=sel_row_end; ++i)
for (j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetAllLines(tabular->GetCellNumber(i,j), setLines);
for (int i = sel_row_start; i <= sel_row_end; ++i)
for (int j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetAllLines(
tabular->GetCellNumber(i,j), setLines);
UpdateLocal(bv, INIT, true);
break;
case LyXTabular::SET_LONGTABULAR:
@ -1733,23 +1777,27 @@ void InsetTabular::TabularFeatures(BufferView * bv,
tabular->SetRotateTabular(false);
break;
case LyXTabular::SET_ROTATE_CELL:
for (i=sel_row_start; i<=sel_row_end; ++i)
for (j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetRotateCell(tabular->GetCellNumber(i,j),true);
for (int i = sel_row_start; i <= sel_row_end; ++i)
for (int j = sel_col_start; j<=sel_col_end; ++j)
tabular->SetRotateCell(
tabular->GetCellNumber(i, j),
true);
break;
case LyXTabular::UNSET_ROTATE_CELL:
for (i = sel_row_start; i <= sel_row_end; ++i)
for (j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetRotateCell(tabular->GetCellNumber(i, j), false);
for (int i = sel_row_start; i <= sel_row_end; ++i)
for (int j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetRotateCell(
tabular->GetCellNumber(i, j), false);
break;
case LyXTabular::SET_USEBOX:
{
LyXTabular::BoxType val = LyXTabular::BoxType(strToInt(value));
if (val == tabular->GetUsebox(actcell))
val = LyXTabular::BOX_NONE;
for (i = sel_row_start; i <= sel_row_end; ++i)
for (j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetUsebox(tabular->GetCellNumber(i, j), val);
for (int i = sel_row_start; i <= sel_row_end; ++i)
for (int j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetUsebox(
tabular->GetCellNumber(i, j), val);
break;
}
case LyXTabular::SET_LTFIRSTHEAD:
@ -1765,9 +1813,11 @@ void InsetTabular::TabularFeatures(BufferView * bv,
tabular->SetLTFoot(actcell, true);
break;
case LyXTabular::SET_LTNEWPAGE:
what = !tabular->GetLTNewPage(actcell);
{
bool what = !tabular->GetLTNewPage(actcell);
tabular->SetLTNewPage(actcell, what);
break;
}
// dummy stuff just to avoid warnings
case LyXTabular::LAST_ACTION:
break;
@ -1798,7 +1848,8 @@ bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button,
bool InsetTabular::ActivateCellInsetAbs(BufferView * bv, int x, int y,
int button)
{
inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
inset_x = cursor.x()
- top_x + tabular->GetBeginningOfTextInCell(actcell);
inset_y = cursor.y();
return ActivateCellInset(bv, x - inset_x, y - inset_y, button);
}
@ -1806,7 +1857,8 @@ bool InsetTabular::ActivateCellInsetAbs(BufferView * bv, int x, int y,
bool InsetTabular::InsetHit(BufferView *, int x, int) const
{
return x + top_x > cursor.x() + tabular->GetBeginningOfTextInCell(actcell);
return (x + top_x)
> (cursor.x() + tabular->GetBeginningOfTextInCell(actcell));
}
@ -1847,7 +1899,8 @@ void InsetTabular::resizeLyXText(BufferView *) const
}
LyXText * InsetTabular::getLyXText(BufferView const * bv, bool const recursive) const
LyXText * InsetTabular::getLyXText(BufferView const * bv,
bool const recursive) const
{
if (the_locking_inset)
return the_locking_inset->getLyXText(bv, recursive);
@ -1858,7 +1911,8 @@ LyXText * InsetTabular::getLyXText(BufferView const * bv, bool const recursive)
bool InsetTabular::ShowInsetDialog(BufferView * bv) const
{
if (!the_locking_inset || !the_locking_inset->ShowInsetDialog(bv))
bv->owner()->getDialogs()->showTabular(const_cast<InsetTabular *>(this));
bv->owner()->getDialogs()
->showTabular(const_cast<InsetTabular *>(this));
return true;
}
@ -1873,7 +1927,8 @@ void InsetTabular::OpenLayoutDialog(BufferView * bv) const
return;
}
}
bv->owner()->getDialogs()->showTabular(const_cast<InsetTabular *>(this));
bv->owner()->getDialogs()->showTabular(
const_cast<InsetTabular *>(this));
}
//
@ -2108,48 +2163,50 @@ bool InsetTabular::copySelection(BufferView * bv)
{
if (!hasSelection())
return false;
delete paste_tabular;
//delete paste_tabular;
int sel_col_start;
int sel_col_end;
int sel_row_start;
int sel_row_end;
//int sel_col_start;
//int sel_col_end;
//int sel_row_start;
//int sel_row_end;
sel_col_start = tabular->column_of_cell(sel_cell_start);
sel_col_end = tabular->column_of_cell(sel_cell_end);
int sel_col_start = tabular->column_of_cell(sel_cell_start);
int sel_col_end = tabular->column_of_cell(sel_cell_end);
if (sel_col_start > sel_col_end) {
sel_col_start = sel_col_end;
sel_col_end = tabular->right_column_of_cell(sel_cell_start);
} else {
sel_col_end = tabular->right_column_of_cell(sel_cell_end);
}
int columns = sel_col_end - sel_col_start + 1;
int const columns = sel_col_end - sel_col_start + 1;
sel_row_start = tabular->row_of_cell(sel_cell_start);
sel_row_end = tabular->row_of_cell(sel_cell_end);
int sel_row_start = tabular->row_of_cell(sel_cell_start);
int sel_row_end = tabular->row_of_cell(sel_cell_end);
if (sel_row_start > sel_row_end) {
//int tmp tmp = sel_row_start;
//sel_row_start = sel_row_end;
//sel_row_end = tmp;
swap(sel_row_start, sel_row_end);
}
int rows = sel_row_end - sel_row_start + 1;
int const rows = sel_row_end - sel_row_start + 1;
delete paste_tabular;
paste_tabular = new LyXTabular(this, *tabular); // rows, columns);
int i;
for (i=0; i < sel_row_start; ++i)
//int i;
for (int i = 0; i < sel_row_start; ++i)
paste_tabular->DeleteRow(0);
while(paste_tabular->rows() > rows)
paste_tabular->DeleteRow(rows);
paste_tabular->SetTopLine(0, true, true);
paste_tabular->SetBottomLine(paste_tabular->GetFirstCellInRow(rows-1),
true, true);
for (i=0; i < sel_col_start; ++i)
for (int i = 0; i < sel_col_start; ++i)
paste_tabular->DeleteColumn(0);
while(paste_tabular->columns() > columns)
while (paste_tabular->columns() > columns)
paste_tabular->DeleteColumn(columns);
paste_tabular->SetLeftLine(0, true, true);
paste_tabular->SetRightLine(paste_tabular->GetLastCellInRow(0),true, true);
paste_tabular->SetRightLine(paste_tabular->GetLastCellInRow(0),
true, true);
ostringstream sstr;
paste_tabular->Ascii(bv->buffer(), sstr);
@ -2165,12 +2222,10 @@ bool InsetTabular::pasteSelection(BufferView * bv)
for (int r1 = 0, r2 = actrow;
(r1 < paste_tabular->rows()) && (r2 < tabular->rows());
++r1, ++r2)
{
++r1, ++r2) {
for(int c1 = 0, c2 = actcol;
(c1 < paste_tabular->columns()) && (c2 < tabular->columns());
++c1, ++c2)
{
++c1, ++c2) {
if (paste_tabular->IsPartOfMultiColumn(r1,c1) &&
tabular->IsPartOfMultiColumn(r2,c2))
continue;
@ -2182,8 +2237,8 @@ bool InsetTabular::pasteSelection(BufferView * bv)
--c1;
continue;
}
int n1 = paste_tabular->GetCellNumber(r1, c1);
int n2 = tabular->GetCellNumber(r2, c2);
int const n1 = paste_tabular->GetCellNumber(r1, c1);
int const n2 = tabular->GetCellNumber(r2, c2);
*(tabular->GetCellInset(n2)) = *(paste_tabular->GetCellInset(n1));
tabular->GetCellInset(n2)->setOwner(this);
tabular->GetCellInset(n2)->deleteLyXText(bv);
@ -2198,21 +2253,21 @@ bool InsetTabular::cutSelection()
if (!hasSelection())
return false;
int sel_col_start;
int sel_col_end;
int sel_row_start;
int sel_row_end;
//int sel_col_start;
//int sel_col_end;
//int sel_row_start;
//int sel_row_end;
sel_col_start = tabular->column_of_cell(sel_cell_start);
sel_col_end = tabular->column_of_cell(sel_cell_end);
int sel_col_start = tabular->column_of_cell(sel_cell_start);
int sel_col_end = tabular->column_of_cell(sel_cell_end);
if (sel_col_start > sel_col_end) {
sel_col_start = sel_col_end;
sel_col_end = tabular->right_column_of_cell(sel_cell_start);
} else {
sel_col_end = tabular->right_column_of_cell(sel_cell_end);
}
sel_row_start = tabular->row_of_cell(sel_cell_start);
sel_row_end = tabular->row_of_cell(sel_cell_end);
int sel_row_start = tabular->row_of_cell(sel_cell_start);
int sel_row_end = tabular->row_of_cell(sel_cell_end);
if (sel_row_start > sel_row_end) {
//int tmp = sel_row_start;
//sel_row_start = sel_row_end;
@ -2233,6 +2288,7 @@ bool InsetTabular::cutSelection()
return true;
}
bool InsetTabular::isRightToLeft(BufferView *bv )
{
return bv->getParentLanguage(this)->RightToLeft();

View File

@ -45,6 +45,9 @@
#ifndef INSETTABULAR_H
#define INSETTABULAR_H
#include <sigc++/signal_system.h>
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
@ -54,7 +57,6 @@
#include "LString.h"
#include "lyxcursor.h"
#include "lyxfunc.h"
#include <sigc++/signal_system.h>
class LyXLex;
class Painter;
@ -107,7 +109,8 @@ public:
///
bool LockInsetInInset(BufferView *, UpdatableInset *);
///
bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
bool UnlockInsetInInset(BufferView *, UpdatableInset *,
bool lr = false);
///
bool UpdateInsetInInset(BufferView *, Inset *);
///
@ -163,7 +166,8 @@ public:
///
Buffer * BufferOwner() const { return const_cast<Buffer *>(buffer); }
///
LyXText * getLyXText(BufferView const *, bool const recursive = false) const;
LyXText * getLyXText(BufferView const *,
bool const recursive = false) const;
///
void resizeLyXText(BufferView *) const;
///
@ -176,7 +180,8 @@ public:
//
// Public structures and variables
///
LyXTabular * tabular;
//LyXTabular * tabular;
boost::scoped_ptr<LyXTabular> tabular;
///
SigC::Signal0<void> hideDialog;

View File

@ -91,7 +91,9 @@ void InsetText::init(InsetText const * ins)
insetDescent = 0;
insetWidth = 0;
the_locking_inset = 0;
#if 0
cursor_visible = false;
#endif
interline_space = 1;
no_selection = false;
need_update = INIT;
@ -1268,16 +1270,16 @@ void InsetText::ToggleInsetCursor(BufferView * bv)
return;
}
LyXFont font = TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
LyXFont const font(TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv)));
int asc = lyxfont::maxAscent(font);
int desc = lyxfont::maxDescent(font);
int const asc = lyxfont::maxAscent(font);
int const desc = lyxfont::maxDescent(font);
if (cursor_visible)
if (isCursorVisible())
bv->hideLockedInsetCursor();
else
bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
cursor_visible = !cursor_visible;
toggleCursorVisible();
}
@ -1287,25 +1289,26 @@ void InsetText::ShowInsetCursor(BufferView * bv, bool show)
the_locking_inset->ShowInsetCursor(bv);
return;
}
if (!cursor_visible) {
LyXFont font = TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
if (!isCursorVisible()) {
LyXFont const font =
TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
int asc = lyxfont::maxAscent(font);
int desc = lyxfont::maxDescent(font);
int const asc = lyxfont::maxAscent(font);
int const desc = lyxfont::maxDescent(font);
bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
if (show)
bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
cursor_visible = true;
setCursorVisible(true);
}
}
void InsetText::HideInsetCursor(BufferView * bv)
{
if (cursor_visible) {
if (isCursorVisible()) {
bv->hideLockedInsetCursor();
cursor_visible = false;
setCursorVisible(false);
}
if (the_locking_inset)
the_locking_inset->HideInsetCursor(bv);