#!/jlc/local/bin/wish # (Function) # Tkpstoedit executes the "pstoedit" command with output # formats selectable from a menu. # (Update Record) # 96/11/11 K.Fujii Original version. # # tkpstoedit.f0.rbbox.fmtlist: xfig tgif gnuplot pdf flatps java # # # #-- # Set preferences. #-- set biglabelfont "helvbo14" set labelfont "helvb12" set messagefont "helvb12" set helpfont "fixed" set itemfont "fixed" # proc split_rgb {name} { set rgblength [string length $name] case $rgblength { 4 {set format "#%1x%1x%1x"; set shift 12} 7 {set format "#%2x%2x%2x"; set shift 8} 10 {set format "#%3x%3x%3x"; set shift 4} 13 {set format "#%4x%4x%4x"; set shift 0} default {error "syntax error in color name \"$name\""} } if {[scan $name $format red green blue] != 3} { error "syntax error in color name \"$name\"" } set red [expr $red<<$shift] set green [expr $green<<$shift] set blue [expr $blue<<$shift] return "$rgblength $red $green $blue" } proc darken_color {color scale} { set rgblist [split_rgb $color] set rgblength [lindex $rgblist 0] set red [format %.0f [expr $scale*[lindex $rgblist 1]]] set green [format %.0f [expr $scale*[lindex $rgblist 2]]] set blue [format %.0f [expr $scale*[lindex $rgblist 3]]] case $rgblength { 4 {set format "#%01x%01x%01x"} 7 {set format "#%02x%02x%02x"} 10 {set format "#%03x%03x%03x"} 13 {set format "#%04x%04x%04x"} default {error "syntax error in color name \"$name\""} } set new_color [format "$format" $red $green $blue] return $new_color } set how_dark 0.875 set vuecolors [exec getvuecolor] set bg1color [lindex $vuecolors 2] # set bg2color [darken_color [lindex $vuecolors 2] $how_dark] set bg2color [lindex $vuecolors 3] set bg3color [lindex $vuecolors 7] set bg4color [lindex $vuecolors 5] set fwdcolor "white" set fwacolor $fwdcolor set fw2color "yellow" set fw3color "yellow" set txfcolor $fwdcolor set txbcolor $bg2color set sbfcolor $bg1color set sbbcolor $bg2color set sbacolor $bg1color #-- # Define message dialog proc. #-- proc help_dialog {fh msg} { global messagefont helpfont message $fh.msg -text $msg -font $helpfont -aspect 600 button $fh.ok -text OK -command { set val 0 } -font $messagefont pack $fh.msg $fh.ok -side top tkwait variable val destroy . } #-- # Set File. #-- if { $argc != 1 } { help_dialog "" " Tkpstoedit invokes pstoedit with a format menu. \n\ Syntax: \n\ \t tkpstoedit \"\\"" exit 0 } else { set infile [lindex $argv 0] } #-- # Set default format. #-- set outfmt "xfig" set default_fmtlist "xfig tgif gnuplot pdf flatps java" wm title . "Tkpstoedit [exec basename $infile]" #-- # Set frames. #-- frame .f0 -bd 4 -bg $bg1color frame .f0.lbbox -bd 2 -relief groove -bg $bg4color frame .f0.rbbox -bd 2 -relief sunken -bg $bg2color frame .f0.swbox -bd 2 -relief flat -bg $bg1color #-- # Set header label. #-- label .f0.lbbox.label -text "Make Your Choice" -font $biglabelfont \ -background $bg4color -height 2 pack .f0.lbbox.label -side top -fill both #-- # Set up switch box. #-- set frb .f0.rbbox set fmtlist [option get $frb fmtlist {}] if { $fmtlist == "" } { set fmtlist $default_fmtlist } foreach ux $fmtlist { radiobutton .f0.rbbox.$ux \ -text [format " %-8s" $ux] -value $ux -variable outfmt \ -font $itemfont -relief flat \ -highlightthickness 0 \ -activeforeground $fwacolor \ -activebackground $bg2color \ -background $bg2color \ -height 1 -width 14 pack .f0.rbbox.$ux -side top -fill both -anchor w } #-- # Set up button. #-- button .f0.swbox.cancel -text "Quit" \ -command { exit 0 } -font $labelfont \ -highlightthickness 0 \ -foreground $fw3color \ -activeforeground $fw3color \ -width 7 button .f0.swbox.ok -text "OK" \ -command { exec_command $outfmt } -font $labelfont \ -highlightthickness 0 \ -activeforeground $fwacolor \ -width 7 pack .f0.swbox.cancel .f0.swbox.ok -padx 0 -anchor w -fill both -side left #-- # Pack everything. #-- pack .f0.lbbox .f0.rbbox .f0.swbox -fill both -anchor w -side top pack .f0 wm minsize . 1 1 #-- # Execute command. #-- proc exec_command {outfmt} { global env infile set outfile [exec basename [exec basename [exec basename $infile .epsf] .eps] .ps] switch $outfmt { xfig { set fmt "fig" ; set outfile $outfile.fig } tgif { set fmt "tgif" ; set outfile $outfile.obj } gnuplot { set fmt "gnuplot" ; set outfile $outfile.data } pdf { set fmt "pdf" ; set outfile $outfile.pdf } flatps { set fmt "ps" ; set outfile $outfile.flat.ps } java { set fmt "java" ; set outfile $outfile.java } default { set fmt "fig" ; set outfile $outfile.fig } } exec pstoedit -f $fmt "$infile" "$outfile" & }