summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--library/demos/ixset137
-rw-r--r--library/demos/rolodex78
3 files changed, 128 insertions, 96 deletions
diff --git a/ChangeLog b/ChangeLog
index 9491f0b..5474c0e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2001-10-30 Donal K. Fellows <fellowsd@cs.man.ac.uk>
+
+ * library/demos/rolodex: Changes up-ported from core-8-3-1-branch
+ to make the script use more 8.*-isms, but not menus due to the way
+ the context help system works.
+
+ * library/demos/ixset: Changed to use the labelframe widget and
+ the grid geometry manager.
+
2001-10-29 Donal K. Fellows <fellowsd@cs.man.ac.uk>
* library/demos/browse: Changes up-ported from core-8-3-1-branch
diff --git a/library/demos/ixset b/library/demos/ixset
index c5bcfd3..8e6df3d 100644
--- a/library/demos/ixset
+++ b/library/demos/ixset
@@ -1,6 +1,6 @@
#!/bin/sh
# the next line restarts using wish \
-exec wish "$0" "$@"
+exec wish8.4 "$0" ${1+"$@"} || exec wish "$0" ${1+"$@"}
# ixset --
# A nice interface to "xset" to change X server settings
@@ -9,7 +9,7 @@ exec wish "$0" "$@"
# 91/11/23 : pda@masi.ibp.fr, jt@ratp.fr : design
# 92/08/01 : pda@masi.ibp.fr : cleaning
#
-# RCS: @(#) $Id: ixset,v 1.2 1998/09/14 18:23:29 stanton Exp $
+# RCS: @(#) $Id: ixset,v 1.3 2001/10/30 10:17:07 dkf Exp $
#
# Button actions
@@ -27,10 +27,15 @@ proc ok {} {
proc cancel {} {
readsettings
dispsettings
+ .buttons.apply configure -state disabled
+ .buttons.cancel configure -state disabled
}
-# apply is just "writesettings"
-
+proc apply {} {
+ writesettings
+ .buttons.apply configure -state disabled
+ .buttons.cancel configure -state disabled
+}
#
# Read current settings
@@ -120,8 +125,8 @@ proc writesettings {} {
set mouseacc [.mouse.hor.acc.entry get]
set mousethr [.mouse.hor.thr.entry get]
- set screentim [.screen.val.le.tim.entry get]
- set screencyc [.screen.val.le.cyc.entry get]
+ set screentim [.screen.tim.entry get]
+ set screencyc [.screen.cyc.entry get]
exec xset \
b $bellvol $bellpit $belldur \
@@ -155,12 +160,12 @@ proc dispsettings {} {
.mouse.hor.thr.entry delete 0 end
.mouse.hor.thr.entry insert 0 $mousethr
- .screen.val.rb.blank [expr "{$screenbla}=={blank} ? {select} : {deselect}"]
- .screen.val.rb.pat [expr "{$screenbla}!={blank} ? {select} : {deselect}"]
- .screen.val.le.tim.entry delete 0 end
- .screen.val.le.tim.entry insert 0 $screentim
- .screen.val.le.cyc.entry delete 0 end
- .screen.val.le.cyc.entry insert 0 $screencyc
+ .screen.blank [expr "{$screenbla}=={blank} ? {select} : {deselect}"]
+ .screen.pat [expr "{$screenbla}!={blank} ? {select} : {deselect}"]
+ .screen.tim.entry delete 0 end
+ .screen.tim.entry insert 0 $screentim
+ .screen.cyc.entry delete 0 end
+ .screen.cyc.entry insert 0 $screencyc
}
@@ -168,12 +173,17 @@ proc dispsettings {} {
# Create all windows, and pack them
#
-proc labelentry {path text length} {
+proc labelentry {path text length {range {}}} {
frame $path
label $path.label -text $text
- entry $path.entry -width $length -relief sunken
- pack $path.label -side left -expand y
- pack $path.entry -side right -expand y
+ if {[llength $range]} {
+ spinbox $path.entry -width $length -relief sunken \
+ -from [lindex $range 0] -to [lindex $range 1]
+ } else {
+ entry $path.entry -width $length -relief sunken
+ }
+ pack $path.label -side left
+ pack $path.entry -side right -expand y -fill x
}
proc createwindows {} {
@@ -182,38 +192,57 @@ proc createwindows {} {
#
frame .buttons
- button .buttons.ok -command "ok" -text "Ok"
- button .buttons.apply -command "writesettings" -text "Apply"
- button .buttons.cancel -command "cancel" -text "Cancel"
- button .buttons.quit -command "quit" -text "Quit"
+ button .buttons.ok -default active -command ok -text "Ok"
+ button .buttons.apply -default normal -command apply -text "Apply" \
+ -state disabled
+ button .buttons.cancel -default normal -command cancel -text "Cancel" \
+ -state disabled
+ button .buttons.quit -default normal -command quit -text "Quit"
pack .buttons.ok .buttons.apply .buttons.cancel .buttons.quit \
-side left -expand yes -pady 5
+ bind . <Return> {.buttons.ok flash; .buttons.ok invoke}
+ bind . <Escape> {.buttons.quit flash; .buttons.quit invoke}
+ bind . <1> {
+ if {![string match .buttons* %W]} {
+ .buttons.apply configure -state normal
+ .buttons.cancel configure -state normal
+ }
+ }
+ bind . <Key> {
+ if {![string match .buttons* %W]} {
+ switch -glob %K {
+ Return - Escape - Tab - *Shift* {}
+ default {
+ .buttons.apply configure -state normal
+ .buttons.cancel configure -state normal
+ }
+ }
+ }
+ }
+
#
# Bell settings
#
- frame .bell -relief raised -borderwidth 2
- label .bell.label -text "Bell Settings"
+ labelframe .bell -text "Bell Settings" -padx 1.5m -pady 1.5m
scale .bell.vol \
-from 0 -to 100 -length 200 -tickinterval 20 \
-label "Volume (%)" -orient horizontal
frame .bell.val
- labelentry .bell.val.pit "Pitch (Hz)" 6
- labelentry .bell.val.dur "Duration (ms)" 6
+ labelentry .bell.val.pit "Pitch (Hz)" 6 {25 20000}
+ labelentry .bell.val.dur "Duration (ms)" 6 {1 10000}
pack .bell.val.pit -side left -padx 5
pack .bell.val.dur -side right -padx 5
- pack .bell.label .bell.vol .bell.val -side top -expand yes
+ pack .bell.vol .bell.val -side top -expand yes
#
# Keyboard settings
#
- frame .kbd -relief raised -borderwidth 2
-
- label .kbd.label -text "Keyboard Repeat Settings"
+ labelframe .kbd -text "Keyboard Repeat Settings" -padx 1.5m -pady 1.5m
frame .kbd.val
checkbutton .kbd.val.onoff \
@@ -223,62 +252,52 @@ proc createwindows {} {
scale .kbd.val.cli \
-from 0 -to 100 -length 200 -tickinterval 20 \
-label "Click Volume (%)" -orient horizontal
- pack .kbd.val.onoff -side left -expand yes -fill both
- pack .kbd.val.cli -side left -expand yes
+ pack .kbd.val.onoff -side left -fill x -expand yes -padx {0 1m}
+ pack .kbd.val.cli -side left -expand yes -fill x -padx {1m 0}
- pack .kbd.label -side top -expand yes
pack .kbd.val -side top -expand yes -pady 2 -fill x
#
# Mouse settings
#
- frame .mouse -relief raised -borderwidth 2
+ labelframe .mouse -text "Mouse Settings" -padx 1.5m -pady 1.5m
- label .mouse.label -text "Mouse Settings"
frame .mouse.hor
- labelentry .mouse.hor.acc "Acceleration" 3
- labelentry .mouse.hor.thr "Threshold (pixels)" 3
+ labelentry .mouse.hor.acc "Acceleration" 5
+ labelentry .mouse.hor.thr "Threshold (pixels)" 3 {1 2000}
- pack .mouse.hor.acc -side left
- pack .mouse.hor.thr -side right
+ pack .mouse.hor.acc -side left -padx {0 1m}
+ pack .mouse.hor.thr -side right -padx {1m 0}
- pack .mouse.label -side top
pack .mouse.hor -side top -expand yes
#
# Screen Saver settings
#
- frame .screen -relief raised -borderwidth 2
+ labelframe .screen -text "Screen-saver Settings" -padx 1.5m -pady 1.5m
- label .screen.label -text "Screen-saver Settings"
- frame .screen.val
-
- frame .screen.val.rb
- radiobutton .screen.val.rb.blank \
+ radiobutton .screen.blank \
-variable screenblank -text "Blank" -relief flat \
- -value "blank" -variable screenbla
- radiobutton .screen.val.rb.pat \
+ -value "blank" -variable screenbla -anchor w
+ radiobutton .screen.pat \
-variable screenblank -text "Pattern" -relief flat \
- -value "noblank" -variable screenbla
- pack .screen.val.rb.blank .screen.val.rb.pat -side top -pady 2 -anchor w
- frame .screen.val.le
- labelentry .screen.val.le.tim "Timeout (s)" 5
- labelentry .screen.val.le.cyc "Cycle (s)" 5
- pack .screen.val.le.tim .screen.val.le.cyc -side top -pady 2 -anchor e
-
- pack .screen.val.rb .screen.val.le -side left
+ -value "noblank" -variable screenbla -anchor w
+ labelentry .screen.tim "Timeout (s)" 5 {1 100000}
+ labelentry .screen.cyc "Cycle (s)" 5 {1 100000}
- pack .screen.label -side top
- pack .screen.val -side top -expand y
+ grid .screen.blank .screen.tim -sticky e
+ grid .screen.pat .screen.cyc -sticky e
+ grid configure .screen.blank .screen.pat -sticky ew
#
# Main window
#
pack .buttons -side top -fill both
- pack .bell .kbd .mouse .screen -side top -fill both -ipady 5 -expand yes
+ pack .bell .kbd .mouse .screen -side top -fill both -expand yes \
+ -padx 1m -pady 1m
#
# Let the user resize our window
@@ -310,3 +329,7 @@ dispsettings
#
# Now, wait for user actions...
#
+
+# Local Variables:
+# mode: tcl
+# End:
diff --git a/library/demos/rolodex b/library/demos/rolodex
index 7b22bad..8245a67 100644
--- a/library/demos/rolodex
+++ b/library/demos/rolodex
@@ -1,6 +1,6 @@
#!/bin/sh
# the next line restarts using wish \
-exec wish "$0" "$@"
+exec wish8.4 "$0" ${1+"$@"} || exec wish "$0" ${1+"$@"}
# rolodex --
# This script was written as an entry in Tom LaStrange's rolodex
@@ -8,12 +8,14 @@ exec wish "$0" "$@"
# feel of a rolodex program, although it's lifeless and doesn't
# actually do the rolodex application.
#
-# RCS: @(#) $Id: rolodex,v 1.2 1998/09/14 18:23:29 stanton Exp $
+# RCS: @(#) $Id: rolodex,v 1.3 2001/10/30 10:17:07 dkf Exp $
foreach i [winfo child .] {
catch {destroy $i}
}
+set version 1.2
+
#------------------------------------------
# Phase 0: create the front end.
#------------------------------------------
@@ -23,12 +25,9 @@ pack .frame -side top -fill y -anchor center
set names {{} Name: Address: {} {} {Home Phone:} {Work Phone:} Fax:}
foreach i {1 2 3 4 5 6 7} {
- frame .frame.$i
- pack .frame.$i -side top -pady 2 -anchor e
-
- label .frame.$i.label -text [lindex $names $i] -anchor e
- entry .frame.$i.entry -width 30 -relief sunken
- pack .frame.$i.entry .frame.$i.label -side right
+ label .frame.label$i -text [lindex $names $i] -anchor e
+ entry .frame.entry$i -width 35
+ grid .frame.label$i .frame.entry$i -sticky ew -pady 2 -padx 1
}
frame .buttons
@@ -77,7 +76,7 @@ proc fileAction {} {
proc addAction {} {
global names
foreach i {1 2 3 4 5 6 7} {
- puts stderr [format "%-12s %s" [lindex $names $i] [.frame.$i.entry get]]
+ puts stderr [format "%-12s %s" [lindex $names $i] [.frame.entry$i get]]
}
}
.buttons.add config -command addAction
@@ -88,20 +87,20 @@ proc addAction {} {
proc clearAction {} {
foreach i {1 2 3 4 5 6 7} {
- .frame.$i.entry delete 0 end
+ .frame.entry$i delete 0 end
}
}
.buttons.clear config -command clearAction
proc fillCard {} {
clearAction
- .frame.1.entry insert 0 "John Ousterhout"
- .frame.2.entry insert 0 "CS Division, Department of EECS"
- .frame.3.entry insert 0 "University of California"
- .frame.4.entry insert 0 "Berkeley, CA 94720"
- .frame.5.entry insert 0 "private"
- .frame.6.entry insert 0 "510-642-0865"
- .frame.7.entry insert 0 "510-642-5775"
+ .frame.entry1 insert 0 "John Ousterhout"
+ .frame.entry2 insert 0 "CS Division, Department of EECS"
+ .frame.entry3 insert 0 "University of California"
+ .frame.entry4 insert 0 "Berkeley, CA 94720"
+ .frame.entry5 insert 0 "private"
+ .frame.entry6 insert 0 "510-642-0865"
+ .frame.entry7 insert 0 "510-642-5775"
}
.buttons.search config -command "addAction; fillCard"
@@ -123,7 +122,7 @@ bind . <Control-f> fileAction
.menu.file.m entryconfig 2 -accel Ctrl+Q
bind . <Control-q> {destroy .}
-focus .frame.1.entry
+focus .frame.entry1
#----------------------------------------------------
# Phase 6: help
@@ -145,42 +144,43 @@ proc Help {topic {x 0} {y 0}} {
}
proc getMenuTopic {w x y} {
- return $w.[$w index @[expr $y-[winfo rooty $w]]]
+ return $w.[$w index @[expr {$y-[winfo rooty $w]}]]
}
-bind . <Any-F1> {Help [winfo containing %X %Y] %X %Y}
-bind . <Any-Help> {Help [winfo containing %X %Y] %X %Y}
+event add <<Help>> <F1> <Help>
+bind . <<Help>> {Help [winfo containing %X %Y] %X %Y}
+bind Menu <<Help>> {Help [winfo containing %X %Y] %X %Y}
# Help text and commands follow:
set helpTopics(.menu.file) {This is the "file" menu. It can be used to invoke some overall operations on the rolodex applications, such as loading a file or exiting.}
set helpCmds(.menu.file.m) {getMenuTopic $topic $x $y}
-set helpTopics(.menu.file.m.0) {The "Load" entry in the "File" menu posts a dialog box that you can use to select a rolodex file}
-set helpTopics(.menu.file.m.1) {The "Exit" entry in the "File" menu causes the rolodex application to terminate}
+set helpTopics(.menu.file.m.1) {The "Load" entry in the "File" menu posts a dialog box that you can use to select a rolodex file}
+set helpTopics(.menu.file.m.2) {The "Exit" entry in the "File" menu causes the rolodex application to terminate}
set helpCmds(.menu.file.m.none) {set topic ".menu.file"}
-set helpTopics(.frame.1.entry) {In this field of the rolodex entry you should type the person's name}
-set helpTopics(.frame.2.entry) {In this field of the rolodex entry you should type the first line of the person's address}
-set helpTopics(.frame.3.entry) {In this field of the rolodex entry you should type the second line of the person's address}
-set helpTopics(.frame.4.entry) {In this field of the rolodex entry you should type the third line of the person's address}
-set helpTopics(.frame.5.entry) {In this field of the rolodex entry you should type the person's home phone number, or "private" if the person doesn't want his or her number publicized}
-set helpTopics(.frame.6.entry) {In this field of the rolodex entry you should type the person's work phone number}
-set helpTopics(.frame.7.entry) {In this field of the rolodex entry you should type the phone number for the person's FAX machine}
-
-set helpCmds(.frame.1.label) {set topic .frame.1.entry}
-set helpCmds(.frame.2.label) {set topic .frame.2.entry}
-set helpCmds(.frame.3.label) {set topic .frame.3.entry}
-set helpCmds(.frame.4.label) {set topic .frame.4.entry}
-set helpCmds(.frame.5.label) {set topic .frame.5.entry}
-set helpCmds(.frame.6.label) {set topic .frame.6.entry}
-set helpCmds(.frame.7.label) {set topic .frame.7.entry}
+set helpTopics(.frame.entry1) {In this field of the rolodex entry you should type the person's name}
+set helpTopics(.frame.entry2) {In this field of the rolodex entry you should type the first line of the person's address}
+set helpTopics(.frame.entry3) {In this field of the rolodex entry you should type the second line of the person's address}
+set helpTopics(.frame.entry4) {In this field of the rolodex entry you should type the third line of the person's address}
+set helpTopics(.frame.entry5) {In this field of the rolodex entry you should type the person's home phone number, or "private" if the person doesn't want his or her number publicized}
+set helpTopics(.frame.entry6) {In this field of the rolodex entry you should type the person's work phone number}
+set helpTopics(.frame.entry7) {In this field of the rolodex entry you should type the phone number for the person's FAX machine}
+
+set helpCmds(.frame.label1) {set topic .frame.entry1}
+set helpCmds(.frame.label2) {set topic .frame.entry2}
+set helpCmds(.frame.label3) {set topic .frame.entry3}
+set helpCmds(.frame.label4) {set topic .frame.entry4}
+set helpCmds(.frame.label5) {set topic .frame.entry5}
+set helpCmds(.frame.label6) {set topic .frame.entry6}
+set helpCmds(.frame.label7) {set topic .frame.entry7}
set helpTopics(context) {Unfortunately, this application doesn't support context-sensitive help in the usual way, because when this demo was written Tk didn't have a grab mechanism and this is needed for context-sensitive help. Instead, you can achieve much the same effect by simply moving the mouse over the window you're curious about and pressing the Help or F1 keys. You can do this anytime.}
set helpTopics(help) {This application provides only very crude help. Besides the entries in this menu, you can get help on individual windows by moving the mouse cursor over the window and pressing the Help or F1 keys.}
set helpTopics(window) {This window is a dummy rolodex application created as part of Tom LaStrange's toolkit benchmark. It doesn't really do anything useful except to demonstrate a few features of the Tk toolkit.}
set helpTopics(keys) "The following accelerator keys are defined for this application (in addition to those already available for the entry windows):\n\nCtrl+A:\t\tAdd\nCtrl+C:\t\tClear\nCtrl+D:\t\tDelete\nCtrl+F:\t\tEnter file name\nCtrl+Q:\t\tExit application (quit)\nCtrl+S:\t\tSearch (dummy operation)"
-set helpTopics(version) {This is version 1.0.}
+set helpTopics(version) "This is version $version."
# Entries in "Help" menu