From cb796d31b0b3a573e9e5e92117675a9ceaa2da85 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sun, 2 Sep 2007 11:27:19 +0000 Subject: [PATCH] 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 --- src/Text.cpp | 13 ------------- src/Text.h | 7 ------- src/TextMetrics.cpp | 14 ++++++++++++++ src/TextMetrics.h | 5 +++++ src/rowpainter.cpp | 6 +++--- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/Text.cpp b/src/Text.cpp index 4013905d6d..230d64c3ed 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -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, word_location const loc) { diff --git a/src/Text.h b/src/Text.h index f0d75fa8ef..fe8714079a 100644 --- a/src/Text.h +++ b/src/Text.h @@ -256,13 +256,6 @@ public: /// return true if this is the main text 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; /// make a suggestion for a label diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 9bde046c8e..cde93d0cfb 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -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 { BOOST_ASSERT(pit >= 0); diff --git a/src/TextMetrics.h b/src/TextMetrics.h index 784e91fc36..77f4166f53 100644 --- a/src/TextMetrics.h +++ b/src/TextMetrics.h @@ -181,6 +181,11 @@ public: /// 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. /// \warning This method is not recursive! It will return the /// outermost inset within this Text. diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp index 82fa18dbb3..f85af08eef 100644 --- a/src/rowpainter.cpp +++ b/src/rowpainter.cpp @@ -389,7 +389,7 @@ void RowPainter::paintChangeBar() if (start == end || !par_.isChanged(start, end)) return; - int const height = text_.isLastRow(pit_, row_) + int const height = text_metrics_.isLastRow(pit_, row_) ? row_.ascent() : row_.height(); @@ -421,7 +421,7 @@ void RowPainter::paintDepthBar() return; depth_type prev_depth = 0; - if (!text_.isFirstRow(pit_, row_)) { + if (!text_metrics_.isFirstRow(pit_, row_)) { pit_type pit2 = pit_; if (row_.pos() == 0) --pit2; @@ -429,7 +429,7 @@ void RowPainter::paintDepthBar() } depth_type next_depth = 0; - if (!text_.isLastRow(pit_, row_)) { + if (!text_metrics_.isLastRow(pit_, row_)) { pit_type pit2 = pit_; if (row_.endpos() >= pars_[pit2].size()) ++pit2; -- 2.39.2