# SpecTcl, by S. A. Uhler and Ken Corey # Copyright (c) 1994-1995 Sun Microsystems, Inc. # # See the file "license.txt" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # proc recipe_box {canvas args} { frame $canvas -bd 0 -relief flat frame $canvas.holder -bd 2 -relief raised grid $canvas.holder -row 1 -column 0 -sticky nsew grid rowconfigure $canvas.holder 0 -minsize 5 grid rowconfigure $canvas.holder 1 -weight 1 grid columnconfigure $canvas.holder 0 -weight 1 upvar \#0 [winfo name $canvas]combobox c grid rowconfigure $canvas 0 -minsize 20 grid rowconfigure $canvas 1 -weight 1 grid columnconfigure $canvas 0 -weight 1 grid propagate $canvas 1 frame $canvas.hide -bd 0 -relief flat grid $canvas.hide -in $canvas.holder -row 0 -column 0 -sticky nsew -rowspan 2 set c(currenttab) 0 set c(totaltabs) 0 set c(next) 15 set c(xpadding) 5 set c(ypadding) 5 set c(top) 5 set c(contentheight) 0 foreach {t f} $args { if {$t != "" && $f != ""} { eval "recipe_tab $canvas [list $t] [list $f]" } } return $canvas } proc recipe_tab {canvas text win} { upvar \#0 [winfo name $canvas]combobox c frame $canvas.[incr c(totaltabs)] -bd 2 -relief raised label $canvas.$c(totaltabs).l -text $text -padx $c(xpadding) -pady $c(ypadding) pack $canvas.$c(totaltabs).l -side top bind $canvas.$c(totaltabs).l <1> "recipe_raise_tab $canvas $c(totaltabs)" if {$c(totaltabs) > 1} { set idx 1 set x 0 while {$idx < $c(totaltabs)} { set x [expr $x + [winfo reqwidth $canvas.$idx.l] + 4] incr idx } set w [winfo reqwidth $canvas.[expr $c(totaltabs)-1]] set h [winfo reqheight $canvas.[expr $c(totaltabs)-1].l] } else { set x 0 set y 0 set w 0 set h 0 } regexp {\-minsize ([0-9]*)} [grid rowconfigure $canvas 0] dummy height if {$h > $height} { grid rowconfigure $canvas 0 -minsize [expr $h + 5] } place $canvas.$c(totaltabs) -x [expr $x + $w +1] -y 0 -height 100 set c($c(totaltabs)) $win grid $win -in $canvas.holder -row 1 -column 0 -sticky nsew recipe_raise_tab $canvas $c(totaltabs) } proc recipe_raise_tab {canvas tab} { upvar \#0 [winfo name $canvas]combobox c if {[info exist c(last)]} { set f [$canvas.$c(last).l cget -font] regsub -- { bold} $f {} f catch {$canvas.$c(last).l config -font $f} } set c(last) $tab set f [$canvas.$tab.l cget -font] append f " bold" catch {$canvas.$tab.l config -font $f} raise $canvas.holder raise $canvas.$tab raise $c($tab) raise $canvas.hide } # Testing code. #set idx 0 #recipe_box .c #proc scroll_set {args} { #} #foreach qqload {pref_general.ui.tcl spectcl.ui.tcl # help.ui.tcl pref_java.ui.tcl test.ui.tcl pref_appear.ui.tcl # project.ui.tcl} { # frame .a[incr idx] # source $qqload # foreach {x y z} [split $qqload "."] {} # eval "${x}_$y .a$idx" # recipe_tab .c $qqload .a$idx #} #recipe_box .c "This" .t "is" .w a .v testing .x program .y #recipe_tab .c "program2" .u #pack .c -expand 1 -fill both