⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utilw32.tcl

📁 windml3.0.3
💻 TCL
📖 第 1 页 / 共 5 页
字号:
#
# ERRORS: N/A
#

proc dialog {dialogType title message args} {
    global ctrlVals
    global setupVals

    switch $dialogType {
        stop {
            switch [messageBox -ok -stopicon $message] {

                ok { return 1 }
            }
        }
        retry_cancel {
            switch [messageBox -retrycancel -questionicon $message] {
                retry  { return 0 }
                cancel { return 1 }
            }
        }
        yes_no {
            switch [messageBox -yesno -questionicon $message] {
                yes { return 0 }
                no  { return 1 }
            }
        }
        yes_no_cancel {
            switch [messageBox -yesnocancel -questionicon $message] {
                yes { return 0 }
                no  { return 1 }
                cancel {return 2}
            }
        }
        ok_proceed_exit {
            global returnval
            set returnval 0

            set controls [list \
                    [list label -name message -title $message \
                                -x 10 -y 10 -w 205 -h 90] \
                    [list button -name Resume -title "&Go back" -default \
                                 -tooltip "Go specify another directory" \
                                 -callback {global returnval;
                        windowClose ok_proceed_exit;
                                            set returnval 0} \
                                 -x 10 -y 78 -w 50 -h 14] \
                    [list button -name Exit -title "&Proceed" \
                                 -tooltip "Continue with installation" \
                                 -callback {global returnval;
                        windowClose ok_proceed_exit;
                                            set returnval 1} \
                                 -x 70 -y 78 -w 50 -h 14] \
                    [list button -name Exit -title "E&xit Setup" \
                                 -tooltip "Stop installation and exit" \
                                 -callback {global returnval;
                        windowClose ok_proceed_exit;
                                            set returnval 2} \
                                 -x 169 -y 78 -w 50 -h 14] \
            ]

            set width 230
            set xpos [expr ($ctrlVals(screenW) / 2) - ($width / 2)]

            set height 100
            set ypos [expr ($ctrlVals(screenH) / 2) - ($height / 2)]

            dialogCreate -name ok_proceed_exit \
                            -nocontexthelp \
                            -title "$title" \
                            -parent $ctrlVals(parentDialog) \
                            -x $xpos -y $ypos \
                            -w $width -h $height \
                            -controls $controls
            return $returnval
        }
        yes_exit {
            global returnval
            set returnval 0

            set controls [list \
                    [list label -name message -title $message \
                                -x 10 -y 10 -w 205 -h 120] \
                    [list button -name Yes -title "&Yes" \
                                 -tooltip "Proceed with installation" \
                                 -callback {global returnVal;
                        windowClose yes_exit;
                                            set returnval 0} \
                                 -x 116 -y 142 -w 50 -h 14] \
                    [list button -name Exit -title "E&xit Setup" \
                                 -tooltip "Stop installation and exit" \
                                 -callback {global returnval;
                        windowClose yes_exit;
                                            set returnval 1} \
                                 -x 169 -y 142 -w 50 -h 14] \
            ]

            set width 230
            set height 160

            dialogCreate -name yes_exit \
                            -title "$title" \
                            -nocontexthelp \
                            -parent $ctrlVals(parentDialog) \
                            -w $width -h $height \
                            -controls $controls
            return $returnval
        }
        resume_exit {
            global returnval
            set returnval 0

            set controls [list \
                    [list label -name message -title $message \
                                -x 10 -y 10 -w 205 -h 80] \
                    [list button -name Resume -title "&Resume" \
                                 -tooltip "Resume installation" \
                                 -callback {global returnVal;
                        windowClose resume_exit;
                                            set returnval 0} \
                                 -x 116 -y 100 -w 50 -h 14] \
                    [list button -name Exit -title "E&xit Setup" \
                                 -tooltip "Stop installation and exit" \
                                 -callback {global returnval;
                        windowClose resume_exit;
                                            set returnval 1} \
                                 -x 169 -y 100 -w 50 -h 14] \
            ]
            set width 230
            set xpos [expr ($ctrlVals(screenW) / 2) - ($width / 2)]

            set height 120
            set ypos [expr ($ctrlVals(screenH) / 2) - ($height / 2)]

            dialogCreate -name resume_exit \
                         -title "$title" \
                         -nocontexthelp \
                         -parent $ctrlVals(parentDialog) \
                         -x $xpos -y $ypos \
                         -w $width -h $height \
                         -controls $controls
            return $returnval
        }
        ok_with_title {
                        set width 200
                        set xpos [expr ($ctrlVals(screenW) / 2) - ($width / 2)]
                        set temp $message
                        set temp [split $temp " "]
                        set numLF 0
                        foreach elem $temp {
                                if {[string first "\n" $elem] != -1} {
                                        incr numLF
                                }
                        }
                        
                        set height [expr 7 + 25 + (10 * [expr [string length $message]/55 + 1])]
                        
                        set height [expr $height + ($numLF * 10)]
                        
                        set ypos [expr ($ctrlVals(screenH) / 2) - ($height / 2)]
                        
                        set controls [list \
                    [list label -name message -title $message \
                                                    -x 10 -y 10 -w 186 \
                                -h [expr ($numLF * 10) + \
                                                        (10 * [expr [string length $message]/55 + 1])]] \
                    [list button -name okWithTitle -title "&OK" \
                                 -callback {windowClose ok_with_title} \
                                 -x 75 -y [expr $height -7 -14] -w 50 -h 14] \
                        ]

                        dialogCreate -name ok_with_title \
                                                -nocontexthelp \
                            -title "$title" \
                            -parent $ctrlVals(parentDialog) \
                            -x $xpos -y $ypos \
                            -w $width -h $height \
                            -controls $controls
                        return 
        }
        re_ig_cancel {
            switch [messageBox -abortretryignore -questionicon $message] {
                abort  { return 2 }
                retry  { return 0 }
                ignore { return 1 }
                default { return 0 }
            }
        }
        re_ig_cancel_old {
            global returnval
            set returnval 0
            set controls [list \
                [list label -name message -title $message \
                            -x 10 -y 7 -w 194 -h 90] \
                [list button -name retry -title "&Retry" \
                             -callback {global returnval; \
                                        windowClose re_ig_cancel; \
                                        set returnval 0} \
                             -x 10 -y 56 -w 50 -h 14] \
                [list button -name ignore -title "&Ignore" \
                             -callback {global returnval; \
                                        windowClose re_ig_cancel; \
                                        set returnval 1} \
                             -x 80 -y 56 -w 50 -h 14] \
                [list button -name cancel -title "&Cancel" \
                             -callback {global returnval; \
                                        windowClose re_ig_cancel; \
                                        set returnval 2} \
                             -x 150 -y 56 -w 50 -h 14] \
            ]

            dialogCreate -name "re_ig_cancel" \
                         -title "$title" \
                         -parent $ctrlVals(parentDialog) \
                         -nocontexthelp \
                         -w 205 -h 76 \
                         -controls $controls
            return $returnval
        }
        base_install_warn {
            global returnval
            set returnval 1

            set controls [list \
                [list frame -white -name baseFrame -x 7 -y 7 -w 1 -h 1 \
                        -w 188 -h 36] \
                [list label -name warn_label \
                        -title " Installing [getProdInfo name] Over an Existing Tree " \
                        -x 20 -y 4 -w 160 -h 8] \
                [list label -name message -title $message \
                        -x 14 -y 14 -w 175 -h 28] \
                [list label -name message2 \
                        -title [strTableGet 4000_BASE_INSTALL_WARN_1] \
                        -x 10 -y 47 -w 184 -h 25] \
                [list button -name continue -title "&Install" \
                        -tooltip "Continue with installation" \
                        -callback onBaseInstallWarnContinue \
                        -x 10 -y 77 -w 50 -h 14] \
                [list button -name return -title "&Select Path" -default \
                        -tooltip "Return to Select Directory page" \
                        -callback onBaseInstallWarnReturn \
                        -x 146 -y 77 -w 50 -h 14] \
                                                ]

                        dialogCreate -name base_install_warn \
                                -title "$title" \
                                -parent $ctrlVals(parentDialog) \
                                -nocontexthelp \
                                -w 205 -h 96 \
                                -init {
                                  controlPropertySet base_install_warn.warn_label -bold 1
                        } \
                                -controls $controls
                        return $returnval
        }
        file_exists_older_warn {
            global retvalOld
            set retvalOld 2
            set controls [list \
                            [list label -name message -title $message \
                              -x 10 -y 7 -w 188 -h 70] \
                            [list choice -name overwriteFile -title \
                              [strTableGet 4010_FILE_EXISTS_WARN_1] \
                              -newgroup -auto \
                              -tooltip "Overwrite one file" \
                              -x 10 -y 55 -w 150 -h 10 ] \
                            [list choice -name no_overwriteFile -title \
                              [strTableGet 4010_FILE_EXISTS_WARN_2] -auto \
                              -tooltip "Do not overwrite file" \
                              -x 10 -y 67 -w 150 -h 10 ] \
                            [list choice -name overwriteAll -title \
                              [strTableGet 4010_FILE_EXISTS_WARN_3] -auto \
                              -tooltip "Overwrite all duplicate files" \
                              -x 10 -y 79 -w 180 -h 10 ] \
                            [list choice -name no_overwriteAny -title \
                              [strTableGet 4010_FILE_EXISTS_WARN_4] -auto \
                              -tooltip "Do not overwrite any duplicate files" \
                              -x 10 -y 91 -w 200 -h 10 ] \
                            [list button -name file_exists_OK -title "&OK" \
                              -callback {windowClose file_exists_older_warn} \
                              -x 77 -y 105 -w 50 -h 14 ]  ]
                        
            dialogCreate -name file_exists_older_warn \
                         -title "$title" \
                         -parent $ctrlVals(parentDialog) \
                         -nocontexthelp \
                         -init fileExistsOlderWarnInit \
                         -w 225 -h 130 \
                         -controls $controls
            return $retvalOld
        }
        file_exists_newer_warn {
            global retvalNew
            set retvalNew 2
            set controls [list \
                            [list label -name message -title $message \
                              -x 10 -y 7 -w 188 -h 70] \
                            [list choice -name overwriteFile -title \
                              [strTableGet 4010_FILE_EXISTS_WARN_1] \
                              -newgroup -auto \
                              -tooltip "Overwrite one file" \
                              -x 10 -y 55 -w 150 -h 10 ] \
                            [list choice -name no_overwriteFile -title \
                              [strTableGet 4010_FILE_EXISTS_WARN_2] -auto \
                               -tooltip "Do not overwrite file" \
                               -x 10 -y 67 -w 150 -h 10 ] \
                            [list choice -name overwriteAll -title \
                              [strTableGet 4010_FILE_EXISTS_WARN_3] -auto \
                               -tooltip "Overwrite all duplicate files" \
                               -x 10 -y 79 -w 180 -h 10 ] \
                            [list choice -name no_overwriteAny -title \
                              [strTableGet 4010_FILE_EXISTS_WARN_4] -auto \
                               -tooltip "Do not overwrite any duplicate files" \
                               -x 10 -y 91 -w 200 -h 10 ] \
                            [list button -name file_exists_OK -title "&OK" \
                               -callback {windowClose file_exists_newer_warn} \
                               -x 77 -y 105 -w 50 -h 14 ]  ]
                        
            dialogCreate -name file_exists_newer_warn \
                         -title "$title" \
                         -parent $ctrlVals(parentDialog) \
                         -nocontexthelp \
                         -init fileExistsNewerWarnInit \
                         -exit fileExistsNewerWarnExit \
                         -w 225 -h 130 \
                         -controls $controls
            return $retvalNew
        }
        ok {
            switch [messageBox -ok -information $message] {
                ok { return 0 }
            }
        }
        ok_cancel {
            switch [messageBox -okcancel -questionicon $message] {
                ok     { return 0 }
                cancel { return 1 }
            }
        }
        proceed_cancel {
            switch [messageBox -proceedcancel -questionicon $message] {
                proceed { return 0 }
                cancel  { return 1 }
            }
        }
    }
}

#############################################################################
#
# messageBox - Display the message box dialog
#
# This procedure is intended to replace the messageBox method from UITclSh.
# The one from UITclSh has problem displaying the button text. This messageBox
# procedure will display NO icon. It only displays text and buttons.
#
# SYNOPSIS
# .tS
# messageBox <option> msg
# .tE
#
# PARAMETERS: 
#        -ok        with OK button
#        -okcancel  with OK and Cancel buttons
#        -yesno     with Yes and No buttons
#        -stop      with OK button (same as -ok)
#        -abortretryignore    with Abort, Retry and Ignore buttons
#        -retrycancel         with Retry and Cancel buttons
#        -proceed_cancel      with Proceed and Cancel buttons
#
# RETURNS: the parameters values
#
# 

proc messageBox {args} {
    global ctrlVals

    set message [lindex $args end]
    set title "Setup"
    set buttons ""
    set msgBoxOption "ok"
    set retVal ""

    # determine option
    foreach var $args {
        switch -exact -- $var {
            -yesnocancel {set msgBoxOption "yesnocancel"}
            -okcancel {set msgBoxOption "okcancel"}  
            -proceedcancel {set msgBoxOption "proceedcancel"}  
            -yesno {set msgBoxOption "yesno"} 
            -stop {set msgBoxOption "stop"} 
            -abortretryignore {set msgBoxOption "abortretryignore"} 
            -retrycancel {set msgBoxOption "retrycancel"} 
            -ok {set msgBoxOption "ok"}
            default {
                if [regexp {^[a-zA-Z0-9]} $var] {
         

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -