+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
}
+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)
{
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;
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();
///
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;
///
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
///
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
void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
- int baseline, float & x) const
+ int baseline, float & x, bool cleared) const
{
Painter & pain = bv->painter();
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);
}
///
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);
///
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;
///
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;
///
void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
- int baseline, float & x) const
+ int baseline, float & x, bool) const
{
Painter & pain = bv->painter();
///
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);
///
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);
///
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;
///
void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font,
- int baseline, float & x) const
+ int baseline, float & x, bool) const
{
Painter & pain = bv->painter();
///
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;
///
void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
- int baseline, float & x) const
+ int baseline, float & x, bool) const
{
string text = DispString();
///
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);
///
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);
///
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
actcell = 0;
cursor.pos(0);
sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
- init_inset = true;
+ need_update = INIT;
}
actcell = 0;
cursor.pos(0);
sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
- init_inset = true;
+ need_update = INIT;
}
delete tabular;
tabular = new LyXTabular(buf, this, lex);
- init_inset = true;
+ need_update = INIT;
if (old_format)
return;
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;
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);
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;
}
}
+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");
if (InsetHit(bv, x, y)) {
ActivateCellInset(bv, x, y, button);
}
- UpdateLocal(bv, false, false);
+ UpdateLocal(bv, NONE, false);
// bv->getOwner()->getPopups().updateFormTabular();
}
}
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());
}
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)) {
return false;
if (the_locking_inset != inset)
return the_locking_inset->UpdateInsetInInset(bv, inset);
- UpdateLocal(bv, false, false);
+ UpdateLocal(bv, CELL, false);
return true;
}
{
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;
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();
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) {
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()))
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:
{
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:
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:
{
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:
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;
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:
{
}
-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())) {
{
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:
// 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:
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:
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:
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:
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:
{
// 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;
}
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:
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);
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;
}
class InsetTabular : public UpdatableInset {
public:
+ ///
+ enum UpdateCodes {
+ NONE = 0,
+ INIT,
+ FULL,
+ CELL,
+ CURSOR,
+ SELECTION
+ };
///
InsetTabular(Buffer *, int rows=1, int columns=1);
///
///
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);
///
///
void InsetUnlock(BufferView *);
///
- void UpdateLocal(BufferView *, bool what, bool mark_dirty);
+ void UpdateLocal(BufferView *, UpdateCodes, bool mark_dirty);
///
bool LockInsetInInset(BufferView *, UpdatableInset *);
///
///
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 *);
actrow;
bool no_selection;
mutable bool locked;
- mutable bool init_inset;
+ mutable UpdateCodes need_update;
};
#endif
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);
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();
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;
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);
}
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;
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;
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();
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();
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();
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,
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);
INIT,
FULL,
CURSOR_PAR,
+ CURSOR,
SELECTION
};
///
///
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);
///
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)
{}
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
} else {
tli->UnlockInsetInInset(owner->view(),
- tli->GetLockingInset());
+ tli->GetLockingInset(),true);
}
return 0;
}
class TexRow;
struct LaTeXFeatures;
class InsetBibKey;
+class BufferView;
/// A LyXParagraph holds all text, attributes and insets in a text paragraph
class LyXParagraph {
///
Inset * InInset() { return inset_owner; }
///
- void SetInsetOwner(Inset * i) { inset_owner = i; }
+ void SetInsetOwner(Inset * i);
+ ///
+ void deleteInsetsLyXText(BufferView *);
private:
///
TextContainer text;
///
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,
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.
///
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;
///
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);
///
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);
///
#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;
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);
+ }
+ }
+ }
+}
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()
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);
}
}
// 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++;
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
}
}
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();
}
}
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();
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();
}
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();
} 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;
// 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;
{
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 */
- row_ptr->par()->bibkey->width(bview->painter(), font);
row_ptr->par()->bibkey->draw(bview, font,
y_offset + row_ptr->baseline(),
- tmpx);
+ tmpx, clear_area);
}
}
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
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
}
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
par = par->Next();
}
SetCursorIntern(bview, firstrow->par(), 0);
-#if 1
+#if 0
// Dump all rowinformation:
Row * tmprow = firstrow;
lyxerr << "Width = " << width << endl;