]> git.lyx.org Git - features.git/commitdiff
Lot's of updates for new update handling of text-insets
authorJürgen Vigna <jug@sad.it>
Fri, 23 Jun 2000 15:02:46 +0000 (15:02 +0000)
committerJürgen Vigna <jug@sad.it>
Fri, 23 Jun 2000 15:02:46 +0000 (15:02 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@831 a592a061-630c-0410-9148-cb99ea01b6c8

37 files changed:
ChangeLog
src/buffer.C
src/buffer.h
src/insets/figinset.C
src/insets/figinset.h
src/insets/insetbutton.C
src/insets/insetbutton.h
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/inseterror.C
src/insets/inseterror.h
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetinfo.C
src/insets/insetinfo.h
src/insets/insetlatexaccent.C
src/insets/insetlatexaccent.h
src/insets/insetquotes.C
src/insets/insetquotes.h
src/insets/insetspecialchar.C
src/insets/insetspecialchar.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/lyxinset.h
src/lyxfunc.C
src/lyxparagraph.h
src/lyxtext.h
src/mathed/formula.C
src/mathed/formula.h
src/mathed/formulamacro.C
src/mathed/formulamacro.h
src/paragraph.C
src/tabular.C
src/text.C
src/text2.C

index 9000aedbc94a1c672386fdfc44193afa7f8d51d2..27cdc311f03d538432d0015c4b84176f3623ba9b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2000-06-23  Juergen Vigna  <jug@sad.it>
+
+       * src/lyxtext.h: added a 'cleared' flag to draw() function.
+
+       * src/buffer.C (resize): delete the LyXText of textinsets.
+
+       * src/paragraph.C (SetInsetOwner): set the owner in the insets too.
+
+       * src/insets/lyxinset.h: added another parameter 'cleared' to
+       the draw() function.
+
+       * src/lyxfunc.C (processKeyEvent): move cursor to the right of the
+       unlocking inset in inset.
+
 2000-06-22  Juergen Vigna  <jug@sad.it>
 
        * src/lyxscreen.h: added some y_offset/x_offset parameters for drawings
index cb7233f9049a2c6dc5fa693d824d5fc92235d0f6..a64627987ac6d3d2ee3bba84b91266196b6b7b67 100644 (file)
@@ -3801,6 +3801,20 @@ bool Buffer::Dispatch(int action, string const & argument)
 }
 
 
+void Buffer::resize()
+{
+       /// first resize the BufferViews!
+       if (users) {
+               users->resize();
+       }
+       /// then remove all LyXText in text-insets
+       LyXParagraph * par = paragraph;
+       for(;par;par = par->next) {
+               par->deleteInsetsLyXText(users);
+       }
+}
+
+
 void Buffer::ChangeLanguage(Language const * from, Language const * to)
 {
 
index 6a3117959f7fcbd9a956257501e2969414becaf5..10388ce06458b2b24be99d5766984769522acd8a 100644 (file)
@@ -88,11 +88,7 @@ public:
        bool Dispatch(int, auto_mem_buffer &);
 
        /// should be changed to work for a list.
-       void resize() {
-               if (users) {
-                       users->resize();
-               }
-       }
+       void resize();
 
        /// Update window titles of all users
        void updateTitles() const;
index 99e447c6c13b5518f13be2ffd61beffc3e5d35ba..e546f7edbb4a77a819e83c7fef44dbe6f08a166e 100644 (file)
@@ -1035,7 +1035,7 @@ int InsetFig::width(Painter &, LyXFont const &) const
 
 
 void InsetFig::draw(BufferView * bv, LyXFont const & f,
-                   int baseline, float & x) const
+                   int baseline, float & x, bool) const
 {
        LyXFont font(f);
        Painter & pain = bv->painter();
index cb53c9218c9f5e3242ad77bf6fb7de236aebfffb..28830c735e67af69b288be2d27842cc4788e7f95 100644 (file)
@@ -30,8 +30,7 @@ public:
        ///
        int width(Painter &, LyXFont const & font) const;
        ///
-       void draw(BufferView *, LyXFont const & font,
-                 int baseline, float & x) const;
+       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
        ///
        void Write(Buffer const *, std::ostream &) const;
        ///
index 327ab0b6566cd97f74cccae7a4c3f6e4c00f160b..368604e5f0f3490f17b558a3b8f1044d6baf670e 100644 (file)
@@ -88,7 +88,7 @@ int InsetButton::width(Painter & pain, LyXFont const &) const
 
 
 void InsetButton::draw(BufferView * bv, LyXFont const &,
-                       int baseline, float & x) const
+                       int baseline, float & x, bool) const
 {
        Painter & pain = bv->painter();
        // Draw it as a box with the LaTeX text
index b88a83729ca612e985d9ca819cfb37a479abc6f2..056c3fe98da65b53f0973d38a95e09472810cc54 100644 (file)
@@ -33,7 +33,7 @@ public:
        ///
        int width(Painter &, LyXFont const &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int baseline, float & x) const;
+       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
 
 protected:
        /// This should provide the text for the button
index 03537313d350a0585a03ab921da72a4a333f3b6f..24457fba6dd235230d5a6f2fbbf0343e7034ba11 100644 (file)
@@ -136,7 +136,7 @@ void InsetCollapsable::draw_collapsed(Painter & pain, LyXFont const & font,
 
 
 void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, 
-                           int baseline, float & x) const
+                           int baseline, float & x, bool cleared) const
 {
     Painter & pain = bv->painter();
 
@@ -155,12 +155,11 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
 
     int w =  InsetText::width(pain, f) + 2 * TEXT_TO_INSET_OFFSET;
     int h = ascent(pain,f) + descent(pain, f);
-    
-    pain.rectangle(int(x), baseline - ascent(pain, f), w, h, framecolor);
-
+    int save_x = static_cast<int>(x);
     x += TEXT_TO_INSET_OFFSET;
     drawTextXOffset = int(x) - top_x;
-    InsetText::draw(bv, f, baseline, x);
+    InsetText::draw(bv, f, baseline, x, cleared);
+    pain.rectangle(save_x, baseline - ascent(pain, f), w, h, framecolor);
 }
 
 
index 5107c448371627fe3da7cc58f255c04d15335a75..73bbc42d4ea2094f5dbb6468c86855600dff572e 100644 (file)
@@ -51,7 +51,7 @@ public:
     ///
     int width(Painter &, LyXFont const & f) const;
     ///
-    void draw(BufferView *, const LyXFont &, int , float &) const;
+    void draw(BufferView *, const LyXFont &, int , float &, bool) const;
     ///
     void Edit(BufferView *, int, int, unsigned int);
     ///
index cc7584a287383c119a3fa3669733e1b8396fddc1..493a01de20a2979daec85d26563cba7b8dfc8b43 100644 (file)
@@ -73,7 +73,7 @@ int InsetError::width(Painter &, LyXFont const & font) const
 
 
 void InsetError::draw(BufferView * bv, LyXFont const & font,
-                     int baseline, float & x) const
+                     int baseline, float & x, bool) const
 {
        Painter & pain = bv->painter();
        LyXFont efont;
index 1147e47e7466c3b6e61dc392009af87a9cc1f48c..eadf9fb513587d898f1f5d846bd31bd85e85d0a9 100644 (file)
@@ -42,7 +42,7 @@ public:
        ///
        int width(Painter &, LyXFont const & font) const;
        ///
-       void draw(BufferView *, LyXFont const & font, int baseline, float & x) const;
+       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
        ///
        void Write(Buffer const *, std::ostream &) const;
        ///
index 35716df97fefdbc40a3f7a22ea373c42e377862c..586934dd14934134ad9d177873eb245ad953af3a 100644 (file)
@@ -135,7 +135,7 @@ int InsetGraphics::width(Painter &, LyXFont const &) const
 
 
 void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
-                        int baseline, float & x) const
+                        int baseline, float & x, bool) const
 {
        Painter & pain = bv->painter();
 
index 76d2ec824eb2ea2f171081714c6ee8dce2ad75ce..e9cc6d563b3d66cd01bccf242e020f00a07592e8 100644 (file)
@@ -35,8 +35,7 @@ public:
        ///
        int width(Painter &, LyXFont const &) const;
        ///
-       void draw(BufferView *, LyXFont const &,
-                         int baseline, float & x) const;
+       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
        ///
        void Edit(BufferView *, int, int, unsigned int);
        ///
index e57b91f0420f63e68027d3c22ec4f3b996b30676..847f37492c543f13814198f96715fa73f76bb977 100644 (file)
@@ -76,7 +76,7 @@ int InsetInfo::width(Painter &, LyXFont const & font) const
 
 
 void InsetInfo::draw(BufferView * bv, LyXFont const & f,
-                    int baseline, float & x) const
+                    int baseline, float & x, bool) const
 {
        Painter & pain = bv->painter();
        LyXFont font(f);
index ef1cf83e1a4528d385b30a8ec227292acf9706b4..8898a874e46e7239752eb2168d02fa89ab2f69b8 100644 (file)
@@ -44,7 +44,7 @@ public:
        ///
        int width(Painter &, LyXFont const &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int baseline, float & x) const;
+       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
        ///
        void Write(Buffer const *, std::ostream &) const;
        ///
index 89fdbfc710d2674ef5d54301b6052cae7f950651..9b74cd696b00b5c5b932272fa4ba5d5b2aafaf3e 100644 (file)
@@ -356,7 +356,7 @@ bool InsetLatexAccent::DisplayISO8859_9(Painter & pain, LyXFont const & font,
 
 
 void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font,
-                           int baseline, float & x) const
+                           int baseline, float & x, bool) const
 {
        Painter & pain = bv->painter();
 
index 5e444703763dcd47cc76e8aaaf3de7ae41c3d5de..9a73aa3704578306c61c4bb0eb7c899a6e504723 100644 (file)
@@ -41,7 +41,7 @@ public:
        ///
        int width(Painter &, LyXFont const &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int baseline, float & x) const;
+       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
        ///
        int Lbearing(LyXFont const & font) const;
        ///
index f2dfa4238efc3c3419e1c0d0de02adef3aba5cc0..ab0adde855df64438e5eab2625e6650dd8ca365a 100644 (file)
@@ -198,7 +198,7 @@ LyXFont InsetQuotes::ConvertFont(LyXFont font)
 
 
 void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
-                      int baseline, float & x) const
+                      int baseline, float & x, bool) const
 {
        string text = DispString();
 
index 3c6a6f24b1464d96472311a276d8d83813263195..cb8b4d9c103c138f17cb20776b54daa94277abd0 100644 (file)
@@ -78,7 +78,7 @@ public:
        ///
        int width(Painter &, LyXFont const &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int baseline, float & x) const;
+       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
        ///
        LyXFont ConvertFont(LyXFont font);
        ///
index 81431d769faca7f7c926e5236efeb5b16ec05d9b..172e0d4aaab69ea7f5fba03e541659502bb224de 100644 (file)
@@ -73,7 +73,7 @@ int InsetSpecialChar::width(Painter &, LyXFont const & font) const
 
 
 void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
-                           int baseline, float & x) const
+                           int baseline, float & x, bool) const
 {
        Painter & pain = bv->painter();
        LyXFont font(f);
index d02aec0d656c6652b05cb3390021b5f5db9dad0f..cb696cd97e280ff18b4cdd4db15dd9a44b442894 100644 (file)
@@ -50,7 +50,7 @@ public:
        ///
        int width(Painter &, LyXFont const &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int baseline, float & x) const;
+       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
        ///
        void Write(Buffer const *, std::ostream &) const;
        /// Will not be used when lyxf3
index 642fe07abf3f0122b2eb4c2ce1342fc41bde5f9e..2acf66517863d27e647cbd0177db5b1ea6cb2348 100644 (file)
@@ -63,7 +63,7 @@ InsetTabular::InsetTabular(Buffer * buf, int rows, int columns)
     actcell = 0;
     cursor.pos(0);
     sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
-    init_inset = true;
+    need_update = INIT;
 }
 
 
@@ -78,7 +78,7 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer * buf)
     actcell = 0;
     cursor.pos(0);
     sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
-    init_inset = true;
+    need_update = INIT;
 }
 
 
@@ -113,7 +113,7 @@ void InsetTabular::Read(Buffer const * buf, LyXLex & lex)
        delete tabular;
     tabular = new LyXTabular(buf, this, lex);
 
-    init_inset = true;
+    need_update = INIT;
 
     if (old_format)
        return;
@@ -150,7 +150,7 @@ int InsetTabular::width(Painter &, LyXFont const &) const
 
 
 void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
-                       float & x) const
+                       float & x, bool cleared) const
 {
     Painter & pain = bv->painter();
     int i, j, cell=0;
@@ -158,8 +158,8 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
     float cx;
 
     UpdatableInset::draw(bv,font,baseline,x);
-    if (init_inset || (top_x != int(x)) || (top_baseline != baseline)) {
-       init_inset = false;
+    if ((need_update == INIT)|| (top_x != int(x)) || (top_baseline != baseline)) {
+       need_update = FULL;
        top_x = int(x);
        top_baseline = baseline;
        resetPos(pain);
@@ -172,35 +172,39 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
                return;
        }
     }
+    bool dodraw;
     x += ADD_TO_TABULAR_WIDTH;
-    for(i=0;i<tabular->rows();++i) {
-       nx = int(x);
-        for(j=0;j<tabular->columns();++j) {
-           if (tabular->IsPartOfMultiColumn(i,j))
-               continue;
-           cx = nx + tabular->GetBeginningOfTextInCell(cell);
-           if (hasSelection())
-               DrawCellSelection(pain, nx, baseline, i, j, cell);
-           tabular->GetCellInset(cell)->draw(bv, font, baseline, cx);
-           DrawCellLines(pain, nx, baseline, i, cell);
-           nx += tabular->GetWidthOfColumn(cell);
-           ++cell;
+    if (cleared || !locked || (need_update == FULL) || (need_update == CELL)) {
+       for(i=0;i<tabular->rows();++i) {
+           nx = int(x);
+           dodraw = ((baseline+tabular->GetDescentOfRow(i)) > 0) &&
+                   (baseline-tabular->GetAscentOfRow(i)) < pain.paperHeight();
+           for(j=0;j<tabular->columns();++j) {
+               if (tabular->IsPartOfMultiColumn(i,j))
+                   continue;
+               cx = nx + tabular->GetBeginningOfTextInCell(cell);
+               if (hasSelection())
+                   DrawCellSelection(pain, nx, baseline, i, j, cell);
+               if (dodraw && !cleared && locked && the_locking_inset) {
+                   if (the_locking_inset == tabular->GetCellInset(cell))
+                       tabular->GetCellInset(cell)->draw(bv, font,
+                                                         baseline, cx,
+                                                         cleared);
+               } else if (dodraw) {
+                   tabular->GetCellInset(cell)->draw(bv, font, baseline, cx,
+                                                     cleared);
+                   DrawCellLines(pain, nx, baseline, i, cell);
+               }
+               nx += tabular->GetWidthOfColumn(cell);
+               ++cell;
+           }
+           baseline += tabular->GetDescentOfRow(i) +
+               tabular->GetAscentOfRow(i+1)+
+               tabular->GetAdditionalHeight(cell+1);
        }
-        baseline += tabular->GetDescentOfRow(i) + tabular->GetAscentOfRow(i+1)
-            + tabular->GetAdditionalHeight(cell+1);
     }
     x += width(pain, font);
-}
-
-
-void InsetTabular::update(BufferView * bv, LyXFont const & font, bool dodraw)
-{
-    if (the_locking_inset)
-       the_locking_inset->update(bv, font, dodraw);
-    if (init_inset) {
-//     calculate_dimensions_of_cells(bv, font, dodraw);
-       init_inset = calculate_dimensions_of_cells(bv, font, dodraw) || init_inset;
-    }
+    need_update = NONE;
 }
 
 
@@ -270,6 +274,26 @@ void InsetTabular::DrawCellSelection(Painter & pain, int x, int baseline,
 }
 
 
+void InsetTabular::update(BufferView * bv, LyXFont const & font, bool dodraw)
+{
+    if (the_locking_inset)
+       the_locking_inset->update(bv, font, dodraw);
+    switch(need_update) {
+    case INIT:
+    case FULL:
+    case CELL:
+       if (calculate_dimensions_of_cells(bv, font, dodraw))
+           need_update = INIT;
+       break;
+    case SELECTION:
+       need_update = INIT;
+       break;
+    default:
+       break;
+    }
+}
+
+
 char const * InsetTabular::EditMessage() const
 {
     return _("Opened Tabular Inset");
@@ -294,7 +318,7 @@ void InsetTabular::Edit(BufferView * bv, int x, int y, unsigned int button)
     if (InsetHit(bv, x, y)) {
        ActivateCellInset(bv, x, y, button);
     }
-    UpdateLocal(bv, false, false);
+    UpdateLocal(bv, NONE, false);
 //    bv->getOwner()->getPopups().updateFormTabular();
 }
 
@@ -308,20 +332,21 @@ void InsetTabular::InsetUnlock(BufferView * bv)
     }
     HideInsetCursor(bv);
     if (hasSelection()) {
-       sel_pos_start = sel_pos_end = cursor.pos();
-       sel_cell_start = sel_cell_end = actcell;
-       UpdateLocal(bv, false, false);
+       sel_pos_start = sel_pos_end = 0;
+       sel_cell_start = sel_cell_end = 0;
+       UpdateLocal(bv, FULL, false);
     }
     no_selection = false;
     oldcell = -1;
     locked = false;
 }
 
-void InsetTabular::UpdateLocal(BufferView * bv, bool what, bool mark_dirty)
+void InsetTabular::UpdateLocal(BufferView * bv, UpdateCodes what,
+                              bool mark_dirty)
 {
-    init_inset = what;
+    need_update = what;
     bv->updateInset(this, mark_dirty);
-    if (what)
+    if (what != NONE)
        resetPos(bv->painter());
 }
 
@@ -366,7 +391,7 @@ bool InsetTabular::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
         the_locking_inset = 0;
         if (lr)
             moveRight(bv, false);
-       UpdateLocal(bv, true, false);
+       UpdateLocal(bv, CELL, false);
         return true;
     }
     if (the_locking_inset->UnlockInsetInInset(bv, inset, lr)) {
@@ -387,7 +412,7 @@ bool InsetTabular::UpdateInsetInInset(BufferView * bv, Inset * inset)
        return false;
     if (the_locking_inset != inset)
        return the_locking_inset->UpdateInsetInInset(bv, inset);
-    UpdateLocal(bv, false, false);
+    UpdateLocal(bv, CELL, false);
     return true;
 }
 
@@ -451,7 +476,7 @@ void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
 {
     if (hasSelection()) {
        sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
-       UpdateLocal(bv, false, false);
+       UpdateLocal(bv, SELECTION, false);
     }
     no_selection = false;
 
@@ -499,7 +524,7 @@ void InsetTabular::InsetMotionNotify(BufferView * bv, int x, int y, int button)
        sel_pos_end = cursor.pos();
        sel_cell_end = actcell;
        if (old != sel_pos_end)
-           UpdateLocal(bv, false, false);
+           UpdateLocal(bv, SELECTION, false);
 #if 0
        if (ocell != actcell)
            bview->getOwner()->getPopups().updateFormTabular();
@@ -544,9 +569,8 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
        if (result == DISPATCHED_NOUPDATE)
            return result;
        else if (result == DISPATCHED) {
-            bool upd = SetCellDimensions(bv->painter(), actcell, actrow);
            the_locking_inset->ToggleInsetCursor(bv);
-           UpdateLocal(bv, upd, false);
+           UpdateLocal(bv, CELL, false);
            the_locking_inset->ToggleInsetCursor(bv);
             return result;
         } else if (result == FINISHED) {
@@ -581,14 +605,14 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
            else
                sel_cell_end = actcell;
        }
-       UpdateLocal(bv, false, false);
+       UpdateLocal(bv, SELECTION, false);
        break;
     case LFUN_RIGHT:
        result = moveRight(bv);
        sel_pos_start = sel_pos_end = cursor.pos();
        sel_cell_start = sel_cell_end = actcell;
        if (hs)
-           UpdateLocal(bv, false, false);
+           UpdateLocal(bv, CURSOR, false);
        break;
     case LFUN_LEFTSEL:
        if (tabular->IsFirstCellInRow(actcell) && cellstart(cursor.pos()))
@@ -602,14 +626,14 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
            else
                sel_cell_end = actcell-1;
        }
-       UpdateLocal(bv, false, false);
+       UpdateLocal(bv, SELECTION, false);
        break;
     case LFUN_LEFT:
        result = moveLeft(bv);
        sel_pos_start = sel_pos_end = cursor.pos();
        sel_cell_start = sel_cell_end = actcell;
        if (hs)
-           UpdateLocal(bv, false, false);
+           UpdateLocal(bv, CURSOR, false);
        break;
     case LFUN_DOWNSEL:
     {
@@ -621,7 +645,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
            sel_cell_end = tabular->GetCellBelow(sel_cell_end);
        else
            sel_cell_end = tabular->GetLastCellBelow(sel_cell_end);
-       UpdateLocal(bv, false, false);
+       UpdateLocal(bv, SELECTION, false);
     }
     break;
     case LFUN_DOWN:
@@ -629,7 +653,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
        sel_pos_start = sel_pos_end = cursor.pos();
        sel_cell_start = sel_cell_end = actcell;
        if (hs)
-           UpdateLocal(bv, false, false);
+           UpdateLocal(bv, CURSOR, false);
        break;
     case LFUN_UPSEL:
     {
@@ -641,7 +665,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
            sel_cell_end = tabular->GetCellAbove(sel_cell_end);
        else
            sel_cell_end = tabular->GetLastCellAbove(sel_cell_end);
-       UpdateLocal(bv, false, false);
+       UpdateLocal(bv, SELECTION, false);
     }
     break;
     case LFUN_UP:
@@ -649,7 +673,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
        sel_pos_start = sel_pos_end = cursor.pos();
        sel_cell_start = sel_cell_end = actcell;
        if (hs)
-           UpdateLocal(bv, false, false);
+           UpdateLocal(bv, CURSOR, false);
        break;
     case LFUN_BACKSPACE:
        break;
@@ -672,7 +696,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
        sel_pos_start = sel_pos_end = cursor.pos();
        sel_cell_start = sel_cell_end = actcell;
        if (hs)
-           UpdateLocal(bv, false, false);
+           UpdateLocal(bv, CURSOR, false);
        break;
     case LFUN_LAYOUT_TABLE:
     {
@@ -885,28 +909,6 @@ void InsetTabular::resetPos(Painter & pain) const
 }
 
 
-bool InsetTabular::SetCellDimensions(Painter & pain, int cell, int row)
-{
-    InsetText * inset = tabular->GetCellInset(cell);
-    LyXFont font(LyXFont::ALL_SANE);
-    int asc = inset->ascent(pain, font) + ADD_TO_HEIGHT;
-    int desc = inset->descent(pain, font) + ADD_TO_HEIGHT;
-    int maxAsc = tabular->GetAscentOfRow(row);
-    int maxDesc = tabular->GetDescentOfRow(row);
-    bool ret = tabular->SetWidthOfCell(cell, inset->width(pain, font));
-
-    if (maxAsc < asc) {
-       ret = true;
-       tabular->SetAscentOfRow(row, asc);
-    }
-    if (maxDesc < desc) {
-       ret = true;
-       tabular->SetDescentOfRow(row, desc);
-    }
-    return ret;
-}
-
-
 UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
 {
     if (!cellstart(cursor.pos())) {
@@ -1066,8 +1068,13 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
     {
        bool update = (tabular->GetPWidth(actcell) != val);
        tabular->SetPWidth(actcell,val);
-       if (update)
-           UpdateLocal(bv, true, true);
+       if (update) {
+           for (int i=0; i < tabular->rows(); ++i) {
+               tabular->GetCellInset(tabular->GetCellNumber(i, column))->
+                   deleteLyXText(bv);
+           }
+           UpdateLocal(bv, INIT, true);
+       }
     }
     break;
     case LyXTabular::SET_SPECIAL_COLUMN:
@@ -1078,34 +1085,34 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
        // append the row into the tabular
        UnlockInsetInInset(bv, the_locking_inset);
        tabular->AppendRow(actcell);
-       UpdateLocal(bv, true, true);
+       UpdateLocal(bv, INIT, true);
        break;
     case LyXTabular::APPEND_COLUMN:
        // append the column into the tabular
        tabular->AppendColumn(actcell);
        actcell = tabular->GetCellNumber(row, column);
-       UpdateLocal(bv, true, true);
+       UpdateLocal(bv, INIT, true);
        break;
     case LyXTabular::DELETE_ROW:
        tabular->DeleteRow(tabular->row_of_cell(actcell));
        if ((row+1) > tabular->rows())
            --row;
        actcell = tabular->GetCellNumber(row, column);
-       UpdateLocal(bv, true, true);
+       UpdateLocal(bv, INIT, true);
        break;
     case LyXTabular::DELETE_COLUMN:
        tabular->DeleteColumn(tabular->column_of_cell(actcell));
        if ((column+1) > tabular->columns())
            --column;
        actcell = tabular->GetCellNumber(row, column);
-       UpdateLocal(bv, true, true);
+       UpdateLocal(bv, INIT, true);
        break;
     case LyXTabular::TOGGLE_LINE_TOP:
        lineSet = !tabular->TopLine(actcell);
        for(i=sel_row_start; i<=sel_row_end; ++i)
            for(j=sel_col_start; j<=sel_col_end; ++j)
                tabular->SetTopLine(tabular->GetCellNumber(i,j),lineSet);
-       UpdateLocal(bv, true, true);
+       UpdateLocal(bv, INIT, true);
        break;
     
     case LyXTabular::TOGGLE_LINE_BOTTOM:
@@ -1113,7 +1120,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
        for(i=sel_row_start; i<=sel_row_end; ++i)
            for(j=sel_col_start; j<=sel_col_end; ++j)
                tabular->SetBottomLine(tabular->GetCellNumber(i,j),lineSet);
-       UpdateLocal(bv, true, true);
+       UpdateLocal(bv, INIT, true);
        break;
                
     case LyXTabular::TOGGLE_LINE_LEFT:
@@ -1121,7 +1128,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
        for(i=sel_row_start; i<=sel_row_end; ++i)
            for(j=sel_col_start; j<=sel_col_end; ++j)
                tabular->SetLeftLine(tabular->GetCellNumber(i,j),lineSet);
-       UpdateLocal(bv, true, true);
+       UpdateLocal(bv, INIT, true);
        break;
 
     case LyXTabular::TOGGLE_LINE_RIGHT:
@@ -1129,7 +1136,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
        for(i=sel_row_start; i<=sel_row_end; ++i)
            for(j=sel_col_start; j<=sel_col_end; ++j)
                tabular->SetRightLine(tabular->GetCellNumber(i,j),lineSet);
-       UpdateLocal(bv, true, true);
+       UpdateLocal(bv, INIT, true);
        break;
     case LyXTabular::ALIGN_LEFT:
     case LyXTabular::ALIGN_RIGHT:
@@ -1137,7 +1144,10 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
        for(i=sel_row_start; i<=sel_row_end; ++i)
            for(j=sel_col_start; j<=sel_col_end; ++j)
                tabular->SetAlignment(tabular->GetCellNumber(i,j),setAlign);
-       UpdateLocal(bv, true, true);
+       if (hasSelection())
+           UpdateLocal(bv, INIT, true);
+       else
+           UpdateLocal(bv, CELL, true);
        break;
     case LyXTabular::MULTICOLUMN:
     {
@@ -1152,10 +1162,10 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
            // check wether we are completly in a multicol
            if (tabular->IsMultiColumn(actcell)) {
                tabular->UnsetMultiColumn(actcell);
-               UpdateLocal(bv, true, true);
+               UpdateLocal(bv, INIT, true);
            } else {
                tabular->SetMultiColumn(actcell, 1);
-               UpdateLocal(bv, false, true);
+               UpdateLocal(bv, CELL, true);
            }
            return;
        }
@@ -1176,7 +1186,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
        cursor.pos(0);
        sel_cell_end = sel_cell_start;
        sel_pos_end = sel_pos_start;
-       UpdateLocal(bv, true, true);
+       UpdateLocal(bv, INIT, true);
        break;
     }
     case LyXTabular::SET_ALL_LINES:
@@ -1185,15 +1195,15 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
        for(i=sel_row_start; i<=sel_row_end; ++i)
            for(j=sel_col_start; j<=sel_col_end; ++j)
                tabular->SetAllLines(tabular->GetCellNumber(i,j), setLines);
-       UpdateLocal(bv, true, true);
+       UpdateLocal(bv, INIT, true);
        break;
     case LyXTabular::SET_LONGTABULAR:
        tabular->SetLongTabular(true);
-       UpdateLocal(bv, true, true); // because this toggles displayed
+       UpdateLocal(bv, INIT, true); // because this toggles displayed
        break;
     case LyXTabular::UNSET_LONGTABULAR:
        tabular->SetLongTabular(false);
-       UpdateLocal(bv, true, true); // because this toggles displayed
+       UpdateLocal(bv, INIT, true); // because this toggles displayed
        break;
     case LyXTabular::SET_ROTATE_TABULAR:
        tabular->SetRotateTabular(true);
@@ -1257,7 +1267,7 @@ bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button,
     inset->Edit(bv, x - inset_x, y - inset_y, button);
     if (!the_locking_inset)
        return false;
-    UpdateLocal(bv, true, false);
+    UpdateLocal(bv, CELL, false);
     return true;
 }
 
index fe59d089ba156e5fb23a711732efc6058af68333..9a2a6ee796666060f4a2e1180ba671989850f4c6 100644 (file)
@@ -61,6 +61,15 @@ class Buffer;
 
 class InsetTabular : public UpdatableInset {
 public:
+    ///
+    enum UpdateCodes {
+       NONE = 0,
+       INIT,
+       FULL,
+       CELL,
+       CURSOR,
+       SELECTION
+    };
     ///
     InsetTabular(Buffer *, int rows=1, int columns=1);
     ///
@@ -80,7 +89,7 @@ public:
     ///
     int width(Painter &, LyXFont const & f) const;
     ///
-    void draw(BufferView *, const LyXFont &, int , float &) const;
+    void draw(BufferView *, const LyXFont &, int , float &, bool) const;
     ///
     void update(BufferView *, LyXFont const &, bool);
     ///
@@ -92,7 +101,7 @@ public:
     ///
     void InsetUnlock(BufferView *);
     ///
-    void UpdateLocal(BufferView *, bool what, bool mark_dirty);
+    void UpdateLocal(BufferView *, UpdateCodes, bool mark_dirty);
     ///
     bool LockInsetInInset(BufferView *, UpdatableInset *);
     ///
@@ -166,8 +175,6 @@ private:
     ///
     void setPos(Painter &, int x, int y) const;
     ///
-    bool SetCellDimensions(Painter & pain, int cell, int row);
-    ///
     UpdatableInset::RESULT moveRight(BufferView *, bool lock=true);
     UpdatableInset::RESULT moveLeft(BufferView *, bool lock=true);
     UpdatableInset::RESULT moveUp(BufferView *);
@@ -216,6 +223,6 @@ private:
         actrow;
     bool no_selection;
     mutable bool locked;
-    mutable bool init_inset;
+    mutable UpdateCodes need_update;
 };
 #endif
index 6375665bd502581f800ef89332c5802969b7bfed..44d51639331f8751bd02b3dc93a7a63e60bd9098 100644 (file)
@@ -205,16 +205,21 @@ int InsetText::width(Painter &, LyXFont const &) const
     return insetWidth;
 }
 
+int InsetText::textWidth(Painter & pain) const
+{
+    return getMaxTextWidth(pain, this) - drawTextXOffset;
+}
+
 
 void InsetText::draw(BufferView * bv, LyXFont const & f,
-                    int baseline, float & x) const
+                    int baseline, float & x, bool cleared) const
 {
     Painter & pain = bv->painter();
 
     xpos = x;
     UpdatableInset::draw(bv, f, baseline, x);
  
-    if (locked && ((need_update==FULL) || (top_x!=int(x)) ||
+    if (!cleared && locked && ((need_update==FULL) || (top_x!=int(x)) ||
                   (top_baseline!=baseline))) {
        need_update = NONE;
        top_x = int(x);
@@ -235,11 +240,16 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
        inset_x = cx(bv) - top_x + drawTextXOffset;
        inset_y = cy(bv) + drawTextYOffset;
     }
+    if (need_update == CURSOR) {
+       x += width(pain, f);
+       need_update = NONE;
+       return;
+    }
     x += TEXT_TO_INSET_OFFSET; // place for border
     long int y = 0;
     Row * row = TEXT(bv)->GetRowNearY(y);
     y += baseline - row->ascent_of_text() + 1;
-    if (!locked || (need_update == FULL)) {
+    if (cleared || !locked || (need_update == FULL)) {
        while (row != 0) {
            TEXT(bv)->GetVisibleRow(bv, y, x, row, y);
            y += row->height();
@@ -252,9 +262,15 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
        bv->screen()->Update(TEXT(bv), y, x);
        locked = true;
     }
+    TEXT(bv)->refresh_y = 0;
+    TEXT(bv)->status = LyXText::UNCHANGED;
     if (drawLockedFrame && locked) {
            pain.rectangle(top_x, baseline - ascent(pain, f), width(pain, f),
                           ascent(pain,f) + descent(pain, f), frame_color);
+    } else {
+           pain.rectangle(top_x, baseline - ascent(pain, f), width(pain, f),
+                          ascent(pain,f) + descent(pain, f),
+                          LColor::background);
     }
     x += width(pain, f) - TEXT_TO_INSET_OFFSET;
     need_update = NONE;
@@ -269,16 +285,18 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool dodraw)
        deleteLyXText(bv);
        need_update = FULL;
     }
-    if (dodraw)
+    if (dodraw && (need_update != CURSOR))
            need_update = FULL;
 
     TEXT(bv)->FullRebreak(bv);
 
     long int y_temp = 0;
     Row * row = TEXT(bv)->GetRowNearY(y_temp);
-    insetAscent = row->ascent_of_text() + 2;
-    insetDescent = TEXT(bv)->height - row->ascent_of_text() + 2;
-    insetWidth = max(getMaxTextWidth(bv->painter(), this), TEXT(bv)->width);
+    insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
+    insetDescent = TEXT(bv)->height - row->ascent_of_text() +
+       TEXT_TO_INSET_OFFSET;
+    insetWidth = max(textWidth(bv->painter()), TEXT(bv)->width) +
+       (2 * TEXT_TO_INSET_OFFSET);
 }
 
 
@@ -300,6 +318,8 @@ void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button)
     locked = true;
     the_locking_inset = 0;
     inset_pos = inset_x = inset_y = 0;
+#warning Fix cursor setting here!!! (Jug)
+    TEXT(bv)->SetCursor(bv, par, 0);
 //    setPos(bv->painter(), x, y);
     checkAndActivateInset(bv, x, y, button);
 //    selection_start_cursor = selection_end_cursor = cursor;
@@ -397,8 +417,6 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
        UpdateLocal(bv, FULL, false);
     }
     no_selection = false;
-//    setPos(bv->painter(), x, y);
-//    cursor.x_fix(-1);
     TEXT(bv)->SetCursorFromCoordinates(bv, x, y+TEXT(bv)->first);
     if (the_locking_inset) {
        UpdatableInset * inset = 0;
@@ -575,7 +593,7 @@ InsetText::LocalDispatch(BufferView * bv,
        result = moveRight(bv);
        TEXT(bv)->selection = 0;
        TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
-       UpdateLocal(bv, CURSOR_PAR, false);
+       UpdateLocal(bv, CURSOR, false);
        break;
     case LFUN_LEFTSEL:
        bv->text->FinishUndo();
@@ -588,7 +606,7 @@ InsetText::LocalDispatch(BufferView * bv,
        result= moveLeft(bv);
        TEXT(bv)->selection = 0;
        TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
-       UpdateLocal(bv, CURSOR_PAR, false);
+       UpdateLocal(bv, CURSOR, false);
        break;
     case LFUN_DOWNSEL:
        bv->text->FinishUndo();
@@ -601,7 +619,7 @@ InsetText::LocalDispatch(BufferView * bv,
        result = moveDown(bv);
        TEXT(bv)->selection = 0;
        TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
-       UpdateLocal(bv, CURSOR_PAR, false);
+       UpdateLocal(bv, CURSOR, false);
        break;
     case LFUN_UPSEL:
        bv->text->FinishUndo();
@@ -614,20 +632,20 @@ InsetText::LocalDispatch(BufferView * bv,
        result = moveUp(bv);
        TEXT(bv)->selection = 0;
        TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
-       UpdateLocal(bv, CURSOR_PAR, false);
+       UpdateLocal(bv, CURSOR, false);
        break;
     case LFUN_HOME:
        bv->text->FinishUndo();
        TEXT(bv)->CursorHome(bv);
        TEXT(bv)->selection = 0;
        TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
-       UpdateLocal(bv, CURSOR_PAR, false);
+       UpdateLocal(bv, CURSOR, false);
        break;
     case LFUN_END:
        TEXT(bv)->CursorEnd(bv);
        TEXT(bv)->selection = 0;
        TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
-       UpdateLocal(bv, CURSOR_PAR, false);
+       UpdateLocal(bv, CURSOR, false);
        break;
     case LFUN_BACKSPACE:
        bv->text->SetUndo(bv->buffer(), Undo::DELETE, 
@@ -913,8 +931,12 @@ void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
 
 void InsetText::UpdateLocal(BufferView * bv, UpdateCodes what, bool mark_dirty)
 {
-    need_update = what;
-    bv->updateInset(this, mark_dirty);
+    if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
+       need_update = FULL;
+    else
+       need_update = what;
+    if ((need_update != CURSOR) || (TEXT(bv)->status != LyXText::UNCHANGED))
+           bv->updateInset(this, mark_dirty);
     if (old_par != cpar(bv)) {
            bv->owner()->getToolbar()->combox->select(cpar(bv)->GetLayout()+1);
            old_par = cpar(bv);
index c61fffd0a493b5d80beb6f00e41b835f0819ee25..50cfd1044e567e9a924a608829a4ca85097deb91 100644 (file)
@@ -45,6 +45,7 @@ public:
        INIT,
        FULL,
        CURSOR_PAR,
+       CURSOR,
        SELECTION
     };
     ///
@@ -71,7 +72,9 @@ public:
     ///
     int width(Painter &, LyXFont const & f) const;
     ///
-    void draw(BufferView *, LyXFont const &, int , float &) const;
+    int textWidth(Painter &) const;
+    ///
+    void draw(BufferView *, LyXFont const &, int , float &, bool) const;
     ///
     void update(BufferView *, LyXFont const &, bool =false);
     ///
index 20117dae392f6a3d5a57b8189086c5e6a3076b48..6f13fa4f838baf6e952e9bb3f6c72933d38ddaf4 100644 (file)
@@ -116,7 +116,7 @@ public:
        virtual int width(Painter &, LyXFont const &) const = 0;
        ///
        virtual void draw(BufferView *, LyXFont const &,
-                         int baseline, float & x) const = 0;
+                         int baseline, float & x, bool cleared) const = 0;
        /// update the inset representation
        virtual void update(BufferView *, LyXFont const &, bool =false)
                {}
index 24aaf44d0c349578b272baa0b04dd430548bf6a0..f23bd3f3c8da34d35aab038bb04c40436b0a5c57 100644 (file)
@@ -215,7 +215,7 @@ int LyXFunc::processKeyEvent(XEvent * ev)
                        owner->getMiniBuffer()->Set(CurrentState(owner->view()));
                } else {
                        tli->UnlockInsetInInset(owner->view(),
-                                               tli->GetLockingInset());
+                                               tli->GetLockingInset(),true);
                }
                return 0;
        }
index 56f3df2c006ca39bed09c3a10f3970fa617a59b8..bafa4a29dc8191812672f78cbe612527ce580a2b 100644 (file)
@@ -31,6 +31,7 @@ class LyXBuffer;
 class TexRow;
 struct LaTeXFeatures;
 class InsetBibKey;
+class BufferView;
 
 /// A LyXParagraph holds all text, attributes and insets in a text paragraph
 class LyXParagraph  {
@@ -195,7 +196,9 @@ public:
        ///
        Inset * InInset() { return inset_owner; }
        ///
-       void SetInsetOwner(Inset * i) { inset_owner = i; }
+       void SetInsetOwner(Inset * i);
+       ///
+       void deleteInsetsLyXText(BufferView *);
 private:
        ///
        TextContainer text;
index c5ea5c05f5c53dc05f66feb737a2f28a9159a1c1..938752c3e0d0d8e9f1ff16157bd817884f72cc75 100644 (file)
@@ -610,7 +610,7 @@ private:
        ///
        void draw(BufferView *, Row const * row,
                  LyXParagraph::size_type & pos,
-                 int offset, float & x);
+                 int offset, float & x, bool cleared);
 
        /// get the next breakpoint in a given paragraph
        LyXParagraph::size_type NextBreakPoint(BufferView *, Row const * row,
index 4980f5c7d9bd2a414d5175cf7fb56e68baac17ee..c27f4c293ded9e6a3a944b0099264304dd0a5ae1 100644 (file)
@@ -404,7 +404,7 @@ int InsetFormula::width(Painter &, LyXFont const & f) const
 
 
 void InsetFormula::draw(BufferView * bv, LyXFont const & f,
-                       int baseline, float & x) const
+                       int baseline, float & x, bool) const
 {
        Painter & pain = bv->painter();
        // Seems commenting out solves a problem.
index 5d96703cf305a3289a81bca1bc8272e8a88e11bf..41da55bfe6b34595d842070bb7d6eb028979bfe6 100644 (file)
@@ -47,7 +47,7 @@ public:
        ///
        int width(Painter &, LyXFont const &) const;
        ///
-       void draw(BufferView *,LyXFont const &, int baseline, float & x) const;
+       void draw(BufferView *,LyXFont const &, int, float &, bool) const;
        ///
        void Write(Buffer const *, std::ostream &) const;
        ///
index 6f7e06bd8b3910d59d42a8b8369a2043561ff764..1ab86ff732f51377823ea193616b37e94d11390e 100644 (file)
@@ -147,14 +147,14 @@ int InsetFormulaMacro::width(Painter & pain, LyXFont const & f) const
 
 
 void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
-                            int baseline, float & x) const
+                            int baseline, float & x, bool cleared) const
 {
        Painter & pain = bv->painter();
        LyXFont font(f);
        tmacro->update();
        if (opened) {
                tmacro->setEditMode(true);
-               InsetFormula::draw(bv, font, baseline, x);
+               InsetFormula::draw(bv, font, baseline, x, cleared);
                tmacro->setEditMode(false);     
        } else {
                font.setColor(LColor::math);
index ecbf0ea60e284d2a7e77a50610f41e5f55f31faf..2ae57cb6eeaa5e898b02afe96e2ce20146e1b83e 100644 (file)
@@ -43,7 +43,7 @@ public:
        ///
        int width(Painter &, LyXFont const &) const;
        ///
-       void draw(BufferView *,LyXFont const &, int baseline, float & x) const;
+       void draw(BufferView *,LyXFont const &, int, float &, bool) const;
        ///
        void Read(Buffer const *, LyXLex & lex);
         ///
index 0ab5d688ed585153516fe9a268d83f49215c563c..75a48929e80e6b0f7f23fb530f50842b008773ae 100644 (file)
 #include "LaTeXFeatures.h"
 #include "insets/insetinclude.h"
 #include "insets/insetbib.h"
+#include "insets/insettext.h"
 #include "support/filetools.h"
 #include "lyx_gui_misc.h"
 #include "texrow.h"
 #include "support/lyxmanip.h"
+#include "BufferView.h"
 
 using std::ostream;
 using std::endl;
@@ -4373,3 +4375,29 @@ string LyXParagraph::String(Buffer const * buffer,
 
        return s;
 }
+
+
+void LyXParagraph::SetInsetOwner(Inset *i)
+{
+       inset_owner = i;
+       for (InsetList::const_iterator cit = insetlist.begin();
+            cit != insetlist.end(); ++cit) {
+               if ((*cit).inset)
+                       (*cit).inset->setOwner(i);
+       }
+}
+
+
+void LyXParagraph::deleteInsetsLyXText(BufferView * bv)
+{
+       // then the insets
+       for (InsetList::const_iterator cit = insetlist.begin();
+            cit != insetlist.end(); ++cit) {
+               if ((*cit).inset) {
+                       if ((*cit).inset->IsTextInset()) {
+                               static_cast<InsetText *>((*cit).inset)->
+                                       deleteLyXText(bv);
+                       }
+               }
+       }
+}
index 7ebdeb69232a63e6dd6bbe2dcb13edb588617c09..42853796d89a57ac785d56e06314d7bc1af400c4 100644 (file)
@@ -54,50 +54,7 @@ LyXTabular::cellstruct::cellstruct()
     bottom_line = false;
     rotate = false;
     linebreaks = false;
-#ifdef INSET_POINTER
-    inset = 0;
-#endif
-}
-
-#ifdef INSET_POINTER
-LyXTabular::cellstruct::~cellstruct() 
-{
-    delete inset;
-}
-
-LyXTabular::cellstruct::cellstruct(cellstruct const & cs)
-{
-    cellno = cs.cellno;
-    width_of_cell = cs.width_of_cell;
-    multicolumn = cs.multicolumn;
-    alignment = cs.alignment;
-    top_line = cs.top_line;
-    bottom_line = cs.bottom_line;
-    rotate = cs.rotate;
-    linebreaks = cs.linebreaks;
-    inset = cs.inset;
-#if 0
-    if (cs.inset)
-       inset = static_cast<InsetText *>(cs.inset->Clone());
-#endif
-}
-
-LyXTabular::cellstruct & 
-LyXTabular::cellstruct::operator=(cellstruct const & cs)
-{
-    cellno = cs.cellno;
-    width_of_cell = cs.width_of_cell;
-    multicolumn = cs.multicolumn;
-    alignment = cs.alignment;
-    top_line = cs.top_line;
-    bottom_line = cs.bottom_line;
-    rotate = cs.rotate;
-    linebreaks = cs.linebreaks;
-    if (cs.inset)
-       inset = static_cast<InsetText *>(cs.inset->Clone());
-    return *this;
 }
-#endif
 
 
 LyXTabular::rowstruct::rowstruct() 
@@ -186,12 +143,7 @@ LyXTabular * LyXTabular::Clone(InsetTabular * inset)
     int i,j;
     for(i=0; i < rows_; ++i) {
        for(j=0; j < columns_; ++j) {
-#ifdef INSET_POINTER
-           delete result->cell_info[i][j].inset;
-           result->cell_info[i][j].inset=new InsetText(*cell_info[i][j].inset);
-#else
            result->cell_info[i][j].inset = cell_info[i][j].inset;
-#endif
            result->cell_info[i][j].inset.setOwner(inset);
        }
     }
@@ -215,10 +167,6 @@ void LyXTabular::Init(int rows_arg, int columns_arg)
     // Jürgen, use iterators.
     for (i = 0; i < rows_; ++i) {
         for (j = 0; j < columns_; ++j) {
-#ifdef INSET_POINTER
-           if (!cell_info[i][j].inset)
-               cell_info[i][j].inset = new InsetText();
-#endif
            cell_info[i][j].inset.setOwner(owner_);
            cell_info[i][j].inset.SetDrawLockedFrame(true);
             cell_info[i][j].cellno = cellno++;
@@ -255,7 +203,7 @@ void LyXTabular::AppendRow(int cell )
     row_vector::iterator rit = row_info.begin() + row;
     row_info.insert(rit, rowstruct());
 
-#if 1
+#if 0
     cell_vvector::iterator cit = cell_info.begin() + row;
     cell_info.insert(cit, vector<cellstruct>(columns_, cellstruct()));
 #else
@@ -273,14 +221,6 @@ void LyXTabular::AppendRow(int cell )
        }
     }
     cell_info = c_info;
-#ifdef INSET_POINTER
-    for(int i = 0; i < rows_; ++i) {
-       for(int j = 0; j < columns_; ++j) {
-           if (!cell_info[i][j].inset)
-               cell_info[i][j].inset = static_cast<InsetText *>(c_info[i][j].inset->Clone());
-       }
-    }
-#endif
     ++row;
     for (int j = 0; j < columns_; ++j) {
        cell_info[row][j].inset.clear();
@@ -329,13 +269,6 @@ void LyXTabular::AppendColumn(int cell)
         }
     }
     cell_info = c_info;
-#ifdef INSET_POINTER
-    for(i = 0; i < rows_; ++i) {
-       for(j = 0; j < columns_; ++j) {
-           cell_info[i][j].inset = static_cast<InsetText *>(c_info[i][j].inset->Clone());
-       }
-    }
-#endif
     ++column;
     for (i = 0; i < rows_; ++i) {
        cell_info[i][column].inset.clear();
index 408872d492d95dbaf1a961018e1ccc617ca50995..d77d5f4644c48e8c0b122ed6f8c478d2f28d13f3 100644 (file)
@@ -117,12 +117,7 @@ bool is_nikud(unsigned char c)
 int LyXText::workWidth(BufferView * bview) const
 {
        if (inset_owner) {
-#if 1
-               return inset_owner->getMaxWidth(bview->painter(), inset_owner);
-#else
-               LyXFont font(LyXFont::ALL_SANE);
-               return inset_owner->width(bview->painter(), font);
-#endif
+               return inset_owner->textWidth(bview->painter());
        }
        return bview->workWidth();
 }
@@ -445,7 +440,7 @@ bool LyXText::IsBoundary(Buffer const * buf, LyXParagraph * par,
 
 void LyXText::draw(BufferView * bview, Row const * row,
                   LyXParagraph::size_type & vpos,
-                  int offset, float & x)
+                  int offset, float & x, bool cleared)
 {
        Painter & pain = bview->painter();
        
@@ -567,7 +562,8 @@ void LyXText::draw(BufferView * bview, Row const * row,
        } else if (c == LyXParagraph::META_INSET) {
                Inset const * tmpinset = row->par()->GetInset(pos);
                if (tmpinset) {
-                       tmpinset->draw(bview, font, offset+row->baseline(), x);
+                       tmpinset->draw(bview, font, offset+row->baseline(), x,
+                                      cleared);
                }
                ++vpos;
 
@@ -3794,10 +3790,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
        
        // clear the area where we want to paint/print
        int ww;
-       if (inset_owner)
-               ww = inset_owner->width(bview->painter(), font) - 1;
-       else
-               ww = bview->workWidth();
+       ww = bview->workWidth();
 
        bool clear_area = true;
 
@@ -3807,8 +3800,14 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
        {
                clear_area = row_ptr->par()->GetInset(row_ptr->pos())->doClearArea();
        }
-       if (clear_area)
-               pain.fillRectangle(x_offset, y_offset, ww, row_ptr->height());
+       if (clear_area) {
+               int w;
+               if (inset_owner)
+                       w = inset_owner->width(bview->painter(), font);
+               else
+                       w = ww;
+               pain.fillRectangle(x_offset, y_offset, w, row_ptr->height());
+       }
        
        if (selection) {
                /* selection code */
@@ -4324,7 +4323,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
                                        - row_ptr->par()->bibkey->width(bview->painter(), font);
                        row_ptr->par()->bibkey->draw(bview, font,
                                                   y_offset + row_ptr->baseline(), 
-                                                  tmpx);
+                                                  tmpx, clear_area);
                }
        }
        
@@ -4528,7 +4527,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
                                                row_ptr->par(), pos);
                                ++vpos;
                        } else
-                               draw(bview, row_ptr, vpos, y_offset, x);
+                               draw(bview, row_ptr, vpos, y_offset, x, clear_area);
                }
                
                /* do not forget the very last cell. This has no NEWLINE so 
@@ -4640,7 +4639,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
                                        x += fill_separator;
                                ++vpos;
                        } else
-                               draw(bview, row_ptr, vpos, y_offset, x);
+                               draw(bview, row_ptr, vpos, y_offset, x, clear_area);
                }
 #ifndef NEW_TABULAR
        }
index ed1aad2b323401a4f185dd3b6a36d79725d9abb6..ab6d84ba4996e06917a3b693d38695f1720eb1b6 100644 (file)
@@ -69,7 +69,8 @@ void LyXText::init()
        lastrow = 0;
        number_of_rows = 0;
        refresh_y = 0;
-       height = width = 0;
+       height = 0;
+       width = -1;
        first = 0;
        status = LyXText::UNCHANGED;
        // set cursor at the very top position
@@ -131,7 +132,7 @@ void LyXText::init(BufferView * bview)
                par = par->Next();
        }
        SetCursorIntern(bview, firstrow->par(), 0);
-#if 1
+#if 0
        // Dump all rowinformation:
        Row * tmprow = firstrow;
        lyxerr << "Width = " << width << endl;