On Wed, Jun 21, 2006 at 12:17:41PM +0200, Jean-Marc Lasgouttes wrote:
> >>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:
> 
> Martin> In my newfound tradition of making everything simpler :-) If
> Martin> you paint the whole tabular background, you don't have to
> Martin> figure out what cell you're in...
> 
> Martin> Please give it some exercise before the go-ahead for 1.4.
> 
> I do not know whether this is related to your patch(es): try to insert
> a collapsable inset in a tabular cell; the right margin of the inset
> is outside of the screen.

I suppose the speed-up patch exposed this bug, i.e., that a tabular
cell with a non-fixed width does not transmit a sensible
mi.base.textwidth to any textinsets it contains. Now that we use this
(or the derived maxwidth_) to decide how much space to give to a Wide
inset, this becomes visible.

Attached the tabular background patch for 1.4 (still not applied) with
code added to fix this problem (first chunk). The code is ugly (deciding
how much space the stuff in the cell needs, and then giving a little
more) but seems to do the trick.

- Martin

Index: insettabular.C
===================================================================
--- insettabular.C      (revision 14143)
+++ insettabular.C      (working copy)
@@ -261,9 +261,13 @@
                        tabular.getCellInset(cell)->metrics(m, dim);
                        if (!p_width.zero())
                                dim.wid = m.base.textwidth;
+                       tabular.setWidthOfCell(cell, dim.wid);
+                       if (p_width.zero()) {
+                               m.base.textwidth = dim.wid + 1;
+                               tabular.getCellInset(cell)->metrics(m, dim);
+                       }
                        maxAsc  = max(maxAsc, dim.asc);
                        maxDesc = max(maxDesc, dim.des);
-                       tabular.setWidthOfCell(cell, dim.wid);
                        ++cell;
                }
                tabular.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT);
@@ -332,6 +336,15 @@
        setPosCache(pi, x, y);
 
        LCursor & cur = pi.base.bv->cursor();
+
+       x += scx_ + ADD_TO_TABULAR_WIDTH;
+
+       // Paint background of current tabular
+       int const w = tabular.getWidthOfTabular();
+       int const h = tabular.getHeightOfTabular();
+       int yy = y - tabular.getAscentOfRow(0);
+       pi.pain.fillRectangle(x, yy, w, h, backgroundColor());
+
        if (!cur.selection())
                return;
        if (!ptr_cmp(&cur.inset(), this))
@@ -339,7 +352,6 @@
 
        //resetPos(cur);
 
-       x += scx_ + ADD_TO_TABULAR_WIDTH;
 
        if (tablemode(cur)) {
                row_type rs, re;

Attachment: pgpaqWNqsAAUn.pgp
Description: PGP signature

Reply via email to