New function ciy() which handles cursor.iy() functions.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3972 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2002-04-11 15:08:22 +00:00
parent 961c3ee574
commit c9a31728e9
3 changed files with 22 additions and 11 deletions

View File

@ -1,5 +1,7 @@
2002-04-11 Juergen Vigna <jug@sad.it> 2002-04-11 Juergen Vigna <jug@sad.it>
* insettext.C: new function ciy() and use it for setting inset_y.
* insetert.C (draw): fix the x return for collapsed version. * insetert.C (draw): fix the x return for collapsed version.
2002-04-07 Herbert Voss <voss@perce.de> 2002-04-07 Herbert Voss <voss@perce.de>

View File

@ -425,7 +425,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
if (the_locking_inset && (cpar(bv) == inset_par) if (the_locking_inset && (cpar(bv) == inset_par)
&& (cpos(bv) == inset_pos)) { && (cpos(bv) == inset_pos)) {
inset_x = cx(bv) - top_x + drawTextXOffset; inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset; inset_y = ciy(bv) + drawTextYOffset;
} }
if (!cleared && (need_update == CURSOR) if (!cleared && (need_update == CURSOR)
&& !getLyXText(bv)->selection.set()) { && !getLyXText(bv)->selection.set()) {
@ -559,7 +559,7 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
if (the_locking_inset) { if (the_locking_inset) {
inset_x = cx(bv) - top_x + drawTextXOffset; inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset; inset_y = ciy(bv) + drawTextYOffset;
the_locking_inset->update(bv, font, reinit); the_locking_inset->update(bv, font, reinit);
} }
@ -786,7 +786,7 @@ void InsetText::lockInset(BufferView * bv, UpdatableInset * inset)
{ {
the_locking_inset = inset; the_locking_inset = inset;
inset_x = cx(bv) - top_x + drawTextXOffset; inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset; inset_y = ciy(bv) + drawTextYOffset;
inset_pos = cpos(bv); inset_pos = cpos(bv);
inset_par = cpar(bv); inset_par = cpar(bv);
inset_boundary = cboundary(bv); inset_boundary = cboundary(bv);
@ -832,7 +832,7 @@ bool InsetText::lockInsetInInset(BufferView * bv, UpdatableInset * inset)
if (cpar(bv) == inset_par && cpos(bv) == inset_pos) { if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
lyxerr[Debug::INSETS] << "OK" << endl; lyxerr[Debug::INSETS] << "OK" << endl;
inset_x = cx(bv) - top_x + drawTextXOffset; inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset; inset_y = ciy(bv) + drawTextYOffset;
} else { } else {
lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl; lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
} }
@ -910,7 +910,7 @@ bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset)
cpar(bv) == inset_par && cpos(bv) == inset_pos) cpar(bv) == inset_par && cpos(bv) == inset_pos)
{ {
inset_x = cx(bv) - top_x + drawTextXOffset; inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset; inset_y = ciy(bv) + drawTextYOffset;
} }
} }
return found; return found;
@ -943,7 +943,7 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
// otherwise unlock the_locking_inset and lock the new inset // otherwise unlock the_locking_inset and lock the new inset
the_locking_inset->insetUnlock(bv); the_locking_inset->insetUnlock(bv);
inset_x = cx(bv) - top_x + drawTextXOffset; inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset; inset_y = ciy(bv) + drawTextYOffset;
the_locking_inset = 0; the_locking_inset = 0;
inset->insetButtonPress(bv, x - inset_x, inset->insetButtonPress(bv, x - inset_x,
y - inset_y, button); y - inset_y, button);
@ -1044,7 +1044,7 @@ bool InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button)
y - inset_y, button); y - inset_y, button);
} else { } else {
inset_x = cx(bv) - top_x + drawTextXOffset; inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset; inset_y = ciy(bv) + drawTextYOffset;
ret = inset->insetButtonRelease(bv, x - inset_x, ret = inset->insetButtonRelease(bv, x - inset_x,
y - inset_y, button); y - inset_y, button);
inset->edit(bv, x - inset_x, inset->edit(bv, x - inset_x,
@ -1747,7 +1747,7 @@ void InsetText::showInsetCursor(BufferView * bv, bool show)
int const asc = lyxfont::maxAscent(font); int const asc = lyxfont::maxAscent(font);
int const desc = lyxfont::maxDescent(font); int const desc = lyxfont::maxDescent(font);
bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc); bv->fitLockedInsetCursor(cx(bv), ciy(bv), asc, desc);
if (show) if (show)
bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc); bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
setCursorVisible(true); setCursorVisible(true);
@ -2020,7 +2020,7 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
if (y < 0) if (y < 0)
y = insetDescent; y = insetDescent;
inset_x = cx(bv) - top_x + drawTextXOffset; inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset; inset_y = ciy(bv) + drawTextYOffset;
inset->edit(bv, x - inset_x, y - inset_y, button); inset->edit(bv, x - inset_x, y - inset_y, button);
if (!the_locking_inset) if (!the_locking_inset)
return false; return false;
@ -2137,6 +2137,13 @@ int InsetText::cy(BufferView * bv) const
} }
int InsetText::ciy(BufferView * bv) const
{
LyXFont font;
return getLyXText(bv)->cursor.iy() - ascent(bv, font) + TEXT_TO_INSET_OFFSET;
}
pos_type InsetText::cpos(BufferView * bv) const pos_type InsetText::cpos(BufferView * bv) const
{ {
return getLyXText(bv)->cursor.pos(); return getLyXText(bv)->cursor.pos();
@ -2286,7 +2293,7 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
restoreLyXTextState(bv, t); restoreLyXTextState(bv, t);
if (the_locking_inset) { if (the_locking_inset) {
inset_x = cx(bv) - top_x + drawTextXOffset; inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset; inset_y = ciy(bv) + drawTextYOffset;
} }
if (bv->screen()) { if (bv->screen()) {
@ -2327,7 +2334,7 @@ void InsetText::reinitLyXText() const
restoreLyXTextState(bv, t); restoreLyXTextState(bv, t);
if (the_locking_inset) { if (the_locking_inset) {
inset_x = cx(bv) - top_x + drawTextXOffset; inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset; inset_y = ciy(bv) + drawTextYOffset;
} }
if (bv->screen()) { if (bv->screen()) {
t->first_y = bv->screen()->topCursorVisible(t); t->first_y = bv->screen()->topCursorVisible(t);

View File

@ -323,6 +323,8 @@ private:
/// ///
int cy(BufferView *) const; int cy(BufferView *) const;
/// ///
int ciy(BufferView *) const;
///
lyx::pos_type cpos(BufferView *) const; lyx::pos_type cpos(BufferView *) const;
/// ///
Paragraph * cpar(BufferView *) const; Paragraph * cpar(BufferView *) const;