diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-07-18 14:15:49 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-07-18 14:15:49 (GMT) |
commit | 9bd0f9a676dc8cf52d4f73b0cf766d4643b64956 (patch) | |
tree | f23e6916460d21f4cdab3544051f4c297ef9007b /generic | |
parent | 3eac0e260bf334098c61c36eff9890b2c97a52b3 (diff) | |
parent | c00e981adab518faf0a905cb261fbddae340d33f (diff) | |
download | tk-9bd0f9a676dc8cf52d4f73b0cf766d4643b64956.zip tk-9bd0f9a676dc8cf52d4f73b0cf766d4643b64956.tar.gz tk-9bd0f9a676dc8cf52d4f73b0cf766d4643b64956.tar.bz2 |
Merge 8.7
Diffstat (limited to 'generic')
-rw-r--r-- | generic/nanosvgrast.h | 2 | ||||
-rw-r--r-- | generic/tk.h | 2 | ||||
-rw-r--r-- | generic/tkBitmap.c | 2 | ||||
-rw-r--r-- | generic/tkCanvText.c | 10 | ||||
-rw-r--r-- | generic/tkConfig.c | 8 | ||||
-rw-r--r-- | generic/tkFont.c | 4 | ||||
-rw-r--r-- | generic/tkFrame.c | 13 | ||||
-rw-r--r-- | generic/tkIcu.c | 7 | ||||
-rw-r--r-- | generic/tkInt.decls | 10 | ||||
-rw-r--r-- | generic/tkInt.h | 4 | ||||
-rw-r--r-- | generic/tkIntXlibDecls.h | 10 | ||||
-rw-r--r-- | generic/tkListbox.c | 21 | ||||
-rw-r--r-- | generic/tkMenu.c | 91 | ||||
-rw-r--r-- | generic/tkMenu.h | 3 | ||||
-rw-r--r-- | generic/tkObj.c | 9 | ||||
-rw-r--r-- | generic/tkStubInit.c | 2 | ||||
-rw-r--r-- | generic/ttk/ttkBlink.c | 71 | ||||
-rw-r--r-- | generic/ttk/ttkLabel.c | 14 | ||||
-rw-r--r-- | generic/ttk/ttkTheme.c | 2 | ||||
-rw-r--r-- | generic/ttk/ttkThemeInt.h | 2 | ||||
-rw-r--r-- | generic/ttk/ttkTreeview.c | 3 |
21 files changed, 217 insertions, 73 deletions
diff --git a/generic/nanosvgrast.h b/generic/nanosvgrast.h index 7992640..eee5bfd 100644 --- a/generic/nanosvgrast.h +++ b/generic/nanosvgrast.h @@ -73,10 +73,10 @@ NANOSVG_SCOPE NSVGrasterizer* nsvgCreateRasterizer(void); * w - width of the image to render * h - height of the image to render * stride - number of bytes per scaleline in the destination buffer + */ NANOSVG_SCOPE void nsvgRasterize(NSVGrasterizer* r, NSVGimage* image, float tx, float ty, float scale, unsigned char* dst, int w, int h, int stride); - */ /* Deletes rasterizer context. */ NANOSVG_SCOPE void nsvgDeleteRasterizer(NSVGrasterizer*); diff --git a/generic/tk.h b/generic/tk.h index 8965b08..51dc7fb 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -149,6 +149,8 @@ typedef const char *Tk_Uid; #if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION == 6) # define Tcl_Size int +# define TCL_SIZE_MAX INT_MAX +# define TCL_SIZE_MODIFIER "" #endif /* diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c index e80760d..9f97b33 100644 --- a/generic/tkBitmap.c +++ b/generic/tkBitmap.c @@ -1084,7 +1084,7 @@ BitmapInit( * TkReadBitmapFile -- * * Loads a bitmap image in X bitmap format into the specified drawable. - * This is equivelent to the XReadBitmapFile in X. + * This is equivalent to the XReadBitmapFile in X. * * Results: * Sets the size, hotspot, and bitmap on success. diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index 27f162a..aaf7c14 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -120,13 +120,11 @@ UnderlineParseProc( obj.bytes = (char *)value; obj.length = strlen(value); obj.typePtr = NULL; - code = TkGetIntForIndex(&obj, TCL_INDEX_END, 0, &underline); + code = TkGetIntForIndex(&obj, TCL_INDEX_NONE, 0, &underline); if (code == TCL_OK) { - if (underline < 0) { - underline = (Tcl_Size)INT_MIN; - } else if ((size_t)underline > (size_t)TCL_INDEX_END>>1) { - underline++; - } else if (underline >= INT_MAX) { + if (underline < INT_MIN) { + underline = INT_MIN; + } else if (underline > INT_MAX) { underline = INT_MAX; } *underlinePtr = (int)underline; diff --git a/generic/tkConfig.c b/generic/tkConfig.c index bc36846..e3bad9d 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -683,17 +683,17 @@ DoObjConfig( case TK_OPTION_INDEX: { Tcl_Size newIndex; - if (TkGetIntForIndex(valuePtr, TCL_INDEX_END, 0, &newIndex) != TCL_OK) { + if (TkGetIntForIndex(valuePtr, TCL_INDEX_NONE, 0, &newIndex) != TCL_OK) { if (interp) { Tcl_AppendResult(interp, "bad index \"", Tcl_GetString(valuePtr), "\": must be integer?[+-]integer?, end?[+-]integer?, or \"\"", NULL); } return TCL_ERROR; } - if (newIndex < 0) { + if (newIndex < INT_MIN) { newIndex = INT_MIN; - } else if ((size_t)newIndex > (size_t)TCL_INDEX_END>>1) { - newIndex++; + } else if (newIndex > INT_MAX) { + newIndex = INT_MAX; } if (internalPtr != NULL) { *((int *) oldInternalPtr) = *((int *) internalPtr); diff --git a/generic/tkFont.c b/generic/tkFont.c index 226f2a9..844ed78 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -422,12 +422,16 @@ TkFontPkgFree( TkFontInfo *fiPtr = mainPtr->fontInfoPtr; Tcl_HashEntry *hPtr, *searchPtr; Tcl_HashSearch search; +#ifdef PURIFY int fontsLeft = 0; +#endif for (searchPtr = Tcl_FirstHashEntry(&fiPtr->fontCache, &search); searchPtr != NULL; searchPtr = Tcl_NextHashEntry(&search)) { +#ifdef PURIFY fontsLeft++; +#endif #ifdef DEBUG_FONTS fprintf(stderr, "Font %s still in cache.\n", (char *) Tcl_GetHashKey(&fiPtr->fontCache, searchPtr)); diff --git a/generic/tkFrame.c b/generic/tkFrame.c index fecf775..91ab80d 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -1480,7 +1480,7 @@ DisplayFrame( Tk_Window tkwin = framePtr->tkwin; int bdX1, bdY1, bdX2, bdY2, hlWidth; Pixmap pixmap; - TkRegion clipRegion = NULL; + Bool useClipping = False; framePtr->flags &= ~REDRAW_PENDING; if ((framePtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { @@ -1619,11 +1619,9 @@ DisplayFrame( if ((labelframePtr->labelBox.width < labelframePtr->labelReqWidth) || (labelframePtr->labelBox.height < labelframePtr->labelReqHeight)) { - clipRegion = TkCreateRegion(); - TkUnionRectWithRegion(&labelframePtr->labelBox, clipRegion, - clipRegion); - TkSetRegion(framePtr->display, labelframePtr->textGC, - clipRegion); + useClipping = True; + XSetClipRectangles(framePtr->display, labelframePtr->textGC, 0, 0, + &labelframePtr->labelBox, 1, Unsorted); } Tk_DrawTextLayout(framePtr->display, pixmap, @@ -1631,9 +1629,8 @@ DisplayFrame( labelframePtr->labelTextX + LABELSPACING, labelframePtr->labelTextY + LABELSPACING, 0, -1); - if (clipRegion != NULL) { + if (useClipping) { XSetClipMask(framePtr->display, labelframePtr->textGC, None); - TkDestroyRegion(clipRegion); } } else { /* diff --git a/generic/tkIcu.c b/generic/tkIcu.c index 342bd11..5639336 100644 --- a/generic/tkIcu.c +++ b/generic/tkIcu.c @@ -11,13 +11,6 @@ */ #include "tkInt.h" -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - -#ifdef HAVE_STDINT_H -#include <stdint.h> -#endif /* * Runtime linking of libicu. diff --git a/generic/tkInt.decls b/generic/tkInt.decls index eabef03..3d04961 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -1339,12 +1339,10 @@ declare 80 win { Drawable d, GC gc, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height) } -# This slot is reserved for use by the clipping rectangle patch: -# declare 81 win { -# XSetClipRectangles(Display *display, GC gc, int clip_x_origin, -# int clip_y_origin, XRectangle rectangles[], int n, int ordering) -# } - +declare 81 win { + int XSetClipRectangles(Display *display, GC gc, int clip_x_origin, + int clip_y_origin, XRectangle rectangles[], int n, int ordering) +} declare 82 win { Status XParseColor(Display *display, Colormap map, _Xconst char *spec, XColor *colorPtr) diff --git a/generic/tkInt.h b/generic/tkInt.h index c3b875c..50829aa 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -31,6 +31,8 @@ #ifdef HAVE_SYS_PARAM_H # include <sys/param.h> #endif +#include <stdint.h> +#include <stdlib.h> #ifdef BYTE_ORDER # ifdef BIG_ENDIAN # if BYTE_ORDER == BIG_ENDIAN @@ -1458,6 +1460,8 @@ MODULE_SCOPE Status TkParseColor (Display * display, MODULE_SCOPE void TkUnixSetXftClipRegion(Region clipRegion); #endif +MODULE_SCOPE void TkpCopyRegion(TkRegion dst, TkRegion src); + #if !defined(__cplusplus) && !defined(c_plusplus) # define c_class class #endif diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index 7e86d52..9725cc5 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -281,7 +281,10 @@ EXTERN int TkPutImage(unsigned long *colors, int ncolors, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height); -/* Slot 81 is reserved */ +/* 81 */ +EXTERN int XSetClipRectangles(Display * display, GC gc, + int clip_x_origin, int clip_y_origin, + XRectangle rectangles[], int n, int ordering); /* 82 */ EXTERN Status XParseColor(Display *display, Colormap map, _Xconst char *spec, XColor *colorPtr); @@ -983,7 +986,7 @@ typedef struct TkIntXlibStubs { Bool (*xFilterEvent) (XEvent *x, Window w); /* 78 */ int (*xmbLookupString) (XIC xi, XKeyPressedEvent *xk, char *c, int i, KeySym *k, Status *s); /* 79 */ int (*tkPutImage) (unsigned long *colors, int ncolors, Display *display, Drawable d, GC gc, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height); /* 80 */ - void (*reserved81)(void); + int (*xSetClipRectangles) (Display* display, GC gc, int clip_x_origin, int clip_y_origin, XRectangle rectangles[], int n, int ordering); /* 81 */ Status (*xParseColor) (Display *display, Colormap map, _Xconst char *spec, XColor *colorPtr); /* 82 */ GC (*xCreateGC) (Display *display, Drawable d, unsigned long valuemask, XGCValues *values); /* 83 */ int (*xFreeGC) (Display *display, GC gc); /* 84 */ @@ -1400,7 +1403,8 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr; (tkIntXlibStubsPtr->xmbLookupString) /* 79 */ #define TkPutImage \ (tkIntXlibStubsPtr->tkPutImage) /* 80 */ -/* Slot 81 is reserved */ +#define XSetClipRectangles \ + (tkIntXlibStubsPtr->xSetClipRectangles) /* 81 */ #define XParseColor \ (tkIntXlibStubsPtr->xParseColor) /* 82 */ #define XCreateGC \ diff --git a/generic/tkListbox.c b/generic/tkListbox.c index d41bece..f66c1b3 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -317,26 +317,23 @@ static const Tk_OptionSpec optionSpecs[] = { */ static const Tk_OptionSpec itemAttrOptionSpecs[] = { - {TK_OPTION_BORDER, "-background", "background", "Background", + {TK_OPTION_BORDER, "-background", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(ItemAttr, border), - TK_OPTION_NULL_OK, - DEF_LISTBOX_BG_MONO, 0}, + TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0}, - {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", + {TK_OPTION_COLOR, "-foreground", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(ItemAttr, fgColor), - TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground", + TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_BORDER, "-selectbackground", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(ItemAttr, selBorder), - TK_OPTION_NULL_OK, - DEF_LISTBOX_SELECT_MONO, 0}, - {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", + TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_COLOR, "-selectforeground", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(ItemAttr, selFgColor), - TK_OPTION_NULL_OK, - DEF_LISTBOX_SELECT_FG_MONO, 0}, - {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0} + TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, NULL, 0} }; /* diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 3eaa86e..ff1148d 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -306,12 +306,12 @@ static const Tk_OptionSpec tkMenuConfigSpecs[] = { static const char *const menuOptions[] = { "activate", "add", "cget", "clone", "configure", "delete", "entrycget", - "entryconfigure", "index", "insert", "invoke", "post", "postcascade", + "entryconfigure", "id", "index", "insert", "invoke", "post", "postcascade", "type", "unpost", "xposition", "yposition", NULL }; enum options { MENU_ACTIVATE, MENU_ADD, MENU_CGET, MENU_CLONE, MENU_CONFIGURE, - MENU_DELETE, MENU_ENTRYCGET, MENU_ENTRYCONFIGURE, MENU_INDEX, + MENU_DELETE, MENU_ENTRYCGET, MENU_ENTRYCONFIGURE, MENU_ID, MENU_INDEX, MENU_INSERT, MENU_INVOKE, MENU_POST, MENU_POSTCASCADE, MENU_TYPE, MENU_UNPOST, MENU_XPOSITION, MENU_YPOSITION }; @@ -451,6 +451,8 @@ Tk_MenuObjCmd( menuPtr->cursorPtr = NULL; menuPtr->mainMenuPtr = menuPtr; menuPtr->menuType = UNKNOWN_TYPE; + Tcl_InitHashTable(&menuPtr->items, TCL_STRING_KEYS); + menuPtr->serial = 0; TkMenuInitializeDrawingFields(menuPtr); Tk_SetClass(menuPtr->tkwin, "Menu"); @@ -821,6 +823,28 @@ MenuWidgetObjCmd( Tcl_Release(mePtr); break; } + case MENU_ID: { + Tcl_Size index; + const char *idStr; + Tcl_HashEntry *entryPtr; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "index"); + goto error; + } + if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { + goto error; + } + if (index == TCL_INDEX_NONE) { + goto done; + } + entryPtr = menuPtr->entries[index]->entryPtr; + if (entryPtr) { + idStr = Tcl_GetHashKey(&menuPtr->items, entryPtr); + Tcl_SetObjResult(interp, Tcl_NewStringObj(idStr, TCL_INDEX_NONE)); + } + break; + } case MENU_INDEX: { Tcl_Size index; @@ -1189,6 +1213,7 @@ DestroyMenuInstance( ckfree(menuPtr->entries); menuPtr->entries = NULL; } + Tcl_DeleteHashTable(&menuPtr->items); TkMenuFreeDrawOptions(menuPtr); Tk_FreeConfigOptions((char *) menuPtr, tsdPtr->menuOptionTable, menuPtr->tkwin); @@ -1455,6 +1480,10 @@ DestroyMenuEntry( TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, MenuVarProc, mePtr); } + if (mePtr->entryPtr) { + Tcl_DeleteHashEntry(mePtr->entryPtr); + mePtr->entryPtr = NULL; + } TkpDestroyMenuEntry(mePtr); TkMenuEntryFreeDrawOptions(mePtr); Tk_FreeConfigOptions((char *) mePtr, mePtr->optionTable, menuPtr->tkwin); @@ -2112,6 +2141,7 @@ GetMenuIndex( { int i; const char *string; + Tcl_HashEntry *entryPtr; if (TkGetIntForIndex(objPtr, menuPtr->numEntries - 1, lastOK, indexPtr) == TCL_OK) { /* TCL_INDEX_NONE is only accepted if it does not result from a negative number */ @@ -2147,12 +2177,19 @@ GetMenuIndex( #endif if (string[0] == '@') { - if (GetIndexFromCoords(NULL, menuPtr, string, indexPtr) + if (GetIndexFromCoords(interp, menuPtr, string, indexPtr) == TCL_OK) { goto success; } } + entryPtr = Tcl_FindHashEntry(&menuPtr->items, string); + if (entryPtr) { + TkMenuEntry *mePtr = Tcl_GetHashValue(entryPtr); + *indexPtr = mePtr->index; + return TCL_OK; + } + for (i = 0; i < (int)menuPtr->numEntries; i++) { Tcl_Obj *labelPtr = menuPtr->entries[i]->labelPtr; const char *label = (labelPtr == NULL) ? NULL : Tcl_GetString(labelPtr); @@ -2301,6 +2338,7 @@ MenuNewEntry( ckfree(mePtr); return NULL; } + mePtr->entryPtr = NULL; TkMenuInitializeEntryDrawingFields(mePtr); if (TkpMenuNewEntry(mePtr) != TCL_OK) { Tk_FreeConfigOptions((char *) mePtr, mePtr->optionTable, @@ -2343,6 +2381,10 @@ MenuAddOrInsert( Tcl_Size index; TkMenuEntry *mePtr; TkMenu *menuListPtr; + Tcl_HashEntry *entryPtr; + Tcl_Obj *idPtr = NULL; + int isNew; + int offs; if (indexPtr != NULL) { if (GetMenuIndex(interp, menuPtr, indexPtr, 1, &index) != TCL_OK) { @@ -2369,11 +2411,26 @@ MenuAddOrInsert( sizeof(char *), "menu entry type", 0, &type) != TCL_OK) { return TCL_ERROR; } + offs = 1; /* - * Now we have to add an entry for every instance related to this menu. + * Check for a user supplied id */ + if (objc % 2 == 0) { + idPtr = objv[offs]; + if (Tcl_FindHashEntry(&menuPtr->items, Tcl_GetString(idPtr))) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "entry \"%s\" already exists", Tcl_GetString(idPtr))); + Tcl_SetErrorCode(interp, "TK", "MENU", "ENTRY_EXISTS", NULL); + return TCL_ERROR; + } + offs++; + } + + /* + * Now we have to add an entry for every instance related to this menu. + */ for (menuListPtr = menuPtr->mainMenuPtr; menuListPtr != NULL; menuListPtr = menuListPtr->nextInstancePtr) { @@ -2381,7 +2438,7 @@ MenuAddOrInsert( if (mePtr == NULL) { return TCL_ERROR; } - if (ConfigureMenuEntry(mePtr, objc - 1, objv + 1) != TCL_OK) { + if (ConfigureMenuEntry(mePtr, objc - offs, objv + offs) != TCL_OK) { TkMenu *errorMenuPtr; Tcl_Size i; @@ -2405,6 +2462,23 @@ MenuAddOrInsert( return TCL_ERROR; } + if (idPtr == NULL) { + char idbuf[16]; + /* Generate an id for the new entry on the main menu */ + do { + snprintf(idbuf, sizeof(idbuf), "e%03X", ++menuPtr->serial); + entryPtr = Tcl_CreateHashEntry( + &menuListPtr->items, idbuf, &isNew); + } while (!isNew); + idPtr = Tcl_NewStringObj(idbuf, TCL_INDEX_NONE); + } else { + /* Reuse the specified or previously generated id on all clones */ + entryPtr = Tcl_CreateHashEntry( + &menuListPtr->items, Tcl_GetString(idPtr), &isNew); + } + Tcl_SetHashValue(entryPtr, mePtr); + mePtr->entryPtr = entryPtr; + /* * If a menu has cascades, then every instance of the menu has to have * its own parallel cascade structure. So adding an entry to a menu @@ -2450,6 +2524,8 @@ MenuAddOrInsert( } } } + + Tcl_SetObjResult(interp, idPtr); return TCL_OK; } @@ -2960,10 +3036,13 @@ GetIndexFromCoords( x = y; p = end + 1; y = strtol(p, &end, 0); - if (end == p) { + if ((end == p) || (*end != '\0')) { goto error; } } else { + if (*end != '\0') { + goto error; + } x = borderwidth; } diff --git a/generic/tkMenu.h b/generic/tkMenu.h index 21ca097..f459277 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -183,6 +183,7 @@ typedef struct TkMenuEntry { int index; /* Need to know which index we are. This is * zero-based. This is the top-left entry of * the menu. */ + Tcl_HashEntry *entryPtr; /* Back-pointer to hash table entry */ /* * Bookeeping for main menus and cascade menus. @@ -379,6 +380,8 @@ typedef struct TkMenu { * multiple menus get changed during one * ConfigureMenu call. */ Tcl_Obj *activeReliefPtr; /* 3-d effect for active element. */ + Tcl_HashTable items; /* Map: id -> entry */ + int serial; /* Next item # for autogenerated ids */ } TkMenu; /* diff --git a/generic/tkObj.c b/generic/tkObj.c index 416b2dd..3f9cad4 100644 --- a/generic/tkObj.c +++ b/generic/tkObj.c @@ -241,18 +241,11 @@ TkGetIntForIndex( const char *value = Tcl_GetString(indexObj); if (!*value) { /* empty string */ - *indexPtr = TCL_INDEX_NONE; + *indexPtr = (end == -1) ? -1 - TCL_SIZE_MAX : TCL_INDEX_NONE; return TCL_OK; } return TCL_ERROR; } - if (*indexPtr < -1) { - *indexPtr = TCL_INDEX_NONE; - } else if (end >= -1) { - if (*indexPtr > end) { - *indexPtr = end + 1; - } - } return TCL_OK; } diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index eddc743..4e7d270 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -761,7 +761,7 @@ static const TkIntXlibStubs tkIntXlibStubs = { XFilterEvent, /* 78 */ XmbLookupString, /* 79 */ TkPutImage, /* 80 */ - 0, /* 81 */ + XSetClipRectangles, /* 81 */ XParseColor, /* 82 */ XCreateGC, /* 83 */ XFreeGC, /* 84 */ diff --git a/generic/ttk/ttkBlink.c b/generic/ttk/ttkBlink.c index fc48af9..c64793e 100644 --- a/generic/ttk/ttkBlink.c +++ b/generic/ttk/ttkBlink.c @@ -10,12 +10,10 @@ * to display the cursor or not (e.g., readonly or disabled states); * TtkBlinkCursor() does not account for this. * - * TODO: - * Add script-level access to configure application-wide blink rate. */ #include "tkInt.h" -#include "ttkTheme.h" +#include "ttkThemeInt.h" #include "ttkWidget.h" #define DEF_CURSOR_ON_TIME 600 /* milliseconds */ @@ -52,6 +50,9 @@ static CursorManager *GetCursorManager(Tcl_Interp *interp) { static const char *cm_key = "ttk::CursorManager"; CursorManager *cm = (CursorManager *)Tcl_GetAssocData(interp, cm_key,0); + Tk_Window window; + Tk_Uid value; + int intValue; if (!cm) { cm = (CursorManager *)ckalloc(sizeof(*cm)); @@ -59,6 +60,27 @@ static CursorManager *GetCursorManager(Tcl_Interp *interp) cm->owner = 0; cm->onTime = DEF_CURSOR_ON_TIME; cm->offTime = DEF_CURSOR_OFF_TIME; + + /* Override on and off default times with values obtained from + * the option database (if such values are specified). + */ + + window = Tk_MainWindow(interp); + if (window) { + value = Tk_GetOption(window, "insertOnTime", "OnTime"); + if (value) { + if (Tcl_GetInt(interp, value, &intValue) == TCL_OK) { + cm->onTime = intValue; + } + } + value = Tk_GetOption(window, "insertOffTime", "OffTime"); + if (value) { + if (Tcl_GetInt(interp, value, &intValue) == TCL_OK) { + cm->offTime = intValue; + } + } + } + Tcl_SetAssocData(interp, cm_key, CursorManagerDeleteProc, cm); } return cm; @@ -154,6 +176,49 @@ CursorEventProc(ClientData clientData, XEvent *eventPtr) } } +void TtkSetBlinkCursorOnTime(Tcl_Interp* interp, int onTime) +{ + CursorManager* cm = GetCursorManager(interp); + + if (onTime >= 0) + cm->onTime = onTime; +} + +void TtkSetBlinkCursorOffTime(Tcl_Interp* interp, int offTime) +{ + CursorManager* cm = GetCursorManager(interp); + + if (offTime >= 0) + cm->offTime = offTime; +} + +/* + * TtkSetBlinkCursorTimes -- + * Set cursor blink on and off times from the "." style defaults + * -insertontime and -insertofftime - For instance to set cursor + * blinking off: + * ttk::style configure . -insertofftime 0 + */ +void TtkSetBlinkCursorTimes(Tcl_Interp* interp) +{ + Ttk_Theme theme; + Ttk_Style style = NULL; + Tcl_Obj* result; + int timeInterval; + + theme = Ttk_GetCurrentTheme(interp); + style = Ttk_GetStyle(theme, "."); + result = Ttk_StyleDefault(style, "-insertontime"); + if (result) { + Tcl_GetIntFromObj(interp, result, &timeInterval); + TtkSetBlinkCursorOnTime(interp, timeInterval); + } + result = Ttk_StyleDefault(style, "-insertofftime"); + if (result) { + Tcl_GetIntFromObj(interp, result, &timeInterval); + TtkSetBlinkCursorOffTime(interp, timeInterval); + } +} /* * TtkBlinkCursor (main routine) -- * Arrange to blink the cursor on and off whenever the diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c index baa6f6a..d94cb23 100644 --- a/generic/ttk/ttkLabel.c +++ b/generic/ttk/ttkLabel.c @@ -130,7 +130,7 @@ static void TextCleanup(TextElement *text) static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b) { XColor *color = Tk_GetColorFromObj(tkwin, text->foregroundObj); - Tcl_Size underline = TCL_INDEX_NONE; + Tcl_Size underline = INT_MIN; XGCValues gcValues; GC gc1, gc2; Tk_Anchor anchor = TK_ANCHOR_CENTER; @@ -175,11 +175,13 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b) text->textLayout, b.x, b.y, 0/*firstChar*/, -1/*lastChar*/); if (text->underlineObj != NULL) { - TkGetIntForIndex(text->underlineObj, TCL_INDEX_END, 0, &underline); - if (underline >= 0) { - if ((size_t)underline > (size_t)TCL_INDEX_END>>1) { - underline++; - } + TkGetIntForIndex(text->underlineObj, TCL_INDEX_NONE, 0, &underline); + if (underline < INT_MIN) { + underline = INT_MIN; + } else if (underline > INT_MAX) { + underline = INT_MAX; + } + if (underline != INT_MIN) { if (text->embossed) { Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc2, text->textLayout, b.x+1, b.y+1, underline); diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c index 852287e..57b0610 100644 --- a/generic/ttk/ttkTheme.c +++ b/generic/ttk/ttkTheme.c @@ -516,6 +516,8 @@ static void ThemeChangedProc(ClientData clientData) */ static void ThemeChanged(StylePackageData *pkgPtr) { + TtkSetBlinkCursorTimes(pkgPtr->interp); + if (!pkgPtr->themeChangePending) { Tcl_DoWhenIdle(ThemeChangedProc, pkgPtr); pkgPtr->themeChangePending = 1; diff --git a/generic/ttk/ttkThemeInt.h b/generic/ttk/ttkThemeInt.h index 67ffc34..e8d9665 100644 --- a/generic/ttk/ttkThemeInt.h +++ b/generic/ttk/ttkThemeInt.h @@ -39,6 +39,8 @@ MODULE_SCOPE Ttk_LayoutTemplate Ttk_FindLayoutTemplate( MODULE_SCOPE const char *Ttk_StyleName(Ttk_Style); +MODULE_SCOPE void TtkSetBlinkCursorTimes(Tcl_Interp* interp); + #if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9) # define TTK_OPTION_UNDERLINE_DEF(type, field) "-1", offsetof(type, field), TCL_INDEX_NONE, 0, NULL #else diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index 4494a65..11de5e0 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -1922,8 +1922,9 @@ static Ttk_Layout TreeviewGetLayout( if ((objPtr = Ttk_QueryOption(treeLayout, "-rowheight", 0))) { (void)Tk_GetPixelsFromObj(NULL, tv->core.tkwin, objPtr, &tv->tree.rowHeight); - tv->tree.rowHeight = MAX(tv->tree.rowHeight, 1); } + tv->tree.rowHeight = MAX(tv->tree.rowHeight, 1); + if ((objPtr = Ttk_QueryOption(treeLayout, "-columnseparatorwidth", 0))) { (void)Tk_GetPixelsFromObj(NULL, tv->core.tkwin, objPtr, &tv->tree.colSeparatorWidth); } |