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_);
}
+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]:
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());
InsetText::InsetText(InsetText const & in)
- : UpdatableInset(in), text_(0, this)
+ : UpdatableInset(in), text_(0, this, true, paragraphs)
{
init(&in);
}
{
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);
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 *);
///
///
mutable lyx::pos_type bidi_end;
+ ///
+ const bool in_inset_;
+ ///
+ ParagraphList & paragraphs_;
+
///
void charInserted();
public:
}
-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();
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;
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;
}
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)
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
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;
}