From 046353d490342a66945758497b9f7a8b4c93bdf5 Mon Sep 17 00:00:00 2001 From: patthoyts Date: Mon, 4 Jan 2010 20:01:06 +0000 Subject: Fix the default size of the font chooser and set minimum size --- ChangeLog | 2 ++ library/fontchooser.tcl | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 94946a0..0df44f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2010-01-04 Pat Thoyts + * library/fontchooser.tcl: [Bug 2727476] Fix default size of font + chooser dialog and assigned minimum sizes for the lists. * library/console.tcl: [Bug 580361] Fix console <> binding. * library/console.tcl: Fix keyboard access to console menu. * library/demos/filebox.tcl: Make prettier using ttk. diff --git a/library/fontchooser.tcl b/library/fontchooser.tcl index 2998969..45cb402 100644 --- a/library/fontchooser.tcl +++ b/library/fontchooser.tcl @@ -8,7 +8,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: fontchooser.tcl,v 1.2 2008/12/10 13:41:19 patthoyts Exp $ +# RCS: @(#) $Id: fontchooser.tcl,v 1.3 2010/01/04 20:01:06 patthoyts Exp $ namespace eval ::tk::fontchooser { variable S @@ -136,16 +136,17 @@ proc ::tk::fontchooser::Create {} { wm withdraw $S(W) wm title $S(W) $S(-title) wm transient $S(W) [winfo toplevel $S(-parent)] - wm geometry $S(W) 430x316 set outer [::ttk::frame $S(W).outer -padding {10 10}] ::tk::AmpWidget ::ttk::label $S(W).font -text [::msgcat::mc "&Font:"] ::tk::AmpWidget ::ttk::label $S(W).style -text [::msgcat::mc "Font st&yle:"] ::tk::AmpWidget ::ttk::label $S(W).size -text [::msgcat::mc "&Size:"] - ttk::entry $S(W).efont -textvariable [namespace which -variable S](font) - ttk::entry $S(W).estyle -textvariable [namespace which -variable S](style) + ttk::entry $S(W).efont -width 18 \ + -textvariable [namespace which -variable S](font) + ttk::entry $S(W).estyle -width 10 \ + -textvariable [namespace which -variable S](style) ttk::entry $S(W).esize -textvariable [namespace which -variable S](size) \ - -width 0 -validate key -validatecommand {string is double %P} + -width 3 -validate key -validatecommand {string is double %P} ttk_slistbox $S(W).lfonts -height 7 -exportselection 0 \ -selectmode browse -activestyle none \ @@ -153,9 +154,9 @@ proc ::tk::fontchooser::Create {} { ttk_slistbox $S(W).lstyles -width 5 -height 7 -exportselection 0 \ -selectmode browse -activestyle none \ -listvariable [namespace which -variable S](styles) - ttk_slistbox $S(W).lsizes -width 6 -height 7 -exportselection 0 \ + ttk_slistbox $S(W).lsizes -width 4 -height 7 -exportselection 0 \ -selectmode browse -activestyle none \ - -listvariable [namespace which -variable S](sizes) \ + -listvariable [namespace which -variable S](sizes) set WE $S(W).effects ::ttk::labelframe $WE -text [::msgcat::mc "Effects"] @@ -177,6 +178,22 @@ proc ::tk::fontchooser::Create {} { -command [namespace code [list Apply]] wm protocol $S(W) WM_DELETE_WINDOW [namespace code [list Done 0]] + # Calculate minimum sizes + ttk::scrollbar $S(W).tmpvs + set scroll_width [winfo reqwidth $S(W).tmpvs] + destroy $S(W).tmpvs + set minsize(gap) 10 + set minsize(bbox) [winfo reqwidth $S(W).ok] + set minsize(fonts) \ + [expr {[font measure TkDefaultFont "Helvetica"] + $scroll_width}] + set minsize(styles) \ + [expr {[font measure TkDefaultFont "Bold Italic"] + $scroll_width}] + set minsize(sizes) \ + [expr {[font measure TkDefaultFont "-99"] + $scroll_width}] + set min [expr {$minsize(gap) * 4}] + foreach {what width} [array get minsize] { incr min $width } + wm minsize $S(W) $min 260 + bind $S(W) [namespace code [list Done 1]] bind $S(W) [namespace code [list Done 0]] bind $S(W) [namespace code [list Visibility %W 1]] @@ -198,7 +215,7 @@ proc ::tk::fontchooser::Create {} { ::ttk::label $WS.sample -relief sunken -anchor center \ -textvariable [namespace which -variable S](sampletext) set S(sample) $WS.sample - grid $WS.sample -sticky news -padx 8 -pady 6 + grid $WS.sample -sticky news -padx 6 -pady 4 grid rowconfigure $WS 0 -weight 1 grid columnconfigure $WS 0 -weight 1 grid propagate $WS 0 @@ -219,8 +236,12 @@ proc ::tk::fontchooser::Create {} { grid $S(W).lfonts x $S(W).lstyles x $S(W).lsizes x ^ -in $outer -sticky news grid $WE x $WS - - x ^ -in $outer -sticky news -pady {15 30} grid configure $bbox -sticky n - grid columnconfigure $outer {1 3 5} -minsize 10 + grid columnconfigure $outer {1 3 5} -minsize $minsize(gap) grid columnconfigure $outer {0 2 4} -weight 1 + grid columnconfigure $outer 0 -minsize $minsize(fonts) + grid columnconfigure $outer 2 -minsize $minsize(styles) + grid columnconfigure $outer 4 -minsize $minsize(sizes) + grid columnconfigure $outer 6 -minsize $minsize(bbox) grid $outer -sticky news grid rowconfigure $S(W) 0 -weight 1 -- cgit v0.12