diff options
author | patthoyts <patthoyts@users.sourceforge.net> | 2008-11-29 00:43:48 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@users.sourceforge.net> | 2008-11-29 00:43:48 (GMT) |
commit | 216f96d49a15f71cc5fd40aed613bcfb4f0f002a (patch) | |
tree | 14934e60d875010bb861e877bc9baf31a36ab9fa /library | |
parent | 7b99e201991548b8e0a661f0394233253c776ddd (diff) | |
download | tk-216f96d49a15f71cc5fd40aed613bcfb4f0f002a.zip tk-216f96d49a15f71cc5fd40aed613bcfb4f0f002a.tar.gz tk-216f96d49a15f71cc5fd40aed613bcfb4f0f002a.tar.bz2 |
Use a styled frame around the popdown listbox so we can adjust the border for each theme as needed.
Diffstat (limited to 'library')
-rw-r--r-- | library/ttk/altTheme.tcl | 4 | ||||
-rw-r--r-- | library/ttk/clamTheme.tcl | 4 | ||||
-rw-r--r-- | library/ttk/classicTheme.tcl | 4 | ||||
-rw-r--r-- | library/ttk/combobox.tcl | 25 | ||||
-rw-r--r-- | library/ttk/defaults.tcl | 9 | ||||
-rw-r--r-- | library/ttk/winTheme.tcl | 6 | ||||
-rw-r--r-- | library/ttk/xpTheme.tcl | 13 |
7 files changed, 51 insertions, 14 deletions
diff --git a/library/ttk/altTheme.tcl b/library/ttk/altTheme.tcl index 0a4ce05..20f6c53 100644 --- a/library/ttk/altTheme.tcl +++ b/library/ttk/altTheme.tcl @@ -1,5 +1,5 @@ # -# $Id: altTheme.tcl,v 1.8 2008/11/01 15:34:24 patthoyts Exp $ +# $Id: altTheme.tcl,v 1.9 2008/11/29 00:43:48 patthoyts Exp $ # # Ttk widget set: Alternate theme # @@ -59,6 +59,8 @@ namespace eval ttk::theme::alt { ttk::style configure TCombobox -padding 1 ttk::style map TCombobox -fieldbackground \ [list readonly $colors(-frame) disabled $colors(-frame)] + ttk::style configure ComboboxPopdownFrame \ + -relief solid -borderwidth 1 ttk::style configure TSpinbox -arrowsize 10 -padding {2 0 10 0} ttk::style map TSpinbox -fieldbackground \ diff --git a/library/ttk/clamTheme.tcl b/library/ttk/clamTheme.tcl index 8498f1e..1a07e3a 100644 --- a/library/ttk/clamTheme.tcl +++ b/library/ttk/clamTheme.tcl @@ -1,5 +1,5 @@ # -# $Id: clamTheme.tcl,v 1.8 2008/11/01 15:34:24 patthoyts Exp $ +# $Id: clamTheme.tcl,v 1.9 2008/11/29 00:43:48 patthoyts Exp $ # # "Clam" theme. # @@ -105,6 +105,8 @@ namespace eval ttk::theme::clam { readonly $colors(-frame)] \ -foreground [list {readonly focus} $colors(-selectfg)] \ ; + ttk::style configure ComboboxPopdownFrame \ + -relief solid -borderwidth 1 ttk::style configure TSpinbox -arrowsize 10 -padding {2 0 10 0} ttk::style map TSpinbox \ diff --git a/library/ttk/classicTheme.tcl b/library/ttk/classicTheme.tcl index 72473df..fd2b280 100644 --- a/library/ttk/classicTheme.tcl +++ b/library/ttk/classicTheme.tcl @@ -1,5 +1,5 @@ # -# $Id: classicTheme.tcl,v 1.8 2008/11/01 15:34:24 patthoyts Exp $ +# $Id: classicTheme.tcl,v 1.9 2008/11/29 00:43:48 patthoyts Exp $ # # "classic" Tk theme. # @@ -70,6 +70,8 @@ namespace eval ttk::theme::classic { ttk::style configure TCombobox -padding 1 ttk::style map TCombobox -fieldbackground \ [list readonly $colors(-frame) disabled $colors(-frame)] + ttk::style configure ComboboxPopdownFrame \ + -relief solid -borderwidth 1 ttk::style configure TSpinbox -arrowsize 10 -padding {2 0 10 0} ttk::style map TSpinbox -fieldbackground \ diff --git a/library/ttk/combobox.tcl b/library/ttk/combobox.tcl index 5094300..581c227 100644 --- a/library/ttk/combobox.tcl +++ b/library/ttk/combobox.tcl @@ -1,5 +1,5 @@ # -# $Id: combobox.tcl,v 1.15 2008/11/22 22:07:34 patthoyts Exp $ +# $Id: combobox.tcl,v 1.16 2008/11/29 00:43:48 patthoyts Exp $ # # Combobox bindings. # @@ -61,6 +61,8 @@ bind TCombobox <Double-ButtonPress-1> { ttk::combobox::Press "2" %W %x %y } bind TCombobox <Triple-ButtonPress-1> { ttk::combobox::Press "3" %W %x %y } bind TCombobox <B1-Motion> { ttk::combobox::Drag %W %x } bind TCombobox <Motion> { ttk::combobox::Motion %W %x %y } +bind TCombobox <Enter> {%W instate !disabled {%W state active}} +bind TCombobox <Leave> {%W state !active} bind TCombobox <MouseWheel> { ttk::combobox::Scroll %W [expr {%D/-120}] } if {[tk windowingsystem] eq "x11"} { @@ -279,7 +281,9 @@ proc ttk::combobox::PopdownWindow {cb} { variable scrollbar if {![winfo exists $cb.popdown]} { - set popdown [PopdownToplevel $cb.popdown] + set poplevel [PopdownToplevel $cb.popdown] + + set popdown [ttk::frame $poplevel.f -style ComboboxPopdownFrame] $scrollbar $popdown.sb \ -orient vertical -command [list $popdown.l yview] @@ -294,9 +298,14 @@ proc ttk::combobox::PopdownWindow {cb} { bindtags $popdown.l \ [list $popdown.l ComboboxListbox Listbox $popdown all] - grid $popdown.l $popdown.sb -sticky news + grid $popdown.l -row 0 -column 0 -padx {1 0} -pady 1 -sticky nsew + grid $popdown.sb -row 0 -column 1 -padx {0 1} -pady 1 -sticky ns grid columnconfigure $popdown 0 -weight 1 grid rowconfigure $popdown 0 -weight 1 + + grid $popdown -sticky news -padx 0 -pady 0 + grid rowconfigure $poplevel 0 -weight 1 + grid columnconfigure $poplevel 0 -weight 1 } return $cb.popdown } @@ -311,11 +320,11 @@ proc ttk::combobox::PopdownToplevel {w} { switch -- [tk windowingsystem] { default - x11 { - $w configure -relief solid -borderwidth 1 + $w configure -relief flat -borderwidth 0 wm overrideredirect $w true } win32 { - $w configure -relief solid -borderwidth 1 + $w configure -relief flat -borderwidth 0 wm overrideredirect $w true } aqua { @@ -335,7 +344,7 @@ proc ttk::combobox::PopdownToplevel {w} { proc ttk::combobox::ConfigureListbox {cb} { variable Values - set popdown [PopdownWindow $cb] + set popdown [PopdownWindow $cb].f set values [$cb cget -values] set current [$cb current] if {$current < 0} { @@ -350,8 +359,10 @@ proc ttk::combobox::ConfigureListbox {cb} { if {$height > [$cb cget -height]} { set height [$cb cget -height] grid $popdown.sb + grid configure $popdown.l -padx {1 0} } else { grid remove $popdown.sb + grid configure $popdown.l -padx 1 } $popdown.l configure -height $height } @@ -424,7 +435,7 @@ proc ttk::combobox::Unpost {cb} { # Return the combobox main widget that owns the listbox. # proc ttk::combobox::LBMaster {lb} { - winfo parent [winfo parent $lb] + winfo parent [winfo parent [winfo parent $lb]] } ## LBSelect $lb -- diff --git a/library/ttk/defaults.tcl b/library/ttk/defaults.tcl index 98185ee5..52a9d33 100644 --- a/library/ttk/defaults.tcl +++ b/library/ttk/defaults.tcl @@ -1,5 +1,5 @@ # -# $Id: defaults.tcl,v 1.8 2008/11/01 15:34:24 patthoyts Exp $ +# $Id: defaults.tcl,v 1.9 2008/11/29 00:43:48 patthoyts Exp $ # # Settings for default theme. # @@ -99,6 +99,13 @@ namespace eval ttk::theme::default { -background [list selected $colors(-selectbg)] \ -foreground [list selected $colors(-selectfg)] ; + # Combobox popdown frame + ttk::style layout ComboboxPopdownFrame { + ComboboxPopdownFrame.border -sticky nswe + } + ttk::style configure ComboboxPopdownFrame \ + -borderwidth 1 -relief solid + # # Toolbar buttons: # diff --git a/library/ttk/winTheme.tcl b/library/ttk/winTheme.tcl index c27c45a..7ee19f5 100644 --- a/library/ttk/winTheme.tcl +++ b/library/ttk/winTheme.tcl @@ -1,5 +1,5 @@ # -# $Id: winTheme.tcl,v 1.8 2008/11/01 15:34:24 patthoyts Exp $ +# $Id: winTheme.tcl,v 1.9 2008/11/29 00:43:48 patthoyts Exp $ # # Settings for 'winnative' theme. # @@ -45,6 +45,10 @@ namespace eval ttk::theme::winnative { -focusfill [list {readonly focus} SystemHighlight] \ ; + ttk::style element create ComboboxPopdownFrame.border from default + ttk::style configure ComboboxPopdownFrame \ + -borderwidth 1 -relief solid + ttk::style configure TSpinbox -padding {2 0 16 0} ttk::style configure TLabelframe -borderwidth 2 -relief groove diff --git a/library/ttk/xpTheme.tcl b/library/ttk/xpTheme.tcl index c204233..07df1d9 100644 --- a/library/ttk/xpTheme.tcl +++ b/library/ttk/xpTheme.tcl @@ -1,5 +1,5 @@ # -# $Id: xpTheme.tcl,v 1.10 2008/11/01 15:34:24 patthoyts Exp $ +# $Id: xpTheme.tcl,v 1.11 2008/11/29 00:43:48 patthoyts Exp $ # # Settings for 'xpnative' theme # @@ -70,9 +70,11 @@ namespace eval ttk::theme::xpnative { COMBOBOX 2 {{} 1} ttk::style element create Combobox.border vsapi \ COMBOBOX 4 {disabled 4 focus 3 active 2 {} 1} + ttk::style element create Combobox.rightdownarrow vsapi \ + COMBOBOX 6 {disabled 4 pressed 3 active 2 {} 1} ttk::style layout TCombobox { Combobox.border -sticky nswe -border 0 -children { - Combobox.downarrow -side right -sticky ns + Combobox.rightdownarrow -side right -sticky ns Combobox.padding -expand 1 -sticky nswe -children { Combobox.focus -expand 1 -sticky nswe -children { Combobox.textarea -sticky nswe @@ -80,6 +82,13 @@ namespace eval ttk::theme::xpnative { } } } + ttk::style element create ComboboxPopdownFrame.background vsapi\ + COMBOBOX 2 + ttk::style layout ComboboxPopdownFrame { + ComboboxPopdownFrame.background -sticky news -border 1 -children { + ComboboxPopdownFrame.padding -sticky news + } + } # EDIT EP_EDITBORDER_HVSCROLL ttk::style configure TSpinbox -padding {2 0 15 1} |