summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--doc/messageBox.n17
-rw-r--r--tests/msgbox.test6
-rw-r--r--win/tkWinDialog.c41
4 files changed, 55 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 43e6507..b68834a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,14 @@
+2004-05-24 Donal K. Fellows <donal.k.fellows@man.ac.uk>
+
+ * doc/messageBox.n: Added documentation for the -detail option.
+ * tests/msgbox.test: Updated test suite with correct list of options.
+ * win/tkWinDialog.c (Tk_MessageBoxObjCmd): Added "support" for the
+ -detail option by concatenating it onto the end of the message.
+
2004-05-24 Jim Ingham <jingham@apple.com>
- * tkMacOSXDialog.c (Tk_MessageBoxObjCmd): Turn on the
- -finemessage option for Mac OS X.
+ * tkMacOSXDialog.c (Tk_MessageBoxObjCmd): Turn on the -detail
+ option for Mac OS X.
2004-05-23 Donal K. Fellows <donal.k.fellows@man.ac.uk>
diff --git a/doc/messageBox.n b/doc/messageBox.n
index 4e6eead..36bcc36 100644
--- a/doc/messageBox.n
+++ b/doc/messageBox.n
@@ -4,7 +4,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: messageBox.n,v 1.5 2000/04/27 18:28:58 ericm Exp $
+'\" RCS: @(#) $Id: messageBox.n,v 1.6 2004/05/24 21:23:23 dkf Exp $
'\"
.so man.macros
.TH tk_messageBox n 4.2 Tk "Tk Built-In Commands"
@@ -33,6 +33,14 @@ this message window ('ok', 'cancel', and so on). See \fB\-type\fR
for a list of the symbolic names. If this option is not specified,
the first button in the dialog will be made the default.
.TP
+\fB\-detail\fR \fIstring\fR
+.VS 8.5
+Specifies an auxiliary message to the main message given by the
+\fB\-message\fR option. Where supported by the underlying OS, the
+message detail will be presented in a less emphasized font than the
+main message.
+.VE 8.5
+.TP
\fB\-icon\fR \fIiconImage\fR
Specifies an icon to display. \fIIconImage\fR must be one of the
following: \fBerror\fR, \fBinfo\fR, \fBquestion\fR or
@@ -78,10 +86,13 @@ and \fBcancel\fR.
.PP
.SH EXAMPLE
.CS
-set answer [tk_messageBox \-message "Really quit?" \-type yesno \-icon question]
+set answer [tk_messageBox \-message "Really quit?" \b
+ \-icon question \-type yesno \b
+ \-detail "Select \b"Yes\b" to make the application exit"]
switch -- $answer {
yes exit
- no {tk_messageBox \-message "I know you like this application!" \-type ok}
+ no {tk_messageBox \-message "I know you like this application!" \b
+ \-type ok}
}
.CE
diff --git a/tests/msgbox.test b/tests/msgbox.test
index 2959ccd..a351d0b 100644
--- a/tests/msgbox.test
+++ b/tests/msgbox.test
@@ -5,7 +5,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: msgbox.test,v 1.8 2004/05/23 17:34:49 dkf Exp $
+# RCS: @(#) $Id: msgbox.test,v 1.9 2004/05/24 21:23:23 dkf Exp $
#
package require tcltest 2.1
@@ -14,10 +14,10 @@ tcltest::loadTestedCommands
test msgbox-1.1 {tk_messageBox command} {
list [catch {tk_messageBox -foo} msg] $msg
-} {1 {bad option "-foo": must be -default, -icon, -message, -parent, -title, or -type}}
+} {1 {bad option "-foo": must be -default, -detail, -icon, -message, -parent, -title, or -type}}
test msgbox-1.2 {tk_messageBox command} {
list [catch {tk_messageBox -foo bar} msg] $msg
-} {1 {bad option "-foo": must be -default, -icon, -message, -parent, -title, or -type}}
+} {1 {bad option "-foo": must be -default, -detail, -icon, -message, -parent, -title, or -type}}
catch {tk_messageBox -foo bar} msg
regsub -all , $msg "" options
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index ea08072..61799dc 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinDialog.c,v 1.34 2004/02/13 01:28:19 hobbs Exp $
+ * RCS: @(#) $Id: tkWinDialog.c,v 1.35 2004/05/24 21:23:23 dkf Exp $
*
*/
@@ -179,9 +179,7 @@ static UINT APIENTRY OFNHookProc(HWND hdlg, UINT uMsg, WPARAM wParam,
static UINT APIENTRY OFNHookProcW(HWND hdlg, UINT uMsg, WPARAM wParam,
LPARAM lParam);
static void SetTkDialog(ClientData clientData);
-
-
-
+
/*
*-------------------------------------------------------------------------
*
@@ -226,9 +224,7 @@ static void EatSpuriousMessageBugFix( void )
PeekMessage(&msg,0,WM_LBUTTONUP,WM_LBUTTONUP,PM_REMOVE);
}
}
-
-
-
+
/*
*-------------------------------------------------------------------------
*
@@ -2530,24 +2526,25 @@ Tk_MessageBoxObjCmd(clientData, interp, objc, objv)
{
Tk_Window tkwin, parent;
HWND hWnd;
- char *message, *title;
+ char *message, *title, *detail;
int defaultBtn, icon, type;
int i, oldMode, winCode;
UINT flags;
Tcl_DString messageString, titleString;
Tcl_Encoding unicodeEncoding = TkWinGetUnicodeEncoding();
static CONST char *optionStrings[] = {
- "-default", "-icon", "-message", "-parent",
- "-title", "-type", NULL
+ "-default", "-detail", "-icon", "-message",
+ "-parent", "-title", "-type", NULL
};
enum options {
- MSG_DEFAULT, MSG_ICON, MSG_MESSAGE, MSG_PARENT,
- MSG_TITLE, MSG_TYPE
+ MSG_DEFAULT, MSG_DETAIL, MSG_ICON, MSG_MESSAGE,
+ MSG_PARENT, MSG_TITLE, MSG_TYPE
};
tkwin = (Tk_Window) clientData;
defaultBtn = -1;
+ detail = NULL;
icon = MB_ICONINFORMATION;
message = NULL;
parent = tkwin;
@@ -2583,6 +2580,10 @@ Tk_MessageBoxObjCmd(clientData, interp, objc, objv)
}
break;
+ case MSG_DETAIL:
+ detail = string;
+ break;
+
case MSG_ICON:
icon = TkFindStateNumObj(interp, optionPtr, iconMap, valuePtr);
if (icon < 0) {
@@ -2648,6 +2649,22 @@ Tk_MessageBoxObjCmd(clientData, interp, objc, objv)
flags |= icon | type | MB_SYSTEMMODAL;
Tcl_UtfToExternalDString(unicodeEncoding, message, -1, &messageString);
+ if (detail != NULL) {
+ Tcl_DString detailString;
+
+ if (message != NULL) {
+ Tcl_UtfToExternalDString(unicodeEncoding, "\n\n", -1,
+ &detailString);
+ Tcl_DStringAppend(&messageString, Tcl_DStringValue(&detailString),
+ Tcl_DStringLength(&detailString));
+ Tcl_DStringFree(&detailString);
+ }
+ Tcl_UtfToExternalDString(unicodeEncoding, detail, -1,
+ &detailString);
+ Tcl_DStringAppend(&messageString, Tcl_DStringValue(&detailString),
+ Tcl_DStringLength(&detailString));
+ Tcl_DStringFree(&detailString);
+ }
Tcl_UtfToExternalDString(unicodeEncoding, title, -1, &titleString);
oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);