#
# $Log: not supported by cvs2svn $
# Revision 1.4  1998/02/19 23:26:03  borland
# Fixed a number of grab/focus problems that prevented proper modal operation
# of FileDisplayWindow.
#
# Revision 1.3  1996/12/19 23:45:53  borland
# Added -default option.
#
# Revision 1.2  1996/06/21  20:18:35  borland
# Added documentation of -width option to help routine.
#
# Revision 1.1  1996/01/16  21:38:29  saunders
# Unofficial routines from ~borland/tcl/rel added. These should
# ultimately be removed from use or modified to comply with
# current conventions.
#
#

proc APSInfoDialogHelp {} {
    return "Usage: APSInfoDialog widget \n\[-parent <string>\]\t\n\[-noPack 1\]\t\n\[-packOption <list>\]\t\n\[-name <string\]\t\n\[-width <width\]\t\n\[-infoMessage <string>\]\t\n\[-contextHelp <string>\]\t\n\[-default <string>\]\n\nCreates\t\$parent\$widget.\n\tmsg\n\tbuttonRow.ok.button\n\tbuttonRow.cancel.button"
}

proc APSInfoDialog {widget args} {
    global apsContextHelp apsInfoDialogChoice apsInfoDialogInput apsttk
    set parent ""
    set noPack 0
    set packOption "-side top -fill x"
    set name "UntitledInfo"
    set infoMessage "No Info"
    set contextHelp ""
    set width 20
    set default ""
    APSStrictParseArguments {parent noPack packOption name infoMessage contextHelp width default}
    set apsInfoDialogInput $default

    if {[info exists apsttk] && ($apsttk != 0)} {
        set ttkPrefix ttk::
    } else {
        set ttkPrefix ""
    }
    if {$contextHelp != ""} {
	set apsContextHelp($parent$widget) $contextHelp
    }

    set windowExists [winfo exists $parent$widget]
    if {$parent == ""} {
	if {$windowExists} {
	    raise $widget
	} else {
	    toplevel $widget
	    wm title $widget $name
	}
    } else {
	${ttkPrefix}frame $parent$widget
	if {!$noPack} {
	    eval pack $parent$widget $packOption
	}
    }

    if {$windowExists} {
        destroy $parent$widget
        } 
    message $parent$widget.msg -relief raised -justify center -bd 2 \
	  -width 10c -text "$infoMessage\n                            "
    pack $parent$widget.msg -side top -fill both -expand 1
	
    APSLabeledEntry .lentry -parent $parent$widget -label "Input: " \
      -textVariable apsInfoDialogInput -width $width \
      -contextHelp $contextHelp

    ${ttkPrefix}frame $parent$widget.buttonRow -relief raised -borderwidth 2
    pack $parent$widget.buttonRow -side bottom -fill x
	
    APSButton .ok -parent $parent$widget.buttonRow -text OK \
	  -command "set apsInfoDialogChoice OK" -highlight 1 -width ""
    APSButton .cancel -parent $parent$widget.buttonRow -text CANCEL \
	  -command "set apsInfoDialogChoice CANCEL" -highlight 0 -width ""

    set grabList [grab current $parent$widget]
    focus $parent$widget
    catch {grab set $parent$widget}
    tkwait variable apsInfoDialogChoice
    catch {grab set $grabList}
    destroy $parent$widget
    if {[string compare $apsInfoDialogChoice "OK"]==0} { 
        return $apsInfoDialogInput
    } 
    return ""
}
