]> git.lyx.org Git - features.git/blobdiff - src/insets/insettabular.C
read the Changelog
[features.git] / src / insets / insettabular.C
index cbffdc4647320ff59f5853c88a2283b4f9d66cf0..6e6aeac44ae78069c5e5f7bd1cb0a2a333b67e63 100644 (file)
@@ -5,7 +5,7 @@
  *
  *           Copyright 2000 The LyX Team.
  *
- *======================================================
+ * ======================================================
  */
 
 #include <config.h>
 #include "LyXView.h"
 #include "lyxfunc.h"
 #include "insets/insettext.h"
-
-extern void MenuLayoutTabular(bool, InsetTabular *);
-extern bool UpdateLayoutTabular(bool, InsetTabular *);
-extern void TabularOptClose();
+#include "frontends/Dialogs.h"
 
 const int ADD_TO_HEIGHT = 2;
 const int ADD_TO_TABULAR_WIDTH = 2;
@@ -43,6 +40,7 @@ using std::ostream;
 using std::ifstream;
 using std::max;
 using std::endl;
+using std::swap;
 
 #define cellstart(p) ((p % 2) == 0)
 
@@ -63,6 +61,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;
+    dialogs_ = 0;
     need_update = INIT;
 }
 
@@ -78,6 +77,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;
+    dialogs_ = 0;
     need_update = INIT;
 }
 
@@ -85,6 +85,8 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer * buf)
 InsetTabular::~InsetTabular()
 {
     delete tabular;
+    if (dialogs_)
+       dialogs_->hideTabular(this);
 }
 
 
@@ -131,19 +133,19 @@ void InsetTabular::Read(Buffer const * buf, LyXLex & lex)
 }
 
 
-int InsetTabular::ascent(Painter &, LyXFont const &) const
+int InsetTabular::ascent(BufferView *, LyXFont const &) const
 {
     return tabular->GetAscentOfRow(0);
 }
 
 
-int InsetTabular::descent(Painter &, LyXFont const &) const
+int InsetTabular::descent(BufferView *, LyXFont const &) const
 {
-    return tabular->GetHeightOfTabular() - tabular->GetAscentOfRow(0);
+    return tabular->GetHeightOfTabular() - tabular->GetAscentOfRow(0) + 1;
 }
 
 
-int InsetTabular::width(Painter &, LyXFont const &) const
+int InsetTabular::width(BufferView *, LyXFont const &) const
 {
     return tabular->GetWidthOfTabular() + (2 * ADD_TO_TABULAR_WIDTH);
 }
@@ -153,28 +155,33 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
                        float & x, bool cleared) const
 {
     Painter & pain = bv->painter();
-    int i, j, cell=0;
+    int i, j, cell = 0;
     int nx;
     float cx;
 
     UpdatableInset::draw(bv,font,baseline,x,cleared);
-    if ((need_update == INIT)|| (top_x != int(x)) || (top_baseline != baseline)) {
+    if (!cleared && ((need_update == INIT) || (need_update == FULL) ||
+                    (top_x != int(x)) || (top_baseline != baseline))) {
+       int h = ascent(bv, font) + descent(bv, font);
+       int tx = display()||!owner()? 0:top_x;
+       int w =  tx? width(bv, font):pain.paperWidth();
+       int ty = baseline - ascent(bv, font);
+       
+       if (ty < 0)
+           ty = 0;
+       if ((ty + h) > pain.paperHeight())
+           h = pain.paperHeight();
+       if ((top_x + w) > pain.paperWidth())
+           w = pain.paperWidth();
+       pain.fillRectangle(tx, ty, w, h);
        need_update = FULL;
-       top_x = int(x);
-       top_baseline = baseline;
-       resetPos(pain);
-       if (locked) { // repaint this way as the background was not cleared
-               if (the_locking_inset)
-                       the_locking_inset->update(bv, font, true);
-               locked = false;
-               bv->updateInset(const_cast<InsetTabular*>(this), false);
-               locked = true;
-               return;
-       }
+       cleared = true;
     }
+    top_x = int(x);
+    top_baseline = baseline;
     bool dodraw;
     x += ADD_TO_TABULAR_WIDTH;
-    if (cleared || !locked || (need_update == FULL) || (need_update == CELL)) {
+    if (cleared || (need_update == FULL) || (need_update == CELL)) {
        for(i=0;i<tabular->rows();++i) {
            nx = int(x);
            dodraw = ((baseline+tabular->GetDescentOfRow(i)) > 0) &&
@@ -203,7 +210,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
                tabular->GetAdditionalHeight(cell+1);
        }
     }
-    x += width(pain, font);
+    x += width(bv, font);
     need_update = NONE;
 }
 
@@ -246,8 +253,6 @@ void InsetTabular::DrawCellLines(Painter & pain, int x, int baseline,
 void InsetTabular::DrawCellSelection(Painter & pain, int x, int baseline,
                                     int row, int column, int cell) const
 {
-    int tmp;
-
     int cs = tabular->column_of_cell(sel_cell_start);
     int ce = tabular->column_of_cell(sel_cell_end);
     if (cs > ce) {
@@ -259,11 +264,7 @@ void InsetTabular::DrawCellSelection(Painter & pain, int x, int baseline,
 
     int rs = tabular->row_of_cell(sel_cell_start);
     int re = tabular->row_of_cell(sel_cell_end);
-    if (rs > re) {
-       tmp = rs;
-       rs = re;
-       re = tmp;
-    }
+    if (rs > re) swap(rs, re);
 
     if ((column >= cs) && (column <= ce) && (row >= rs) && (row <= re)) {
        int w = tabular->GetWidthOfColumn(cell);
@@ -274,15 +275,22 @@ void InsetTabular::DrawCellSelection(Painter & pain, int x, int baseline,
 }
 
 
-void InsetTabular::update(BufferView * bv, LyXFont const & font, bool dodraw)
+void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit)
 {
+    if (reinit) {
+       need_update = INIT;
+       calculate_dimensions_of_cells(bv, font, true);
+       if (owner())
+           owner()->update(bv, font, true);
+       return;
+    }
     if (the_locking_inset)
-       the_locking_inset->update(bv, font, dodraw);
+       the_locking_inset->update(bv, font, reinit);
     switch(need_update) {
     case INIT:
     case FULL:
     case CELL:
-       if (calculate_dimensions_of_cells(bv, font, dodraw))
+       if (calculate_dimensions_of_cells(bv, font, false))
            need_update = INIT;
        break;
     case SELECTION:
@@ -311,7 +319,7 @@ void InsetTabular::Edit(BufferView * bv, int x, int y, unsigned int button)
     locked = true;
     the_locking_inset = 0;
     inset_pos = inset_x = inset_y = 0;
-    setPos(bv->painter(), x, y);
+    setPos(bv, x, y);
     sel_pos_start = sel_pos_end = cursor.pos();
     sel_cell_start = sel_cell_end = actcell;
     bv->text->FinishUndo();
@@ -325,7 +333,6 @@ void InsetTabular::Edit(BufferView * bv, int x, int y, unsigned int button)
 
 void InsetTabular::InsetUnlock(BufferView * bv)
 {
-    TabularOptClose();
     if (the_locking_inset) {
        the_locking_inset->InsetUnlock(bv);
        the_locking_inset = 0;
@@ -341,15 +348,17 @@ void InsetTabular::InsetUnlock(BufferView * bv)
     locked = false;
 }
 
+
 void InsetTabular::UpdateLocal(BufferView * bv, UpdateCodes what,
                               bool mark_dirty)
 {
     need_update = what;
     bv->updateInset(this, mark_dirty);
     if (what != NONE)
-       resetPos(bv->painter());
+       resetPos(bv);
 }
 
+
 bool InsetTabular::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
 {
     lyxerr[Debug::INSETS] << "InsetTabular::LockInsetInInset(" <<inset<< "): ";
@@ -359,7 +368,7 @@ bool InsetTabular::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
     if (inset == tabular->GetCellInset(actcell)) {
        lyxerr[Debug::INSETS] << "OK" << endl;
        the_locking_inset = tabular->GetCellInset(actcell);
-       resetPos(bv->painter());
+       resetPos(bv);
        inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
        inset_y = cursor.y();
        inset_pos = cursor.pos();
@@ -367,7 +376,7 @@ bool InsetTabular::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
     } else if (the_locking_inset && (the_locking_inset == inset)) {
        if (cursor.pos() == inset_pos) {
            lyxerr[Debug::INSETS] << "OK" << endl;
-           resetPos(bv->painter());
+           resetPos(bv);
            inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
            inset_y = cursor.y();
        } else {
@@ -381,6 +390,7 @@ bool InsetTabular::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
     return false;
 }
 
+
 bool InsetTabular::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
                                   bool lr)
 {
@@ -398,7 +408,8 @@ bool InsetTabular::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
        if ((inset->LyxCode() == TABULAR_CODE) &&
            !the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE))
        {
-           UpdateLayoutTabular(true, const_cast<InsetTabular *>(this));
+           dialogs_ = bv->owner()->getDialogs();
+           dialogs_->updateTabular(const_cast<InsetTabular *>(this));
            oldcell = actcell;
        }
        return true;
@@ -406,6 +417,7 @@ bool InsetTabular::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
     return false;
 }
 
+
 bool InsetTabular::UpdateInsetInInset(BufferView * bv, Inset * inset)
 {
     if (!the_locking_inset)
@@ -450,28 +462,6 @@ bool InsetTabular::InsertInset(BufferView * bv, Inset * inset)
 }
 
 
-void InsetTabular::InsetButtonRelease(BufferView * bv,
-                                     int x, int y, int button)
-{
-    if (button == 3) {
-       if (the_locking_inset) {
-           UpdatableInset * i;
-           if ((i=the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE))) {
-               i->InsetButtonRelease(bv, x, y, button);
-               return;
-           }
-       }
-       MenuLayoutTabular(true, this);
-       return;
-    }
-    if (the_locking_inset) {
-        the_locking_inset->InsetButtonRelease(bv, x-inset_x, y-inset_y,button);
-        return;
-    }
-    no_selection = false;
-}
-
-
 void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
 {
     if (hasSelection()) {
@@ -482,7 +472,7 @@ void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
 
     int ocell = actcell;
 
-    setPos(bv->painter(), x, y);
+    setPos(bv, x, y);
     sel_pos_start = sel_pos_end = cursor.pos();
     sel_cell_start = sel_cell_end = actcell;
 
@@ -499,13 +489,33 @@ void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
        ActivateCellInset(bv, x, y, button);
        the_locking_inset->InsetButtonPress(bv, x-inset_x, y-inset_y, button);
     }
-    
+}
+
+
+void InsetTabular::InsetButtonRelease(BufferView * bv,
+                                     int x, int y, int button)
+{
+    if (button == 3) {
+       if (the_locking_inset) {
+           UpdatableInset * i;
+           if ((i=the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE))) {
+               i->InsetButtonRelease(bv, x, y, button);
+               return;
+           }
+       }
+       dialogs_ = bv->owner()->getDialogs();
+        dialogs_->showTabular(this);
 #if 0
-    if (button == 3)
-        bview->getOwner()->getPopups().showFormTabular();
-    else if (ocell != actcell)
-        bview->getOwner()->getPopups().updateFormTabular();
+       else if (ocell != actcell)
+               bview->getOwner()->getPopups().updateTabular();
 #endif
+       return;
+    }
+    if (the_locking_inset) {
+        the_locking_inset->InsetButtonRelease(bv, x-inset_x, y-inset_y,button);
+        return;
+    }
+    no_selection = false;
 }
 
 
@@ -520,7 +530,7 @@ void InsetTabular::InsetMotionNotify(BufferView * bv, int x, int y, int button)
            // int ocell = actcell,
            int old = sel_pos_end;
 
-       setPos(bv->painter(), x, y);
+       setPos(bv, x, y);
        sel_pos_end = cursor.pos();
        sel_cell_end = actcell;
        if (old != sel_pos_end)
@@ -553,10 +563,9 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
     if (((result=UpdatableInset::LocalDispatch(bv, action, arg)) == DISPATCHED)
        || (result == DISPATCHED_NOUPDATE)) {
 
-       resetPos(bv->painter());
+       resetPos(bv);
        return result;
     }
-    result=DISPATCHED;
 
     if ((action < 0) && arg.empty())
         return FINISHED;
@@ -576,7 +585,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
         } else if (result == FINISHED) {
            if ((action == LFUN_RIGHT) || (action == -1)) {
                cursor.pos(inset_pos + 1);
-               resetPos(bv->painter());
+               resetPos(bv);
            }
            sel_pos_start = sel_pos_end = cursor.pos();
            sel_cell_start = sel_cell_end = actcell;
@@ -588,6 +597,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
 
     bool hs = hasSelection();
     HideInsetCursor(bv);
+    result=DISPATCHED;
     switch (action) {
        // Normal chars not handled here
     case -1:
@@ -612,7 +622,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, CURSOR, false);
+           UpdateLocal(bv, SELECTION, false);
        break;
     case LFUN_LEFTSEL:
        if (tabular->IsFirstCellInRow(actcell) && cellstart(cursor.pos()))
@@ -633,7 +643,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, CURSOR, false);
+           UpdateLocal(bv, SELECTION, false);
        break;
     case LFUN_DOWNSEL:
     {
@@ -653,7 +663,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, CURSOR, false);
+           UpdateLocal(bv, SELECTION, false);
        break;
     case LFUN_UPSEL:
     {
@@ -673,7 +683,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, CURSOR, false);
+           UpdateLocal(bv, SELECTION, false);
        break;
     case LFUN_BACKSPACE:
        break;
@@ -686,9 +696,9 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
     case LFUN_SHIFT_TAB:
     case LFUN_TAB:
        if (the_locking_inset) {
-           the_locking_inset->InsetUnlock(bv);
+           UnlockInsetInInset(bv, the_locking_inset);
+           the_locking_inset = 0;
        }
-       the_locking_inset = 0;
        if (action == LFUN_TAB)
            moveNextCell(bv);
        else
@@ -696,12 +706,12 @@ 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, CURSOR, false);
+           UpdateLocal(bv, SELECTION, false);
        break;
     case LFUN_LAYOUT_TABLE:
     {
-       int flag = (arg == "true");
-       MenuLayoutTabular(flag, this);
+       dialogs_ = bv->owner()->getDialogs();
+        dialogs_->showTabular(this);
     }
     break;
     default:
@@ -722,7 +732,8 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
 }
 
 
-int InsetTabular::Latex(Buffer const * buf, ostream & os, bool fragile, bool fp) const
+int InsetTabular::Latex(Buffer const * buf, ostream & os,
+                       bool fragile, bool fp) const
 {
     return tabular->Latex(buf, os, fragile, fp);
 }
@@ -733,6 +744,7 @@ int InsetTabular::Ascii(Buffer const *, ostream &) const
     return 0;
 }
 
+
 int InsetTabular::Linuxdoc(Buffer const *, ostream &) const
 {
     return 0;
@@ -753,7 +765,7 @@ void InsetTabular::Validate(LaTeXFeatures & features) const
 
 bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv,
                                                 LyXFont const & font,
-                                                bool dodraw) const
+                                                bool reinit) const
 {
     int cell = -1;
     int maxAsc, maxDesc;
@@ -767,10 +779,11 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv,
                continue;
            ++cell;
            inset = tabular->GetCellInset(cell);
-           inset->update(bv, font, dodraw);
-           maxAsc = max(maxAsc, inset->ascent(bv->painter(), font));
-           maxDesc = max(maxDesc, inset->descent(bv->painter(), font));
-           changed = tabular->SetWidthOfCell(cell, inset->width(bv->painter(), font)) || changed;
+           if (!reinit)
+               inset->update(bv, font, false);
+           maxAsc = max(maxAsc, inset->ascent(bv, font));
+           maxDesc = max(maxDesc, inset->descent(bv, font));
+           changed = tabular->SetWidthOfCell(cell, inset->width(bv, font)) || changed;
        }
        changed = tabular->SetAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed;
        changed = tabular->SetDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed;
@@ -827,7 +840,7 @@ void InsetTabular::HideInsetCursor(BufferView * bv)
 }
 
 
-void InsetTabular::setPos(Painter & pain, int x, int y) const
+void InsetTabular::setPos(BufferView * bv, int x, int y) const
 {
        cursor.y(0);
        cursor.pos(0);
@@ -853,16 +866,17 @@ void InsetTabular::setPos(Painter & pain, int x, int y) const
        ++actcell,lx += tabular->GetWidthOfColumn(actcell) +
            tabular->GetAdditionalWidth(actcell - 1));
     cursor.pos(((actcell+1) * 2) - 1);
-    resetPos(pain);
+    resetPos(bv);
     if ((lx - (tabular->GetWidthOfColumn(actcell)/2)) < x) {
        cursor.x(lx + top_x - 2);
     } else {
        cursor.pos(cursor.pos() - 1);
        cursor.x(lx - tabular->GetWidthOfColumn(actcell) + top_x + 2);
     }
-    resetPos(pain);
+    resetPos(bv);
 }
 
+
 int InsetTabular::getCellXPos(int cell) const
 {
     int c;
@@ -877,7 +891,8 @@ int InsetTabular::getCellXPos(int cell) const
            ADD_TO_TABULAR_WIDTH);
 }
 
-void InsetTabular::resetPos(Painter & pain) const
+
+void InsetTabular::resetPos(BufferView * bv) const
 {
     if (!locked)
        return;
@@ -897,13 +912,14 @@ void InsetTabular::resetPos(Painter & pain) const
     cursor.x(getCellXPos(actcell) + 2);
     if (cursor.pos() % 2) {
        LyXFont font(LyXFont::ALL_SANE);
-       cursor.x(cursor.x() + tabular->GetCellInset(actcell)->width(pain,font) +
+       cursor.x(cursor.x() + tabular->GetCellInset(actcell)->width(bv,font) +
                tabular->GetBeginningOfTextInCell(actcell));
     }
     if ((!the_locking_inset ||
         !the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE)) &&
        (actcell != oldcell)) {
-       UpdateLayoutTabular(true, const_cast<InsetTabular *>(this));
+       dialogs_ = bv->owner()->getDialogs();
+        dialogs_->updateTabular(const_cast<InsetTabular *>(this));
        oldcell = actcell;
     }
 }
@@ -922,7 +938,7 @@ UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
     } else {              // before the inset
        cursor.pos(cursor.pos() + 1);
     }
-    resetPos(bv->painter());
+    resetPos(bv);
     return DISPATCHED_NOUPDATE;
 }
 
@@ -941,7 +957,7 @@ UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
        if (ActivateCellInset(bv, 0, 0, 0, true))
            return DISPATCHED;
     }
-    resetPos(bv->painter());
+    resetPos(bv);
     return DISPATCHED_NOUPDATE;
 }
 
@@ -952,7 +968,7 @@ UpdatableInset::RESULT InsetTabular::moveUp(BufferView * bv)
     actcell = tabular->GetCellAbove(actcell);
     if (actcell == ocell) // we moved out of the inset
        return FINISHED;
-    resetPos(bv->painter());
+    resetPos(bv);
     return DISPATCHED_NOUPDATE;
 }
 
@@ -963,7 +979,7 @@ UpdatableInset::RESULT InsetTabular::moveDown(BufferView * bv)
     actcell = tabular->GetCellBelow(actcell);
     if (actcell == ocell) // we moved out of the inset
        return FINISHED;
-    resetPos(bv->painter());
+    resetPos(bv);
     return DISPATCHED_NOUPDATE;
 }
 
@@ -976,7 +992,7 @@ bool InsetTabular::moveNextCell(BufferView * bv)
     cursor.pos(cursor.pos() + 1);
     if (!cellstart(cursor.pos()))
        cursor.pos(cursor.pos() + 1);
-    resetPos(bv->painter());
+    resetPos(bv);
     return true;
 }
 
@@ -989,7 +1005,7 @@ bool InsetTabular::movePrevCell(BufferView * bv)
     cursor.pos(cursor.pos() - 1);
     if (cellstart(cursor.pos()))
        cursor.pos(cursor.pos() - 1);
-    resetPos(bv->painter());
+    resetPos(bv);
     return true;
 }
 
@@ -1246,6 +1262,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
     }
 }
 
+
 bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button,
                                     bool behind)
 {
@@ -1253,14 +1270,14 @@ bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button,
     // reset the curor pos first!
     if (cursor.pos() % 2) { // behind the inset
        cursor.pos(cursor.pos() - 1);
-       resetPos(bv->painter());
+       resetPos(bv);
     }
     UpdatableInset * inset =
        static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
     LyXFont font(LyXFont::ALL_SANE);
     if (behind) {
-       x = inset->x() + inset->width(bv->painter(), font);
-       y = inset->descent(bv->painter(), font);
+       x = inset->x() + inset->width(bv, font);
+       y = inset->descent(bv, font);
     }
     inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
     inset_y = cursor.y();
@@ -1271,6 +1288,7 @@ bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button,
     return true;
 }
 
+
 bool InsetTabular::InsetHit(BufferView * bv, int x, int ) const
 {
     InsetText * inset = tabular->GetCellInset(actcell);
@@ -1278,16 +1296,16 @@ bool InsetTabular::InsetHit(BufferView * bv, int x, int ) const
 
     if (cursor.pos() % 2) { // behind the inset
        return (((x + top_x) < cursor.x()) &&
-               ((x + top_x) > (cursor.x() - inset->width(bv->painter(),
+               ((x + top_x) > (cursor.x() - inset->width(bv,
                                                      LyXFont(LyXFont::ALL_SANE)))));
     } else {
        int x2 = cursor.x() + tabular->GetBeginningOfTextInCell(actcell);
        return ((x1 > x2) &&
-               (x1 < (x2 + inset->width(bv->painter(),
-                                        LyXFont(LyXFont::ALL_SANE)))));
+               (x1 < (x2 + inset->width(bv, LyXFont(LyXFont::ALL_SANE)))));
     }
 }
 
+
 // This returns paperWidth() if the cell-width is unlimited or the width
 // in pixels if we have a pwidth for this cell.
 int InsetTabular::GetMaxWidthOfCell(Painter &, int cell) const
@@ -1299,6 +1317,7 @@ int InsetTabular::GetMaxWidthOfCell(Painter &, int cell) const
     return VSpace(s).inPixels( 0, 0);
 }
 
+
 int InsetTabular::getMaxWidth(Painter & pain,
                              UpdatableInset const * inset) const
 {
@@ -1318,7 +1337,9 @@ int InsetTabular::getMaxWidth(Painter & pain,
     return w;
 }
 
-void InsetTabular::recomputeTextInsets(BufferView * bv, const LyXFont & font) const
+
+void InsetTabular::recomputeTextInsets(BufferView * bv,
+                                      LyXFont const & font) const
 {
     InsetText * inset;
     int cell;
@@ -1331,9 +1352,15 @@ void InsetTabular::recomputeTextInsets(BufferView * bv, const LyXFont & font) co
            cell = tabular->GetCellNumber(i,j);
            inset = tabular->GetCellInset(cell);
            inset->update(bv, font);
-           tabular->SetWidthOfCell(cell, inset->width(bv->painter(), font));
+           tabular->SetWidthOfCell(cell, inset->width(bv, font));
        }
 //     cell = tabular->GetCellNumber(0, j);
 //     cx += tabular->GetWidthOfColumn(cell);
     }
 }
+
+
+void InsetTabular::resizeLyXText(BufferView *) const
+{
+    need_update = FULL;
+}