Lot's of updates for new update handling of text-insets

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@831 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2000-06-23 15:02:46 +00:00
parent 572556e94f
commit b744c6ed9f
37 changed files with 268 additions and 241 deletions

View File

@ -1,3 +1,17 @@
2000-06-23 Juergen Vigna <jug@sad.it>
* src/lyxtext.h: added a 'cleared' flag to draw() function.
* src/buffer.C (resize): delete the LyXText of textinsets.
* src/paragraph.C (SetInsetOwner): set the owner in the insets too.
* src/insets/lyxinset.h: added another parameter 'cleared' to
the draw() function.
* src/lyxfunc.C (processKeyEvent): move cursor to the right of the
unlocking inset in inset.
2000-06-22 Juergen Vigna <jug@sad.it>
* src/lyxscreen.h: added some y_offset/x_offset parameters for drawings

View File

@ -3801,6 +3801,20 @@ bool Buffer::Dispatch(int action, string const & argument)
}
void Buffer::resize()
{
/// first resize the BufferViews!
if (users) {
users->resize();
}
/// then remove all LyXText in text-insets
LyXParagraph * par = paragraph;
for(;par;par = par->next) {
par->deleteInsetsLyXText(users);
}
}
void Buffer::ChangeLanguage(Language const * from, Language const * to)
{

View File

@ -88,11 +88,7 @@ public:
bool Dispatch(int, auto_mem_buffer &);
/// should be changed to work for a list.
void resize() {
if (users) {
users->resize();
}
}
void resize();
/// Update window titles of all users
void updateTitles() const;

View File

@ -1035,7 +1035,7 @@ int InsetFig::width(Painter &, LyXFont const &) const
void InsetFig::draw(BufferView * bv, LyXFont const & f,
int baseline, float & x) const
int baseline, float & x, bool) const
{
LyXFont font(f);
Painter & pain = bv->painter();

View File

@ -30,8 +30,7 @@ public:
///
int width(Painter &, LyXFont const & font) const;
///
void draw(BufferView *, LyXFont const & font,
int baseline, float & x) const;
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
void Write(Buffer const *, std::ostream &) const;
///

View File

@ -88,7 +88,7 @@ int InsetButton::width(Painter & pain, LyXFont const &) const
void InsetButton::draw(BufferView * bv, LyXFont const &,
int baseline, float & x) const
int baseline, float & x, bool) const
{
Painter & pain = bv->painter();
// Draw it as a box with the LaTeX text

View File

@ -33,7 +33,7 @@ public:
///
int width(Painter &, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int baseline, float & x) const;
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
protected:
/// This should provide the text for the button

View File

@ -136,7 +136,7 @@ void InsetCollapsable::draw_collapsed(Painter & pain, LyXFont const & font,
void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
int baseline, float & x) const
int baseline, float & x, bool cleared) const
{
Painter & pain = bv->painter();
@ -155,12 +155,11 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
int w = InsetText::width(pain, f) + 2 * TEXT_TO_INSET_OFFSET;
int h = ascent(pain,f) + descent(pain, f);
pain.rectangle(int(x), baseline - ascent(pain, f), w, h, framecolor);
int save_x = static_cast<int>(x);
x += TEXT_TO_INSET_OFFSET;
drawTextXOffset = int(x) - top_x;
InsetText::draw(bv, f, baseline, x);
InsetText::draw(bv, f, baseline, x, cleared);
pain.rectangle(save_x, baseline - ascent(pain, f), w, h, framecolor);
}

View File

@ -51,7 +51,7 @@ public:
///
int width(Painter &, LyXFont const & f) const;
///
void draw(BufferView *, const LyXFont &, int , float &) const;
void draw(BufferView *, const LyXFont &, int , float &, bool) const;
///
void Edit(BufferView *, int, int, unsigned int);
///

View File

@ -73,7 +73,7 @@ int InsetError::width(Painter &, LyXFont const & font) const
void InsetError::draw(BufferView * bv, LyXFont const & font,
int baseline, float & x) const
int baseline, float & x, bool) const
{
Painter & pain = bv->painter();
LyXFont efont;

View File

@ -42,7 +42,7 @@ public:
///
int width(Painter &, LyXFont const & font) const;
///
void draw(BufferView *, LyXFont const & font, int baseline, float & x) const;
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
void Write(Buffer const *, std::ostream &) const;
///

View File

@ -135,7 +135,7 @@ int InsetGraphics::width(Painter &, LyXFont const &) const
void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
int baseline, float & x) const
int baseline, float & x, bool) const
{
Painter & pain = bv->painter();

View File

@ -35,8 +35,7 @@ public:
///
int width(Painter &, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &,
int baseline, float & x) const;
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
void Edit(BufferView *, int, int, unsigned int);
///

View File

@ -76,7 +76,7 @@ int InsetInfo::width(Painter &, LyXFont const & font) const
void InsetInfo::draw(BufferView * bv, LyXFont const & f,
int baseline, float & x) const
int baseline, float & x, bool) const
{
Painter & pain = bv->painter();
LyXFont font(f);

View File

@ -44,7 +44,7 @@ public:
///
int width(Painter &, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int baseline, float & x) const;
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
void Write(Buffer const *, std::ostream &) const;
///

View File

@ -356,7 +356,7 @@ bool InsetLatexAccent::DisplayISO8859_9(Painter & pain, LyXFont const & font,
void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font,
int baseline, float & x) const
int baseline, float & x, bool) const
{
Painter & pain = bv->painter();

View File

@ -41,7 +41,7 @@ public:
///
int width(Painter &, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int baseline, float & x) const;
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
int Lbearing(LyXFont const & font) const;
///

View File

@ -198,7 +198,7 @@ LyXFont InsetQuotes::ConvertFont(LyXFont font)
void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
int baseline, float & x) const
int baseline, float & x, bool) const
{
string text = DispString();

View File

@ -78,7 +78,7 @@ public:
///
int width(Painter &, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int baseline, float & x) const;
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
LyXFont ConvertFont(LyXFont font);
///

View File

@ -73,7 +73,7 @@ int InsetSpecialChar::width(Painter &, LyXFont const & font) const
void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
int baseline, float & x) const
int baseline, float & x, bool) const
{
Painter & pain = bv->painter();
LyXFont font(f);

View File

@ -50,7 +50,7 @@ public:
///
int width(Painter &, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int baseline, float & x) const;
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
void Write(Buffer const *, std::ostream &) const;
/// Will not be used when lyxf3

View File

@ -63,7 +63,7 @@ InsetTabular::InsetTabular(Buffer * buf, int rows, int columns)
actcell = 0;
cursor.pos(0);
sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
init_inset = true;
need_update = INIT;
}
@ -78,7 +78,7 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer * buf)
actcell = 0;
cursor.pos(0);
sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
init_inset = true;
need_update = INIT;
}
@ -113,7 +113,7 @@ void InsetTabular::Read(Buffer const * buf, LyXLex & lex)
delete tabular;
tabular = new LyXTabular(buf, this, lex);
init_inset = true;
need_update = INIT;
if (old_format)
return;
@ -150,7 +150,7 @@ int InsetTabular::width(Painter &, LyXFont const &) const
void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
float & x) const
float & x, bool cleared) const
{
Painter & pain = bv->painter();
int i, j, cell=0;
@ -158,8 +158,8 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
float cx;
UpdatableInset::draw(bv,font,baseline,x);
if (init_inset || (top_x != int(x)) || (top_baseline != baseline)) {
init_inset = false;
if ((need_update == INIT)|| (top_x != int(x)) || (top_baseline != baseline)) {
need_update = FULL;
top_x = int(x);
top_baseline = baseline;
resetPos(pain);
@ -172,35 +172,39 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
return;
}
}
bool dodraw;
x += ADD_TO_TABULAR_WIDTH;
for(i=0;i<tabular->rows();++i) {
nx = int(x);
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);
tabular->GetCellInset(cell)->draw(bv, font, baseline, cx);
DrawCellLines(pain, nx, baseline, i, cell);
nx += tabular->GetWidthOfColumn(cell);
++cell;
if (cleared || !locked || (need_update == FULL) || (need_update == CELL)) {
for(i=0;i<tabular->rows();++i) {
nx = int(x);
dodraw = ((baseline+tabular->GetDescentOfRow(i)) > 0) &&
(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))
tabular->GetCellInset(cell)->draw(bv, font,
baseline, cx,
cleared);
} 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);
}
baseline += tabular->GetDescentOfRow(i) + tabular->GetAscentOfRow(i+1)
+ tabular->GetAdditionalHeight(cell+1);
}
x += width(pain, font);
}
void InsetTabular::update(BufferView * bv, LyXFont const & font, bool dodraw)
{
if (the_locking_inset)
the_locking_inset->update(bv, font, dodraw);
if (init_inset) {
// calculate_dimensions_of_cells(bv, font, dodraw);
init_inset = calculate_dimensions_of_cells(bv, font, dodraw) || init_inset;
}
need_update = NONE;
}
@ -270,6 +274,26 @@ void InsetTabular::DrawCellSelection(Painter & pain, int x, int baseline,
}
void InsetTabular::update(BufferView * bv, LyXFont const & font, bool dodraw)
{
if (the_locking_inset)
the_locking_inset->update(bv, font, dodraw);
switch(need_update) {
case INIT:
case FULL:
case CELL:
if (calculate_dimensions_of_cells(bv, font, dodraw))
need_update = INIT;
break;
case SELECTION:
need_update = INIT;
break;
default:
break;
}
}
char const * InsetTabular::EditMessage() const
{
return _("Opened Tabular Inset");
@ -294,7 +318,7 @@ void InsetTabular::Edit(BufferView * bv, int x, int y, unsigned int button)
if (InsetHit(bv, x, y)) {
ActivateCellInset(bv, x, y, button);
}
UpdateLocal(bv, false, false);
UpdateLocal(bv, NONE, false);
// bv->getOwner()->getPopups().updateFormTabular();
}
@ -308,20 +332,21 @@ void InsetTabular::InsetUnlock(BufferView * bv)
}
HideInsetCursor(bv);
if (hasSelection()) {
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
UpdateLocal(bv, false, false);
sel_pos_start = sel_pos_end = 0;
sel_cell_start = sel_cell_end = 0;
UpdateLocal(bv, FULL, false);
}
no_selection = false;
oldcell = -1;
locked = false;
}
void InsetTabular::UpdateLocal(BufferView * bv, bool what, bool mark_dirty)
void InsetTabular::UpdateLocal(BufferView * bv, UpdateCodes what,
bool mark_dirty)
{
init_inset = what;
need_update = what;
bv->updateInset(this, mark_dirty);
if (what)
if (what != NONE)
resetPos(bv->painter());
}
@ -366,7 +391,7 @@ bool InsetTabular::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
the_locking_inset = 0;
if (lr)
moveRight(bv, false);
UpdateLocal(bv, true, false);
UpdateLocal(bv, CELL, false);
return true;
}
if (the_locking_inset->UnlockInsetInInset(bv, inset, lr)) {
@ -387,7 +412,7 @@ bool InsetTabular::UpdateInsetInInset(BufferView * bv, Inset * inset)
return false;
if (the_locking_inset != inset)
return the_locking_inset->UpdateInsetInInset(bv, inset);
UpdateLocal(bv, false, false);
UpdateLocal(bv, CELL, false);
return true;
}
@ -451,7 +476,7 @@ void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
{
if (hasSelection()) {
sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
UpdateLocal(bv, false, false);
UpdateLocal(bv, SELECTION, false);
}
no_selection = false;
@ -499,7 +524,7 @@ void InsetTabular::InsetMotionNotify(BufferView * bv, int x, int y, int button)
sel_pos_end = cursor.pos();
sel_cell_end = actcell;
if (old != sel_pos_end)
UpdateLocal(bv, false, false);
UpdateLocal(bv, SELECTION, false);
#if 0
if (ocell != actcell)
bview->getOwner()->getPopups().updateFormTabular();
@ -544,9 +569,8 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
if (result == DISPATCHED_NOUPDATE)
return result;
else if (result == DISPATCHED) {
bool upd = SetCellDimensions(bv->painter(), actcell, actrow);
the_locking_inset->ToggleInsetCursor(bv);
UpdateLocal(bv, upd, false);
UpdateLocal(bv, CELL, false);
the_locking_inset->ToggleInsetCursor(bv);
return result;
} else if (result == FINISHED) {
@ -581,14 +605,14 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
else
sel_cell_end = actcell;
}
UpdateLocal(bv, false, false);
UpdateLocal(bv, SELECTION, false);
break;
case LFUN_RIGHT:
result = moveRight(bv);
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
UpdateLocal(bv, false, false);
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_LEFTSEL:
if (tabular->IsFirstCellInRow(actcell) && cellstart(cursor.pos()))
@ -602,14 +626,14 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
else
sel_cell_end = actcell-1;
}
UpdateLocal(bv, false, false);
UpdateLocal(bv, SELECTION, false);
break;
case LFUN_LEFT:
result = moveLeft(bv);
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
UpdateLocal(bv, false, false);
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_DOWNSEL:
{
@ -621,7 +645,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
sel_cell_end = tabular->GetCellBelow(sel_cell_end);
else
sel_cell_end = tabular->GetLastCellBelow(sel_cell_end);
UpdateLocal(bv, false, false);
UpdateLocal(bv, SELECTION, false);
}
break;
case LFUN_DOWN:
@ -629,7 +653,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
UpdateLocal(bv, false, false);
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_UPSEL:
{
@ -641,7 +665,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
sel_cell_end = tabular->GetCellAbove(sel_cell_end);
else
sel_cell_end = tabular->GetLastCellAbove(sel_cell_end);
UpdateLocal(bv, false, false);
UpdateLocal(bv, SELECTION, false);
}
break;
case LFUN_UP:
@ -649,7 +673,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
UpdateLocal(bv, false, false);
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_BACKSPACE:
break;
@ -672,7 +696,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
UpdateLocal(bv, false, false);
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_LAYOUT_TABLE:
{
@ -885,28 +909,6 @@ void InsetTabular::resetPos(Painter & pain) const
}
bool InsetTabular::SetCellDimensions(Painter & pain, int cell, int row)
{
InsetText * inset = tabular->GetCellInset(cell);
LyXFont font(LyXFont::ALL_SANE);
int asc = inset->ascent(pain, font) + ADD_TO_HEIGHT;
int desc = inset->descent(pain, font) + ADD_TO_HEIGHT;
int maxAsc = tabular->GetAscentOfRow(row);
int maxDesc = tabular->GetDescentOfRow(row);
bool ret = tabular->SetWidthOfCell(cell, inset->width(pain, font));
if (maxAsc < asc) {
ret = true;
tabular->SetAscentOfRow(row, asc);
}
if (maxDesc < desc) {
ret = true;
tabular->SetDescentOfRow(row, desc);
}
return ret;
}
UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
{
if (!cellstart(cursor.pos())) {
@ -1066,8 +1068,13 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
{
bool update = (tabular->GetPWidth(actcell) != val);
tabular->SetPWidth(actcell,val);
if (update)
UpdateLocal(bv, true, true);
if (update) {
for (int i=0; i < tabular->rows(); ++i) {
tabular->GetCellInset(tabular->GetCellNumber(i, column))->
deleteLyXText(bv);
}
UpdateLocal(bv, INIT, true);
}
}
break;
case LyXTabular::SET_SPECIAL_COLUMN:
@ -1078,34 +1085,34 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
// append the row into the tabular
UnlockInsetInInset(bv, the_locking_inset);
tabular->AppendRow(actcell);
UpdateLocal(bv, true, true);
UpdateLocal(bv, INIT, true);
break;
case LyXTabular::APPEND_COLUMN:
// append the column into the tabular
tabular->AppendColumn(actcell);
actcell = tabular->GetCellNumber(row, column);
UpdateLocal(bv, true, true);
UpdateLocal(bv, INIT, true);
break;
case LyXTabular::DELETE_ROW:
tabular->DeleteRow(tabular->row_of_cell(actcell));
if ((row+1) > tabular->rows())
--row;
actcell = tabular->GetCellNumber(row, column);
UpdateLocal(bv, true, true);
UpdateLocal(bv, INIT, true);
break;
case LyXTabular::DELETE_COLUMN:
tabular->DeleteColumn(tabular->column_of_cell(actcell));
if ((column+1) > tabular->columns())
--column;
actcell = tabular->GetCellNumber(row, column);
UpdateLocal(bv, true, true);
UpdateLocal(bv, INIT, true);
break;
case LyXTabular::TOGGLE_LINE_TOP:
lineSet = !tabular->TopLine(actcell);
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);
UpdateLocal(bv, true, true);
UpdateLocal(bv, INIT, true);
break;
case LyXTabular::TOGGLE_LINE_BOTTOM:
@ -1113,7 +1120,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
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);
UpdateLocal(bv, true, true);
UpdateLocal(bv, INIT, true);
break;
case LyXTabular::TOGGLE_LINE_LEFT:
@ -1121,7 +1128,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
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);
UpdateLocal(bv, true, true);
UpdateLocal(bv, INIT, true);
break;
case LyXTabular::TOGGLE_LINE_RIGHT:
@ -1129,7 +1136,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
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);
UpdateLocal(bv, true, true);
UpdateLocal(bv, INIT, true);
break;
case LyXTabular::ALIGN_LEFT:
case LyXTabular::ALIGN_RIGHT:
@ -1137,7 +1144,10 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
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);
UpdateLocal(bv, true, true);
if (hasSelection())
UpdateLocal(bv, INIT, true);
else
UpdateLocal(bv, CELL, true);
break;
case LyXTabular::MULTICOLUMN:
{
@ -1152,10 +1162,10 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
// check wether we are completly in a multicol
if (tabular->IsMultiColumn(actcell)) {
tabular->UnsetMultiColumn(actcell);
UpdateLocal(bv, true, true);
UpdateLocal(bv, INIT, true);
} else {
tabular->SetMultiColumn(actcell, 1);
UpdateLocal(bv, false, true);
UpdateLocal(bv, CELL, true);
}
return;
}
@ -1176,7 +1186,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
cursor.pos(0);
sel_cell_end = sel_cell_start;
sel_pos_end = sel_pos_start;
UpdateLocal(bv, true, true);
UpdateLocal(bv, INIT, true);
break;
}
case LyXTabular::SET_ALL_LINES:
@ -1185,15 +1195,15 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
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);
UpdateLocal(bv, true, true);
UpdateLocal(bv, INIT, true);
break;
case LyXTabular::SET_LONGTABULAR:
tabular->SetLongTabular(true);
UpdateLocal(bv, true, true); // because this toggles displayed
UpdateLocal(bv, INIT, true); // because this toggles displayed
break;
case LyXTabular::UNSET_LONGTABULAR:
tabular->SetLongTabular(false);
UpdateLocal(bv, true, true); // because this toggles displayed
UpdateLocal(bv, INIT, true); // because this toggles displayed
break;
case LyXTabular::SET_ROTATE_TABULAR:
tabular->SetRotateTabular(true);
@ -1257,7 +1267,7 @@ bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button,
inset->Edit(bv, x - inset_x, y - inset_y, button);
if (!the_locking_inset)
return false;
UpdateLocal(bv, true, false);
UpdateLocal(bv, CELL, false);
return true;
}

View File

@ -61,6 +61,15 @@ class Buffer;
class InsetTabular : public UpdatableInset {
public:
///
enum UpdateCodes {
NONE = 0,
INIT,
FULL,
CELL,
CURSOR,
SELECTION
};
///
InsetTabular(Buffer *, int rows=1, int columns=1);
///
@ -80,7 +89,7 @@ public:
///
int width(Painter &, LyXFont const & f) const;
///
void draw(BufferView *, const LyXFont &, int , float &) const;
void draw(BufferView *, const LyXFont &, int , float &, bool) const;
///
void update(BufferView *, LyXFont const &, bool);
///
@ -92,7 +101,7 @@ public:
///
void InsetUnlock(BufferView *);
///
void UpdateLocal(BufferView *, bool what, bool mark_dirty);
void UpdateLocal(BufferView *, UpdateCodes, bool mark_dirty);
///
bool LockInsetInInset(BufferView *, UpdatableInset *);
///
@ -166,8 +175,6 @@ private:
///
void setPos(Painter &, int x, int y) const;
///
bool SetCellDimensions(Painter & pain, int cell, int row);
///
UpdatableInset::RESULT moveRight(BufferView *, bool lock=true);
UpdatableInset::RESULT moveLeft(BufferView *, bool lock=true);
UpdatableInset::RESULT moveUp(BufferView *);
@ -216,6 +223,6 @@ private:
actrow;
bool no_selection;
mutable bool locked;
mutable bool init_inset;
mutable UpdateCodes need_update;
};
#endif

View File

@ -205,16 +205,21 @@ int InsetText::width(Painter &, LyXFont const &) const
return insetWidth;
}
int InsetText::textWidth(Painter & pain) const
{
return getMaxTextWidth(pain, this) - drawTextXOffset;
}
void InsetText::draw(BufferView * bv, LyXFont const & f,
int baseline, float & x) const
int baseline, float & x, bool cleared) const
{
Painter & pain = bv->painter();
xpos = x;
UpdatableInset::draw(bv, f, baseline, x);
if (locked && ((need_update==FULL) || (top_x!=int(x)) ||
if (!cleared && locked && ((need_update==FULL) || (top_x!=int(x)) ||
(top_baseline!=baseline))) {
need_update = NONE;
top_x = int(x);
@ -235,11 +240,16 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset;
}
if (need_update == CURSOR) {
x += width(pain, f);
need_update = NONE;
return;
}
x += TEXT_TO_INSET_OFFSET; // place for border
long int y = 0;
Row * row = TEXT(bv)->GetRowNearY(y);
y += baseline - row->ascent_of_text() + 1;
if (!locked || (need_update == FULL)) {
if (cleared || !locked || (need_update == FULL)) {
while (row != 0) {
TEXT(bv)->GetVisibleRow(bv, y, x, row, y);
y += row->height();
@ -252,9 +262,15 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
bv->screen()->Update(TEXT(bv), y, x);
locked = true;
}
TEXT(bv)->refresh_y = 0;
TEXT(bv)->status = LyXText::UNCHANGED;
if (drawLockedFrame && locked) {
pain.rectangle(top_x, baseline - ascent(pain, f), width(pain, f),
ascent(pain,f) + descent(pain, f), frame_color);
} else {
pain.rectangle(top_x, baseline - ascent(pain, f), width(pain, f),
ascent(pain,f) + descent(pain, f),
LColor::background);
}
x += width(pain, f) - TEXT_TO_INSET_OFFSET;
need_update = NONE;
@ -269,16 +285,18 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool dodraw)
deleteLyXText(bv);
need_update = FULL;
}
if (dodraw)
if (dodraw && (need_update != CURSOR))
need_update = FULL;
TEXT(bv)->FullRebreak(bv);
long int y_temp = 0;
Row * row = TEXT(bv)->GetRowNearY(y_temp);
insetAscent = row->ascent_of_text() + 2;
insetDescent = TEXT(bv)->height - row->ascent_of_text() + 2;
insetWidth = max(getMaxTextWidth(bv->painter(), this), TEXT(bv)->width);
insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
insetDescent = TEXT(bv)->height - row->ascent_of_text() +
TEXT_TO_INSET_OFFSET;
insetWidth = max(textWidth(bv->painter()), TEXT(bv)->width) +
(2 * TEXT_TO_INSET_OFFSET);
}
@ -300,6 +318,8 @@ void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button)
locked = true;
the_locking_inset = 0;
inset_pos = inset_x = inset_y = 0;
#warning Fix cursor setting here!!! (Jug)
TEXT(bv)->SetCursor(bv, par, 0);
// setPos(bv->painter(), x, y);
checkAndActivateInset(bv, x, y, button);
// selection_start_cursor = selection_end_cursor = cursor;
@ -397,8 +417,6 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
UpdateLocal(bv, FULL, false);
}
no_selection = false;
// setPos(bv->painter(), x, y);
// cursor.x_fix(-1);
TEXT(bv)->SetCursorFromCoordinates(bv, x, y+TEXT(bv)->first);
if (the_locking_inset) {
UpdatableInset * inset = 0;
@ -575,7 +593,7 @@ InsetText::LocalDispatch(BufferView * bv,
result = moveRight(bv);
TEXT(bv)->selection = 0;
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR_PAR, false);
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_LEFTSEL:
bv->text->FinishUndo();
@ -588,7 +606,7 @@ InsetText::LocalDispatch(BufferView * bv,
result= moveLeft(bv);
TEXT(bv)->selection = 0;
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR_PAR, false);
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_DOWNSEL:
bv->text->FinishUndo();
@ -601,7 +619,7 @@ InsetText::LocalDispatch(BufferView * bv,
result = moveDown(bv);
TEXT(bv)->selection = 0;
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR_PAR, false);
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_UPSEL:
bv->text->FinishUndo();
@ -614,20 +632,20 @@ InsetText::LocalDispatch(BufferView * bv,
result = moveUp(bv);
TEXT(bv)->selection = 0;
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR_PAR, false);
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_HOME:
bv->text->FinishUndo();
TEXT(bv)->CursorHome(bv);
TEXT(bv)->selection = 0;
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR_PAR, false);
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_END:
TEXT(bv)->CursorEnd(bv);
TEXT(bv)->selection = 0;
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR_PAR, false);
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_BACKSPACE:
bv->text->SetUndo(bv->buffer(), Undo::DELETE,
@ -913,8 +931,12 @@ void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
void InsetText::UpdateLocal(BufferView * bv, UpdateCodes what, bool mark_dirty)
{
need_update = what;
bv->updateInset(this, mark_dirty);
if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
need_update = FULL;
else
need_update = what;
if ((need_update != CURSOR) || (TEXT(bv)->status != LyXText::UNCHANGED))
bv->updateInset(this, mark_dirty);
if (old_par != cpar(bv)) {
bv->owner()->getToolbar()->combox->select(cpar(bv)->GetLayout()+1);
old_par = cpar(bv);

View File

@ -45,6 +45,7 @@ public:
INIT,
FULL,
CURSOR_PAR,
CURSOR,
SELECTION
};
///
@ -71,7 +72,9 @@ public:
///
int width(Painter &, LyXFont const & f) const;
///
void draw(BufferView *, LyXFont const &, int , float &) const;
int textWidth(Painter &) const;
///
void draw(BufferView *, LyXFont const &, int , float &, bool) const;
///
void update(BufferView *, LyXFont const &, bool =false);
///

View File

@ -116,7 +116,7 @@ public:
virtual int width(Painter &, LyXFont const &) const = 0;
///
virtual void draw(BufferView *, LyXFont const &,
int baseline, float & x) const = 0;
int baseline, float & x, bool cleared) const = 0;
/// update the inset representation
virtual void update(BufferView *, LyXFont const &, bool =false)
{}

View File

@ -215,7 +215,7 @@ int LyXFunc::processKeyEvent(XEvent * ev)
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
} else {
tli->UnlockInsetInInset(owner->view(),
tli->GetLockingInset());
tli->GetLockingInset(),true);
}
return 0;
}

View File

@ -31,6 +31,7 @@ class LyXBuffer;
class TexRow;
struct LaTeXFeatures;
class InsetBibKey;
class BufferView;
/// A LyXParagraph holds all text, attributes and insets in a text paragraph
class LyXParagraph {
@ -195,7 +196,9 @@ public:
///
Inset * InInset() { return inset_owner; }
///
void SetInsetOwner(Inset * i) { inset_owner = i; }
void SetInsetOwner(Inset * i);
///
void deleteInsetsLyXText(BufferView *);
private:
///
TextContainer text;

View File

@ -610,7 +610,7 @@ private:
///
void draw(BufferView *, Row const * row,
LyXParagraph::size_type & pos,
int offset, float & x);
int offset, float & x, bool cleared);
/// get the next breakpoint in a given paragraph
LyXParagraph::size_type NextBreakPoint(BufferView *, Row const * row,

View File

@ -404,7 +404,7 @@ int InsetFormula::width(Painter &, LyXFont const & f) const
void InsetFormula::draw(BufferView * bv, LyXFont const & f,
int baseline, float & x) const
int baseline, float & x, bool) const
{
Painter & pain = bv->painter();
// Seems commenting out solves a problem.

View File

@ -47,7 +47,7 @@ public:
///
int width(Painter &, LyXFont const &) const;
///
void draw(BufferView *,LyXFont const &, int baseline, float & x) const;
void draw(BufferView *,LyXFont const &, int, float &, bool) const;
///
void Write(Buffer const *, std::ostream &) const;
///

View File

@ -147,14 +147,14 @@ int InsetFormulaMacro::width(Painter & pain, LyXFont const & f) const
void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
int baseline, float & x) const
int baseline, float & x, bool cleared) const
{
Painter & pain = bv->painter();
LyXFont font(f);
tmacro->update();
if (opened) {
tmacro->setEditMode(true);
InsetFormula::draw(bv, font, baseline, x);
InsetFormula::draw(bv, font, baseline, x, cleared);
tmacro->setEditMode(false);
} else {
font.setColor(LColor::math);

View File

@ -43,7 +43,7 @@ public:
///
int width(Painter &, LyXFont const &) const;
///
void draw(BufferView *,LyXFont const &, int baseline, float & x) const;
void draw(BufferView *,LyXFont const &, int, float &, bool) const;
///
void Read(Buffer const *, LyXLex & lex);
///

View File

@ -29,10 +29,12 @@
#include "LaTeXFeatures.h"
#include "insets/insetinclude.h"
#include "insets/insetbib.h"
#include "insets/insettext.h"
#include "support/filetools.h"
#include "lyx_gui_misc.h"
#include "texrow.h"
#include "support/lyxmanip.h"
#include "BufferView.h"
using std::ostream;
using std::endl;
@ -4373,3 +4375,29 @@ string LyXParagraph::String(Buffer const * buffer,
return s;
}
void LyXParagraph::SetInsetOwner(Inset *i)
{
inset_owner = i;
for (InsetList::const_iterator cit = insetlist.begin();
cit != insetlist.end(); ++cit) {
if ((*cit).inset)
(*cit).inset->setOwner(i);
}
}
void LyXParagraph::deleteInsetsLyXText(BufferView * bv)
{
// then the insets
for (InsetList::const_iterator cit = insetlist.begin();
cit != insetlist.end(); ++cit) {
if ((*cit).inset) {
if ((*cit).inset->IsTextInset()) {
static_cast<InsetText *>((*cit).inset)->
deleteLyXText(bv);
}
}
}
}

View File

@ -54,51 +54,8 @@ LyXTabular::cellstruct::cellstruct()
bottom_line = false;
rotate = false;
linebreaks = false;
#ifdef INSET_POINTER
inset = 0;
#endif
}
#ifdef INSET_POINTER
LyXTabular::cellstruct::~cellstruct()
{
delete inset;
}
LyXTabular::cellstruct::cellstruct(cellstruct const & cs)
{
cellno = cs.cellno;
width_of_cell = cs.width_of_cell;
multicolumn = cs.multicolumn;
alignment = cs.alignment;
top_line = cs.top_line;
bottom_line = cs.bottom_line;
rotate = cs.rotate;
linebreaks = cs.linebreaks;
inset = cs.inset;
#if 0
if (cs.inset)
inset = static_cast<InsetText *>(cs.inset->Clone());
#endif
}
LyXTabular::cellstruct &
LyXTabular::cellstruct::operator=(cellstruct const & cs)
{
cellno = cs.cellno;
width_of_cell = cs.width_of_cell;
multicolumn = cs.multicolumn;
alignment = cs.alignment;
top_line = cs.top_line;
bottom_line = cs.bottom_line;
rotate = cs.rotate;
linebreaks = cs.linebreaks;
if (cs.inset)
inset = static_cast<InsetText *>(cs.inset->Clone());
return *this;
}
#endif
LyXTabular::rowstruct::rowstruct()
{
@ -186,12 +143,7 @@ LyXTabular * LyXTabular::Clone(InsetTabular * inset)
int i,j;
for(i=0; i < rows_; ++i) {
for(j=0; j < columns_; ++j) {
#ifdef INSET_POINTER
delete result->cell_info[i][j].inset;
result->cell_info[i][j].inset=new InsetText(*cell_info[i][j].inset);
#else
result->cell_info[i][j].inset = cell_info[i][j].inset;
#endif
result->cell_info[i][j].inset.setOwner(inset);
}
}
@ -215,10 +167,6 @@ void LyXTabular::Init(int rows_arg, int columns_arg)
// Jürgen, use iterators.
for (i = 0; i < rows_; ++i) {
for (j = 0; j < columns_; ++j) {
#ifdef INSET_POINTER
if (!cell_info[i][j].inset)
cell_info[i][j].inset = new InsetText();
#endif
cell_info[i][j].inset.setOwner(owner_);
cell_info[i][j].inset.SetDrawLockedFrame(true);
cell_info[i][j].cellno = cellno++;
@ -255,7 +203,7 @@ void LyXTabular::AppendRow(int cell )
row_vector::iterator rit = row_info.begin() + row;
row_info.insert(rit, rowstruct());
#if 1
#if 0
cell_vvector::iterator cit = cell_info.begin() + row;
cell_info.insert(cit, vector<cellstruct>(columns_, cellstruct()));
#else
@ -273,14 +221,6 @@ void LyXTabular::AppendRow(int cell )
}
}
cell_info = c_info;
#ifdef INSET_POINTER
for(int i = 0; i < rows_; ++i) {
for(int j = 0; j < columns_; ++j) {
if (!cell_info[i][j].inset)
cell_info[i][j].inset = static_cast<InsetText *>(c_info[i][j].inset->Clone());
}
}
#endif
++row;
for (int j = 0; j < columns_; ++j) {
cell_info[row][j].inset.clear();
@ -329,13 +269,6 @@ void LyXTabular::AppendColumn(int cell)
}
}
cell_info = c_info;
#ifdef INSET_POINTER
for(i = 0; i < rows_; ++i) {
for(j = 0; j < columns_; ++j) {
cell_info[i][j].inset = static_cast<InsetText *>(c_info[i][j].inset->Clone());
}
}
#endif
++column;
for (i = 0; i < rows_; ++i) {
cell_info[i][column].inset.clear();

View File

@ -117,12 +117,7 @@ bool is_nikud(unsigned char c)
int LyXText::workWidth(BufferView * bview) const
{
if (inset_owner) {
#if 1
return inset_owner->getMaxWidth(bview->painter(), inset_owner);
#else
LyXFont font(LyXFont::ALL_SANE);
return inset_owner->width(bview->painter(), font);
#endif
return inset_owner->textWidth(bview->painter());
}
return bview->workWidth();
}
@ -445,7 +440,7 @@ bool LyXText::IsBoundary(Buffer const * buf, LyXParagraph * par,
void LyXText::draw(BufferView * bview, Row const * row,
LyXParagraph::size_type & vpos,
int offset, float & x)
int offset, float & x, bool cleared)
{
Painter & pain = bview->painter();
@ -567,7 +562,8 @@ void LyXText::draw(BufferView * bview, Row const * row,
} else if (c == LyXParagraph::META_INSET) {
Inset const * tmpinset = row->par()->GetInset(pos);
if (tmpinset) {
tmpinset->draw(bview, font, offset+row->baseline(), x);
tmpinset->draw(bview, font, offset+row->baseline(), x,
cleared);
}
++vpos;
@ -3794,10 +3790,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
// clear the area where we want to paint/print
int ww;
if (inset_owner)
ww = inset_owner->width(bview->painter(), font) - 1;
else
ww = bview->workWidth();
ww = bview->workWidth();
bool clear_area = true;
@ -3807,8 +3800,14 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
{
clear_area = row_ptr->par()->GetInset(row_ptr->pos())->doClearArea();
}
if (clear_area)
pain.fillRectangle(x_offset, y_offset, ww, row_ptr->height());
if (clear_area) {
int w;
if (inset_owner)
w = inset_owner->width(bview->painter(), font);
else
w = ww;
pain.fillRectangle(x_offset, y_offset, w, row_ptr->height());
}
if (selection) {
/* selection code */
@ -4324,7 +4323,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
- row_ptr->par()->bibkey->width(bview->painter(), font);
row_ptr->par()->bibkey->draw(bview, font,
y_offset + row_ptr->baseline(),
tmpx);
tmpx, clear_area);
}
}
@ -4528,7 +4527,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
row_ptr->par(), pos);
++vpos;
} else
draw(bview, row_ptr, vpos, y_offset, x);
draw(bview, row_ptr, vpos, y_offset, x, clear_area);
}
/* do not forget the very last cell. This has no NEWLINE so
@ -4640,7 +4639,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
x += fill_separator;
++vpos;
} else
draw(bview, row_ptr, vpos, y_offset, x);
draw(bview, row_ptr, vpos, y_offset, x, clear_area);
}
#ifndef NEW_TABULAR
}

View File

@ -69,7 +69,8 @@ void LyXText::init()
lastrow = 0;
number_of_rows = 0;
refresh_y = 0;
height = width = 0;
height = 0;
width = -1;
first = 0;
status = LyXText::UNCHANGED;
// set cursor at the very top position
@ -131,7 +132,7 @@ void LyXText::init(BufferView * bview)
par = par->Next();
}
SetCursorIntern(bview, firstrow->par(), 0);
#if 1
#if 0
// Dump all rowinformation:
Row * tmprow = firstrow;
lyxerr << "Width = " << width << endl;