diff options
author | patthoyts <patthoyts@users.sourceforge.net> | 2008-04-04 14:18:30 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@users.sourceforge.net> | 2008-04-04 14:18:30 (GMT) |
commit | 71c2e7e5d1b9156ee1ca34123a863a594c730b31 (patch) | |
tree | ac50fe8f4abdc68c44b36ce7202a1f8304b4fe54 | |
parent | 4aaeef4ab3e62901320ee961372c34e4527092e7 (diff) | |
download | tk-71c2e7e5d1b9156ee1ca34123a863a594c730b31.zip tk-71c2e7e5d1b9156ee1ca34123a863a594c730b31.tar.gz tk-71c2e7e5d1b9156ee1ca34123a863a594c730b31.tar.bz2 |
Don't resize the window if the toplevel is not resizable or the sizegrip is disabled
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | library/ttk/sizegrip.tcl | 22 |
2 files changed, 24 insertions, 3 deletions
@@ -1,3 +1,8 @@ +2008-04-04 Pat Thoyts <patthoyts@users.sourceforge.net> + + * library/ttk/sizegrip.tcl: Don't resize if the toplevel is not resizable + or the sizegrip has been disabled. + 2008-04-03 Pat Thoyts <patthoyts@users.sourceforge.net> * win/makefile.vc: Fixed stubs usage diff --git a/library/ttk/sizegrip.tcl b/library/ttk/sizegrip.tcl index f1b87b1..51667dd 100644 --- a/library/ttk/sizegrip.tcl +++ b/library/ttk/sizegrip.tcl @@ -1,5 +1,5 @@ # -# $Id: sizegrip.tcl,v 1.1 2006/10/31 01:42:27 hobbs Exp $ +# $Id: sizegrip.tcl,v 1.2 2008/04/04 14:18:30 patthoyts Exp $ # # Ttk widget set -- sizegrip widget bindings. # @@ -20,6 +20,8 @@ namespace eval ttk::sizegrip { height 0 widthInc 1 heightInc 1 + resizeX 1 + resizeY 1 toplevel {} } } @@ -31,8 +33,16 @@ bind TSizegrip <ButtonRelease-1> { ttk::sizegrip::Release %W %X %Y } proc ttk::sizegrip::Press {W X Y} { variable State + if {[$W instate disabled]} { return } + set top [winfo toplevel $W] + # If the toplevel is not resizable then bail + foreach {State(resizeX) State(resizeY)} [wm resizable $top] break + if {!$State(resizeX) && !$State(resizeY)} { + return + } + # Sanity-checks: # If a negative X or Y position was specified for [wm geometry], # just bail out -- there's no way to handle this cleanly. @@ -62,8 +72,14 @@ proc ttk::sizegrip::Press {W X Y} { proc ttk::sizegrip::Drag {W X Y} { variable State if {!$State(pressed)} { return } - set w [expr {$State(width) + ($X - $State(pressX))/$State(widthInc)}] - set h [expr {$State(height) + ($Y - $State(pressY))/$State(heightInc)}] + set w $State(width) + set h $State(height) + if {$State(resizeX)} { + set w [expr {$w + ($X - $State(pressX))/$State(widthInc)}] + } + if {$State(resizeY)} { + set h [expr {$h + ($Y - $State(pressY))/$State(heightInc)}] + } if {$w <= 0} { set w 1 } if {$h <= 0} { set h 1 } wm geometry $State(toplevel) ${w}x${h} |