remove cursor.i[xy]

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7640 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-09-02 17:08:54 +00:00
parent e28225d79a
commit 0769f8d599
15 changed files with 49 additions and 113 deletions

View File

@ -479,7 +479,7 @@ bool BufferView::lockInset(UpdatableInset * inset)
bool BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc)
{
if (theLockingInset() && available()) {
y += text->cursor.iy() + theLockingInset()->insetInInsetY();
y += text->cursor.y() + theLockingInset()->insetInInsetY();
if (screen().fitManualCursor(this, text, x, y, asc, desc)) {
updateScrollbar();
return true;

View File

@ -1,3 +1,11 @@
2003-09-02 John Levon <levon@movementarian.org>
* BufferView.C:
* lyxcursor.h:
* lyxcursor.C:
* lyxfunc.C:
* lyxfunc.h: remove cursor.i[x]y(), it no longer differs
2003-09-02 John Levon <levon@movementarian.org>
* text2.C: simplification of cursorEnd(), including partial

View File

@ -1,3 +1,7 @@
2003-09-02 John Levon <levon@movementarian.org>
* screen.C: remove cursor.i[xy]()
2003-09-02 Lars Gullik Bjønnes <larsbj@gullik.net>
* Alert.C (prompt, warning, error, information, askForText): Make

View File

@ -183,7 +183,7 @@ void LyXScreen::showCursor(BufferView & bv)
// Ugly as you like.
int bx, by;
inset->getCursorPos(&bv, bx, by);
by += inset->insetInInsetY() + bv.text->cursor.iy();
by += inset->insetInInsetY() + bv.text->cursor.y();
if (by < top_y)
return;
if (by > top_y + workarea().workHeight())

View File

@ -1,3 +1,8 @@
2003-09-02 John Levon <levon@movementarian.org>
* insettext.h:
* insettext.C: remove cursor.i[xy]()
2003-08-28 Angus Leeming <leeming@lyx.org>
* insetgraphics.C (prepareFile): prepend "convertDefault.sh" with

View File

@ -54,6 +54,7 @@ std::auto_ptr<InsetBase> InsetBibtex::clone() const
return std::auto_ptr<InsetBase>(new InsetBibtex(*this));
}
void InsetBibtex::metrics(MetricsInfo & mi, Dimension & dim) const
{
InsetCommand::metrics(mi, dim);

View File

@ -131,6 +131,7 @@ dispatch_result InsetBranch::localDispatch(FuncRequest const & cmd)
case LFUN_INSET_EDIT:
if (cmd.button() != mouse_button::button3)
return InsetCollapsable::localDispatch(cmd);
return UNDISPATCHED;
case LFUN_INSET_DIALOG_UPDATE:
InsetBranchMailer("branch", *this).updateDialog(bv);

View File

@ -243,7 +243,6 @@ void InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd)
}
bv->updateInset(this);
bv->buffer()->markDirty();
lyxerr << "InsetCollapsable::lfunMouseRelease\n";
} else if (!collapsed_ && cmd.y > button_dim.y2) {
ret = inset.localDispatch(adjustCommand(cmd)) == DISPATCHED;
}

View File

@ -281,8 +281,8 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
top_y = y - dim_.asc;
if (the_locking_inset && cpar() == inset_par && cpos() == inset_pos) {
inset_x = cix() - x + drawTextXOffset;
inset_y = ciy() + drawTextYOffset;
inset_x = cx() - x + drawTextXOffset;
inset_y = cy() + drawTextYOffset;
}
x += TEXT_TO_INSET_OFFSET;
@ -386,8 +386,8 @@ void InsetText::lockInset(BufferView * bv)
void InsetText::lockInset(BufferView * /*bv*/, UpdatableInset * inset)
{
the_locking_inset = inset;
inset_x = cix() - top_x + drawTextXOffset;
inset_y = ciy() + drawTextYOffset;
inset_x = cx() - top_x + drawTextXOffset;
inset_y = cy() + drawTextYOffset;
inset_pos = cpos();
inset_par = cpar();
inset_boundary = cboundary();
@ -438,8 +438,8 @@ bool InsetText::lockInsetInInset(BufferView * bv, UpdatableInset * inset)
if (the_locking_inset && the_locking_inset == inset) {
if (cpar() == inset_par && cpos() == inset_pos) {
lyxerr[Debug::INSETS] << "OK" << endl;
inset_x = cix() - top_x + drawTextXOffset;
inset_y = ciy() + drawTextYOffset;
inset_x = cx() - top_x + drawTextXOffset;
inset_y = cy() + drawTextYOffset;
} else {
lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
}
@ -581,8 +581,8 @@ bool InsetText::lfunMouseRelease(FuncRequest const & cmd)
if (isHighlyEditableInset(inset))
ret = inset->localDispatch(cmd1);
else {
inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy() + drawTextYOffset;
inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy() + drawTextYOffset;
cmd1.x = cmd.x - inset_x;
cmd1.y = cmd.x - inset_y;
inset->edit(bv, cmd1.x, cmd1.y, cmd.button());
@ -1433,8 +1433,8 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
x = dim_.wid;
if (y < 0)
y = dim_.des;
inset_x = cix() - top_x + drawTextXOffset;
inset_y = ciy() + drawTextYOffset;
inset_x = cx() - top_x + drawTextXOffset;
inset_y = cy() + drawTextYOffset;
FuncRequest cmd(bv, LFUN_INSET_EDIT, x - inset_x, y - inset_y, button);
inset->localDispatch(cmd);
if (!the_locking_inset)
@ -1501,30 +1501,12 @@ int InsetText::cx() const
}
int InsetText::cix() const
{
int x = text_.cursor.ix() + top_x + TEXT_TO_INSET_OFFSET;
if (the_locking_inset) {
LyXFont font = text_.getFont(text_.cursor.par(), text_.cursor.pos());
if (font.isVisibleRightToLeft())
x -= the_locking_inset->width();
}
return x;
}
int InsetText::cy() const
{
return text_.cursor.y() - dim_.asc + TEXT_TO_INSET_OFFSET;
}
int InsetText::ciy() const
{
return text_.cursor.iy() - dim_.asc + TEXT_TO_INSET_OFFSET;
}
pos_type InsetText::cpos() const
{
return text_.cursor.pos();

View File

@ -258,12 +258,8 @@ private:
///
int cx() const;
///
int cix() const;
///
int cy() const;
///
int ciy() const;
///
lyx::pos_type cpos() const;
///
ParagraphList::iterator cpar() const;

View File

@ -18,7 +18,7 @@
LyXCursor::LyXCursor()
: par_(), pos_(0), boundary_(false),
x_(0), ix_(0), x_fix_(0), y_(0), iy_(0)
x_(0), x_fix_(0), y_(0)
{}
@ -69,17 +69,6 @@ int LyXCursor::x() const
}
void LyXCursor::ix(int n)
{
ix_ = n;
}
int LyXCursor::ix() const
{
return ix_;
}
void LyXCursor::x_fix(int i)
{
x_fix_ = i;
@ -104,18 +93,6 @@ int LyXCursor::y() const
}
void LyXCursor::iy(int i)
{
iy_ = i;
}
int LyXCursor::iy() const
{
return iy_;
}
bool operator==(LyXCursor const & a, LyXCursor const & b)
{
return a.par() == b.par()

View File

@ -46,16 +46,6 @@ public:
void x(int i);
/// return the x position in pixels
int x() const;
/// set the stored next-line position when at the end of a row
void ix(int i);
/**
* Return the x position of the start of the next row, when this
* cursor is at the end of the previous row, for insets that take
* a full row.
*
* FIXME: explain why we need this ?
*/
int ix() const;
/// set the cached x position
void x_fix(int i);
/**
@ -75,16 +65,7 @@ public:
void y(int i);
/// return the y position in pixels
int y() const;
/// set the stored next-line y position when at the end of a row
void iy(int i);
/**
* Return the y position of the start of the next row, when this
* cursor is at the end of the previous row, for insets that take
* a full row.
*
* FIXME: explain why we need this ? especially for y...
*/
int iy() const;
private:
/// The paragraph the cursor is in.
ParagraphList::iterator par_;
@ -108,14 +89,10 @@ private:
bool boundary_;
/// the pixel x position
int x_;
/// the stored next-row x position
int ix_;
/// the cached x position
int x_fix_;
/// the pixel y position
int y_;
/// the stored next-row y position
int iy_;
};
///

View File

@ -922,8 +922,8 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
if (irow != view()->text->firstRow()) {
#if 1
view()->text->setCursorFromCoordinates(
view()->text->cursor.ix() + inset_x,
view()->text->cursor.iy() -
view()->text->cursor.x() + inset_x,
view()->text->cursor.y() -
irow->baseline() - 1);
view()->text->cursor.x_fix(view()->text->cursor.x());
#else
@ -940,8 +940,8 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
if (irow != view()->text->lastRow()) {
#if 1
view()->text->setCursorFromCoordinates(
view()->text->cursor.ix() + inset_x,
view()->text->cursor.iy() -
view()->text->cursor.x() + inset_x,
view()->text->cursor.y() -
irow->baseline() +
irow->height() + 1);
view()->text->cursor.x_fix(view()->text->cursor.x());

View File

@ -1352,18 +1352,12 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
RowList::iterator row = getRow(pit, pos);
int y = row->y();
RowList::iterator old_row = row;
// if we are before the first char of this row and are still in the
// same paragraph and there is a previous row then put the cursor on
// the end of the previous row
cur.iy(y + row->baseline());
// y is now the beginning of the cursor row
y += row->baseline();
// y is now the cursor baseline
cur.y(y);
pos_type last = lastPrintablePos(*pit, old_row);
pos_type last = lastPrintablePos(*pit, row);
// None of these should happen, but we're scaredy-cats
if (pos > pit->size()) {
@ -1385,11 +1379,6 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
float x = getCursorX(pit, row, pos, last, boundary);
cur.x(int(x));
cur.x_fix(cur.x());
if (old_row != row) {
x = getCursorX(pit, old_row, pos, last, boundary);
cur.ix(int(x));
} else
cur.ix(cur.x());
}
@ -1626,9 +1615,6 @@ void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y)
cur.x(x);
cur.y(y + rit->baseline());
cur.iy(cur.y());
cur.ix(cur.x());
cur.boundary(bound);
}
@ -1675,7 +1661,7 @@ void LyXText::cursorUp(bool selecting)
setCursorFromCoordinates(x, y);
if (!selecting) {
int topy = bv_owner->top_y();
int y1 = cursor.iy() - topy;
int y1 = cursor.y() - topy;
int y2 = y1;
y -= topy;
InsetOld * inset_hit = checkInsetHit(x, y1);
@ -1701,7 +1687,7 @@ void LyXText::cursorDown(bool selecting)
setCursorFromCoordinates(x, y);
if (!selecting && cursorRow() == cursorIRow()) {
int topy = bv_owner->top_y();
int y1 = cursor.iy() - topy;
int y1 = cursor.y() - topy;
int y2 = y1;
y -= topy;
InsetOld * inset_hit = checkInsetHit(x, y1);

View File

@ -116,13 +116,13 @@ namespace {
int const width = inset->width();
int const inset_x = font.isVisibleRightToLeft()
? (cur.ix() - width) : cur.ix();
? (cur.x() - width) : cur.x();
Box b(
inset_x + inset->scroll(),
inset_x + width,
cur.iy() - inset->ascent(),
cur.iy() + inset->descent()
cur.y() - inset->ascent(),
cur.y() + inset->descent()
);
if (!b.contained(x, y)) {
@ -136,7 +136,7 @@ namespace {
x -= b.x1;
// The origin of an inset is on the baseline
y -= text.cursor.iy();
y -= text.cursor.y();
return inset;
}
@ -266,7 +266,7 @@ void LyXText::cursorPrevious()
// tall rows, but it's not working right now.
} else {
if (inset_owner) {
new_y = bv()->text->cursor.iy()
new_y = bv()->text->cursor.y()
+ bv()->theLockingInset()->insetInInsetY() + y
+ rit->height()
- bv()->workHeight() + 1;
@ -302,7 +302,7 @@ void LyXText::cursorNext()
int y = topy + bv_owner->workHeight();
if (inset_owner && !topy) {
y -= (bv_owner->text->cursor.iy()
y -= (bv_owner->text->cursor.y()
- bv_owner->top_y()
+ bv_owner->theLockingInset()->insetInInsetY());
}
@ -327,7 +327,7 @@ void LyXText::cursorNext()
#endif
} else {
if (inset_owner) {
new_y = bv()->text->cursor.iy()
new_y = bv()->text->cursor.y()
+ bv()->theLockingInset()->insetInInsetY()
+ y - rit->baseline();
} else {
@ -1214,11 +1214,11 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
LyXFont font = bv->text->getFont(cursor.par(), cursor.pos());
int width = tli->width();
int inset_x = font.isVisibleRightToLeft()
? cursor.ix() - width : cursor.ix();
? cursor.x() - width : cursor.x();
int start_x = inset_x + tli->scroll();
FuncRequest cmd1 = cmd;
cmd1.x = cmd.x - start_x;
cmd1.y = cmd.y - cursor.iy() + bv->top_y();
cmd1.y = cmd.y - cursor.y() + bv->top_y();
tli->localDispatch(cmd1);
break;
}