diff options
Diffstat (limited to 'library/ttk/sizegrip.tcl')
-rw-r--r-- | library/ttk/sizegrip.tcl | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/library/ttk/sizegrip.tcl b/library/ttk/sizegrip.tcl index f167b00..1b9119b 100644 --- a/library/ttk/sizegrip.tcl +++ b/library/ttk/sizegrip.tcl @@ -1,14 +1,22 @@ # -# $Id: sizegrip.tcl,v 1.1.4.1 2009/12/23 04:30:51 jenglish Exp $ +# $Id: sizegrip.tcl,v 1.1.4.2 2010/08/26 02:06:10 hobbs Exp $ # -# Ttk widget set -- sizegrip widget bindings. +# Sizegrip widget bindings. # # Dragging a sizegrip widget resizes the containing toplevel. # # NOTE: the sizegrip widget must be in the lower right hand corner. # -option add *TSizegrip.cursor $::ttk::Cursors(seresize) +switch -- [tk windowingsystem] { + x11 - + win32 { + option add *TSizegrip.cursor [ttk::cursor seresize] + } + aqua { + # Aqua sizegrips use default Arrow cursor. + } +} namespace eval ttk::sizegrip { variable State @@ -20,6 +28,8 @@ namespace eval ttk::sizegrip { height 0 widthInc 1 heightInc 1 + resizeX 1 + resizeY 1 toplevel {} } } @@ -31,8 +41,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. @@ -64,8 +82,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 } set x $State(x) ; set y $State(y) |