xy0_->xyo_ + two fixes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8111 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Alfredo Braunstein 2003-11-21 08:35:15 +00:00
parent 4e2a7f6e81
commit 43198fcbda
7 changed files with 45 additions and 33 deletions

View File

@ -1,3 +1,10 @@
2003-11-21 Alfredo Braunstein <abraunst@lyx.org>
* lyxtext.h: x0_,y0_ -> xo_,yo_
* text2.C (cursorUp, cursorDown): adjust + some cursorRow use
* text3.C (checkInsetHit): fix coordinates using absolute xo_,yo_
* rowpainter.C (paintRows): paint full paragraphs
2003-11-20 Alfredo Braunstein <abraunst@lyx.org>
* text2.C (cursorUp, cursorDown): small fix (insettext::edit takes

View File

@ -1,3 +1,7 @@
2003-11-21 Alfredo Braunstein <abraunst@lyx.org>
* insettext.C (edit): x0_,y0_ -> xo_,yo_
2003-11-20 Alfredo Braunstein <abraunst@lyx.org>
* insettext.C (draw): sets LyXText absolute coordinates

View File

@ -258,8 +258,8 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
x += TEXT_TO_INSET_OFFSET;
text_.x0_ = x;
text_.y0_ = y - text_.firstRow()->ascent_of_text() + bv->top_y();
text_.xo_ = x;
text_.yo_ = y - text_.firstRow()->ascent_of_text() + bv->top_y();
paintTextInset(*bv, text_, x, y);
@ -344,8 +344,8 @@ void InsetText::edit(BufferView * bv, int x, int y)
lyxerr << "InsetText::edit xy" << endl;
old_par = -1;
sanitizeEmptyText(bv);
text_.setCursorFromCoordinates(x - text_.x0_, y + bv->top_y()
- text_.y0_);
text_.setCursorFromCoordinates(x - text_.xo_, y + bv->top_y()
- text_.yo_);
text_.clearSelection();
finishUndo();

View File

@ -472,8 +472,8 @@ private:
public:
/// absolute document pixel coordinates of this LyXText
int x0_;
int y0_;
int xo_;
int yo_;
};
/// return the default height of a row in pixels, considering font zoom

View File

@ -993,12 +993,12 @@ int paintRows(BufferView const & bv, LyXText const & text,
RowPainter painter(bv, text, pit, row, y + yo, xo, y + bv.top_y());
painter.paint();
y += row->height();
if (yy + y >= y2)
return y;
} else {
//lyxerr << " paintRows: row: " << &*row << " ignored" << endl;
}
}
if (yy + y >= y2)
return y;
}
return y;

View File

@ -74,7 +74,7 @@ LyXText::LyXText(BufferView * bv, InsetText * inset, bool ininset,
ParagraphList & paragraphs)
: height(0), width(0), inset_owner(inset), bv_owner(bv),
in_inset_(ininset), paragraphs_(&paragraphs),
cache_pos_(-1), x0_(0), y0_(0)
cache_pos_(-1), xo_(0), yo_(0)
{}
@ -1300,6 +1300,7 @@ void LyXText::setCursor(LyXCursor & cur, paroffset_type par,
ParagraphList::iterator pit = getPar(par);
Row const & row = *pit->getRow(pos);
int y = pit->y + row.y_offset();
// y is now the beginning of the cursor row
@ -1404,7 +1405,7 @@ void LyXText::setCursorIntern(paroffset_type par,
pos_type pos, bool setfont, bool boundary)
{
setCursor(cursor, par, pos, boundary);
bv()->x_target(cursor.x() + x0_);
bv()->x_target(cursor.x() + xo_);
if (setfont)
setCurrentFont();
}
@ -1708,33 +1709,32 @@ bool LyXText::cursorRight(bool internal)
void LyXText::cursorUp(bool selecting)
{
ParagraphList::iterator cpit = cursorPar();
Row const & crow = *cpit->getRow(cursor.pos());
int x = bv()->x_target() - x0_;
int y = cursor.y() - crow.baseline() - 1;
Row const & row = *cursorRow();
int x = bv()->x_target() - xo_;
int y = cursor.y() - row.baseline() - 1;
setCursorFromCoordinates(x, y);
if (!selecting) {
y += y0_ - bv()->top_y();
lyxerr << "y:" << y << " y0: " << y0_ << endl;
InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y);
int y_abs = y + yo_ - bv()->top_y();
InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y_abs);
if (inset_hit && isHighlyEditableInset(inset_hit))
inset_hit->edit(bv(), bv()->x_target(), y);
inset_hit->edit(bv(), bv()->x_target(), y_abs);
}
}
void LyXText::cursorDown(bool selecting)
{
ParagraphList::iterator cpit = cursorPar();
Row const & crow = *cpit->getRow(cursor.pos());
int x = bv()->x_target() - x0_;
int y = cursor.y() - crow.baseline() + crow.height() + 1;
Row const & row = *cursorRow();
int x = bv()->x_target() - xo_;
int y = cursor.y() - row.baseline() + row.height() + 1;
setCursorFromCoordinates(x, y);
if (!selecting) {
y += y0_ - bv()->top_y();
InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y);
int y_abs = y + yo_ - bv()->top_y();
InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y_abs);
if (inset_hit && isHighlyEditableInset(inset_hit))
inset_hit->edit(bv(), bv()->x_target(), y);
inset_hit->edit(bv(), bv()->x_target(), y_abs);
}
}

View File

@ -260,7 +260,8 @@ InsetOld * LyXText::checkInsetHit(int x, int y)
ParagraphList::iterator end;
getParsInRange(ownerParagraphs(),
bv()->top_y(), bv()->top_y() + bv()->workHeight(),
bv()->top_y() - yo_,
bv()->top_y() - yo_ + bv()->workHeight(),
pit, end);
lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
@ -365,8 +366,8 @@ void LyXText::cursorPrevious()
RowList::iterator crit = cursorRow();
int x = bv()->x_target() - x0_;
int y = bv()->top_y() - y0_;
int x = bv()->x_target() - xo_;
int y = bv()->top_y() - yo_;
setCursorFromCoordinates(x, y);
if (crit == cursorRow()) {
@ -384,8 +385,8 @@ void LyXText::cursorNext()
{
RowList::iterator crit = cursorRow();
int x = bv()->x_target() - x0_;
int y = bv()->top_y() + bv()->workHeight() - y0_;
int x = bv()->x_target() - xo_;
int y = bv()->top_y() + bv()->workHeight() - yo_;
setCursorFromCoordinates(x, y);
if (crit == cursorRow()) {
@ -1242,9 +1243,9 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
// FIXME: shouldn't be top-text-specific
if (cursorrow == cursorRow() && !in_inset_) {
if (cmd.y - bv->top_y() >= bv->workHeight())
cursorDown(false);
cursorDown(true);
else if (cmd.y - bv->top_y() < 0)
cursorUp(false);
cursorUp(true);
}
setSelection();
break;
@ -1292,7 +1293,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
setCursorFromCoordinates(cmd.x, cmd.y);
selection.cursor = cursor;
finishUndo();
bv->x_target(cursor.x() + x0_);
bv->x_target(cursor.x() + xo_);
if (bv->fitCursor())
selection_possible = false;