summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tkGrid.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/generic/tkGrid.c b/generic/tkGrid.c
index f5c3503..7624537 100644
--- a/generic/tkGrid.c
+++ b/generic/tkGrid.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkGrid.c,v 1.25 2002/10/10 21:07:51 pspjuth Exp $
+ * RCS: @(#) $Id: tkGrid.c,v 1.25.2.1 2004/02/18 20:10:34 pspjuth Exp $
*/
#include "tkInt.h"
@@ -1271,7 +1271,7 @@ AdjustOffsets(size, slots, slotPtr)
int diff; /* Extra pixels needed to add to the layout. */
int totalWeight = 0; /* Sum of the weights for all the slots. */
int weight = 0; /* Sum of the weights so far. */
- int minSize = 0; /* Minimum possible layout size. */
+ int minSize; /* Minimum possible layout size. */
int newDiff; /* The most pixels that can be added on
* the current pass. */
@@ -1290,7 +1290,7 @@ AdjustOffsets(size, slots, slotPtr)
* there is extra space, else clip on the bottom/right.
*/
- for (slot=0; slot < slots; slot++) {
+ for (slot = 0; slot < slots; slot++) {
totalWeight += slotPtr[slot].weight;
}
@@ -1304,7 +1304,8 @@ AdjustOffsets(size, slots, slotPtr)
*/
if (diff > 0) {
- for (weight=slot=0; slot < slots; slot++) {
+ weight = 0;
+ for (slot = 0; slot < slots; slot++) {
weight += slotPtr[slot].weight;
slotPtr[slot].offset += diff * weight / totalWeight;
}
@@ -1314,16 +1315,19 @@ AdjustOffsets(size, slots, slotPtr)
/*
* The layout must shrink below its requested size. Compute the
* minimum possible size by looking at the slot minSizes.
+ * Store each slot's minimum size in temp.
*/
- for (slot=0; slot < slots; slot++) {
+ minSize = 0;
+ for (slot = 0; slot < slots; slot++) {
if (slotPtr[slot].weight > 0) {
- minSize += slotPtr[slot].minSize;
+ slotPtr[slot].temp = slotPtr[slot].minSize;
} else if (slot > 0) {
- minSize += slotPtr[slot].offset - slotPtr[slot-1].offset;
+ slotPtr[slot].temp = slotPtr[slot].offset - slotPtr[slot-1].offset;
} else {
- minSize += slotPtr[slot].offset;
+ slotPtr[slot].temp = slotPtr[slot].offset;
}
+ minSize += slotPtr[slot].temp;
}
/*
@@ -1334,14 +1338,8 @@ AdjustOffsets(size, slots, slotPtr)
if (size <= minSize) {
int offset = 0;
- for (slot=0; slot < slots; slot++) {
- if (slotPtr[slot].weight > 0) {
- offset += slotPtr[slot].minSize;
- } else if (slot > 0) {
- offset += slotPtr[slot].offset - slotPtr[slot-1].offset;
- } else {
- offset += slotPtr[slot].offset;
- }
+ for (slot = 0; slot < slots; slot++) {
+ offset += slotPtr[slot].temp;
slotPtr[slot].offset = offset;
}
return(0);