]> git.lyx.org Git - features.git/commitdiff
Disable InsetText::update and InsetTabular::update
authorAndré Pönitz <poenitz@gmx.net>
Thu, 17 Jul 2003 06:45:39 +0000 (06:45 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 17 Jul 2003 06:45:39 +0000 (06:45 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7297 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/insets/ChangeLog
src/insets/insetcollapsable.C
src/insets/insettabular.C
src/insets/insettext.C
src/lyxtext.h
src/rowpainter.C
src/text2.C

index 7c9b728b80633247480e5b22b48a4927e64cd2a0..16de892ce5cfcde5e56670f18a77288b29578838 100644 (file)
@@ -1,4 +1,10 @@
 
+2003-07-17  André Pönitz  <poenitz@gmx.net>
+
+       * lyxtext.h:
+       * rowpainter.C:
+       * text2.C: don't call inset->update() anymore
+
 2003-07-16  André Pönitz  <poenitz@gmx.net>
 
        * lyxcursor.[Ch]:
index 38b6dc929107b2bf572441a9e065f785443b67a8..f939571026ae3127c20b802ff3982ee945d242a7 100644 (file)
@@ -1,4 +1,10 @@
 
+2003-07-17  André Pönitz  <poenitz@gmx.net>
+
+       * insetcollapsable.C:
+       * insettabular.C:
+       * insettext.C: don't call Inset::update() anymore
+
 2003-07-16  André Pönitz  <poenitz@gmx.net>
 
        * insettext.C (selectAll): remove
index 7f24b59882c4a8eaafd3d5338f6255a6dca48947..43d81cc2d315580210ad4aaf1cf14705c032080e 100644 (file)
@@ -308,13 +308,15 @@ void InsetCollapsable::update(BufferView * bv, bool reinit)
 
 Inset::RESULT InsetCollapsable::localDispatch(FuncRequest const & cmd)
 {
-       //lyxerr << "InsetCollapsable::localDispatch: " << cmd.action << "\n";
+       lyxerr << "InsetCollapsable::localDispatch: "
+               << cmd.action << " '" << cmd.argument << "'\n";
        BufferView * bv = cmd.view();
        switch (cmd.action) {
                case LFUN_INSET_EDIT: {
                        if (!cmd.argument.empty()) {
                                UpdatableInset::localDispatch(cmd);
                                if (collapsed_) {
+                                       lyxerr << "branch collapsed_\n";
                                        collapsed_ = false;
                                        if (bv->lockInset(this)) {
                                                inset.setUpdateStatus(InsetText::FULL);
@@ -324,6 +326,7 @@ Inset::RESULT InsetCollapsable::localDispatch(FuncRequest const & cmd)
                                                first_after_edit = true;
                                        }
                                } else {
+                                       lyxerr << "branch not collapsed_\n";
                                        if (bv->lockInset(this))
                                                inset.localDispatch(cmd);
                                }
index 5572ae09a99a036768208dc7e90989a0eec9a787..7a2229a0155b073059a760926227fed895f70787 100644 (file)
@@ -259,6 +259,7 @@ void InsetTabular::read(Buffer const * buf, LyXLex & lex)
 void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        if (mi.base.bv) {
+               calculate_dimensions_of_cells(mi.base.bv, true);
                //lyxerr << "InsetTabular::metrics, bv: " << mi.base.bv << endl;
                for (int i = 0; i < tabular.getNumberOfCells(); ++i) {
                        tabular.cellinfo_of_cell(i)->inset.text_.bv_owner = mi.base.bv;
@@ -411,42 +412,6 @@ void InsetTabular::drawCellSelection(Painter & pain, int x, int y,
 
 void InsetTabular::update(BufferView * bv, bool reinit)
 {
-       if (in_update) {
-               if (reinit) {
-                       resetPos(bv);
-                       if (owner())
-                               owner()->update(bv, true);
-               }
-               return;
-       }
-       in_update = true;
-       if (reinit) {
-               need_update = INIT;
-               if (calculate_dimensions_of_cells(bv, true))
-                       resetPos(bv);
-               if (owner())
-                       owner()->update(bv, true);
-               in_update = false;
-               return;
-       }
-       if (the_locking_inset)
-               the_locking_inset->update(bv, reinit);
-       if (need_update < FULL && bv->text->needRefresh())
-               need_update = FULL;
-
-       switch (need_update) {
-       case INIT:
-       case FULL:
-       case CELL:
-               if (calculate_dimensions_of_cells(bv, false)) {
-                       need_update = INIT;
-                       resetPos(bv);
-               }
-               break;
-       default:
-               break;
-       }
-       in_update = false;
 }
 
 
index d56527f55cd965f8270461a1799c7c80c4d080de..570e8b486ca392281408a34fa47edd70297e9d6a 100644 (file)
@@ -277,6 +277,7 @@ void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        BufferView * bv = mi.base.bv;
        setViewCache(bv);
+       text_.rebuild();
        dim.asc = text_.rows().begin()->ascent_of_text() + TEXT_TO_INSET_OFFSET;
        dim.des = text_.height - dim.asc + TEXT_TO_INSET_OFFSET;
        dim.wid = max(textWidth(bv), int(text_.width)) + 2 * TEXT_TO_INSET_OFFSET;
@@ -405,56 +406,6 @@ void InsetText::drawFrame(Painter & pain, int x) const
 void InsetText::update(BufferView * bv, bool reinit)
 {
        setViewCache(bv);
-
-       if (in_update) {
-               if (reinit && owner()) {
-                       reinitLyXText();
-                       owner()->update(bv, true);
-               }
-               return;
-       }
-       in_update = true;
-
-       if (reinit || need_update == INIT) {
-               need_update = FULL;
-               // we should put this call where we set need_update to INIT!
-               reinitLyXText();
-               if (owner())
-                       owner()->update(bv, true);
-               in_update = false;
-
-               int nw = getMaxWidth(bv, this);
-               if (nw > 0 && old_max_width != nw) {
-                       need_update |= INIT;
-                       old_max_width = nw;
-               }
-               return;
-       }
-
-       if (!autoBreakRows && paragraphs.size() > 1)
-               collapseParagraphs(bv);
-
-       if (the_locking_inset) {
-               inset_x = cix(bv) - top_x + drawTextXOffset;
-               inset_y = ciy() + drawTextYOffset;
-               the_locking_inset->update(bv, reinit);
-       }
-
-       if ((need_update & CURSOR_PAR) && !text_.needRefresh() &&
-               the_locking_inset) {
-               text_.updateInset(the_locking_inset);
-       }
-
-       if (text_.needRefresh())
-               need_update |= FULL;
-
-       in_update = false;
-
-       int nw = getMaxWidth(bv, this);
-       if (nw > 0 && old_max_width != nw) {
-               need_update |= INIT;
-               old_max_width = nw;
-       }
 }
 
 
@@ -476,6 +427,9 @@ void InsetText::setUpdateStatus(int what) const
 
 void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty)
 {
+       if (!bv)
+               return;
+
        if (!autoBreakRows && paragraphs.size() > 1)
                collapseParagraphs(bv);
 
@@ -555,7 +509,7 @@ void InsetText::lockInset(BufferView * bv)
        inset_boundary = false;
        inset_par = paragraphs.end();
        old_par = paragraphs.end();
-       text_.setCursor(paragraphs.begin(), 0);
+       text_.setCursorIntern(paragraphs.begin(), 0);
        text_.clearSelection();
        finishUndo();
        // If the inset is empty set the language of the current font to the
@@ -581,7 +535,7 @@ void InsetText::lockInset(BufferView * bv, UpdatableInset * inset)
        inset_pos = cpos();
        inset_par = cpar();
        inset_boundary = cboundary();
-       updateLocal(bv, CURSOR, false);
+       //updateLocal(bv, CURSOR, false);
 }
 
 
@@ -597,30 +551,36 @@ bool InsetText::lockInsetInInset(BufferView * bv, UpdatableInset * inset)
 
                int const id = inset->id();
                for (; pit != pend; ++pit) {
-                       InsetList::iterator it =
-                               pit->insetlist.begin();
-                       InsetList::iterator const end =
-                               pit->insetlist.end();
+                       InsetList::iterator it = pit->insetlist.begin();
+                       InsetList::iterator const end = pit->insetlist.end();
                        for (; it != end; ++it) {
                                if (it->inset == inset) {
-                                       getLyXText(bv)->setCursorIntern(pit, it->pos);
+                                       lyxerr << "InsetText::lockInsetInInset: 1 a\n";
+                                       text_.setCursorIntern(pit, it->pos);
+                                       lyxerr << "InsetText::lockInsetInInset: 1 b\n";
+                                       lyxerr << "bv: " << bv << " inset: " << inset << "\n";
                                        lockInset(bv, inset);
+                                       lyxerr << "InsetText::lockInsetInInset: 1 c" << endl;
                                        return true;
                                }
                                if (it->inset->getInsetFromID(id)) {
-                                       getLyXText(bv)->setCursorIntern(pit, it->pos);
+                                       lyxerr << "InsetText::lockInsetInInset: 2\n";
+                                       text_.setCursorIntern(pit, it->pos);
                                        it->inset->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
                                        return the_locking_inset->lockInsetInInset(bv, inset);
                                }
                        }
                }
+               lyxerr << "InsetText::lockInsetInInset: 3\n";
                return false;
        }
        if (inset == cpar()->getInset(cpos())) {
                lyxerr[Debug::INSETS] << "OK" << endl;
                lockInset(bv, inset);
                return true;
-       } else if (the_locking_inset && (the_locking_inset == inset)) {
+       }
+
+       if (the_locking_inset && the_locking_inset == inset) {
                if (cpar() == inset_par && cpos() == inset_pos) {
                        lyxerr[Debug::INSETS] << "OK" << endl;
                        inset_x = cix(bv) - top_x + drawTextXOffset;
@@ -884,7 +844,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & cmd)
 
                if (cmd.argument.size()) {
                        if (cmd.argument == "left")
-                               text_.setCursor(paragraphs.begin(), 0);
+                               text_.setCursorIntern(paragraphs.begin(), 0);
                        else {
                                ParagraphList::iterator it = paragraphs.begin();
                                ParagraphList::iterator end = paragraphs.end();
index a33a71c9bb3a610db79ec3fcb7004b4958dcbf40..2e6ddd97c343df0830428b891686ecd3f74ba3c4 100644 (file)
@@ -163,6 +163,8 @@ public:
        void partialRebreak();
        /// a full rebreak of the whole text
        void fullRebreak();
+       /// rebuild RowList cache
+       void rebuild();
 
        ///
        RowList::iterator need_break_row;
index 8c0ee616b396665dcca24e6f5c2bca8af744bb67..dab05373fbff91b51f3f055de1a0d443c6e838bd 100644 (file)
@@ -179,7 +179,7 @@ void RowPainter::paintInset(pos_type const pos)
        Assert(inset);
 
 #warning inset->update FIXME
-       inset->update(perv(bv_), false);
+       //inset->update(perv(bv_), false);
 
        PainterInfo pi(perv(bv_));
        pi.base.font = getFont(pos);
index f8b72a88bbc9f541f67cd0d6adddc5fdee8f325a..d183f53934bc81bd4b4f3956ca8ab179dfc3208a 100644 (file)
@@ -692,6 +692,32 @@ void LyXText::fullRebreak()
 }
 
 
+void LyXText::rebuild()
+{
+       rowlist_.clear();
+       need_break_row = rows().end();
+       width = height = 0;
+
+       anchor_row_ = rows().end();
+       anchor_row_offset_ = 0;
+
+       ParagraphList::iterator pit = ownerParagraphs().begin();
+       ParagraphList::iterator end = ownerParagraphs().end();
+
+       //current_font = getFont(bview->buffer(), pit, 0);
+
+       for (; pit != end; ++pit)
+               insertParagraph(pit, rowlist_.end());
+
+       //setCursorIntern(rowlist_.begin()->par(), 0);
+       //selection.cursor = cursor;
+
+       //updateCounters();
+
+       //setCursorIntern(cursor.par(), cursor.pos());
+}
+
+
 void LyXText::partialRebreak()
 {
        if (rows().empty()) {
@@ -1516,6 +1542,8 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
        cur.par(pit);
        cur.pos(pos);
        cur.boundary(boundary);
+       if (rows().empty())
+               return;
 
        // get the cursor y position in text
        int y = 0;