help_menu
TCL/TK UseCase3
Abstract : Contains the help windows and procedure.
Comments : The on-line help needs 2 text files that contain information.
The procedures then search though these files for topics and
other information. Complete instructions on adding help entrys and
information are located at the end of this document. At this time,
there isn't much in the help text files.
#
#Help menu by Paul Guglielmino
#Part of a class project for COM1205 fall 95
#
#This is just a message box to tell the user that help ain't here!
proc NoHelp {} {
toplevel .nohelp
wm title .nohelp "ERROR!"
message .nohelp.msg -width 8c -text "The help files can not be found. Help functions will not be available."
button .nohelp.noHelpOK -text "OK" -command {destroy .nohelp}
pack .nohelp.msg
pack .nohelp.noHelpOK
}
#This proc enables action to take place in the text widget than deletes all
#text in it and inserts the new help text that the user selected.
proc displayHelp { helpStuff window } {
$window configure -state normal
$window delete 1.0 end
$window insert end $helpStuff
$window configure -state disabled
}
# Proc to get the help text from help file "help2.txt"
proc getHelpText { indexNum window } {
set helpText [open "help2.txt" r]
set count 0
while { [gets $helpText line] >= 0 } {
if {$line == "00"} {
incr count
}
if { $count == $indexNum } {
set theHelp ""
while { [gets $helpText newLine] != -1} {
if { $newLine != "00" } {
append theHelp $newLine
} else {
break
}
}
displayHelp $theHelp $window
set theHelp ""
break
}
}
}
#Finds the help that the user wants from "help1.txt"
proc FindHelp { userSel window } {
set helpFile [open "help1.txt" r]
while { [gets $helpFile line] >= 0 } {
if { [ regexp $userSel $line ] == 1 } {
set foo [string index $line [expr [string length $line]-1] ]
getHelpText $foo $window
break
}
}
close $helpFile
}
#This proc will display the results of a user's search for them
proc SearchBox {} {
global searchFor
destroy .watch
set helpFile [open "help1.txt" r]
toplevel .search -borderwidth 3
wm geometry .search 600x300
wm title .search "Search Results"
wm iconname .search "Search Results"
listbox .search.selectedHelp -relief sunken -exportselection 0 -borderwidth 2 -yscrollcommand ".search.scroll set"
text .search.helpText -relief sunken -wrap word -yscrollcommand ".search.scrollHelp set"
button .search.done -text "Done" -command "destroy .search"
scrollbar .search.scrollHelp -command ".search.helpText yview"
scrollbar .search.scroll -command ".search.selectedHelp yview"
pack .search.done -side bottom -fill x
pack .search.selectedHelp -side left -fill both -ipadx 1c
pack .search.scroll -side left -fill y
pack .search.scrollHelp -side right -fill y
pack .search.helpText -side right -fill both
bind .search.selectedHelp { FindHelp [.search.selectedHelp get [.search.selectedHelp curselection] ] .search.helpText }
while { [gets $helpFile line] >= 0 } {
if [ regexp $searchFor $line ] {
set line [string range "$line" 0 [expr [string length "$line"] - 4] ]
.search.selectedHelp insert end $line
}
}
close $helpFile
}
#This proc will display a window in which the user can type his desired search
#string and will start the search proc
proc HelpMe {} {
global searchFor
if { [ catch {open "help1.txt" r} result ] || [ catch {open "help2.txt" r} result ] } {
NoHelp
return
}
toplevel .watch -borderwidth 4
wm title .watch "Help Search"
wm geometry .watch 350x125
label .watch.value -text "What would you like to search for:"
entry .watch.entry -width 20 -relief sunken -bd 2 -textvariable searchFor
button .watch.go -text "Start Search" -command { SearchBox }
button .watch.cancel -text "Cancel Search" -command "destroy .watch"
bind .watch.entry { SearchBox }
pack .watch.cancel -side bottom -padx 1m -padx 1m
pack .watch.go -side bottom
pack .watch.value .watch.entry -side left -padx 1m -pady 1m
focus .watch.entry
}
#These procs bring the user to the demeter home page and faq.
proc WebHelp {} {
exec sh -c "netscape -install http://www.ccs.neu.edu/research/demeter/index.html"
}
proc WebHelp.faq {} {
exec sh -c "netscape -install ftp://ftp.ccs.neu.edu/pub/people/lieber/faq/Demeter-FAQ"
}
proc DemDrawPage {} {
exec sh -c "netscape -install http://www.ccs.neu.edu/home/prat/cddoc"
}
#This proc will list all the topics in "help1.txt" for the user to see and
#select
proc listTopics {} {
if { [ catch {open "help1.txt" r} result ] || [ catch {open "help2.txt" r} result ] } {
NoHelp
return
}
toplevel .topics
wm title .topics "Help Topics"
wm geometry .topics 500x400
frame .topics.pick
listbox .topics.pick.list -relief sunken -borderwidth 2
scrollbar .topics.pick.textscroll -command ".topics.helpText yview"
text .topics.helpText -relief sunken -yscrollcommand ".topics.pick.textscroll set"
entry .topics.where -relief sunken -textvariable whereIS
button .topics.done -text "Done" -command "destroy .topics"
#Pack Everything
pack .topics.pick -side top
pack .topics.pick.list -side left -fill x -ipadx 1c
pack .topics.pick.textscroll -side left -fill y
pack .topics.done .topics.helpText -side bottom -fill x
set helpText [open "help1.txt" r]
while { [gets $helpText line] >= 0 } {
set line [string range "$line" 0 [expr [string length "$line"] - 4] ]
.topics.pick.list insert end $line
}
bind .topics.pick.list { FindHelp [.topics.pick.list get [.topics.pick.list curselection] ] .topics.helpText }
close $helpText
}
#The about box! Anyone for pictures? :-)
proc about {} {
toplevel .about -borderwidth 3
wm title .about "About DemDraw"
wm geometry .about 300x475
message .about.people -width 12c -text "This project was headed by:
Professor Karl Lieberherr
The students working on this project were:
Adam N Reitsma
Adnan Khan
Anthony Cordeiro
Carlos A. Santiago
Chaki Ng
Chandan Bandopadhyay
Chih-Chien Ueng
Eric Singleton
Gary B. Card
Gyanendra Kumar
Jiatong Li
Joshua J Houghton
Karen D Ready
Kevin Chau-Ming Chu
Marsha Akeson
Michael Robert Boucher
Paul Guglielmino
Peter Tandara-Kuhns
Ronald Westberg
Saqib Rehman
Stanislav Paltis
Steven Kaufman
Tim Russo
Tom Kneeland
Young Soo Yang"
button .about.ok -text "OK" -command "destroy .about"
pack .about.people
pack .about.ok -padx 3m -pady 3m -fill x
}