summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--tests/winDialog.test80
-rw-r--r--win/tkWinDialog.c6
-rw-r--r--win/tkWinTest.c5
4 files changed, 89 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index dfcb0ec..0f67cad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-04-14 Pat Thoyts <patthoyts@users.sourceforge.net>
+
+ * win/tkWinDialog.c: backport tk_chooseColor -title fix from head
+ * win/tkWinTest.c: Added parent to testgetwininfo
+ * tests/winDialog.test: Created some tk_chooseColor win tests.
+
2008-04-11 Don Porter <dgp@users.sourceforge.net>
* generic/tk.h: Bump version number to 8.5.3b1 to distinguish
diff --git a/tests/winDialog.test b/tests/winDialog.test
index d4e24e5..4c172cb 100644
--- a/tests/winDialog.test
+++ b/tests/winDialog.test
@@ -6,7 +6,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# Copyright (c) 1998-1999 ActiveState Corporation.
#
-# RCS: @(#) $Id: winDialog.test,v 1.15 2007/12/13 15:27:55 dgp Exp $
+# RCS: @(#) $Id: winDialog.test,v 1.15.2.1 2008/04/14 20:59:51 patthoyts Exp $
package require tcltest 2.1
eval tcltest::configure $argv
@@ -57,10 +57,80 @@ proc SetText {button text} {
return [testwinevent $::tk_dialog $button WM_SETTEXT $text]
}
-test winDialog-1.1 {Tk_ChooseColorObjCmd} {nt} {
-} {}
-
-test winDialog-2.1 {ColorDlgHookProc} {nt} {
+test winDialog-1.1.0 {Tk_ChooseColorObjCmd} -constraints {
+ testwinevent
+} -body {
+ start {tk_chooseColor}
+ then {
+ Click cancel
+ }
+} -result {0}
+test winDialog-1.1.1 {Tk_ChooseColorObjCmd} -constraints {
+ testwinevent
+} -body {
+ start {set clr [tk_chooseColor -initialcolor "#ff9933"]}
+ then {
+ set x [Click cancel]
+ }
+ list $x $clr
+} -result {0 {}}
+test winDialog-1.1.2 {Tk_ChooseColorObjCmd} -constraints {
+ testwinevent
+} -body {
+ start {set clr [tk_chooseColor -initialcolor "#ff9933"]}
+ then {
+ set x [Click 1]
+ }
+ list $x $clr
+} -result [list 0 "#ff9933"]
+test winDialog-1.1.3 {Tk_ChooseColorObjCmd: -title} -constraints {
+ testwinevent
+} -body {
+ set x {}
+ start {set clr [tk_chooseColor -initialcolor "#ff9933" -title "Hello"]}
+ then {
+ array set a [testgetwindowinfo $::tk_dialog]
+ if {[info exists a(text)]} {lappend x $a(text)}
+ lappend x [Click 1]
+ }
+ lappend x $clr
+} -result [list Hello 0 "#ff9933"]
+test winDialog-1.1.4 {Tk_ChooseColorObjCmd: -title} -constraints {
+ testwinevent
+} -body {
+ set x {}
+ start {
+ set clr [tk_chooseColor -initialcolor "#ff9933" \
+ -title "\u041f\u0440\u0438\u0432\u0435\u0442"]
+ }
+ then {
+ array set a [testgetwindowinfo $::tk_dialog]
+ if {[info exists a(text)]} {lappend x $a(text)}
+ lappend x [Click 1]
+ }
+ lappend x $clr
+} -result [list "\u041f\u0440\u0438\u0432\u0435\u0442" 0 "#ff9933"]
+test winDialog-1.1.5 {Tk_ChooseColorObjCmd: -parent} -constraints {
+ testwinevent
+} -body {
+ start {set clr [tk_chooseColor -initialcolor "#ff9933" -parent .]}
+ set x {}
+ then {
+ array set a [testgetwindowinfo $::tk_dialog]
+ if {[info exists a(parent)]} {
+ append x [expr {$a(parent) == [wm frame .]}]
+ }
+ Click 1
+ }
+ list $x $clr
+} -result [list 1 "#ff9933"]
+test winDialog-1.1.6 {Tk_ChooseColorObjCmd: -parent} -constraints {
+ testwinevent
+} -body {
+ tk_chooseColor -initialcolor "#ff9933" -parent .xyzzy12
+} -returnCodes error -match glob -result {bad window path name*}
+
+test winDialog-2.1 {ColorDlgHookProc} {emptyTest nt} {
} {}
test winDialog-3.1 {Tk_GetOpenFileObjCmd} {nt testwinevent} {
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index ec6ede9..06cceb2 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.50 2008/01/31 23:31:02 hobbs Exp $
+ * RCS: @(#) $Id: tkWinDialog.c,v 1.50.2.1 2008/04/14 20:59:51 patthoyts Exp $
*
*/
@@ -455,13 +455,15 @@ ColorDlgHookProc(
const char *title;
CHOOSECOLOR *ccPtr;
- switch (uMsg) {
+ if (WM_INITDIALOG == uMsg) {
+
/*
* Set the title string of the dialog.
*/
ccPtr = (CHOOSECOLOR *) lParam;
title = (const char *) ccPtr->lCustData;
+
if ((title != NULL) && (title[0] != '\0')) {
Tcl_DString ds;
diff --git a/win/tkWinTest.c b/win/tkWinTest.c
index 57792ec..95b5336 100644
--- a/win/tkWinTest.c
+++ b/win/tkWinTest.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinTest.c,v 1.14 2007/12/13 15:28:56 dgp Exp $
+ * RCS: @(#) $Id: tkWinTest.c,v 1.14.2.1 2008/04/14 20:59:51 patthoyts Exp $
*/
#include "tkWinInt.h"
@@ -466,6 +466,9 @@ TestgetwindowinfoObjCmd(
Tcl_ListObjAppendElement(interp, resObj, Tcl_NewStringObj("text", -1));
Tcl_ListObjAppendElement(interp, resObj, textObj);
+ Tcl_ListObjAppendElement(interp, resObj, Tcl_NewStringObj("parent", -1));
+ Tcl_ListObjAppendElement(interp, resObj,
+ Tcl_NewLongObj((long)GetParent(hwnd)));
childrenObj = Tcl_NewListObj(0, NULL);
EnumChildWindows(hwnd, EnumChildrenProc, (LPARAM)childrenObj);