From b14052f6a5823878733a72f6d8e565cedd5f8c96 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Wed, 28 Mar 2001 09:28:48 +0000 Subject: [PATCH] Changed drawing of button in InsetCollapsable and some Mouse/Curosor fixes. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1840 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/POTFILES.in | 3 ++ src/BufferView_pimpl.C | 5 ++- src/ChangeLog | 4 ++ src/frontends/xforms/FormMinipage.C | 2 +- src/insets/ChangeLog | 18 +++++++++ src/insets/insetcollapsable.C | 63 ++++++++++++----------------- src/insets/insetminipage.C | 8 +++- src/insets/insettext.C | 10 +++-- 8 files changed, 67 insertions(+), 46 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 07541bd66b..53ffdc22a4 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -16,6 +16,9 @@ src/frontends/controllers/ButtonController.h src/frontends/controllers/ControlCharacter.C src/frontends/controllers/ControlCopyright.C src/frontends/controllers/ControlCredits.C +src/frontends/controllers/ControlPreamble.C +src/frontends/controllers/ControlPrint.C +src/frontends/controllers/ControlSearch.C src/frontends/gnome/FormCitation.C src/frontends/gnome/FormCopyright.C src/frontends/gnome/FormError.C diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index f29dfba909..4890ac972e 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -921,6 +921,8 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y, LyXCursor cursor; text->SetCursorFromCoordinates(bv_, cursor, x, y_tmp); + text->SetCursor(bv_, cursor, cursor.par(),cursor.pos(),true); + #ifndef NEW_INSETS if (cursor.pos() < cursor.par()->Last() @@ -943,7 +945,8 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y, if (x > start_x && x < end_x && y_tmp > cursor.y() - tmpinset->ascent(bv_, font) - && y_tmp < cursor.y() + tmpinset->descent(bv_, font)) { + && y_tmp < cursor.y() + tmpinset->descent(bv_, font)) + { text->SetCursor(bv_, cursor.par(),cursor.pos(),true); x = x - start_x; // The origin of an inset is on the baseline diff --git a/src/ChangeLog b/src/ChangeLog index 8da350ce2b..e48aad0859 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2001-03-27 Juergen Vigna + + * BufferView_pimpl.C: set the temporary cursor right! + 2001-03-27 Angus Leeming * BufferView_pimpl.C (Dispatch): corrected spelling givven -> given. diff --git a/src/frontends/xforms/FormMinipage.C b/src/frontends/xforms/FormMinipage.C index bf3cb4a695..7ca95f30f7 100644 --- a/src/frontends/xforms/FormMinipage.C +++ b/src/frontends/xforms/FormMinipage.C @@ -8,7 +8,7 @@ * ====================================================== * * \file FormMinipage.C - * \author Juergen Vigna, jug@sad.it + * \author Jürgen Vigna, jug@sad.it */ #include diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index c3fae2ce3b..5747933438 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,21 @@ +2001-03-28 Juergen Vigna + + * insettext.C (InsetButtonPress): only enter !inset if button == 2 + (checkAndActivateInset): don't use the values returned from + call to bv->checkInsetHit. + + * insetminipage.C (Clone): set special minipage values. + + * insetcollapsable.C (draw): changed to draw the button in the + upper left corner outside the textinset. + (ascent): changed because of different drawing + (descent): ditto + (width): ditto + (Edit): ditto + (InsetButtonPress): ditto + (InsetButtonRelease): ditto + (InsetMotionNotify): ditto + 2001-03-27 Dekel Tsur * figinset.C (GetPSSizes): Fix for the case when filename doesn't diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 847e86642f..7d7e92c855 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -132,10 +132,7 @@ int InsetCollapsable::width_collapsed(Painter & pain, LyXFont const &) const int InsetCollapsable::ascent(BufferView * bv, LyXFont const & font) const { - if (collapsed) - return ascent_collapsed(bv->painter(), font); - else - return inset->ascent(bv, font) + TEXT_TO_TOP_OFFSET; + return ascent_collapsed(bv->painter(), font); } @@ -143,8 +140,9 @@ int InsetCollapsable::descent(BufferView * bv, LyXFont const & font) const { if (collapsed) return descent_collapsed(bv->painter(), font); - else - return inset->descent(bv, font) + TEXT_TO_BOTTOM_OFFSET; + + return descent_collapsed(bv->painter(), font) + inset->descent(bv, font) + + inset->ascent(bv, font) + TEXT_TO_BOTTOM_OFFSET; } @@ -153,7 +151,8 @@ int InsetCollapsable::width(BufferView * bv, LyXFont const & font) const if (collapsed) return widthCollapsed; - return inset->width(bv, font) + widthCollapsed; + return (inset->width(bv, font) > widthCollapsed) ? + inset->width(bv, font) : widthCollapsed; } @@ -173,8 +172,9 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, Painter & pain = bv->painter(); button_length = widthCollapsed; - button_top_y = -ascent_collapsed(pain, f); - button_bottom_y = descent_collapsed(pain, f); + button_top_y = -ascent(bv, f); + button_bottom_y = -ascent(bv, f) + ascent_collapsed(pain,f) + + descent_collapsed(pain, f); if (collapsed) { draw_collapsed(pain, f, baseline, x); x += TEXT_TO_INSET_OFFSET; @@ -202,19 +202,20 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, top_x = int(x); top_baseline = baseline; - draw_collapsed(pain, f, - baseline - ascent(bv, f) + ascent_collapsed(pain, f), - x); + float dummy = x; + int bl = baseline - ascent(bv, f) + ascent_collapsed(pain, f); + + draw_collapsed(pain, f, bl, dummy); inset->draw(bv, f, - baseline - ascent(bv, f) + ascent_collapsed(pain, f), + bl + descent_collapsed(pain, f) + inset->ascent(bv, f), x, cleared); need_update = NONE; } -void InsetCollapsable::Edit(BufferView * bv, int x, int y, unsigned int button) +void InsetCollapsable::Edit(BufferView * bv, int xp, int yp, unsigned int button) { - UpdatableInset::Edit(bv, x, y, button); + UpdatableInset::Edit(bv, xp, yp, button); if (collapsed && autocollapse) { collapsed = false; @@ -225,7 +226,7 @@ void InsetCollapsable::Edit(BufferView * bv, int x, int y, unsigned int button) } else if (!collapsed) { if (!bv->lockInset(this)) return; - inset->Edit(bv, x - widthCollapsed, y, button); + inset->Edit(bv, xp, yp+(top_baseline - inset->y()), button); } } @@ -250,10 +251,8 @@ void InsetCollapsable::InsetUnlock(BufferView * bv) void InsetCollapsable::InsetButtonPress(BufferView * bv,int x,int y,int button) { - if (!collapsed && (x >= button_length)) { - inset->InsetButtonPress(bv, x - widthCollapsed, - y + (top_baseline - inset->y()), - button); + if (!collapsed && (y > button_bottom_y)) { + inset->InsetButtonPress(bv, x, y+(top_baseline - inset->y()), button); } } @@ -262,7 +261,7 @@ void InsetCollapsable::InsetButtonRelease(BufferView * bv, int x, int y, int button) { if ((x >= 0) && (x < button_length) && - (y >= button_top_y) && (y < button_bottom_y)) { + (y >= button_top_y) && (y <= button_bottom_y)) { if (collapsed) { collapsed = false; inset->InsetButtonRelease(bv, 0, 0, button); @@ -272,10 +271,8 @@ void InsetCollapsable::InsetButtonRelease(BufferView * bv, bv->unlockInset(this); bv->updateInset(this, false); } - } else if (!collapsed && (x >= button_length) && (y >= button_top_y)) { - inset->InsetButtonRelease(bv, x - widthCollapsed, - y + (top_baseline - inset->y()), - button); + } else if (!collapsed && (y > button_top_y)) { + inset->InsetButtonRelease(bv, x, y+(top_baseline-inset->y()), button); } } @@ -283,10 +280,8 @@ void InsetCollapsable::InsetButtonRelease(BufferView * bv, void InsetCollapsable::InsetMotionNotify(BufferView * bv, int x, int y, int state) { - if (x >= button_length) { - inset->InsetMotionNotify(bv, x-widthCollapsed, - y + (top_baseline - inset->y()), - state); + if (x > button_bottom_y) { + inset->InsetMotionNotify(bv, x, y+(top_baseline - inset->y()), state); } } @@ -311,6 +306,7 @@ int InsetCollapsable::getMaxWidth(Painter & pain, if (w < 0) { // What does a negative max width signify? (Lgb) + // Use the max width of the draw-area (Jug) return w; } // should be at least 30 pixels !!! @@ -318,15 +314,6 @@ int InsetCollapsable::getMaxWidth(Painter & pain, } -#if 0 -int InsetCollapsable::getMaxTextWidth(Painter & pain, - UpdatableInset const * inset) const -{ - return getMaxWidth(pain, inset) - widthCollapsed; -} -#endif - - void InsetCollapsable::update(BufferView * bv, LyXFont const & font, bool reinit) { diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index ffec4c3848..cc096f24e2 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -173,14 +173,17 @@ Inset * InsetMinipage::Clone(Buffer const &) const result->inset->init(inset); result->collapsed = collapsed; + result->pos_ = pos_; + result->inner_pos_ = inner_pos_; + result->height_ = height_; + result->width_ = width_; + result->widthp_ = widthp_; return result; } int InsetMinipage::ascent(BufferView * bv, LyXFont const & font) const { - lyxerr << "InsetMinipage::ascent" << endl; - if (collapsed) return ascent_collapsed(bv->painter(), font); else { @@ -357,6 +360,7 @@ void InsetMinipage::InsetButtonRelease(BufferView * bv, int x, int y, InsetCollapsable::InsetButtonRelease(bv, x, y, button); } + int InsetMinipage::getMaxWidth(Painter & pain, UpdatableInset const * inset) const { diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 5a7dd6ac1f..833eb64c62 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -712,7 +712,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button) return; } } - if (!inset) { + if (!inset && (button == 2)) { bool paste_internally = false; if ((button == 2) && TEXT(bv)->selection) { LocalDispatch(bv, LFUN_COPY, ""); @@ -1494,9 +1494,11 @@ bool InsetText::checkAndActivateInset(BufferView * bv, bool behind) bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y, int button) { - x = x - drawTextXOffset; - y = y + insetAscent; - Inset * inset = bv->checkInsetHit(TEXT(bv), x, y, button); + int dummyx, dummyy; + + dummyx = x = x - drawTextXOffset; + dummyy = y + insetAscent; + Inset * inset = bv->checkInsetHit(TEXT(bv), dummyx, dummyy, button); if (inset) { if (x < 0) -- 2.39.2