#install.tcl
# Copyright (c) 2001-2004 Digi International Inc., All Rights Reserved
# 
# This software contains proprietary and confidential information of Digi
# International Inc.  By accepting transfer of this copy, Recipient agrees
# to retain this software in confidence, to prevent disclosure to others,
# and to make no use of this software other than that for which it was
# delivered.  This is an unpublished copyrighted work of Digi International
# Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
# prohibited.
# 
# Restricted Rights Legend
#
# Use, duplication, or disclosure by the Government is subject to
# restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
# Technical Data and Computer Software clause at DFARS 252.227-7031 or
# subparagraphs (c)(1) and (2) of the Commercial Computer Software -
# Restricted Rights at 48 CFR 52.227-19, as applicable.
#
# Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
#
# ***************************************************************************

namespace eval ::dg::install {}

proc ::dg::install::Exe {pathExe} {
    exec $pathExe &
}

proc ::dg::install::ListDialog {parent} {
    global lstSoftware
    . configure -cursor {}
    toplevel .l -width 300 -height 250
    ::window::center .l
    if {$::tcl_platform(platform) == "windows"} {
        wm attributes .l -toolwindow 1
    }
    wm transient .l .
    wm resizable .l 0 0
    wm title .l [mc install.l.title]
    set lstSoftware {}
    foreach sw $::softw($::dg::strOS) {
        lappend lstSoftware [mc $sw]
    }

    set frmList [frame .l.frmlist]
    set lblInstall [label $frmList.lbl -text [mc install.lbl]]
    set lbxInstall [listbox $frmList.lbx -width 50 -listvariable ::lstSoftware]
    $lbxInstall selection set 0
    pack $lblInstall $lbxInstall -side top -anchor w
    
    set frmButtons [frame .l.frmb]
    set btnInstall [button $frmButtons.i -width 10 -default active -text [mc install.btn.install] \
     -command "[list ::dg::install::Install $lbxInstall]"]
    set btnCancel [button $frmButtons.c -width 10 -default normal -text [mc install.btn.cancel] \
     -command {destroy .l}]
    pack $btnInstall $btnCancel -side left -padx 10 -pady 5

    pack $frmList $frmButtons -side top -padx 10 -pady 5
    bind .l <Escape> "::dg::dgButtonInvoke $btnCancel"
    bind .l <Return>  "::dg::dgButtonInvoke $btnInstall"
    bind .l <Up> "focus $lbxInstall"
    bind .l <Down> "focus $lbxInstall"
    focus $btnInstall
    grab set .l
    tkwait window .l
}

proc ::dg::dgButtonInvoke {w} {
    if {[info tclversion] >= 8.4} {
        tk::ButtonInvoke $w
    } else {
        tkButtonInvoke $w
    }
}

proc ::dg::install::Install {lbxW} {
    if {[$lbxW curselection] == ""} {
        tk_messageBox -message [mc install.noselection] -parent .l
        return
    }
    ::dg::command::Install [$lbxW curselection]
}

