14 files changed:
2000-06-22 Juergen Vigna <jug@sad.it>
2000-06-22 Juergen Vigna <jug@sad.it>
+ * src/lyxscreen.h: added some y_offset/x_offset parameters for drawings
+ of insets and moved first to LyXText.
+
* src/mathed/formulamacro.[Ch]:
* src/mathed/formula.[Ch]: changed prototype of draw() and GetCursorPos
* src/mathed/formulamacro.[Ch]:
* src/mathed/formula.[Ch]: changed prototype of draw() and GetCursorPos
text->SetCursor(this, cursor,
cursor.par(), cursor.pos() - 1);
y += cursor.y() + the_locking_inset->InsetInInsetY();
text->SetCursor(this, cursor,
cursor.par(), cursor.pos() - 1);
y += cursor.y() + the_locking_inset->InsetInInsetY();
- pimpl_->screen_->ShowManualCursor(x, y, asc, desc,
- LyXScreen::BAR_SHAPE);
+ pimpl_->screen_->ShowManualCursor(text, x, y, asc, desc,
+ LyXScreen::BAR_SHAPE);
updateScreen();
updateScrollbar();
}
updateScreen();
updateScrollbar();
}
- screen_->first = screen_->TopCursorVisible(bv_->text);
+ bv_->text->first = screen_->TopCursorVisible(bv_->text);
redraw();
owner_->getDialogs()->updateBufferDependent();
bv_->insetWakeup();
redraw();
owner_->getDialogs()->updateBufferDependent();
bv_->insetWakeup();
bv_->text->selection = false;
}
}
bv_->text->selection = false;
}
}
- screen_->first = screen_->TopCursorVisible(bv_->text);
+ bv_->text->first = screen_->TopCursorVisible(bv_->text);
/* this will scroll the
* screen such that the
* cursor becomes
/* this will scroll the
* screen such that the
* cursor becomes
unsigned long cbth = 0;
long cbsf = 0;
unsigned long cbth = 0;
long cbsf = 0;
cbth = bv_->text->height;
cbth = bv_->text->height;
- if (screen_)
- cbsf = screen_->first;
+ cbsf = bv_->text->first;
+ }
// check if anything has changed.
if (max2 == cbth &&
// check if anything has changed.
if (max2 == cbth &&
LyXText * vbt = bv_->text;
unsigned int height = vbt->DefaultHeight();
LyXText * vbt = bv_->text;
unsigned int height = vbt->DefaultHeight();
- if (vbt->cursor.y() < screen_->first + height) {
+ if (vbt->cursor.y() < bv_->text->first + height) {
vbt->SetCursorFromCoordinates(bv_, 0,
vbt->SetCursorFromCoordinates(bv_, 0,
height);
} else if (vbt->cursor.y() >
height);
} else if (vbt->cursor.y() >
- screen_->first + workarea_->height() - height) {
+ bv_->text->first + workarea_->height() - height) {
vbt->SetCursorFromCoordinates(bv_, 0,
vbt->SetCursorFromCoordinates(bv_, 0,
workarea_->height() -
height);
}
workarea_->height() -
height);
}
bv_->the_locking_inset->
InsetMotionNotify(bv_,
x - cursor.x(),
bv_->the_locking_inset->
InsetMotionNotify(bv_,
x - cursor.x(),
- y - cursor.y() + screen_->first,
+ y - cursor.y() + bv_->text->first,
if (selection_possible) {
screen_->HideCursor();
if (selection_possible) {
screen_->HideCursor();
- bv_->text->SetCursorFromCoordinates(bv_, x, y + screen_->first);
+ bv_->text->SetCursorFromCoordinates(bv_, x, y + bv_->text->first);
if (!bv_->text->selection)
update(BufferView::UPDATE); // Maybe an empty line was deleted
if (!bv_->text->selection)
update(BufferView::UPDATE); // Maybe an empty line was deleted
// Right button mouse click on a table
if (button == 3 &&
(bv_->text->cursor.par()->table ||
// Right button mouse click on a table
if (button == 3 &&
(bv_->text->cursor.par()->table ||
- bv_->text->MouseHitInTable(bv_, xpos, ypos + screen_->first))) {
+ bv_->text->MouseHitInTable(bv_, xpos, ypos + bv_->text->first))) {
// Set the cursor to the press-position
// Set the cursor to the press-position
- bv_->text->SetCursorFromCoordinates(bv_, xpos, ypos + screen_->first);
+ bv_->text->SetCursorFromCoordinates(bv_, xpos, ypos + bv_->text->first);
bool doit = true;
// Only show the table popup if the hit is in
bool doit = true;
// Only show the table popup if the hit is in
- int screen_first = screen_->first;
+ int screen_first = bv_->text->first;
// Middle button press pastes if we have a selection
bool paste_internally = false;
// Middle button press pastes if we have a selection
bool paste_internally = false;
int box_x = 20; // LYX_PAPER_MARGIN;
box_x += lyxfont::width(" wide-tab ", font);
int box_x = 20; // LYX_PAPER_MARGIN;
box_x += lyxfont::width(" wide-tab ", font);
- unsigned int screen_first = screen_->first;
+ unsigned int screen_first = bv_->text->first;
if (x < box_x
&& y + screen_first > bv_->text->cursor.y() -
if (x < box_x
&& y + screen_first > bv_->text->cursor.y() -
- unsigned int y_tmp = y + screen_->first;
+ unsigned int y_tmp = y + bv_->text->first;
LyXCursor cursor;
bv_->text->SetCursorFromCoordinates(bv_, cursor, x, y_tmp);
LyXCursor cursor;
bv_->text->SetCursorFromCoordinates(bv_, cursor, x, y_tmp);
{
if (!bv_->text->cursor.row()->previous()) return;
{
if (!bv_->text->cursor.row()->previous()) return;
- long y = screen_->first;
+ long y = bv_->text->first;
Row * cursorrow = bv_->text->cursor.row();
bv_->text->SetCursorFromCoordinates(bv_, bv_->text->cursor.x_fix(), y);
bv_->text->FinishUndo();
Row * cursorrow = bv_->text->cursor.row();
bv_->text->SetCursorFromCoordinates(bv_, bv_->text->cursor.x_fix(), y);
bv_->text->FinishUndo();
{
if (!bv_->text->cursor.row()->next()) return;
{
if (!bv_->text->cursor.row()->next()) return;
- long y = screen_->first;
+ long y = bv_->text->first;
bv_->text->GetRowNearY(y);
Row * cursorrow = bv_->text->cursor.row();
bv_->text->SetCursorFromCoordinates(bv_, bv_->text->cursor.x_fix(), y
bv_->text->GetRowNearY(y);
Row * cursorrow = bv_->text->cursor.row();
bv_->text->SetCursorFromCoordinates(bv_, bv_->text->cursor.x_fix(), y
int i, j, cell=0;
int nx;
float cx;
int i, j, cell=0;
int nx;
float cx;
UpdatableInset::draw(bv,font,baseline,x);
if (init_inset || (top_x != int(x)) || (top_baseline != baseline)) {
UpdatableInset::draw(bv,font,baseline,x);
if (init_inset || (top_x != int(x)) || (top_baseline != baseline)) {
init_inset = false;
top_x = int(x);
top_baseline = baseline;
init_inset = false;
top_x = int(x);
top_baseline = baseline;
-// if (ox != top_x)
-// recomputeTextInsets(pain, font);
-// calculate_width_of_cells(pain, font);
+ if (locked) { // repaint this way as the background was not cleared
+ if (the_locking_inset)
+ the_locking_inset->update(bv, font, true);
+ locked = false;
+ bv->updateInset(const_cast<InsetTabular*>(this), false);
+ locked = true;
+ return;
+ }
}
x += ADD_TO_TABULAR_WIDTH;
for(i=0;i<tabular->rows();++i) {
}
x += ADD_TO_TABULAR_WIDTH;
for(i=0;i<tabular->rows();++i) {
void InsetTabular::update(BufferView * bv, LyXFont const & font, bool dodraw)
{
void InsetTabular::update(BufferView * bv, LyXFont const & font, bool dodraw)
{
+ if (the_locking_inset)
+ the_locking_inset->update(bv, font, dodraw);
- calculate_width_of_cells(bv, font, dodraw);
-// recomputeTextInsets(bv, font);
+// calculate_dimensions_of_cells(bv, font, dodraw);
+ init_inset = calculate_dimensions_of_cells(bv, font, dodraw) || init_inset;
if (InsetHit(bv, x, y)) {
ActivateCellInset(bv, x, y, button);
}
if (InsetHit(bv, x, y)) {
ActivateCellInset(bv, x, y, button);
}
- UpdateLocal(bv, true, false);
+ UpdateLocal(bv, false, false);
// bv->getOwner()->getPopups().updateFormTabular();
}
// bv->getOwner()->getPopups().updateFormTabular();
}
void InsetTabular::UpdateLocal(BufferView * bv, bool what, bool mark_dirty)
{
void InsetTabular::UpdateLocal(BufferView * bv, bool what, bool mark_dirty)
{
-// if (what)
-// calculate_width_of_cells(bv->painter(), LyXFont(LyXFont::ALL_SANE));
init_inset = what;
bv->updateInset(this, mark_dirty);
if (what)
init_inset = what;
bv->updateInset(this, mark_dirty);
if (what)
the_locking_inset = 0;
if (lr)
moveRight(bv, false);
the_locking_inset = 0;
if (lr)
moveRight(bv, false);
+ UpdateLocal(bv, true, false);
return true;
}
if (the_locking_inset->UnlockInsetInInset(bv, inset, lr)) {
return true;
}
if (the_locking_inset->UnlockInsetInInset(bv, inset, lr)) {
return false;
if (the_locking_inset != inset)
return the_locking_inset->UpdateInsetInInset(bv, inset);
return false;
if (the_locking_inset != inset)
return the_locking_inset->UpdateInsetInInset(bv, inset);
- UpdateLocal(bv, true, false);
+ UpdateLocal(bv, false, false);
-void InsetTabular::calculate_width_of_cells(BufferView * bv,
- LyXFont const & font, bool dodraw) const
+bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv,
+ LyXFont const & font,
+ bool dodraw) const
{
int cell = -1;
int maxAsc, maxDesc;
InsetText * inset;
{
int cell = -1;
int maxAsc, maxDesc;
InsetText * inset;
for(int i = 0; i < tabular->rows(); ++i) {
maxAsc = maxDesc = 0;
for(int i = 0; i < tabular->rows(); ++i) {
maxAsc = maxDesc = 0;
inset->update(bv, font, dodraw);
maxAsc = max(maxAsc, inset->ascent(bv->painter(), font));
maxDesc = max(maxDesc, inset->descent(bv->painter(), font));
inset->update(bv, font, dodraw);
maxAsc = max(maxAsc, inset->ascent(bv->painter(), font));
maxDesc = max(maxDesc, inset->descent(bv->painter(), font));
- tabular->SetWidthOfCell(cell, inset->width(bv->painter(), font));
+ changed = tabular->SetWidthOfCell(cell, inset->width(bv->painter(), font)) || changed;
- tabular->SetAscentOfRow(i, maxAsc + ADD_TO_HEIGHT);
- tabular->SetDescentOfRow(i, maxDesc + ADD_TO_HEIGHT);
+ changed = tabular->SetAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed;
+ changed = tabular->SetDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed;
-void InsetTabular::SetFont(BufferView *, LyXFont const &, bool)
+void InsetTabular::SetFont(BufferView * bv, LyXFont const & font, bool tall)
+ if (the_locking_inset)
+ the_locking_inset->SetFont(bv, font, tall);
LyXTabular * tabular;
private:
LyXTabular * tabular;
private:
- void calculate_width_of_cells(BufferView *, LyXFont const &, bool =false) const;
+ bool calculate_dimensions_of_cells(BufferView *, LyXFont const &, bool =false) const;
///
void DrawCellLines(Painter &, int x, int baseline, int row, int cell)
const;
///
void DrawCellLines(Painter &, int x, int baseline, int row, int cell)
const;
- bool
- locked,
- no_selection;
- mutable bool
- init_inset;
+ bool no_selection;
+ mutable bool locked;
+ mutable bool init_inset;
xpos = x;
UpdatableInset::draw(bv, f, baseline, x);
xpos = x;
UpdatableInset::draw(bv, f, baseline, x);
+ if (locked && ((need_update==FULL) || (top_x!=int(x)) ||
+ (top_baseline!=baseline))) {
+ need_update = NONE;
+ top_x = int(x);
+ top_baseline = baseline;
+ locked = false;
+ bv->updateInset(const_cast<InsetText *>(this), false);
+ locked = true;
+ if (drawLockedFrame)
+ pain.rectangle(top_x, baseline - ascent(pain, f),
+ width(pain, f), ascent(pain,f)+descent(pain, f),
+ frame_color);
+ return;
+ }
top_baseline = baseline;
top_x = int(x);
top_baseline = baseline;
top_x = int(x);
y += row->height();
row = row->next();
}
y += row->height();
row = row->next();
}
- if (drawLockedFrame && locked) {
+ } else if (need_update == SELECTION) {
+ bv->screen()->ToggleToggle(getLyXText(bv), y, x);
+ } else {
+ locked = false;
+ bv->screen()->Update(TEXT(bv), y, x);
+ locked = true;
+ }
+ if (drawLockedFrame && locked) {
pain.rectangle(top_x, baseline - ascent(pain, f), width(pain, f),
ascent(pain,f) + descent(pain, f), frame_color);
pain.rectangle(top_x, baseline - ascent(pain, f), width(pain, f),
ascent(pain,f) + descent(pain, f), frame_color);
- }
- } else {
- bv->screen()->Update(TEXT(bv));
}
x += width(pain, f) - TEXT_TO_INSET_OFFSET;
}
x += width(pain, f) - TEXT_TO_INSET_OFFSET;
-void InsetText::update(BufferView * bv, LyXFont const &, bool dodraw)
+void InsetText::update(BufferView * bv, LyXFont const & font, bool dodraw)
+ if (the_locking_inset)
+ the_locking_inset->update(bv, font, dodraw);
if (need_update == INIT) {
deleteLyXText(bv);
need_update = FULL;
}
if (need_update == INIT) {
deleteLyXText(bv);
need_update = FULL;
}
+ if (dodraw)
+ need_update = FULL;
-#if 0
- switch(need_update) {
- case NONE: // most common first
- break;
- case INIT:
- need_update = NONE;
- break;
- case CURSOR_PAR:
- need_update = NONE;
- break;
- case FULL:
- TEXT(bv)->FullRebreak(bv);
- need_update = NONE;
- break;
- default:
- need_update = NONE;
- break;
- }
-#endif
TEXT(bv)->FullRebreak(bv);
long int y_temp = 0;
TEXT(bv)->FullRebreak(bv);
long int y_temp = 0;
no_selection = false;
// setPos(bv->painter(), x, y);
// cursor.x_fix(-1);
no_selection = false;
// setPos(bv->painter(), x, y);
// cursor.x_fix(-1);
- TEXT(bv)->SetCursorFromCoordinates(bv, x, y+bv->screen()->first);
+ TEXT(bv)->SetCursorFromCoordinates(bv, x, y+TEXT(bv)->first);
if (the_locking_inset) {
UpdatableInset * inset = 0;
if (cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET)
if (the_locking_inset) {
UpdatableInset * inset = 0;
if (cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET)
bv->text->FinishUndo();
moveRight(bv, false);
TEXT(bv)->SetSelection();
bv->text->FinishUndo();
moveRight(bv, false);
TEXT(bv)->SetSelection();
- UpdateLocal(bv, CURSOR_PAR, false);
+ UpdateLocal(bv, SELECTION, false);
break;
case LFUN_RIGHT:
bv->text->FinishUndo();
break;
case LFUN_RIGHT:
bv->text->FinishUndo();
bv->text->FinishUndo();
moveLeft(bv, false);
TEXT(bv)->SetSelection();
bv->text->FinishUndo();
moveLeft(bv, false);
TEXT(bv)->SetSelection();
- UpdateLocal(bv, CURSOR_PAR, false);
+ UpdateLocal(bv, SELECTION, false);
break;
case LFUN_LEFT:
bv->text->FinishUndo();
break;
case LFUN_LEFT:
bv->text->FinishUndo();
bv->text->FinishUndo();
moveDown(bv);
TEXT(bv)->SetSelection();
bv->text->FinishUndo();
moveDown(bv);
TEXT(bv)->SetSelection();
- UpdateLocal(bv, CURSOR_PAR, false);
+ UpdateLocal(bv, SELECTION, false);
break;
case LFUN_DOWN:
bv->text->FinishUndo();
break;
case LFUN_DOWN:
bv->text->FinishUndo();
bv->text->FinishUndo();
moveUp(bv);
TEXT(bv)->SetSelection();
bv->text->FinishUndo();
moveUp(bv);
TEXT(bv)->SetSelection();
- UpdateLocal(bv, CURSOR_PAR, false);
+ UpdateLocal(bv, SELECTION, false);
break;
case LFUN_UP:
bv->text->FinishUndo();
break;
case LFUN_UP:
bv->text->FinishUndo();
+ CURSOR_PAR,
+ SELECTION
/* Private structures and variables */
///
/* Private structures and variables */
///
///
int insetAscent;
int insetDescent;
///
int insetAscent;
int insetDescent;
///
void CursorToggle(LyXText const *);
///
///
void CursorToggle(LyXText const *);
///
- void ShowManualCursor(long x, long y, int asc, int desc,
+ void ShowManualCursor(LyXText const *, long x, long y, int asc, int desc,
Cursor_Shape shape);
/// returns 1 if first has changed, otherwise 0
bool FitManualCursor(LyXText *, long, long, int, int);
///
void ToggleSelection(LyXText *, bool = true);
///
Cursor_Shape shape);
/// returns 1 if first has changed, otherwise 0
bool FitManualCursor(LyXText *, long, long, int, int);
///
void ToggleSelection(LyXText *, bool = true);
///
- void ToggleToggle(LyXText *);
+ void ToggleToggle(LyXText *, int y_offset = 0, int x_offset = 0);
/** Updates part of the screen. If text->status is
LyXText::NEED_MORE_REFRESH, we update from the
point of change and to the end of the screen.
If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
we only update the current row. */
/** Updates part of the screen. If text->status is
LyXText::NEED_MORE_REFRESH, we update from the
point of change and to the end of the screen.
If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
we only update the current row. */
- void Update(LyXText *);
-
- /// first visible pixel-row
- unsigned long first;
+ void Update(LyXText *, int y_offset=0, int x_offset=0);
void expose(int x, int y, int exp_width, int exp_height);
/// y1 and y2 are coordinates of the screen
void expose(int x, int y, int exp_width, int exp_height);
/// y1 and y2 are coordinates of the screen
- void DrawFromTo(LyXText *, int y1, int y2);
+ void DrawFromTo(LyXText *, int y1, int y2, int y_offset=0, int x_offset=0);
/// y is a coordinate of the text
/// y is a coordinate of the text
- void DrawOneRow(LyXText *, Row * row, long y_text);
+ void DrawOneRow(LyXText *, Row * row, long y_text, int y_offset=0,
+ int x_offset=0);
- ///
- //LyXText * text;
-
///
Pixmap cursor_pixmap;
///
///
Pixmap cursor_pixmap;
///
mutable LyXFont current_font;
/// the current font
mutable LyXFont real_current_font;
mutable LyXFont current_font;
/// the current font
mutable LyXFont real_current_font;
+ /// first visible pixel-row is set from LyXScreen!!!
+ unsigned long first;
+ ///
+ BufferView * bv_owner;
+ ///
+ InsetText * inset_owner;
///
// void owner(BufferView *);
///
// void owner(BufferView *);
- BufferView * bv_owner;
- ///
- InsetText * inset_owner;
- ///
mutable Row * firstrow;
///
mutable Row * lastrow;
mutable Row * firstrow;
///
mutable Row * lastrow;
#include "WorkArea.h"
#include "buffer.h"
#include "font.h"
#include "WorkArea.h"
#include "buffer.h"
#include "font.h"
+#include "insets/insettext.h"
using std::max;
using std::min;
using std::max;
using std::min;
LyXScreen::LyXScreen(WorkArea & o) //, LyXText * text_ptr)
: owner(o) //, text(text_ptr)
{
LyXScreen::LyXScreen(WorkArea & o) //, LyXText * text_ptr)
: owner(o) //, text(text_ptr)
{
// the cursor isnt yet visible
cursor_visible = false;
cursor_pixmap = 0;
// the cursor isnt yet visible
cursor_visible = false;
cursor_pixmap = 0;
-void LyXScreen::DrawFromTo(LyXText * text, int y1, int y2)
+void LyXScreen::DrawFromTo(LyXText * text, int y1, int y2, int y_offset, int x_offset)
- long y_text = first + y1;
+ long y_text = text->first + y1;
// get the first needed row
Row * row = text->GetRowNearY(y_text);
// y_text is now the real beginning of the row
// get the first needed row
Row * row = text->GetRowNearY(y_text);
// y_text is now the real beginning of the row
- long y = y_text - first;
+ long y = y_text - text->first;
// y1 is now the real beginning of row on the screen
while (row != 0 && y < y2) {
// y1 is now the real beginning of row on the screen
while (row != 0 && y < y2) {
- text->GetVisibleRow(owner.owner(), y, 0, row, y + first);
+ text->GetVisibleRow(owner.owner(), y+y_offset, x_offset, row, y + text->first);
y += row->height();
row = row->next();
}
// maybe we have to clear the screen at the bottom
y += row->height();
row = row->next();
}
// maybe we have to clear the screen at the bottom
+ if ((y < y2) && text->bv_owner) {
owner.getPainter().fillRectangle(0, y,
owner.workWidth(),
y2 - y,
owner.getPainter().fillRectangle(0, y,
owner.workWidth(),
y2 - y,
-void LyXScreen::DrawOneRow(LyXText * text, Row * row, long y_text)
+void LyXScreen::DrawOneRow(LyXText * text, Row * row, long y_text,
+ int y_offset, int x_offset)
- long y = y_text - first;
+ long y = y_text - text->first + y_offset;
if (y + row->height() > 0
&& y - row->height() <= long(owner.height())) {
// ok there is something visible
if (y + row->height() > 0
&& y - row->height() <= long(owner.height())) {
// ok there is something visible
- text->GetVisibleRow(owner.owner(), y, 0, row, y + first);
+ text->GetVisibleRow(owner.owner(), y, x_offset, row, y + text->first);
{
if (cursor_visible) HideCursor();
{
if (cursor_visible) HideCursor();
- unsigned long old_first = first;
- first = y;
+ unsigned long old_first = text->first;
+ text->first = y;
// is any optimiziation possible?
if ((y - old_first) < owner.height()
&& (old_first - y) < owner.height()) {
// is any optimiziation possible?
if ((y - old_first) < owner.height()
&& (old_first - y) < owner.height()) {
- if (first < old_first) {
- DrawFromTo(text, 0, old_first - first);
+ if (text->first < old_first) {
+ DrawFromTo(text, 0, old_first - text->first);
XCopyArea (fl_display,
owner.getWin(),
owner.getWin(),
XCopyArea (fl_display,
owner.getWin(),
owner.getWin(),
owner.xpos(),
owner.ypos(),
owner.workWidth(),
owner.xpos(),
owner.ypos(),
owner.workWidth(),
- owner.height() - old_first + first,
+ owner.height() - old_first + text->first,
- owner.ypos() + old_first - first
+ owner.ypos() + old_first - text->first
);
// expose the area drawn
expose(0, 0,
owner.workWidth(),
);
// expose the area drawn
expose(0, 0,
owner.workWidth(),
+ old_first - text->first);
} else {
DrawFromTo(text,
} else {
DrawFromTo(text,
- owner.height() + old_first - first,
+ owner.height() + old_first - text->first,
owner.height());
XCopyArea (fl_display,
owner.getWin(),
owner.getWin(),
gc_copy,
owner.xpos(),
owner.height());
XCopyArea (fl_display,
owner.getWin(),
owner.getWin(),
gc_copy,
owner.xpos(),
- owner.ypos() + first - old_first,
+ owner.ypos() + text->first - old_first,
- owner.height() + old_first - first,
+ owner.height() + old_first - text->first,
owner.xpos(),
owner.ypos());
// expose the area drawn
owner.xpos(),
owner.ypos());
// expose the area drawn
- expose(0, owner.height() + old_first - first,
- owner.workWidth(), first - old_first);
+ expose(0, owner.height() + old_first - text->first,
+ owner.workWidth(), text->first - old_first);
}
} else {
// make a dumb new-draw
}
} else {
// make a dumb new-draw
!= owner.owner()->buffer()->params.language_info->RightToLeft())
shape = (text->real_current_font.isVisibleRightToLeft())
? REVERSED_L_SHAPE : L_SHAPE;
!= owner.owner()->buffer()->params.language_info->RightToLeft())
shape = (text->real_current_font.isVisibleRightToLeft())
? REVERSED_L_SHAPE : L_SHAPE;
- ShowManualCursor(text->cursor.x(), text->cursor.y(),
+ ShowManualCursor(text, text->cursor.x(), text->cursor.y(),
lyxfont::maxAscent(text->real_current_font),
lyxfont::maxDescent(text->real_current_font),
shape);
lyxfont::maxAscent(text->real_current_font),
lyxfont::maxDescent(text->real_current_font),
shape);
bool LyXScreen::FitManualCursor(LyXText * text,
long /*x*/, long y, int asc, int desc)
{
bool LyXScreen::FitManualCursor(LyXText * text,
long /*x*/, long y, int asc, int desc)
{
+ long newtop = text->first;
- if (y + desc - first >= owner.height())
+ if (y + desc - text->first >= owner.height())
newtop = y - 3 * owner.height() / 4; // the scroll region must be so big!!
newtop = y - 3 * owner.height() / 4; // the scroll region must be so big!!
- else if (y - asc < long(first)
- && first > 0) {
+ else if (y - asc < long(text->first)
+ && text->first > 0) {
newtop = y - owner.height() / 4;
}
newtop = max(newtop, 0L); // can newtop ever be < 0? (Lgb)
newtop = y - owner.height() / 4;
}
newtop = max(newtop, 0L); // can newtop ever be < 0? (Lgb)
- if (newtop != long(first)) {
+ if (newtop != long(text->first)) {
return true;
}
return false;
}
return true;
}
return false;
}
-void LyXScreen::ShowManualCursor(long x, long y, int asc, int desc,
- Cursor_Shape shape)
+void LyXScreen::ShowManualCursor(LyXText const * text, long x, long y,
+ int asc, int desc, Cursor_Shape shape)
- unsigned long y1 = max(y - first - asc, 0UL);
+ unsigned long y1 = max(y - text->first - asc, 0UL);
typedef unsigned long ulong;
typedef unsigned long ulong;
- unsigned long y2 = min(y - first + desc, ulong(owner.height()));
+ unsigned long y2 = min(y - text->first + desc, ulong(owner.height()));
// Secure against very strange situations
y2 = max(y2, y1);
// Secure against very strange situations
y2 = max(y2, y1);
/* returns a new top so that the cursor is visible */
unsigned long LyXScreen::TopCursorVisible(LyXText const * text)
{
/* returns a new top so that the cursor is visible */
unsigned long LyXScreen::TopCursorVisible(LyXText const * text)
{
+ long newtop = text->first;
if (text->cursor.y()
- text->cursor.row()->baseline()
+ text->cursor.row()->height()
if (text->cursor.y()
- text->cursor.row()->baseline()
+ text->cursor.row()->height()
- - first >= owner.height()) {
+ - text->first >= owner.height()) {
if (text->cursor.row()->height() < owner.height()
&& text->cursor.row()->height() > owner.height() / 4)
newtop = text->cursor.y()
if (text->cursor.row()->height() < owner.height()
&& text->cursor.row()->height() > owner.height() / 4)
newtop = text->cursor.y()
else
newtop = text->cursor.y()
- 3 * owner.height() / 4; /* the scroll region must be so big!! */
else
newtop = text->cursor.y()
- 3 * owner.height() / 4; /* the scroll region must be so big!! */
- } else if (text->cursor.y() - text->cursor.row()->baseline() < first
- && first > 0) {
+ } else if (text->cursor.y() - text->cursor.row()->baseline() < text->first
+ && text->first > 0) {
if (text->cursor.row()->height() < owner.height()
&& text->cursor.row()->height() > owner.height() / 4)
newtop = text->cursor.y() - text->cursor.row()->baseline();
else {
newtop = text->cursor.y() - owner.height() / 4;
if (text->cursor.row()->height() < owner.height()
&& text->cursor.row()->height() > owner.height() / 4)
newtop = text->cursor.y() - text->cursor.row()->baseline();
else {
newtop = text->cursor.y() - owner.height() / 4;
- newtop = min(newtop, long(first));
+ newtop = min(newtop, long(text->first));
{
// Is a change necessary?
unsigned long newtop = TopCursorVisible(text);
{
// Is a change necessary?
unsigned long newtop = TopCursorVisible(text);
- bool result = (newtop != first);
+ bool result = (newtop != text->first);
if (result)
Draw(text, newtop);
return result;
}
if (result)
Draw(text, newtop);
return result;
}
-void LyXScreen::Update(LyXText * text)
+void LyXScreen::Update(LyXText * text, int y_offset, int x_offset)
{
switch(text->status) {
case LyXText::NEED_MORE_REFRESH:
{
{
switch(text->status) {
case LyXText::NEED_MORE_REFRESH:
{
- long y = max(text->refresh_y - long(first), 0L);
-
- DrawFromTo(text, y, owner.height());
+ long y = max(text->refresh_y - long(text->first), 0L);
+ int height;
+ if (text->inset_owner)
+ height = text->inset_owner->ascent(owner.owner()->painter(),
+ text->real_current_font)
+ + text->inset_owner->descent(owner.owner()->painter(),
+ text->real_current_font);
+ else
+ height = owner.height();
+ DrawFromTo(text, y, owner.height(), y_offset, x_offset);
text->refresh_y = 0;
text->status = LyXText::UNCHANGED;
expose(0, y,
text->refresh_y = 0;
text->status = LyXText::UNCHANGED;
expose(0, y,
case LyXText::NEED_VERY_LITTLE_REFRESH:
{
// ok I will update the current cursor row
case LyXText::NEED_VERY_LITTLE_REFRESH:
{
// ok I will update the current cursor row
- DrawOneRow(text, text->refresh_row, text->refresh_y);
+ DrawOneRow(text, text->refresh_row, text->refresh_y,
+ y_offset, x_offset);
text->status = LyXText::UNCHANGED;
text->status = LyXText::UNCHANGED;
- expose(0, text->refresh_y - first,
+ expose(0, text->refresh_y - text->first + y_offset,
owner.workWidth(), text->refresh_row->height());
}
break;
owner.workWidth(), text->refresh_row->height());
}
break;
long bottom = min(max(text->sel_end_cursor.y()
- text->sel_end_cursor.row()->baseline()
long bottom = min(max(text->sel_end_cursor.y()
- text->sel_end_cursor.row()->baseline()
- + text->sel_end_cursor.row()->height(), first),
- first + owner.height());
+ + text->sel_end_cursor.row()->height(), text->first),
+ text->first + owner.height());
long top = min(max(text->sel_start_cursor.y()
long top = min(max(text->sel_start_cursor.y()
- - text->sel_start_cursor.row()->baseline(), first),
- first + owner.height());
+ - text->sel_start_cursor.row()->baseline(), text->first),
+ text->first + owner.height());
if (kill_selection)
text->selection = 0;
if (kill_selection)
text->selection = 0;
- DrawFromTo(text, top - first, bottom - first);
- expose(0, top - first,
+ DrawFromTo(text, top - text->first, bottom - text->first);
+ expose(0, top - text->first,
- bottom - first - (top - first));
+ bottom - text->first - (top - text->first));
-void LyXScreen::ToggleToggle(LyXText * text)
+void LyXScreen::ToggleToggle(LyXText * text, int y_offset, int x_offset)
{
if (text->toggle_cursor.par() == text->toggle_end_cursor.par()
&& text->toggle_cursor.pos() == text->toggle_end_cursor.pos())
{
if (text->toggle_cursor.par() == text->toggle_end_cursor.par()
&& text->toggle_cursor.pos() == text->toggle_end_cursor.pos())
typedef unsigned long ulong;
typedef unsigned long ulong;
- bottom = min(max(ulong(bottom), first), first + owner.height());
- top = min(max(ulong(top), first), first + owner.height());
+ bottom = min(max(ulong(bottom), text->first), text->first + owner.height());
+ top = min(max(ulong(top), text->first), text->first + owner.height());
- DrawFromTo(text, top - first, bottom - first);
- expose(0, top - first, owner.workWidth(),
- bottom - first - (top - first));
+ DrawFromTo(text, top - text->first, bottom - text->first, y_offset,
+ x_offset);
+ expose(0, top - text->first, owner.workWidth(),
+ bottom - text->first - (top - text->first));
-void LyXTabular::SetAscentOfRow(int row, int height)
+bool LyXTabular::SetAscentOfRow(int row, int height)
- if (row >= rows_)
- return;
+ if ((row >= rows_) || (row_info[row].ascent_of_row == height))
+ return false;
row_info[row].ascent_of_row = height;
row_info[row].ascent_of_row = height;
-void LyXTabular::SetDescentOfRow(int row, int height)
+bool LyXTabular::SetDescentOfRow(int row, int height)
- if (row >= rows_)
- return;
+ if ((row >= rows_) || (row_info[row].descent_of_row == height))
+ return false;
row_info[row].descent_of_row = height;
row_info[row].descent_of_row = height;
int GetDescentOfRow(int row) const;
///
int GetHeightOfTabular() const;
int GetDescentOfRow(int row) const;
///
int GetHeightOfTabular() const;
- ///
- void SetAscentOfRow(int row, int height);
- ///
- void SetDescentOfRow(int row, int height);
+ /// Returns true if a complete update is necessary, otherwise false
+ bool SetAscentOfRow(int row, int height);
+ /// Returns true if a complete update is necessary, otherwise false
+ bool SetDescentOfRow(int row, int height);
/// Returns true if a complete update is necessary, otherwise false
bool SetWidthOfCell(int cell, int new_width);
/// Returns true if a complete update is necessary, otherwise false
/// Returns true if a complete update is necessary, otherwise false
bool SetWidthOfCell(int cell, int new_width);
/// Returns true if a complete update is necessary, otherwise false
bool clear_area = true;
if ((last == row_ptr->pos()) &&
bool clear_area = true;
if ((last == row_ptr->pos()) &&
- row_ptr->par()->GetInset(row_ptr->pos())) {
+ (row_ptr->par()->GetChar(row_ptr->pos()) == LyXParagraph::META_INSET) &&
+ (row_ptr->par()->GetInset(row_ptr->pos())))
+ {
clear_area = row_ptr->par()->GetInset(row_ptr->pos())->doClearArea();
}
clear_area = row_ptr->par()->GetInset(row_ptr->pos())->doClearArea();
}
- if (bv_owner && clear_area)
pain.fillRectangle(x_offset, y_offset, ww, row_ptr->height());
if (selection) {
pain.fillRectangle(x_offset, y_offset, ww, row_ptr->height());
if (selection) {
number_of_rows = 0;
refresh_y = 0;
height = width = 0;
number_of_rows = 0;
refresh_y = 0;
height = width = 0;
status = LyXText::UNCHANGED;
// set cursor at the very top position
selection = true; /* these setting is necessary
status = LyXText::UNCHANGED;
// set cursor at the very top position
selection = true; /* these setting is necessary