summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpspjuth <peter.spjuth@gmail.com>2007-02-25 04:30:30 (GMT)
committerpspjuth <peter.spjuth@gmail.com>2007-02-25 04:30:30 (GMT)
commitb8d2831d91a1f2014b0bf3398b87d58e0ae5ebcf (patch)
treecd64b54644945efba1f91c85a2ea0365cb88415a
parent33432c59af4ba34defb03b255dad42030e7db41e (diff)
downloadtk-b8d2831d91a1f2014b0bf3398b87d58e0ae5ebcf.zip
tk-b8d2831d91a1f2014b0bf3398b87d58e0ae5ebcf.tar.gz
tk-b8d2831d91a1f2014b0bf3398b87d58e0ae5ebcf.tar.bz2
Fixed grid anchor center problem in labelframes. [Bug 1545765]
-rw-r--r--ChangeLog5
-rw-r--r--generic/tkUtil.c10
-rw-r--r--tests/grid.test31
3 files changed, 42 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 274c65e..3b620b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-02-25 Peter Spjuth <peter.spjuth@space.se>
+
+ * generic/tkUtil.c: Fixed grid anchor center problem in labelframes.
+ * tests/grid.test: [Bug 1545765]
+
2007-02-23 Jeff Hobbs <jeffh@ActiveState.com>
* library/ttk/notebook.tcl (ttk::notebook::enableTraversal): OS X
diff --git a/generic/tkUtil.c b/generic/tkUtil.c
index 3cf672d..05a76d2 100644
--- a/generic/tkUtil.c
+++ b/generic/tkUtil.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUtil.c,v 1.16 2007/01/19 06:29:20 das Exp $
+ * RCS: @(#) $Id: tkUtil.c,v 1.17 2007/02/25 04:30:30 pspjuth Exp $
*/
#include "tkInt.h"
@@ -796,7 +796,9 @@ TkComputeAnchor(
case TK_ANCHOR_N:
case TK_ANCHOR_CENTER:
case TK_ANCHOR_S:
- *xPtr = (Tk_Width(tkwin) - innerWidth) / 2;
+ *xPtr = (Tk_Width(tkwin) - innerWidth - Tk_InternalBorderLeft(tkwin) -
+ Tk_InternalBorderRight(tkwin)) / 2 +
+ Tk_InternalBorderLeft(tkwin);
break;
default:
@@ -815,7 +817,9 @@ TkComputeAnchor(
case TK_ANCHOR_W:
case TK_ANCHOR_CENTER:
case TK_ANCHOR_E:
- *yPtr = (Tk_Height(tkwin) - innerHeight) / 2;
+ *yPtr = (Tk_Height(tkwin) - innerHeight- Tk_InternalBorderTop(tkwin) -
+ Tk_InternalBorderBottom(tkwin)) / 2 +
+ Tk_InternalBorderTop(tkwin);
break;
default:
diff --git a/tests/grid.test b/tests/grid.test
index 0d8129a..0bdcf58 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.28 2006/04/11 21:52:20 pspjuth Exp $
+# RCS: @(#) $Id: grid.test,v 1.29 2007/02/25 04:30:31 pspjuth Exp $
package require tcltest 2.1
eval tcltest::configure $argv
@@ -1922,6 +1922,35 @@ test grid-21.6 {anchor} {
{37 50 225 150}]
grid_reset 21.6
+test grid-21.7 {anchor} {
+ # Test with a non-symmetric internal border.
+ # This only tests vertically, there is currently no way to get
+ # it assymetric horizontally.
+ labelframe .f -bd 0
+ frame .f.x -width 20 -height 20
+ .f configure -labelwidget .f.x
+ pack .f -fill both -expand 1
+
+ foreach i {0 1 2} {
+ frame .$i -bg gray -width 75 -height 50 -bd 2 -relief ridge
+ grid .$i -in .f -row $i -column $i -sticky nswe
+ }
+ pack propagate . 0
+ grid propagate .f 0
+ . configure -width 300 -height 250
+
+ set res {}
+ foreach a {n ne e se s sw w nw center} {
+ grid anchor .f $a
+ update
+ lappend res [grid bbox .f]
+ }
+ set res
+} [list {37 20 225 150} {75 20 225 150} {75 60 225 150} {75 100 225 150} \
+ {37 100 225 150} {0 100 225 150} {0 60 225 150} {0 20 225 150} \
+ {37 60 225 150}]
+grid_reset 21.7
+
# cleanup
cleanupTests
return