Transfer metrics and screen related methods from Text to TextMetrics.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19995 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-09-02 11:27:19 +00:00
parent 502b048246
commit cb796d31b0
5 changed files with 22 additions and 23 deletions

View File

@ -1160,19 +1160,6 @@ bool Text::dissolveInset(Cursor & cur) {
} }
bool Text::isLastRow(pit_type pit, Row const & row) const
{
return row.endpos() >= pars_[pit].size()
&& pit + 1 == pit_type(paragraphs().size());
}
bool Text::isFirstRow(pit_type pit, Row const & row) const
{
return row.pos() == 0 && pit == 0;
}
void Text::getWord(CursorSlice & from, CursorSlice & to, void Text::getWord(CursorSlice & from, CursorSlice & to,
word_location const loc) word_location const loc)
{ {

View File

@ -256,13 +256,6 @@ public:
/// return true if this is the main text /// return true if this is the main text
bool isMainText(Buffer const &) const; bool isMainText(Buffer const &) const;
/// is this row the last in the text?
/// FIXME: move to TextMetrics.
bool isLastRow(pit_type pit, Row const & row) const;
/// is this row the first in the text?
/// FIXME: move to TextMetrics.
bool isFirstRow(pit_type pit, Row const & row) const;
/// ///
double spacing(Buffer const & buffer, Paragraph const & par) const; double spacing(Buffer const & buffer, Paragraph const & par) const;
/// make a suggestion for a label /// make a suggestion for a label

View File

@ -1457,6 +1457,20 @@ void TextMetrics::deleteLineForward(Cursor & cur)
} }
bool TextMetrics::isLastRow(pit_type pit, Row const & row) const
{
ParagraphList const & pars = text_->paragraphs();
return row.endpos() >= pars[pit].size()
&& pit + 1 == pit_type(pars.size());
}
bool TextMetrics::isFirstRow(pit_type pit, Row const & row) const
{
return row.pos() == 0 && pit == 0;
}
int TextMetrics::leftMargin(int max_width, pit_type pit) const int TextMetrics::leftMargin(int max_width, pit_type pit) const
{ {
BOOST_ASSERT(pit >= 0); BOOST_ASSERT(pit >= 0);

View File

@ -181,6 +181,11 @@ public:
/// ///
void deleteLineForward(Cursor & cur); void deleteLineForward(Cursor & cur);
/// is this row the last in the text?
bool isLastRow(pit_type pit, Row const & row) const;
/// is this row the first in the text?
bool isFirstRow(pit_type pit, Row const & row) const;
/// Returns an inset if inset was hit, or 0 if not. /// Returns an inset if inset was hit, or 0 if not.
/// \warning This method is not recursive! It will return the /// \warning This method is not recursive! It will return the
/// outermost inset within this Text. /// outermost inset within this Text.

View File

@ -389,7 +389,7 @@ void RowPainter::paintChangeBar()
if (start == end || !par_.isChanged(start, end)) if (start == end || !par_.isChanged(start, end))
return; return;
int const height = text_.isLastRow(pit_, row_) int const height = text_metrics_.isLastRow(pit_, row_)
? row_.ascent() ? row_.ascent()
: row_.height(); : row_.height();
@ -421,7 +421,7 @@ void RowPainter::paintDepthBar()
return; return;
depth_type prev_depth = 0; depth_type prev_depth = 0;
if (!text_.isFirstRow(pit_, row_)) { if (!text_metrics_.isFirstRow(pit_, row_)) {
pit_type pit2 = pit_; pit_type pit2 = pit_;
if (row_.pos() == 0) if (row_.pos() == 0)
--pit2; --pit2;
@ -429,7 +429,7 @@ void RowPainter::paintDepthBar()
} }
depth_type next_depth = 0; depth_type next_depth = 0;
if (!text_.isLastRow(pit_, row_)) { if (!text_metrics_.isLastRow(pit_, row_)) {
pit_type pit2 = pit_; pit_type pit2 = pit_;
if (row_.endpos() >= pars_[pit2].size()) if (row_.endpos() >= pars_[pit2].size())
++pit2; ++pit2;