diff options
-rw-r--r-- | ChangeLog | 83 | ||||
-rw-r--r-- | doc/label.n | 23 | ||||
-rw-r--r-- | generic/tk3d.c | 54 | ||||
-rw-r--r-- | generic/tkButton.c | 8 | ||||
-rw-r--r-- | generic/tkCanvPoly.c | 7 | ||||
-rw-r--r-- | generic/tkColor.c | 52 | ||||
-rw-r--r-- | generic/tkCursor.c | 33 | ||||
-rw-r--r-- | generic/tkImgGIF.c | 87 | ||||
-rw-r--r-- | generic/tkMenu.c | 4 | ||||
-rw-r--r-- | generic/tkPlace.c | 38 | ||||
-rw-r--r-- | generic/tkText.c | 33 | ||||
-rw-r--r-- | library/focus.tcl | 8 | ||||
-rw-r--r-- | tests/button.test | 7 | ||||
-rw-r--r-- | tests/canvas.test | 14 | ||||
-rw-r--r-- | tests/focus.test | 3 | ||||
-rw-r--r-- | tests/menu.test | 29 | ||||
-rw-r--r-- | tests/text.test | 57 | ||||
-rw-r--r-- | win/tkWinMenu.c | 23 |
18 files changed, 382 insertions, 181 deletions
@@ -1,3 +1,86 @@ +2000-08-05 Jeff Hobbs <hobbs@scriptics.com> + + * win/Makefile.in (cat32.${OBJEXT}): corrected where to find cat.c + given the change in default def'n of TCL_SRC_DIR. + + * win/tcl.m4: changed references from 8.4 to 8.3 (leftover from a + backported file). + + * library/safetk.tcl: rationalized the setting of tk_library when + initialized Tk in a safe interpreter. + +2000-08-04 Jeff Hobbs <hobbs@scriptics.com> + + * BACKPORTED FROM 8.4 (HEAD) BRANCH: + + * tests/button.test: + * generic/tkButton.c: Added -activeforeground, -activebackground + for labels, for the -state option. + + * doc/label.n: Added -disabledforeground to list of options [Bug: + 6053]. + + * tests/focus.test (focusSetupAlt): removed wm withdraw from proc + as it would cause a hang for tkwait visibility + + * tests/menu.test: + * generic/tk3d.c: + * generic/tkColor.c: + * generic/tkCursor.c: corrected handling of 3DBorder, Cursor and + Color objects on multiple screens. [Bug: 5454] + + * generic/tkCursor.c: Added initialization for nextPtr field of + TkCursor, patch from Nijtmans/Howlett. + + * canvas.test: added test for 5783. + * generic/tkCanvPoly.c (DisplayPolygon): added checks for the + polygon fillGC not being empty to prevent segfault. [Bug: 5783] + + * generic/tkImgGIF.c: Applied patch from Jan Nijtmans to fix a + problem with the GIF writing code [Bug: 5823]. + * generic/tkImgGIF.c: Changed defines for GIF87a/GIF89a to be + static char arrays with integer initialization, to address EBCIDIC + vs. ASCII encoding issues and to handle compilers that don't deal + with "\xAB" syntax for specifying hex values in strings. + + * generic/tkMenu.c (DeleteMenuCloneEntries): Applied fix from + [Bug: 5275], which corrected a segfault-causing indexing problem + when deleting entries from torn-off menus. + + * generic/tkPlace.c (Tk_PlaceCmd): reworked place master/slave + table init'n to prevent seg fault when using place on multiple + displays. + + * tests/text.test: Added tests for -regexp -nocase searches with + backslash character classes. + * tests/text.test: Added tests for searching when text is elided. + * generic/tkText.c (TextSearchCmd): Text search did not work + properly when -regexp and -nocase were used, in combination with + backslash character classes represented by capital letters (ie, + \W, \M); altered implementation of -regexp -nocase searches to use + new regexp interfaces to fix this problem. [Bug: 5988]. + * generic/tkText.c (TextSearchCmd): Text search was not returning + the correct index when the search covered (but did not search) + elided characters; corrected this by adjusting the match index by + the number of elided characters preceeding the start of the match, + just as is done with embedded windows, etc. [Bug: 5470]. + * generic/tkText.c (TextSearchCmd): Added a test for a NULL + segment pointer when doing backwards searches for "" on an empty + text widget. [Bug: 6007]. + + * library/focus.tcl: fixed calling of takeFocus proc [Bug: 5372] + + * win/tkWinMenu.c (ReconfigureWindowsMenu): Added MF_GRAYED bit + for disabled menu entries, to ensure that those which are drawn by + the system are shown grayed (such as entries on menubars) [Bug: 4372]. + * win/tkWinMenu.c (ReconfigureWindowsMenu): Added code to add the + MF_SEPARATOR bit for SEPARATOR_ENTRY menu items. This causes + separator entries on the system menu to be drawn correctly [Bug: 5451]. + * win/tkWinMenu.c (GetMenuSeparatorGeometry): Tweaked height + requested for separator bars to be (linespace - (2*descent)) + instead of just (linespace); this makes the separator occupy a + more correct amount of vertical space. [Bug: 5303]. + 2000-07-20 Brent Welch <welch@ajubasolutions.com> * win/tkConfig.sh.in: diff --git a/doc/label.n b/doc/label.n index 370f4f4..6d6be19 100644 --- a/doc/label.n +++ b/doc/label.n @@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: label.n,v 1.2 1998/09/14 18:22:57 stanton Exp $ +'\" RCS: @(#) $Id: label.n,v 1.2.18.1 2000/08/05 23:53:09 hobbs Exp $ '\" .so man.macros .TH label n 4.0 Tk "Tk Built-In Commands" @@ -16,11 +16,14 @@ label \- Create and manipulate label widgets .SH SYNOPSIS \fBlabel\fR \fIpathName \fR?\fIoptions\fR? .SO -\-anchor \-font \-image \-takefocus -\-background \-foreground \-justify \-text -\-bitmap \-highlightbackground \-padx \-textvariable -\-borderwidth \-highlightcolor \-pady \-underline -\-cursor \-highlightthickness \-relief \-wraplength +\-activebackground \-activeforeground \-anchor +\-background \-bitmap \-borderwidth +\-cursor \-disabledforeground \-font +\-foreground \-highlightbackground \-highlightcolor +\-highlightthickness \-image \-justify +\-padx \-pady \-relief +\-takefocus \-text \-textvariable +\-underline \-wraplength .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-height height Height @@ -30,6 +33,14 @@ screen units (i.e. any of the forms acceptable to \fBTk_GetPixels\fR); for text it is in lines of text. If this option isn't specified, the label's desired height is computed from the size of the image or bitmap or text being displayed in it. +.OP \-state state State +Specifies one of three states for the label: \fBnormal\fR, \fBactive\fR, +or \fBdisabled\fR. In normal state the button is displayed using the +\fBforeground\fR and \fBbackground\fR options. In active state +the label is displayed using the \fBactiveForeground\fR and +\fBactiveBackground\fR options. In the disabled state the +\fBdisabledForeground\fR and \fBbackground\fR options determine how +the button is displayed. .OP \-width width Width Specifies a desired width for the label. If an image or bitmap is being displayed in the label then the value is in diff --git a/generic/tk3d.c b/generic/tk3d.c index 8cbe0ee..195433a 100644 --- a/generic/tk3d.c +++ b/generic/tk3d.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: tk3d.c,v 1.6 1999/12/21 23:55:10 hobbs Exp $ + * RCS: @(#) $Id: tk3d.c,v 1.6.2.1 2000/08/05 23:53:10 hobbs Exp $ */ #include "tk3d.h" @@ -501,6 +501,7 @@ Tk_Free3DBorderFromObj(tkwin, objPtr) Tcl_Obj *objPtr; /* The Tcl_Obj * to be freed. */ { Tk_Free3DBorder(Tk_Get3DBorderFromObj(tkwin, objPtr)); + FreeBorderObjProc(objPtr); } /* @@ -1263,37 +1264,46 @@ Tk_Get3DBorderFromObj(tkwin, objPtr) InitBorderObj(objPtr); } - borderPtr = (TkBorder *) objPtr->internalRep.twoPtrValue.ptr1; - if (borderPtr != NULL) { - if ((borderPtr->resourceRefCount > 0) - && (Tk_Screen(tkwin) == borderPtr->screen) - && (Tk_Colormap(tkwin) == borderPtr->colormap)) { - /* - * The object already points to the right border structure. - * Just return it. - */ + /* + * If we are lucky (and the user doesn't use too many different + * displays, screens, or colormaps...) then the TkBorder + * structure we need will be cached in the internal + * representation of the Tcl_Obj. Check it out... + */ - return (Tk_3DBorder) borderPtr; - } - hashPtr = borderPtr->hashPtr; - FreeBorderObjProc(objPtr); - } else { - hashPtr = Tcl_FindHashEntry(&dispPtr->borderTable, - Tcl_GetString(objPtr)); - if (hashPtr == NULL) { - goto error; - } + borderPtr = (TkBorder *) objPtr->internalRep.twoPtrValue.ptr1; + if ((borderPtr != NULL) + && (borderPtr->resourceRefCount > 0) + && (Tk_Screen(tkwin) == borderPtr->screen) + && (Tk_Colormap(tkwin) == borderPtr->colormap)) { + /* + * The object already points to the right border structure. + * Just return it. + */ + return (Tk_3DBorder) borderPtr; } /* - * At this point we've got a hash table entry, off of which hang - * one or more TkBorder structures. See if any of them will work. + * If we make it here, it means we aren't so lucky. Either there + * was no cached TkBorder in the Tcl_Obj, or the TkBorder that was + * there is for the wrong screen/colormap. Either way, we have + * to search for the right TkBorder. For each color name, there is + * linked list of TkBorder structures, one structure for each + * screen/colormap combination. The head of the linked list is + * recorded in a hash table (where the key is the color name) + * attached to the TkDisplay structure. Walk this list to find + * the right TkBorder structure. */ + hashPtr = Tcl_FindHashEntry(&dispPtr->borderTable, Tcl_GetString(objPtr)); + if (hashPtr == NULL) { + goto error; + } for (borderPtr = (TkBorder *) Tcl_GetHashValue(hashPtr); (borderPtr != NULL); borderPtr = borderPtr->nextPtr) { if ((Tk_Screen(tkwin) == borderPtr->screen) && (Tk_Colormap(tkwin) == borderPtr->colormap)) { + FreeBorderObjProc(objPtr); objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) borderPtr; borderPtr->objRefCount++; return (Tk_3DBorder) borderPtr; diff --git a/generic/tkButton.c b/generic/tkButton.c index 1d832c8..fdb581c 100644 --- a/generic/tkButton.c +++ b/generic/tkButton.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkButton.c,v 1.4 2000/03/08 03:19:31 ericm Exp $ + * RCS: @(#) $Id: tkButton.c,v 1.4.2.1 2000/08/05 23:53:10 hobbs Exp $ */ #include "tkButton.h" @@ -48,6 +48,12 @@ static char *stateStrings[] = { */ static Tk_OptionSpec labelOptionSpecs[] = { + {TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground", + DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder), + 0, (ClientData) DEF_BUTTON_ACTIVE_BG_MONO, 0}, + {TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background", + DEF_BUTTON_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg), + TK_OPTION_NULL_OK, (ClientData) DEF_BUTTON_ACTIVE_FG_MONO, 0}, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0}, {TK_OPTION_BORDER, "-background", "background", "Background", diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c index 79ba527..9f2926b 100644 --- a/generic/tkCanvPoly.c +++ b/generic/tkCanvPoly.c @@ -5,11 +5,12 @@ * * Copyright (c) 1991-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright (c) 1998-2000 Ajuba Solutions. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCanvPoly.c,v 1.5 2000/02/01 11:41:09 hobbs Exp $ + * RCS: @(#) $Id: tkCanvPoly.c,v 1.5.2.1 2000/08/05 23:53:11 hobbs Exp $ */ #include <stdio.h> @@ -916,7 +917,7 @@ DisplayPolygon(canvas, itemPtr, display, drawable, x, y, width, height) * read-only. */ - if (stipple != None) { + if ((stipple != None) && (polyPtr->fillGC != None)) { Tk_TSOffset *tsoffset = &polyPtr->tsoffset; int w=0; int h=0; int flags = tsoffset->flags; @@ -991,7 +992,7 @@ DisplayPolygon(canvas, itemPtr, display, drawable, x, y, width, height) } } Tk_ResetOutlineGC(canvas, itemPtr, &(polyPtr->outline)); - if (stipple != None) { + if ((stipple != None) && (polyPtr->fillGC != None)) { XSetTSOrigin(display, polyPtr->fillGC, 0, 0); } } diff --git a/generic/tkColor.c b/generic/tkColor.c index 006e93b..ffa877f 100644 --- a/generic/tkColor.c +++ b/generic/tkColor.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkColor.c,v 1.6 1999/11/19 22:00:02 hobbs Exp $ + * RCS: @(#) $Id: tkColor.c,v 1.6.2.1 2000/08/05 23:53:11 hobbs Exp $ */ #include "tkColor.h" @@ -540,6 +540,7 @@ Tk_FreeColorFromObj(tkwin, objPtr) Tcl_Obj *objPtr; /* The Tcl_Obj * to be freed. */ { Tk_FreeColor(Tk_GetColorFromObj(tkwin, objPtr)); + FreeColorObjProc(objPtr); } /* @@ -645,38 +646,43 @@ Tk_GetColorFromObj(tkwin, objPtr) if (objPtr->typePtr != &colorObjType) { InitColorObj(objPtr); } - + + /* + * First check to see if the internal representation of the object + * is defined and is a color that is valid for the current screen + * and color map. If it is, we are done. + */ tkColPtr = (TkColor *) objPtr->internalRep.twoPtrValue.ptr1; - if (tkColPtr != NULL) { - if ((tkColPtr->resourceRefCount > 0) - && (Tk_Screen(tkwin) == tkColPtr->screen) - && (Tk_Colormap(tkwin) == tkColPtr->colormap)) { - /* - * The object already points to the right TkColor structure. - * Just return it. - */ - - return (XColor *) tkColPtr; - } - hashPtr = tkColPtr->hashPtr; - FreeColorObjProc(objPtr); - } else { - hashPtr = Tcl_FindHashEntry(&dispPtr->colorNameTable, - Tcl_GetString(objPtr)); - if (hashPtr == NULL) { - goto error; - } + if ((tkColPtr != NULL) + && (tkColPtr->resourceRefCount > 0) + && (Tk_Screen(tkwin) == tkColPtr->screen) + && (Tk_Colormap(tkwin) == tkColPtr->colormap)) { + /* + * The object already points to the right TkColor structure. + * Just return it. + */ + + return (XColor *) tkColPtr; } /* - * At this point we've got a hash table entry, off of which hang - * one or more TkColor structures. See if any of them will work. + * If we reach this point, it means that the TkColor structure + * that we have cached in the internal representation is not valid + * for the current screen and colormap. But there is a list of + * other TkColor structures attached to the TkDisplay. Walk this + * list looking for the right TkColor structure. */ + hashPtr = Tcl_FindHashEntry(&dispPtr->colorNameTable, + Tcl_GetString(objPtr)); + if (hashPtr == NULL) { + goto error; + } for (tkColPtr = (TkColor *) Tcl_GetHashValue(hashPtr); (tkColPtr != NULL); tkColPtr = tkColPtr->nextPtr) { if ((Tk_Screen(tkwin) == tkColPtr->screen) && (Tk_Colormap(tkwin) == tkColPtr->colormap)) { + FreeColorObjProc(objPtr); objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) tkColPtr; tkColPtr->objRefCount++; return (XColor *) tkColPtr; diff --git a/generic/tkCursor.c b/generic/tkCursor.c index c8e5588..a1c2717 100644 --- a/generic/tkCursor.c +++ b/generic/tkCursor.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCursor.c,v 1.4 1999/09/02 17:02:28 hobbs Exp $ + * RCS: @(#) $Id: tkCursor.c,v 1.4.2.1 2000/08/05 23:53:11 hobbs Exp $ */ #include "tkPort.h" @@ -276,6 +276,7 @@ GetCursor(interp, tkwin, string) cursorPtr->objRefCount = 0; cursorPtr->otherTable = &dispPtr->cursorNameTable; cursorPtr->hashPtr = nameHashPtr; + cursorPtr->nextPtr = NULL; cursorPtr->idHashPtr = Tcl_CreateHashEntry(&dispPtr->cursorIdTable, (char *) cursorPtr->cursor, &new); if (!new) { @@ -561,6 +562,7 @@ Tk_FreeCursorFromObj(tkwin, objPtr) Tcl_Obj *objPtr; /* The Tcl_Obj * to be freed. */ { FreeCursor(GetCursorFromObj(tkwin, objPtr)); + FreeCursorObjProc(objPtr); } /* @@ -696,28 +698,31 @@ GetCursorFromObj(tkwin, objPtr) InitCursorObj(objPtr); } + /* + * The internal representation is a cache of the last cursor used + * with the given name. But there can be lots different cursors + * for each cursor name; one cursor for each display. Check to + * see if the cursor we have cached is the one that is needed. + */ cursorPtr = (TkCursor *) objPtr->internalRep.twoPtrValue.ptr1; - if (cursorPtr != NULL) { - if (Tk_Display(tkwin) == cursorPtr->display) { - return cursorPtr; - } - hashPtr = cursorPtr->hashPtr; - } else { - hashPtr = Tcl_FindHashEntry(&dispPtr->cursorNameTable, - Tcl_GetString(objPtr)); - if (hashPtr == NULL) { - goto error; - } + if ((cursorPtr != NULL) && (Tk_Display(tkwin) == cursorPtr->display)) { + return cursorPtr; } /* - * At this point we've got a hash table entry, off of which hang - * one or more TkCursor structures. See if any of them will work. + * If we get to here, it means the cursor we need is not in the cache. + * Try to look up the cursor in the TkDisplay structure of the window. */ + hashPtr = Tcl_FindHashEntry(&dispPtr->cursorNameTable, + Tcl_GetString(objPtr)); + if (hashPtr == NULL) { + goto error; + } for (cursorPtr = (TkCursor *) Tcl_GetHashValue(hashPtr); cursorPtr != NULL; cursorPtr = cursorPtr->nextPtr) { if (Tk_Display(tkwin) == cursorPtr->display) { + FreeCursorObjProc(objPtr); objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) cursorPtr; cursorPtr->objRefCount++; return cursorPtr; diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c index 4dc466a..0b528aa 100644 --- a/generic/tkImgGIF.c +++ b/generic/tkImgGIF.c @@ -2,8 +2,8 @@ * tkImgGIF.c -- * * A photo image file handler for GIF files. Reads 87a and 89a GIF - * files. At present, there only is a file write function. GIF images may be - * read using the -data option of the photo image. The data may be + * files. At present, there only is a file write function. GIF images + * may be read using the -data option of the photo image. The data may be * given as a binary string in a Tcl_Obj or by representing * the data as BASE64 encoded ascii. Derived from the giftoppm code * found in the pbmplus package and tkImgFmtPPM.c in the tk4.0b2 @@ -29,7 +29,7 @@ * | provided "as is" without express or implied warranty. | * +-------------------------------------------------------------------+ * - * RCS: @(#) $Id: tkImgGIF.c,v 1.14 2000/03/30 19:44:41 ericm Exp $ + * RCS: @(#) $Id: tkImgGIF.c,v 1.14.2.1 2000/08/05 23:53:11 hobbs Exp $ */ /* @@ -72,11 +72,13 @@ typedef struct mFile { * encoding independant. */ -# define GIF87a "\x47\x49\x46\x38\x37\x61" /* ASCII GIF87a */ -# define GIF89a "\x47\x49\x46\x38\x39\x61" /* ASCII GIF89a */ -# define GIF_TERMINATOR 0x3b /* ASCII ; */ -# define GIF_EXTENSION 0x21 /* ASCII ! */ -# define GIF_START 0x2c /* ASCII , */ +static CONST char GIF87a[] = + { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x00 }; /* ASCII GIF87a */ +static CONST char GIF89a[] = + { 0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x00 }; /* ASCII GIF89a */ +# define GIF_TERMINATOR 0x3b /* ASCII ; */ +# define GIF_EXTENSION 0x21 /* ASCII ! */ +# define GIF_START 0x2c /* ASCII , */ /* * HACK ALERT!! HACK ALERT!! HACK ALERT!! @@ -1326,15 +1328,15 @@ static unsigned char mapa[MAXCOLORMAPSIZE][3]; * Definition of new functions to write GIFs */ -static int color _ANSI_ARGS_((int red,int green, int blue)); +static int color _ANSI_ARGS_((int red,int green, int blue, + unsigned char mapa[MAXCOLORMAPSIZE][3])); static void compress _ANSI_ARGS_((int init_bits, Tcl_Channel handle, ifunptr readValue)); static int nuevo _ANSI_ARGS_((int red, int green ,int blue, unsigned char mapa[MAXCOLORMAPSIZE][3])); -static int savemap _ANSI_ARGS_((Tk_PhotoImageBlock *blockPtr, +static void savemap _ANSI_ARGS_((Tk_PhotoImageBlock *blockPtr, unsigned char mapa[MAXCOLORMAPSIZE][3])); static int ReadValue _ANSI_ARGS_((void)); -static int no_bits _ANSI_ARGS_((int colors)); static int FileWriteGIF (interp, filename, format, blockPtr) @@ -1353,9 +1355,6 @@ FileWriteGIF (interp, filename, format, blockPtr) if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") != TCL_OK) { return TCL_ERROR; } - if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") != TCL_OK) { - return TCL_ERROR; - } result = CommonWriteGIF(interp, chan, format, blockPtr); if (Tcl_Close(interp, chan) == TCL_ERROR) { @@ -1374,12 +1373,10 @@ CommonWriteGIF(interp, handle, format, blockPtr) Tk_PhotoImageBlock *blockPtr; { int resolution; - long numcolormap; long width,height,x; unsigned char c; unsigned int top,left; - int num; top = 0; left = 0; @@ -1410,11 +1407,12 @@ CommonWriteGIF(interp, handle, format, blockPtr) height=blockPtr->height; pixelo=blockPtr->pixelPtr + blockPtr->offset[0]; pixelPitch=blockPtr->pitch; - if ((num=savemap(blockPtr,mapa))<0) { + savemap(blockPtr,mapa); + if (num>=MAXCOLORMAPSIZE) { Tcl_AppendResult(interp, "too many colors", (char *) NULL); return TCL_ERROR; } - if (num<3) num=3; + if (num<2) num=2; c=LSB(width); Mputc(c,handle); c=MSB(width); @@ -1424,11 +1422,14 @@ CommonWriteGIF(interp, handle, format, blockPtr) c=MSB(height); Mputc(c,handle); - c= (1 << 7) | (no_bits(num) << 4) | (no_bits(num)); + resolution = 0; + while (num >> resolution) { + resolution++; + } + c = 111 + resolution * 17; Mputc(c,handle); - resolution = no_bits(num)+1; - numcolormap=1 << resolution; + num = 1 << resolution; /* background color */ @@ -1439,7 +1440,7 @@ CommonWriteGIF(interp, handle, format, blockPtr) Mputc(c,handle); - for (x=0; x<numcolormap ;x++) { + for (x=0; x<num ;x++) { c = mapa[x][CM_RED]; Mputc(c,handle); c = mapa[x][CM_GREEN]; @@ -1497,10 +1498,11 @@ CommonWriteGIF(interp, handle, format, blockPtr) } static int -color(red, green, blue) +color(red, green, blue, mapa) int red; int green; int blue; + unsigned char mapa[MAXCOLORMAPSIZE][3]; { int x; for (x=(alphaOffset != 0);x<=MAXCOLORMAPSIZE;x++) { @@ -1519,7 +1521,7 @@ nuevo(red, green, blue, mapa) unsigned char mapa[MAXCOLORMAPSIZE][3]; { int x; - for (x=(alphaOffset != 0);x<num;x++) { + for (x=(alphaOffset != 0);x<=num;x++) { if ((mapa[x][CM_RED]==red) && (mapa[x][CM_GREEN]==green) && (mapa[x][CM_BLUE]==blue)) { return 0; @@ -1528,7 +1530,7 @@ nuevo(red, green, blue, mapa) return 1; } -static int +static void savemap(blockPtr,mapa) Tk_PhotoImageBlock *blockPtr; unsigned char mapa[MAXCOLORMAPSIZE][3]; @@ -1538,12 +1540,12 @@ savemap(blockPtr,mapa) unsigned char red,green,blue; if (alphaOffset) { - num = 1; + num = 0; mapa[0][CM_RED] = 0xd9; mapa[0][CM_GREEN] = 0xd9; mapa[0][CM_BLUE] = 0xd9; } else { - num = 0; + num = -1; } for(y=0;y<blockPtr->height;y++) { @@ -1555,19 +1557,19 @@ savemap(blockPtr,mapa) green = colores[greenOffset]; blue = colores[blueOffset]; if (nuevo(red,green,blue,mapa)) { - if (num>255) - return -1; - + num++; + if (num>=MAXCOLORMAPSIZE) { + return; + } mapa[num][CM_RED]=red; mapa[num][CM_GREEN]=green; mapa[num][CM_BLUE]=blue; - num++; } } colores += pixelSize; } } - return num-1; + return; } static int @@ -1581,7 +1583,7 @@ ReadValue() if (alphaOffset && (pixelo[alphaOffset]==0)) { col = 0; } else { - col = color(pixelo[0],pixelo[greenOffset],pixelo[blueOffset]); + col = color(pixelo[0],pixelo[greenOffset],pixelo[blueOffset], mapa); } pixelo += pixelSize; if (--ssize <= 0) { @@ -1593,25 +1595,6 @@ ReadValue() return col; } -/* - * Return the number of bits ( -1 ) to represent a given - * number of colors ( ex: 256 colors => 7 ). - */ - -static int -no_bits( colors ) -int colors; -{ - register int bits = 0; - - colors--; - while ( colors >> bits ) { - bits++; - } - - return (bits-1); -} - /*----------------------------------------------------------------------- diff --git a/generic/tkMenu.c b/generic/tkMenu.c index b3f906d..6ceddf0 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.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: tkMenu.c,v 1.6 2000/02/10 08:52:35 hobbs Exp $ + * RCS: @(#) $Id: tkMenu.c,v 1.6.2.1 2000/08/05 23:53:12 hobbs Exp $ */ /* @@ -3403,7 +3403,7 @@ DeleteMenuCloneEntries(menuPtr, first, last) } for (i = last + 1; i < menuListPtr->numEntries; i++) { menuListPtr->entries[i - numDeleted] = menuListPtr->entries[i]; - menuListPtr->entries[i - numDeleted]->index = i; + menuListPtr->entries[i - numDeleted]->index = i - numDeleted; } menuListPtr->numEntries -= numDeleted; if (menuListPtr->numEntries == 0) { diff --git a/generic/tkPlace.c b/generic/tkPlace.c index 174a022..0cac18e 100644 --- a/generic/tkPlace.c +++ b/generic/tkPlace.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: tkPlace.c,v 1.5 1999/04/21 21:53:27 rjohnson Exp $ + * RCS: @(#) $Id: tkPlace.c,v 1.5.12.1 2000/08/05 23:53:12 hobbs Exp $ */ #include "tkPort.h" @@ -161,18 +161,6 @@ Tk_PlaceCmd(clientData, interp, argc, argv) int c; TkDisplay *dispPtr; - dispPtr = ((TkWindow *) clientData)->dispPtr; - - /* - * Initialize, if that hasn't been done yet. - */ - - if (!dispPtr->placeInit) { - Tcl_InitHashTable(&dispPtr->masterTable, TCL_ONE_WORD_KEYS); - Tcl_InitHashTable(&dispPtr->slaveTable, TCL_ONE_WORD_KEYS); - dispPtr->placeInit = 1; - } - if (argc < 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " option|pathName args", (char *) NULL); @@ -190,6 +178,18 @@ Tk_PlaceCmd(clientData, interp, argc, argv) if (tkwin == NULL) { return TCL_ERROR; } + + /* + * Initialize, if that hasn't been done yet. + */ + + dispPtr = ((TkWindow *) tkwin)->dispPtr; + if (!dispPtr->placeInit) { + Tcl_InitHashTable(&dispPtr->masterTable, TCL_ONE_WORD_KEYS); + Tcl_InitHashTable(&dispPtr->slaveTable, TCL_ONE_WORD_KEYS); + dispPtr->placeInit = 1; + } + slavePtr = FindSlave(tkwin); return ConfigureSlave(interp, slavePtr, argc-2, argv+2); } @@ -203,6 +203,18 @@ Tk_PlaceCmd(clientData, interp, argc, argv) if (tkwin == NULL) { return TCL_ERROR; } + + /* + * Initialize, if that hasn't been done yet. + */ + + dispPtr = ((TkWindow *) tkwin)->dispPtr; + if (!dispPtr->placeInit) { + Tcl_InitHashTable(&dispPtr->masterTable, TCL_ONE_WORD_KEYS); + Tcl_InitHashTable(&dispPtr->slaveTable, TCL_ONE_WORD_KEYS); + dispPtr->placeInit = 1; + } + if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)) { if (argc < 5) { Tcl_AppendResult(interp, "wrong # args: should be \"", diff --git a/generic/tkText.c b/generic/tkText.c index d92363b..4d17bb9 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkText.c,v 1.14 2000/02/03 17:29:57 ericm Exp $ + * RCS: @(#) $Id: tkText.c,v 1.14.2.1 2000/08/05 23:53:12 hobbs Exp $ */ #include "default.h" @@ -1673,6 +1673,7 @@ TextSearchCmd(textPtr, interp, argc, argv) TkTextSegment *segPtr; TkTextLine *linePtr; TkTextIndex curIndex; + Tcl_Obj *patObj = NULL; Tcl_RegExp regexp = NULL; /* Initialization needed only to * prevent compiler warning. */ @@ -1748,7 +1749,7 @@ TextSearchCmd(textPtr, interp, argc, argv) * Convert the pattern to lower-case if we're supposed to ignore case. */ - if (noCase) { + if (noCase && exact) { Tcl_DStringInit(&patDString); Tcl_DStringAppend(&patDString, pattern, -1); pattern = Tcl_DStringValue(&patDString); @@ -1798,7 +1799,10 @@ TextSearchCmd(textPtr, interp, argc, argv) if (exact) { patLength = strlen(pattern); } else { - regexp = Tcl_RegExpCompile(interp, pattern); + patObj = Tcl_NewStringObj(pattern, -1); + Tcl_IncrRefCount(patObj); + regexp = Tcl_GetRegExpFromObj(interp, patObj, + (noCase ? TCL_REG_NOCASE : 0) | TCL_REG_ADVANCED); if (regexp == NULL) { code = TCL_ERROR; goto done; @@ -1952,18 +1956,26 @@ TextSearchCmd(textPtr, interp, argc, argv) /* * The index information returned by the regular expression * parser only considers textual information: it doesn't - * account for embedded windows or any other non-textual info. + * account for embedded windows, elided text (when we are not + * searching elided text) or any other non-textual info. * Scan through the line's segments again to adjust both * matchChar and matchCount. + * + * We will walk through the segments of this line until we have + * either reached the end of the match or we have reached the end + * of the line. */ + curIndex.linePtr = linePtr; curIndex.byteIndex = 0; for (segPtr = linePtr->segPtr, leftToScan = matchByte; - leftToScan >= 0; segPtr = segPtr->nextPtr) { - if (segPtr->typePtr != &tkTextCharType) { + leftToScan >= 0 && segPtr; segPtr = segPtr->nextPtr) { + if (segPtr->typePtr != &tkTextCharType || \ + (!searchElide && TkTextIsElided(textPtr, &curIndex))) { matchByte += segPtr->size; - continue; + } else { + leftToScan -= segPtr->size; } - leftToScan -= segPtr->size; + curIndex.byteIndex += segPtr->size; } for (leftToScan += matchLength; leftToScan > 0; segPtr = segPtr->nextPtr) { @@ -2023,9 +2035,12 @@ TextSearchCmd(textPtr, interp, argc, argv) } done: Tcl_DStringFree(&line); - if (noCase) { + if (noCase && exact) { Tcl_DStringFree(&patDString); } + if (patObj != NULL) { + Tcl_DecrRefCount(patObj); + } return code; } diff --git a/library/focus.tcl b/library/focus.tcl index 1658988..7bcc126 100644 --- a/library/focus.tcl +++ b/library/focus.tcl @@ -3,7 +3,7 @@ # This file defines several procedures for managing the input # focus. # -# RCS: @(#) $Id: focus.tcl,v 1.7 2000/03/31 09:24:11 hobbs Exp $ +# RCS: @(#) $Id: focus.tcl,v 1.7.2.1 2000/08/05 23:53:13 hobbs Exp $ # # Copyright (c) 1994-1995 Sun Microsystems, Inc. # @@ -130,14 +130,14 @@ proc tk_focusPrev w { proc tkFocusOK w { set code [catch {$w cget -takefocus} value] - if {($code == 0) && [string compare $value ""]} { + if {($code == 0) && ($value != "")} { if {$value == 0} { return 0 } elseif {$value == 1} { return [winfo viewable $w] } else { - set value [uplevel #0 [list $value $w]] - if {[string compare $value ""]} { + set value [uplevel #0 $value [list $w]] + if {$value != ""} { return $value } } diff --git a/tests/button.test b/tests/button.test index 58932bb..8ee8860 100644 --- a/tests/button.test +++ b/tests/button.test @@ -7,7 +7,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: button.test,v 1.5 2000/03/08 03:19:31 ericm Exp $ +# RCS: @(#) $Id: button.test,v 1.5.2.1 2000/08/05 23:53:13 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -51,9 +51,9 @@ update set i 1 foreach test { {-activebackground #012345 #012345 non-existent - {unknown color name "non-existent"} {0 1 1 1}} + {unknown color name "non-existent"} {1 1 1 1}} {-activeforeground #ff0000 #ff0000 non-existent - {unknown color name "non-existent"} {0 1 1 1}} + {unknown color name "non-existent"} {1 1 1 1}} {-anchor nw nw bogus {bad anchor "bogus": must be n, ne, e, se, s, sw, w, nw, or center} {1 1 1 1}} {-background #ff0000 #ff0000 non-existent {unknown color name "non-existent"} {1 1 1 1}} @@ -126,7 +126,6 @@ foreach test { test button-1.$i {configuration options} { .c configure -selectcolor {} } {} -incr i test button-3.1 {ButtonCreate - not enough cd ../unix } { diff --git a/tests/canvas.test b/tests/canvas.test index 86da456..df4d524 100644 --- a/tests/canvas.test +++ b/tests/canvas.test @@ -3,10 +3,10 @@ # standard fashion for Tcl tests. # # Copyright (c) 1995-1996 Sun Microsystems, Inc. -# Copyright (c) 1998-1999 by Scriptics Corporation. +# Copyright (c) 1998-2000 Ajuba Solutions. # All rights reserved. # -# RCS: @(#) $Id: canvas.test,v 1.8 2000/03/29 00:09:06 ericm Exp $ +# RCS: @(#) $Id: canvas.test,v 1.8.2.1 2000/08/05 23:53:14 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -319,7 +319,7 @@ test canvas-10.7 {check errors from tag expressions} { canvas .c .c create oval 20 20 40 40 -fill red -tag [list a b c d] .c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"] - catch {.c find withtag {d&&"tag with spaces}} err + catch {.c find withtag "d&&\"tag with spaces"} err set err } {Missing endquote in tag search expression} test canvas-10.8 {check errors from tag expressions} { @@ -359,6 +359,14 @@ test canvas-10.12 {multple events bound to same tag expr} { .c bind {a && b} <Leave> {puts Leave} } {} +test canvas-11.1 {canvas poly fill check, bug 5783} { + # This would crash in 8.3.0 and 8.3.1 + destroy .c + pack [canvas .c] + .c create polygon 0 0 100 100 200 50 \ + -fill {} -stipple gray50 -outline black +} 1 + # cleanup ::tcltest::cleanupTests return diff --git a/tests/focus.test b/tests/focus.test index e8f850a..de6eda3 100644 --- a/tests/focus.test +++ b/tests/focus.test @@ -6,7 +6,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: focus.test,v 1.5 1999/04/16 01:51:37 stanton Exp $ +# RCS: @(#) $Id: focus.test,v 1.5.12.1 2000/08/05 23:53:14 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -33,7 +33,6 @@ proc focusSetupAlt {} { global env catch {destroy .alt} toplevel .alt -screen $env(TK_ALT_DISPLAY) - wm withdraw .alt foreach i {a b c d} { button .alt.$i -text .alt.$i -relief raised -bd 2 pack .alt.$i diff --git a/tests/menu.test b/tests/menu.test index 7b8ba02..e04ef3e 100644 --- a/tests/menu.test +++ b/tests/menu.test @@ -5,7 +5,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: menu.test,v 1.3 1999/04/16 01:51:39 stanton Exp $ +# RCS: @(#) $Id: menu.test,v 1.3.12.1 2000/08/05 23:53:14 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -2438,20 +2438,21 @@ test menu-33.1 {menu vs command hiding} { # menu-34 MenuInit only called at boot time +# creating menus on two different screens then deleting the +# menu from the first screen crashes Tk8.3.1 +# +test menu-35.1 {menus on multiple screens - crashes tk8.3.1, Bug 5454} { + if {[info exists ::env(TK_ALT_DISPLAY)]} { + toplevel .one + menu .one.m + toplevel .two -screen $::env(TK_ALT_DISPLAY) + menu .two.m + destroy .one + destroy .two + } +} {} + # cleanup deleteWindows ::tcltest::cleanupTests return - - - - - - - - - - - - - diff --git a/tests/text.test b/tests/text.test index 651e7d8..e23b67e 100644 --- a/tests/text.test +++ b/tests/text.test @@ -6,7 +6,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: text.test,v 1.10 2000/02/03 17:29:58 ericm Exp $ +# RCS: @(#) $Id: text.test,v 1.10.2.1 2000/08/05 23:53:15 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -1110,7 +1110,60 @@ test text-20.65 {TextSearchCmd, unicode with non-text segments} { set result } {1.3 3} - +test text-20.66 {TextSearchCmd, hidden text does not affect match index} { + eval destroy [winfo child .] + pack [text .t2] + .t2 insert end "12345H7890" + .t2 search 7 1.0 +} 1.6 +test text-20.67 {TextSearchCmd, hidden text does not affect match index} { + eval destroy [winfo child .] + pack [text .t2] + .t2 insert end "12345H7890" + .t2 tag configure hidden -elide true + .t2 tag add hidden 1.5 + .t2 search 7 1.0 +} 1.6 +test text-20.68 {TextSearchCmd, hidden text does not affect match index} { + eval destroy [winfo child .] + pack [text .t2] + .t2 insert end "foobar\nbarbaz\nbazboo" + .t2 search boo 1.0 +} 3.3 +test text-20.69 {TextSearchCmd, hidden text does not affect match index} { + eval destroy [winfo child .] + pack [text .t2] + .t2 insert end "foobar\nbarbaz\nbazboo" + .t2 tag configure hidden -elide true + .t2 tag add hidden 2.0 3.0 + .t2 search boo 1.0 +} 3.3 + +test text-20.70 {TextSearchCmd, -regexp -nocase searches} { + catch {destroy .t} + pack [text .t] + .t insert end "word1 word2" + set res [.t search -nocase -regexp {\mword.} 1.0 end] + destroy .t + set res +} 1.0 +test text-20.71 {TextSearchCmd, -regexp -nocase searches} { + catch {destroy .t} + pack [text .t] + .t insert end "word1 word2" + set res [.t search -nocase -regexp {word.\M} 1.0 end] + destroy .t + set res +} 1.0 +test text-20.72 {TextSearchCmd, -regexp -nocase searches} { + catch {destroy .t} + pack [text .t] + .t insert end "word1 word2" + set res [.t search -nocase -regexp {word.\W} 1.0 end] + destroy .t + set res +} 1.0 + eval destroy [winfo child .] text .t2 -highlightthickness 0 -bd 0 -relief flat -padx 0 -width 100 pack .t2 diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index e379faa..733978d 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.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: tkWinMenu.c,v 1.8 2000/04/13 20:51:55 ericm Exp $ + * RCS: @(#) $Id: tkWinMenu.c,v 1.8.2.1 2000/08/05 23:53:15 hobbs Exp $ */ #define OEMRESOURCE @@ -82,8 +82,6 @@ static int defaultBorderWidth; /* The windows default border width. */ static Tcl_DString menuFontDString; /* A buffer to store the default menu font * string. */ -TCL_DECLARE_MUTEX(winMenuMutex) - /* * Forward declarations for procedures defined later in this file: */ @@ -149,7 +147,6 @@ static void GetTearoffEntryGeometry _ANSI_ARGS_((TkMenu *menuPtr, int *heightPtr)); static int GetNewID _ANSI_ARGS_((TkMenuEntry *mePtr, int *menuIDPtr)); -static void MenuExitProc _ANSI_ARGS_((ClientData clientData)); static int MenuKeyBindProc _ANSI_ARGS_(( ClientData clientData, Tcl_Interp *interp, XEvent *eventPtr, @@ -579,13 +576,13 @@ ReconfigureWindowsMenu( lpNewItem = (LPCTSTR) mePtr; flags |= MF_OWNERDRAW; } - + /* * Set enabling and disabling correctly. */ if (mePtr->state == ENTRY_DISABLED) { - flags |= MF_DISABLED; + flags |= MF_DISABLED | MF_GRAYED; } /* @@ -598,6 +595,18 @@ ReconfigureWindowsMenu( flags |= MF_CHECKED; } + /* + * Set the SEPARATOR bit for separator entries. This bit is not + * used by our internal drawing functions, but it is used by the + * system when drawing the system menu (we do not draw the system menu + * ourselves). If this bit is not set, separator entries on the system + * menu will not be drawn correctly. + */ + + if (mePtr->type == SEPARATOR_ENTRY) { + flags |= MF_SEPARATOR; + } + if (mePtr->columnBreak) { flags |= MF_MENUBREAK; } @@ -1384,7 +1393,7 @@ GetMenuSeparatorGeometry ( int *heightPtr) /* The resulting height */ { *widthPtr = 0; - *heightPtr = fmPtr->linespace; + *heightPtr = fmPtr->linespace - (2 * fmPtr->descent); } /* |