summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--library/tkfbox.tcl85
2 files changed, 38 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index 82e94ee..299a3d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2003-02-21 Donal K. Fellows <fellowsd@cs.man.ac.uk>
+ * library/tkfbox.tcl (file::Create): This procedure was really
+ very crufty in how it went about creating the GUI. It is far
+ easier and more robust to use the grid geometry manager than it is
+ to tune the results of pack with tweaks to -width. [Bug #673722]
+
* library/comdlg.tcl (FDGetFileTypes): Set an upper limit on how
long a file type item description string can get due to appending
of types. [Bug #617392]
diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl
index c494eac..fb4a8e4 100644
--- a/library/tkfbox.tcl
+++ b/library/tkfbox.tcl
@@ -11,7 +11,7 @@
# files by clicking on the file icons or by entering a filename
# in the "Filename:" entry.
#
-# RCS: @(#) $Id: tkfbox.tcl,v 1.37 2002/07/22 21:25:39 mdejong Exp $
+# RCS: @(#) $Id: tkfbox.tcl,v 1.38 2003/02/21 14:13:26 dkf Exp $
#
# Copyright (c) 1994-1998 Sun Microsystems, Inc.
#
@@ -218,9 +218,9 @@ proc ::tk::IconList_Create {w} {
frame $w
set data(sbar) [scrollbar $w.sbar -orient horizontal \
- -highlightthickness 0 -takefocus 0]
+ -highlightthickness 0 -takefocus 0]
set data(canvas) [canvas $w.canvas -bd 2 -relief sunken \
- -width 400 -height 120 -takefocus 1]
+ -width 400 -height 120 -takefocus 1]
pack $data(sbar) -side bottom -fill x -padx 2
pack $data(canvas) -expand yes -fill both
@@ -807,11 +807,11 @@ proc ::tk::dialog::file:: {type args} {
set data(upBtn) $w.f1.up
set data(icons) $w.icons
set data(ent) $w.f2.ent
- set data(typeMenuLab) $w.f3.lab
- set data(typeMenuBtn) $w.f3.menu
+ set data(typeMenuLab) $w.f2.lab
+ set data(typeMenuBtn) $w.f2.menu
set data(typeMenu) $data(typeMenuBtn).m
set data(okBtn) $w.f2.ok
- set data(cancelBtn) $w.f3.cancel
+ set data(cancelBtn) $w.f2.cancel
::tk::dialog::file::SetSelectMode $w $data(-multiple)
}
@@ -1019,17 +1019,14 @@ static char updir_bits[] = {
#
if { [string equal $class TkFDialog] } {
if { $data(-multiple) } {
- set fNameCaption "[mc {File &names:}]"
+ set fNameCaption [mc "File &names:"]
} else {
- set fNameCaption "[mc {File &name:}]"
+ set fNameCaption [mc "File &name:"]
}
set fTypeCaption [mc "Files of &type:"]
- set fCaptionWidth [::tk::mcmaxamp $fNameCaption $fTypeCaption]
- set fCaptionWidth [expr {$fCaptionWidth<14?14:$fCaptionWidth}]
set iconListCommand [list ::tk::dialog::file::OkCmd $w]
} else {
set fNameCaption [mc "&Selection:"]
- set fCaptionWidth [string length $fNameCaption]
set iconListCommand [list ::tk::dialog::file::chooseDir::DblClick $w]
}
set data(icons) [::tk::IconList $w.icons \
@@ -1038,21 +1035,18 @@ static char updir_bits[] = {
bind $data(icons) <<ListboxSelect>> \
[list ::tk::dialog::file::ListBrowse $w]
- # f2: the frame with the OK button and the "file name" field
+ # f2: the frame with the OK button, cancel button, "file name" field
+ # and file types field.
#
set f2 [frame $w.f2 -bd 0]
- bind [::tk::AmpWidget label $f2.lab -text $fNameCaption -anchor e -width $fCaptionWidth \
- -pady 0] <<AltUnderlined>> [list focus $f2.ent]
+ bind [::tk::AmpWidget label $f2.lab -text $fNameCaption -anchor e -pady 0]\
+ <<AltUnderlined>> [list focus $f2.ent]
set data(ent) [entry $f2.ent]
# The font to use for the icons. The default Canvas font on Unix
# is just deviant.
set ::tk::$w.icons(font) [$data(ent) cget -font]
- # f3: the frame with the cancel button and the file types field
- #
- set f3 [frame $w.f3 -bd 0]
-
# Make the file types bits only if this is a File Dialog
if { [string equal $class TkFDialog] } {
# The "File of types:" label needs to be grayed-out when
@@ -1060,50 +1054,47 @@ static char updir_bits[] = {
# grayed-out text on monochrome displays. Therefore, we have to
# use a button widget to emulate a label widget (by setting its
# bindtags)
-
- set data(typeMenuLab) [::tk::AmpWidget button $f3.lab -text $fTypeCaption \
- -anchor e -width $fCaptionWidth \
- -bd [$f2.lab cget -bd] \
+
+ set data(typeMenuLab) [::tk::AmpWidget button $f2.lab2 \
+ -text $fTypeCaption -anchor e -bd [$f2.lab cget -bd] \
-highlightthickness [$f2.lab cget -highlightthickness] \
-relief [$f2.lab cget -relief] \
-padx [$f2.lab cget -padx] \
-pady [$f2.lab cget -pady]]
bindtags $data(typeMenuLab) [list $data(typeMenuLab) Label \
[winfo toplevel $data(typeMenuLab)] all]
- set data(typeMenuBtn) [menubutton $f3.menu -indicatoron 1 \
- -menu $f3.menu.m]
+ set data(typeMenuBtn) [menubutton $f2.menu -indicatoron 1 \
+ -menu $f2.menu.m]
set data(typeMenu) [menu $data(typeMenuBtn).m -tearoff 0]
$data(typeMenuBtn) config -takefocus 1 -highlightthickness 2 \
-relief raised -bd 2 -anchor w
- bind $data(typeMenuLab) <<AltUnderlined>> [list focus \
- $data(typeMenuBtn)]
+ bind $data(typeMenuLab) <<AltUnderlined>> [list \
+ focus $data(typeMenuBtn)]
}
# the okBtn is created after the typeMenu so that the keyboard traversal
# is in the right order
- set maxWidth [::tk::mcmaxamp &OK &Cancel]
- set maxWidth [expr {$maxWidth<6?6:$maxWidth}]
- set data(okBtn) [::tk::AmpWidget button $f2.ok -text "[mc "&OK"]" \
- -width $maxWidth -default active -pady 3]
- set data(cancelBtn) [::tk::AmpWidget button $f3.cancel -text "[mc "&Cancel"]" \
- -width $maxWidth -default normal -pady 3]
-
- # pack the widgets in f2 and f3
+ set data(okBtn) [::tk::AmpWidget button $f2.ok \
+ -text "[mc "&OK"]" -default active -pady 3]
+ set data(cancelBtn) [::tk::AmpWidget button $f2.cancel \
+ -text "[mc "&Cancel"]" -default normal -pady 3]
+
+ # grid the widgets in f2
#
- pack $data(okBtn) -side right -padx 4 -anchor e
- pack $f2.lab -side left -padx 4
- pack $f2.ent -expand yes -fill x -padx 2 -pady 0
-
- pack $data(cancelBtn) -side right -padx 4 -anchor w
+ grid $f2.lab $f2.ent $data(okBtn) -padx 4 -sticky ew
+ grid configure $f2.ent -padx 2
if { [string equal $class TkFDialog] } {
- pack $data(typeMenuLab) -side left -padx 4
- pack $data(typeMenuBtn) -expand yes -fill x -side right
+ grid $data(typeMenuLab) $data(typeMenuBtn) $data(cancelBtn) \
+ -padx 4 -sticky ew
+ grid configure $data(typeMenuBtn) -padx 0
+ } else {
+ grid x x $data(cancelBtn) -padx 4 -sticky ew
}
+ grid columnconfigure $f2 1 -weight 1
# Pack all the frames together. We are done with widget construction.
#
pack $f1 -side top -fill x -pady 4
- pack $f3 -side bottom -fill x
pack $f2 -side bottom -fill x
pack $data(icons) -expand yes -fill both -padx 4 -pady 1
@@ -1313,18 +1304,8 @@ rSASvJTGhnhcV3EJlo3kh53ltF5nAhQAOw==}]
#
if {[string equal $data(type) open]} {
::tk::SetAmpText $data(okBtn) [mc "&Open"]
- set maxWidth [::tk::mcmaxamp [mc "&Open"]]
- if {$maxWidth>[$data(okBtn) cget -width]} {
- $data(okBtn) config -width $maxWidth
- $data(cancelBtn) config -width $maxWidth
- }
} else {
::tk::SetAmpText $data(okBtn) [mc "&Save"]
- set maxWidth [::tk::mcmaxamp [mc "&Save"]]
- if {$maxWidth>[$data(okBtn) cget -width]} {
- $data(okBtn) config -width $maxWidth
- $data(cancelBtn) config -width $maxWidth
- }
}
}