diff options
-rw-r--r-- | ChangeLog | 54 | ||||
-rw-r--r-- | changes | 10 | ||||
-rw-r--r-- | doc/GetClrmap.3 | 22 | ||||
-rw-r--r-- | doc/TkInitStubs.3 | 4 | ||||
-rw-r--r-- | doc/ttk_style.n | 6 | ||||
-rw-r--r-- | generic/tkEvent.c | 128 | ||||
-rw-r--r-- | generic/tkInt.h | 18 | ||||
-rw-r--r-- | generic/tkStubLib.c | 12 | ||||
-rw-r--r-- | library/demos/goldberg.tcl | 1486 | ||||
-rw-r--r-- | tests/wm.test | 1830 | ||||
-rw-r--r-- | unix/Makefile.in | 10 | ||||
-rw-r--r-- | unix/tcl.m4 | 4 | ||||
-rw-r--r-- | unix/tkConfig.h.in | 3 | ||||
-rw-r--r-- | unix/tkUnixCursor.c | 6 | ||||
-rw-r--r-- | unix/tkUnixEvent.c | 118 | ||||
-rw-r--r-- | unix/tkUnixKey.c | 73 | ||||
-rw-r--r-- | win/Makefile.in | 7 | ||||
-rw-r--r-- | win/makefile.vc | 7 |
18 files changed, 1948 insertions, 1850 deletions
@@ -1,7 +1,45 @@ +2008-03-26 Don Porter <dgp@users.sourceforge.net> + + * changes: Updates for 8.5.2 release. + + * unix/tkUnixCursor.c: Stop crash in [. configure -cursor] on X11. + Thanks to emiliano gavilán. [Bug 1922466] + +2008-03-26 Joe English <jenglish@users.sourceforge.net> + + * generic/tkInt.h, generic/tkEvent.c, unix/tkUnixEvent.c, + unix/tkUnixKey.c: XIM reorganization and cleanup; see + [Patch 1919791] for details. + +2008-03-21 Joe English <jenglish@users.sourceforge.net> + + * generic/tk.decls, generic/ttk/ttkStubLib.c, unix/Makefile.in: + Keep ttkStubLib.o in libtkstub instead of libtk. [Bug 1920030] + +2008-03-20 Donal K. Fellows <dkf@users.sf.net> + + * tests/wm.test: Rewrote so that tests clean up after themselves + rather than leaving that to the following test. Makes it easier to + catch problems where they originate. Inspired by [Bug 1852338] + +2008-03-19 Donal K. Fellows <dkf@users.sf.net> + + * doc/GetClrmap.3: Documented Tk_PreserveColormap. [Bug 220809] + +2008-03-17 Joe English <jenglish@users.sourceforge.net> + + * unix/Makefile.in, win/Makefile.in, win/makefile.vc: Put ttkStubLib.o + in libtkstub instead of libtk. [Bug 1863007] + +2008-03-16 Donal K. Fellows <dkf@users.sf.net> + + * library/demos/goldberg.tcl: Made work when run twice in the same + session. [Bug 1899664] Also made the control panel use Ttk widgets. + 2008-03-13 Daniel Steffen <das@users.sourceforge.net> - * unix/configure.in: use backslash-quoting instead of double-quoting - * unix/tcl.m4: for lib paths in tkConfig.sh [Bug 1913622]. + * unix/configure.in: Use backslash-quoting instead of double-quoting + * unix/tcl.m4: for lib paths in tkConfig.sh. [Bug 1913622] * unix/configure: autoconf-2.59 2008-03-13 Don Porter <dgp@users.sourceforge.net> @@ -10,7 +48,7 @@ 2008-03-12 Daniel Steffen <das@users.sourceforge.net> - * macosx/Wish.xcodeproj/project.pbxproj: add support for Xcode 3.1 + * macosx/Wish.xcodeproj/project.pbxproj: Add support for Xcode 3.1 * macosx/Wish.xcodeproj/default.pbxuser: CODE_SIGN_IDENTITY and * macosx/Wish-Common.xcconfig: 'xcodebuild install'. @@ -24,13 +62,13 @@ * library/demos/knightstour.tcl: Aqua GOOBE. * library/demos/widget: - * macosx/Wish.xcodeproj/project.pbxproj: add support for Xcode 3.1 and + * macosx/Wish.xcodeproj/project.pbxproj: Add support for Xcode 3.1 and * macosx/Wish.xcodeproj/default.pbxuser: targets for building with * macosx/Wish-Common.xcconfig: gcc-4.2 and llvm-gcc-4.2. - * generic/tkCanvUtil.c: fix gcc-4.2 warnings. + * generic/tkCanvUtil.c: Fix gcc-4.2 warnings. - * macosx/GNUmakefile: fix quoting to allow paths to + * macosx/GNUmakefile: Fix quoting to allow paths to * macosx/Wish-Common.xcconfig: ${builddir}, ${INSTALL_ROOT} * unix/Makefile.in: and ${TCL_BIN_DIR} to contain * unix/configure.in: spaces. @@ -39,7 +77,7 @@ * unix/configure: autoconf-2.59 - * unix/Makefile.in (install-strip): strip non-global symbols from + * unix/Makefile.in (install-strip): Strip non-global symbols from dynamic library. 2008-03-10 Don Porter <dgp@users.sourceforge.net> @@ -53,7 +91,7 @@ 2008-03-06 Joe English <jenglish@users.sourceforge.net> * doc/ttk_notebook.n: Move "TAB IDENTIFIERS" section above "WIDGET - COMMAND" section [Bug 1882011]. + COMMAND" section. [Bug 1882011] 2008-02-29 Pat Thoyts <patthoyts@users.sourceforge.net> @@ -2,7 +2,7 @@ This file summarizes all changes made to Tk since version 1.0 was released on March 13, 1991. Changes that aren't backward compatible are marked specially. -RCS: @(#) $Id: changes,v 1.107.2.11 2008/03/13 14:57:30 dgp Exp $ +RCS: @(#) $Id: changes,v 1.107.2.12 2008/03/26 20:09:30 dgp Exp $ 3/16/91 (bug fix) Modified tkWindow.c to remove Tk's Tcl commands from the interpreter when the main window is deleted (otherwise there will @@ -6490,4 +6490,10 @@ Several documentation and release notes improvements 2008-03-12 (bug fix)[1090382] crash when GetFont() fails (jenglish) ---- Released 8.5.2, March 14, 2008 --- See ChangeLog for details --- +2008-03-13 (enhancement) support space in INSTALL_ROOT or $builddir (steffen) + +2008-03-21 (bug fix)[1863007,1920030] Export Ttk stubs table (english) + +2008-03-26 (bug fix)[1922466] crash in [. configure -cursor] (gavilán) + +--- Released 8.5.2, March 28, 2008 --- See ChangeLog for details --- diff --git a/doc/GetClrmap.3 b/doc/GetClrmap.3 index bb8bff3..1a7ccdc 100644 --- a/doc/GetClrmap.3 +++ b/doc/GetClrmap.3 @@ -5,13 +5,13 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: GetClrmap.3,v 1.4.2.1 2007/11/01 16:37:12 dgp Exp $ +'\" RCS: @(#) $Id: GetClrmap.3,v 1.4.2.2 2008/03/26 20:09:30 dgp Exp $ '\" .so man.macros .TH Tk_GetColormap 3 4.0 Tk "Tk Library Procedures" .BS .SH NAME -Tk_GetColormap, Tk_FreeColormap \- allocate and free colormaps +Tk_GetColormap, Tk_PreserveColormap, Tk_FreeColormap \- allocate and free colormaps .SH SYNOPSIS .nf \fB#include <tk.h>\fR @@ -19,6 +19,8 @@ Tk_GetColormap, Tk_FreeColormap \- allocate and free colormaps Colormap \fBTk_GetColormap(\fIinterp, tkwin, string\fB)\fR .sp +\fBTk_PreserveColormap(\fIdisplay, colormap\fB)\fR +.sp \fBTk_FreeColormap(\fIdisplay, colormap\fB)\fR .SH ARGUMENTS .AS "Colormap" colormap @@ -32,10 +34,9 @@ with the same screen and visual as \fItkwin\fR. .AP Display *display in Display for which \fIcolormap\fR was allocated. .AP Colormap colormap in -Colormap to free; must have been returned by a previous +Colormap to free or preserve; must have been returned by a previous call to \fBTk_GetColormap\fR or \fBTk_GetVisual\fR. .BE - .SH DESCRIPTION .PP These procedures are used to manage colormaps. @@ -47,13 +48,19 @@ window is returned. If \fIstring\fR does not make sense, or if it refers to a window on a different screen from \fItkwin\fR or with a different visual than \fItkwin\fR, then \fBTk_GetColormap\fR returns -\fBNone\fR and leaves an error message in \fIinterp->result\fR. +\fBNone\fR and leaves an error message in \fIinterp\fR's result. +.PP +\fBTk_PreserveColormap\fR increases the internal reference count for a +colormap previously returned by \fBTk_GetColormap\fR, which allows the +colormap to be stored in several locations without knowing which order +they will be released. .PP \fBTk_FreeColormap\fR should be called when a colormap returned by \fBTk_GetColormap\fR is no longer needed. Tk maintains a reference count for each colormap returned by \fBTk_GetColormap\fR, so there should eventually be one call to -\fBTk_FreeColormap\fR for each call to \fBTk_GetColormap\fR. +\fBTk_FreeColormap\fR for each call to \fBTk_GetColormap\fR and each +call to \fBTk_PreserveColormap\fR. When a colormap's reference count becomes zero, Tk releases the X colormap. .PP @@ -68,6 +75,5 @@ If \fBTk_GetColormap\fR is called with a \fIstring\fR value of be returned by \fBTk_GetVisual\fR; however, it can be used in other windows by calling \fBTk_GetColormap\fR with the original window's name as \fIstring\fR. - .SH KEYWORDS -colormap +colormap, visual diff --git a/doc/TkInitStubs.3 b/doc/TkInitStubs.3 index e7d93ea..93c6389 100644 --- a/doc/TkInitStubs.3 +++ b/doc/TkInitStubs.3 @@ -1,10 +1,10 @@ '\" -'\" Copyright (c) 1999 Scriptics Corportation +'\" Copyright (c) 1999 Scriptics Corporation '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: TkInitStubs.3,v 1.5.2.1 2007/11/01 16:37:13 dgp Exp $ +'\" RCS: @(#) $Id: TkInitStubs.3,v 1.5.2.2 2008/03/26 20:09:31 dgp Exp $ '\" .so man.macros .TH Tk_InitStubs 3 8.4 Tk "Tk Library Procedures" diff --git a/doc/ttk_style.n b/doc/ttk_style.n index c9aae75..f145126 100644 --- a/doc/ttk_style.n +++ b/doc/ttk_style.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: ttk_style.n,v 1.3.2.5 2007/12/13 06:28:47 dgp Exp $ +'\" RCS: @(#) $Id: ttk_style.n,v 1.3.2.6 2008/03/26 20:09:31 dgp Exp $ '\" .so man.macros .TH ttk::style n 8.5 Tk "Tk Themed Widget" @@ -58,7 +58,7 @@ for style \fIstyle\fR. .TP \fBttk::style element create\fR \fIelementName\fR \fItype\fR ?\fIargs...\fR? Creates a new element in the current theme of type \fItype\fR. -The only built-in element type is \fIimage\fR (see \fIimage(n)\fR), +The only built-in element type is \fIimage\fR (see \fBttk_image\fR(n)), although themes may define other element types (see \fBTtk_RegisterElementFactory\fR). .TP @@ -117,6 +117,6 @@ ttk::style layout Horizontal.TScrollbar { } .CE .SH "SEE ALSO" -ttk::intro(n), ttk::widget(n), photo(n) +ttk::intro(n), ttk::widget(n), photo(n), ttk_image(n) .SH KEYWORDS style, theme, appearance diff --git a/generic/tkEvent.c b/generic/tkEvent.c index fda8ac9..7a52490 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkEvent.c,v 1.34 2006/11/24 18:04:14 jenglish Exp $ + * RCS: @(#) $Id: tkEvent.c,v 1.34.2.1 2008/03/26 20:09:31 dgp Exp $ */ #include "tkInt.h" @@ -210,9 +210,7 @@ static void UpdateButtonEventState(XEvent *eventPtr); static int WindowEventProc(Tcl_Event *evPtr, int flags); #ifdef TK_USE_INPUT_METHODS static int InvokeInputMethods(TkWindow *winPtr, XEvent *eventPtr); -#if TK_XIM_SPOT -static void CreateXIMSpotMethods(TkWindow *winPtr); -#endif /* TK_XIM_SPOT */ +static void CreateXIC(TkWindow *winPtr); #endif /* TK_USE_INPUT_METHODS */ /* @@ -319,69 +317,52 @@ InvokeMouseHandlers( /* *---------------------------------------------------------------------- * - * CreateXIMSpotMethods -- + * CreateXIC -- * - * Create the X input methods for our winPtr. XIM is only ever enabled on - * Unix. - * - * Results: - * None. - * - * Side effects: - * An input context is created or we Tcl_Panic. + * Create the X input context for our winPtr. + * XIM is only ever enabled on Unix. * *---------------------------------------------------------------------- */ -#if defined(TK_USE_INPUT_METHODS) && TK_XIM_SPOT +#if defined(TK_USE_INPUT_METHODS) static void -CreateXIMSpotMethods( +CreateXIC( TkWindow *winPtr) { TkDisplay *dispPtr = winPtr->dispPtr; + long im_event_mask = 0L; + const char *preedit_attname = NULL; + XVaNestedList preedit_attlist = NULL; - if (dispPtr->flags & TK_DISPLAY_XIM_SPOT) { - XVaNestedList preedit_attr; + if (dispPtr->inputStyle & XIMPreeditPosition) { XPoint spot = {0, 0}; - if (dispPtr->inputXfs == NULL) { - /* - * We only need to create one XFontSet - */ + preedit_attname = XNPreeditAttributes; + preedit_attlist = XVaCreateNestedList(0, + XNSpotLocation, &spot, + XNFontSet, dispPtr->inputXfs, + NULL); + } - char **missing_list; - int missing_count; - char *def_string; + winPtr->inputContext = XCreateIC(dispPtr->inputMethod, + XNInputStyle, dispPtr->inputStyle, + XNClientWindow, winPtr->window, + XNFocusWindow, winPtr->window, + preedit_attname, preedit_attlist, + NULL); - dispPtr->inputXfs = XCreateFontSet(dispPtr->display, - "-*-*-*-R-Normal--14-130-75-75-*-*", - &missing_list, &missing_count, &def_string); - if (missing_count > 0) { - XFreeStringList(missing_list); - } - } + if (preedit_attlist) { + XFree(preedit_attlist); + } - preedit_attr = XVaCreateNestedList(0, XNSpotLocation, - &spot, XNFontSet, dispPtr->inputXfs, NULL); - if (winPtr->inputContext != NULL) { - Tcl_Panic("inputContext not NULL"); - } - winPtr->inputContext = XCreateIC(dispPtr->inputMethod, - XNInputStyle, XIMPreeditPosition|XIMStatusNothing, - XNClientWindow, winPtr->window, - XNFocusWindow, winPtr->window, - XNPreeditAttributes, preedit_attr, - NULL); - XFree(preedit_attr); - } else { - if (winPtr->inputContext != NULL) { - Tcl_Panic("inputContext not NULL"); - } - winPtr->inputContext = XCreateIC(dispPtr->inputMethod, - XNInputStyle, XIMPreeditNothing|XIMStatusNothing, - XNClientWindow, winPtr->window, - XNFocusWindow, winPtr->window, - NULL); + /* + * Adjust the window's event mask if the IM requires it. + */ + XGetICValues(winPtr->inputContext, XNFilterEvents, &im_event_mask, NULL); + if ((winPtr->atts.event_mask & im_event_mask) != im_event_mask) { + winPtr->atts.event_mask |= im_event_mask; + XSelectInput(winPtr->display, winPtr->window, winPtr->atts.event_mask); } } #endif @@ -397,8 +378,7 @@ CreateXIMSpotMethods( * context). * * When the event is a FocusIn event, set the input context focus to the - * receiving window. This is needed for certain versions of Solaris, but - * we are still not sure whether it is being done in the right way. + * receiving window. * * Results: * 1 when we are done with the event. @@ -419,38 +399,24 @@ InvokeInputMethods( TkDisplay *dispPtr = winPtr->dispPtr; if ((dispPtr->flags & TK_DISPLAY_USE_IM)) { - long im_event_mask = 0L; if (!(winPtr->flags & (TK_CHECKED_IC|TK_ALREADY_DEAD))) { winPtr->flags |= TK_CHECKED_IC; if (dispPtr->inputMethod != NULL) { -#if TK_XIM_SPOT - CreateXIMSpotMethods(winPtr); -#else - if (winPtr->inputContext != NULL) { - Tcl_Panic("inputContext not NULL"); - } - winPtr->inputContext = XCreateIC(dispPtr->inputMethod, - XNInputStyle, XIMPreeditNothing|XIMStatusNothing, - XNClientWindow, winPtr->window, - XNFocusWindow, winPtr->window, - NULL); -#endif - } - } - if (winPtr->inputContext != NULL && - (eventPtr->xany.type == FocusIn)) { - XGetICValues(winPtr->inputContext, - XNFilterEvents, &im_event_mask, NULL); - if (im_event_mask != 0L) { - XSelectInput(winPtr->display, winPtr->window, - winPtr->atts.event_mask | im_event_mask); - XSetICFocus(winPtr->inputContext); + CreateXIC(winPtr); } } - if (eventPtr->type == KeyPress || eventPtr->type == KeyRelease) { - if (XFilterEvent(eventPtr, None)) { - return 1; - } + switch (eventPtr->type) { + case FocusIn: + if (winPtr->inputContext != NULL) { + XSetICFocus(winPtr->inputContext); + } + break; + case KeyPress: + case KeyRelease: + if (XFilterEvent(eventPtr, None)) { + return 1; + } + break; } } return 0; diff --git a/generic/tkInt.h b/generic/tkInt.h index 2d4fdcb..db5643a 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -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: tkInt.h,v 1.77.2.3 2007/10/16 04:03:53 dgp Exp $ + * RCS: $Id: tkInt.h,v 1.77.2.4 2008/03/26 20:09:32 dgp Exp $ */ #ifndef _TKINT @@ -145,16 +145,6 @@ typedef struct TkCursor { } TkCursor; /* - * This defines whether we should try to use XIM over-the-spot style input. - * Allow users to override it. It is a much more elegant use of XIM, but uses - * a bit more memory. - */ - -#ifndef TK_XIM_SPOT -#define TK_XIM_SPOT 1 -#endif - -/* * The following structure is kept one-per-TkDisplay to maintain information * about the caret (cursor location) on this display. This is used to dictate * global focus location (Windows Accessibility guidelines) and to position @@ -530,9 +520,8 @@ typedef struct TkDisplay { #ifdef TK_USE_INPUT_METHODS XIM inputMethod; /* Input method for this display. */ -#if TK_XIM_SPOT + XIMStyle inputStyle; /* Input style selected for this display. */ XFontSet inputXfs; /* XFontSet cached for over-the-spot XIM. */ -#endif #endif /* TK_USE_INPUT_METHODS */ Tcl_HashTable winTable; /* Maps from X window ids to TkWindow ptrs. */ @@ -572,8 +561,6 @@ typedef struct TkDisplay { * Indicates that we should collapse motion events on this display * TK_DISPLAY_USE_IM: (default on, set via tk.tcl) * Whether to use input methods for this display - * TK_DISPLAY_XIM_SPOT: (default off) - * Indicates that we should use over-the-spot XIM on this display * TK_DISPLAY_WM_TRACING: (default off) * Whether we should do wm tracing on this display. * TK_DISPLAY_IN_WARP: (default off) @@ -582,7 +569,6 @@ typedef struct TkDisplay { #define TK_DISPLAY_COLLAPSE_MOTION_EVENTS (1 << 0) #define TK_DISPLAY_USE_IM (1 << 1) -#define TK_DISPLAY_XIM_SPOT (1 << 2) #define TK_DISPLAY_WM_TRACING (1 << 3) #define TK_DISPLAY_IN_WARP (1 << 4) diff --git a/generic/tkStubLib.c b/generic/tkStubLib.c index 54491ff..76ae4e3 100644 --- a/generic/tkStubLib.c +++ b/generic/tkStubLib.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkStubLib.c,v 1.14.2.3 2007/09/19 17:28:22 dgp Exp $ + * RCS: @(#) $Id: tkStubLib.c,v 1.14.2.4 2008/03/26 20:09:32 dgp Exp $ */ /* @@ -48,11 +48,11 @@ #include "tkPlatDecls.h" #include "tkIntXlibDecls.h" -TkStubs *tkStubsPtr; -TkPlatStubs *tkPlatStubsPtr; -TkIntStubs *tkIntStubsPtr; -TkIntPlatStubs *tkIntPlatStubsPtr; -TkIntXlibStubs *tkIntXlibStubsPtr; +TkStubs *tkStubsPtr = NULL; +TkPlatStubs *tkPlatStubsPtr = NULL; +TkIntStubs *tkIntStubsPtr = NULL; +TkIntPlatStubs *tkIntPlatStubsPtr = NULL; +TkIntXlibStubs *tkIntXlibStubsPtr = NULL; /* * Use our own isdigit to avoid linking to libc on windows diff --git a/library/demos/goldberg.tcl b/library/demos/goldberg.tcl index 8daa73e..284b5c2 100644 --- a/library/demos/goldberg.tcl +++ b/library/demos/goldberg.tcl @@ -50,20 +50,21 @@ wm iconname $w "goldberg" wm resizable $w 0 0 #positionWindow $w -label $w.msg -font {Arial 10} -wraplength 4i -justify left -text "This is a demonstration of just how complex you can make your animations become. Click the ball to start things moving!\n\n\"Man will always find a difficult means to perform a simple task\"\n - Rube Goldberg" +label $w.msg -font {Arial 10} -wraplength 4i -justify left -text "This is a\ + demonstration of just how complex you can make your animations\ + become. Click the ball to start things moving!\n\n\"Man will always\ + find a difficult means to perform a simple task\"\n - Rube Goldberg" pack $w.msg -side top -if 0 { -## See Code / Dismiss buttons -set btns [addSeeDismiss $w.buttons $w] -pack $btns -side bottom -fill x -} - +###--- End of Boilerplate ---### # Ensure that this this is an array array set animationCallbacks {} - -###--- End of Boilerplate ---### +bind $w <Destroy> { + if {"%W" eq [winfo toplevel %W]} { + unset S C speed + } +} set S(title) "Tk Goldberg" set S(speed) 5 @@ -79,27 +80,28 @@ set C(fg) black set C(bg) gray75 set C(bg) cornflowerblue -set C(0) white; set C(1a) darkgreen; set C(1b) yellow -set C(2) red; set C(3a) green; set C(3b) darkblue -set C(4) $C(fg); set C(5a) brown; set C(5b) white -set C(6) magenta; set C(7) green; set C(8) $C(fg) -set C(9) blue4; set C(10a) white; set C(10b) cyan -set C(11a) yellow; set C(11b) mediumblue; set C(12) tan2 -set C(13a) yellow; set C(13b) red; set C(14) white -set C(15a) green; set C(15b) yellow; set C(16) gray65 -set C(17) \#A65353; set C(18) $C(fg); set C(19) gray50 -set C(20) cyan; set C(21) gray65; set C(22) $C(20) -set C(23a) blue; set C(23b) red; set C(23c) yellow -set C(24a) red; set C(24b) white; - -proc DoDisplay {} { - global S C w - - frame $w.ctrl -relief ridge -bd 2 -padx 5 -pady 5 - pack [frame $w.screen -bd 2 -relief raised] -side left -fill both -expand 1 +set C(0) white; set C(1a) darkgreen; set C(1b) yellow +set C(2) red; set C(3a) green; set C(3b) darkblue +set C(4) $C(fg); set C(5a) brown; set C(5b) white +set C(6) magenta; set C(7) green; set C(8) $C(fg) +set C(9) blue4; set C(10a) white; set C(10b) cyan +set C(11a) yellow; set C(11b) mediumblue; set C(12) tan2 +set C(13a) yellow; set C(13b) red; set C(14) white +set C(15a) green; set C(15b) yellow; set C(16) gray65 +set C(17) \#A65353; set C(18) $C(fg); set C(19) gray50 +set C(20) cyan; set C(21) gray65; set C(22) $C(20) +set C(23a) blue; set C(23b) red; set C(23c) yellow +set C(24a) red; set C(24b) white; + +proc DoDisplay {w} { + global S C + + ttk::frame $w.ctrl -relief ridge -borderwidth 2 -padding 5 + pack [frame $w.screen -bd 2 -relief raised] \ + -side left -fill both -expand 1 canvas $w.c -width 860 -height 730 -bg $C(bg) -highlightthickness 0 - $w.c config -scrollregion {0 0 1000 1000} ;# Kludge to move everything up + $w.c config -scrollregion {0 0 1000 1000} ;# Kludge: move everything up $w.c yview moveto .05 pack $w.c -in $w.screen -side top -fill both -expand 1 @@ -108,181 +110,223 @@ proc DoDisplay {} { after cancel $animationCallbacks(goldberg) unset animationCallbacks(goldberg) } - DoCtrlFrame - DoDetailFrame - button $w.show -text ">>" -command ShowCtrl -bg $C(bg) -activebackground $C(bg) + DoCtrlFrame $w + DoDetailFrame $w + if {[tk windowingsystem] ne "aqua"} { + ttk::button $w.show -text "\u00bb" -command [list ShowCtrl $w] -width 2 + } else { + button $w.show -text "\u00bb" -command [list ShowCtrl $w] -width 2 -highlightbackground $C(bg) + } place $w.show -in $w.c -relx 1 -rely 0 -anchor ne update } -proc DoCtrlFrame {} { - global w - button $w.start -text "Start" -bd 6 -command {DoButton 0} - $w.start configure -font "[font actual [$w.start cget -font]] -weight bold" - set font [$w.start cget -font] - checkbutton $w.pause -text "Pause" -font $font \ - -command {DoButton 1} -variable S(pause) -relief raised - button $w.step -text "Single Step" -font $font -command {DoButton 2} - button $w.bstep -text "Big Step" -font $font -command {DoButton 4} - button $w.reset -text "Reset" -font $font -command {DoButton 3} - frame $w.details -bd 2 -relief ridge - checkbutton $w.detail -text "Details" -font $font -variable S(details) - - entry $w.message -textvariable S(message) -justify center - scale $w.speed -orient h -from 1 -to 10 -font $font \ - -variable S(speed) -bd 2 -relief ridge -showvalue 0 - button $w.about -text About -command About -font $font + +proc DoCtrlFrame {w} { + global S + ttk::button $w.start -text "Start" -command [list DoButton $w 0] + ttk::checkbutton $w.pause -text "Pause" -command [list DoButton $w 1] \ + -variable S(pause) + ttk::button $w.step -text "Single Step" -command [list DoButton $w 2] + ttk::button $w.bstep -text "Big Step" -command [list DoButton $w 4] + ttk::button $w.reset -text "Reset" -command [list DoButton $w 3] + ttk::labelframe $w.details + raise $w.details + set S(details) 0 + ttk::checkbutton $w.details.cb -text "Details" -variable S(details) + ttk::labelframe $w.message -text "Message" + ttk::entry $w.message.e -textvariable S(message) -justify center + ttk::labelframe $w.speed -text "Speed: 0" + ttk::scale $w.speed.scale -orient h -from 1 -to 10 -variable S(speed) + ttk::button $w.about -text About -command [list About $w] grid $w.start -in $w.ctrl -row 0 -sticky ew grid rowconfigure $w.ctrl 1 -minsize 10 grid $w.pause -in $w.ctrl -row 2 -sticky ew - grid $w.step -in $w.ctrl -sticky ew - grid $w.bstep -in $w.ctrl -sticky ew - grid $w.reset -in $w.ctrl -sticky ew - grid rowconfigure $w.ctrl 10 -minsize 20 + grid $w.step -in $w.ctrl -sticky ew -pady 2 + grid $w.bstep -in $w.ctrl -sticky ew + grid $w.reset -in $w.ctrl -sticky ew -pady 2 + grid rowconfigure $w.ctrl 10 -minsize 18 grid $w.details -in $w.ctrl -row 11 -sticky ew - grid $w.detail -in $w.details -row 0 -sticky ew + grid rowconfigure $w.ctrl 11 -minsize 20 + $w.details configure -labelwidget $w.details.cb + grid [ttk::frame $w.details.b -height 1] ;# Work around minor bug + raise $w.details + raise $w.details.cb grid rowconfigure $w.ctrl 50 -weight 1 - trace variable ::S(mode) w ActiveGUI - trace variable ::S(details) w ActiveGUI - trace variable ::S(speed) w ActiveGUI + trace variable ::S(mode) w [list ActiveGUI $w] + trace variable ::S(details) w [list ActiveGUI $w] + trace variable ::S(speed) w [list ActiveGUI $w] grid $w.message -in $w.ctrl -row 98 -sticky ew -pady 5 - grid $w.speed -in $w.ctrl -row 99 -sticky ew + grid $w.message.e -sticky nsew + grid $w.speed -in $w.ctrl -row 99 -sticky ew -pady {0 5} + pack $w.speed.scale -fill both -expand 1 grid $w.about -in $w.ctrl -row 100 -sticky ew - bind $w.reset <3> {set S(mode) -1} ;# Debugging + bind $w.reset <3> {set S(mode) -1} ;# Debugging + + ## See Code / Dismiss buttons hack! + set btns [addSeeDismiss $w.ctrl.buttons $w] + grid [ttk::separator $w.ctrl.sep] -sticky ew -pady 4 + set i 0 + foreach b [winfo children $btns] { + if {[winfo class $b] eq "TButton"} { + grid [set b2 [ttk::button $w.ctrl.b[incr i]]] -sticky ew + foreach b3 [$b configure] { + set b3 [lindex $b3 0] + # Some options are read-only; ignore those errors + catch {$b2 configure $b3 [$b cget $b3]} + } + } + } + destroy $btns } -proc DoDetailFrame {} { - global w + +proc DoDetailFrame {w} { set w2 $w.details.f - frame $w2 + ttk::frame $w2 set bd 2 - set rel solid - label $w2.l -textvariable S(cnt) -bd 1 -relief $rel -bg white + ttk::label $w2.l -textvariable S(cnt) -background white grid $w2.l - - - -sticky ew -row 0 for {set i 1} {1} {incr i} { - if {[info procs "Move$i"] == {}} break - label $w2.l$i -text $i -anchor e -width 2 -bd 1 -relief $rel -bg white - label $w2.ll$i -textvariable STEP($i) -width 5 -bd 1 -relief $rel -bg white - set row [expr {($i + 1) / 2}] - set col [expr {(($i + 1) & 1) * 2}] - grid $w2.l$i -sticky ew -row $row -column $col - grid $w2.ll$i -sticky ew -row $row -column [incr col] + if {[info procs "Move$i"] eq ""} break + ttk::label $w2.l$i -text $i -anchor e -width 2 -background white + ttk::label $w2.ll$i -textvariable STEP($i) -width 5 -background white + set row [expr {($i + 1) / 2}] + set col [expr {(($i + 1) & 1) * 2}] + grid $w2.l$i -sticky ew -row $row -column $col + grid $w2.ll$i -sticky ew -row $row -column [incr col] } grid columnconfigure $w2 1 -weight 1 } + # Map or unmap the ctrl window -proc ShowCtrl {} { - global w +proc ShowCtrl {w} { if {[winfo ismapped $w.ctrl]} { - pack forget $w.ctrl - $w.show config -text ">>" + pack forget $w.ctrl + $w.show config -text "\u00bb" } else { - pack $w.ctrl -side right -fill both -ipady 5 - $w.show config -text "<<" + pack $w.ctrl -side right -fill both -ipady 5 + $w.show config -text "\u00ab" } } -proc DrawAll {} { - global w + +proc DrawAll {w} { ResetStep $w.c delete all for {set i 0} {1} {incr i} { - set p "Draw$i" - if {[info procs $p] == {}} break - $p + set p "Draw$i" + if {[info procs $p] eq ""} break + $p $w } } -proc ActiveGUI {var1 var2 op} { - global S w + +proc ActiveGUI {w var1 var2 op} { + global S MGO MSTART MDONE array set z {0 disabled 1 normal} set m $S(mode) set S(pause) [expr {$m == 2}] - $w.start config -state $z([expr {$m != $::MGO}]) - $w.pause config -state $z([expr {$m != $::MSTART && $m != $::MDONE}]) - $w.step config -state $z([expr {$m != $::MGO && $m != $::MDONE}]) - $w.bstep config -state $z([expr {$m != $::MGO && $m != $::MDONE}]) - $w.reset config -state $z([expr {$m != $::MSTART}]) + $w.start config -state $z([expr {$m != $MGO}]) + $w.pause config -state $z([expr {$m != $MSTART && $m != $MDONE}]) + $w.step config -state $z([expr {$m != $MGO && $m != $MDONE}]) + $w.bstep config -state $z([expr {$m != $MGO && $m != $MDONE}]) + $w.reset config -state $z([expr {$m != $MSTART}]) if {$S(details)} { - grid $w.details.f -in $w.details -row 2 -sticky ew + grid $w.details.f -sticky ew } else { - grid forget $w.details.f + grid forget $w.details.f } - $w.speed config -label "Speed: $S(speed)" + set S(speed) [expr {round($S(speed))}] + $w.speed config -text "Speed: $S(speed)" } + proc Start {} { - global S - set S(mode) $::MGO + global S MGO + set S(mode) $MGO } -proc DoButton {what} { - global S - if {$what == 0} { ;# Start - if {$S(mode) == $::MDONE} Reset - set S(mode) $::MGO - } elseif {$what == 1} { ;# Pause - set S(mode) [expr {$S(pause) ? $::MPAUSE : $::MGO}] - } elseif {$what == 2} { ;# Step - set S(mode) $::MSSTEP - } elseif {$what == 3} { ;# Reset - Reset - } elseif {$what == 4} { ;# Big step - set S(mode) $::MBSTEP +proc DoButton {w what} { + global S MDONE MGO MSSTEP MBSTEP MPAUSE + + if {$what == 0} { ;# Start + if {$S(mode) == $MDONE} { + Reset $w + } + set S(mode) $MGO + } elseif {$what == 1} { ;# Pause + set S(mode) [expr {$S(pause) ? $MPAUSE : $MGO}] + } elseif {$what == 2} { ;# Step + set S(mode) $MSSTEP + } elseif {$what == 3} { ;# Reset + Reset $w + } elseif {$what == 4} { ;# Big step + set S(mode) $MBSTEP } } -proc Go {{who {}}} { - global S speed animationCallbacks + +proc Go {w {who {}}} { + global S speed animationCallbacks MGO MPAUSE MSSTEP MBSTEP set now [clock clicks -milliseconds] catch {after cancel $animationCallbacks(goldberg)} - if {$who != {}} { ;# Start here for debugging - set S(active) $who; - set S(mode) $::MGO + if {$who ne ""} { ;# Start here for debugging + set S(active) $who; + set S(mode) $MGO } - if {$S(mode) == -1} return ;# Debugging + if {$S(mode) == -1} return ;# Debugging set n 0 - if {$S(mode) != $::MPAUSE} { ;# Not paused - set n [NextStep] ;# Do the next move + if {$S(mode) != $MPAUSE} { ;# Not paused + set n [NextStep $w] ;# Do the next move + } + if {$S(mode) == $MSSTEP} { ;# Single step + set S(mode) $MPAUSE + } + if {$S(mode) == $MBSTEP && $n} { ;# Big step + set S(mode) $MSSTEP } - if {$S(mode) == $::MSSTEP} {set S(mode) $::MPAUSE} ;# Single step - if {$S(mode) == $::MBSTEP && $n} {set S(mode) $::MSSTEP} ;# Big step set elapsed [expr {[clock click -milliseconds] - $now}] set delay [expr {$speed($S(speed)) - $elapsed}] - if {$delay <= 0} { set delay 1} - set animationCallbacks(goldberg) [after $delay Go] + if {$delay <= 0} { + set delay 1 + } + set animationCallbacks(goldberg) [after $delay [list Go $w]] } + # NextStep: drives the next step of the animation -proc NextStep {} { - global S - set rval 0 ;# Return value +proc NextStep {w} { + global S MSTART MDONE + set rval 0 ;# Return value - if {$S(mode) != $::MSTART && $S(mode) != $::MDONE} { incr S(cnt) } + if {$S(mode) != $MSTART && $S(mode) != $MDONE} { + incr S(cnt) + } set alive {} foreach {who} $S(active) { - set n ["Move$who"] - if {$n & 1} { ;# This guy still alive - lappend alive $who - } - if {$n & 2} { ;# Next guy is active - lappend alive [expr {$who + 1}] - set rval 1 - } - if {$n & 4} { ;# End of puzzle flag - set S(mode) $::MDONE ;# Done mode - set S(active) {} ;# No more animation - return 1 - } + set n ["Move$who" $w] + if {$n & 1} { ;# This guy still alive + lappend alive $who + } + if {$n & 2} { ;# Next guy is active + lappend alive [expr {$who + 1}] + set rval 1 + } + if {$n & 4} { ;# End of puzzle flag + set S(mode) $MDONE ;# Done mode + set S(active) {} ;# No more animation + return 1 + } } set S(active) $alive return $rval } -proc About {} { - set msg "$::S(title)\nby Keith Vetter, March 2003\n(Reproduced by kind permission of the author)\n\n" - append msg "Man will always find a difficult means to perform a simple task" - append msg "\nRube Goldberg" - tk_messageBox -message $msg -title About +proc About {w} { + set msg "$::S(title)\nby Keith Vetter, March 2003\n(Reproduced by kind\ + permission of the author)\n\n\"Man will always find a difficult\ + means to perform a simple task.\"\nRube Goldberg" + tk_messageBox -parent $w -message $msg -title About } ################################################################ # @@ -290,8 +334,7 @@ proc About {} { # # START HERE! banner -proc Draw0 {} { - global w +proc Draw0 {w} { set color $::C(0) set xy {579 119} $w.c create text $xy -text "START HERE!" -fill $color -anchor w \ @@ -301,12 +344,12 @@ proc Draw0 {} { -arrowshape {18 18 5} $w.c bind I0 <1> Start } -proc Move0 {{step {}}} { +proc Move0 {w {step {}}} { set step [GetStep 0 $step] - if {$::S(mode) > $::MSTART} { ;# Start the ball rolling - MoveAbs I0 {-100 -100} ;# Hide the banner - return 2 + if {$::S(mode) > $::MSTART} { ;# Start the ball rolling + MoveAbs $w I0 {-100 -100} ;# Hide the banner + return 2 } set pos { @@ -314,12 +357,12 @@ proc Move0 {{step {}}} { {693 119} {688 119} {683 119} {678 119} } set step [expr {$step % [llength $pos]}] - MoveAbs I0 [lindex $pos $step] + MoveAbs $w I0 [lindex $pos $step] return 1 } + # Dropping ball -proc Draw1 {} { - global w +proc Draw1 {w} { set color $::C(1a) set color2 $::C(1b) set xy {844 133 800 133 800 346 820 346 820 168 844 168 844 133} @@ -331,60 +374,61 @@ proc Draw1 {} { $w.c create oval $xy -tag I1 -fill $color2 -outline {} $w.c bind I1 <1> Start } -proc Move1 {{step {}}} { +proc Move1 {w {step {}}} { set step [GetStep 1 $step] set pos { {807 122} {802 122} {797 123} {793 124} {789 129} {785 153} - {785 203} {785 278 x} {785 367} {810 392} {816 438} {821 503} - {824 585 y} {838 587} {848 593} {857 601} {-100 -100} + {785 203} {785 278 x} {785 367} {810 392} {816 438} {821 503} + {824 585 y} {838 587} {848 593} {857 601} {-100 -100} } if {$step >= [llength $pos]} { return 0 } set where [lindex $pos $step] - MoveAbs I1 $where + MoveAbs $w I1 $where - if {[lindex $where 2] == "y"} { - Move15a + if {[lindex $where 2] eq "y"} { + Move15a $w } - if {[lindex $where 2] == "x"} { + if {[lindex $where 2] eq "x"} { return 3 } return 1 } + # Lighting the match -proc Draw2 {} { - global w +proc Draw2 {w} { set color red set color $::C(2) - set xy {750 369 740 392 760 392} ;# Fulcrum + set xy {750 369 740 392 760 392} ;# Fulcrum $w.c create poly $xy -fill $::C(fg) -outline $::C(fg) - set xy {628 335 660 383} ;# Strike box + set xy {628 335 660 383} ;# Strike box $w.c create rect $xy -fill {} -outline $::C(fg) for {set y 0} {$y < 3} {incr y} { - set yy [expr {335+$y*16}] - $w.c create bitmap 628 $yy -bitmap gray25 -anchor nw -foreground $::C(fg) - $w.c create bitmap 644 $yy -bitmap gray25 -anchor nw -foreground $::C(fg) + set yy [expr {335+$y*16}] + $w.c create bitmap 628 $yy -bitmap gray25 -anchor nw \ + -foreground $::C(fg) + $w.c create bitmap 644 $yy -bitmap gray25 -anchor nw \ + -foreground $::C(fg) } - set xy {702 366 798 366} ;# Lever + set xy {702 366 798 366} ;# Lever $w.c create line $xy -fill $::C(fg) -width 6 -tag I2_0 - set xy {712 363 712 355} ;# R strap + set xy {712 363 712 355} ;# R strap $w.c create line $xy -fill $::C(fg) -width 3 -tag I2_1 - set xy {705 363 705 355} ;# L strap + set xy {705 363 705 355} ;# L strap $w.c create line $xy -fill $::C(fg) -width 3 -tag I2_2 - set xy {679 356 679 360 717 360 717 356 679 356} ;# Match stick + set xy {679 356 679 360 717 360 717 356 679 356} ;# Match stick $w.c create line $xy -fill $::C(fg) -tag I2_3 - #set xy {662 352 680 365} ;# Match head + #set xy {662 352 680 365} ;# Match head set xy { 671 352 677.4 353.9 680 358.5 677.4 363.1 671 365 664.6 363.1 - 662 358.5 664.6 353.9 + 662 358.5 664.6 353.9 } $w.c create poly $xy -fill $color -outline $color -tag I2_4 } -proc Move2 {{step {}}} { - global w +proc Move2 {w {step {}}} { set step [GetStep 2 $step] set stages {0 0 1 2 0 2 1 0 1 2 0 2 1} @@ -403,64 +447,67 @@ proc Move2 {{step {}}} { return 0 } - if {$step == 0} { ;# Rotate the match - set beta 20 - foreach {Ox Oy} [Anchor I2_0 s] break ;# Where to pivot - for {set i 0} {[$w.c find withtag I2_$i] != {}} {incr i} { - RotateItem I2_$i $Ox $Oy $beta - } - $w.c create poly -tag I2 -smooth 1 -fill $::C(2) ;# For the flame - return 1 + if {$step == 0} { ;# Rotate the match + set beta 20 + lassign [Anchor $w I2_0 s] Ox Oy ;# Where to pivot + for {set i 0} {[$w.c find withtag I2_$i] ne ""} {incr i} { + RotateItem $w I2_$i $Ox $Oy $beta + } + $w.c create poly -tag I2 -smooth 1 -fill $::C(2) ;# For the flame + return 1 } $w.c coords I2 $xy([lindex $stages $step]) return [expr {$step == 7 ? 3 : 1}] } + # Weight and pulleys -proc Draw3 {} { - global w +proc Draw3 {w} { set color $::C(3a) set color2 $::C(3b) set xy {602 296 577 174 518 174} - foreach {x y} $xy { ;# 3 Pulleys - $w.c create oval [box $x $y 13] -fill $color -outline $::C(fg) -width 3 - $w.c create oval [box $x $y 2] -fill $::C(fg) -outline $::C(fg) + foreach {x y} $xy { ;# 3 Pulleys + $w.c create oval [box $x $y 13] -fill $color -outline $::C(fg) \ + -width 3 + $w.c create oval [box $x $y 2] -fill $::C(fg) -outline $::C(fg) } - set xy {750 309 670 309} ;# Wall to flame + set xy {750 309 670 309} ;# Wall to flame $w.c create line $xy -tag I3_s -width 3 -fill $::C(fg) -smooth 1 - set xy {670 309 650 309} ;# Flame to pulley 1 + set xy {670 309 650 309} ;# Flame to pulley 1 $w.c create line $xy -tag I3_0 -width 3 -fill $::C(fg) - set xy {650 309 600 309} ;# Flame to pulley 1 + set xy {650 309 600 309} ;# Flame to pulley 1 $w.c create line $xy -tag I3_1 -width 3 -fill $::C(fg) - set xy {589 296 589 235} ;# Pulley 1 half way to 2 + set xy {589 296 589 235} ;# Pulley 1 half way to 2 $w.c create line $xy -tag I3_2 -width 3 -fill $::C(fg) - set xy {589 235 589 174} ;# Pulley 1 other half to 2 + set xy {589 235 589 174} ;# Pulley 1 other half to 2 $w.c create line $xy -width 3 -fill $::C(fg) - set xy {577 161 518 161} ;# Across the top + set xy {577 161 518 161} ;# Across the top $w.c create line $xy -width 3 -fill $::C(fg) - set xy {505 174 505 205} ;# Down to weight + set xy {505 174 505 205} ;# Down to weight $w.c create line $xy -tag I3_w -width 3 -fill $::C(fg) # Draw the weight as 2 circles, two rectangles and 1 rounded rectangle set xy {515 207 495 207} foreach {x1 y1 x2 y2} $xy { - $w.c create oval [box $x1 $y1 6] -tag I3_ -fill $color2 -outline $color2 - $w.c create oval [box $x2 $y2 6] -tag I3_ -fill $color2 -outline $color2 - incr y1 -6; incr y2 6 - $w.c create rect $x1 $y1 $x2 $y2 -tag I3_ -fill $color2 -outline $color2 + $w.c create oval [box $x1 $y1 6] -tag I3_ -fill $color2 \ + -outline $color2 + $w.c create oval [box $x2 $y2 6] -tag I3_ -fill $color2 \ + -outline $color2 + incr y1 -6; incr y2 6 + $w.c create rect $x1 $y1 $x2 $y2 -tag I3_ -fill $color2 \ + -outline $color2 } set xy {492 220 518 263} - set xy [RoundRect $xy 15] + set xy [RoundRect $w $xy 15] $w.c create poly $xy -smooth 1 -tag I3_ -fill $color2 -outline $color2 set xy {500 217 511 217} $w.c create line $xy -tag I3_ -fill $color2 -width 10 - set xy {502 393 522 393 522 465} ;# Bottom weight target + set xy {502 393 522 393 522 465} ;# Bottom weight target $w.c create line $xy -tag I3__ -fill $::C(fg) -join miter -width 10 } -proc Move3 {{step {}}} { - global w +proc Move3 {w {step {}}} { set step [GetStep 3 $step] set pos {{505 247} {505 297} {505 386.5} {505 386.5}} @@ -469,51 +516,53 @@ proc Move3 {{step {}}} { set rope(2) {750 309 737 309 740 343 736 351 725 340} set rope(3) {750 309 738 321 746 345 742 356} - if {$step >= [llength $pos]} {return 0} + if {$step >= [llength $pos]} { + return 0 + } - $w.c delete "I3_$step" ;# Delete part of the rope - MoveAbs I3_ [lindex $pos $step] ;# Move weight down - $w.c coords I3_s $rope($step) ;# Flapping rope end + $w.c delete "I3_$step" ;# Delete part of the rope + MoveAbs $w I3_ [lindex $pos $step] ;# Move weight down + $w.c coords I3_s $rope($step) ;# Flapping rope end $w.c coords I3_w [concat 505 174 [lindex $pos $step]] if {$step == 2} { - $w.c move I3__ 0 30 - return 2 + $w.c move I3__ 0 30 + return 2 } return 1 } + # Cage and door -proc Draw4 {} { - global w +proc Draw4 {w} { set color $::C(4) - set xy {527 356 611 464} - foreach {x0 y0 x1 y1} $xy break + lassign {527 356 611 464} x0 y0 x1 y1 - for {set y $y0} {$y <= $y1} {incr y 12} { ;# Horizontal bars - $w.c create line $x0 $y $x1 $y -fill $color -width 1 + for {set y $y0} {$y <= $y1} {incr y 12} { ;# Horizontal bars + $w.c create line $x0 $y $x1 $y -fill $color -width 1 } - for {set x $x0} {$x <= $x1} {incr x 12} { ;# Vertical bars - $w.c create line $x $y0 $x $y1 -fill $color -width 1 + for {set x $x0} {$x <= $x1} {incr x 12} { ;# Vertical bars + $w.c create line $x $y0 $x $y1 -fill $color -width 1 } - set xy {518 464 518 428} ;# Swing gate + set xy {518 464 518 428} ;# Swing gate $w.c create line $xy -tag I4 -fill $color -width 3 } -proc Move4 {{step {}}} { - global w +proc Move4 {w {step {}}} { set step [GetStep 4 $step] set angles {-10 -20 -30 -30} - if {$step >= [llength $angles]} {return 0} - RotateItem I4 518 464 [lindex $angles $step] + if {$step >= [llength $angles]} { + return 0 + } + RotateItem $w I4 518 464 [lindex $angles $step] $w.c raise I4 return [expr {$step == 3 ? 3 : 1}] } + # Mouse -proc Draw5 {} { - global w +proc Draw5 {w} { set color $::C(5a) set color2 $::C(5b) - set xy {377 248 410 248 410 465 518 465} ;# Mouse course + set xy {377 248 410 248 410 465 518 465} ;# Mouse course lappend xy 518 428 451 428 451 212 377 212 $w.c create poly $xy -fill $color2 -outline $::C(fg) -width 3 @@ -522,52 +571,55 @@ proc Draw5 {} { 566 456 554 456 545 456 537 454 530 452 } $w.c create poly $xy -tag {I5 I5_0} -fill $color - set xy {573 452 592 458 601 460 613 456} ;# Tail + set xy {573 452 592 458 601 460 613 456} ;# Tail $w.c create line $xy -tag {I5 I5_1} -fill $color -smooth 1 -width 3 - set xy [box 540 446 2] ;# Eye + set xy [box 540 446 2] ;# Eye set xy {540 444 541 445 541 447 540 448 538 447 538 445} #.c create oval $xy -tag {I5 I5_2} -fill $::C(bg) -outline {} $w.c create poly $xy -tag {I5 I5_2} -fill $::C(bg) -outline {} -smooth 1 - set xy {538 454 535 461} ;# Front leg + set xy {538 454 535 461} ;# Front leg $w.c create line $xy -tag {I5 I5_3} -fill $color -width 2 - set xy {566 455 569 462} ;# Back leg + set xy {566 455 569 462} ;# Back leg $w.c create line $xy -tag {I5 I5_4} -fill $color -width 2 - set xy {544 455 545 460} ;# 2nd front leg + set xy {544 455 545 460} ;# 2nd front leg $w.c create line $xy -tag {I5 I5_5} -fill $color -width 2 - set xy {560 455 558 460} ;# 2nd back leg - $w.c create line $xy -tag {I5 I5_6} -fill $color -width 2 + set xy {560 455 558 460} ;# 2nd back leg + $w.c create line $xy -tag {I5 I5_6} -fill $color -width 2 } -proc Move5 {{step {}}} { +proc Move5 {w {step {}}} { set step [GetStep 5 $step] set pos { {553 452} {533 452} {513 452} {493 452} {473 452} - {463 442 30} {445.5 441.5 30} {425.5 434.5 30} {422 414} {422 394} - {422 374} {422 354} {422 334} {422 314} {422 294} - {422 274 -30} {422 260.5 -30 x} {422.5 248.5 -28} {425 237} + {463 442 30} {445.5 441.5 30} {425.5 434.5 30} {422 414} {422 394} + {422 374} {422 354} {422 334} {422 314} {422 294} + {422 274 -30} {422 260.5 -30 x} {422.5 248.5 -28} {425 237} } if {$step >= [llength $pos]} { return 0 } - foreach {x y beta next} [lindex $pos $step] break - MoveAbs I5 [list $x $y] - if {$beta != {}} { - foreach {Ox Oy} [Centroid I5_0] break - foreach id {0 1 2 3 4 5 6} { - RotateItem I5_$id $Ox $Oy $beta - } + lassign [lindex $pos $step] x y beta next + MoveAbs $w I5 [list $x $y] + if {$beta ne ""} { + lassign [Centroid $w I5_0] Ox Oy + foreach id {0 1 2 3 4 5 6} { + RotateItem $w I5_$id $Ox $Oy $beta + } + } + if {$next eq "x"} { + return 3 } - if {$next == "x"} {return 3} return 1 } + # Dropping gumballs array set XY6 { -1 {366 207} -2 {349 204} -3 {359 193} -4 {375 192} -5 {340 190} -6 {349 177} -7 {366 177} -8 {380 176} -9 {332 172} -10 {342 161} -11 {357 164} -12 {372 163} -13 {381 149} -14 {364 151} -15 {349 146} -16 {333 148} 0 {357 219} - 1 {359 261} 2 {359 291} 3 {359 318} 4 {361 324} 5 {365 329} 6 {367 334} + 1 {359 261} 2 {359 291} 3 {359 318} 4 {361 324} 5 {365 329} 6 {367 334} 7 {367 340} 8 {366 346} 9 {364 350} 10 {361 355} 11 {359 370} 12 {359 391} 13,0 {360 456} 13,1 {376 456} 13,2 {346 456} 13,3 {330 456} 13,4 {353 444} 13,5 {368 443} 13,6 {339 442} 13,7 {359 431} @@ -575,170 +627,173 @@ array set XY6 { 13,12 {331 420} 13,13 {360 417} 13,14 {345 412} 13,15 {376 410} 13,16 {360 403} } - -proc Draw6 {} { - global w +proc Draw6 {w} { set color $::C(6) - set xy {324 130 391 204} ;# Ball holder - set xy [RoundRect $xy 10] + set xy {324 130 391 204} ;# Ball holder + set xy [RoundRect $w $xy 10] $w.c create poly $xy -smooth 1 -outline $::C(fg) -width 3 -fill $color - set xy {339 204 376 253} ;# Below the ball holder - $w.c create rect $xy -fill {} -outline $::C(fg) -width 3 -fill $color -tag I6c + set xy {339 204 376 253} ;# Below the ball holder + $w.c create rect $xy -fill {} -outline $::C(fg) -width 3 -fill $color \ + -tag I6c set xy [box 346 339 28] - $w.c create oval $xy -fill $color -outline {} ;# Rotor + $w.c create oval $xy -fill $color -outline {} ;# Rotor $w.c create arc $xy -outline $::C(fg) -width 2 -style arc \ -start 80 -extent 205 $w.c create arc $xy -outline $::C(fg) -width 2 -style arc \ -start -41 -extent 85 - set xy [box 346 339 15] ;# Center of rotor + set xy [box 346 339 15] ;# Center of rotor $w.c create oval $xy -outline $::C(fg) -fill $::C(fg) -tag I6m - set xy {352 312 352 254 368 254 368 322} ;# Top drop to rotor + set xy {352 312 352 254 368 254 368 322} ;# Top drop to rotor $w.c create poly $xy -fill $color -outline {} $w.c create line $xy -fill $::C(fg) -width 2 - set xy {353 240 367 300} ;# Poke bottom hole + set xy {353 240 367 300} ;# Poke bottom hole $w.c create rect $xy -fill $color -outline {} - set xy {341 190 375 210} ;# Poke another hole + set xy {341 190 375 210} ;# Poke another hole $w.c create rect $xy -fill $color -outline {} set xy {368 356 368 403 389 403 389 464 320 464 320 403 352 403 352 366} - $w.c create poly $xy -fill $color -outline {} -width 2 ;# Below rotor + $w.c create poly $xy -fill $color -outline {} -width 2 ;# Below rotor $w.c create line $xy -fill $::C(fg) -width 2 - set xy [box 275 342 7] ;# On/off rotor + set xy [box 275 342 7] ;# On/off rotor $w.c create oval $xy -outline $::C(fg) -fill $::C(fg) - set xy {276 334 342 325} ;# Fan belt top + set xy {276 334 342 325} ;# Fan belt top $w.c create line $xy -fill $::C(fg) -width 3 - set xy {276 349 342 353} ;# Fan belt bottom + set xy {276 349 342 353} ;# Fan belt bottom $w.c create line $xy -fill $::C(fg) -width 3 - set xy {337 212 337 247} ;# What the mouse pushes + set xy {337 212 337 247} ;# What the mouse pushes $w.c create line $xy -fill $::C(fg) -width 3 -tag I6_ set xy {392 212 392 247} $w.c create line $xy -fill $::C(fg) -width 3 -tag I6_ set xy {337 230 392 230} $w.c create line $xy -fill $::C(fg) -width 7 -tag I6_ - set who -1 ;# All the balls + set who -1 ;# All the balls set colors {red cyan orange green blue darkblue} - eval lappend colors $colors $colors + lappend colors {*}$colors {*}$colors for {set i 0} {$i < 17} {incr i} { - set loc [expr {-1 * $i}] - set color [lindex $colors $i] - $w.c create oval [eval box $::XY6($loc) 5] -fill $color \ + set loc [expr {-1 * $i}] + set color [lindex $colors $i] + $w.c create oval [box {*}$::XY6($loc) 5] -fill $color \ -outline $color -tag I6_b$i } - Draw6a 12 ;# The wheel + Draw6a $w 12 ;# The wheel } -proc Draw6a {beta} { - global w +proc Draw6a {w beta} { $w.c delete I6_0 - foreach {Ox Oy} {346 339} break + lassign {346 339} Ox Oy for {set i 0} {$i < 4} {incr i} { - set b [expr {$beta + $i * 45}] - foreach {x y} [RotateC 28 0 0 0 $b] break - set xy [list [expr {$Ox+$x}] [expr {$Oy+$y}] \ + set b [expr {$beta + $i * 45}] + lassign [RotateC 28 0 0 0 $b] x y + set xy [list [expr {$Ox+$x}] [expr {$Oy+$y}] \ [expr {$Ox-$x}] [expr {$Oy-$y}]] - $w.c create line $xy -tag I6_0 -fill $::C(fg) -width 2 + $w.c create line $xy -tag I6_0 -fill $::C(fg) -width 2 } } -proc Move6 {{step {}}} { - global w +proc Move6 {w {step {}}} { set step [GetStep 6 $step] - if {$step > 62} {return 0} + if {$step > 62} { + return 0 + } - if {$step < 2} { ;# Open gate for balls to drop - $w.c move I6_ -7 0 - if {$step == 1} { ;# Poke a hole - set xy {348 226 365 240} - $w.c create rect $xy -fill [$w.c itemcget I6c -fill] -outline {} - } - return 1 + if {$step < 2} { ;# Open gate for balls to drop + $w.c move I6_ -7 0 + if {$step == 1} { ;# Poke a hole + set xy {348 226 365 240} + $w.c create rect $xy -fill [$w.c itemcget I6c -fill] -outline {} + } + return 1 } - set s [expr {$step - 1}] ;# Do the gumball drop dance + set s [expr {$step - 1}] ;# Do the gumball drop dance for {set i 0} {$i <= int(($s-1) / 3)} {incr i} { - set tag "I6_b$i" - if {[$w.c find withtag $tag] == {}} break - set loc [expr {$s - 3 * $i}] - - if {[info exists ::XY6($loc,$i)]} { - MoveAbs $tag $::XY6($loc,$i) - } elseif {[info exists ::XY6($loc)]} { - MoveAbs $tag $::XY6($loc) - } + set tag "I6_b$i" + if {[$w.c find withtag $tag] eq ""} break + set loc [expr {$s - 3 * $i}] + + if {[info exists ::XY6($loc,$i)]} { + MoveAbs $w $tag $::XY6($loc,$i) + } elseif {[info exists ::XY6($loc)]} { + MoveAbs $w $tag $::XY6($loc) + } } if {($s % 3) == 1} { - set first [expr {($s + 2) / 3}] - for {set i $first} {1} {incr i} { - set tag "I6_b$i" - if {[$w.c find withtag $tag] == {}} break - set loc [expr {$first - $i}] - MoveAbs $tag $::XY6($loc) - } - } - if {$s >= 3} { ;# Rotate the motor - set idx [expr {$s % 3}] - #Draw6a [lindex {12 35 64} $idx] - Draw6a [expr {12 + $s * 15}] + set first [expr {($s + 2) / 3}] + for {set i $first} {1} {incr i} { + set tag "I6_b$i" + if {[$w.c find withtag $tag] eq ""} break + set loc [expr {$first - $i}] + MoveAbs $w $tag $::XY6($loc) + } + } + if {$s >= 3} { ;# Rotate the motor + set idx [expr {$s % 3}] + #Draw6a $w [lindex {12 35 64} $idx] + Draw6a $w [expr {12 + $s * 15}] } return [expr {$s == 3 ? 3 : 1}] } + # On/off switch -proc Draw7 {} { - global w +proc Draw7 {w} { set color $::C(7) - set xy {198 306 277 374} ;# Box + set xy {198 306 277 374} ;# Box $w.c create rect $xy -outline $::C(fg) -width 2 -fill $color -tag I7z $w.c lower I7z set xy {275 343 230 349} $w.c create line $xy -tag I7 -fill $::C(fg) -arrow last \ -arrowshape {23 23 8} -width 6 - set xy {225 324} ;# On button - $w.c create oval [eval box $xy 3] -fill $::C(fg) -outline $::C(fg) - set xy {218 323} ;# On text + set xy {225 324} ;# On button + $w.c create oval [box {*}$xy 3] -fill $::C(fg) -outline $::C(fg) + set xy {218 323} ;# On text set font {{Times Roman} 8} $w.c create text $xy -text "on" -anchor e -fill $::C(fg) -font $font - set xy {225 350} ;# Off button - $w.c create oval [eval box $xy 3] -fill $::C(fg) -outline $::C(fg) - set xy {218 349} ;# Off button + set xy {225 350} ;# Off button + $w.c create oval [box {*}$xy 3] -fill $::C(fg) -outline $::C(fg) + set xy {218 349} ;# Off button $w.c create text $xy -text "off" -anchor e -fill $::C(fg) -font $font } -proc Move7 {{step {}}} { +proc Move7 {w {step {}}} { set step [GetStep 7 $step] set numsteps 30 - if {$step > $numsteps} {return 0} + if {$step > $numsteps} { + return 0 + } set beta [expr {30.0 / $numsteps}] - RotateItem I7 275 343 $beta + RotateItem $w I7 275 343 $beta return [expr {$step == $numsteps ? 3 : 1}] } + # Electricity to the fan -proc Draw8 {} { - Sine 271 248 271 306 5 8 -tag I8_s -fill $::C(8) -width 3 +proc Draw8 {w} { + Sine $w 271 248 271 306 5 8 -tag I8_s -fill $::C(8) -width 3 } -proc Move8 {{step {}}} { - global w +proc Move8 {w {step {}}} { set step [GetStep 8 $step] - if {$step > 3} {return 0} + if {$step > 3} { + return 0 + } if {$step == 0} { - Sparkle [Anchor I8_s s] I8 - return 1 + Sparkle $w [Anchor $w I8_s s] I8 + return 1 } elseif {$step == 1} { - MoveAbs I8 [Anchor I8_s c] + MoveAbs $w I8 [Anchor $w I8_s c] } elseif {$step == 2} { - MoveAbs I8 [Anchor I8_s n] + MoveAbs $w I8 [Anchor $w I8_s n] } else { - $w.c delete I8 + $w.c delete I8 } return [expr {$step == 2 ? 3 : 1}] } + # Fan -proc Draw9 {} { - global w +proc Draw9 {w} { set color $::C(9) set xy {266 194 310 220} $w.c create oval $xy -outline $color -fill $color @@ -747,10 +802,10 @@ proc Draw9 {} { set xy {288 249 252 249 260 240 280 234 296 234 316 240 324 249 288 249} $w.c create poly $xy -fill $color -smooth 1 - set xy {248 205 265 214 264 205 265 196} ;# Spinner + set xy {248 205 265 214 264 205 265 196} ;# Spinner $w.c create poly $xy -fill $color - set xy {255 206 265 234} ;# Fan blades + set xy {255 206 265 234} ;# Fan blades $w.c create oval $xy -fill {} -outline $::C(fg) -width 3 -tag I9_0 set xy {255 176 265 204} $w.c create oval $xy -fill {} -outline $::C(fg) -width 3 -tag I9_0 @@ -759,54 +814,55 @@ proc Draw9 {} { set xy {255 190 265 204} $w.c create oval $xy -fill {} -outline $::C(fg) -width 1 -tag I9_1 } -proc Move9 {{step {}}} { - global w +proc Move9 {w {step {}}} { set step [GetStep 9 $step] if {$step & 1} { - $w.c itemconfig I9_0 -width 4 - $w.c itemconfig I9_1 -width 1 - $w.c lower I9_1 I9_0 + $w.c itemconfig I9_0 -width 4 + $w.c itemconfig I9_1 -width 1 + $w.c lower I9_1 I9_0 } else { - $w.c itemconfig I9_0 -width 1 - $w.c itemconfig I9_1 -width 4 - $w.c lower I9_0 I9_1 + $w.c itemconfig I9_0 -width 1 + $w.c itemconfig I9_1 -width 4 + $w.c lower I9_0 I9_1 + } + if {$step == 0} { + return 3 } - if {$step == 0} {return 3} return 1 } + # Boat -proc Draw10 {} { - global w +proc Draw10 {w} { set color $::C(10a) set color2 $::C(10b) - set xy {191 230 233 230 233 178 191 178} ;# Sail + set xy {191 230 233 230 233 178 191 178} ;# Sail $w.c create poly $xy -fill $color -width 3 -outline $::C(fg) -tag I10 - set xy [box 209 204 31] ;# Front + set xy [box 209 204 31] ;# Front $w.c create arc $xy -outline {} -fill $color -style pie \ -start 120 -extent 120 -tag I10 $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \ -start 120 -extent 120 -tag I10 - set xy [box 249 204 31] ;# Back + set xy [box 249 204 31] ;# Back $w.c create arc $xy -outline {} -fill $::C(bg) -width 3 -style pie \ -start 120 -extent 120 -tag I10 $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \ -start 120 -extent 120 -tag I10 - set xy {200 171 200 249} ;# Mast + set xy {200 171 200 249} ;# Mast $w.c create line $xy -fill $::C(fg) -width 3 -tag I10 - set xy {159 234 182 234} ;# Bow sprit + set xy {159 234 182 234} ;# Bow sprit $w.c create line $xy -fill $::C(fg) -width 3 -tag I10 - set xy {180 234 180 251 220 251} ;# Hull + set xy {180 234 180 251 220 251} ;# Hull $w.c create line $xy -fill $::C(fg) -width 6 -tag I10 - set xy {92 255 221 255} ;# Waves - eval Sine $xy 2 25 -fill $color2 -width 1 -tag I10w + set xy {92 255 221 255} ;# Waves + Sine $w {*}$xy 2 25 -fill $color2 -width 1 -tag I10w - set xy [lrange [$w.c coords I10w] 4 end-4] ;# Water + set xy [lrange [$w.c coords I10w] 4 end-4] ;# Water set xy [concat $xy 222 266 222 277 99 277] $w.c create poly $xy -fill $color2 -outline $color2 - set xy {222 266 222 277 97 277 97 266} ;# Water bottom + set xy {222 266 222 277 97 277 97 266} ;# Water bottom $w.c create line $xy -fill $::C(fg) -width 3 set xy [box 239 262 17] @@ -815,94 +871,106 @@ proc Draw10 {} { set xy [box 76 266 21] $w.c create arc $xy -outline $::C(fg) -width 3 -style arc -extent 190 } -proc Move10 {{step {}}} { +proc Move10 {w {step {}}} { set step [GetStep 10 $step] set pos { {195 212} {193 212} {190 212} {186 212} {181 212} {176 212} - {171 212} {166 212} {161 212} {156 212} {151 212} {147 212} {142 212} - {137 212} {132 212 x} {127 212} {121 212} {116 212} {111 212} + {171 212} {166 212} {161 212} {156 212} {151 212} {147 212} {142 212} + {137 212} {132 212 x} {127 212} {121 212} {116 212} {111 212} } - if {$step >= [llength $pos]} {return 0} + if {$step >= [llength $pos]} { + return 0 + } set where [lindex $pos $step] - MoveAbs I10 $where + MoveAbs $w I10 $where - if {[lindex $where 2] == "x"} {return 3} + if {[lindex $where 2] eq "x"} { + return 3 + } return 1 } + # 2nd ball drop -proc Draw11 {} { - global w +proc Draw11 {w} { set color $::C(11a) set color2 $::C(11b) - set xy {23 264 55 591} ;# Color the down tube + set xy {23 264 55 591} ;# Color the down tube $w.c create rect $xy -fill $color -outline {} - set xy [box 71 460 48] ;# Color the outer loop + set xy [box 71 460 48] ;# Color the outer loop $w.c create oval $xy -fill $color -outline {} - set xy {55 264 55 458} ;# Top right side + set xy {55 264 55 458} ;# Top right side $w.c create line $xy -fill $::C(fg) -width 3 - set xy {55 504 55 591} ;# Bottom right side + set xy {55 504 55 591} ;# Bottom right side $w.c create line $xy -fill $::C(fg) -width 3 - set xy [box 71 460 48] ;# Outer loop + set xy [box 71 460 48] ;# Outer loop $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \ -start 110 -extent -290 -tag I11i - set xy [box 71 460 16] ;# Inner loop + set xy [box 71 460 16] ;# Inner loop $w.c create oval $xy -outline $::C(fg) -fill {} -width 3 -tag I11i $w.c create oval $xy -outline $::C(fg) -fill $::C(bg) -width 3 - set xy {23 264 23 591} ;# Left side + set xy {23 264 23 591} ;# Left side $w.c create line $xy -fill $::C(fg) -width 3 - set xy [box 1 266 23] ;# Top left curve + set xy [box 1 266 23] ;# Top left curve $w.c create arc $xy -outline $::C(fg) -width 3 -style arc -extent 90 - set xy [box 75 235 9] ;# The ball + set xy [box 75 235 9] ;# The ball $w.c create oval $xy -fill $color2 -outline {} -width 3 -tag I11 } -proc Move11 {{step {}}} { +proc Move11 {w {step {}}} { set step [GetStep 11 $step] set pos { {75 235} {70 235} {65 237} {56 240} {46 247} {38 266} {38 296} - {38 333} {38 399} {38 475} {74 496} {105 472} {100 437} {65 423} - {-100 -100} {38 505} {38 527 x} {38 591} + {38 333} {38 399} {38 475} {74 496} {105 472} {100 437} {65 423} + {-100 -100} {38 505} {38 527 x} {38 591} } - if {$step >= [llength $pos]} {return 0} + if {$step >= [llength $pos]} { + return 0 + } set where [lindex $pos $step] - MoveAbs I11 $where - if {[lindex $where 2] == "x"} {return 3} + MoveAbs $w I11 $where + if {[lindex $where 2] eq "x"} { + return 3 + } return 1 } + # Hand -proc Draw12 {} { - global w +proc Draw12 {w} { set xy {20 637 20 617 20 610 20 590 40 590 40 590 60 590 60 610 60 610} - lappend xy 60 610 65 620 60 631 ;# Thumb + lappend xy 60 610 65 620 60 631 ;# Thumb lappend xy 60 631 60 637 60 662 60 669 52 669 56 669 50 669 50 662 50 637 - set y0 637 ;# Bumps for fingers + set y0 637 ;# Bumps for fingers set y1 645 for {set x 50} {$x > 20} {incr x -10} { - set x1 [expr {$x - 5}] - set x2 [expr {$x - 10}] - lappend xy $x $y0 $x1 $y1 $x2 $y0 + set x1 [expr {$x - 5}] + set x2 [expr {$x - 10}] + lappend xy $x $y0 $x1 $y1 $x2 $y0 } $w.c create poly $xy -fill $::C(12) -outline $::C(fg) -smooth 1 -tag I12 \ -width 3 } -proc Move12 {{step {}}} { +proc Move12 {w {step {}}} { set step [GetStep 12 $step] set pos {{42.5 641 x}} - if {$step >= [llength $pos]} {return 0} + if {$step >= [llength $pos]} { + return 0 + } set where [lindex $pos $step] - MoveAbs I12 $where - if {[lindex $where 2] == "x"} {return 3} + MoveAbs $w I12 $where + if {[lindex $where 2] eq "x"} { + return 3 + } return 1 } + # Fax -proc Draw13 {} { - global w +proc Draw13 {w} { set color $::C(13a) set xy {86 663 149 663 149 704 50 704 50 681 64 681 86 671} set xy2 {784 663 721 663 721 704 820 704 820 681 806 681 784 671} @@ -912,51 +980,55 @@ proc Draw13 {} { RoundPoly $w.c $xy2 $radii -width 3 -outline $::C(fg) -fill $color set xy {56 677} - $w.c create rect [eval box $xy 4] -fill {} -outline $::C(fg) -width 3 -tag I13 + $w.c create rect [box {*}$xy 4] -fill {} -outline $::C(fg) -width 3 \ + -tag I13 set xy {809 677} - $w.c create rect [eval box $xy 4] -fill {} -outline $::C(fg) -width 3 -tag I13R + $w.c create rect [box {*}$xy 4] -fill {} -outline $::C(fg) -width 3 \ + -tag I13R - set xy {112 687} ;# Label - $w.c create text $xy -text "FAX" -fill $::C(fg) -font {{Times Roman} 12 bold} + set xy {112 687} ;# Label + $w.c create text $xy -text "FAX" -fill $::C(fg) \ + -font {{Times Roman} 12 bold} set xy {762 687} - $w.c create text $xy -text "FAX" -fill $::C(fg) -font {{Times Roman} 12 bold} + $w.c create text $xy -text "FAX" -fill $::C(fg) \ + -font {{Times Roman} 12 bold} - set xy {138 663 148 636 178 636} ;# Paper guide + set xy {138 663 148 636 178 636} ;# Paper guide $w.c create line $xy -smooth 1 -fill $::C(fg) -width 3 set xy {732 663 722 636 692 636} $w.c create line $xy -smooth 1 -fill $::C(fg) -width 3 - Sine 149 688 720 688 5 15 -tag I13_s -fill $::C(fg) -width 3 + Sine $w 149 688 720 688 5 15 -tag I13_s -fill $::C(fg) -width 3 } -proc Move13 {{step {}}} { - global w +proc Move13 {w {step {}}} { set step [GetStep 13 $step] set numsteps 7 if {$step == $numsteps+2} { - MoveAbs I13_star {-100 -100} - $w.c itemconfig I13R -fill $::C(13b) -width 2 - return 2 + MoveAbs $w I13_star {-100 -100} + $w.c itemconfig I13R -fill $::C(13b) -width 2 + return 2 } - if {$step == 0} { ;# Button down - $w.c delete I13 - Sparkle {-100 -100} I13_star ;# Create off screen - return 1 + if {$step == 0} { ;# Button down + $w.c delete I13 + Sparkle $w {-100 -100} I13_star ;# Create off screen + return 1 } - foreach {x0 y0} [Anchor I13_s w] {x1 y1} [Anchor I13_s e] break + lassign [Anchor $w I13_s w] x0 y0 + lassign [Anchor $w I13_s e] x1 y1 set x [expr {$x0 + ($x1-$x0) * ($step - 1) / double($numsteps)}] - MoveAbs I13_star [list $x $y0] + MoveAbs $w I13_star [list $x $y0] return 1 } + # Paper in fax -proc Draw14 {} { - global w +proc Draw14 {w} { set color $::C(14) - set xy {102 661 113 632 130 618} ;# Left paper edge + set xy {102 661 113 632 130 618} ;# Left paper edge $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14L_0 - set xy {148 629 125 640 124 662} ;# Right paper edge + set xy {148 629 125 640 124 662} ;# Right paper edge $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14L_1 - Draw14a L + Draw14a $w L set xy { 768.0 662.5 767.991316225 662.433786215 767.926187912 662.396880171 @@ -971,13 +1043,12 @@ proc Draw14 {} { $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14R_1 $w.c lower I14R_1 } -proc Draw14a {side} { - global w +proc Draw14a {w side} { set color $::C(14) set xy [$w.c coords I14${side}_0] set xy2 [$w.c coords I14${side}_1] - foreach {x0 y0 x1 y1 x2 y2} $xy break - foreach {x3 y3 x4 y4 x5 y5} $xy2 break + lassign $xy x0 y0 x1 y1 x2 y2 + lassign $xy2 x3 y3 x4 y4 x5 y5 set zz [concat \ $x0 $y0 $x0 $y0 $xy $x2 $y2 $x2 $y2 \ $x3 $y3 $x3 $y3 $xy2 $x5 $y5 $x5 $y5] @@ -986,38 +1057,37 @@ proc Draw14a {side} { -width 3 $w.c lower I14$side } -proc Move14 {{step {}}} { - global w +proc Move14 {w {step {}}} { set step [GetStep 14 $step] # Paper going down set sc [expr {.9 - .05*$step}] if {$sc < .3} { - $w.c delete I14L - return 0 + $w.c delete I14L + return 0 } - foreach {Ox Oy} [$w.c coords I14L_0] break + lassign [$w.c coords I14L_0] Ox Oy $w.c scale I14L_0 $Ox $Oy $sc $sc - foreach {Ox Oy} [lrange [$w.c coords I14L_1] end-1 end] break + lassign [lrange [$w.c coords I14L_1] end-1 end] Ox Oy $w.c scale I14L_1 $Ox $Oy $sc $sc - Draw14a L + Draw14a $w L # Paper going up set sc [expr {.35 + .05*$step}] set sc [expr {1 / $sc}] - foreach {Ox Oy} [$w.c coords I14R_0] break + lassign [$w.c coords I14R_0] Ox Oy $w.c scale I14R_0 $Ox $Oy $sc $sc - foreach {Ox Oy} [lrange [$w.c coords I14R_1] end-1 end] break + lassign [lrange [$w.c coords I14R_1] end-1 end] Ox Oy $w.c scale I14R_1 $Ox $Oy $sc $sc - Draw14a R + Draw14a $w R return [expr {$step == 10 ? 3 : 1}] } + # Light beam -proc Draw15 {} { - global w +proc Draw15 {w} { set color $::C(15a) set xy {824 599 824 585 820 585 829 585} $w.c create line $xy -fill $::C(fg) -width 3 -tag I15a @@ -1035,72 +1105,70 @@ proc Draw15 {} { set xy {765 557 784 583} $w.c create rect $xy -fill $color -outline $::C(fg) -width 2 - Sine 658 580 765 580 3 15 -tag I15_s -fill $::C(fg) -width 3 + Sine $w 658 580 765 580 3 15 -tag I15_s -fill $::C(fg) -width 3 } -proc Move15a {} { - global w +proc Move15a {w} { set color $::C(15b) - $w.c scale I15a 824 599 1 .3 ;# Button down + $w.c scale I15a 824 599 1 .3 ;# Button down set xy {765 621 681 621} $w.c create line $xy -dash "-" -width 3 -fill $color -tag I15 } -proc Move15 {{step {}}} { - global w +proc Move15 {w {step {}}} { set step [GetStep 15 $step] set numsteps 6 if {$step == $numsteps+2} { - MoveAbs I15_star {-100 -100} - return 2 + MoveAbs $w I15_star {-100 -100} + return 2 } - if {$step == 0} { ;# Break the light beam - Sparkle {-100 -100} I15_star - set xy {765 621 745 621} - $w.c coords I15 $xy - return 1 + if {$step == 0} { ;# Break the light beam + Sparkle $w {-100 -100} I15_star + set xy {765 621 745 621} + $w.c coords I15 $xy + return 1 } - foreach {x0 y0} [Anchor I15_s w] {x1 y1} [Anchor I15_s e] break + lassign [Anchor $w I15_s w] x0 y0 + lassign [Anchor $w I15_s e] x1 y1 set x [expr {$x0 + ($x1-$x0) * ($step - 1) / double($numsteps)}] - MoveAbs I15_star [list $x $y0] + MoveAbs $w I15_star [list $x $y0] return 1 } + # Bell -proc Draw16 {} { - global w +proc Draw16 {w} { set color $::C(16) set xy {722 485 791 556} $w.c create rect $xy -fill {} -outline $::C(fg) -width 3 - set xy [box 752 515 25] ;# Bell + set xy [box 752 515 25] ;# Bell $w.c create oval $xy -fill $color -outline black -tag I16b -width 2 - set xy [box 752 515 5] ;# Bell button + set xy [box 752 515 5] ;# Bell button $w.c create oval $xy -fill black -outline black -tag I16b - set xy {784 523 764 549} ;# Clapper + set xy {784 523 764 549} ;# Clapper $w.c create line $xy -width 3 -tag I16c -fill $::C(fg) set xy [box 784 523 4] $w.c create oval $xy -fill $::C(fg) -outline $::C(fg) -tag I16d } -proc Move16 {{step {}}} { - global w +proc Move16 {w {step {}}} { set step [GetStep 16 $step] # Note: we never stop - foreach {Ox Oy} {760 553} break + lassign {760 553} Ox Oy if {$step & 1} { - set beta 12 - $w.c move I16b 3 0 + set beta 12 + $w.c move I16b 3 0 } else { - set beta -12 - $w.c move I16b -3 0 + set beta -12 + $w.c move I16b -3 0 } - RotateItem I16c $Ox $Oy $beta - RotateItem I16d $Ox $Oy $beta + RotateItem $w I16c $Ox $Oy $beta + RotateItem $w I16d $Ox $Oy $beta return [expr {$step == 1 ? 3 : 1}] } + # Cat -proc Draw17 {} { - global w +proc Draw17 {w} { set color $::C(17) set xy {584 556 722 556} @@ -1108,24 +1176,24 @@ proc Draw17 {} { set xy {584 485 722 485} $w.c create line $xy -fill $::C(fg) -width 3 - set xy {664 523 717 549} ;# Body + set xy {664 523 717 549} ;# Body $w.c create arc $xy -outline $::C(fg) -fill $color -width 3 \ -style chord -start 128 -extent -260 -tag I17 - set xy {709 554 690 543} ;# Paw + set xy {709 554 690 543} ;# Paw $w.c create oval $xy -outline $::C(fg) -fill $color -width 3 -tag I17 set xy {657 544 676 555} $w.c create oval $xy -outline $::C(fg) -fill $color -width 3 -tag I17 - set xy [box 660 535 15] ;# Lower face + set xy [box 660 535 15] ;# Lower face $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \ -start 150 -extent 240 -tag I17_ $w.c create arc $xy -outline {} -fill $color -width 1 -style chord \ -start 150 -extent 240 -tag I17_ - set xy {674 529 670 513 662 521 658 521 650 513 647 529} ;# Ears + set xy {674 529 670 513 662 521 658 521 650 513 647 529} ;# Ears $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ $w.c create poly $xy -fill $color -outline {} -width 1 -tag {I17_ I17_c} - set xy {652 542 628 539} ;# Whiskers + set xy {652 542 628 539} ;# Whiskers $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ set xy {652 543 632 545} $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ @@ -1139,77 +1207,75 @@ proc Draw17 {} { set xy {668 547 688 553} $w.c create line $xy -fill $::C(fg) -width 3 -tag {I17_ I17w} - set xy {649 530 654 538 659 530} ;# Left eye + set xy {649 530 654 538 659 530} ;# Left eye $w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17 - set xy {671 530 666 538 661 530} ;# Right eye + set xy {671 530 666 538 661 530} ;# Right eye $w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17 - set xy {655 543 660 551 665 543} ;# Mouth + set xy {655 543 660 551 665 543} ;# Mouth $w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17 } -proc Move17 {{step {}}} { - global w +proc Move17 {w {step {}}} { set step [GetStep 17 $step] if {$step == 0} { - $w.c delete I17 ;# Delete most of the cat - set xy {655 543 660 535 665 543} ;# Mouth - $w.c create line $xy -fill $::C(fg) -width 3 -smooth 1 -tag I17_ - set xy [box 654 530 4] ;# Left eye - $w.c create oval $xy -outline $::C(fg) -width 3 -fill {} -tag I17_ - set xy [box 666 530 4] ;# Right eye - $w.c create oval $xy -outline $::C(fg) -width 3 -fill {} -tag I17_ - - $w.c move I17_ 0 -20 ;# Move face up - set xy {652 528 652 554} ;# Front leg - $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ - set xy {670 528 670 554} ;# 2nd front leg - $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ - - set xy { + $w.c delete I17 ;# Delete most of the cat + set xy {655 543 660 535 665 543} ;# Mouth + $w.c create line $xy -fill $::C(fg) -width 3 -smooth 1 -tag I17_ + set xy [box 654 530 4] ;# Left eye + $w.c create oval $xy -outline $::C(fg) -width 3 -fill {} -tag I17_ + set xy [box 666 530 4] ;# Right eye + $w.c create oval $xy -outline $::C(fg) -width 3 -fill {} -tag I17_ + + $w.c move I17_ 0 -20 ;# Move face up + set xy {652 528 652 554} ;# Front leg + $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ + set xy {670 528 670 554} ;# 2nd front leg + $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ + + set xy { 675 506 694 489 715 513 715 513 715 513 716 525 716 525 716 525 - 706 530 695 530 679 535 668 527 668 527 668 527 675 522 676 517 - 677 512 + 706 530 695 530 679 535 668 527 668 527 668 527 675 522 676 517 + 677 512 } ;# Body - $w.c create poly $xy -fill [$w.c itemcget I17_c -fill] \ + $w.c create poly $xy -fill [$w.c itemcget I17_c -fill] \ -outline $::C(fg) -width 3 -smooth 1 -tag I17_ - set xy {716 514 716 554} ;# Back leg - $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ - set xy {694 532 694 554} ;# 2nd back leg - $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ - set xy {715 514 718 506 719 495 716 488};# Tail - $w.c create line $xy -fill $::C(fg) -width 3 -smooth 1 -tag I17_ + set xy {716 514 716 554} ;# Back leg + $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ + set xy {694 532 694 554} ;# 2nd back leg + $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ + set xy {715 514 718 506 719 495 716 488};# Tail + $w.c create line $xy -fill $::C(fg) -width 3 -smooth 1 -tag I17_ - $w.c raise I17w ;# Make whiskers visible - $w.c move I17_ -5 0 ;# Move away from the wall a bit - return 2 + $w.c raise I17w ;# Make whiskers visible + $w.c move I17_ -5 0 ;# Move away from wall a bit + return 2 } return 0 } + # Sling shot -proc Draw18 {} { - global w +proc Draw18 {w} { set color $::C(18) - set xy {721 506 627 506} ;# Sling hold + set xy {721 506 627 506} ;# Sling hold $w.c create line $xy -width 4 -fill $::C(fg) -tag I18 - set xy {607 500 628 513} ;# Sling rock + set xy {607 500 628 513} ;# Sling rock $w.c create oval $xy -fill $color -outline {} -tag I18a - set xy {526 513 606 507 494 502} ;# Sling band + set xy {526 513 606 507 494 502} ;# Sling band $w.c create line $xy -fill $::C(fg) -width 4 -tag I18b - set xy { 485 490 510 540 510 575 510 540 535 491 } ;# Sling + set xy { 485 490 510 540 510 575 510 540 535 491 } ;# Sling $w.c create line $xy -fill $::C(fg) -width 6 } -proc Move18 {{step {}}} { - global w +proc Move18 {w {step {}}} { set step [GetStep 18 $step] set pos { {587 506} {537 506} {466 506} {376 506} {266 506 x} {136 506} - {16 506} {-100 -100} + {16 506} {-100 -100} } - set b(0) {490 502 719 507 524 512} ;# Band collapsing + set b(0) {490 502 719 507 524 512} ;# Band collapsing set b(1) { 491 503 524 557 563 505 559 496 546 506 551 525 553 536 538 534 532 519 529 499 @@ -1217,44 +1283,48 @@ proc Move18 {{step {}}} { set b(2) {491 503 508 563 542 533 551 526 561 539 549 550 530 500} set b(3) {491 503 508 563 530 554 541 562 525 568 519 544 530 501} - if {$step >= [llength $pos]} { return 0} + if {$step >= [llength $pos]} { + return 0 + } if {$step == 0} { - $w.c delete I18 - $w.c itemconfig I18b -smooth 1 + $w.c delete I18 + $w.c itemconfig I18b -smooth 1 } if {[info exists b($step)]} { - $w.c coords I18b $b($step) + $w.c coords I18b $b($step) } set where [lindex $pos $step] - MoveAbs I18a $where - if {[lindex $where 2] == "x"} {return 3} + MoveAbs $w I18a $where + if {[lindex $where 2] eq "x"} { + return 3 + } return 1 } + # Water pipe -proc Draw19 {} { - global w +proc Draw19 {w} { set color $::C(19) set xx {249 181 155 118 86 55 22 0} foreach {x1 x2} $xx { - $w.c create rect $x1 453 $x2 467 -fill $color -outline {} -tag I19 - $w.c create line $x1 453 $x2 453 -fill $::C(fg) -width 1 ;# Pipe top - $w.c create line $x1 467 $x2 467 -fill $::C(fg) -width 1 ;# Pipe bottom + $w.c create rect $x1 453 $x2 467 -fill $color -outline {} -tag I19 + $w.c create line $x1 453 $x2 453 -fill $::C(fg) -width 1;# Pipe top + $w.c create line $x1 467 $x2 467 -fill $::C(fg) -width 1;# Pipe bottom } $w.c raise I11i - set xy [box 168 460 16] ;# Bulge by the joint + set xy [box 168 460 16] ;# Bulge by the joint $w.c create oval $xy -fill $color -outline {} $w.c create arc $xy -outline $::C(fg) -width 1 -style arc \ -start 21 -extent 136 $w.c create arc $xy -outline $::C(fg) -width 1 -style arc \ -start -21 -extent -130 - set xy {249 447 255 473} ;# First joint 26x6 + set xy {249 447 255 473} ;# First joint 26x6 $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 - set xy [box 257 433 34] ;# Bend up + set xy [box 257 433 34] ;# Bend up $w.c create arc $xy -outline {} -fill $color -width 1 \ -style pie -start 0 -extent -91 $w.c create arc $xy -outline $::C(fg) -width 1 \ @@ -1264,7 +1334,7 @@ proc Draw19 {} { -style pie -start 0 -extent -92 $w.c create arc $xy -outline $::C(fg) -width 1 \ -style arc -start 0 -extent -90 - set xy [box 257 421 34] ;# Bend left + set xy [box 257 421 34] ;# Bend left $w.c create arc $xy -outline {} -fill $color -width 1 \ -style pie -start 1 -extent 91 $w.c create arc $xy -outline $::C(fg) -width 1 \ @@ -1274,7 +1344,7 @@ proc Draw19 {} { -style pie -start 0 -extent 90 $w.c create arc $xy -outline $::C(fg) -width 1 \ -style arc -start 0 -extent 90 - set xy [box 243 421 34] ;# Bend down + set xy [box 243 421 34] ;# Bend down $w.c create arc $xy -outline {} -fill $color -width 1 \ -style pie -start 90 -extent 90 $w.c create arc $xy -outline $::C(fg) -width 1 \ @@ -1285,97 +1355,106 @@ proc Draw19 {} { $w.c create arc $xy -outline $::C(fg) -width 1 \ -style arc -start 90 -extent 90 - set xy {270 427 296 433} ;# 2nd joint bottom + set xy {270 427 296 433} ;# 2nd joint bottom $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 - set xy {270 421 296 427} ;# 2nd joint top + set xy {270 421 296 427} ;# 2nd joint top $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 - set xy {249 382 255 408} ;# Third joint right + set xy {249 382 255 408} ;# Third joint right $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 - set xy {243 382 249 408} ;# Third joint left + set xy {243 382 249 408} ;# Third joint left $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 - set xy {203 420 229 426} ;# Last joint + set xy {203 420 229 426} ;# Last joint $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 - set xy [box 168 460 6] ;# Handle joint + set xy [box 168 460 6] ;# Handle joint $w.c create oval $xy -fill $::C(fg) -outline {} -tag I19a - set xy {168 460 168 512} ;# Handle bar + set xy {168 460 168 512} ;# Handle bar $w.c create line $xy -fill $::C(fg) -width 5 -tag I19b } -proc Move19 {{step {}}} { +proc Move19 {w {step {}}} { set step [GetStep 19 $step] set angles {30 30 30} - if {$step == [llength $angles]} {return 2} - - foreach {Ox Oy} [Centroid I19a] break - RotateItem I19b $Ox $Oy [lindex $angles $step] + if {$step == [llength $angles]} { + return 2 + } + RotateItem $w I19b {*}[Centroid $w I19a] [lindex $angles $step] return 1 } + # Water pouring -proc Draw20 {} { +proc Draw20 {w} { } -proc Move20 {{step {}}} { - global w +proc Move20 {w {step {}}} { set step [GetStep 20 $step] set pos {451 462 473 484 496 504 513 523 532} set freq {20 40 40 40 40 40 40 40 40} set pos { {451 20} {462 40} {473 40} {484 40} {496 40} {504 40} {513 40} - {523 40} {532 40 x} + {523 40} {532 40 x} + } + if {$step >= [llength $pos]} { + return 0 } - if {$step >= [llength $pos]} {return 0} $w.c delete I20 set where [lindex $pos $step] - foreach {y f} $where break - H2O $y $f - if {[lindex $where 2] == "x"} {return 3} + lassign $where y f + H2O $w $y $f + if {[lindex $where 2] eq "x"} { + return 3 + } return 1 } -proc H2O {y f} { - global w +proc H2O {w y f} { set color $::C(20) $w.c delete I20 - Sine 208 428 208 $y 4 $f -tag {I20 I20s} -width 3 -fill $color -smooth 1 - $w.c create line [$w.c coords I20s] -width 3 -fill $color -smooth 1 -tag {I20 I20a} - $w.c create line [$w.c coords I20s] -width 3 -fill $color -smooth 1 -tag {I20 I20b} + Sine $w 208 428 208 $y 4 $f -tag {I20 I20s} -width 3 -fill $color \ + -smooth 1 + $w.c create line [$w.c coords I20s] -width 3 -fill $color -smooth 1 \ + -tag {I20 I20a} + $w.c create line [$w.c coords I20s] -width 3 -fill $color -smooth 1 \ + -tag {I20 I20b} $w.c move I20a 8 0 $w.c move I20b 16 0 } + # Bucket -proc Draw21 {} { - global w +proc Draw21 {w} { set color $::C(21) - set xy {217 451 244 490} ;# Right handle + set xy {217 451 244 490} ;# Right handle $w.c create line $xy -fill $::C(fg) -width 2 -tag I21_a - set xy {201 467 182 490} ;# Left handle + set xy {201 467 182 490} ;# Left handle $w.c create line $xy -fill $::C(fg) -width 2 -tag I21_a - set xy {245 490 237 535} ;# Right side - set xy2 {189 535 181 490} ;# Left side - $w.c create poly [concat $xy $xy2] -fill $color -outline {} -tag {I21 I21f} + set xy {245 490 237 535} ;# Right side + set xy2 {189 535 181 490} ;# Left side + $w.c create poly [concat $xy $xy2] -fill $color -outline {} \ + -tag {I21 I21f} $w.c create line $xy -fill $::C(fg) -width 2 -tag I21 $w.c create line $xy2 -fill $::C(fg) -width 2 -tag I21 - set xy {182 486 244 498} ;# Top + set xy {182 486 244 498} ;# Top $w.c create oval $xy -fill $color -outline {} -width 2 -tag {I21 I21f} $w.c create oval $xy -fill {} -outline $::C(fg) -width 2 -tag {I21 I21t} - set xy {189 532 237 540} ;# Bottom - $w.c create oval $xy -fill $color -outline $::C(fg) -width 2 -tag {I21 I21b} + set xy {189 532 237 540} ;# Bottom + $w.c create oval $xy -fill $color -outline $::C(fg) -width 2 \ + -tag {I21 I21b} } -proc Move21 {{step {}}} { - global w +proc Move21 {w {step {}}} { set step [GetStep 21 $step] set numsteps 30 - if {$step >= $numsteps} {return 0} + if {$step >= $numsteps} { + return 0 + } - foreach {x1 y1 x2 y2} [$w.c coords I21b] break - #foreach {X1 Y1 X2 Y2} [$w.c coords I21t] break - foreach {X1 Y1 X2 Y2} {183 492 243 504} break + lassign [$w.c coords I21b] x1 y1 x2 y2 + #lassign [$w.c coords I21t] X1 Y1 X2 Y2 + lassign {183 492 243 504} X1 Y1 X2 Y2 set f [expr {$step / double($numsteps)}] set y2 [expr {$y2 - 3}] @@ -1383,7 +1462,7 @@ proc Move21 {{step {}}} { set yy1 [expr {$y1 + ($Y1 - $y1) * $f}] set xx2 [expr {$x2 + ($X2 - $x2) * $f}] set yy2 [expr {$y2 + ($Y2 - $y2) * $f}] - #H2O $yy1 40 + #H2O $w $yy1 40 $w.c itemconfig I21b -fill $::C(20) $w.c delete I21w @@ -1395,81 +1474,88 @@ proc Move21 {{step {}}} { return [expr {$step == $numsteps-1 ? 3 : 1}] } + # Bucket drop -proc Draw22 {} { +proc Draw22 {w} { } -proc Move22 {{step {}}} { - global w +proc Move22 {w {step {}}} { set step [GetStep 22 $step] set pos {{213 513} {213 523} {213 543 x} {213 583} {213 593}} if {$step == 0} {$w.c itemconfig I21f -fill $::C(22)} - if {$step >= [llength $pos]} {return 0} + if {$step >= [llength $pos]} { + return 0 + } set where [lindex $pos $step] - MoveAbs I21 $where - H2O [lindex $where 1] 40 - $w.c delete I21_a ;# Delete handles + MoveAbs $w I21 $where + H2O $w [lindex $where 1] 40 + $w.c delete I21_a ;# Delete handles - if {[lindex $where 2] == "x"} {return 3} + if {[lindex $where 2] eq "x"} { + return 3 + } return 1 } + # Blow dart -proc Draw23 {} { - global w +proc Draw23 {w} { set color $::C(23a) set color2 $::C(23b) set color3 $::C(23c) - set xy {185 623 253 650} ;# Block + set xy {185 623 253 650} ;# Block $w.c create rect $xy -fill black -outline $::C(fg) -width 2 -tag I23a - set xy {187 592 241 623} ;# Balloon + set xy {187 592 241 623} ;# Balloon $w.c create oval $xy -outline {} -fill $color -tag I23b $w.c create arc $xy -outline $::C(fg) -width 3 -tag I23b \ -style arc -start 12 -extent 336 - set xy {239 604 258 589 258 625 239 610} ;# Balloon nozzle + set xy {239 604 258 589 258 625 239 610} ;# Balloon nozzle $w.c create poly $xy -outline {} -fill $color -tag I23b $w.c create line $xy -fill $::C(fg) -width 3 -tag I23b - set xy {285 611 250 603} ;# Dart body + set xy {285 611 250 603} ;# Dart body $w.c create oval $xy -fill $color2 -outline $::C(fg) -width 3 -tag I23d - set xy {249 596 249 618 264 607 249 596} ;# Dart tail + set xy {249 596 249 618 264 607 249 596} ;# Dart tail $w.c create poly $xy -fill $color3 -outline $::C(fg) -width 3 -tag I23d - set xy {249 607 268 607} ;# Dart detail + set xy {249 607 268 607} ;# Dart detail $w.c create line $xy -fill $::C(fg) -width 3 -tag I23d - set xy {285 607 305 607} ;# Dart needle + set xy {285 607 305 607} ;# Dart needle $w.c create line $xy -fill $::C(fg) -width 3 -tag I23d } -proc Move23 {{step {}}} { - global w +proc Move23 {w {step {}}} { set step [GetStep 23 $step] set pos { {277 607} {287 607} {307 607 x} {347 607} {407 607} {487 607} - {587 607} {687 607} {787 607} {-100 -100} + {587 607} {687 607} {787 607} {-100 -100} } - if {$step >= [llength $pos]} {return 0} + if {$step >= [llength $pos]} { + return 0 + } if {$step <= 1} { - eval $w.c scale I23b [Anchor I23a n] .9 .5 + $w.c scale I23b {*}[Anchor $w I23a n] .9 .5 } set where [lindex $pos $step] - MoveAbs I23d $where + MoveAbs $w I23d $where - if {[lindex $where 2] == "x"} {return 3} + if {[lindex $where 2] eq "x"} { + return 3 + } return 1 } + # Balloon -proc Draw24 {} { - global w +proc Draw24 {w} { set color $::C(24a) - set xy {366 518 462 665} ;# Balloon + set xy {366 518 462 665} ;# Balloon $w.c create oval $xy -fill $color -outline $::C(fg) -width 3 -tag I24 - set xy {414 666 414 729} ;# String + set xy {414 666 414 729} ;# String $w.c create line $xy -fill $::C(fg) -width 3 -tag I24 - set xy {410 666 404 673 422 673 418 666} ;# Nozzle + set xy {410 666 404 673 422 673 418 666} ;# Nozzle $w.c create poly $xy -fill $color -outline $::C(fg) -width 3 -tag I24 - set xy {387 567 390 549 404 542} ;# Reflections + set xy {387 567 390 549 404 542} ;# Reflections $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24 set xy {395 568 399 554 413 547} $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24 @@ -1478,60 +1564,67 @@ proc Draw24 {} { set xy {408 564 402 547 386 545} $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24 } -proc Move24 {{step {}}} { - global S w +proc Move24 {w {step {}}} { + global S set step [GetStep 24 $step] - if {$step > 4} {return 0} - if {$step == 4} {return 2} + if {$step > 4} { + return 0 + } elseif {$step == 4} { + return 2 + } if {$step == 0} { - $w.c delete I24 ;# Exploding balloon - set xy { + $w.c delete I24 ;# Exploding balloon + set xy { 347 465 361 557 271 503 272 503 342 574 259 594 259 593 362 626 320 737 320 740 398 691 436 738 436 739 476 679 528 701 527 702 494 627 548 613 548 613 480 574 577 473 577 473 474 538 445 508 431 441 431 440 400 502 347 465 347 465 } - $w.c create poly $xy -tag I24 -fill $::C(24b) -outline $::C(24a) \ + $w.c create poly $xy -tag I24 -fill $::C(24b) -outline $::C(24a) \ -width 10 -smooth 1 - set msg [subst $S(message)] - $w.c create text [Centroid I24] -text $msg -tag {I24 I24t} \ + set msg [subst $S(message)] + $w.c create text [Centroid $w I24] -text $msg -tag {I24 I24t} \ -justify center -font {{Times Roman} 18 bold} - return 1 + return 1 } $w.c itemconfig I24t -font [list {Times Roman} [expr {18 + 6*$step}] bold] $w.c move I24 0 -60 - eval $w.c scale I24 [Centroid I24] 1.25 1.25 + $w.c scale I24 {*}[Centroid $w I24] 1.25 1.25 return 1 } + # Displaying the message -proc Move25 {{step {}}} { +proc Move25 {w {step {}}} { global S set step [GetStep 25 $step] if {$step == 0} { - set ::XY(25) [clock clicks -milliseconds] - return 1 + set ::XY(25) [clock clicks -milliseconds] + return 1 } set elapsed [expr {[clock clicks -milliseconds] - $::XY(25)}] - if {$elapsed < 5000} {return 1} + if {$elapsed < 5000} { + return 1 + } return 2 } + # Collapsing balloon -proc Move26 {{step {}}} { - global S w +proc Move26 {w {step {}}} { + global S set step [GetStep 26 $step] if {$step >= 3} { - $w.c delete I24 I26 - $w.c create text 430 755 -anchor s -tag I26 \ + $w.c delete I24 I26 + $w.c create text 430 755 -anchor s -tag I26 \ -text "click to continue" -font {{Times Roman} 24 bold} - bind $w.c <1> Reset - return 4 + bind $w.c <1> [list Reset $w] + return 4 } - eval $w.c scale I24 [Centroid I24] .8 .8 + $w.c scale I24 {*}[Centroid $w I24] .8 .8 $w.c move I24 0 60 $w.c itemconfig I24t -font [list {Times Roman} [expr {30 - 6*$step}] bold] return 1 @@ -1541,101 +1634,105 @@ proc Move26 {{step {}}} { # # Helper functions # + proc box {x y r} { return [list [expr {$x-$r}] [expr {$y-$r}] [expr {$x+$r}] [expr {$y+$r}]] } -proc MoveAbs {item xy} { - global w - foreach {x y} $xy break - foreach {Ox Oy} [Centroid $item] break + +proc MoveAbs {w item xy} { + lassign $xy x y + lassign [Centroid $w $item] Ox Oy set dx [expr {$x - $Ox}] set dy [expr {$y - $Oy}] $w.c move $item $dx $dy } -proc RotateItem {item Ox Oy beta} { - global w + +proc RotateItem {w item Ox Oy beta} { set xy [$w.c coords $item] set xy2 {} foreach {x y} $xy { - eval lappend xy2 [RotateC $x $y $Ox $Oy $beta] + lappend xy2 {*}[RotateC $x $y $Ox $Oy $beta] } $w.c coords $item $xy2 } + proc RotateC {x y Ox Oy beta} { # rotates vector (Ox,Oy)->(x,y) by beta degrees clockwise - set x [expr {$x - $Ox}] ;# Shift to origin + set x [expr {$x - $Ox}] ;# Shift to origin set y [expr {$y - $Oy}] - set beta [expr {$beta * atan(1) * 4 / 180.0}] ;# Radians - set xx [expr {$x * cos($beta) - $y * sin($beta)}] ;# Rotate + set beta [expr {$beta * atan(1) * 4 / 180.0}] ;# Radians + set xx [expr {$x * cos($beta) - $y * sin($beta)}] ;# Rotate set yy [expr {$x * sin($beta) + $y * cos($beta)}] - set xx [expr {$xx + $Ox}] ;# Shift back + set xx [expr {$xx + $Ox}] ;# Shift back set yy [expr {$yy + $Oy}] return [list $xx $yy] } -proc Reset {} { - global S w - DrawAll +proc Reset {w} { + global S + DrawAll $w bind $w.c <1> {} set S(mode) $::MSTART set S(active) 0 } + # Each Move## keeps its state info in STEP, this retrieves and increments it proc GetStep {who step} { global STEP - if {$step != {}} { - set STEP($who) $step + if {$step ne ""} { + set STEP($who) $step + } elseif {![info exists STEP($who)] || $STEP($who) eq ""} { + set STEP($who) 0 } else { - if {! [info exists STEP($who)] || $STEP($who) == ""} { - set STEP($who) 0 - } else { - incr STEP($who) - } + incr STEP($who) } return $STEP($who) } + proc ResetStep {} { global STEP set ::S(cnt) 0 - foreach a [array names STEP] { set STEP($a) ""} + foreach a [array names STEP] { + set STEP($a) "" + } } -proc Sine {x0 y0 x1 y1 amp freq args} { - global w + +proc Sine {w x0 y0 x1 y1 amp freq args} { set PI [expr {4 * atan(1)}] set step 2 set xy {} - if {$y0 == $y1} { ;# Horizontal - for {set x $x0} {$x <= $x1} {incr x $step} { - set beta [expr {($x - $x0) * 2 * $PI / $freq}] - set y [expr {$y0 + $amp * sin($beta)}] - lappend xy $x $y - } + if {$y0 == $y1} { ;# Horizontal + for {set x $x0} {$x <= $x1} {incr x $step} { + set beta [expr {($x - $x0) * 2 * $PI / $freq}] + set y [expr {$y0 + $amp * sin($beta)}] + lappend xy $x $y + } } else { - for {set y $y0} {$y <= $y1} {incr y $step} { - set beta [expr {($y - $y0) * 2 * $PI / $freq}] - set x [expr {$x0 + $amp * sin($beta)}] - lappend xy $x $y - } + for {set y $y0} {$y <= $y1} {incr y $step} { + set beta [expr {($y - $y0) * 2 * $PI / $freq}] + set x [expr {$x0 + $amp * sin($beta)}] + lappend xy $x $y + } } - return [eval $w.c create line $xy $args] + return [$w.c create line $xy {*}$args] } -proc RoundRect {xy radius args} { - global w - foreach {x0 y0 x3 y3} $xy break + +proc RoundRect {w xy radius args} { + lassign $xy x0 y0 x3 y3 set r [winfo pixels $w.c $radius] set d [expr {2 * $r}] # Make sure that the radius of the curve is less than 3/8 size of the box! set maxr 0.75 - if {$d > $maxr * ($x3 - $x0) } { - set d [expr { $maxr * ($x3 - $x0)}] + if {$d > $maxr * ($x3 - $x0)} { + set d [expr {$maxr * ($x3 - $x0)}] } - if {$d > $maxr * ($y3 - $y0) } { - set d [expr { $maxr * ($y3 - $y0) }] + if {$d > $maxr * ($y3 - $y0)} { + set d [expr {$maxr * ($y3 - $y0)}] } set x1 [expr { $x0 + $d }] @@ -1647,34 +1744,36 @@ proc RoundRect {xy radius args} { lappend xy $x3 $y3 $x2 $y3 $x1 $y3 $x0 $y3 $x0 $y2 $x0 $y1 return $xy } + proc RoundPoly {canv xy radii args} { set lenXY [llength $xy] set lenR [llength $radii] if {$lenXY != 2*$lenR} { - error "wrong number of vertices and radii" + error "wrong number of vertices and radii" } set knots {} - foreach {x0 y0} [lrange $xy end-1 end] break - foreach {x1 y1} $xy break - eval lappend xy [lrange $xy 0 1] + lassign [lrange $xy end-1 end] x0 y0 + lassign $xy x1 y1 + lappend xy {*}[lrange $xy 0 1] for {set i 0} {$i < $lenXY} {incr i 2} { - set radius [lindex $radii [expr {$i/2}]] - set r [winfo pixels $canv $radius] + set radius [lindex $radii [expr {$i/2}]] + set r [winfo pixels $canv $radius] - foreach {x2 y2} [lrange $xy [expr {$i + 2}] [expr {$i + 3}]] break - set z [_RoundPoly2 $x0 $y0 $x1 $y1 $x2 $y2 $r] - eval lappend knots $z + lassign [lrange $xy [expr {$i + 2}] [expr {$i + 3}]] x2 y2 + set z [_RoundPoly2 $x0 $y0 $x1 $y1 $x2 $y2 $r] + lappend knots {*}$z - foreach {x0 y0} [list $x1 $y1] break - foreach {x1 y1} [list $x2 $y2] break + lassign [list $x1 $y1] x0 y0 + lassign [list $x2 $y2] x1 y1 } - set n [eval $canv create polygon $knots -smooth 1 $args] + set n [$canv create polygon $knots -smooth 1 {*}$args] return $n } + proc _RoundPoly2 {x0 y0 x1 y1 x2 y2 radius} { - set d [expr { 2 * $radius }] + set d [expr {2 * $radius}] set maxr 0.75 set v1x [expr {$x0 - $x1}] @@ -1685,10 +1784,10 @@ proc _RoundPoly2 {x0 y0 x1 y1 x2 y2 radius} { set vlen1 [expr {sqrt($v1x*$v1x + $v1y*$v1y)}] set vlen2 [expr {sqrt($v2x*$v2x + $v2y*$v2y)}] if {$d > $maxr * $vlen1} { - set d [expr {$maxr * $vlen1}] + set d [expr {$maxr * $vlen1}] } if {$d > $maxr * $vlen2} { - set d [expr {$maxr * $vlen2}] + set d [expr {$maxr * $vlen2}] } lappend xy [expr {$x1 + $d * $v1x/$vlen1}] [expr {$y1 + $d * $v1y/$vlen1}] @@ -1697,37 +1796,38 @@ proc _RoundPoly2 {x0 y0 x1 y1 x2 y2 radius} { return $xy } -proc Sparkle {Oxy tag} { - global w + +proc Sparkle {w Oxy tag} { set xy {299 283 298 302 295 314 271 331 239 310 242 292 256 274 281 273} foreach {x y} $xy { - $w.c create line 271 304 $x $y -fill white -width 3 -tag $tag + $w.c create line 271 304 $x $y -fill white -width 3 -tag $tag } - MoveAbs $tag $Oxy + MoveAbs $w $tag $Oxy } -proc Centroid {item} { - return [Anchor $item c] + +proc Centroid {w item} { + return [Anchor $w $item c] } -proc Anchor {item where} { - global w - foreach {x1 y1 x2 y2} [$w.c bbox $item] break - if {[string first "n" $where] > -1} { - set y $y1 - } elseif {[string first "s" $where] > -1} { - set y $y2 + +proc Anchor {w item where} { + lassign [$w.c bbox $item] x1 y1 x2 y2 + if {[string match *n* $where]} { + set y $y1 + } elseif {[string match *s* $where]} { + set y $y2 } else { - set y [expr {($y1 + $y2) / 2.0}] + set y [expr {($y1 + $y2) / 2.0}] } - if {[string first "w" $where] > -1} { - set x $x1 - } elseif {[string first "e" $where] > -1} { - set x $x2 + if {[string match *w* $where]} { + set x $x1 + } elseif {[string match *e* $where]} { + set x $x2 } else { - set x [expr {($x1 + $x2) / 2.0}] + set x [expr {($x1 + $x2) / 2.0}] } return [list $x $y] } -DoDisplay -Reset -Go ;# Start everything going +DoDisplay $w +Reset $w +Go $w ;# Start everything going diff --git a/tests/wm.test b/tests/wm.test index 10b77e5..d2b3cd9 100644 --- a/tests/wm.test +++ b/tests/wm.test @@ -1,17 +1,17 @@ -# This file is a Tcl script to test out Tk's interactions with -# the window manager, including the "wm" command. It is organized -# in the standard fashion for Tcl tests. +# This file is a Tcl script to test out Tk's interactions with the window +# manager, including the "wm" command. It is organized in the standard fashion +# for Tcl tests. # # Copyright (c) 1992-1994 The Regents of the University of California. # Copyright (c) 1994-1997 Sun Microsystems, Inc. # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: wm.test,v 1.37.2.1 2007/10/16 04:03:54 dgp Exp $ +# RCS: @(#) $Id: wm.test,v 1.37.2.2 2008/03/26 20:09:32 dgp Exp $ -# This file tests window manager interactions that work across -# platforms. Window manager tests that only work on a specific -# platform should be placed in unixWm.test or winWm.test. +# This file tests window manager interactions that work across platforms. +# Window manager tests that only work on a specific platform should be placed +# in unixWm.test or winWm.test. package require tcltest 2.1 eval tcltest::configure $argv @@ -29,164 +29,176 @@ proc stdWindow {} { update } -# [raise] and [lower] may return before the window manager -# has completed the operation. The raiseDelay procedure -# idles for a while to give the operation a chance to complete. +# [raise] and [lower] may return before the window manager has completed the +# operation. The raiseDelay procedure idles for a while to give the operation +# a chance to complete. # proc raiseDelay {} { after 100; update } +# How to carry out a small delay while processing events + +proc eventDelay {{delay 200}} { + after $delay "set done 1" ; vwait done +} deleteWindows + +############################################################################## + stdWindow -test wm-1.1 {Tk_WmObjCmd procedure, miscellaneous errors} { - list [catch {wm} msg] $msg -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-1.2 {Tk_WmObjCmd procedure, miscellaneous errors} { - list [catch {wm foo} msg] $msg -} {1 {bad option "foo": must be aspect, attributes, client, colormapwindows, command, deiconify, focusmodel, forget, frame, geometry, grid, group, iconbitmap, iconify, iconmask, iconname, iconphoto, iconposition, iconwindow, manage, maxsize, minsize, overrideredirect, positionfrom, protocol, resizable, sizefrom, stackorder, state, title, transient, or withdraw}} -test wm-1.3 {Tk_WmObjCmd procedure, miscellaneous errors} { - list [catch {wm command} msg] $msg -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-1.4 {Tk_WmObjCmd procedure, miscellaneous errors} { - list [catch {wm aspect bogus} msg] $msg -} {1 {bad window path name "bogus"}} -test wm-1.5 {Tk_WmObjCmd procedure, miscellaneous errors} -setup { - destroy .b -} -body { +test wm-1.1 {Tk_WmObjCmd procedure, miscellaneous errors} -returnCodes error -body { + wm +} -result {wrong # args: should be "wm option window ?arg ...?"} +# Next test will fail every time set of subcommands is changed +test wm-1.2 {Tk_WmObjCmd procedure, miscellaneous errors} -returnCodes error -body { + wm foo +} -result {bad option "foo": must be aspect, attributes, client, colormapwindows, command, deiconify, focusmodel, forget, frame, geometry, grid, group, iconbitmap, iconify, iconmask, iconname, iconphoto, iconposition, iconwindow, manage, maxsize, minsize, overrideredirect, positionfrom, protocol, resizable, sizefrom, stackorder, state, title, transient, or withdraw} +test wm-1.3 {Tk_WmObjCmd procedure, miscellaneous errors} -returnCodes error -body { + wm command +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-1.4 {Tk_WmObjCmd procedure, miscellaneous errors} -returnCodes error -body { + wm aspect bogus +} -result {bad window path name "bogus"} +test wm-1.5 {Tk_WmObjCmd procedure, miscellaneous errors} -body { button .b -text hello - list [catch {wm geometry .b} msg] $msg -} -result {1 {window ".b" isn't a top-level window}} + wm geometry .b +} -returnCodes error -cleanup { + destroy .b +} -result {window ".b" isn't a top-level window} ### wm aspect ### -test wm-aspect-1.1 {usage} { - list [catch {wm aspect} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-aspect-1.2 {usage} { - list [catch {wm aspect . _} err] $err -} {1 {wrong # args: should be "wm aspect window ?minNumer minDenom maxNumer maxDenom?"}} -test wm-aspect-1.3 {usage} { - list [catch {wm aspect . _ _ _} err] $err -} {1 {wrong # args: should be "wm aspect window ?minNumer minDenom maxNumer maxDenom?"}} -test wm-aspect-1.4 {usage} { - list [catch {wm aspect . _ _ _ _ _} err] $err -} {1 {wrong # args: should be "wm aspect window ?minNumer minDenom maxNumer maxDenom?"}} -test wm-aspect-1.5 {usage} { - list [catch {wm aspect . bad 14 15 16} msg] $msg -} {1 {expected integer but got "bad"}} -test wm-aspect-1.6 {usage} { - list [catch {wm aspect . 13 foo 15 16} msg] $msg -} {1 {expected integer but got "foo"}} -test wm-aspect-1.7 {usage} { - list [catch {wm aspect . 13 14 bar 16} msg] $msg -} {1 {expected integer but got "bar"}} -test wm-aspect-1.8 {usage} { - list [catch {wm aspect . 13 14 15 baz} msg] $msg -} {1 {expected integer but got "baz"}} -test wm-aspect-1.9 {usage} { - list [catch {wm aspect . 0 14 15 16} msg] $msg -} {1 {aspect number can't be <= 0}} -test wm-aspect-1.10 {usage} { - list [catch {wm aspect . 13 0 15 16} msg] $msg -} {1 {aspect number can't be <= 0}} -test wm-aspect-1.11 {usage} { - list [catch {wm aspect . 13 14 0 16} msg] $msg -} {1 {aspect number can't be <= 0}} -test wm-aspect-1.12 {usage} { - list [catch {wm aspect . 13 14 15 0} msg] $msg -} {1 {aspect number can't be <= 0}} - -test wm-aspect-2.1 {setting and reading values} { +test wm-aspect-1.1 {usage} -returnCodes error -body { + wm aspect +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-aspect-1.2 {usage} -returnCodes error -body { + wm aspect . _ +} -result {wrong # args: should be "wm aspect window ?minNumer minDenom maxNumer maxDenom?"} +test wm-aspect-1.3 {usage} -returnCodes error -body { + wm aspect . _ _ _ +} -result {wrong # args: should be "wm aspect window ?minNumer minDenom maxNumer maxDenom?"} +test wm-aspect-1.4 {usage} -returnCodes error -body { + wm aspect . _ _ _ _ _ +} -result {wrong # args: should be "wm aspect window ?minNumer minDenom maxNumer maxDenom?"} +test wm-aspect-1.5 {usage} -returnCodes error -body { + wm aspect . bad 14 15 16 +} -result {expected integer but got "bad"} +test wm-aspect-1.6 {usage} -returnCodes error -body { + wm aspect . 13 foo 15 16 +} -result {expected integer but got "foo"} +test wm-aspect-1.7 {usage} -returnCodes error -body { + wm aspect . 13 14 bar 16 +} -result {expected integer but got "bar"} +test wm-aspect-1.8 {usage} -returnCodes error -body { + wm aspect . 13 14 15 baz +} -result {expected integer but got "baz"} +test wm-aspect-1.9 {usage} -returnCodes error -body { + wm aspect . 0 14 15 16 +} -result {aspect number can't be <= 0} +test wm-aspect-1.10 {usage} -returnCodes error -body { + wm aspect . 13 0 15 16 +} -result {aspect number can't be <= 0} +test wm-aspect-1.11 {usage} -returnCodes error -body { + wm aspect . 13 14 0 16 +} -result {aspect number can't be <= 0} +test wm-aspect-1.12 {usage} -returnCodes error -body { + wm aspect . 13 14 15 0 +} -result {aspect number can't be <= 0} + +test wm-aspect-2.1 {setting and reading values} -setup { set result {} +} -body { lappend result [wm aspect .t] wm aspect .t 3 4 10 2 lappend result [wm aspect .t] wm aspect .t {} {} {} {} lappend result [wm aspect .t] -} [list {} {3 4 10 2} {}] +} -result [list {} {3 4 10 2} {}] ### wm attributes ### -test wm-attributes-1.1 {usage} { - list [catch {wm attributes} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-attributes-1.2.1 {usage} win { +test wm-attributes-1.1 {usage} -returnCodes error -body { + wm attributes +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-attributes-1.2.1 {usage} -constraints win -returnCodes error -body { # This is the wrong error to output - unix has it right, but it's # not critical. - list [catch {wm attributes . _} err] $err -} {1 {wrong # args: should be "wm attributes window ?-alpha ?double?? ?-transparentcolor ?color?? ?-disabled ?bool?? ?-fullscreen ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"}} -test wm-attributes-1.2.2 {usage} win { - list [catch {wm attributes . -alpha 1.0 -disabled} err] $err -} {1 {wrong # args: should be "wm attributes window ?-alpha ?double?? ?-transparentcolor ?color?? ?-disabled ?bool?? ?-fullscreen ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"}} -test wm-attributes-1.2.3 {usage} win { + wm attributes . _ +} -result {wrong # args: should be "wm attributes window ?-alpha ?double?? ?-transparentcolor ?color?? ?-disabled ?bool?? ?-fullscreen ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"} +test wm-attributes-1.2.2 {usage} -constraints win -returnCodes error -body { + wm attributes . -alpha 1.0 -disabled +} -result {wrong # args: should be "wm attributes window ?-alpha ?double?? ?-transparentcolor ?color?? ?-disabled ?bool?? ?-fullscreen ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"} +test wm-attributes-1.2.3 {usage} -constraints win -returnCodes error -body { # This is the wrong error to output - unix has it right, but it's # not critical. - list [catch {wm attributes . -to} err] $err -} {1 {wrong # args: should be "wm attributes window ?-alpha ?double?? ?-transparentcolor ?color?? ?-disabled ?bool?? ?-fullscreen ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"}} -test wm-attributes-1.2.4 {usage} {unix notAqua} { - list [catch {wm attributes . _} err] $err -} {1 {bad attribute "_": must be -alpha, -topmost, -zoomed, or -fullscreen}} -test wm-attributes-1.2.5 {usage} aqua { - list [catch {wm attributes . _} err] $err -} {1 {bad attribute "_": must be -alpha, -modified, -notify, or -titlepath}} + wm attributes . -to +} -result {wrong # args: should be "wm attributes window ?-alpha ?double?? ?-transparentcolor ?color?? ?-disabled ?bool?? ?-fullscreen ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"} +test wm-attributes-1.2.4 {usage} -constraints {unix notAqua} -returnCodes error -body { + wm attributes . _ +} -result {bad attribute "_": must be -alpha, -topmost, -zoomed, or -fullscreen} +test wm-attributes-1.2.5 {usage} -constraints aqua -returnCodes error -body { + wm attributes . _ +} -result {bad attribute "_": must be -alpha, -modified, -notify, or -titlepath} ### wm client ### -test wm-client-1.1 {usage} { - list [catch {wm client} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-client-1.2 {usage} { - list [catch {wm client . _ _} err] $err -} {1 {wrong # args: should be "wm client window ?name?"}} - -test wm-client-2.1 {setting and reading values} { +test wm-client-1.1 {usage} -returnCodes error -body { + wm client +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-client-1.2 {usage} -returnCodes error -body { + wm client . _ _ +} -result {wrong # args: should be "wm client window ?name?"} + +test wm-client-2.1 {setting and reading values} -setup { set result {} +} -body { lappend result [wm client .t] wm client .t Miffo lappend result [wm client .t] wm client .t {} lappend result [wm client .t] -} [list {} Miffo {}] +} -result [list {} Miffo {}] +deleteWindows -test wm-attributes-1.3.0 {default -fullscreen value} {win} { - deleteWindows +test wm-attributes-1.3.0 {default -fullscreen value} -constraints win -body { toplevel .t wm attributes .t -fullscreen -} {0} - -test wm-attributes-1.3.1 {change -fullscreen before map} {win} { +} -cleanup { deleteWindows +} -result 0 +test wm-attributes-1.3.1 {change -fullscreen before map} -constraints win -body { toplevel .t wm attributes .t -fullscreen 1 wm attributes .t -fullscreen -} {1} - -test wm-attributes-1.3.2 {change -fullscreen before map} {win} { +} -cleanup { deleteWindows +} -result 1 +test wm-attributes-1.3.2 {change -fullscreen before map} -constraints win -body { toplevel .t wm attributes .t -fullscreen 1 update wm attributes .t -fullscreen -} {1} - -test wm-attributes-1.3.3 {change -fullscreen after map} {win} { +} -cleanup { deleteWindows +} -result 1 +test wm-attributes-1.3.3 {change -fullscreen after map} -constraints win -body { toplevel .t update wm attributes .t -fullscreen 1 wm attributes .t -fullscreen -} {1} - -test wm-attributes-1.3.4 {change -fullscreen after map} {win} { +} -cleanup { deleteWindows +} -result 1 +test wm-attributes-1.3.4 {change -fullscreen after map} -setup { + set booleans [list] +} -constraints win -body { toplevel .t update - set booleans [list] lappend booleans [wm attributes .t -fullscreen] wm attributes .t -fullscreen 1 lappend booleans [wm attributes .t -fullscreen] @@ -194,275 +206,262 @@ test wm-attributes-1.3.4 {change -fullscreen after map} {win} { lappend booleans [wm attributes .t -fullscreen] wm attributes .t -fullscreen 0 lappend booleans [wm attributes .t -fullscreen] - set booleans -} {0 1 1 0} - -test wm-attributes-1.3.5 {change -fullscreen after map} {win} { +} -cleanup { deleteWindows - toplevel .t +} -result {0 1 1 0} +test wm-attributes-1.3.5 {change -fullscreen after map} -setup { + set results [list] set normal_geom "301x302+101+102" - set fullscreen_geom "[winfo screenwidth .t]x[winfo screenheight .t]+0+0" + set fullscreen_geom "[winfo screenwidth .]x[winfo screenheight .]+0+0" +} -constraints win -body { + toplevel .t wm geom .t $normal_geom update - set results [list] lappend results [string equal [wm geom .t] $normal_geom] wm attributes .t -fullscreen 1 lappend results [string equal [wm geom .t] $fullscreen_geom] wm attributes .t -fullscreen 0 lappend results [string equal [wm geom .t] $normal_geom] - set results -} {1 1 1} - -test wm-attributes-1.3.6 {state change does not change -fullscreen} {win} { +} -cleanup { deleteWindows +} -result {1 1 1} +test wm-attributes-1.3.6 {state change does not change -fullscreen} -constraints win -body { toplevel .t update wm attributes .t -fullscreen 1 wm withdraw .t wm deiconify .t wm attributes .t -fullscreen -} {1} - -test wm-attributes-1.3.7 {state change does not change -fullscreen} {win} { +} -cleanup { deleteWindows +} -result 1 +test wm-attributes-1.3.7 {state change does not change -fullscreen} -constraints win -body { toplevel .t update wm attributes .t -fullscreen 1 wm iconify .t wm deiconify .t wm attributes .t -fullscreen -} {1} - -test wm-attributes-1.3.8 {override-redirect not compatible with fullscreen attribute} {win} { +} -cleanup { deleteWindows +} -result 1 +test wm-attributes-1.3.8 {override-redirect not compatible with fullscreen attribute} -constraints win -body { toplevel .t update wm overrideredirect .t 1 - list [catch {wm attributes .t -fullscreen 1} err] $err -} {1 {can't set fullscreen attribute for ".t": override-redirect flag is set}} - -test wm-attributes-1.3.9 {max height too small} {win} { + wm attributes .t -fullscreen 1 +} -returnCodes error -cleanup { deleteWindows +} -result {can't set fullscreen attribute for ".t": override-redirect flag is set} +test wm-attributes-1.3.9 {max height too small} -constraints win -body { toplevel .t update wm maxsize .t 5000 450 - list [catch {wm attributes .t -fullscreen 1} err] $err -} {1 {can't set fullscreen attribute for ".t": max width/height is too small}} - -test wm-attributes-1.3.10 {max height too small} {win} { + wm attributes .t -fullscreen 1 +} -returnCodes error -cleanup { deleteWindows +} -result {can't set fullscreen attribute for ".t": max width/height is too small} +test wm-attributes-1.3.10 {max height too small} -constraints win -body { toplevel .t update wm maxsize .t 450 5000 - list [catch {wm attributes .t -fullscreen 1} err] $err -} {1 {can't set fullscreen attribute for ".t": max width/height is too small}} - -test wm-attributes-1.3.11 {another attribute, then -fullscreen} {win} { + wm attributes .t -fullscreen 1 +} -returnCodes error -cleanup { deleteWindows +} -result {can't set fullscreen attribute for ".t": max width/height is too small} +test wm-attributes-1.3.11 {another attribute, then -fullscreen} -constraints win -body { toplevel .t update wm attributes .t -alpha 1.0 -fullscreen 1 wm attributes .t -fullscreen -} 1 - -test wm-attributes-1.3.12 {another attribute, then -fullscreen, then another} {win} { +} -cleanup { deleteWindows +} -result 1 +test wm-attributes-1.3.12 {another attribute, then -fullscreen, then another} -constraints win -body { toplevel .t update wm attributes .t -toolwindow 0 -fullscreen 1 -topmost 0 wm attributes .t -fullscreen -} 1 - -test wm-attributes-1.4.0 {setting/unsetting fullscreen does not change the focus} {win} { +} -cleanup { deleteWindows +} -result 1 + +test wm-attributes-1.4.0 {setting/unsetting fullscreen does not change the focus} -setup { + set results [list] +} -constraints win -body { focus -force . toplevel .t lower .t update - set results [list] lappend results [focus] wm attributes .t -fullscreen 1 - after 200 "set done 1" ; vwait done + eventDelay lappend results [focus] wm attributes .t -fullscreen 0 - after 200 "set done 1" ; vwait done + eventDelay lappend results [focus] - - set results -} {. . .} - -test wm-attributes-1.4.1 {setting fullscreen does not generate FocusIn on wrapper create} {win} { +} -cleanup { deleteWindows +} -result {. . .} +test wm-attributes-1.4.1 {setting fullscreen does not generate FocusIn on wrapper create} -setup { catch {unset focusin} +} -constraints win -body { focus -force . toplevel .t pack [entry .t.e] lower .t bind .t <FocusIn> {lappend focusin %W} - after 200 "set done 1" ; vwait done + eventDelay lappend focusin 1 focus -force .t.e - after 200 "set done 1" ; vwait done - + eventDelay + lappend focusin 2 wm attributes .t -fullscreen 1 - after 200 "set done 1" ; vwait done + eventDelay lappend focusin 3 wm attributes .t -fullscreen 0 - after 200 "set done 1" ; vwait done - - lappend focusin final [focus] + eventDelay + lappend focusin final [focus] +} -cleanup { bind . <FocusIn> {} bind .t <FocusIn> {} - set focusin -} {1 .t .t.e 2 3 final .t.e} - -test wm-attributes-1.5.0 {fullscreen stackorder} {win} { deleteWindows - toplevel .t +} -result {1 .t .t.e 2 3 final .t.e} + +test wm-attributes-1.5.0 {fullscreen stackorder} -setup { set results [list] +} -constraints win -body { + toplevel .t lappend results [wm stackorder .] - after 200 "set done 1" ; vwait done + eventDelay lappend results [wm stackorder .] - # Default stacking is on top of other windows - # on the display. Setting the fullscreen attribute - # does not change this. + # Default stacking is on top of other windows on the display. Setting the + # fullscreen attribute does not change this. wm attributes .t -fullscreen 1 - after 200 "set done 1" ; vwait done + eventDelay lappend results [wm stackorder .] - - set results -} {. {. .t} {. .t}} - -test wm-attributes-1.5.1 {fullscreen stackorder} {win} { +} -cleanup { deleteWindows +} -result {. {. .t} {. .t}} +test wm-attributes-1.5.1 {fullscreen stackorder} -setup { + set results [list] +} -constraints win -body { toplevel .t lower .t - after 200 "set done 1" ; vwait done - set results [list] + eventDelay lappend results [wm stackorder .] - # If stacking order is explicitly set, then - # setting the fullscreen attribute should - # not change it. + # If stacking order is explicitly set, then setting the fullscreen + # attribute should not change it. wm attributes .t -fullscreen 1 - after 200 "set done 1" ; vwait done + eventDelay lappend results [wm stackorder .] - - set results -} {{.t .} {.t .}} - -test wm-attributes-1.5.2 {fullscreen stackorder} {win} { +} -cleanup { deleteWindows +} -result {{.t .} {.t .}} +test wm-attributes-1.5.2 {fullscreen stackorder} -setup { + set results [list] +} -constraints win -body { toplevel .t # lower forces the window to be mapped, it would not be otherwise lower .t - set results [list] lappend results [wm stackorder .] - # If stacking order is explicitly set - # for an unmapped window, then setting - # the fullscreen attribute should - # not change it. + # If stacking order is explicitly set for an unmapped window, then setting + # the fullscreen attribute should not change it. wm attributes .t -fullscreen 1 - after 200 "set done 1" ; vwait done + eventDelay lappend results [wm stackorder .] - - set results -} {{.t .} {.t .}} - -test wm-attributes-1.5.3 {fullscreen stackorder} {win} { +} -cleanup { deleteWindows - toplevel .t - after 200 "set done 1" ; vwait done +} -result {{.t .} {.t .}} +test wm-attributes-1.5.3 {fullscreen stackorder} -setup { set results [list] +} -constraints win -body { + toplevel .t + eventDelay lappend results [wm stackorder .] wm attributes .t -fullscreen 1 - after 200 "set done 1" ; vwait done + eventDelay lappend results [wm stackorder .] - # Unsetting the fullscreen attribute - # should not change the stackorder. + # Unsetting the fullscreen attribute should not change the stackorder. wm attributes .t -fullscreen 0 - after 200 "set done 1" ; vwait done + eventDelay lappend results [wm stackorder .] - - set results -} {{. .t} {. .t} {. .t}} - -test wm-attributes-1.5.4 {fullscreen stackorder} {win} { +} -cleanup { deleteWindows +} -result {{. .t} {. .t} {. .t}} +test wm-attributes-1.5.4 {fullscreen stackorder} -setup { + set results [list] +} -constraints win -body { toplevel .t lower .t - after 200 "set done 1" ; vwait done - set results [list] + eventDelay lappend results [wm stackorder .] wm attributes .t -fullscreen 1 - after 200 "set done 1" ; vwait done + eventDelay lappend results [wm stackorder .] - # Unsetting the fullscreen attribute - # should not change the stackorder. + # Unsetting the fullscreen attribute should not change the stackorder. wm attributes .t -fullscreen 0 - after 200 "set done 1" ; vwait done + eventDelay lappend results [wm stackorder .] - - set results -} {{.t .} {.t .} {.t .}} - -test wm-attributes-1.5.5 {fullscreen stackorder} {win} { +} -cleanup { deleteWindows +} -result {{.t .} {.t .} {.t .}} +test wm-attributes-1.5.5 {fullscreen stackorder} -setup { + set results [list] +} -constraints win -body { toplevel .a toplevel .b toplevel .c raise .a raise .b raise .c - after 200 "set done 1" ; vwait done - set results [list] + eventDelay lappend results [wm stackorder .] wm attributes .b -fullscreen 1 - after 200 "set done 1" ; vwait done + eventDelay lappend results [wm stackorder .] - # Unsetting the fullscreen attribute - # should not change the stackorder. + # Unsetting the fullscreen attribute should not change the stackorder. wm attributes .b -fullscreen 0 - after 200 "set done 1" ; vwait done + eventDelay lappend results [wm stackorder .] +} -cleanup { + deleteWindows +} -result {{. .a .b .c} {. .a .b .c} {. .a .b .c}} - set results -} {{. .a .b .c} {. .a .b .c} {. .a .b .c}} -deleteWindows stdWindow + ### wm colormapwindows ### -test wm-colormapwindows-1.1 {usage} { - list [catch {wm colormapwindows} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-colormapwindows-1.2 {usage} { - list [catch {wm colormapwindows . _ _} err] $err -} {1 {wrong # args: should be "wm colormapwindows window ?windowList?"}} -test wm-colormapwindows-1.3 {usage} { - list [catch {wm colormapwindows . "a \{"} msg] $msg -} {1 {unmatched open brace in list}} -test wm-colormapwindows-1.4 {usage} { - list [catch {wm colormapwindows . foo} msg] $msg -} {1 {bad window path name "foo"}} - -test wm-colormapwindows-2.1 {reading values} -setup { - destroy .t2 -} -body { +test wm-colormapwindows-1.1 {usage} -returnCodes error -body { + wm colormapwindows +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-colormapwindows-1.2 {usage} -returnCodes error -body { + wm colormapwindows . _ _ +} -result {wrong # args: should be "wm colormapwindows window ?windowList?"} +test wm-colormapwindows-1.3 {usage} -returnCodes error -body { + wm colormapwindows . "a \{" +} -result {unmatched open brace in list} +test wm-colormapwindows-1.4 {usage} -returnCodes error -body { + wm colormapwindows . foo +} -result {bad window path name "foo"} + +test wm-colormapwindows-2.1 {reading values} -body { toplevel .t2 -width 200 -height 200 -colormap new wm geom .t2 +0+0 frame .t2.a -width 100 -height 30 @@ -474,10 +473,10 @@ test wm-colormapwindows-2.1 {reading values} -setup { pack .t2.c -side top update list $x [wm colormapwindows .t2] -} -result {{.t2.b .t2} {.t2.b .t2.c .t2}} -test wm-colormapwindows-2.2 {setting and reading values} -setup { +} -cleanup { destroy .t2 -} -body { +} -result {{.t2.b .t2} {.t2.b .t2.c .t2}} +test wm-colormapwindows-2.2 {setting and reading values} -body { toplevel .t2 -width 200 -height 200 wm geom .t2 +0+0 frame .t2.a -width 100 -height 30 @@ -486,40 +485,43 @@ test wm-colormapwindows-2.2 {setting and reading values} -setup { pack .t2.a .t2.b .t2.c -side top wm colormapwindows .t2 {.t2.b .t2.a} wm colormapwindows .t2 +} -cleanup { + destroy .t2 } -result {.t2.b .t2.a} ### wm command ### -test wm-command-1.1 {usage} { - list [catch {wm command} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-command-1.2 {usage} { - list [catch {wm command . _ _} err] $err -} {1 {wrong # args: should be "wm command window ?value?"}} -test wm-command-1.3 {usage} { - list [catch {wm command . "a \{"} msg] $msg -} {1 {unmatched open brace in list}} - -test wm-command-2.1 {setting and reading values} { +test wm-command-1.1 {usage} -returnCodes error -body { + wm command +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-command-1.2 {usage} -returnCodes error -body { + wm command . _ _ +} -result {wrong # args: should be "wm command window ?value?"} +test wm-command-1.3 {usage} -returnCodes error -body { + wm command . "a \{" +} -result {unmatched open brace in list} + +test wm-command-2.1 {setting and reading values} -setup { set result {} +} -body { lappend result [wm command .t] wm command .t [list Miffo Foo] lappend result [wm command .t] wm command .t {} lappend result [wm command .t] -} [list {} [list Miffo Foo] {}] +} -result [list {} [list Miffo Foo] {}] ### wm deiconify ### -test wm-deiconify-1.1 {usage} { - list [catch {wm deiconify} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-deiconify-1.2 {usage} { - list [catch {wm deiconify . _} err] $err -} {1 {wrong # args: should be "wm deiconify window"}} -test wm-deiconify-1.3 {usage} { - list [catch {wm deiconify _} err] $err -} {1 {bad window path name "_"}} +test wm-deiconify-1.1 {usage} -returnCodes error -body { + wm deiconify +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-deiconify-1.2 {usage} -returnCodes error -body { + wm deiconify . _ +} -result {wrong # args: should be "wm deiconify window"} +test wm-deiconify-1.3 {usage} -returnCodes error -body { + wm deiconify _ +} -result {bad window path name "_"} test wm-deiconify-1.4 {usage} -setup { destroy .icon } -body { @@ -529,9 +531,8 @@ test wm-deiconify-1.4 {usage} -setup { } -returnCodes error -cleanup { destroy .icon } -result {can't deiconify .icon: it is an icon for .t} -if {$tcl_platform(platform) == "windows"} { # test embedded window for Windows -test wm-deiconify-1.5 {usage} -setup { +test wm-deiconify-1.5 {usage} -constraints win -setup { destroy .embed } -body { frame .t.f -container 1 @@ -540,9 +541,8 @@ test wm-deiconify-1.5 {usage} -setup { } -returnCodes error -cleanup { destroy .t.f .embed } -result {can't deiconify .embed: the container does not support the request} -} else { # test embedded window for other platforms -test wm-deiconify-1.5 {usage} -setup { +test wm-deiconify-1.6 {usage} -constraints !win -setup { destroy .embed } -body { frame .t.f -container 1 @@ -551,29 +551,31 @@ test wm-deiconify-1.5 {usage} -setup { } -returnCodes error -cleanup { destroy .t.f .embed } -result {can't deiconify .embed: it is an embedded window} -} +deleteWindows test wm-deiconify-2.1 {a window that has never been mapped\ - should not be mapped by a call to deiconify} { - deleteWindows + should not be mapped by a call to deiconify} -body { toplevel .t wm deiconify .t winfo ismapped .t -} 0 -test wm-deiconify-2.2 {a window that has already been\ - mapped should be mapped by deiconify} { +} -cleanup { deleteWindows +} -result 0 +test wm-deiconify-2.2 {a window that has already been\ + mapped should be mapped by deiconify} -body { toplevel .t update idletasks wm withdraw .t wm deiconify .t winfo ismapped .t -} 1 +} -cleanup { + deleteWindows +} -result 1 test wm-deiconify-2.3 {geometry for an unmapped window\ should not be calculated by a call to deiconify,\ - it should be done at idle time} { - deleteWindows + it should be done at idle time} -setup { set results {} +} -body { toplevel .t -width 200 -height 200 lappend results [wm geometry .t] wm deiconify .t @@ -581,190 +583,194 @@ test wm-deiconify-2.3 {geometry for an unmapped window\ update idletasks lappend results [lindex [split \ [wm geometry .t] +] 0] -} {1x1+0+0 1x1+0+0 200x200} +} -cleanup { + deleteWindows +} -result {1x1+0+0 1x1+0+0 200x200} test wm-deiconify-2.4 {invoking destroy after a deiconify\ should not result in a crash because of a callback\ - set on the toplevel} { - deleteWindows + set on the toplevel} -body { toplevel .t wm withdraw .t wm deiconify .t destroy .t update -} {} +} -cleanup { + deleteWindows +} ### wm focusmodel ### -test wm-focusmodel-1.1 {usage} { - list [catch {wm focusmodel} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-focusmodel-1.2 {usage} { - list [catch {wm focusmodel . _ _} err] $err -} {1 {wrong # args: should be "wm focusmodel window ?active|passive?"}} -test wm-focusmodel-1.3 {usage} { - list [catch {wm focusmodel . bogus} msg] $msg -} {1 {bad argument "bogus": must be active or passive}} +test wm-focusmodel-1.1 {usage} -returnCodes error -body { + wm focusmodel +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-focusmodel-1.2 {usage} -returnCodes error -body { + wm focusmodel . _ _ +} -result {wrong # args: should be "wm focusmodel window ?active|passive?"} +test wm-focusmodel-1.3 {usage} -returnCodes error -body { + wm focusmodel . bogus +} -result {bad argument "bogus": must be active or passive} stdWindow -test wm-focusmodel-2.1 {setting and reading values} { - set result {} +test wm-focusmodel-2.1 {setting and reading values} -setup { + set result {} +} -body { lappend result [wm focusmodel .t] wm focusmodel .t active lappend result [wm focusmodel .t] wm focusmodel .t passive lappend result [wm focusmodel .t] - set result -} {passive active passive} +} -result {passive active passive} ### wm frame ### -test wm-frame-1.1 {usage} { - list [catch {wm frame} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-frame-1.2 {usage} { - list [catch {wm frame . _} err] $err -} {1 {wrong # args: should be "wm frame window"}} +test wm-frame-1.1 {usage} -returnCodes error -body { + wm frame +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-frame-1.2 {usage} -returnCodes error -body { + wm frame . _ +} -result {wrong # args: should be "wm frame window"} ### wm geometry ### -test wm-geometry-1.1 {usage} { - list [catch {wm geometry} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-geometry-1.2 {usage} { - list [catch {wm geometry . _ _} err] $err -} {1 {wrong # args: should be "wm geometry window ?newGeometry?"}} -test wm-geometry-1.3 {usage} { - list [catch {wm geometry . bogus} msg] $msg -} {1 {bad geometry specifier "bogus"}} - -test wm-geometry-2.1 {setting values} { +test wm-geometry-1.1 {usage} -returnCodes error -body { + wm geometry +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-geometry-1.2 {usage} -returnCodes error -body { + wm geometry . _ _ +} -result {wrong # args: should be "wm geometry window ?newGeometry?"} +test wm-geometry-1.3 {usage} -returnCodes error -body { + wm geometry . bogus +} -result {bad geometry specifier "bogus"} + +test wm-geometry-2.1 {setting values} -setup { set result {} +} -body { wm geometry .t 150x150+50+50 update lappend result [wm geometry .t] wm geometry .t {} update lappend result [string equal [wm geometry .t] "150x150+50+50"] -} [list 150x150+50+50 0] +} -result [list 150x150+50+50 0] ### wm grid ### -test wm-grid-1.1 {usage} { - list [catch {wm grid} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-grid-1.2 {usage} { - list [catch {wm grid . _} err] $err -} {1 {wrong # args: should be "wm grid window ?baseWidth baseHeight widthInc heightInc?"}} -test wm-grid-1.3 {usage} { - list [catch {wm grid . _ _ _} err] $err -} {1 {wrong # args: should be "wm grid window ?baseWidth baseHeight widthInc heightInc?"}} -test wm-grid-1.4 {usage} { - list [catch {wm grid . _ _ _ _ _} err] $err -} {1 {wrong # args: should be "wm grid window ?baseWidth baseHeight widthInc heightInc?"}} -test wm-grid-1.5 {usage} { - list [catch {wm grid . bad 14 15 16} msg] $msg -} {1 {expected integer but got "bad"}} -test wm-grid-1.6 {usage} { - list [catch {wm grid . 13 foo 15 16} msg] $msg -} {1 {expected integer but got "foo"}} -test wm-grid-1.7 {usage} { - list [catch {wm grid . 13 14 bar 16} msg] $msg -} {1 {expected integer but got "bar"}} -test wm-grid-1.8 {usage} { - list [catch {wm grid . 13 14 15 baz} msg] $msg -} {1 {expected integer but got "baz"}} -test wm-grid-1.9 {usage} { - list [catch {wm grid . -1 14 15 16} msg] $msg -} {1 {baseWidth can't be < 0}} -test wm-grid-1.10 {usage} { - list [catch {wm grid . 13 -1 15 16} msg] $msg -} {1 {baseHeight can't be < 0}} -test wm-grid-1.11 {usage} { - list [catch {wm grid . 13 14 -1 16} msg] $msg -} {1 {widthInc can't be <= 0}} -test wm-grid-1.12 {usage} { - list [catch {wm grid . 13 14 15 -1} msg] $msg -} {1 {heightInc can't be <= 0}} - -test wm-grid-2.1 {setting and reading values} { +test wm-grid-1.1 {usage} -returnCodes error -body { + wm grid +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-grid-1.2 {usage} -returnCodes error -body { + wm grid . _ +} -result {wrong # args: should be "wm grid window ?baseWidth baseHeight widthInc heightInc?"} +test wm-grid-1.3 {usage} -returnCodes error -body { + wm grid . _ _ _ +} -result {wrong # args: should be "wm grid window ?baseWidth baseHeight widthInc heightInc?"} +test wm-grid-1.4 {usage} -returnCodes error -body { + wm grid . _ _ _ _ _ +} -result {wrong # args: should be "wm grid window ?baseWidth baseHeight widthInc heightInc?"} +test wm-grid-1.5 {usage} -returnCodes error -body { + wm grid . bad 14 15 16 +} -result {expected integer but got "bad"} +test wm-grid-1.6 {usage} -returnCodes error -body { + wm grid . 13 foo 15 16 +} -result {expected integer but got "foo"} +test wm-grid-1.7 {usage} -returnCodes error -body { + wm grid . 13 14 bar 16 +} -result {expected integer but got "bar"} +test wm-grid-1.8 {usage} -returnCodes error -body { + wm grid . 13 14 15 baz +} -result {expected integer but got "baz"} +test wm-grid-1.9 {usage} -returnCodes error -body { + wm grid . -1 14 15 16 +} -result {baseWidth can't be < 0} +test wm-grid-1.10 {usage} -returnCodes error -body { + wm grid . 13 -1 15 16 +} -result {baseHeight can't be < 0} +test wm-grid-1.11 {usage} -returnCodes error -body { + wm grid . 13 14 -1 16 +} -result {widthInc can't be <= 0} +test wm-grid-1.12 {usage} -returnCodes error -body { + wm grid . 13 14 15 -1 +} -result {heightInc can't be <= 0} + +test wm-grid-2.1 {setting and reading values} -setup { set result {} +} -body { lappend result [wm grid .t] wm grid .t 3 4 10 2 lappend result [wm grid .t] wm grid .t {} {} {} {} lappend result [wm grid .t] -} [list {} {3 4 10 2} {}] +} -result [list {} {3 4 10 2} {}] ### wm group ### -test wm-group-1.1 {usage} { - list [catch {wm group} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-group-1.2 {usage} { - list [catch {wm group .t 12 13} msg] $msg -} {1 {wrong # args: should be "wm group window ?pathName?"}} -test wm-group-1.3 {usage} { - list [catch {wm group .t bogus} msg] $msg -} {1 {bad window path name "bogus"}} - -test wm-group-2.1 {setting and reading values} { +test wm-group-1.1 {usage} -returnCodes error -body { + wm group +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-group-1.2 {usage} -returnCodes error -body { + wm group .t 12 13 +} -result {wrong # args: should be "wm group window ?pathName?"} +test wm-group-1.3 {usage} -returnCodes error -body { + wm group .t bogus +} -result {bad window path name "bogus"} + +test wm-group-2.1 {setting and reading values} -setup { set result {} +} -body { lappend result [wm group .t] wm group .t . lappend result [wm group .t] wm group .t {} lappend result [wm group .t] -} [list {} . {}] +} -result [list {} . {}] ### wm iconbitmap ### -test wm-iconbitmap-1.1 {usage} { - list [catch {wm iconbitmap} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-iconbitmap-1.2.1 {usage} unix { - list [catch {wm iconbitmap .t 12 13} msg] $msg -} {1 {wrong # args: should be "wm iconbitmap window ?bitmap?"}} -test wm-iconbitmap-1.2.2 {usage} win { - list [catch {wm iconbitmap .t 12 13 14} msg] $msg -} {1 {wrong # args: should be "wm iconbitmap window ?-default? ?image?"}} -test wm-iconbitmap-1.3 {usage} win { - list [catch {wm iconbitmap .t 12 13} msg] $msg -} {1 {illegal option "12" must be "-default"}} -test wm-iconbitmap-1.4 {usage} { - list [catch {wm iconbitmap .t bad-bitmap} msg] $msg -} {1 {bitmap "bad-bitmap" not defined}} - -test wm-iconbitmap-2.1 {setting and reading values} { +test wm-iconbitmap-1.1 {usage} -returnCodes error -body { + wm iconbitmap +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-iconbitmap-1.2.1 {usage} -constraints unix -returnCodes error -body { + wm iconbitmap .t 12 13 +} -result {wrong # args: should be "wm iconbitmap window ?bitmap?"} +test wm-iconbitmap-1.2.2 {usage} -constraints win -returnCodes error -body { + wm iconbitmap .t 12 13 14 +} -result {wrong # args: should be "wm iconbitmap window ?-default? ?image?"} +test wm-iconbitmap-1.3 {usage} -constraints win -returnCodes error -body { + wm iconbitmap .t 12 13 +} -result {illegal option "12" must be "-default"} +test wm-iconbitmap-1.4 {usage} -returnCodes error -body { + wm iconbitmap .t bad-bitmap +} -result {bitmap "bad-bitmap" not defined} + +test wm-iconbitmap-2.1 {setting and reading values} -setup { set result {} +} -body { lappend result [wm iconbitmap .t] wm iconbitmap .t hourglass lappend result [wm iconbitmap .t] wm iconbitmap .t {} lappend result [wm iconbitmap .t] -} [list {} hourglass {}] +} -result [list {} hourglass {}] ### wm iconify ### -test wm-iconify-1.1 {usage} { - list [catch {wm iconify} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-iconify-1.2 {usage} { - list [catch {wm iconify .t _} msg] $msg -} {1 {wrong # args: should be "wm iconify window"}} - -test wm-iconify-2.1 {Misc errors} -setup { - destroy .t2 -} -body { +test wm-iconify-1.1 {usage} -returnCodes error -body { + wm iconify +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-iconify-1.2 {usage} -returnCodes error -body { + wm iconify .t _ +} -result {wrong # args: should be "wm iconify window"} + +destroy .t2 +test wm-iconify-2.1 {Misc errors} -body { toplevel .t2 wm overrideredirect .t2 1 wm iconify .t2 } -returnCodes error -cleanup { destroy .t2 } -result {can't iconify ".t2": override-redirect flag is set} -test wm-iconify-2.2 {Misc errors} -setup { - destroy .t2 -} -body { +test wm-iconify-2.2 {Misc errors} -body { toplevel .t2 wm geom .t2 +0+0 wm transient .t2 .t @@ -772,9 +778,7 @@ test wm-iconify-2.2 {Misc errors} -setup { } -returnCodes error -cleanup { destroy .t2 } -result {can't iconify ".t2": it is a transient} -test wm-iconify-2.3 {Misc errors} -setup { - destroy .t2 -} -body { +test wm-iconify-2.3 {Misc errors} -body { toplevel .t2 wm geom .t2 +0+0 wm iconwindow .t .t2 @@ -782,9 +786,8 @@ test wm-iconify-2.3 {Misc errors} -setup { } -returnCodes error -cleanup { destroy .t2 } -result {can't iconify .t2: it is an icon for .t} -if {$tcl_platform(platform) == "windows"} { # test embedded window for Windows -test wm-iconify-2.4 {Misc errors} -setup { +test wm-iconify-2.4.1 {Misc errors} -constraints win -setup { destroy .t2 } -body { frame .t.f -container 1 @@ -793,9 +796,8 @@ test wm-iconify-2.4 {Misc errors} -setup { } -returnCodes error -cleanup { destroy .t2 .r.f } -result {can't iconify .t2: the container does not support the request} -} else { # test embedded window for other platforms -test wm-iconify-2.4 {Misc errors} -setup { +test wm-iconify-2.4.2 {Misc errors} -constraints !win -setup { destroy .t2 } -body { frame .t.f -container 1 @@ -804,10 +806,8 @@ test wm-iconify-2.4 {Misc errors} -setup { } -returnCodes error -cleanup { destroy .t2 .r.f } -result {can't iconify .t2: it is an embedded window} -} -test wm-iconify-3.1 {} -setup { - destroy .t2 -} -body { + +test wm-iconify-3.1 {iconify behavior} -body { toplevel .t2 wm geom .t2 -0+0 update @@ -821,99 +821,102 @@ test wm-iconify-3.1 {} -setup { ### wm iconmask ### -test wm-iconmask-1.1 {usage} { - list [catch {wm iconmask} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-iconmask-1.2 {usage} { - list [catch {wm iconmask .t 12 13} msg] $msg -} {1 {wrong # args: should be "wm iconmask window ?bitmap?"}} -test wm-iconmask-1.3 {usage} { - list [catch {wm iconmask .t bad-bitmap} msg] $msg -} {1 {bitmap "bad-bitmap" not defined}} - -test wm-iconmask-2.1 {setting and reading values} { +test wm-iconmask-1.1 {usage} -returnCodes error -body { + wm iconmask +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-iconmask-1.2 {usage} -returnCodes error -body { + wm iconmask .t 12 13 +} -result {wrong # args: should be "wm iconmask window ?bitmap?"} +test wm-iconmask-1.3 {usage} -returnCodes error -body { + wm iconmask .t bad-bitmap +} -result {bitmap "bad-bitmap" not defined} + +test wm-iconmask-2.1 {setting and reading values} -setup { set result {} +} -body { lappend result [wm iconmask .t] wm iconmask .t hourglass lappend result [wm iconmask .t] wm iconmask .t {} lappend result [wm iconmask .t] -} [list {} hourglass {}] +} -result [list {} hourglass {}] ### wm iconname ### -test wm-iconname-1.1 {usage} { - list [catch {wm iconname} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-iconname-1.2 {usage} { - list [catch {wm iconname .t 12 13} msg] $msg -} {1 {wrong # args: should be "wm iconname window ?newName?"}} - -test wm-iconname-2.1 {setting and reading values} { +test wm-iconname-1.1 {usage} -returnCodes error -body { + wm iconname +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-iconname-1.2 {usage} -returnCodes error -body { + wm iconname .t 12 13 +} -result {wrong # args: should be "wm iconname window ?newName?"} + +test wm-iconname-2.1 {setting and reading values} -setup { set result {} +} -body { lappend result [wm iconname .t] wm iconname .t ThisIconHasAName lappend result [wm iconname .t] wm iconname .t {} lappend result [wm iconname .t] -} [list {} ThisIconHasAName {}] +} -result [list {} ThisIconHasAName {}] ### wm iconphoto ### -test wm-iconphoto-1.1 {usage} { - list [catch {wm iconphoto} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-iconphoto-1.2 {usage} { - list [catch {wm iconphoto .} msg] $msg -} {1 {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"}} -test wm-iconphoto-1.3 {usage} { - list [catch {wm iconphoto . notanimage} msg] $msg -} {1 {can't use "notanimage" as iconphoto: not a photo image}} -test wm-iconphoto-1.4 {usage} { +test wm-iconphoto-1.1 {usage} -returnCodes error -body { + wm iconphoto +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-iconphoto-1.2 {usage} -returnCodes error -body { + wm iconphoto . +} -result {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"} +test wm-iconphoto-1.3 {usage} -returnCodes error -body { + wm iconphoto . notanimage +} -result {can't use "notanimage" as iconphoto: not a photo image} +test wm-iconphoto-1.4 {usage} -returnCodes error -body { # we currently have no return info - list [catch {wm iconphoto . -default} msg] $msg -} {1 {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"}} + wm iconphoto . -default +} -result {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"} # All other iconphoto tests are platform specific ### wm iconposition ### -test wm-iconposition-1.1 {usage} { - list [catch {wm iconposition} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-iconposition-1.2 {usage} { - list [catch {wm iconposition .t 12} msg] $msg -} {1 {wrong # args: should be "wm iconposition window ?x y?"}} -test wm-iconposition-1.3 {usage} { - list [catch {wm iconposition .t 12 13 14} msg] $msg -} {1 {wrong # args: should be "wm iconposition window ?x y?"}} -test wm-iconposition-1.4 {usage} { - list [catch {wm iconposition .t bad 13} msg] $msg -} {1 {expected integer but got "bad"}} -test wm-iconposition-1.5 {usage} { - list [catch {wm iconposition .t 13 lousy} msg] $msg -} {1 {expected integer but got "lousy"}} - -test wm-iconposition-2.1 {setting and reading values} { +test wm-iconposition-1.1 {usage} -returnCodes error -body { + wm iconposition +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-iconposition-1.2 {usage} -returnCodes error -body { + wm iconposition .t 12 +} -result {wrong # args: should be "wm iconposition window ?x y?"} +test wm-iconposition-1.3 {usage} -returnCodes error -body { + wm iconposition .t 12 13 14 +} -result {wrong # args: should be "wm iconposition window ?x y?"} +test wm-iconposition-1.4 {usage} -returnCodes error -body { + wm iconposition .t bad 13 +} -result {expected integer but got "bad"} +test wm-iconposition-1.5 {usage} -returnCodes error -body { + wm iconposition .t 13 lousy +} -result {expected integer but got "lousy"} + +test wm-iconposition-2.1 {setting and reading values} -setup { set result {} +} -body { lappend result [wm iconposition .t] wm iconposition .t 10 20 lappend result [wm iconposition .t] wm iconposition .t {} {} lappend result [wm iconposition .t] -} [list {} {10 20} {}] +} -result [list {} {10 20} {}] ### wm iconwindow ### -test wm-iconwindow-1.1 {usage} { - list [catch {wm iconwindow} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-iconwindow-1.2 {usage} { - list [catch {wm iconwindow .t 12 13} msg] $msg -} {1 {wrong # args: should be "wm iconwindow window ?pathName?"}} -test wm-iconwindow-1.3 {usage} { - list [catch {wm iconwindow .t bogus} msg] $msg -} {1 {bad window path name "bogus"}} +test wm-iconwindow-1.1 {usage} -returnCodes error -body { + wm iconwindow +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-iconwindow-1.2 {usage} -returnCodes error -body { + wm iconwindow .t 12 13 +} -result {wrong # args: should be "wm iconwindow window ?pathName?"} +test wm-iconwindow-1.3 {usage} -returnCodes error -body { + wm iconwindow .t bogus +} -result {bad window path name "bogus"} test wm-iconwindow-1.4 {usage} -setup { destroy .b } -body { @@ -936,8 +939,8 @@ test wm-iconwindow-1.5 {usage} -setup { test wm-iconwindow-2.1 {setting and reading values} -setup { destroy .icon -} -body { set result {} +} -body { lappend result [wm iconwindow .t] toplevel .icon -width 50 -height 50 -bg green wm iconwindow .t .icon @@ -949,21 +952,21 @@ test wm-iconwindow-2.1 {setting and reading values} -setup { ### wm maxsize ### -test wm-maxsize-1.1 {usage} { - list [catch {wm maxsize} msg] $msg -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-maxsize-1.2 {usage} { - list [catch {wm maxsize . a} msg] $msg -} {1 {wrong # args: should be "wm maxsize window ?width height?"}} -test wm-maxsize-1.3 {usage} { - list [catch {wm maxsize . a b c} msg] $msg -} {1 {wrong # args: should be "wm maxsize window ?width height?"}} -test wm-maxsize-1.4 {usage} { - list [catch {wm maxsize . x 100} msg] $msg -} {1 {expected integer but got "x"}} -test wm-maxsize-1.5 {usage} { - list [catch {wm maxsize . 100 bogus} msg] $msg -} {1 {expected integer but got "bogus"}} +test wm-maxsize-1.1 {usage} -returnCodes error -body { + wm maxsize +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-maxsize-1.2 {usage} -returnCodes error -body { + wm maxsize . a +} -result {wrong # args: should be "wm maxsize window ?width height?"} +test wm-maxsize-1.3 {usage} -returnCodes error -body { + wm maxsize . a b c +} -result {wrong # args: should be "wm maxsize window ?width height?"} +test wm-maxsize-1.4 {usage} -returnCodes error -body { + wm maxsize . x 100 +} -result {expected integer but got "x"} +test wm-maxsize-1.5 {usage} -returnCodes error -body { + wm maxsize . 100 bogus +} -result {expected integer but got "bogus"} test wm-maxsize-1.6 {usage} -setup { destroy .t2 } -body { @@ -977,27 +980,28 @@ test wm-maxsize-1.7 {maxsize must be <= screen size} -setup { destroy .t } -body { toplevel .t - foreach {t_width t_height} [wm maxsize .t] break + lassign [wm maxsize .t] t_width t_height set s_width [winfo screenwidth .t] set s_height [winfo screenheight .t] expr {($t_width <= $s_width) && ($t_height <= $s_height)} +} -cleanup { + destroy .t } -result 1 +destroy .t test wm-maxsize-2.1 {setting the maxsize to a value smaller\ - than the current size will resize a toplevel} -setup { - destroy .t -} -body { + than the current size will resize a toplevel} -body { toplevel .t -width 300 -height 300 update wm maxsize .t 200 150 # UpdateGeometryInfo invoked at idle update lrange [split [wm geom .t] x+] 0 1 +} -cleanup { + destroy .t } -result {200 150} test wm-maxsize-2.2 {setting the maxsize to a value smaller\ - than the current size will resize a gridded toplevel} -setup { - destroy .t -} -body { + than the current size will resize a gridded toplevel} -body { toplevel .t wm grid .t 0 0 50 50 wm geometry .t 6x6 @@ -1006,22 +1010,22 @@ test wm-maxsize-2.2 {setting the maxsize to a value smaller\ # UpdateGeometryInfo invoked at idle update lrange [split [wm geom .t] x+] 0 1 +} -cleanup { + destroy .t } -result {4 3} test wm-maxsize-2.3 {attempting to resize to a value\ - bigger than the current maxsize will set it to the max size} -setup { - destroy .t -} -body { + bigger than the current maxsize will set it to the max size} -body { toplevel .t -width 200 -height 200 wm maxsize .t 300 250 update wm geom .t 400x300 update lrange [split [wm geom .t] x+] 0 1 +} -cleanup { + destroy .t } -result {300 250} test wm-maxsize-2.4 {attempting to resize to a value bigger than the\ - current maxsize will set it to the max size when gridded} -setup { - destroy .t -} -body { + current maxsize will set it to the max size when gridded} -body { toplevel .t wm grid .t 1 1 50 50 wm geom .t 4x4 @@ -1030,11 +1034,11 @@ test wm-maxsize-2.4 {attempting to resize to a value bigger than the\ wm geom .t 8x6 update lrange [split [wm geom .t] x+] 0 1 +} -cleanup { + destroy .t } -result {6 5} test wm-maxsize-2.5 {Use max size if window size is not explicitly set\ - and the reqWidth/reqHeight are bigger than the max size} -setup { - destroy .t -} -body { + and the reqWidth/reqHeight are bigger than the max size} -body { toplevel .t pack [frame .t.f -width 400 -height 400] update idletasks @@ -1042,25 +1046,27 @@ test wm-maxsize-2.5 {Use max size if window size is not explicitly set\ wm maxsize .t 300 300 update list $req [lrange [split [wm geom .t] x+] 0 1] +} -cleanup { + destroy .t } -result {{400 400} {300 300}} ### wm minsize ### -test wm-minsize-1.1 {usage} { - list [catch {wm minsize} msg] $msg -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-minsize-1.2 {usage} { - list [catch {wm minsize . a} msg] $msg -} {1 {wrong # args: should be "wm minsize window ?width height?"}} -test wm-minsize-1.3 {usage} { - list [catch {wm minsize . a b c} msg] $msg -} {1 {wrong # args: should be "wm minsize window ?width height?"}} -test wm-minsize-1.4 {usage} { - list [catch {wm minsize . x 100} msg] $msg -} {1 {expected integer but got "x"}} -test wm-minsize-1.5 {usage} { - list [catch {wm minsize . 100 bogus} msg] $msg -} {1 {expected integer but got "bogus"}} +test wm-minsize-1.1 {usage} -returnCodes error -body { + wm minsize +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-minsize-1.2 {usage} -returnCodes error -body { + wm minsize . a +} -result {wrong # args: should be "wm minsize window ?width height?"} +test wm-minsize-1.3 {usage} -returnCodes error -body { + wm minsize . a b c +} -result {wrong # args: should be "wm minsize window ?width height?"} +test wm-minsize-1.4 {usage} -returnCodes error -body { + wm minsize . x 100 +} -result {expected integer but got "x"} +test wm-minsize-1.5 {usage} -returnCodes error -body { + wm minsize . 100 bogus +} -result {expected integer but got "bogus"} test wm-minsize-1.6 {usage} -setup { destroy .t2 } -body { @@ -1072,20 +1078,18 @@ test wm-minsize-1.6 {usage} -setup { } -result {300 200} test wm-minsize-2.1 {setting the minsize to a value larger\ - than the current size will resize a toplevel} -setup { - destroy .t -} -body { + than the current size will resize a toplevel} -body { toplevel .t -width 200 -height 200 update wm minsize .t 400 300 # UpdateGeometryInfo invoked at idle update lrange [split [wm geom .t] x+] 0 1 +} -cleanup { + destroy .t } -result {400 300} test wm-minsize-2.2 {setting the minsize to a value larger\ - than the current size will resize a gridded toplevel} -setup { - destroy .t -} -body { + than the current size will resize a gridded toplevel} -body { toplevel .t wm grid .t 1 1 50 50 wm geom .t 4x4 @@ -1094,22 +1098,22 @@ test wm-minsize-2.2 {setting the minsize to a value larger\ # UpdateGeometryInfo invoked at idle update lrange [split [wm geom .t] x+] 0 1 +} -cleanup { + destroy .t } -result {8 8} test wm-minsize-2.3 {attempting to resize to a value\ - smaller than the current minsize will set it to the minsize} -setup { - destroy .t -} -body { + smaller than the current minsize will set it to the minsize} -body { toplevel .t -width 400 -height 400 wm minsize .t 300 300 update wm geom .t 200x200 update lrange [split [wm geom .t] x+] 0 1 +} -cleanup { + destroy .t } -result {300 300} test wm-minsize-2.4 {attempting to resize to a value smaller than the\ - current minsize will set it to the minsize when gridded} -setup { - destroy .t -} -body { + current minsize will set it to the minsize when gridded} -body { toplevel .t wm grid .t 1 1 50 50 wm geom .t 8x8 @@ -1118,59 +1122,64 @@ test wm-minsize-2.4 {attempting to resize to a value smaller than the\ wm geom .t 4x4 update lrange [split [wm geom .t] x+] 0 1 +} -cleanup { + destroy .t } -result {6 6} test wm-minsize-2.5 {Use min size if window size is not explicitly set\ and the reqWidth/reqHeight are smaller than the min size} -setup { - destroy .t + set result [list] } -body { toplevel .t pack [frame .t.f -width 250 -height 250] update idletasks - set req [list [winfo reqwidth .t] \ - [winfo reqheight .t]] + lappend result [list [winfo reqwidth .t] [winfo reqheight .t]] wm minsize .t 300 300 update - list $req [lrange [split [wm geom .t] x+] 0 1] + lappend result [lrange [split [wm geom .t] x+] 0 1] +} -cleanup { + destroy .t } -result {{250 250} {300 300}} +stdWindow ### wm overrideredirect ### -test wm-overrideredirect-1.1 {usage} { - list [catch {wm overrideredirect} msg] $msg -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-overrideredirect-1.2 {usage} { - list [catch {wm overrideredirect .t 1 2} msg] $msg -} {1 {wrong # args: should be "wm overrideredirect window ?boolean?"}} -test wm-overrideredirect-1.3 {usage} { - list [catch {wm overrideredirect .t boo} msg] $msg -} {1 {expected boolean value but got "boo"}} - -test wm-overrideredirect-2.1 {setting and reading values} { +test wm-overrideredirect-1.1 {usage} -returnCodes error -body { + wm overrideredirect +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-overrideredirect-1.2 {usage} -returnCodes error -body { + wm overrideredirect .t 1 2 +} -result {wrong # args: should be "wm overrideredirect window ?boolean?"} +test wm-overrideredirect-1.3 {usage} -returnCodes error -body { + wm overrideredirect .t boo +} -result {expected boolean value but got "boo"} + +test wm-overrideredirect-2.1 {setting and reading values} -setup { set result {} +} -body { lappend result [wm overrideredirect .t] wm overrideredirect .t true lappend result [wm overrideredirect .t] wm overrideredirect .t off lappend result [wm overrideredirect .t] -} {0 1 0} +} -result {0 1 0} ### wm positionfrom ### -test wm-positionfrom-1.1 {usage} { - list [catch {wm positionfrom} msg] $msg -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-positionfrom-1.2 {usage} { - list [catch {wm positionfrom .t 1 2} msg] $msg -} {1 {wrong # args: should be "wm positionfrom window ?user/program?"}} -test wm-positionfrom-1.3 {usage} { - list [catch {wm positionfrom .t none} msg] $msg -} {1 {bad argument "none": must be program or user}} +test wm-positionfrom-1.1 {usage} -returnCodes error -body { + wm positionfrom +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-positionfrom-1.2 {usage} -returnCodes error -body { + wm positionfrom .t 1 2 +} -result {wrong # args: should be "wm positionfrom window ?user/program?"} +test wm-positionfrom-1.3 {usage} -returnCodes error -body { + wm positionfrom .t none +} -result {bad argument "none": must be program or user} test wm-positionfrom-2.1 {setting and reading values} -setup { destroy .t2 + set result {} } -body { toplevel .t2 - set result {} wm positionfrom .t user lappend result [wm positionfrom .t] wm positionfrom .t program @@ -1183,55 +1192,56 @@ test wm-positionfrom-2.1 {setting and reading values} -setup { ### wm protocol ### -test wm-protocol-1.1 {usage} { - list [catch {wm protocol} msg] $msg -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-protocol-1.2 {usage} { - list [catch {wm protocol .t 1 2 3} msg] $msg -} {1 {wrong # args: should be "wm protocol window ?name? ?command?"}} - -test wm-protocol-2.1 {setting and reading values} { +test wm-protocol-1.1 {usage} -returnCodes error -body { + wm protocol +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-protocol-1.2 {usage} -returnCodes error -body { + wm protocol .t 1 2 3 +} -result {wrong # args: should be "wm protocol window ?name? ?command?"} + +test wm-protocol-2.1 {setting and reading values} -body { wm protocol .t {foo a} {a b c} wm protocol .t bar {test script for bar} - set result [wm protocol .t] + wm protocol .t +} -cleanup { wm protocol .t {foo a} {} wm protocol .t bar {} - set result -} {bar {foo a}} -test wm-protocol-2.2 {setting and reading values} { +} -result {bar {foo a}} +test wm-protocol-2.2 {setting and reading values} -setup { set result {} +} -body { wm protocol .t foo {a b c} wm protocol .t bar {test script for bar} lappend result [wm protocol .t foo] [wm protocol .t bar] wm protocol .t foo {} wm protocol .t bar {} lappend result [wm protocol .t foo] [wm protocol .t bar] -} {{a b c} {test script for bar} {} {}} -test wm-protocol-2.3 {setting and reading values} { +} -result {{a b c} {test script for bar} {} {}} +test wm-protocol-2.3 {setting and reading values} -body { wm protocol .t foo {a b c} wm protocol .t foo {test script} - set result [wm protocol .t foo] + wm protocol .t foo +} -cleanup { wm protocol .t foo {} - set result -} {test script} +} -result {test script} ### wm resizable ### -test wm-resizable-1.1 {usage} { - list [catch {wm resizable} msg] $msg -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-resizable-1.2 {usage} { - list [catch {wm resizable .t 1} msg] $msg -} {1 {wrong # args: should be "wm resizable window ?width height?"}} -test wm-resizable-1.3 {usage} { - list [catch {wm resizable .t 1 2 3} msg] $msg -} {1 {wrong # args: should be "wm resizable window ?width height?"}} -test wm-resizable-1.4 {usage} { - list [catch {wm resizable .t bad 0} msg] $msg -} {1 {expected boolean value but got "bad"}} -test wm-resizable-1.5 {usage} { - list [catch {wm resizable .t 1 bad} msg] $msg -} {1 {expected boolean value but got "bad"}} +test wm-resizable-1.1 {usage} -returnCodes error -body { + wm resizable +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-resizable-1.2 {usage} -returnCodes error -body { + wm resizable .t 1 +} -result {wrong # args: should be "wm resizable window ?width height?"} +test wm-resizable-1.3 {usage} -returnCodes error -body { + wm resizable .t 1 2 3 +} -result {wrong # args: should be "wm resizable window ?width height?"} +test wm-resizable-1.4 {usage} -returnCodes error -body { + wm resizable .t bad 0 +} -result {expected boolean value but got "bad"} +test wm-resizable-1.5 {usage} -returnCodes error -body { + wm resizable .t 1 bad +} -result {expected boolean value but got "bad"} test wm-resizable-2.1 {setting and reading values} { wm resizable .t 0 1 @@ -1244,15 +1254,15 @@ test wm-resizable-2.1 {setting and reading values} { ### wm sizefrom ### -test wm-sizefrom-1.1 {usage} { - list [catch {wm sizefrom} msg] $msg -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-sizefrom-1.2 {usage} { - list [catch {wm sizefrom .t 1 2} msg] $msg -} {1 {wrong # args: should be "wm sizefrom window ?user|program?"}} -test wm-sizefrom-1.4 {usage} { - list [catch {wm sizefrom .t bad} msg] $msg -} {1 {bad argument "bad": must be program or user}} +test wm-sizefrom-1.1 {usage} -returnCodes error -body { + wm sizefrom +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-sizefrom-1.2 {usage} -returnCodes error -body { + wm sizefrom .t 1 2 +} -result {wrong # args: should be "wm sizefrom window ?user|program?"} +test wm-sizefrom-1.4 {usage} -returnCodes error -body { + wm sizefrom .t bad +} -result {bad argument "bad": must be program or user} test wm-sizefrom-2.1 {setting and reading values} { set result [list [wm sizefrom .t]] @@ -1264,105 +1274,107 @@ test wm-sizefrom-2.1 {setting and reading values} { lappend result [wm sizefrom .t] } {{} user program {}} +destroy .t ### wm stackorder ### -test wm-stackorder-1.1 {usage} { - list [catch {wm stackorder} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-stackorder-1.2 {usage} { - list [catch {wm stackorder . _} err] $err -} {1 {wrong # args: should be "wm stackorder window ?isabove|isbelow window?"}} -test wm-stackorder-1.3 {usage} { - list [catch {wm stackorder . _ _ _} err] $err -} {1 {wrong # args: should be "wm stackorder window ?isabove|isbelow window?"}} -test wm-stackorder-1.4 {usage} { - list [catch {wm stackorder . is .} err] $err -} {1 {ambiguous argument "is": must be isabove or isbelow}} -test wm-stackorder-1.5 {usage} { - list [catch {wm stackorder _} err] $err -} {1 {bad window path name "_"}} -test wm-stackorder-1.6 {usage} { - list [catch {wm stackorder . isabove _} err] $err -} {1 {bad window path name "_"}} -test wm-stackorder-1.7 {usage} -setup { - destroy .t -} -body { +test wm-stackorder-1.1 {usage} -returnCodes error -body { + wm stackorder +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-stackorder-1.2 {usage} -returnCodes error -body { + wm stackorder . _ +} -result {wrong # args: should be "wm stackorder window ?isabove|isbelow window?"} +test wm-stackorder-1.3 {usage} -returnCodes error -body { + wm stackorder . _ _ _ +} -result {wrong # args: should be "wm stackorder window ?isabove|isbelow window?"} +test wm-stackorder-1.4 {usage} -returnCodes error -body { + wm stackorder . is . +} -result {ambiguous argument "is": must be isabove or isbelow} +test wm-stackorder-1.5 {usage} -returnCodes error -body { + wm stackorder _ +} -result {bad window path name "_"} +test wm-stackorder-1.6 {usage} -returnCodes error -body { + wm stackorder . isabove _ +} -result {bad window path name "_"} +test wm-stackorder-1.7 {usage} -body { toplevel .t button .t.b wm stackorder .t.b -} -returnCodes error -result {window ".t.b" isn't a top-level window} -test wm-stackorder-1.8 {usage} -setup { +} -cleanup { destroy .t -} -body { +} -returnCodes error -result {window ".t.b" isn't a top-level window} +test wm-stackorder-1.8 {usage} -body { toplevel .t button .t.b pack .t.b update wm stackorder . isabove .t.b -} -returnCodes error -result {window ".t.b" isn't a top-level window} -test wm-stackorder-1.9 {usage} -setup { +} -cleanup { destroy .t -} -body { +} -returnCodes error -result {window ".t.b" isn't a top-level window} +test wm-stackorder-1.9 {usage} -body { toplevel .t button .t.b pack .t.b update wm stackorder . isbelow .t.b -} -returnCodes error -result {window ".t.b" isn't a top-level window} -test wm-stackorder-1.10 {usage, isabove|isbelow toplevels must be mapped} -setup { +} -cleanup { destroy .t -} -body { +} -returnCodes error -result {window ".t.b" isn't a top-level window} +test wm-stackorder-1.10 {usage, isabove|isbelow toplevels must be mapped} -body { toplevel .t update wm withdraw .t wm stackorder .t isabove . -} -returnCodes error -result {window ".t" isn't mapped} -test wm-stackorder-1.11 {usage, isabove|isbelow toplevels must be mapped} -setup { +} -cleanup { destroy .t -} -body { +} -returnCodes error -result {window ".t" isn't mapped} +test wm-stackorder-1.11 {usage, isabove|isbelow toplevels must be mapped} -body { toplevel .t update wm withdraw .t wm stackorder . isbelow .t +} -cleanup { + destroy .t } -returnCodes error -result {window ".t" isn't mapped} deleteWindows -test wm-stackorder-2.1 {} -setup { - destroy .t -} -body { +test wm-stackorder-2.1 {stacking order} -body { toplevel .t ; update wm stackorder . -} -result {. .t} -test wm-stackorder-2.2 {} -setup { +} -cleanup { destroy .t -} -body { +} -result {. .t} +test wm-stackorder-2.2 {stacking order} -body { toplevel .t ; update raise . raiseDelay wm stackorder . +} -cleanup { + destroy .t } -result {.t .} -test wm-stackorder-2.3 {} -setup { - destroy .t .t2 -} -body { +test wm-stackorder-2.3 {stacking order} -body { toplevel .t ; update toplevel .t2 ; update raise . raise .t2 raiseDelay wm stackorder . -} -result {.t . .t2} -test wm-stackorder-2.4 {} -setup { +} -cleanup { destroy .t .t2 -} -body { +} -result {.t . .t2} +test wm-stackorder-2.4 {stacking order} -body { toplevel .t ; update toplevel .t2 ; update raise . lower .t2 raiseDelay wm stackorder . +} -cleanup { + destroy .t .t2 } -result {.t2 .t .} -test wm-stackorder-2.5 {} { +test wm-stackorder-2.5 {stacking order} -setup { destroy .parent +} -body { toplevel .parent ; update destroy .parent.child1 toplevel .parent.child1 ; update @@ -1374,123 +1386,124 @@ test wm-stackorder-2.5 {} { lower .parent.child2 raiseDelay wm stackorder .parent -} {.parent.child2 .parent.child1 .parent} -deleteWindows -test wm-stackorder-2.6 {non-toplevel widgets ignored} -setup { - destroy .t1 -} -body { +} -cleanup { + deleteWindows +} -result {.parent.child2 .parent.child1 .parent} +test wm-stackorder-2.6 {stacking order: non-toplevel widgets ignored} -body { toplevel .t1 button .t1.b pack .t1.b update wm stackorder . +} -cleanup { + destroy .t1 } -result {. .t1} -deleteWindows -test wm-stackorder-2.7 {no children returns self} { +test wm-stackorder-2.7 {stacking order: no children returns self} -setup { + deleteWindows +} -body { wm stackorder . -} {.} +} -result {.} + deleteWindows -test wm-stackorder-3.1 {unmapped toplevel} -setup { - destroy .t1 .t2 -} -body { +test wm-stackorder-3.1 {unmapped toplevel} -body { toplevel .t1 ; update toplevel .t2 ; update wm iconify .t1 wm stackorder . -} -result {. .t2} -test wm-stackorder-3.2 {unmapped toplevel} -setup { +} -cleanup { destroy .t1 .t2 -} -body { +} -result {. .t2} +test wm-stackorder-3.2 {unmapped toplevel} -body { toplevel .t1 ; update toplevel .t2 ; update wm withdraw .t2 wm stackorder . -} -result {. .t1} -test wm-stackorder-3.3 {unmapped toplevel} -setup { +} -cleanup { destroy .t1 .t2 -} -body { +} -result {. .t1} +test wm-stackorder-3.3 {unmapped toplevel} -body { toplevel .t1 ; update toplevel .t2 ; update wm withdraw .t2 wm stackorder .t2 +} -cleanup { + destroy .t1 .t2 } -result {} -test wm-stackorder-3.4 {unmapped toplevel} -setup { - destroy .t1 -} -body { +test wm-stackorder-3.4 {unmapped toplevel} -body { toplevel .t1 ; update toplevel .t1.t2 ; update wm withdraw .t1.t2 wm stackorder .t1 -} -result {.t1} -test wm-stackorder-3.5 {unmapped toplevel} -setup { +} -cleanup { destroy .t1 -} -body { +} -result {.t1} +test wm-stackorder-3.5 {unmapped toplevel} -body { toplevel .t1 ; update toplevel .t1.t2 ; update wm withdraw .t1 wm stackorder .t1 -} -result {.t1.t2} -test wm-stackorder-3.6 {unmapped toplevel} -setup { +} -cleanup { destroy .t1 -} -body { +} -result {.t1.t2} +test wm-stackorder-3.6 {unmapped toplevel} -body { toplevel .t1 ; update toplevel .t1.t2 ; update toplevel .t1.t2.t3 ; update wm withdraw .t1.t2 wm stackorder .t1 -} -result {.t1 .t1.t2.t3} -test wm-stackorder-3.7 {unmapped toplevel, mapped children returned} -setup { +} -cleanup { destroy .t1 -} -body { +} -result {.t1 .t1.t2.t3} +test wm-stackorder-3.7 {unmapped toplevel, mapped children returned} -body { toplevel .t1 ; update toplevel .t1.t2 ; update wm withdraw .t1 wm stackorder .t1 -} -result {.t1.t2} -test wm-stackorder-3.8 {toplevel mapped in idle callback } -setup { +} -cleanup { destroy .t1 -} -body { +} -result {.t1.t2} +test wm-stackorder-3.8 {toplevel mapped in idle callback} -body { toplevel .t1 wm stackorder . +} -cleanup { + destroy .t1 } -result {.} deleteWindows -test wm-stackorder-4.1 {wm stackorder isabove|isbelow} -setup { - destroy .t -} -body { +test wm-stackorder-4.1 {wm stackorder isabove|isbelow} -body { toplevel .t ; update raise .t wm stackorder . isabove .t -} -result {0} -test wm-stackorder-4.2 {wm stackorder isabove|isbelow} -setup { +} -cleanup { destroy .t -} -body { +} -result {0} +test wm-stackorder-4.2 {wm stackorder isabove|isbelow} -body { toplevel .t ; update raise .t wm stackorder . isbelow .t -} -result {1} -test wm-stackorder-4.3 {wm stackorder isabove|isbelow} -setup { +} -cleanup { destroy .t -} -body { +} -result {1} +test wm-stackorder-4.3 {wm stackorder isabove|isbelow} -body { toplevel .t ; update raise . raiseDelay wm stackorder .t isa . -} -result {0} -test wm-stackorder-4.4 {wm stackorder isabove|isbelow} -setup { +} -cleanup { destroy .t -} -body { +} -result {0} +test wm-stackorder-4.4 {wm stackorder isabove|isbelow} -body { toplevel .t ; update raise . raiseDelay wm stackorder .t isb . +} -cleanup { + destroy .t } -result {1} deleteWindows -test wm-stackorder-5.1 {a menu is not a toplevel} -setup { - destroy .t -} -body { +test wm-stackorder-5.1 {a menu is not a toplevel} -body { toplevel .t menu .t.m -type menubar .t.m add cascade -label "File" @@ -1499,113 +1512,122 @@ test wm-stackorder-5.1 {a menu is not a toplevel} -setup { raise . raiseDelay wm stackorder . +} -cleanup { + destroy .t } -result {.t .} test wm-stackorder-5.2 {A normal toplevel can't be\ - raised above an overrideredirect toplevel} -setup { - destroy .t -} -body { + raised above an overrideredirect toplevel} -body { toplevel .t wm overrideredirect .t 1 raise . update raiseDelay wm stackorder . isabove .t +} -cleanup { + destroy .t } -result 0 test wm-stackorder-5.3 {An overrideredirect window\ - can be explicitly lowered} -setup { - destroy .t -} -body { + can be explicitly lowered} -body { toplevel .t wm overrideredirect .t 1 lower .t update raiseDelay wm stackorder .t isbelow . +} -cleanup { + destroy .t } -result 1 test wm-stackorder-6.1 {An embedded toplevel does not\ - appear in the stacking order} -setup { - deleteWindows -} -body { + appear in the stacking order} -body { toplevel .real -container 1 toplevel .embd -bg blue -use [winfo id .real] update wm stackorder . +} -cleanup { + deleteWindows } -result {. .real} -stdWindow +stdWindow ### wm title ### -test wm-title-1.1 {usage} { - list [catch {wm title} msg] $msg -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-title-1.2 {usage} { - list [catch {wm title . 1 2} msg] $msg -} {1 {wrong # args: should be "wm title window ?newTitle?"}} - -test wm-title-2.1 {setting and reading values} { +test wm-title-1.1 {usage} -returnCodes error -body { + wm title +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-title-1.2 {usage} -returnCodes error -body { + wm title . 1 2 +} -result {wrong # args: should be "wm title window ?newTitle?"} + +test wm-title-2.1 {setting and reading values} -setup { destroy .t +} -body { toplevel .t set result [wm title .t] wm title .t Apa lappend result [wm title .t] wm title .t {} lappend result [wm title .t] -} {t Apa {}} +} -result {t Apa {}} ### wm transient ### -test wm-transient-1.1 {usage} { +test wm-transient-1.1 {usage} -returnCodes error -body { catch {destroy .t} ; toplevel .t - list [catch {wm transient .t 1 2} msg] $msg -} {1 {wrong # args: should be "wm transient window ?master?"}} -test wm-transient-1.2 {usage} { + wm transient .t 1 2 +} -result {wrong # args: should be "wm transient window ?master?"} +test wm-transient-1.2 {usage} -returnCodes error -body { catch {destroy .t} ; toplevel .t - list [catch {wm transient .t foo} msg] $msg -} {1 {bad window path name "foo"}} -test wm-transient-1.3 {usage} { + wm transient .t foo +} -result {bad window path name "foo"} +test wm-transient-1.3 {usage} -returnCodes error -body { catch {destroy .t} ; toplevel .t - list [catch {wm transient foo .t} msg] $msg -} {1 {bad window path name "foo"}} -test wm-transient-1.4 {usage} { - deleteWindows + wm transient foo .t +} -result {bad window path name "foo"} +deleteWindows +test wm-transient-1.4 {usage} -returnCodes error -body { toplevel .master toplevel .subject wm transient .subject .master - list [catch {wm iconify .subject} msg] $msg -} {1 {can't iconify ".subject": it is a transient}} -test wm-transient-1.5 {usage} { + wm iconify .subject +} -cleanup { deleteWindows +} -result {can't iconify ".subject": it is a transient} +test wm-transient-1.5 {usage} -returnCodes error -body { toplevel .icon -bg blue toplevel .top wm iconwindow .top .icon toplevel .dummy - list [catch {wm transient .icon .dummy} msg] $msg -} {1 {can't make ".icon" a transient: it is an icon for .top}} -test wm-transient-1.6 {usage} { + wm transient .icon .dummy +} -cleanup { deleteWindows +} -result {can't make ".icon" a transient: it is an icon for .top} +test wm-transient-1.6 {usage} -returnCodes error -body { toplevel .icon -bg blue toplevel .top wm iconwindow .top .icon toplevel .dummy - list [catch {wm transient .dummy .icon} msg] $msg -} {1 {can't make ".icon" a master: it is an icon for .top}} -test wm-transient-1.7 {usage} { + wm transient .dummy .icon +} -cleanup { deleteWindows +} -result {can't make ".icon" a master: it is an icon for .top} +test wm-transient-1.7 {usage} -returnCodes error -body { toplevel .master - list [catch {wm transient .master .master} err] $err -} {1 {can't make ".master" its own master}} -test wm-transient-1.8 {usage} { + wm transient .master .master +} -cleanup { deleteWindows +} -result {can't make ".master" its own master} +test wm-transient-1.8 {usage} -returnCodes error -body { toplevel .master frame .master.f - list [catch {wm transient .master .master.f} err] $err -} {1 {can't make ".master" its own master}} - -test wm-transient-2.1 { basic get/set of master } { + wm transient .master .master.f +} -cleanup { deleteWindows - set results [list] +} -result {can't make ".master" its own master} + +test wm-transient-2.1 {basic get/set of master} -setup { + set results [list] +} -body { toplevel .master toplevel .subject lappend results [wm transient .subject] @@ -1613,21 +1635,21 @@ test wm-transient-2.1 { basic get/set of master } { lappend results [wm transient .subject] wm transient .subject {} lappend results [wm transient .subject] - set results -} {{} .master {}} -test wm-transient-2.2 { first toplevel parent of - non-toplevel master is used } { +} -cleanup { deleteWindows +} -result {{} .master {}} +test wm-transient-2.2 {first toplevel parent of non-toplevel master is used} -body { toplevel .master frame .master.f toplevel .subject wm transient .subject .master.f wm transient .subject -} {.master} - -test wm-transient-3.1 { transient toplevel is withdrawn - when mapped if master is withdrawn } { +} -cleanup { deleteWindows +} -result {.master} + +test wm-transient-3.1 {transient toplevel is withdrawn + when mapped if master is withdrawn} -body { toplevel .master wm withdraw .master update @@ -1635,10 +1657,11 @@ test wm-transient-3.1 { transient toplevel is withdrawn wm transient .subject .master update list [wm state .subject] [winfo ismapped .subject] -} {withdrawn 0} -test wm-transient-3.2 { already mapped transient toplevel - takes on withdrawn state of master } { +} -cleanup { deleteWindows +} -result {withdrawn 0} +test wm-transient-3.2 {already mapped transient toplevel + takes on withdrawn state of master} -body { toplevel .master wm withdraw .master update @@ -1647,29 +1670,29 @@ test wm-transient-3.2 { already mapped transient toplevel wm transient .subject .master update list [wm state .subject] [winfo ismapped .subject] -} {withdrawn 0} -test wm-transient-3.3 { withdraw/deiconify on the master - also does a withdraw/deiconify on the transient } { +} -cleanup { deleteWindows +} -result {withdrawn 0} +test wm-transient-3.3 {withdraw/deiconify on the master + also does a withdraw/deiconify on the transient} -setup { set results [list] +} -body { toplevel .master toplevel .subject update wm transient .subject .master wm withdraw .master update - lappend results [wm state .subject] \ - [winfo ismapped .subject] + lappend results [wm state .subject] [winfo ismapped .subject] wm deiconify .master update - lappend results [wm state .subject] \ - [winfo ismapped .subject] - set results -} {withdrawn 0 normal 1} - -test wm-transient-4.1 { transient toplevel is withdrawn - when mapped if master is iconic } { + lappend results [wm state .subject] [winfo ismapped .subject] +} -cleanup { deleteWindows +} -result {withdrawn 0 normal 1} + +test wm-transient-4.1 {transient toplevel is withdrawn + when mapped if master is iconic} -body { toplevel .master wm iconify .master update @@ -1677,10 +1700,11 @@ test wm-transient-4.1 { transient toplevel is withdrawn wm transient .subject .master update list [wm state .subject] [winfo ismapped .subject] -} {withdrawn 0} -test wm-transient-4.2 { already mapped transient toplevel - is withdrawn if master is iconic } { +} -cleanup { deleteWindows +} -result {withdrawn 0} +test wm-transient-4.2 {already mapped transient toplevel + is withdrawn if master is iconic} -body { toplevel .master wm iconify .master update @@ -1689,30 +1713,31 @@ test wm-transient-4.2 { already mapped transient toplevel wm transient .subject .master update list [wm state .subject] [winfo ismapped .subject] -} {withdrawn 0} -test wm-transient-4.3 { iconify/deiconify on the master - does a withdraw/deiconify on the transient } { +} -cleanup { deleteWindows +} -result {withdrawn 0} +test wm-transient-4.3 {iconify/deiconify on the master + does a withdraw/deiconify on the transient} -setup { set results [list] +} -body { toplevel .master toplevel .subject update wm transient .subject .master wm iconify .master update - lappend results [wm state .subject] \ - [winfo ismapped .subject] + lappend results [wm state .subject] [winfo ismapped .subject] wm deiconify .master update - lappend results [wm state .subject] \ - [winfo ismapped .subject] - set results -} {withdrawn 0 normal 1} - -test wm-transient-5.1 { an error during transient command should not - cause the map/unmap binding to be deleted } { + lappend results [wm state .subject] [winfo ismapped .subject] +} -cleanup { deleteWindows +} -result {withdrawn 0 normal 1} + +test wm-transient-5.1 {an error during transient command should not + cause the map/unmap binding to be deleted} -setup { set results [list] +} -body { toplevel .master toplevel .subject update @@ -1725,11 +1750,11 @@ test wm-transient-5.1 { an error during transient command should not wm deiconify .master update lappend results [wm state .subject] - set results -} {1 withdrawn normal} -test wm-transient-5.2 { remove transient property when master - is destroyed } { +} -cleanup { deleteWindows +} -result {1 withdrawn normal} +test wm-transient-5.2 {remove transient property when master + is destroyed} -body { toplevel .master toplevel .subject wm transient .subject .master @@ -1737,20 +1762,22 @@ test wm-transient-5.2 { remove transient property when master destroy .master update wm transient .subject -} {} -test wm-transient-5.3 { remove transient property from window - that had never been mapped when master is destroyed } { +} -cleanup { deleteWindows +} -result {} +test wm-transient-5.3 {remove transient property from window + that had never been mapped when master is destroyed} -body { toplevel .master toplevel .subject wm transient .subject .master destroy .master wm transient .subject -} {} - -test wm-transient-6.1 { a withdrawn transient does not track - state changes in the master } { +} -cleanup { deleteWindows +} -result {} + +test wm-transient-6.1 {a withdrawn transient does not track + state changes in the master} -body { toplevel .master toplevel .subject update @@ -1761,11 +1788,13 @@ test wm-transient-6.1 { a withdrawn transient does not track # idle handler should not map the transient update wm state .subject -} {withdrawn} -test wm-transient-6.2 { a withdrawn transient does not track - state changes in the master } { - set results [list] +} -cleanup { deleteWindows +} -result {withdrawn} +test wm-transient-6.2 {a withdrawn transient does not track + state changes in the master} -setup { + set results [list] +} -body { toplevel .master toplevel .subject update @@ -1784,10 +1813,11 @@ test wm-transient-6.2 { a withdrawn transient does not track # idle handler should map transient update lappend results [wm state .subject] -} {withdrawn normal withdrawn normal} -test wm-transient-6.3 { a withdrawn transient does not track - state changes in the master } { +} -cleanup { deleteWindows +} -result {withdrawn normal withdrawn normal} +test wm-transient-6.3 {a withdrawn transient does not track + state changes in the master} -body { toplevel .master toplevel .subject update @@ -1799,244 +1829,271 @@ test wm-transient-6.3 { a withdrawn transient does not track # idle handler should not map the transient update wm state .subject -} {withdrawn} +} -cleanup { + deleteWindows +} -result {withdrawn} # wm-transient-7.*: See SF Tk Bug #592201 "wm transient fails with two masters" # wm-transient-7.3 through 7.5 all caused panics on Unix in Tk 8.4b1. # 7.1 and 7.2 added to catch (potential) future errors. # -test wm-transient-7.1 {Destroying transient} { - deleteWindows - toplevel .t - toplevel .transient +test wm-transient-7.1 {Destroying transient} -body { + toplevel .t + toplevel .transient wm transient .transient .t destroy .transient destroy .t # OK: the above did not cause a panic. -} {} -test wm-transient-7.2 {Destroying master} { +} -cleanup { deleteWindows +} +test wm-transient-7.2 {Destroying master} -body { toplevel .t - toplevel .transient + toplevel .transient wm transient .transient .t destroy .t - set result [wm transient .transient] - destroy .transient - set result -} {} -test wm-transient-7.3 {Reassign transient, destroy old master} { + wm transient .transient +} -cleanup { deleteWindows - toplevel .t1 - toplevel .t2 +} -result {} +test wm-transient-7.3 {Reassign transient, destroy old master} -body { + toplevel .t1 + toplevel .t2 toplevel .transient wm transient .transient .t1 wm transient .transient .t2 destroy .t1 ;# Caused panic in 8.4b1 - destroy .t2 + destroy .t2 destroy .transient -} {} -test wm-transient-7.4 {Reassign transient, destroy new master} { +} -cleanup { deleteWindows - toplevel .t1 - toplevel .t2 +} +test wm-transient-7.4 {Reassign transient, destroy new master} -body { + toplevel .t1 + toplevel .t2 toplevel .transient wm transient .transient .t1 wm transient .transient .t2 destroy .t2 ;# caused panic in 8.4b1 destroy .t1 destroy .transient -} {} -test wm-transient-7.5 {Reassign transient, destroy transient} { +} -cleanup { deleteWindows - toplevel .t1 - toplevel .t2 +} +test wm-transient-7.5 {Reassign transient, destroy transient} -body { + toplevel .t1 + toplevel .t2 toplevel .transient wm transient .transient .t1 wm transient .transient .t2 destroy .transient destroy .t2 ;# caused panic in 8.4b1 destroy .t1 ;# so did this -} {} +} -cleanup { + deleteWindows +} ### wm state ### -test wm-state-1.1 {usage} { - list [catch {wm state} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-state-1.2 {usage} { - list [catch {wm state . _ _} err] $err -} {1 {wrong # args: should be "wm state window ?state?"}} +test wm-state-1.1 {usage} -returnCodes error -body { + wm state +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-state-1.2 {usage} -returnCodes error -body { + wm state . _ _ +} -result {wrong # args: should be "wm state window ?state?"} -test wm-state-2.1 {initial state} { - deleteWindows +deleteWindows +test wm-state-2.1 {initial state} -body { toplevel .t wm state .t -} {normal} -test wm-state-2.2 {state change before map} { +} -cleanup { deleteWindows +} -result {normal} +test wm-state-2.2 {state change before map} -body { toplevel .t wm state .t withdrawn wm state .t -} {withdrawn} -test wm-state-2.3 {state change before map} { +} -cleanup { deleteWindows +} -result {withdrawn} +test wm-state-2.3 {state change before map} -body { toplevel .t wm withdraw .t wm state .t -} {withdrawn} -test wm-state-2.4 {state change after map} { +} -cleanup { deleteWindows +} -result {withdrawn} +test wm-state-2.4 {state change after map} -body { toplevel .t update wm state .t withdrawn wm state .t -} {withdrawn} -test wm-state-2.5 {state change after map} { +} -cleanup { deleteWindows +} -result {withdrawn} +test wm-state-2.5 {state change after map} -body { toplevel .t update wm withdraw .t wm state .t -} {withdrawn} -test wm-state-2.6 {state change before map} { +} -cleanup { deleteWindows +} -result {withdrawn} +test wm-state-2.6 {state change before map} -body { toplevel .t wm state .t iconic wm state .t -} {iconic} -test wm-state-2.7 {state change before map} { +} -cleanup { deleteWindows +} -result {iconic} +test wm-state-2.7 {state change before map} -body { toplevel .t wm iconify .t wm state .t -} {iconic} -test wm-state-2.8 {state change after map} { +} -cleanup { deleteWindows +} -result {iconic} +test wm-state-2.8 {state change after map} -body { toplevel .t update wm state .t iconic wm state .t -} {iconic} -test wm-state-2.9 {state change after map} { +} -cleanup { deleteWindows +} -result {iconic} +test wm-state-2.9 {state change after map} -body { toplevel .t update wm iconify .t wm state .t -} {iconic} -test wm-state-2.10 {state change before map} { +} -cleanup { deleteWindows +} -result {iconic} +test wm-state-2.10 {state change before map} -body { toplevel .t wm withdraw .t wm state .t normal wm state .t -} {normal} -test wm-state-2.11 {state change before map} { +} -cleanup { deleteWindows +} -result {normal} +test wm-state-2.11 {state change before map} -body { toplevel .t wm withdraw .t wm deiconify .t wm state .t -} {normal} -test wm-state-2.12 {state change after map} { +} -cleanup { deleteWindows +} -result {normal} +test wm-state-2.12 {state change after map} -body { toplevel .t update wm withdraw .t wm state .t normal wm state .t -} {normal} -test wm-state-2.13 {state change after map} { +} -cleanup { deleteWindows +} -result {normal} +test wm-state-2.13 {state change after map} -body { toplevel .t update wm withdraw .t wm deiconify .t wm state .t -} {normal} -test wm-state-2.14 {state change before map} { +} -cleanup { deleteWindows +} -result {normal} +test wm-state-2.14 {state change before map} -body { toplevel .t wm iconify .t wm state .t normal wm state .t -} {normal} -test wm-state-2.15 {state change before map} { +} -cleanup { deleteWindows +} -result {normal} +test wm-state-2.15 {state change before map} -body { toplevel .t wm iconify .t wm deiconify .t wm state .t -} {normal} -test wm-state-2.16 {state change after map} { +} -cleanup { deleteWindows +} -result {normal} +test wm-state-2.16 {state change after map} -body { toplevel .t update wm iconify .t wm state .t normal wm state .t -} {normal} -test wm-state-2.17 {state change after map} { +} -cleanup { deleteWindows +} -result {normal} +test wm-state-2.17 {state change after map} -body { toplevel .t update wm iconify .t wm deiconify .t wm state .t -} {normal} -test wm-state-2.18 {state change after map} win { +} -cleanup { deleteWindows +} -result {normal} +test wm-state-2.18 {state change after map} -constraints win -body { toplevel .t update wm state .t zoomed wm state .t -} {zoomed} +} -cleanup { + deleteWindows +} -result {zoomed} ### wm withdraw ### -test wm-withdraw-1.1 {usage} { - list [catch {wm withdraw} err] $err -} {1 {wrong # args: should be "wm option window ?arg ...?"}} -test wm-withdraw-1.2 {usage} { - list [catch {wm withdraw . _} msg] $msg -} {1 {wrong # args: should be "wm withdraw window"}} +test wm-withdraw-1.1 {usage} -returnCodes error -body { + wm withdraw +} -result {wrong # args: should be "wm option window ?arg ...?"} +test wm-withdraw-1.2 {usage} -returnCodes error -body { + wm withdraw . _ +} -result {wrong # args: should be "wm withdraw window"} -test wm-withdraw-2.1 {Misc errors} -setup { - deleteWindows -} -body { +deleteWindows +test wm-withdraw-2.1 {Misc errors} -body { toplevel .t toplevel .t2 wm iconwindow .t .t2 wm withdraw .t2 } -returnCodes error -cleanup { - destroy .t2 + deleteWindows } -result {can't withdraw .t2: it is an icon for .t} -test wm-withdraw-3.1 {} { - update +test wm-withdraw-3.1 {} -setup { set result {} +} -body { + toplevel .t + update wm withdraw .t lappend result [wm state .t] [winfo ismapped .t] wm deiconify .t lappend result [wm state .t] [winfo ismapped .t] -} {withdrawn 0 normal 1} +} -cleanup { + deleteWindows +} -result {withdrawn 0 normal 1} ### Misc. wm tests ### -test wm-deletion-epoch-1.1 {Deletion epoch on multiple displays} -constraints altDisplay -setup { - deleteWindows -} -body { +test wm-deletion-epoch-1.1 {Deletion epoch on multiple displays} -constraints altDisplay -body { # See Tk Bug #671330 "segfault when e.g. deiconifying destroyed window" set w [toplevel .t -screen $env(TK_ALT_DISPLAY)] wm deiconify $w ;# this caches the WindowRep destroy .t wm deiconify $w -} -returnCodes error -result {bad window path name ".t"} +} -returnCodes error -result {bad window path name ".t"} -cleanup { + deleteWindows +} ### Docking test (manage, forget) ### -test wm-manage-1.1 {} { - deleteWindows +test wm-manage-1.1 {managing a button} -setup { set result [list] +} -body { toplevel .t button .t.b -text "Manage This" pack .t.b @@ -2052,12 +2109,12 @@ test wm-manage-1.1 {} { update lappend result [winfo manage .t.b] lappend result [winfo toplevel .t.b] - set result -} {pack .t wm .t.b pack .t} - -test wm-manage-1.2 {} { +} -cleanup { deleteWindows +} -result {pack .t wm .t.b pack .t} +test wm-manage-1.2 {unmanaging a toplevel} -setup { set result [list] +} -body { toplevel .t toplevel .t.t button .t.t.b -text "Manage This" @@ -2077,17 +2134,20 @@ test wm-manage-1.2 {} { update lappend result [winfo manage .t.t] lappend result [winfo toplevel .t.t.b] -} {wm .t.t pack .t wm .t.t} +} -cleanup { + deleteWindows +} -result {wm .t.t pack .t wm .t.t} # FIXME: -# Test delivery of virtual events to the WM. We could check to see -# if the window was raised after a button click for example. -# This sort of testing may not be possible. +# Test delivery of virtual events to the WM. We could check to see if the +# window was raised after a button click for example. This sort of testing may +# not be possible. + +############################################################################## deleteWindows cleanupTests catch {unset results} catch {unset focusin} return - diff --git a/unix/Makefile.in b/unix/Makefile.in index f3f1d64..33276d2 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -5,7 +5,7 @@ # "autoconf" program (constructs like "@foo@" will get replaced in the # actual Makefile. # -# RCS: @(#) $Id: Makefile.in,v 1.128.2.10 2008/03/13 14:57:34 dgp Exp $ +# RCS: @(#) $Id: Makefile.in,v 1.128.2.11 2008/03/26 20:09:32 dgp Exp $ # Current Tk version; used in various names. @@ -370,13 +370,11 @@ TTK_OBJS = \ ttkPanedwindow.o ttkProgress.o ttkScale.o ttkScrollbar.o ttkScroll.o \ ttkSeparator.o ttkSquare.o ttkState.o \ ttkTagSet.o ttkTheme.o ttkTrace.o ttkTrack.o ttkTreeview.o \ - ttkWidget.o - -TTK_STUB_OBJS = ttkStubInit.o ttkStubLib.o + ttkWidget.o ttkStubInit.o STUB_OBJS = tkStubInit.o tkStubLib.o -STUB_LIB_OBJS = tkStubLib.o +STUB_LIB_OBJS = tkStubLib.o ttkStubLib.o X11_OBJS = tkUnix.o tkUnix3d.o tkUnixButton.o tkUnixColor.o tkUnixConfig.o \ tkUnixCursor.o tkUnixDraw.o tkUnixEmbed.o tkUnixEvent.o \ @@ -400,7 +398,7 @@ AQUA_OBJS = tkMacOSXBitmap.o tkMacOSXButton.o tkMacOSXClipboard.o \ AQUA_TKTEST_OBJS = tkMacOSXTest.o OBJS = $(GENERIC_OBJS) $(WIDG_OBJS) $(CANV_OBJS) $(IMAGE_OBJS) $(TEXT_OBJS) \ - $(STUB_OBJS) $(TTK_OBJS) $(TTK_STUB_OBJS) \ + $(STUB_OBJS) $(TTK_OBJS) \ $(@TK_WINDOWINGSYSTEM@_OBJS) @PLAT_OBJS@ TK_DECLS = \ diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 3a13ea3..9476cae 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1454,10 +1454,6 @@ dnl AC_CHECK_TOOL(AR, ar) # files in compat/*.c is being linked in. AS_IF([test x"${USE_COMPAT}" != x],[CFLAGS="$CFLAGS -fno-inline"]) - - # XIM peeking works under XFree86. - AC_DEFINE(PEEK_XCLOSEIM, 1, [May we use XIM peeking safely?]) - ;; GNU*) SHLIB_CFLAGS="-fPIC" diff --git a/unix/tkConfig.h.in b/unix/tkConfig.h.in index 819efff..285bb38 100644 --- a/unix/tkConfig.h.in +++ b/unix/tkConfig.h.in @@ -130,9 +130,6 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* May we use XIM peeking safely? */ -#undef PEEK_XCLOSEIM - /* Is this a static build? */ #undef STATIC_BUILD diff --git a/unix/tkUnixCursor.c b/unix/tkUnixCursor.c index fa7f25c..447053f 100644 --- a/unix/tkUnixCursor.c +++ b/unix/tkUnixCursor.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: tkUnixCursor.c,v 1.10.2.1 2007/09/07 01:25:38 dgp Exp $ + * RCS: @(#) $Id: tkUnixCursor.c,v 1.10.2.2 2008/03/26 20:09:33 dgp Exp $ */ #include "tkInt.h" @@ -493,7 +493,7 @@ CreateCursorFromTableOrFile( * If there is no mask data, then create the cursor now. */ - if ((!inTkTable && (argc == 2)) || (tkCursorPtr->mask == NULL)) { + if ((!inTkTable && (argc == 2)) || (inTkTable && tkCursorPtr->mask == NULL)) { cursor = XCreatePixmapCursor(display, source, source, &fg, &fg, (unsigned) xHot, (unsigned) yHot); goto cleanup; @@ -532,7 +532,7 @@ CreateCursorFromTableOrFile( } } - if ((maskWidth != width) && (maskHeight != height)) { + if ((maskWidth != width) || (maskHeight != height)) { Tcl_SetResult(interp, "source and mask bitmaps have different sizes", TCL_STATIC); goto cleanup; diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c index 3b11cb4..3a1b2a0 100644 --- a/unix/tkUnixEvent.c +++ b/unix/tkUnixEvent.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixEvent.c,v 1.24.2.1 2007/09/07 01:25:39 dgp Exp $ + * RCS: @(#) $Id: tkUnixEvent.c,v 1.24.2.2 2008/03/26 20:09:33 dgp Exp $ */ #include "tkUnixInt.h" @@ -25,18 +25,6 @@ typedef struct ThreadSpecificData { } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; -#if defined(TK_USE_INPUT_METHODS) && defined(PEEK_XCLOSEIM) -/* - * Structure used to peek into internal XIM data structure. This is only known - * to work with XFree86. - */ - -struct XIMPeek { - void *junk1, *junk2; - XIC ic_chain; -}; -#endif - /* * Prototypes for functions that are referenced only in this file: */ @@ -173,54 +161,10 @@ TkpCloseDisplay( TkWmCleanup(dispPtr); #ifdef TK_USE_INPUT_METHODS -#if TK_XIM_SPOT if (dispPtr->inputXfs) { XFreeFontSet(dispPtr->display, dispPtr->inputXfs); } -#endif if (dispPtr->inputMethod) { - /* - * Calling XCloseIM with an input context that has not been freed can - * cause a crash. This crash has been reproduced under Linux systems - * with XFree86 3.3 and may have also been seen under Solaris 2.3. The - * crash is caused by a double free of memory inside the X library. - * Memory that was already deallocated may be accessed again inside - * XCloseIM. This bug can be avoided by making sure that a call to - * XDestroyIC is made for each XCreateIC call. This bug has been fixed - * in XFree86 4.2.99.2. The internal layout of the XIM structure - * changed in the XFree86 4.2 release so the test should not be run - * for with these new releases. - */ - -#if defined(TK_USE_INPUT_METHODS) && defined(PEEK_XCLOSEIM) - int do_peek = 0; - struct XIMPeek *peek; - - if (strstr(ServerVendor(dispPtr->display), "XFree86")) { - int vendrel = VendorRelease(dispPtr->display); - - if (vendrel < 336) { - /* 3.3.4 and 3.3.5 */ - do_peek = 1; - } else if (vendrel < 3900) { - /* Other 3.3.x versions */ - do_peek = 1; - } else if (vendrel < 40000000) { - /* 4.0.x versions */ - do_peek = 1; - } else { - /* Newer than 4.0 */ - do_peek = 0; - } - } - - if (do_peek) { - peek = (struct XIMPeek *) dispPtr->inputMethod; - if (peek->ic_chain != NULL) { - Tcl_Panic("input contexts not freed before XCloseIM"); - } - } -#endif XCloseIM(dispPtr->inputMethod); } #endif @@ -621,9 +565,7 @@ TkpSync( * * OpenIM -- * - * Tries to open an X input method, associated with the given display. - * Right now we can only deal with a bare-bones input style: no preedit, - * and no status. + * Tries to open an X input method associated with the given display. * * Results: * Stores the input method in dispPtr->inputMethod; if there isn't a @@ -639,11 +581,12 @@ static void OpenIM( TkDisplay *dispPtr) /* Tk's structure for the display. */ { - unsigned short i; + int i; XIMStyles *stylePtr; + XIMStyle bestStyle = 0; if (XSetLocaleModifiers("") == NULL) { - goto error; + return; } dispPtr->inputMethod = XOpenIM(dispPtr->display, NULL, NULL, NULL); @@ -656,38 +599,45 @@ OpenIM( goto error; } -#if TK_XIM_SPOT /* - * If we want to do over-the-spot XIM, we have to check that this mode is - * supported. If not we will fall-through to the check below. + * Select the best input style supported by both the IM and Tk. */ - for (i = 0; i < stylePtr->count_styles; i++) { - if (stylePtr->supported_styles[i] - == (XIMPreeditPosition | XIMStatusNothing)) { - dispPtr->flags |= TK_DISPLAY_XIM_SPOT; - XFree(stylePtr); - return; + XIMStyle thisStyle = stylePtr->supported_styles[i]; + if (thisStyle == (XIMPreeditPosition | XIMStatusNothing)) { + bestStyle = thisStyle; + break; + } else if (thisStyle == (XIMPreeditNothing | XIMStatusNothing)) { + bestStyle = thisStyle; } } -#endif /* TK_XIM_SPOT */ + XFree(stylePtr); + if (bestStyle == 0) { + goto error; + } - for (i = 0; i < stylePtr->count_styles; i++) { - if (stylePtr->supported_styles[i] - == (XIMPreeditNothing | XIMStatusNothing)) { - XFree(stylePtr); - return; + dispPtr->inputStyle = bestStyle; + + /* + * Create an XFontSet for preedit area. + */ + if (dispPtr->inputStyle & XIMPreeditPosition) { + char **missing_list; + int missing_count; + char *def_string; + + dispPtr->inputXfs = XCreateFontSet(dispPtr->display, + "-*-*-*-R-Normal--14-130-75-75-*-*", + &missing_list, &missing_count, &def_string); + if (missing_count > 0) { + XFreeStringList(missing_list); } } - XFree(stylePtr); - error: - if (dispPtr->inputMethod) { - /* - * This call should not suffer from any core dumping problems since we - * have not allocated any input contexts. - */ + return; +error: + if (dispPtr->inputMethod) { XCloseIM(dispPtr->inputMethod); dispPtr->inputMethod = NULL; } diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c index 7dc91da..5e2c0ca 100644 --- a/unix/tkUnixKey.c +++ b/unix/tkUnixKey.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixKey.c,v 1.12 2007/02/27 14:52:57 dkf Exp $ + * RCS: @(#) $Id: tkUnixKey.c,v 1.12.2.1 2008/03/26 20:09:33 dgp Exp $ */ #include "tkInt.h" @@ -24,16 +24,9 @@ * Tk_SetCaretPos -- * * This enables correct placement of the XIM caret. This is called by - * widgets to indicate their cursor placement, and the caret location is - * used by TkpGetString to place the XIM caret. This is currently only + * widgets to indicate their cursor placement. This is currently only * used for over-the-spot XIM. * - * Results: - * None - * - * Side effects: - * None - * *---------------------------------------------------------------------- */ @@ -44,16 +37,42 @@ Tk_SetCaretPos( int y, int height) { - TkCaret *caretPtr = &(((TkWindow *) tkwin)->dispPtr->caret); + TkWindow *winPtr = (TkWindow *) tkwin; + TkDisplay *dispPtr = winPtr->dispPtr; + + if ( dispPtr->caret.winPtr == winPtr + && dispPtr->caret.x == x + && dispPtr->caret.y == y + && dispPtr->caret.height == height) + { + return; + } + + dispPtr->caret.winPtr = winPtr; + dispPtr->caret.x = x; + dispPtr->caret.y = y; + dispPtr->caret.height = height; +#ifdef TK_USE_INPUT_METHODS /* - * Use height for best placement of the XIM over-the-spot box. + * Adjust the XIM caret position. */ + if ( (dispPtr->flags & TK_DISPLAY_USE_IM) + && (dispPtr->inputStyle & XIMPreeditPosition) + && (winPtr->inputContext != NULL) ) + { + XVaNestedList preedit_attr; + XPoint spot; - caretPtr->winPtr = ((TkWindow *) tkwin); - caretPtr->x = x; - caretPtr->y = y; - caretPtr->height = height; + spot.x = dispPtr->caret.x; + spot.y = dispPtr->caret.y + dispPtr->caret.height; + preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL); + XSetICValues(winPtr->inputContext, + XNPreeditAttributes, preedit_attr, + NULL); + XFree(preedit_attr); + } +#endif } /* @@ -85,9 +104,6 @@ TkpGetString( int len; Tcl_DString buf; Status status; -#ifdef TK_USE_INPUT_METHODS - TkDisplay *dispPtr = winPtr->dispPtr; -#endif /* * Overallocate the dstring to the maximum stack amount. @@ -97,13 +113,9 @@ TkpGetString( Tcl_DStringSetLength(&buf, TCL_DSTRING_STATIC_SIZE-1); #ifdef TK_USE_INPUT_METHODS - if ((dispPtr->flags & TK_DISPLAY_USE_IM) + if ((winPtr->dispPtr->flags & TK_DISPLAY_USE_IM) && (winPtr->inputContext != NULL) && (eventPtr->type == KeyPress)) { -#if TK_XIM_SPOT - XVaNestedList preedit_attr; - XPoint spot; -#endif len = XmbLookupString(winPtr->inputContext, &eventPtr->xkey, Tcl_DStringValue(&buf), Tcl_DStringLength(&buf), NULL, @@ -121,21 +133,6 @@ TkpGetString( len = 0; } -#if TK_XIM_SPOT - /* - * Adjust the XIM caret position. We might want to check that this is - * the right caret.winPtr as well. - */ - - if (dispPtr->flags & TK_DISPLAY_XIM_SPOT) { - spot.x = dispPtr->caret.x; - spot.y = dispPtr->caret.y + dispPtr->caret.height; - preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL); - XSetICValues(winPtr->inputContext, - XNPreeditAttributes, preedit_attr, NULL); - XFree(preedit_attr); - } -#endif } else { len = XLookupString(&eventPtr->xkey, Tcl_DStringValue(&buf), Tcl_DStringLength(&buf), NULL, NULL); diff --git a/win/Makefile.in b/win/Makefile.in index 516128c..7799911 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -4,7 +4,7 @@ # "autoconf" program (constructs like "@foo@" will get replaced in the # actual Makefile. # -# RCS: @(#) $Id: Makefile.in,v 1.73.2.3 2007/11/01 16:37:25 dgp Exp $ +# RCS: @(#) $Id: Makefile.in,v 1.73.2.4 2008/03/26 20:09:33 dgp Exp $ TCLVERSION = @TCL_VERSION@ TCLPATCHL = @TCL_PATCH_LEVEL@ @@ -385,11 +385,10 @@ TTK_OBJS = \ ttkTrack.$(OBJEXT) \ ttkTreeview.$(OBJEXT) \ ttkWidget.$(OBJEXT) \ - ttkStubInit.$(OBJEXT) \ - ttkStubLib.$(OBJEXT) + ttkStubInit.$(OBJEXT) STUB_OBJS = \ - tkStubLib.$(OBJEXT) + tkStubLib.$(OBJEXT) ttkStubLib.$(OBJEXT) TCL_DOCS = "$(TCL_SRC_DIR_NATIVE)"/doc/*.[13n] TK_DOCS = "$(ROOT_DIR_NATIVE)"/doc/*.[13n] diff --git a/win/makefile.vc b/win/makefile.vc index 644295b..d21d2be 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -12,7 +12,7 @@ # Copyright (c) 2001-2004 David Gravereaux. # #------------------------------------------------------------------------------ -# RCS: @(#) $Id: makefile.vc,v 1.103.2.8 2008/01/23 16:39:14 dgp Exp $ +# RCS: @(#) $Id: makefile.vc,v 1.103.2.9 2008/03/26 20:09:33 dgp Exp $ #------------------------------------------------------------------------------ # Check to see we are configured to build with MSVC (MSDEVDIR or MSVCDIR) @@ -393,11 +393,10 @@ TTK_OBJS = \ $(TMP_DIR)\ttkTrack.obj \ $(TMP_DIR)\ttkTreeview.obj \ $(TMP_DIR)\ttkWidget.obj \ - $(TMP_DIR)\ttkStubInit.obj \ - $(TMP_DIR)\ttkStubLib.obj + $(TMP_DIR)\ttkStubInit.obj TKSTUBOBJS = \ - $(TMP_DIR)\tkStubLib.obj + $(TMP_DIR)\tkStubLib.obj $(TMP_DIR)\ttkStubLib.obj WINDIR = $(ROOT)\win |