#include "lyxfont.h"
#include "layout.h"
#include "lyxlayout_ptr_fwd.h"
-#include "RowList_fwd.h"
#include "ParagraphList_fwd.h"
#include <iosfwd>
* y-coordinate (relative to the whole text). y is set to the
* real beginning of this row
*/
- RowList::iterator getRowNearY(int y, par_type & pit) const;
+ Row const & getRowNearY(int y, par_type & pit) const;
/** returns the column near the specified x-coordinate of the row
x is set to the real beginning of this column
bool isMainText() const;
/// return first row of text
- RowList::iterator firstRow() const;
- /// return last row of text
- RowList::iterator lastRow() const;
- /// return row "behind" last row of text
- RowList::iterator endRow() const;
- /// return next row crossing paragraph boundaries
- void nextRow(par_type & pit, RowList::iterator & rit) const;
- /// return previous row crossing paragraph boundaries
- void previousRow(par_type & pit, RowList::iterator & rit) const;
+ Row const & firstRow() const;
/// is this row the last in the text?
bool isLastRow(par_type pit, Row const & row) const;
// y is relative to this LyXText's top
-RowList::iterator LyXText::getRowNearY(int y, par_type & pit) const
+Row const & LyXText::getRowNearY(int y, par_type & pit) const
{
BOOST_ASSERT(!paragraphs().empty());
BOOST_ASSERT(!paragraphs().begin()->rows.empty());
-#if 1
par_type const pend = paragraphs().size() - 1;
pit = 0;
while (int(pars_[pit].y + pars_[pit].height) < y && pit != pend)
--rit;
} while (rit != rbegin && int(pars_[pit].y + rit->y_offset()) > y);
- return rit;
-#else
- pit = paragraphs().size() - 1;
-
- RowList::iterator rit = lastRow();
- RowList::iterator rbegin = firstRow();
-
- while (rit != rbegin && int(pars_[pit].y + rit->y_offset()) > y)
- previousRow(pit, rit);
-
- return rit;
-#endif
-}
-
-
-RowList::iterator LyXText::firstRow() const
-{
- return paragraphs().front().rows.begin();
+ return *rit;
}
-RowList::iterator LyXText::lastRow() const
+Row const & LyXText::firstRow() const
{
- return boost::prior(endRow());
-}
-
-
-RowList::iterator LyXText::endRow() const
-{
- return paragraphs().back().rows.end();
-}
-
-
-void LyXText::nextRow(par_type & pit, RowList::iterator & rit) const
-{
- ++rit;
- if (rit == pars_[pit].rows.end()) {
- ++pit;
- if (pit == par_type(paragraphs().size()))
- --pit;
- else
- rit = pars_[pit].rows.begin();
- }
-}
-
-
-void LyXText::previousRow(par_type & pit, RowList::iterator & rit) const
-{
- if (rit != pars_[pit].rows.begin())
- --rit;
- else {
- BOOST_ASSERT(pit != 0);
- --pit;
- rit = boost::prior(pars_[pit].rows.end());
- }
+ return *paragraphs().front().rows.begin();
}
width_ = maxParagraphWidth(paragraphs());
// final dimension
- dim.asc = firstRow()->ascent_of_text();
+ dim.asc = firstRow().ascent_of_text();
dim.des = height_ - dim.asc;
dim.wid = width_;
}
int LyXText::ascent() const
{
- return firstRow()->ascent_of_text();
+ return firstRow().ascent_of_text();
}
int LyXText::descent() const
{
- return height_ - firstRow()->ascent_of_text();
+ return height_ - firstRow().ascent_of_text();
}
x -= xo_;
y -= yo_;
par_type pit;
- Row const & row = *getRowNearY(y, pit);
+ Row const & row = getRowNearY(y, pit);
lyxerr << "setCursorFromCoordinates:: hit row at: " << row.pos() << endl;
bool bound = false;
int xx = x + xo_; // getRowNearX get absolute x coords
InsetBase * LyXText::editXY(LCursor & cur, int x, int y)
{
par_type pit;
- Row const & row = *getRowNearY(y - yo_, pit);
+ Row const & row = getRowNearY(y - yo_, pit);
bool bound = false;
int xx = x; // is modified by getColumnNearX