GTK tables



recently I encountered an error with GtkTable, when GTK_EXPAND or
homegenius was enabled and the cells were small and the table was large,
a roundoff error was introduced to the extra variable and thus the last
cell was bigger (by quite a LOT!) ... the solution is to recalculato the
variable "extra" each iteration tehreby reducing the error to +/- 1 pixel

here's a patch ... I hope I haven't missed anything! ... please test it
and I would like a solution to this problem in GTK since without it my
new panel implementation looks VERY strange :)


--- gtktable.c.old	Wed Jan 21 03:23:07 1998
+++ gtktable.c	Wed Jan 21 03:16:39 1998
@@ -688,10 +688,10 @@
               if (width < child->widget->requisition.width)
                 {
                   width = child->widget->requisition.width - width;
-                  extra = width / (child->right_attach - child->left_attach);
 
                   for (col = child->left_attach; col < child->right_attach; col++)
                     {
+                      extra = width / (child->right_attach - child->left_attach - col);
                       if ((col + 1) < child->right_attach)
                         table->cols[col].requisition += extra;
                       else
@@ -723,10 +723,10 @@
               if (height < child->widget->requisition.height)
                 {
                   height = child->widget->requisition.height - height;
-                  extra = height / (child->bottom_attach - child->top_attach);
 
                   for (row = child->top_attach; row < child->bottom_attach; row++)
                     {
+                      extra = height / (child->bottom_attach - child->top_attach - row);
                       if ((row + 1) < child->bottom_attach)
                         table->rows[row].requisition += extra;
                       else
@@ -941,10 +941,10 @@
           for (col = 0; col < table->ncols - 1; col++)
             width -= table->cols[col].spacing;
 
-          extra = width / table->ncols;
-
           for (col = 0; col < table->ncols; col++)
             {
+              extra = width / (table->ncols - col);
+
               if ((col + 1) == table->ncols)
                 table->cols[col].allocation = width;
               else
@@ -976,11 +976,11 @@
       if ((width < real_width) && (nexpand >= 1))
         {
           width = real_width - width;
-          extra = width / nexpand;
 
           for (col = 0; col < table->ncols; col++)
             if (table->cols[col].expand)
               {
+                extra = width / nexpand;
                 if (nexpand == 1)
                   table->cols[col].allocation += width;
                 else
@@ -996,11 +996,11 @@
       if ((width > real_width) && (nshrink >= 1))
         {
           width = width - real_width;
-          extra = width / nshrink;
 
           for (col = 0; col < table->ncols; col++)
             if (table->cols[col].shrink)
               {
+                extra = width / nshrink;
                 if (nshrink == 1)
                   table->cols[col].allocation -= width;
                 else
@@ -1029,10 +1029,10 @@
           for (row = 0; row < table->nrows - 1; row++)
             height -= table->rows[row].spacing;
 
-          extra = height / table->nrows;
 
           for (row = 0; row < table->nrows; row++)
             {
+              extra = height / (table->nrows - row);
               if ((row + 1) == table->nrows)
                 table->rows[row].allocation = height;
               else
@@ -1064,11 +1064,11 @@
       if ((height < real_height) && (nexpand >= 1))
         {
           height = real_height - height;
-          extra = height / nexpand;
 
           for (row = 0; row < table->nrows; row++)
             if (table->rows[row].expand)
               {
+                extra = height / nexpand;
                 if (nexpand == 1)
                   table->rows[row].allocation += height;
                 else
@@ -1084,11 +1084,11 @@
       if ((height > real_height) && (nshrink >= 1))
         {
           height = height - real_height;
-          extra = height / nshrink;
 
           for (row = 0; row < table->nrows; row++)
             if (table->rows[row].shrink)
               {
+                extra = height / nshrink;
                 if (nshrink == 1)
                   table->rows[row].allocation -= height;
                 else



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]