From: Jean-Marc Lasgouttes Date: Fri, 13 Aug 2004 19:14:17 +0000 (+0000) Subject: constify the various incarnations of editXY X-Git-Tag: 1.6.10~15089 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=9e20808369e80d7823a09e9d71c4c9f9183c9e4a;p=lyx.git constify the various incarnations of editXY git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8907 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 6aaa39784c..22ec2ee7a8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-08-13 Jean-Marc Lasgouttes + + * text2.C (editXY): + * text3.C (checkInsetHit): constify + 2004-08-13 Jean-Marc Lasgouttes * LyXAction.C (init): mark LFUN_WORD_FIND as working in read-only diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 19287b2378..753aac8eb9 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,5 +1,11 @@ 2004-08-13 Jean-Marc Lasgouttes + * insettext.C (editXY): + + * insettabular.C (editXY): + * insetcollapsable.C (editXY): + * insetbase.C (editXY): constify + * insetcollapsable.C (priv_dispatch): on a mouse press event, do not ask for an update if we did nothing; on a mouse release, make sure that the cursor is moved to the right position; on a mouse diff --git a/src/insets/insetbase.C b/src/insets/insetbase.C index bc27fb0968..abfeeb8ca7 100644 --- a/src/insets/insetbase.C +++ b/src/insets/insetbase.C @@ -138,10 +138,10 @@ void InsetBase::edit(LCursor &, bool) } -InsetBase * InsetBase::editXY(LCursor &, int x, int y) +InsetBase * InsetBase::editXY(LCursor &, int x, int y) const { lyxerr << "InsetBase: editXY x:" << x << " y: " << y << std::endl; - return this; + return const_cast(this); } diff --git a/src/insets/insetbase.h b/src/insets/insetbase.h index 5f9e1c2ac9..1287b5a74a 100644 --- a/src/insets/insetbase.h +++ b/src/insets/insetbase.h @@ -79,7 +79,7 @@ public: /// cursor enters virtual void edit(LCursor & cur, bool left); /// cursor enters - virtual InsetBase * editXY(LCursor & cur, int x, int y); + virtual InsetBase * editXY(LCursor & cur, int x, int y) const; /// compute the size of the object returned in dim virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0; diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 7b31d8e750..7f7fb2b766 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -240,12 +240,12 @@ void InsetCollapsable::edit(LCursor & cur, bool left) } -InsetBase * InsetCollapsable::editXY(LCursor & cur, int x, int y) +InsetBase * InsetCollapsable::editXY(LCursor & cur, int x, int y) const { - cur.push(*this); + cur.push(const_cast(*this)); //lyxerr << "InsetCollapsable: edit xy" << endl; if (status_ == Collapsed) { - return this; + return const_cast(this); } return InsetText::editXY(cur, x, y); } diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 4e30b609a5..335c0ddb34 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -101,7 +101,7 @@ protected: /// void edit(LCursor & cur, bool left); /// - InsetBase * editXY(LCursor & cur, int x, int y); + InsetBase * editXY(LCursor & cur, int x, int y) const; protected: /// diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 515f95cf22..a0c75ba21b 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -394,11 +394,11 @@ void InsetTabular::edit(LCursor & cur, bool left) } -InsetBase * InsetTabular::editXY(LCursor & cur, int x, int y) +InsetBase * InsetTabular::editXY(LCursor & cur, int x, int y) const { //lyxerr << "InsetTabular::editXY: " << this << endl; cur.selection() = false; - cur.push(*this); + cur.push(const_cast(*this)); return setPos(cur, x, y); //int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell); } diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 1e01bb7bd0..712fbe4b61 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -137,7 +137,7 @@ public: /// lock cell with given index void edit(LCursor & cur, bool left); /// - InsetBase * editXY(LCursor & cur, int x, int y); + InsetBase * editXY(LCursor & cur, int x, int y) const; /// can we go further down on mouse click? bool descendable() const { return true; } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 1fc588c0e2..cd751325f5 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -304,7 +304,7 @@ void InsetText::edit(LCursor & cur, bool left) } -InsetBase * InsetText::editXY(LCursor & cur, int x, int y) +InsetBase * InsetText::editXY(LCursor & cur, int x, int y) const { lyxerr << "InsetText::edit xy" << endl; old_par = -1; diff --git a/src/insets/insettext.h b/src/insets/insettext.h index d89bb3413e..09ba688011 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -138,7 +138,7 @@ public: /// void edit(LCursor & cur, bool left); /// - InsetBase * editXY(LCursor & cur, int x, int y); + InsetBase * editXY(LCursor & cur, int x, int y) const; /// number of cells in this inset size_t nargs() const { return 1; } diff --git a/src/lyxtext.h b/src/lyxtext.h index 7a489ac934..965f8f990c 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -184,7 +184,7 @@ public: /// void setCursorFromCoordinates(LCursor & cur, int x, int y); /// - InsetBase * editXY(LCursor & cur, int x, int y); + InsetBase * editXY(LCursor & cur, int x, int y) const; /// void cursorUp(LCursor & cur); /// @@ -268,7 +268,7 @@ public: /// updates all counters void updateCounters(); /// Returns an inset if inset was hit, or 0 if not. - InsetBase * checkInsetHit(int x, int y); + InsetBase * checkInsetHit(int x, int y) const; /// int singleWidth(par_type pit, pos_type pos) const; diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index b1fb5ac0cc..fb7004c6fa 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,7 @@ +2004-08-13 Jean-Marc Lasgouttes + + * math_nestinset.C (editXY): constify + 2004-08-13 José Matos * math_hullinset.C (docbook): add awareness of the distinction diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index 74af5a1439..341faf7d41 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -879,7 +879,7 @@ void MathNestInset::edit(LCursor & cur, bool left) } -InsetBase * MathNestInset::editXY(LCursor & cur, int x, int y) +InsetBase * MathNestInset::editXY(LCursor & cur, int x, int y) const { int idx_min = 0; int dist_min = 1000000; @@ -890,8 +890,8 @@ InsetBase * MathNestInset::editXY(LCursor & cur, int x, int y) idx_min = i; } } - MathArray & ar = cell(idx_min); - cur.push(*this); + MathArray const & ar = cell(idx_min); + cur.push(const_cast(*this)); cur.idx() = idx_min; cur.pos() = ar.x2pos(x - ar.xo()); lyxerr << "found cell : " << idx_min << " pos: " << cur.pos() << endl; @@ -901,7 +901,7 @@ InsetBase * MathNestInset::editXY(LCursor & cur, int x, int y) if (ar[i]->covers(x, y)) return ar[i].nucleus()->editXY(cur, x, y); } - return this; + return const_cast(this); } diff --git a/src/mathed/math_nestinset.h b/src/mathed/math_nestinset.h index 012f1542ae..819d64dc64 100644 --- a/src/mathed/math_nestinset.h +++ b/src/mathed/math_nestinset.h @@ -41,7 +41,7 @@ public: /// void edit(LCursor & cur, bool left); /// - InsetBase * editXY(LCursor & cur, int x, int y); + InsetBase * editXY(LCursor & cur, int x, int y) const; /// order of movement through the cells when pressing the left key bool idxLeft(LCursor &) const; diff --git a/src/text2.C b/src/text2.C index 8b8db5f61e..d7a8733ba0 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1138,7 +1138,7 @@ void LyXText::setCursorFromCoordinates(LCursor & cur, int x, int y) // x,y are absolute screen coordinates -InsetBase * LyXText::editXY(LCursor & cur, int x, int y) +InsetBase * LyXText::editXY(LCursor & cur, int x, int y) const { par_type pit; Row const & row = getRowNearY(y - yo_, pit); diff --git a/src/text3.C b/src/text3.C index 4a36c41392..dd6b10244a 100644 --- a/src/text3.C +++ b/src/text3.C @@ -185,7 +185,7 @@ string const freefont2string() //takes absolute x,y coordinates -InsetBase * LyXText::checkInsetHit(int x, int y) +InsetBase * LyXText::checkInsetHit(int x, int y) const { par_type pit; par_type end; @@ -198,8 +198,8 @@ InsetBase * LyXText::checkInsetHit(int x, int y) lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl; lyxerr << " pit: " << pit << " end: " << end << endl; for (; pit != end; ++pit) { - InsetList::iterator iit = pars_[pit].insetlist.begin(); - InsetList::iterator iend = pars_[pit].insetlist.end(); + InsetList::const_iterator iit = pars_[pit].insetlist.begin(); + InsetList::const_iterator iend = pars_[pit].insetlist.end(); for (; iit != iend; ++iit) { InsetBase * inset = iit->inset; #if 0