#! /usr/bin/wish

# interface generated by SpecTcl version 1.2 from /home/msj/projects/SpecTcl/SpecTcl/menueditorgetname.ui
#   root     is the parent window for this user interface

proc menueditorgetname_ui {root args} {

	# this treats "." as a special case

	if {$root == "."} {
	    set base ""
	} else {
	    set base $root
	}
    
	label $base.lName \
		-text {Name of New Menu}

	entry $base.eName

	button $base.butOk \
		-default active \
		-text Ok
	catch {
		$base.butOk configure \
			-font -*-Helvetica-Bold-R-Normal-*-*-120-*-*-*-*-*-*
	}

	button $base.butCancel \
		-command "destroy $root" \
		-text Cancel
	catch {
		$base.butCancel configure \
			-font -*-Helvetica-Bold-R-Normal-*-*-120-*-*-*-*-*-*
	}


	# Add contents to menus

	# Geometry management

	grid $base.lName -in $root	-row 1 -column 1 
	grid $base.eName -in $root	-row 1 -column 2 
	grid $base.butOk -in $root	-row 2 -column 1 
	grid $base.butCancel -in $root	-row 2 -column 2 

	# Resize behavior management

	grid rowconfigure $root 1 -weight 0 -minsize 30
	grid rowconfigure $root 2 -weight 0 -minsize 30
	grid columnconfigure $root 1 -weight 0 -minsize 30
	grid columnconfigure $root 2 -weight 0 -minsize 30
# additional interface code
bind $root <Key-Return> "$base.butOk invoke"
bind $root <Key-Escape> "$base.butCancel invoke"
focus $base.eName

switch [lindex $args  0] {
   new {}
   rename {$base.lName config -text "New name of menu"}
   copy {}
}

$base.butOk config -command "
   if {\[::menueditor::nameexists \[$base.eName get\]\]} {
      tk_messageBox -icon error -parent $root -message {Widget name already exists}
      break
   }
   switch [lindex $args  0] {
      new {::menueditor::getname::new \[$base.eName get\]}
      rename {::menueditor::getname::rename \[$base.eName get\]}
      copy {::menueditor::getname::copy \[$base.eName get\]}
   }
   destroy $root
"






# end additional interface code

}


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

catch {
    if [info exists embed_args] {
	# we are running in the plugin
	menueditorgetname_ui .
    } else {
	# we are running in stand-alone mode
	if {$argv0 == [info script]} {
	    wm title . "Testing menueditorgetname_ui"
	    menueditorgetname_ui .
	}
    }
}
