+2001-04-13 Juergen Vigna <jug@sad.it>
+
+ * tabular.C (GetAdditionalHeight): changed parameter from cell to row.
+ (LyXTabular): tried to minimize operator= operations (and realized
+ hopfully Lars wish).
+
2001-04-12 Dekel Tsur <dekelts@tau.ac.il>
* LaTeX.C (deplog): Always check that foundfile exists.
+2001-04-13 Juergen Vigna <jug@sad.it>
+
+ * insettext.C: tried to avoid unneeded redraws.
+ (doClearArea): return true also if I need a FULL|INIT redraw.
+
+ * insettabular.C: tried to avoid unneeded redraws. Still one
+ problem with scrolling remains (resetPos).
+ (doClearArea): return true also if I need a FULL|INIT redraw.
+
+ * lyxinset.h: changed the scroll() function behaviour a bit.
+ Added nodraw() function so that I can block unneeded redraws.
+ Implemented the above 2 functions correctly in InsetText,
+ InsetTabular and InsetCollapsable. Now only the topmost Inset
+ owner is scrolled (as it should be) if a child inset requests this!
+
2001-04-06 John Levon <moz@compsoc.man.ac.uk>
* insetexternal.h:
void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool )
{}
-
void UpdatableInset::scroll(BufferView * bv, float s) const
{
LyXFont font;
if ((tmp_top_x + scx + width(bv, font)) < (workW / 2)) {
scx += (workW / 2) - (tmp_top_x + scx + width(bv, font));
}
- // bv->updateInset(const_cast<UpdatableInset *>(this), false);
+
+// bv->updateInset(const_cast<UpdatableInset *>(this), false);
}
void UpdatableInset::scroll(BufferView * bv, int offset) const
scx += offset;
}
}
- // bv->updateInset(const_cast<UpdatableInset *>(this), false);
+// bv->updateInset(const_cast<UpdatableInset *>(this), false);
}
}
-void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
- int baseline, float & x, bool cleared) const
+void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
+ int baseline, float & x, bool cleared) const
{
+ if (nodraw())
+ return;
+
Painter & pain = bv->painter();
button_length = widthCollapsed;
return;
}
+ float old_x = x;
+
+#if 0
+ UpdatableInset::draw(bv, f, baseline, x, cleared);
+#else
+ if (!owner())
+ x += (float)scroll();
+#endif
if (!cleared && (inset.need_update == InsetText::FULL ||
inset.need_update == InsetText::INIT ||
top_x != int(x) ||
- top_baseline != baseline)) {
+ top_baseline != baseline))
+ {
+#if 1
+ // we don't need anymore to clear here we just have to tell
+ // the underlying LyXText that it should do the RowClear!
+ inset.SetUpdateStatus(bv, InsetText::FULL);
+ bv->text->status = LyXText::CHANGED_IN_DRAW;
+ return;
+#else
int w = owner() ? width(bv, f) : pain.paperWidth();
int h = ascent(bv, f) + descent(bv, f);
int const tx = (needFullRow() && !owner()) ? 0 : int(x);
h += (baseline - ascent(bv, f));
pain.fillRectangle(tx, ty - 1, w, h + 2);
cleared = true;
+#endif
}
top_x = int(x);
top_baseline = baseline;
- float dummy = x;
int const bl = baseline - ascent(bv, f) + ascent_collapsed(pain, f);
- draw_collapsed(pain, f, bl, dummy);
+ draw_collapsed(pain, f, bl, old_x);
inset.draw(bv, f,
bl + descent_collapsed(pain, f) + inset.ascent(bv, f),
x, cleared);
collapsed = true;
}
inset.InsetUnlock(bv);
+ if (scroll())
+ scroll(bv, 0.0F);
bv->updateInset(this, false);
}
bv->unlockInset(this);
return true;
}
- return inset.UnlockInsetInInset(bv, in, lr);
+ bool ret = inset.UnlockInsetInInset(bv, in, lr);
+ return ret;
}
{
return inset.getLabelList();
}
+
+bool InsetCollapsable::nodraw() const
+{
+ return inset.nodraw();
+}
+
+int InsetCollapsable::scroll(bool recursive) const
+{
+ int sx = UpdatableInset::scroll(false);
+
+ if (recursive)
+ sx += inset.scroll(recursive);
+
+ return sx;
+}
void resizeLyXText(BufferView *) const;
///
std::vector<string> const getLabelList() const;
+ ///
+ bool nodraw() const;
+ ///
+ int scroll(bool recursive=true) const;
+ void scroll(BufferView *bv, float sx) const {
+ UpdatableInset::scroll(bv, sx);
+ }
+ void scroll(BufferView *bv, int offset) const {
+ UpdatableInset::scroll(bv, offset);
+ }
+
protected:
///
int ascent_collapsed(Painter &, LyXFont const &) const;
actrow = actcell = 0;
clearSelection();
need_update = INIT;
- no_draw = false;
}
actrow = actcell = 0;
sel_cell_start = sel_cell_end = 0;
need_update = INIT;
- no_draw = false;
}
void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
float & x, bool cleared) const
{
- if (no_draw)
+ if (nodraw())
return;
-
+ if (bv->text->status == LyXText::CHANGED_IN_DRAW)
+ return;
+
+// lyxerr << "InsetTabular::draw(" << need_update << ")\n";
+
Painter & pain = bv->painter();
int i;
int j;
int nx;
-
+
+#if 0
UpdatableInset::draw(bv, font, baseline, x, cleared);
+#else
+ if (!owner())
+ x += (float)scroll();
+#endif
if (!cleared && ((need_update == INIT) || (need_update == FULL) ||
(top_x != int(x)) || (top_baseline != baseline))) {
int h = ascent(bv, font) + descent(bv, font);
}
top_x = int(x);
top_baseline = baseline;
- if (bv->text->status == LyXText::CHANGED_IN_DRAW)
- return;
- bool dodraw;
x += ADD_TO_TABULAR_WIDTH;
if (cleared) {
int cell = 0;
first_visible_cell = -1;
for (i = 0; i < tabular->rows(); ++i) {
nx = int(x);
- dodraw = ((baseline + tabular->GetDescentOfRow(i)) > 0) &&
- (baseline - tabular->GetAscentOfRow(i))<pain.paperHeight();
+ cell = tabular->GetCellNumber(i, 0);
+ if (!((baseline + tabular->GetDescentOfRow(i)) > 0) &&
+ (baseline - tabular->GetAscentOfRow(i))<pain.paperHeight())
+ {
+ baseline += tabular->GetDescentOfRow(i) +
+ tabular->GetAscentOfRow(i + 1) +
+ tabular->GetAdditionalHeight(i + 1);
+ continue;
+ }
for (j = 0; j < tabular->columns(); ++j) {
+ if (nx > bv->workWidth())
+ break;
if (tabular->IsPartOfMultiColumn(i, j))
continue;
cx = nx + tabular->GetBeginningOfTextInCell(cell);
- if (dodraw) {
- if (first_visible_cell < 0)
- first_visible_cell = cell;
- if (hasSelection())
- DrawCellSelection(pain, nx, baseline, i, j, cell);
- tabular->GetCellInset(cell)->draw(bv, font, baseline, cx,
- cleared);
- DrawCellLines(pain, nx, baseline, i, cell);
- }
+ if (first_visible_cell < 0)
+ first_visible_cell = cell;
+ if (hasSelection())
+ DrawCellSelection(pain, nx, baseline, i, j, cell);
+ 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);
+ tabular->GetAdditionalHeight(i + 1);
}
} else if (need_update == CELL) {
int cell = 0;
nx = int(x);
- if (the_locking_inset) {
+ if (the_locking_inset &&
+ tabular->GetCellInset(actcell) != the_locking_inset)
+ {
Inset * inset = tabular->GetCellInset(cell);
for (i = 0;
inset != the_locking_inset && i < tabular->rows();
nx = int(x);
baseline += tabular->GetDescentOfRow(i) +
tabular->GetAscentOfRow(i + 1) +
- tabular->GetAdditionalHeight(cell);
+ tabular->GetAdditionalHeight(i + 1);
}
}
} else {
- for (i = 0;
- cell < actcell && i < tabular->rows(); ++i) {
- for (j = 0; (cell < actcell) && (j < tabular->columns()); ++j) {
- if (tabular->IsPartOfMultiColumn(i, j))
+ // copute baseline for actual row
+ for (i = 0; i < actrow; ++i) {
+ baseline += tabular->GetDescentOfRow(i) +
+ tabular->GetAscentOfRow(i + 1) +
+ tabular->GetAdditionalHeight(i + 1);
+ }
+ // now compute the right x position
+ cell = tabular->GetCellNumber(actrow, 0);
+ for (j = 0; (cell < actcell) && (j < tabular->columns()); ++j) {
+ if (tabular->IsPartOfMultiColumn(actrow, j))
continue;
nx += tabular->GetWidthOfColumn(cell);
++cell;
- }
- if (tabular->row_of_cell(cell) > i) {
- nx = int(x);
- baseline += tabular->GetDescentOfRow(i) +
- tabular->GetAscentOfRow(i + 1) +
- tabular->GetAdditionalHeight(cell);
- }
}
}
i = tabular->row_of_cell(cell);
owner()->update(bv, font, true);
return;
}
- if (the_locking_inset) {
+ if (the_locking_inset)
the_locking_inset->update(bv, font, reinit);
-// resetPos(bv);
-// inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
-// inset_y = cursor.y();
- }
+
switch (need_update) {
case INIT:
case FULL:
no_selection = false;
oldcell = -1;
locked = false;
- if (scroll() || hasSelection()) {
+ if (scroll(false) || hasSelection()) {
sel_cell_start = sel_cell_end = 0;
- if (scroll()) {
+ if (scroll(false)) {
scroll(bv, 0.0F);
}
UpdateLocal(bv, FULL, false);
if (the_locking_inset == inset) {
the_locking_inset->InsetUnlock(bv);
the_locking_inset = 0;
- UpdateLocal(bv, CELL, false);
+ if (scroll(false))
+ scroll(bv, 0.0F);
+ else
+ UpdateLocal(bv, CELL, false);
ShowInsetCursor(bv, false);
return true;
}
sel_cell_start = sel_cell_end = actcell;
if (hs)
UpdateLocal(bv, SELECTION, false);
- ShowInsetCursor(bv);
+ if (!the_locking_inset) {
+ ShowInsetCursor(bv);
+ return DISPATCHED_NOUPDATE;
+ }
return result;
}
// this to avoid compiler warnings.
result = UNDISPATCHED;
if (the_locking_inset)
break;
- no_draw = true;
+ nodraw(true);
if (ActivateCellInset(bv)) {
result = the_locking_inset->LocalDispatch(bv, action, arg);
if ((result == UNDISPATCHED) || (result == FINISHED)) {
UnlockInsetInInset(bv, the_locking_inset);
- no_draw = false;
+ nodraw(false);
the_locking_inset = 0;
return UNDISPATCHED;
}
- no_draw = false;
- the_locking_inset->ToggleInsetCursor(bv);
+ nodraw(false);
+// the_locking_inset->ToggleInsetCursor(bv);
UpdateLocal(bv, CELL, false);
- the_locking_inset->ToggleInsetCursor(bv);
+// the_locking_inset->ToggleInsetCursor(bv);
return result;
}
break;
int const desc = lyxfont::maxDescent(font);
bv->fitLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
if (show)
- bv->showLockedInsetCursor(cursor.x(), cursor.y(),
- asc, desc);
+ bv->showLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
setCursorVisible(true);
}
}
// 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,
- actcol)));
+ cursor.y(cursor.y() + tabular->GetDescentOfRow(actrow) +
+ tabular->GetAscentOfRow(actrow + 1) +
+ tabular->GetAdditionalHeight(actrow + 1));
++actrow;
ly = cursor.y() + tabular->GetDescentOfRow(actrow);
}
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(actrow + 1));
++actrow;
}
}
new_x += offset;
cursor.x(new_x);
// cursor.x(getCellXPos(actcell) + offset);
- if (scroll() && (tabular->GetWidthOfTabular() < bv->workWidth()-20))
+ if (scroll(false) && (tabular->GetWidthOfTabular() < bv->workWidth()-20)) {
scroll(bv, 0.0F);
- else if (the_locking_inset &&
+ UpdateLocal(bv, FULL, false);
+ } else if (the_locking_inset &&
(tabular->GetWidthOfColumn(actcell) > bv->workWidth()-20)) {
int xx = cursor.x() - offset + bv->text->GetRealCursorX(bv);
if (xx > (bv->workWidth()-20))
xx = 60;
scroll(bv, xx);
}
+ UpdateLocal(bv, FULL, false);
} else if ((cursor.x() - offset) > 20 &&
(cursor.x() - offset + tabular->GetWidthOfColumn(actcell))
> (bv->workWidth() - 20)) {
} else if ((cursor.x() - offset) < 20) {
scroll(bv, 20 - cursor.x() + offset);
UpdateLocal(bv, FULL, false);
- } else if (scroll() && top_x > 20 &&
+ } else if (scroll(false) && top_x > 20 &&
(top_x + tabular->GetWidthOfTabular()) > (bv->workWidth() - 20)) {
scroll(bv, old_x - cursor.x());
+ UpdateLocal(bv, FULL, false);
}
if ((!the_locking_inset ||
!the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE)) &&
{
return bv->getParentLanguage(this)->RightToLeft();
}
+
+bool InsetTabular::nodraw() const
+{
+ if (the_locking_inset)
+ return the_locking_inset->nodraw();
+ return UpdatableInset::nodraw();
+}
+
+int InsetTabular::scroll(bool recursive) const
+{
+ int sx = UpdatableInset::scroll(false);
+
+ if (recursive && the_locking_inset)
+ sx += the_locking_inset->scroll(recursive);
+
+ return sx;
+}
+
+bool InsetTabular::doClearArea() const
+{
+ return !locked || (need_update & (FULL|INIT));
+}
+/* Emacs:
+ * Local variables:
+ * tab-width: 4
+ * End:
+ * vi:set tabstop=4:
+ */
///
void Edit(BufferView *, int x, int y, unsigned int);
///
- bool doClearArea() const { return !locked; };
+ bool doClearArea() const;
///
void InsetUnlock(BufferView *);
///
LyXFunc::func_status getStatus(string const & argument) const;
///
std::vector<string> const getLabelList() const;
+ ///
+ void nodraw(bool b) {
+ UpdatableInset::nodraw(b);
+ }
+ bool nodraw() const;
+ ///
+ int scroll(bool recursive=true) const;
+ void scroll(BufferView *bv, float sx) const {
+ UpdatableInset::scroll(bv, sx);
+ }
+ void scroll(BufferView *bv, int offset) const {
+ UpdatableInset::scroll(bv, offset);
+ }
+
//
// Public structures and variables
///
///
bool no_selection;
///
- bool no_draw;
- ///
mutable bool locked;
///
mutable UpdateCodes need_update;
drawTextXOffset = 0;
drawTextYOffset = 0;
autoBreakRows = false;
- drawFrame = NEVER;
+ drawFrame_ = NEVER;
xpos = 0.0;
if (ins) {
- SetParagraphData(ins->par);
- autoBreakRows = ins->autoBreakRows;
- drawFrame = ins->drawFrame;
+ SetParagraphData(ins->par);
+ autoBreakRows = ins->autoBreakRows;
+ drawFrame_ = ins->drawFrame_;
}
par->SetInsetOwner(this);
frame_color = LColor::insetframe;
locked = false;
old_par = 0;
last_drawn_width = -1;
+ frame_is_visible = false;
}
void InsetText::draw(BufferView * bv, LyXFont const & f,
- int baseline, float & x, bool cleared) const
+ int baseline, float & x, bool cleared) const
{
+ if (nodraw())
+ return;
+
Painter & pain = bv->painter();
// no draw is necessary !!!
- if ((drawFrame == LOCKED) && !locked && !par->size()) {
- if (!cleared && (need_update & CLEAR_FRAME)) {
- pain.rectangle(top_x + 1, baseline - insetAscent + 1,
- width(bv, f) - 1,
- insetAscent + insetDescent - 1,
- LColor::background);
- }
+ if ((drawFrame_ == LOCKED) && !locked && !par->size()) {
top_x = int(x);
top_baseline = baseline;
x += width(bv, f);
+ if (!cleared && (need_update & CLEAR_FRAME))
+ clearFrame(pain, cleared);
need_update = NONE;
return;
}
xpos = x;
+#if 0
UpdatableInset::draw(bv, f, baseline, x, cleared);
-
+#else
+ if (!owner())
+ x += (float)scroll();
+#endif
// update insetWidth and insetHeight with dummy calls
(void)ascent(bv, f);
(void)descent(bv, f);
// if top_x differs we have a rule down and we don't have to clear anything
if (!cleared && (top_x == int(x)) &&
- ((need_update == INIT) || (need_update == FULL) || (top_baseline != baseline) ||
- (last_drawn_width!=insetWidth))) {
+ ((need_update&(INIT|FULL)) || (top_baseline!=baseline) ||
+ (last_drawn_width!=insetWidth)))
+ {
int w = insetWidth;
int h = insetAscent + insetDescent;
int ty = baseline - insetAscent;
return;
if (top_x != int(x)) {
- need_update = INIT;
+ need_update |= INIT;
top_x = int(x);
bv->text->status = LyXText::CHANGED_IN_DRAW;
return;
}
+
+// lyxerr << "InsetText::draw[" << this << "](" << need_update << ":" << int(x) << ":" << top_x << ")\n";
+
if (cleared || (last_drawn_width != insetWidth)) {
need_update |= FULL;
last_drawn_width = insetWidth;
inset_y = cy(bv) + drawTextYOffset;
}
if (!cleared && (need_update == CURSOR) && !TEXT(bv)->selection) {
+ drawFrame(pain, cleared);
x += width(bv, f);
need_update = NONE;
return;
x += TEXT_TO_INSET_OFFSET;
#warning Jürgen, why is this a block of its own? (Lgb)
+#warning because you told me to define variables only in local contest (Jug)!
{
int y = 0;
Row * row = TEXT(bv)->GetRowNearY(y);
if (y_offset < 0)
y_offset = y;
TEXT(bv)->first = first;
- if (cleared) { // (need_update&FULL) || (need_update&INIT)
+ if (cleared) {
int yf = y_offset;
y = 0;
while ((row != 0) && (yf < ph)) {
TEXT(bv)->refresh_y = 0;
TEXT(bv)->status = LyXText::UNCHANGED;
if ((need_update != CURSOR_PAR) &&
- ((drawFrame == ALWAYS) || ((drawFrame == LOCKED) && locked)))
- {
- pain.rectangle(top_x + 1, baseline - insetAscent + 1,
- width(bv, f) - 1,
- insetAscent + insetDescent - 1,
- frame_color);
- } else if (need_update & CLEAR_FRAME) {
- pain.rectangle(top_x + 1, baseline - insetAscent + 1,
- width(bv, f) - 1,
- insetAscent + insetDescent - 1,
- LColor::background);
- }
+ ((drawFrame_ == ALWAYS) || ((drawFrame_ == LOCKED) && locked)))
+ drawFrame(pain, cleared);
+ else if (need_update & CLEAR_FRAME)
+ clearFrame(pain, cleared);
x += width(bv, f) - TEXT_TO_INSET_OFFSET;
if (bv->text->status==LyXText::CHANGED_IN_DRAW) {
- need_update = INIT;
+ need_update |= INIT;
} else if (need_update != INIT)
need_update = NONE;
}
+void InsetText::drawFrame(Painter & pain, bool cleared) const
+{
+ if (!frame_is_visible || cleared) {
+ pain.rectangle(top_x + 1, top_baseline - insetAscent + 1,
+ insetWidth - 1, insetAscent + insetDescent - 1,
+ frame_color);
+ frame_is_visible = true;
+ }
+}
+
+
+void InsetText::clearFrame(Painter & pain, bool cleared) const
+{
+ if (frame_is_visible) {
+ if (!cleared) {
+ pain.rectangle(top_x + 1, top_baseline - insetAscent + 1,
+ insetWidth - 1, insetAscent + insetDescent - 1,
+ LColor::background);
+ }
+ frame_is_visible = false;
+ }
+}
+
+
void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
{
- if (reinit) { // && (need_update != CURSOR)) {
- need_update = INIT;
+ if (reinit) {
+ need_update |= INIT;
resizeLyXText(bv);
if (owner())
owner()->update(bv, font, true);
inset_y = cy(bv) + drawTextYOffset;
the_locking_inset->update(bv, font, reinit);
}
+#if 0
if (need_update == INIT) {
resizeLyXText(bv);
- need_update = FULL;
+ need_update |= FULL;
}
+#endif
int oldw = insetWidth;
-#if 1
insetWidth = TEXT(bv)->width + (2 * TEXT_TO_INSET_OFFSET);
- // max(textWidth(bv->painter()),
- // static_cast<int>(TEXT(bv)->width) + drawTextXOffset) +
- // (2 * TEXT_TO_INSET_OFFSET);
-#else
- insetWidth = textWidth(bv);
- if (insetWidth < 0)
- insetWidth = static_cast<int>(TEXT(bv)->width);
-#endif
if (oldw != insetWidth) {
-// printf("TW(%p): %d-%d-%d-%d\n",this,insetWidth, oldw,
-// textWidth(bv->painter()),static_cast<int>(TEXT(bv)->width));
resizeLyXText(bv);
- need_update = FULL;
- update(bv, font, reinit);
+ need_update |= FULL;
+// update(bv, font, reinit);
return;
}
- if ((need_update == CURSOR_PAR) && (TEXT(bv)->status == LyXText::UNCHANGED) &&
+ if ((need_update&CURSOR_PAR) && (TEXT(bv)->status==LyXText::UNCHANGED) &&
the_locking_inset)
{
TEXT(bv)->UpdateInset(bv, the_locking_inset);
}
if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
- need_update = FULL;
-
+ need_update |= FULL;
+#if 0
int y_temp = 0;
Row * row = TEXT(bv)->GetRowNearY(y_temp);
insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
insetDescent = TEXT(bv)->height - row->ascent_of_text() +
TEXT_TO_INSET_OFFSET;
+#endif
}
-void InsetText::SetUpdateStatus(BufferView * bv, int what)
+void InsetText::SetUpdateStatus(BufferView * bv, int what) const
{
need_update |= what;
if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
bv->text->FinishUndo();
ShowInsetCursor(bv);
- UpdateLocal(bv, FULL, false);
+ UpdateLocal(bv, CURSOR, false);
// If the inset is empty set the language of the current font to the
// language to the surronding text.
if (lr)
moveRight(bv, false);
old_par = 0; // force layout setting
- UpdateLocal(bv, CURSOR_PAR, false);
+ if (scroll())
+ scroll(bv, 0.0F);
+ else
+ UpdateLocal(bv, CURSOR, false);
return true;
}
return the_locking_inset->UnlockInsetInInset(bv, inset, lr);
inset->Edit(bv, x, y, 0);
if (!the_locking_inset)
return false;
- UpdateLocal(bv, CURSOR_PAR, false);
+ UpdateLocal(bv, CURSOR, false);
return true;
}
return false;
inset->Edit(bv, x - inset_x, y - inset_y, button);
if (!the_locking_inset)
return false;
- UpdateLocal(bv, CURSOR_PAR, false);
+ UpdateLocal(bv, CURSOR, false);
return true;
}
return false;
void InsetText::SetDrawFrame(BufferView * bv, DrawFrame how)
{
- if (how != drawFrame) {
- drawFrame = how;
+ if (how != drawFrame_) {
+ drawFrame_ = how;
if (bv)
UpdateLocal(bv, DRAW_FRAME, false);
}
}
}
}
+
+bool InsetText::nodraw() const
+{
+ if (the_locking_inset)
+ return the_locking_inset->nodraw();
+ return UpdatableInset::nodraw();
+}
+
+int InsetText::scroll(bool recursive) const
+{
+ int sx = UpdatableInset::scroll(false);
+
+ if (recursive && the_locking_inset)
+ sx += the_locking_inset->scroll(recursive);
+
+ return sx;
+}
+
+bool InsetText::doClearArea() const
+{
+ return !locked || (need_update & (FULL|INIT));
+}
+/* Emacs:
+ * Local variables:
+ * tab-width: 4
+ * End:
+ * vi:set tabstop=4:
+ */
///
void update(BufferView *, LyXFont const &, bool =false);
///
- void SetUpdateStatus(BufferView *, int what);
+ void SetUpdateStatus(BufferView *, int what) const;
///
string const EditMessage() const;
///
///
bool IsTextInset() const { return true; }
///
- bool doClearArea() const { return !locked; }
+ bool doClearArea() const;
///
void InsetUnlock(BufferView *);
///
///
std::vector<string> const getLabelList() const;
///
+ bool nodraw() const;
+ ///
+ int scroll(bool recursive=true) const;
+ void scroll(BufferView *bv, float sx) const {
+ UpdatableInset::scroll(bv, sx);
+ }
+ void scroll(BufferView *bv, int offset) const {
+ UpdatableInset::scroll(bv, offset);
+ }
+
LyXParagraph * par;
///
mutable int need_update;
///
bool autoBreakRows;
///
- DrawFrame drawFrame;
+ DrawFrame drawFrame_;
///
LColor::color frame_color;
///
bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
int button = 0);
+ ///
void removeNewlines();
-
///
int cx(BufferView *) const;
///
bool cboundary(BufferView *) const;
///
Row * crow(BufferView *) const;
-
+ ///
/// This instead of a macro
LyXText * TEXT(BufferView * bv) const {
return getLyXText(bv);
}
+ ///
+ void drawFrame(Painter &, bool cleared) const;
+ void clearFrame(Painter &, bool cleared) const;
+ ///
/* Private structures and variables */
///
mutable Cache cache;
///
mutable int last_drawn_width;
+ ///
+ mutable bool frame_is_visible;
};
#endif
///
virtual void resizeLyXText(BufferView *) const {}
/// returns the actuall scroll-value
- int scroll() const { return scx; }
+ virtual int scroll(bool recursive=true) const {
+ if (!recursive || !owner_)
+ return scx;
+ return 0;
+ }
+
protected:
///
mutable int top_x;
///
- UpdatableInset() : cursor_visible_(false) {}
+ UpdatableInset() : cursor_visible_(false), block_drawing_(false) {}
///
virtual EDITABLE Editable() const;
///
virtual int getMaxWidth(BufferView * bv, UpdatableInset const *) const;
///
- int scroll() const {
+ int scroll(bool recursive=true) const {
// We need this method to not clobber the real method in Inset
- return Inset::scroll();
+ return Inset::scroll(recursive);
}
///
virtual bool ShowInsetDialog(BufferView *) const { return false; }
+ ///
+ virtual void nodraw(bool b) {
+ block_drawing_ = b;
+ }
+ ///
+ virtual bool nodraw() const {
+ return block_drawing_;
+ }
+
protected:
///
void toggleCursorVisible() const {
void scroll(BufferView *, float sx) const;
/// scrolls offset pixels
void scroll(BufferView *, int offset) const;
+
private:
///
mutable bool cursor_visible_;
+ ///
+ bool block_drawing_;
};
#endif
}
selection_possible = false;
-
+
if (owner->view()->available())
owner->view()->hideCursor();
string ps_command;
/// option for telling the dvi viewer about the paper size
string view_dvi_paper_option;
- /// default paper size for local xdvi/dvips/ghostview/whatever
- BufferParams::PAPER_SIZE default_papersize;
+ /// default paper size for local xdvi/dvips/ghostview/whatever
+ BufferParams::PAPER_SIZE default_papersize;
/// command to run chktex incl. options
string chktex_command;
///
LyXTabular::LyXTabular(InsetTabular * inset, LyXTabular const & lt)
{
owner_ = inset;
- Init(lt.rows_, lt.columns_);
+ Init(lt.rows_, lt.columns_, <);
+#if 0
#ifdef WITH_WARNINGS
#warning Jürgen, can you make it the other way round. So that copy assignment depends on the copy constructor and not the other way. (Lgb)
#endif
operator=(lt);
+#endif
}
LyXTabular * LyXTabular::Clone(InsetTabular * inset)
{
LyXTabular * result = new LyXTabular(inset, *this);
+#if 0
// don't know if this is good but I need to Clone also
// the text-insets here, this is for the Undo-facility!
for (int i = 0; i < rows_; ++i) {
result->cell_info[i][j].inset.setOwner(inset);
}
}
+#endif
return result;
}
/* activates all lines and sets all widths to 0 */
-void LyXTabular::Init(int rows_arg, int columns_arg)
+void LyXTabular::Init(int rows_arg, int columns_arg, LyXTabular const * lt)
{
rows_ = rows_arg;
columns_ = columns_arg;
column_info = column_vector(columns_, columnstruct());
cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct()));
+ if (lt) {
+ operator=(*lt);
+ return;
+ }
+
int cellno = 0;
for (int i = 0; i < rows_; ++i) {
for (int j = 0; j < columns_; ++j) {
bool LyXTabular::TopAlreadyDrawed(int cell) const
{
- if (GetAdditionalHeight(cell))
- return false;
int row = row_of_cell(cell);
- if (row > 0) {
+ if ((row > 0) && !GetAdditionalHeight(row)) {
int column = column_of_cell(cell);
--row;
while (column
}
-int LyXTabular::GetAdditionalHeight(int cell) const
+int LyXTabular::GetAdditionalHeight(int row) const
{
- int const row = row_of_cell(cell);
- if (!row) return 0;
+ if (!row || row >= rows_)
+ return 0;
bool top = true;
bool bottom = true;
bool LyXTabular::SetAlignSpecial(int cell, string const & special,
- LyXTabular::Feature what)
+ LyXTabular::Feature what)
{
if (what == SET_SPECIAL_MULTI)
cellinfo_of_cell(cell)->align_special = special;
for (int row = 0; row < rows_; ++row)
height += GetAscentOfRow(row) + GetDescentOfRow(row) +
- GetAdditionalHeight(GetCellNumber(row, 0));
+ GetAdditionalHeight(row);
return height;
}
return BOX_NONE;
}
#endif
+/* Emacs:
+ * Local variables:
+ * tab-width: 4
+ * End:
+ * vi:set tabstop=4:
+ */
bool IsLastRow(int cell) const;
///
- int GetAdditionalHeight(int cell) const;
+ int GetAdditionalHeight(int row) const;
///
int GetAdditionalWidth(int cell) const;
InsetTabular * owner_;
///
- void Init(int columns_arg, int rows_arg);
+ void Init(int columns_arg, int rows_arg, LyXTabular const * lt = 0);
///
void Reinit();
///
int LyXText::Fill(BufferView * bview, Row * row, int paper_width) const
{
if (paper_width < 0)
- return 0;
+ return 20;
int w;
// get the pure distance
}
int const fill = paper_width - w - RightMargin(bview->buffer(), row);
+ if (fill < 0)
+ return 0;
return fill;
}
tmpfont = GetFont(bview->buffer(), row_ptr->par(), pos);
tmpinset = row_ptr->par()->GetInset(pos);
if (tmpinset) {
- tmpinset->update(bview, tmpfont);
+// tmpinset->update(bview, tmpfont);
asc = tmpinset->ascent(bview, tmpfont);
desc = tmpinset->descent(bview, tmpfont);
maxwidth += tmpinset->width(bview, tmpfont);