- Transfer rowpainter.cpp:paintTextInset() to TextMetrics::draw()

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19842 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-08-27 22:36:20 +00:00
parent 27ca671388
commit 55f184563e
6 changed files with 29 additions and 33 deletions

View File

@ -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 // only used for inset right now. should also be used for main text
void Text::drawSelection(PainterInfo & pi, int x, int) const void Text::drawSelection(PainterInfo & pi, int x, int) const
{ {

View File

@ -22,18 +22,19 @@
#include "Buffer.h" #include "Buffer.h"
#include "BufferParams.h" #include "BufferParams.h"
#include "BufferView.h" #include "BufferView.h"
#include "paragraph_funcs.h" #include "Color.h"
#include "ParIterator.h"
#include "CoordCache.h" #include "CoordCache.h"
#include "debug.h" #include "debug.h"
#include "FuncRequest.h"
#include "FontIterator.h" #include "FontIterator.h"
#include "Color.h" #include "FuncRequest.h"
#include "Length.h" #include "Length.h"
#include "LyXRC.h" #include "LyXRC.h"
#include "Text.h"
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "paragraph_funcs.h"
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
#include "ParIterator.h"
#include "rowpainter.h"
#include "Text.h"
#include "VSpace.h" #include "VSpace.h"
#include "frontends/FontMetrics.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 //int Text::pos2x(pit_type pit, pos_type pos) const
//{ //{
// ParagraphMetrics const & pm = par_metrics_[pit]; // ParagraphMetrics const & pm = par_metrics_[pit];

View File

@ -73,6 +73,7 @@ public:
* the cursor and when creating a visible row */ * the cursor and when creating a visible row */
RowMetrics computeRowMetrics(pit_type pit, Row const & row) const; RowMetrics computeRowMetrics(pit_type pit, Row const & row) const;
void draw(PainterInfo & pi, int x, int y) const;
private: private:
/// ///

View File

@ -194,7 +194,7 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
TextMetrics & tm = pi.base.bv->textMetrics(&text_); TextMetrics & tm = pi.base.bv->textMetrics(&text_);
text_.draw(pi, x + border_, y); tm.draw(pi, x + border_, y);
if (drawFrame_) { if (drawFrame_) {
int const w = tm.width() + 2 * border_; int const w = tm.width() + 2 * border_;

View File

@ -876,6 +876,8 @@ bool CursorOnRow(PainterInfo & pi, pit_type const pit,
return false; return false;
} }
} // namespace anon
void paintPar void paintPar
(PainterInfo & pi, Text const & text, pit_type pit, int x, int y, (PainterInfo & pi, Text const & text, pit_type pit, int x, int y,
@ -948,8 +950,6 @@ void paintPar
LYXERR(Debug::PAINTING) << "." << endl; LYXERR(Debug::PAINTING) << "." << endl;
} }
} // namespace anon
void paintText(BufferView & bv, void paintText(BufferView & bv,
Painter & pain) Painter & pain)
@ -995,20 +995,4 @@ void paintText(BufferView & bv,
pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, Color::bottomarea); 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 } // namespace lyx

View File

@ -28,8 +28,10 @@ namespace frontend { class Painter; }
/// paint visible paragraph of main text /// paint visible paragraph of main text
void paintText(BufferView & bv, frontend::Painter & painter); void paintText(BufferView & bv, frontend::Painter & painter);
/// paint the rows of a text inset /// paint paragraph.
void paintTextInset(Text const & text, PainterInfo & pi, int x, int y); 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) /// some space for drawing the 'nested' markers (in pixel)
inline int nestMargin() { return 15; } inline int nestMargin() { return 15; }