rowpainter.C: remove extra metrics calls

lyxtext.h: merge the two constructors into a single one,
 pass reference to owner's par list

 BufferView_pimpl.C:
 text.C:
 text2.C: adjust


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7557 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-08-15 14:54:19 +00:00
parent f48ccf9641
commit 040a03e4a4
7 changed files with 36 additions and 64 deletions

View File

@ -418,7 +418,7 @@ void BufferView::Pimpl::resizeCurrentBuffer()
textcache.show(lyxerr, "resizeCurrentBuffer");
} else {
lyxerr << "no text in cache!" << endl;
bv_->text = new LyXText(bv_);
bv_->text = new LyXText(bv_, 0, false, bv_->buffer()->paragraphs);
bv_->text->init(bv_);
}

View File

@ -1,4 +1,15 @@
2003-08-15 André Pönitz <poenitz@gmx.net>
* rowpainter.C: remove extra metrics calls
* lyxtext.h: merge the two constructors into a single one,
pass reference to owner's par list
* BufferView_pimpl.C:
* text.C:
* text2.C: adjust
2003-08-15 André Pönitz <poenitz@gmx.net>
* lyxrow_funcs.[Ch]:

View File

@ -82,7 +82,7 @@ using lyx::textclass_type;
InsetText::InsetText(BufferParams const & bp)
: UpdatableInset(), text_(0, this)
: UpdatableInset(), text_(0, this, true, paragraphs)
{
paragraphs.push_back(Paragraph());
paragraphs.begin()->layout(bp.getLyXTextClass().defaultLayout());
@ -93,7 +93,7 @@ InsetText::InsetText(BufferParams const & bp)
InsetText::InsetText(InsetText const & in)
: UpdatableInset(in), text_(0, this)
: UpdatableInset(in), text_(0, this, true, paragraphs)
{
init(&in);
}
@ -1586,8 +1586,8 @@ void InsetText::setViewCache(BufferView const * bv) const
{
if (bv) {
if (bv != text_.bv_owner) {
lyxerr << "setting view cache from "
<< text_.bv_owner << " to " << bv << "\n";
//lyxerr << "setting view cache from "
// << text_.bv_owner << " to " << bv << "\n";
text_.init(const_cast<BufferView *>(bv));
}
text_.bv_owner = const_cast<BufferView *>(bv);

View File

@ -50,9 +50,8 @@ class Dimension;
class LyXText : public TextCursor {
public:
/// Constructor
LyXText(BufferView *);
/// sets inset as owner
LyXText(BufferView *, InsetText *);
LyXText(BufferView *, InsetText *, bool ininset,
ParagraphList & paragraphs);
void init(BufferView *);
///
@ -480,6 +479,11 @@ private:
///
mutable lyx::pos_type bidi_end;
///
const bool in_inset_;
///
ParagraphList & paragraphs_;
///
void charInserted();
public:

View File

@ -1065,47 +1065,11 @@ int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
}
void paintRow(BufferView const & bv, LyXText const & text,
ParagraphList::iterator pit,
RowList::iterator rit, int y_offset, int x_offset, int y)
{
RowPainter painter(bv, text, pit, rit, y_offset, x_offset, y);
painter.paint();
}
int paintRows(BufferView const & bv, LyXText const & text,
RowList::iterator rit, int xo, int y, int yf, int y2, int yo)
{
// fix up missing metrics() call for main LyXText
// calling metrics() directly is (a) slow and (b) crashs
if (&text == bv.text) {
#if 1
// make sure all insets are updated
ParagraphList::iterator pit = text.ownerParagraphs().begin();
ParagraphList::iterator end = text.ownerParagraphs().end();
// compute inset metrics
for (; pit != end; ++pit) {
InsetList & insetList = pit->insetlist;
InsetList::iterator ii = insetList.begin();
InsetList::iterator iend = insetList.end();
for (; ii != iend; ++ii) {
Dimension dim;
LyXFont font;
MetricsInfo mi(perv(bv), font, text.workWidth());
ii->inset->metrics(mi, dim);
}
}
#else
LyXFont font;
Dimension dim;
MetricsInfo mi(perv(bv), font, text.workWidth());
const_cast<LyXText&>(text).metrics(mi, dim);
#endif
}
//lyxerr << "paintRows: rit: " << &*rit << endl;
const_cast<LyXText&>(text).updateRowPositions();
int yy = yf - y;
ParagraphList::iterator pit = text.ownerParagraphs().begin();
@ -1120,7 +1084,8 @@ int paintRows(BufferView const & bv, LyXText const & text,
if (row == rit)
active = true;
if (active) {
paintRow(bv, text, pit, row, y + yo, xo, y + text.top_y());
RowPainter painter(bv, text, pit, row, y + yo, xo, y + text.top_y());
painter.paint();
y += row->height();
if (yy + y >= y2)
return y;

View File

@ -103,9 +103,6 @@ int LyXText::top_y() const
void LyXText::top_y(int newy)
{
if (ownerParagraphs().begin()->rows.empty())
return;
anchor_y_ = newy;
lyxerr[Debug::GUI] << "changing reference to offset: " << anchor_y_ << endl;
}

View File

@ -59,16 +59,13 @@ using std::pair;
using lyx::pos_type;
LyXText::LyXText(BufferView * bv)
LyXText::LyXText(BufferView * bv, InsetText * inset, bool ininset,
ParagraphList & paragraphs)
: height(0), width(0), anchor_y_(0),
inset_owner(0), the_locking_inset(0), bv_owner(bv)
{}
LyXText::LyXText(BufferView * bv, InsetText * inset)
: height(0), width(0), anchor_y_(0),
inset_owner(inset), the_locking_inset(0), bv_owner(bv)
{}
inset_owner(inset), the_locking_inset(0), bv_owner(bv),
in_inset_(ininset), paragraphs_(paragraphs)
{
}
void LyXText::init(BufferView * bview)
@ -595,7 +592,8 @@ void LyXText::fullRebreak()
void LyXText::metrics(MetricsInfo & mi, Dimension & dim)
{
//lyxerr << "LyXText::metrics: width: " << mi.base.textwidth << endl;
//lyxerr << "LyXText::metrics: width: " << mi.base.textwidth
// << " workWidth: " << workWidth() << endl;
//Assert(mi.base.textwidth);
// rebuild row cache
@ -1944,17 +1942,14 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
ParagraphList & LyXText::ownerParagraphs() const
{
if (inset_owner) {
return inset_owner->paragraphs;
}
return bv_owner->buffer()->paragraphs;
return paragraphs_;
}
bool LyXText::isInInset() const
{
// Sub-level has non-null bv owner and non-null inset owner.
return inset_owner != 0 && bv_owner != 0;
return inset_owner != 0;
}