# interface generated by SpecTcl version 1.0 from edit.ui
#   root     is the parent window for this user interface

proc edit_ui {root args} {

	# this treats "." as a special case

	if {$root == "."} {
	    set base ""
	} else {
	    set base $root
	}
    
	frame $base.frame#1 \
		-background #d9d9d9 \
		-highlightbackground #d9d9d9

	text $base.text \
		-background #d9d9d9 \
		-foreground Black \
		-height 20 \
		-highlightbackground #d9d9d9 \
		-width 60 \
		-wrap none \
		-xscrollcommand "$base.scrollbar#2 set" \
		-yscrollcommand "scroll_set $base.scrollbar#1"
	catch {
		$base.text configure \
			-font -*-Courier-Medium-R-Normal-*-*-140-*-*-*-*-*-*
	}

	scrollbar $base.scrollbar#1 \
		-background #d9d9d9 \
		-command "$base.text yview" \
		-highlightbackground #d9d9d9 \
		-orient v

	scrollbar $base.scrollbar#2 \
		-background #d9d9d9 \
		-command "$base.text xview" \
		-highlightbackground #d9d9d9 \
		-orient h

	button $base.dismiss \
		-background #d9d9d9 \
		-command "set Current(dirty) 1;set f(code) \[$base.text get 1.0 end\];destroy $root" \
		-foreground Black \
		-highlightbackground #d9d9d9 \
		-text Dismiss

	button $base.apply \
		-background #d9d9d9 \
		-command "set Current(dirty) 1; set f(code) \[$base.text get 1.0 end\]" \
		-foreground Black \
		-highlightbackground #d9d9d9 \
		-text Apply

	button $base.revert \
		-background #d9d9d9 \
		-command "append f(code) {}; $root.text delete 1.0 end; $root.text insert 1.0 \$f(code)" \
		-foreground Black \
		-highlightbackground #d9d9d9 \
		-text Revert


	# Geometry management

	grid $base.frame#1 -in $root	-row 3 -column 1 
	grid $base.text -in $root	-row 1 -column 1  \
		-sticky nesw
	grid $base.scrollbar#1 -in $root	-row 1 -column 2  \
		-sticky ns
	grid $base.scrollbar#2 -in $root	-row 2 -column 1  \
		-sticky ew
	grid $base.dismiss -in $base.frame#1	-row 1 -column 1 
	grid $base.apply -in $base.frame#1	-row 1 -column 2 
	grid $base.revert -in $base.frame#1	-row 1 -column 3 

	# Resize behavior management

	grid rowconfigure $root 1 -weight 1 -minsize 225
	grid rowconfigure $root 2 -weight 0 -minsize 30
	grid rowconfigure $root 3 -weight 0 -minsize 30
	grid columnconfigure $root 1 -weight 1 -minsize 359
	grid columnconfigure $root 2 -weight 0 -minsize 0

	grid rowconfigure $base.frame#1 1 -weight 0 -minsize 30
	grid columnconfigure $base.frame#1 1 -weight 0 -minsize 30
	grid columnconfigure $base.frame#1 2 -weight 0 -minsize 30
	grid columnconfigure $base.frame#1 3 -weight 0 -minsize 30
# additional interface code
global f Clip
bind $base.text <Control-w> {
   if {$Current(widget) != ""} {
      upvar #0 [winfo name $Current(widget)] data
      %W insert insert $data(item_name)
   }
    break
}
bind $base.text <Control-c> {
   set Clip [%W get sel.first sel.last]
}
bind $base.text <Control-v> {
   %W insert insert $Clip
}
append f(code) {}
$base.text insert 1.0 $f(code)
tkwait visibility $root
focus $base.text


# end additional interface code

}


# Allow interface to be run "stand-alone" for testing

catch {
    if {$argv0 == [info script]} {
	wm title . "Testing edit"
	edit_ui .
    }
}
