From 529054fe046640eb870bea1db3e8cbc3f8076bd7 Mon Sep 17 00:00:00 2001 From: jenglish Date: Sat, 17 Nov 2007 19:17:49 +0000 Subject: Swap in core scrollbars for [ttk::scrollbar]s on OSX. --- ChangeLog | 5 +++++ library/ttk/scrollbar.tcl | 20 +++++++++++++++++++- tests/ttk/scrollbar.test | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index afa556f..682b139 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-11-17 Joe English + + * library/ttk/scrollbar.tcl: Swap in core scrollbars for + [ttk::scrollbar]s on OSX. + 2007-11-16 Benjamin Riefenstahl * macosx/tkMacOSXFont.c (TkpMeasureCharsInContext): Correct an diff --git a/library/ttk/scrollbar.tcl b/library/ttk/scrollbar.tcl index 6b37b24..b901325 100644 --- a/library/ttk/scrollbar.tcl +++ b/library/ttk/scrollbar.tcl @@ -1,9 +1,27 @@ # -# $Id: scrollbar.tcl,v 1.1 2006/10/31 01:42:27 hobbs Exp $ +# $Id: scrollbar.tcl,v 1.2 2007/11/17 19:17:50 jenglish Exp $ # # Bindings for TScrollbar widget # +# Still don't have a working ttk::scrollbar under OSX - +# Swap in a [tk::scrollbar] on that platform, +# unless user specifies -class or -style. +# +if {[tk windowingsystem] eq "aqua"} { + rename ::ttk::scrollbar ::ttk::_scrollbar + proc ttk::scrollbar {w args} { + set constructor ::scrollbar + foreach {option _} $args { + if {$option eq "-class" || $option eq "-style"} { + set constructor ::ttk::_scrollbar + break + } + } + return [eval [linsert $args 0 $constructor $w]] + } +} + namespace eval ttk::scrollbar { variable State # State(xPress) -- diff --git a/tests/ttk/scrollbar.test b/tests/ttk/scrollbar.test index f91659a..c83fc9b 100644 --- a/tests/ttk/scrollbar.test +++ b/tests/ttk/scrollbar.test @@ -1,11 +1,42 @@ # -# $Id: scrollbar.test,v 1.1 2006/10/31 01:42:27 hobbs Exp $ +# $Id: scrollbar.test,v 1.2 2007/11/17 19:17:50 jenglish Exp $ # package require Tk 8.5 package require tcltest ; namespace import -force tcltest::* loadTestedCommands +testConstraint coreScrollbar [expr {[tk windowingsystem] eq "aqua"}] + +test scrollbar-swapout-1 "Use core scrollbars on OSX..." -constraints { + coreScrollbar +} -body { + ttk::scrollbar .sb -command "yadda" + list [winfo class .sb] [.sb cget -command] +} -result [list Scrollbar yadda] -cleanup { + destroy .sb +} + +test scrollbar-swapout-2 "... unless -style is specified ..." -constraints { + coreScrollbar +} -body { + ttk::style layout Vertical.Custom.TScrollbar \ + [ttk::style layout Vertical.TScrollbar] ; # See #1833339 + ttk::scrollbar .sb -command "yadda" -style Custom.TScrollbar + list [winfo class .sb] [.sb cget -command] [.sb cget -style] +} -result [list TScrollbar yadda Custom.TScrollbar] -cleanup { + destroy .sb +} + +test scrollbar-swapout-3 "... or -class." -constraints { + coreScrollbar +} -body { + ttk::scrollbar .sb -command "yadda" -class Custom.TScrollbar + list [winfo class .sb] [.sb cget -command] +} -result [list Custom.TScrollbar yadda] -cleanup { + destroy .sb +} + test scrollbar-1.0 "Setup" -body { ttk::scrollbar .tsb } -result .tsb -- cgit v0.12