summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpspjuth <peter.spjuth@gmail.com>2005-04-03 15:21:47 (GMT)
committerpspjuth <peter.spjuth@gmail.com>2005-04-03 15:21:47 (GMT)
commit5f22350bce26c673b27a3020578d27f7383e18ed (patch)
tree8a08bc26118d895204f0b23b236fbc240f9a72e2
parentd68a04d73a0f026078896a5862436d5539f63a1c (diff)
downloadtk-5f22350bce26c673b27a3020578d27f7383e18ed.zip
tk-5f22350bce26c673b27a3020578d27f7383e18ed.tar.gz
tk-5f22350bce26c673b27a3020578d27f7383e18ed.tar.bz2
Fixed bug in geometry calculations for
widgets that span multiple columns/row. Bug was introduced in 8.5a1 when fixing 792387. [Bug 1175092]
-rw-r--r--ChangeLog7
-rw-r--r--generic/tkGrid.c19
-rw-r--r--tests/grid.test28
3 files changed, 46 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 639033d..2f198bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-04-03 Peter Spjuth <peter.spjuth@space.se>
+
+ * tests/grid.test:
+ * generic/tkGrid.c: Fixed bug in geometry calculations for
+ widgets that span multiple columns/row.
+ Bug was introduced in 8.5a1 when fixing 792387. [Bug 1175092]
+
2005-03-29 Jeff Hobbs <jeffh@ActiveState.com>
* win/tcl.m4, win/configure: do not require cygpath in macros to
diff --git a/generic/tkGrid.c b/generic/tkGrid.c
index 7cdbb80..8f8c33a 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.35 2005/01/11 10:35:27 dkf Exp $
+ * RCS: @(#) $Id: tkGrid.c,v 1.36 2005/04/03 15:21:48 pspjuth Exp $
*/
#include "tkInt.h"
@@ -2097,7 +2097,7 @@ ResolveConstraints(masterPtr, slotType, maxOffset)
* its range of possible values fixed at a single value.
*/
- for (start=0; start < gridCount;) {
+ for (start = 0; start < gridCount;) {
int totalWeight = 0; /* Sum of the weights for all of the
* slots in this span. */
int need = 0; /* The minimum space needed to layout
@@ -2119,7 +2119,7 @@ ResolveConstraints(masterPtr, slotType, maxOffset)
continue;
}
- for (end=start+1; end<gridCount; end++) {
+ for (end = start + 1; end < gridCount; end++) {
if (layoutPtr[end].minOffset == layoutPtr[end].maxOffset) {
break;
}
@@ -2131,7 +2131,7 @@ ResolveConstraints(masterPtr, slotType, maxOffset)
* use.
*/
- for (slot=start; slot<=end; slot++) {
+ for (slot = start; slot <= end; slot++) {
totalWeight += layoutPtr[slot].weight;
need += layoutPtr[slot].minSize;
}
@@ -2255,9 +2255,14 @@ ResolveConstraints(masterPtr, slotType, maxOffset)
* to propagate the new space allocation.
*/
- for (slot=end; slot > start; slot--) {
- layoutPtr[slot-1].maxOffset =
- layoutPtr[slot].maxOffset-layoutPtr[slot].minSize;
+ for (slot = end; slot > start; slot--) {
+ /* maxOffset may not go up */
+ if ((layoutPtr[slot].maxOffset-layoutPtr[slot].minSize)
+ < layoutPtr[slot-1].maxOffset)
+ {
+ layoutPtr[slot-1].maxOffset =
+ layoutPtr[slot].maxOffset-layoutPtr[slot].minSize;
+ }
}
}
diff --git a/tests/grid.test b/tests/grid.test
index fca981c..0428eb4 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.25 2004/11/07 22:00:12 pspjuth Exp $
+# RCS: @(#) $Id: grid.test,v 1.26 2005/04/03 15:21:49 pspjuth Exp $
package require tcltest 2.1
eval tcltest::configure $argv
@@ -1660,6 +1660,32 @@ test grid-16.17 {layout weights (shrinking at minsize)} {
} {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.17
+test grid-16.18 {layout span} {
+ frame .f1 -width 30 -height 20
+ frame .f2 -width 166 -height 20
+ frame .f3 -width 39 -height 20
+ frame .f4 -width 10 -height 20
+
+ grid .f1 .f3 -
+ grid .f2 - .f4
+ grid columnconfigure . 0 -weight 1
+
+ set res {}
+ foreach w {{1 0 0} {0 1 0} {0 0 1}} {
+ for {set c 0} {$c < 3} {incr c} {
+ grid columnconfigure . $c -weight [lindex $w $c]
+ }
+ update
+ set res2 {}
+ for {set c 0} {$c <= 2} {incr c} {
+ lappend res2 [lindex [grid bbox . $c 0] 2]
+ }
+ lappend res $res2
+ }
+ set res
+} [list [list 137 29 10] [list 30 136 10] [list 98 68 10]]
+grid_reset 16.18
+
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.