On Fri, Jan 04, 2002 at 08:36:58AM +0100, Michael Schmitt wrote:
> - Insert a (math) inset into a table cell. Then, move the cursor along the current 
>   row. The lines at the bottom of other cells are erased (on screen) (#59)

Fixed, and did some cleanup and documentation too, for my own
consumption ;-)

Martin
-- 
Martin Vermeer  [EMAIL PROTECTED]
Helsinki University of Technology 
Department of Surveying
P.O. Box 1200, FIN-02015 HUT, Finland
:wq
Index: insettabular.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/insets/insettabular.C,v
retrieving revision 1.159
diff -u -p -r1.159 insettabular.C
--- insettabular.C      2002/01/03 13:31:12     1.159
+++ insettabular.C      2002/01/06 20:09:23
@@ -267,6 +267,9 @@ void InsetTabular::draw(BufferView * bv,
                if ((top_x + w) > pain.paperWidth())
                        w = pain.paperWidth();
                pain.fillRectangle(tx, ty, w, h, backgroundColor());
+               //lyxerr << "Tabular fillRect A " << 
+               //              tx << " " << ty << " " 
+               //              << w << " " << h << endl;
                need_update = FULL;
                cleared = true;
        }
@@ -362,39 +365,56 @@ void InsetTabular::draw(BufferView * bv,
                float dx = nx + tabular->GetBeginningOfTextInCell(cell);
                float cx = dx;
                tabular->GetCellInset(cell)->draw(bv, font, baseline, dx, false);
+               //
+               // Here we use rectangular backgroundColor patches to clean up
+               // within a cell around the cell's red inset box. As follows:
+               //
+               //  +---+            +---+
+               //  |   |            |   |   The rectangles are A, B and C
+               //  | A |------------| B |   below, origin top left (tx, ty), 
+               //  |   |  inset box |   |   dimensions w(idth), h(eight).
+               //  +---+------------+---+   x grows rightward, y downward
+               //  |         D          |
+               //  +--------------------+
+               //
                // clear only if we didn't have a change
                if (bv->text->status() != LyXText::CHANGED_IN_DRAW) {
                        // clear before the inset
-                       pain.fillRectangle(
-                               nx + 1,
-                               baseline - tabular->GetAscentOfRow(i) + 1,
-                               int(cx - nx - 1),
-                               tabular->GetAscentOfRow(i) +
-                               tabular->GetDescentOfRow(i) - 1,
-                               backgroundColor());
+                       int tx, ty, w, h;
+                       tx = nx + 1; 
+                       ty = baseline - tabular->GetAscentOfRow(i) + 1;
+                       w = int(cx - nx - 1);
+                       h = tabular->GetAscentOfRow(i) + 
+                               tabular->GetDescentOfRow(i) - 1;
+                       pain.fillRectangle(tx, ty, w, h, backgroundColor());
+                       //lyxerr << "Tabular fillRect B " << tx << " " << ty << " " 
+                       //      << w << " " << h << endl;
                        // clear behind the inset
-                       pain.fillRectangle(
-                               int(cx + the_locking_inset->width(bv,font) + 1),
-                               baseline - tabular->GetAscentOfRow(i) + 1,
-                               tabular->GetWidthOfColumn(cell) -
+                       tx = int(cx + the_locking_inset->width(bv,font) + 1);
+                       ty = baseline - tabular->GetAscentOfRow(i) + 1;
+                       w = tabular->GetWidthOfColumn(cell) -
                                tabular->GetBeginningOfTextInCell(cell) -
                                the_locking_inset->width(bv,font) -
-                               tabular->GetAdditionalWidth(cell) - 1,
-                               tabular->GetAscentOfRow(i) +
-                               tabular->GetDescentOfRow(i) - 1,
-                               backgroundColor());
+                               tabular->GetAdditionalWidth(cell) - 1;
+                       h = tabular->GetAscentOfRow(i) + tabular->GetDescentOfRow(i) - 
+1;
+                       pain.fillRectangle(tx, ty, w, h, backgroundColor());
+                       //lyxerr << "Tabular fillRect C " << tx << " " << ty << " " 
+                       //              << w << " " << h << endl;
                        // clear below the inset
-                       pain.fillRectangle(
-                               nx + 1,
-                               baseline + the_locking_inset->descent(bv, font) + 1,
-                               tabular->GetWidthOfColumn(cell) -
-                               tabular->GetAdditionalWidth(cell) - 1,
-                               tabular->GetAscentOfRow(i) +
-                               tabular->GetDescentOfRow(i) -
-                               the_locking_inset->ascent(bv, font) -
-                               the_locking_inset->descent(bv, font) -
-                               TEXT_TO_INSET_OFFSET - 1,
-                               backgroundColor());
+                       tx = nx + 1;
+                       ty = baseline + the_locking_inset->descent(bv, font) + 1;
+                       w = tabular->GetWidthOfColumn(cell) -
+                               tabular->GetAdditionalWidth(cell) - 1;
+                       h = tabular->GetDescentOfRow(i) -
+                               the_locking_inset->descent(bv, font) - 1;
+                       //lyxerr << " " << tabular->GetAscentOfRow(i) << 
+                       //              " " << tabular->GetDescentOfRow(i) << 
+                       //              " - " << the_locking_inset->ascent(bv, font) 
+<< 
+                       //              " " << the_locking_inset->descent(bv, font) << 
+                       //              " " << TEXT_TO_INSET_OFFSET << endl;
+                       pain.fillRectangle(tx, ty, w, h, backgroundColor());
+                       //lyxerr << "Tabular fillRect D " << tx << " " << ty << " " 
+                       //              << w << " " << h << endl;
                }
        }
        x -= ADD_TO_TABULAR_WIDTH;

Attachment: msg30999/pgp00000.pgp
Description: PGP signature

Reply via email to