mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Various updates for the update-handling and redrawing of insets(text).
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@830 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
64d9f30605
commit
572556e94f
@ -1,5 +1,8 @@
|
||||
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
|
||||
|
||||
|
@ -745,8 +745,8 @@ void BufferView::showLockedInsetCursor(long x, long y, int asc, int desc)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ void BufferView::Pimpl::buffer(Buffer * b)
|
||||
updateScreen();
|
||||
updateScrollbar();
|
||||
}
|
||||
screen_->first = screen_->TopCursorVisible(bv_->text);
|
||||
bv_->text->first = screen_->TopCursorVisible(bv_->text);
|
||||
redraw();
|
||||
owner_->getDialogs()->updateBufferDependent();
|
||||
bv_->insetWakeup();
|
||||
@ -271,7 +271,7 @@ int BufferView::Pimpl::resizeCurrentBuffer()
|
||||
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
|
||||
@ -346,10 +346,10 @@ void BufferView::Pimpl::updateScrollbar()
|
||||
unsigned long cbth = 0;
|
||||
long cbsf = 0;
|
||||
|
||||
if (bv_->text)
|
||||
if (bv_->text) {
|
||||
cbth = bv_->text->height;
|
||||
if (screen_)
|
||||
cbsf = screen_->first;
|
||||
cbsf = bv_->text->first;
|
||||
}
|
||||
|
||||
// check if anything has changed.
|
||||
if (max2 == cbth &&
|
||||
@ -410,14 +410,14 @@ void BufferView::Pimpl::scrollCB(double value)
|
||||
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,
|
||||
screen_->first +
|
||||
bv_->text->first +
|
||||
height);
|
||||
} else if (vbt->cursor.y() >
|
||||
screen_->first + workarea_->height() - height) {
|
||||
bv_->text->first + workarea_->height() - height) {
|
||||
vbt->SetCursorFromCoordinates(bv_, 0,
|
||||
screen_->first +
|
||||
bv_->text->first +
|
||||
workarea_->height() -
|
||||
height);
|
||||
}
|
||||
@ -498,7 +498,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
|
||||
bv_->the_locking_inset->
|
||||
InsetMotionNotify(bv_,
|
||||
x - cursor.x(),
|
||||
y - cursor.y() + screen_->first,
|
||||
y - cursor.y() + bv_->text->first,
|
||||
state);
|
||||
return;
|
||||
}
|
||||
@ -508,7 +508,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
|
||||
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
|
||||
@ -569,9 +569,9 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
|
||||
// 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
|
||||
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
|
||||
@ -604,7 +604,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
|
||||
}
|
||||
#endif
|
||||
|
||||
int screen_first = screen_->first;
|
||||
int screen_first = bv_->text->first;
|
||||
|
||||
// Middle button press pastes if we have a selection
|
||||
bool paste_internally = false;
|
||||
@ -847,7 +847,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
|
||||
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() -
|
||||
@ -885,7 +885,7 @@ Inset * BufferView::Pimpl::checkInsetHit(int & x, int & y,
|
||||
if (!screen_)
|
||||
return 0;
|
||||
|
||||
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);
|
||||
@ -1196,7 +1196,7 @@ void BufferView::Pimpl::cursorPrevious()
|
||||
{
|
||||
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();
|
||||
@ -1218,7 +1218,7 @@ void BufferView::Pimpl::cursorNext()
|
||||
{
|
||||
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
|
||||
|
@ -156,19 +156,21 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
|
||||
int i, j, cell=0;
|
||||
int nx;
|
||||
float cx;
|
||||
bool reinit = false;
|
||||
|
||||
UpdatableInset::draw(bv,font,baseline,x);
|
||||
if (init_inset || (top_x != int(x)) || (top_baseline != baseline)) {
|
||||
// int ox = top_x;
|
||||
init_inset = false;
|
||||
top_x = int(x);
|
||||
top_baseline = baseline;
|
||||
// if (ox != top_x)
|
||||
// recomputeTextInsets(pain, font);
|
||||
// calculate_width_of_cells(pain, font);
|
||||
resetPos(pain);
|
||||
reinit = true;
|
||||
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) {
|
||||
@ -193,9 +195,11 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
|
||||
|
||||
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_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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -290,7 +294,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, true, false);
|
||||
UpdateLocal(bv, false, false);
|
||||
// bv->getOwner()->getPopups().updateFormTabular();
|
||||
}
|
||||
|
||||
@ -315,8 +319,6 @@ void InsetTabular::InsetUnlock(BufferView * bv)
|
||||
|
||||
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)
|
||||
@ -364,6 +366,7 @@ bool InsetTabular::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
|
||||
the_locking_inset = 0;
|
||||
if (lr)
|
||||
moveRight(bv, false);
|
||||
UpdateLocal(bv, true, false);
|
||||
return true;
|
||||
}
|
||||
if (the_locking_inset->UnlockInsetInInset(bv, inset, lr)) {
|
||||
@ -384,7 +387,7 @@ bool InsetTabular::UpdateInsetInInset(BufferView * bv, Inset * inset)
|
||||
return false;
|
||||
if (the_locking_inset != inset)
|
||||
return the_locking_inset->UpdateInsetInInset(bv, inset);
|
||||
UpdateLocal(bv, true, false);
|
||||
UpdateLocal(bv, false, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -724,12 +727,14 @@ void InsetTabular::Validate(LaTeXFeatures & features) const
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
bool changed = false;
|
||||
|
||||
for(int i = 0; i < tabular->rows(); ++i) {
|
||||
maxAsc = maxDesc = 0;
|
||||
@ -741,11 +746,12 @@ void InsetTabular::calculate_width_of_cells(BufferView * bv,
|
||||
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;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
@ -992,8 +998,10 @@ bool InsetTabular::Delete()
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -152,7 +152,7 @@ public:
|
||||
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;
|
||||
@ -214,10 +214,8 @@ private:
|
||||
oldcell,
|
||||
actcol,
|
||||
actrow;
|
||||
bool
|
||||
locked,
|
||||
no_selection;
|
||||
mutable bool
|
||||
init_inset;
|
||||
bool no_selection;
|
||||
mutable bool locked;
|
||||
mutable bool init_inset;
|
||||
};
|
||||
#endif
|
||||
|
@ -214,6 +214,20 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
|
||||
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);
|
||||
|
||||
@ -231,43 +245,33 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
bv->screen()->Update(TEXT(bv));
|
||||
}
|
||||
x += width(pain, f) - TEXT_TO_INSET_OFFSET;
|
||||
need_update = NONE;
|
||||
}
|
||||
|
||||
|
||||
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 (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;
|
||||
@ -395,7 +399,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
|
||||
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)
|
||||
@ -564,7 +568,7 @@ InsetText::LocalDispatch(BufferView * bv,
|
||||
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();
|
||||
@ -577,7 +581,7 @@ InsetText::LocalDispatch(BufferView * bv,
|
||||
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();
|
||||
@ -590,7 +594,7 @@ InsetText::LocalDispatch(BufferView * bv,
|
||||
bv->text->FinishUndo();
|
||||
moveDown(bv);
|
||||
TEXT(bv)->SetSelection();
|
||||
UpdateLocal(bv, CURSOR_PAR, false);
|
||||
UpdateLocal(bv, SELECTION, false);
|
||||
break;
|
||||
case LFUN_DOWN:
|
||||
bv->text->FinishUndo();
|
||||
@ -603,7 +607,7 @@ InsetText::LocalDispatch(BufferView * bv,
|
||||
bv->text->FinishUndo();
|
||||
moveUp(bv);
|
||||
TEXT(bv)->SetSelection();
|
||||
UpdateLocal(bv, CURSOR_PAR, false);
|
||||
UpdateLocal(bv, SELECTION, false);
|
||||
break;
|
||||
case LFUN_UP:
|
||||
bv->text->FinishUndo();
|
||||
|
@ -44,7 +44,8 @@ public:
|
||||
NONE = 0,
|
||||
INIT,
|
||||
FULL,
|
||||
CURSOR_PAR
|
||||
CURSOR_PAR,
|
||||
SELECTION
|
||||
};
|
||||
///
|
||||
explicit
|
||||
@ -194,7 +195,7 @@ private:
|
||||
|
||||
/* Private structures and variables */
|
||||
///
|
||||
bool locked;
|
||||
mutable bool locked;
|
||||
///
|
||||
int insetAscent;
|
||||
int insetDescent;
|
||||
|
@ -64,24 +64,21 @@ public:
|
||||
///
|
||||
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);
|
||||
///
|
||||
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. */
|
||||
void Update(LyXText *);
|
||||
|
||||
/// first visible pixel-row
|
||||
unsigned long first;
|
||||
void Update(LyXText *, int y_offset=0, int x_offset=0);
|
||||
|
||||
///
|
||||
bool cursor_visible;
|
||||
@ -90,17 +87,15 @@ private:
|
||||
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
|
||||
void DrawOneRow(LyXText *, Row * row, long y_text);
|
||||
void DrawOneRow(LyXText *, Row * row, long y_text, int y_offset=0,
|
||||
int x_offset=0);
|
||||
|
||||
///
|
||||
WorkArea & owner;
|
||||
|
||||
///
|
||||
//LyXText * text;
|
||||
|
||||
///
|
||||
Pixmap cursor_pixmap;
|
||||
///
|
||||
|
@ -68,6 +68,12 @@ public:
|
||||
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 *);
|
||||
@ -539,10 +545,6 @@ private:
|
||||
///
|
||||
void init();
|
||||
///
|
||||
BufferView * bv_owner;
|
||||
///
|
||||
InsetText * inset_owner;
|
||||
///
|
||||
mutable Row * firstrow;
|
||||
///
|
||||
mutable Row * lastrow;
|
||||
|
125
src/screen.C
125
src/screen.C
@ -23,6 +23,7 @@
|
||||
#include "WorkArea.h"
|
||||
#include "buffer.h"
|
||||
#include "font.h"
|
||||
#include "insets/insettext.h"
|
||||
|
||||
using std::max;
|
||||
using std::min;
|
||||
@ -48,8 +49,6 @@ GC createGC()
|
||||
LyXScreen::LyXScreen(WorkArea & o) //, LyXText * text_ptr)
|
||||
: owner(o) //, text(text_ptr)
|
||||
{
|
||||
first = 0;
|
||||
|
||||
// the cursor isnt yet visible
|
||||
cursor_visible = false;
|
||||
cursor_pixmap = 0;
|
||||
@ -87,25 +86,25 @@ void LyXScreen::expose(int x, int y, int exp_width, int exp_height)
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
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) {
|
||||
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
|
||||
if (y < y2) {
|
||||
if ((y < y2) && text->bv_owner) {
|
||||
owner.getPainter().fillRectangle(0, y,
|
||||
owner.workWidth(),
|
||||
y2 - y,
|
||||
@ -114,14 +113,15 @@ void LyXScreen::DrawFromTo(LyXText * text, int y1, int y2)
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
text->GetVisibleRow(owner.owner(), y, 0, row, y + first);
|
||||
text->GetVisibleRow(owner.owner(), y, x_offset, row, y + text->first);
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,14 +132,14 @@ void LyXScreen::Draw(LyXText * text, unsigned long y)
|
||||
{
|
||||
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()) {
|
||||
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(),
|
||||
@ -147,31 +147,31 @@ void LyXScreen::Draw(LyXText * text, unsigned long y)
|
||||
owner.xpos(),
|
||||
owner.ypos(),
|
||||
owner.workWidth(),
|
||||
owner.height() - old_first + first,
|
||||
owner.height() - old_first + text->first,
|
||||
owner.xpos(),
|
||||
owner.ypos() + old_first - first
|
||||
owner.ypos() + old_first - text->first
|
||||
);
|
||||
// expose the area drawn
|
||||
expose(0, 0,
|
||||
owner.workWidth(),
|
||||
old_first - first);
|
||||
old_first - text->first);
|
||||
} 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.ypos() + first - old_first,
|
||||
owner.ypos() + text->first - old_first,
|
||||
owner.workWidth(),
|
||||
owner.height() + old_first - first,
|
||||
owner.height() + old_first - text->first,
|
||||
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
|
||||
@ -191,7 +191,7 @@ void LyXScreen::ShowCursor(LyXText const * text)
|
||||
!= 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);
|
||||
@ -203,33 +203,33 @@ void LyXScreen::ShowCursor(LyXText const * text)
|
||||
bool LyXScreen::FitManualCursor(LyXText * text,
|
||||
long /*x*/, long y, int asc, int desc)
|
||||
{
|
||||
long newtop = first;
|
||||
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!!
|
||||
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)
|
||||
|
||||
if (newtop != long(first)) {
|
||||
if (newtop != long(text->first)) {
|
||||
Draw(text, newtop);
|
||||
first = newtop;
|
||||
text->first = newtop;
|
||||
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;
|
||||
|
||||
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);
|
||||
@ -330,12 +330,12 @@ void LyXScreen::CursorToggle(LyXText const * text)
|
||||
/* returns a new top so that the cursor is visible */
|
||||
unsigned long LyXScreen::TopCursorVisible(LyXText const * text)
|
||||
{
|
||||
long newtop = first;
|
||||
long newtop = text->first;
|
||||
|
||||
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()
|
||||
@ -344,14 +344,14 @@ unsigned long LyXScreen::TopCursorVisible(LyXText const * text)
|
||||
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;
|
||||
newtop = min(newtop, long(first));
|
||||
newtop = min(newtop, long(text->first));
|
||||
}
|
||||
}
|
||||
|
||||
@ -367,21 +367,28 @@ bool LyXScreen::FitCursor(LyXText * 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;
|
||||
}
|
||||
|
||||
|
||||
void LyXScreen::Update(LyXText * text)
|
||||
void LyXScreen::Update(LyXText * text, int y_offset, int x_offset)
|
||||
{
|
||||
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,
|
||||
@ -391,9 +398,10 @@ void LyXScreen::Update(LyXText * text)
|
||||
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;
|
||||
expose(0, text->refresh_y - first,
|
||||
expose(0, text->refresh_y - text->first + y_offset,
|
||||
owner.workWidth(), text->refresh_row->height());
|
||||
}
|
||||
break;
|
||||
@ -411,22 +419,22 @@ void LyXScreen::ToggleSelection(LyXText * text, bool kill_selection)
|
||||
|
||||
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()
|
||||
- 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;
|
||||
DrawFromTo(text, top - first, bottom - first);
|
||||
expose(0, top - first,
|
||||
DrawFromTo(text, top - text->first, bottom - text->first);
|
||||
expose(0, top - text->first,
|
||||
owner.workWidth(),
|
||||
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())
|
||||
@ -440,10 +448,11 @@ void LyXScreen::ToggleToggle(LyXText * text)
|
||||
|
||||
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));
|
||||
}
|
||||
|
@ -1779,19 +1779,21 @@ bool LyXTabular::GetLTNewPage(int cell) const
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -117,10 +117,10 @@ public:
|
||||
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
|
||||
|
@ -3802,10 +3802,12 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
|
||||
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();
|
||||
}
|
||||
if (bv_owner && clear_area)
|
||||
if (clear_area)
|
||||
pain.fillRectangle(x_offset, y_offset, ww, row_ptr->height());
|
||||
|
||||
if (selection) {
|
||||
|
@ -70,6 +70,7 @@ void LyXText::init()
|
||||
number_of_rows = 0;
|
||||
refresh_y = 0;
|
||||
height = width = 0;
|
||||
first = 0;
|
||||
status = LyXText::UNCHANGED;
|
||||
// set cursor at the very top position
|
||||
selection = true; /* these setting is necessary
|
||||
|
Loading…
Reference in New Issue
Block a user