summaryrefslogtreecommitdiffstats
path: root/library/ttk/sizegrip.tcl
diff options
context:
space:
mode:
authorhobbs <hobbs>2010-08-26 02:06:08 (GMT)
committerhobbs <hobbs>2010-08-26 02:06:08 (GMT)
commitb29adcfbfc2e03e058536524f1aa3378b948e7ed (patch)
treefa90e1e6d32590addfbb0a1599a40b1f7f99ea3b /library/ttk/sizegrip.tcl
parent7dec1714e5d5efd6b7d095657c1434fa68af0f87 (diff)
downloadtk-b29adcfbfc2e03e058536524f1aa3378b948e7ed.zip
tk-b29adcfbfc2e03e058536524f1aa3378b948e7ed.tar.gz
tk-b29adcfbfc2e03e058536524f1aa3378b948e7ed.tar.bz2
Major backport of 8.6 Ttk for 8.5.9. Most changes were only being
committed to head (8.6), although they could apply for 8.5 as well. This re-sync makes future work easier to maintain and adds some useful work for 8.5 users. Notable changes: - Lots of code cleanup - Some bug fixes never backported - Addition of ttk::spinbox - minor color changes - Improved Vista/7 styling - Move to tile version 0.8.6 (pseudo-package) - ABI and API compatible (even $w identify) - minor new features (extended $w identify)
Diffstat (limited to 'library/ttk/sizegrip.tcl')
-rw-r--r--library/ttk/sizegrip.tcl34
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)