msgbox.tcl revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
# msgbox.tcl --
#
# Implements messageboxes for platforms that do not have native
# messagebox support.
#
# SCCS: @(#) msgbox.tcl 1.4 96/09/05 11:30:30
#
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# tkMessageBox --
#
# Pops up a messagebox with an application-supplied message with
# an icon and a list of buttons. This procedure will be called
# by tk_messageBox if the platform does not have native
# messagebox support, or if the particular type of messagebox is
# not supported natively.
#
# This procedure is a private procedure shouldn't be called
# directly. Call tk_messageBox instead.
#
# See the user documentation for details on what tk_messageBox does.
#
proc tkMessageBox {args} {
global tkPriv
set w tkPrivMsgBox
upvar #0 $w data
#
# The default value of the title is space (" ") not the empty string
# because for some window managers, a
# wm title .foo ""
# causes the window title to be "foo" instead of the empty string.
#
set specs {
{-default "" "" ""}
{-icon "" "" "info"}
{-message "" "" ""}
{-parent "" "" .}
{-title "" "" " "}
{-type "" "" "ok"}
}
error "invalid icon \"$data(-icon)\", must be error, info, question or warning"
}
error "bad window path name \"$data(-parent)\""
}
set buttons {
}
}
ok {
set buttons {
}
}
}
okcancel {
set buttons {
}
}
set buttons {
}
}
yesno {
set buttons {
}
}
set buttons {
}
}
default {
error "invalid message box type \"$data(-type)\", must be abortretryignore, ok, okcancel, retrycancel, yesno or yesnocancel"
}
}
break
}
}
if !$valid {
error "invalid default button \"$data(-default)\""
}
}
# 2. Set the dialog to be a child window of $parent
#
#
} else {
set w .__tk__messagebox
}
# 3. Create the top-level window and divide it into top
# and bottom parts.
catch {destroy $w}
# 4. Fill the top part with bitmap and message (use the option
# database for -wraplength so that it can be overridden by
# the caller).
}
}
# 5. Create a row of buttons at the bottom of the dialog.
# Capitalize the first letter of $name
set capName \
[string toupper \
}
} else {
}
# create the binding for the key accelerator, based on the underline
#
}
incr i
}
# 6. Create a binding for <Return> on the dialog if there is a
# default button.
}
# 7. Withdraw the window, then update all the geometry information
# so we know how big it wants to be, then center the window in the
# display and de-iconify it.
update idletasks
# 8. Set a grab and claim the focus too.
set oldFocus [focus]
}
grab $w
} else {
focus $w
}
# 9. Wait for the user to respond, then restore the focus and
# return the index of the selected button. Restore the focus
# before deleting the window, since otherwise the window manager
# may take the focus away so we can't redirect it. Finally,
# restore any grab that was in effect.
tkwait variable tkPriv(button)
catch {focus $oldFocus}
destroy $w
grab -global $oldGrab
} else {
grab $oldGrab
}
}
return $tkPriv(button)
}