summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--generic/tkGrid.c30
-rw-r--r--tests/grid.test28
3 files changed, 46 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 67ef7cc..8d4aa50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-02-18 Peter Spjuth <peter.spjuth@space.se>
+
+ * tests/grid.test:
+ * generic/tkGrid.c: Fixed a bug in grid geometry calculations for
+ a shrinking grid. [Bug 899246]
+
2004-02-17 Jeff Hobbs <jeffh@ActiveState.com>
*** 8.4.6 TAGGED FOR RELEASE ***
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);
diff --git a/tests/grid.test b/tests/grid.test
index c47348e..50064e3 100644
--- a/tests/grid.test
+++ b/tests/grid.test
@@ -5,7 +5,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: grid.test,v 1.17 2002/10/10 21:07:52 pspjuth Exp $
+# RCS: @(#) $Id: grid.test,v 1.17.2.1 2004/02/18 20:10:34 pspjuth Exp $
package require tcltest 2.1
namespace import -force tcltest::configure
@@ -1305,7 +1305,7 @@ test grid-16.7 {layout weights (shrinking at minsize)} {
lappend a [winfo width .$i]-[winfo height .$i]-[winfo ismapped .$i]
}
set a
-} {100-75-1 1-1-0 200-150-1}
+} {100-75-1 1-1-0 100-75-1}
grid_reset 16.7
test grid-16.8 {layout internal constraints} {
@@ -1426,6 +1426,30 @@ test grid-16.12 {layout uniform (grow)} {
{0 0 70 95} {70 0 50 95} {120 0 140 95} {260 0 90 95}]
grid_reset 16.12
+test grid-16.13 {layout weights (shrinking at minsize)} {
+ foreach i {0 1 2 3} {
+ frame .$i -bg gray -width 100 -height 75 -bd 2 -relief ridge
+ grid .$i -row $i -column $i -sticky nswe
+ }
+ grid propagate . 0
+ grid columnconfigure . {0 1} -weight 1 -minsize 0
+ grid rowconfigure . {0 1} -weight 1 -minsize 0
+ set a ""
+ . configure -width 250 -height 200
+ update
+ foreach i {0 1 2 3} {
+ lappend a [winfo width .$i]-[winfo height .$i]-[winfo ismapped .$i]
+ }
+ . configure -width 150 -height 100
+ update
+ foreach i {0 1 2 3} {
+ lappend a [winfo width .$i]-[winfo height .$i]-[winfo ismapped .$i]
+ }
+ set a
+} {25-25-1 25-25-1 100-75-1 100-75-1 25-25-0 25-25-0 100-75-1 100-75-1}
+grid_reset 16.13
+
+
test grid-17.1 {forget and pending idle handlers} {
# This test is intended to detect a crash caused by a failure to remove
# pending idle handlers when grid forget is invoked.