home *** CD-ROM | disk | FTP | other *** search
/ Chip: Linux Special / CorelLinux_CHIP.iso / VMware / bin / vmware-wizard / lib / help.tcl < prev    next >
Encoding:
Text File  |  1999-08-24  |  3.1 KB  |  114 lines

  1.  
  2. ############################################################
  3. ###
  4. ### help window
  5. ###
  6. ############################################################
  7.  
  8. ##
  9. ## redo this with text widget instead of message widget
  10. ##
  11. ##   issues:
  12. ##     message widget will not resize its width
  13. ##     text widget will not resize its height
  14. ##
  15. ## hardcode window size for now XXX dangerous
  16. ##
  17.  
  18. proc helpOpenURL {url} {
  19.     set netscape [Shell_DoesBinaryExist_Prompt {netscape}]
  20.     if {$netscape == ""} {
  21.         DialogWin .error "Help System Error" \
  22.             "Could not find netscape. URLs will not be available." {} 0 OK
  23.         return
  24.     }
  25.     
  26.     if [catch {exec $netscape \
  27.                    -remote "openURL($url, vmware-window, raise)" >& /dev/null} err] {
  28.         if [catch {exec $netscape $url >& /dev/null &} err] {
  29.             DialogWin .error "Help System Error" "Can't open $netscape." {} 0 OK
  30.         }
  31.     }
  32. }
  33.  
  34. proc helpBind {wind tag event body} {
  35.     regsub -all {%W} $body $wind body
  36.     regsub -all {%T} $body $tag body
  37.     $wind tag bind $tag $event $body
  38. }
  39.  
  40. proc helpWindow {name title text urls} {
  41.     if {[winfo exists $name]} {
  42.         set children [winfo children $name]
  43.         foreach child $children {
  44.             destroy $child
  45.         }
  46.     } else {
  47.         catch {destroy $name}
  48.         toplevel $name
  49.     }
  50.     
  51.     wm title $name "$title Help"
  52.     wm iconname $name Dialog
  53.     wm minsize $name 400 400
  54.  
  55.     raise $name
  56.     
  57.     button $name.ok -text OK -width 7 -command "destroy $name" 
  58.     pack $name.ok -side bottom -anchor s -pady 1m
  59.     
  60.     frame $name.div2 -relief sunken -bd 1 -height 1m
  61.     pack $name.div2 -side bottom -fill x
  62.     
  63.     text $name.text -relief flat -wrap word -height 0
  64.     $name.text insert end $text
  65.  
  66.     #$name.text tag add title 1.0 1.end 
  67.     #$name.text tag configure title -underline true
  68.     
  69.     if {[llength $urls]} {
  70.         $name.text insert end "\nSee Also:\n"
  71.         set i 0
  72.         foreach u $urls {
  73.             global $name.text
  74.  
  75.             set $name.text(url$i:url) [lindex $u 0]
  76.  
  77.             $name.text insert end [lindex $u 1]
  78.             $name.text tag add url$i "current linestart" "current lineend" 
  79.             $name.text tag configure url$i -underline true -foreground blue -spacing1 5
  80.  
  81.             helpBind $name.text url$i <Enter> {
  82.                 %W configure -cursor hand2
  83.             }
  84.  
  85.             helpBind $name.text url$i <Leave> {
  86.                 %W configure -cursor xterm
  87.             }
  88.             
  89.             helpBind $name.text url$i <ButtonPress-1> {
  90.                 %W tag configure %T -foreground red
  91.                 helpOpenURL [set %W(%T:url)]
  92.                 %W tag configure %T -foreground blue
  93.             }
  94.             
  95.             $name.text insert end "\n"
  96.             incr i
  97.         }        
  98.     }
  99.  
  100.     $name.text configure -state disabled
  101.  
  102.     scrollbar $name.scroll -bd 2 -width 12
  103.  
  104.     $name.scroll configure -command "$name.text yview"
  105.     $name.text configure -yscrollcommand "$name.scroll set"
  106.  
  107.     pack $name.scroll -side right -fill y
  108.     pack $name.text -padx 2m -pady 2m -anchor n -fill both -expand 1 -side right
  109.  
  110.     frame $name.spacer -height 400p
  111.     pack $name.spacer
  112. }
  113.  
  114.