From 55f184563eefc9706e9eefa176e794aef1dea713 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 27 Aug 2007 22:36:20 +0000 Subject: [PATCH] - Transfer rowpainter.cpp:paintTextInset() to TextMetrics::draw() git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19842 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Text.cpp | 7 ------- src/TextMetrics.cpp | 26 +++++++++++++++++++++----- src/TextMetrics.h | 1 + src/insets/InsetText.cpp | 2 +- src/rowpainter.cpp | 20 ++------------------ src/rowpainter.h | 6 ++++-- 6 files changed, 29 insertions(+), 33 deletions(-) diff --git a/src/Text.cpp b/src/Text.cpp index 3b47413b49..c159d6f27c 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -1354,13 +1354,6 @@ bool Text::dissolveInset(Cursor & cur) { } -// only used for inset right now. should also be used for main text -void Text::draw(PainterInfo & pi, int x, int y) const -{ - paintTextInset(*this, pi, x, y); -} - - // only used for inset right now. should also be used for main text void Text::drawSelection(PainterInfo & pi, int x, int) const { diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 3a52902078..caa6d5de52 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -22,18 +22,19 @@ #include "Buffer.h" #include "BufferParams.h" #include "BufferView.h" -#include "paragraph_funcs.h" -#include "ParIterator.h" +#include "Color.h" #include "CoordCache.h" #include "debug.h" -#include "FuncRequest.h" #include "FontIterator.h" -#include "Color.h" +#include "FuncRequest.h" #include "Length.h" #include "LyXRC.h" -#include "Text.h" #include "MetricsInfo.h" +#include "paragraph_funcs.h" #include "ParagraphParameters.h" +#include "ParIterator.h" +#include "rowpainter.h" +#include "Text.h" #include "VSpace.h" #include "frontends/FontMetrics.h" @@ -963,6 +964,21 @@ int TextMetrics::singleWidth(pit_type pit, pos_type pos) const } +// only used for inset right now. should also be used for main text +void TextMetrics::draw(PainterInfo & pi, int x, int y) const +{ + ParMetricsCache::const_iterator it = par_metrics_.begin(); + ParMetricsCache::const_iterator const end = par_metrics_.end(); + y -= it->second.ascent(); + for (; it != end; ++it) { + ParagraphMetrics const & pmi = it->second; + y += pmi.ascent(); + paintPar(pi, *text_, it->first, x, y, true); + y += pmi.descent(); + } +} + + //int Text::pos2x(pit_type pit, pos_type pos) const //{ // ParagraphMetrics const & pm = par_metrics_[pit]; diff --git a/src/TextMetrics.h b/src/TextMetrics.h index 0e9df11111..19adbaa30d 100644 --- a/src/TextMetrics.h +++ b/src/TextMetrics.h @@ -73,6 +73,7 @@ public: * the cursor and when creating a visible row */ RowMetrics computeRowMetrics(pit_type pit, Row const & row) const; + void draw(PainterInfo & pi, int x, int y) const; private: /// diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index caff61676c..c9b70dd83a 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -194,7 +194,7 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const TextMetrics & tm = pi.base.bv->textMetrics(&text_); - text_.draw(pi, x + border_, y); + tm.draw(pi, x + border_, y); if (drawFrame_) { int const w = tm.width() + 2 * border_; diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp index ca2618eb80..9751a5c016 100644 --- a/src/rowpainter.cpp +++ b/src/rowpainter.cpp @@ -876,6 +876,8 @@ bool CursorOnRow(PainterInfo & pi, pit_type const pit, return false; } +} // namespace anon + void paintPar (PainterInfo & pi, Text const & text, pit_type pit, int x, int y, @@ -948,8 +950,6 @@ void paintPar LYXERR(Debug::PAINTING) << "." << endl; } -} // namespace anon - void paintText(BufferView & bv, Painter & pain) @@ -995,20 +995,4 @@ void paintText(BufferView & bv, pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, Color::bottomarea); } - -void paintTextInset(Text const & text, PainterInfo & pi, int x, int y) -{ -// lyxerr << " paintTextInset: y: " << y << endl; - - y -= pi.base.bv->parMetrics(&text, 0).ascent(); - for (int pit = 0; pit < int(text.paragraphs().size()); ++pit) { - ParagraphMetrics const & pmi - = pi.base.bv->parMetrics(&text, pit); - y += pmi.ascent(); - paintPar(pi, text, pit, x, y, true); - y += pmi.descent(); - } -} - - } // namespace lyx diff --git a/src/rowpainter.h b/src/rowpainter.h index 63bad10004..a602bfe6ec 100644 --- a/src/rowpainter.h +++ b/src/rowpainter.h @@ -28,8 +28,10 @@ namespace frontend { class Painter; } /// paint visible paragraph of main text void paintText(BufferView & bv, frontend::Painter & painter); -/// paint the rows of a text inset -void paintTextInset(Text const & text, PainterInfo & pi, int x, int y); +/// paint paragraph. +void paintPar + (PainterInfo & pi, Text const & text, pit_type pit, int x, int y, + bool repaintAll); /// some space for drawing the 'nested' markers (in pixel) inline int nestMargin() { return 15; } -- 2.39.5