Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | Merge 8.6 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | mac_styles |
Files: | files | file ages | folders |
SHA3-256: |
2603d1554b760bc92bb106e5a1efca32 |
User & Date: | marc_culler 2020-09-10 17:22:06 |
2020-09-12
| ||
21:50 | Add a disclosure triangle that works in Big Sur check-in: 01a53c58 user: marc_culler tags: mac_styles | |
2020-09-10
| ||
17:22 | Merge 8.6 check-in: 2603d155 user: marc_culler tags: mac_styles | |
12:09 | Fix [ab1feaea9c]: Aqua initialization issues check-in: c28d05ab user: marc_culler tags: core-8-6-branch | |
2020-09-08
| ||
16:27 | Merge 8.6 check-in: 609db937 user: marc_culler tags: mac_styles | |
Changes to generic/tkConfig.c.
︙ | ︙ | |||
1496 1497 1498 1499 1500 1501 1502 | int count; Tk_SavedOption *savedOptionPtr; if (savePtr->nextPtr != NULL) { Tk_FreeSavedOptions(savePtr->nextPtr); ckfree(savePtr->nextPtr); } | | | < | 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 | int count; Tk_SavedOption *savedOptionPtr; if (savePtr->nextPtr != NULL) { Tk_FreeSavedOptions(savePtr->nextPtr); ckfree(savePtr->nextPtr); } for (count = savePtr->numItems; count > 0; count--) { savedOptionPtr = &savePtr->items[count-1]; if (savedOptionPtr->optionPtr->flags & OPTION_NEEDS_FREEING) { FreeResources(savedOptionPtr->optionPtr, savedOptionPtr->valuePtr, (char *) &savedOptionPtr->internalForm, savePtr->tkwin); } if (savedOptionPtr->valuePtr != NULL) { Tcl_DecrRefCount(savedOptionPtr->valuePtr); } |
︙ | ︙ |
Changes to generic/tkFont.c.
︙ | ︙ | |||
376 377 378 379 380 381 382 | *--------------------------------------------------------------------------- */ void TkFontPkgInit( TkMainInfo *mainPtr) /* The application being created. */ { | | | 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | *--------------------------------------------------------------------------- */ void TkFontPkgInit( TkMainInfo *mainPtr) /* The application being created. */ { TkFontInfo *fiPtr = (TkFontInfo *)ckalloc(sizeof(TkFontInfo)); Tcl_InitHashTable(&fiPtr->fontCache, TCL_STRING_KEYS); Tcl_InitHashTable(&fiPtr->namedTable, TCL_STRING_KEYS); fiPtr->mainPtr = mainPtr; fiPtr->updatePending = 0; mainPtr->fontInfoPtr = fiPtr; |
︙ | ︙ | |||
469 470 471 472 473 474 475 | Tk_FontObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { int index; | | | 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | Tk_FontObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { int index; Tk_Window tkwin = (Tk_Window)clientData; TkFontInfo *fiPtr = ((TkWindow *) tkwin)->mainPtr->fontInfoPtr; static const char *const optionStrings[] = { "actual", "configure", "create", "delete", "families", "measure", "metrics", "names", NULL }; enum options { |
︙ | ︙ | |||
613 614 615 616 617 618 619 | if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, "fontname ?-option value ...?"); return TCL_ERROR; } string = Tcl_GetString(objv[2]); namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, string); | | | | 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 | if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, "fontname ?-option value ...?"); return TCL_ERROR; } string = Tcl_GetString(objv[2]); namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, string); nfPtr = NULL; if (namedHashPtr != NULL) { nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr); } if ((namedHashPtr == NULL) || nfPtr->deletePending) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "named font \"%s\" doesn't exist", string)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "FONT", string, NULL); return TCL_ERROR; } |
︙ | ︙ | |||
793 794 795 796 797 798 799 | if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "names"); return TCL_ERROR; } resultPtr = Tcl_NewObj(); namedHashPtr = Tcl_FirstHashEntry(&fiPtr->namedTable, &search); while (namedHashPtr != NULL) { | | | | 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 | if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "names"); return TCL_ERROR; } resultPtr = Tcl_NewObj(); namedHashPtr = Tcl_FirstHashEntry(&fiPtr->namedTable, &search); while (namedHashPtr != NULL) { NamedFont *nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr); if (!nfPtr->deletePending) { char *string = (char *)Tcl_GetHashKey(&fiPtr->namedTable, namedHashPtr); Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(string, -1)); } namedHashPtr = Tcl_NextHashEntry(&search); } |
︙ | ︙ | |||
839 840 841 842 843 844 845 | TkFontInfo *fiPtr, /* Info about application's fonts. */ Tk_Window tkwin, /* A window in the application. */ Tcl_HashEntry *namedHashPtr)/* The named font that is changing. */ { Tcl_HashEntry *cacheHashPtr; Tcl_HashSearch search; TkFont *fontPtr; | | | | | 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 | TkFontInfo *fiPtr, /* Info about application's fonts. */ Tk_Window tkwin, /* A window in the application. */ Tcl_HashEntry *namedHashPtr)/* The named font that is changing. */ { Tcl_HashEntry *cacheHashPtr; Tcl_HashSearch search; TkFont *fontPtr; NamedFont *nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr); if (nfPtr->refCount == 0) { /* * Well nobody's using this named font, so don't have to tell any * widgets to recompute themselves. */ return; } cacheHashPtr = Tcl_FirstHashEntry(&fiPtr->fontCache, &search); while (cacheHashPtr != NULL) { for (fontPtr = (TkFont *)Tcl_GetHashValue(cacheHashPtr); fontPtr != NULL; fontPtr = fontPtr->nextPtr) { if (fontPtr->namedHashPtr == namedHashPtr) { TkpGetFontFromAttributes(fontPtr, tkwin, &nfPtr->fa); if (!fiPtr->updatePending) { fiPtr->updatePending = 1; Tcl_DoWhenIdle(TheWorldHasChanged, fiPtr); } } } cacheHashPtr = Tcl_NextHashEntry(&search); } } static void TheWorldHasChanged( ClientData clientData) /* Info about application's fonts. */ { TkFontInfo *fiPtr = (TkFontInfo *)clientData; /* * On macOS it is catastrophic to recompute all widgets while the * [NSView drawRect] method is drawing. The best that we can do in * that situation is to abort the recomputation and hope for the best. * This is ignored on other platforms. */ |
︙ | ︙ | |||
960 961 962 963 964 965 966 | TkFontInfo *fiPtr = ((TkWindow *) tkwin)->mainPtr->fontInfoPtr; Tcl_HashEntry *namedHashPtr; int isNew; NamedFont *nfPtr; namedHashPtr = Tcl_CreateHashEntry(&fiPtr->namedTable, name, &isNew); if (!isNew) { | | | 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 | TkFontInfo *fiPtr = ((TkWindow *) tkwin)->mainPtr->fontInfoPtr; Tcl_HashEntry *namedHashPtr; int isNew; NamedFont *nfPtr; namedHashPtr = Tcl_CreateHashEntry(&fiPtr->namedTable, name, &isNew); if (!isNew) { nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr); if (!nfPtr->deletePending) { if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "named font \"%s\" already exists", name)); Tcl_SetErrorCode(interp, "TK", "FONT", "EXISTS", NULL); } return TCL_ERROR; |
︙ | ︙ | |||
982 983 984 985 986 987 988 | nfPtr->fa = *faPtr; nfPtr->deletePending = 0; UpdateDependentFonts(fiPtr, tkwin, namedHashPtr); return TCL_OK; } | | | 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 | nfPtr->fa = *faPtr; nfPtr->deletePending = 0; UpdateDependentFonts(fiPtr, tkwin, namedHashPtr); return TCL_OK; } nfPtr = (NamedFont *)ckalloc(sizeof(NamedFont)); nfPtr->deletePending = 0; Tcl_SetHashValue(namedHashPtr, nfPtr); nfPtr->fa = *faPtr; nfPtr->refCount = 0; nfPtr->deletePending = 0; return TCL_OK; } |
︙ | ︙ | |||
1021 1022 1023 1024 1025 1026 1027 | if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "named font \"%s\" doesn't exist", name)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "FONT", name, NULL); } return TCL_ERROR; } | | | 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 | if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "named font \"%s\" doesn't exist", name)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "FONT", name, NULL); } return TCL_ERROR; } nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr); if (nfPtr->refCount != 0) { nfPtr->deletePending = 1; } else { Tcl_DeleteHashEntry(namedHashPtr); ckfree(nfPtr); } return TCL_OK; |
︙ | ︙ | |||
1110 1111 1112 1113 1114 1115 1116 | NamedFont *nfPtr; if (objPtr->typePtr != &tkFontObjType || objPtr->internalRep.twoPtrValue.ptr2 != fiPtr) { SetFontFromAny(interp, objPtr); } | | | 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 | NamedFont *nfPtr; if (objPtr->typePtr != &tkFontObjType || objPtr->internalRep.twoPtrValue.ptr2 != fiPtr) { SetFontFromAny(interp, objPtr); } oldFontPtr = (TkFont *)objPtr->internalRep.twoPtrValue.ptr1; if (oldFontPtr != NULL) { if (oldFontPtr->resourceRefCount == 0) { /* * This is a stale reference: it refers to a TkFont that's no * longer in use. Clear the reference. */ |
︙ | ︙ | |||
1139 1140 1141 1142 1143 1144 1145 | if (oldFontPtr != NULL) { cacheHashPtr = oldFontPtr->cacheHashPtr; FreeFontObj(objPtr); } else { cacheHashPtr = Tcl_CreateHashEntry(&fiPtr->fontCache, Tcl_GetString(objPtr), &isNew); } | | | 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 | if (oldFontPtr != NULL) { cacheHashPtr = oldFontPtr->cacheHashPtr; FreeFontObj(objPtr); } else { cacheHashPtr = Tcl_CreateHashEntry(&fiPtr->fontCache, Tcl_GetString(objPtr), &isNew); } firstFontPtr = (TkFont *)Tcl_GetHashValue(cacheHashPtr); for (fontPtr = firstFontPtr; (fontPtr != NULL); fontPtr = fontPtr->nextPtr) { if (Tk_Screen(tkwin) == fontPtr->screen) { fontPtr->resourceRefCount++; fontPtr->objRefCount++; objPtr->internalRep.twoPtrValue.ptr1 = fontPtr; objPtr->internalRep.twoPtrValue.ptr2 = fiPtr; |
︙ | ︙ | |||
1162 1163 1164 1165 1166 1167 1168 | namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, Tcl_GetString(objPtr)); if (namedHashPtr != NULL) { /* * Construct a font based on a named font. */ | | | 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 | namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, Tcl_GetString(objPtr)); if (namedHashPtr != NULL) { /* * Construct a font based on a named font. */ nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr); nfPtr->refCount++; fontPtr = TkpGetFontFromAttributes(NULL, tkwin, &nfPtr->fa); } else { /* * Native font? */ |
︙ | ︙ | |||
1295 1296 1297 1298 1299 1300 1301 | Tcl_HashEntry *hashPtr; if (objPtr->typePtr != &tkFontObjType || objPtr->internalRep.twoPtrValue.ptr2 != fiPtr) { SetFontFromAny(NULL, objPtr); } | | | 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 | Tcl_HashEntry *hashPtr; if (objPtr->typePtr != &tkFontObjType || objPtr->internalRep.twoPtrValue.ptr2 != fiPtr) { SetFontFromAny(NULL, objPtr); } fontPtr = (TkFont *)objPtr->internalRep.twoPtrValue.ptr1; if (fontPtr != NULL) { if (fontPtr->resourceRefCount == 0) { /* * This is a stale reference: it refers to a TkFont that's no * longer in use. Clear the reference. */ |
︙ | ︙ | |||
1322 1323 1324 1325 1326 1327 1328 | if (fontPtr != NULL) { hashPtr = fontPtr->cacheHashPtr; FreeFontObj(objPtr); } else { hashPtr = Tcl_FindHashEntry(&fiPtr->fontCache, Tcl_GetString(objPtr)); } if (hashPtr != NULL) { | | | 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 | if (fontPtr != NULL) { hashPtr = fontPtr->cacheHashPtr; FreeFontObj(objPtr); } else { hashPtr = Tcl_FindHashEntry(&fiPtr->fontCache, Tcl_GetString(objPtr)); } if (hashPtr != NULL) { for (fontPtr = (TkFont *)Tcl_GetHashValue(hashPtr); fontPtr != NULL; fontPtr = fontPtr->nextPtr) { if (Tk_Screen(tkwin) == fontPtr->screen) { fontPtr->objRefCount++; objPtr->internalRep.twoPtrValue.ptr1 = fontPtr; objPtr->internalRep.twoPtrValue.ptr2 = fiPtr; return (Tk_Font) fontPtr; } |
︙ | ︙ | |||
1357 1358 1359 1360 1361 1362 1363 | * TkFont pointer is NULL. * *---------------------------------------------------------------------- */ static int SetFontFromAny( | | | 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 | * TkFont pointer is NULL. * *---------------------------------------------------------------------- */ static int SetFontFromAny( TCL_UNUSED(Tcl_Interp *), /* Used for error reporting if not NULL. */ Tcl_Obj *objPtr) /* The object to convert. */ { const Tcl_ObjType *typePtr; /* * Free the old internalRep before setting the new one. */ |
︙ | ︙ | |||
1433 1434 1435 1436 1437 1438 1439 | { TkFont *fontPtr = (TkFont *) tkfont, *prevPtr; NamedFont *nfPtr; if (fontPtr == NULL) { return; } | < | | | | 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 | { TkFont *fontPtr = (TkFont *) tkfont, *prevPtr; NamedFont *nfPtr; if (fontPtr == NULL) { return; } if (fontPtr->resourceRefCount-- > 1) { return; } if (fontPtr->namedHashPtr != NULL) { /* * This font derived from a named font. Reduce the reference count on * the named font and free it if no-one else is using it. */ nfPtr = (NamedFont *)Tcl_GetHashValue(fontPtr->namedHashPtr); nfPtr->refCount--; if ((nfPtr->refCount == 0) && nfPtr->deletePending) { Tcl_DeleteHashEntry(fontPtr->namedHashPtr); ckfree(nfPtr); } } prevPtr = (TkFont *)Tcl_GetHashValue(fontPtr->cacheHashPtr); if (prevPtr == fontPtr) { if (fontPtr->nextPtr == NULL) { Tcl_DeleteHashEntry(fontPtr->cacheHashPtr); } else { Tcl_SetHashValue(fontPtr->cacheHashPtr, fontPtr->nextPtr); } } else { |
︙ | ︙ | |||
1529 1530 1531 1532 1533 1534 1535 | objPtr->typePtr = NULL; } static void FreeFontObj( Tcl_Obj *objPtr) /* The object we are releasing. */ { | | | 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 | objPtr->typePtr = NULL; } static void FreeFontObj( Tcl_Obj *objPtr) /* The object we are releasing. */ { TkFont *fontPtr = (TkFont *)objPtr->internalRep.twoPtrValue.ptr1; if (fontPtr != NULL) { fontPtr->objRefCount--; if ((fontPtr->resourceRefCount == 0) && (fontPtr->objRefCount == 0)) { ckfree(fontPtr); } objPtr->internalRep.twoPtrValue.ptr1 = NULL; |
︙ | ︙ | |||
1564 1565 1566 1567 1568 1569 1570 | */ static void DupFontObjProc( Tcl_Obj *srcObjPtr, /* The object we are copying from. */ Tcl_Obj *dupObjPtr) /* The object we are copying to. */ { | | | 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 | */ static void DupFontObjProc( Tcl_Obj *srcObjPtr, /* The object we are copying from. */ Tcl_Obj *dupObjPtr) /* The object we are copying to. */ { TkFont *fontPtr = (TkFont *)srcObjPtr->internalRep.twoPtrValue.ptr1; dupObjPtr->typePtr = srcObjPtr->typePtr; dupObjPtr->internalRep.twoPtrValue.ptr1 = fontPtr; dupObjPtr->internalRep.twoPtrValue.ptr2 = srcObjPtr->internalRep.twoPtrValue.ptr2; if (fontPtr != NULL) { |
︙ | ︙ | |||
2003 2004 2005 2006 2007 2008 2009 | } if (wrapLength == 0) { wrapLength = -1; } maxChunks = 1; | | | | 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 | } if (wrapLength == 0) { wrapLength = -1; } maxChunks = 1; layoutPtr = (TextLayout *)ckalloc(Tk_Offset(TextLayout, chunks) + maxChunks * sizeof(LayoutChunk)); layoutPtr->tkfont = tkfont; layoutPtr->string = string; layoutPtr->numChunks = 0; baseline = fmPtr->ascent; maxWidth = 0; |
︙ | ︙ | |||
3401 3402 3403 3404 3405 3406 3407 | * *--------------------------------------------------------------------------- */ static int ConfigAttributesObj( Tcl_Interp *interp, /* Interp for error return. */ | | | 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 | * *--------------------------------------------------------------------------- */ static int ConfigAttributesObj( Tcl_Interp *interp, /* Interp for error return. */ TCL_UNUSED(Tk_Window), /* For display on which font will be used. */ int objc, /* Number of elements in argv. */ Tcl_Obj *const objv[], /* Command line options. */ TkFontAttributes *faPtr) /* Font attributes structure whose fields are * to be modified. Structure must already be * properly initialized. */ { int i, n, index; |
︙ | ︙ | |||
3776 3777 3778 3779 3780 3781 3782 | int maxChunks, numChars; size_t s; layoutPtr = *layoutPtrPtr; maxChunks = *maxPtr; if (layoutPtr->numChunks == maxChunks) { maxChunks *= 2; | | | 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 | int maxChunks, numChars; size_t s; layoutPtr = *layoutPtrPtr; maxChunks = *maxPtr; if (layoutPtr->numChunks == maxChunks) { maxChunks *= 2; s = Tk_Offset(TextLayout, chunks) + (maxChunks * sizeof(LayoutChunk)); layoutPtr = ckrealloc(layoutPtr, s); *layoutPtrPtr = layoutPtr; *maxPtr = maxChunks; } numChars = Tcl_NumUtfChars(start, numBytes); chunkPtr = &layoutPtr->chunks[layoutPtr->numChunks]; |
︙ | ︙ | |||
4240 4241 4242 4243 4244 4245 4246 | Tcl_HashEntry *hashPtr; Tcl_Obj *resultPtr, *objPtr; resultPtr = Tcl_NewObj(); hashPtr = Tcl_FindHashEntry( &((TkWindow *) tkwin)->mainPtr->fontInfoPtr->fontCache, name); if (hashPtr != NULL) { | | | 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 | Tcl_HashEntry *hashPtr; Tcl_Obj *resultPtr, *objPtr; resultPtr = Tcl_NewObj(); hashPtr = Tcl_FindHashEntry( &((TkWindow *) tkwin)->mainPtr->fontInfoPtr->fontCache, name); if (hashPtr != NULL) { fontPtr = (TkFont *)Tcl_GetHashValue(hashPtr); if (fontPtr == NULL) { Tcl_Panic("TkDebugFont found empty hash table entry"); } for ( ; (fontPtr != NULL); fontPtr = fontPtr->nextPtr) { objPtr = Tcl_NewObj(); Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewIntObj(fontPtr->resourceRefCount)); |
︙ | ︙ | |||
4293 4294 4295 4296 4297 4298 4299 | if ((layoutPtr == NULL) || (layoutPtr->numChunks == 0) || (layoutPtr->chunks->numDisplayChars <= 0)) { dst[0] = '\0'; return 0; } chunkPtr = layoutPtr->chunks; numBytesInChunk = chunkPtr->numBytes; | | | 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 | if ((layoutPtr == NULL) || (layoutPtr->numChunks == 0) || (layoutPtr->chunks->numDisplayChars <= 0)) { dst[0] = '\0'; return 0; } chunkPtr = layoutPtr->chunks; numBytesInChunk = chunkPtr->numBytes; strncpy(dst, chunkPtr->start, numBytesInChunk); *font = layoutPtr->tkfont; return numBytesInChunk; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkGeometry.c.
︙ | ︙ | |||
16 17 18 19 20 21 22 | /* * Data structures of the following type are used by Tk_MaintainGeometry. For * each content managed by Tk_MaintainGeometry, there is one of these structures * associated with its container. */ typedef struct MaintainContent { | | | | | | | | | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | /* * Data structures of the following type are used by Tk_MaintainGeometry. For * each content managed by Tk_MaintainGeometry, there is one of these structures * associated with its container. */ typedef struct MaintainContent { Tk_Window content; /* The content window being positioned. */ Tk_Window container; /* The container that determines content's * position; it must be a descendant of * content's parent. */ int x, y; /* Desired position of content relative to * container. */ int width, height; /* Desired dimensions of content. */ struct MaintainContent *nextPtr; /* Next in list of Maintains associated with * container. */ } MaintainContent; /* * For each window that has been specified as a content to Tk_MaintainGeometry, * there is a structure of the following type: */ typedef struct MaintainContainer { Tk_Window ancestor; /* The lowest ancestor of this window for * which we have *not* created a * StructureNotify handler. May be the same as * the window itself. */ int checkScheduled; /* Non-zero means that there is already a call * to MaintainCheckProc scheduled as an idle * handler. */ MaintainContent *contentPtr; /* First in list of all content associated with * this container. */ } MaintainContainer; /* * Prototypes for static procedures in this file: */ static void MaintainCheckProc(ClientData clientData); static void MaintainContainerProc(ClientData clientData, XEvent *eventPtr); static void MaintainContentProc(ClientData clientData, XEvent *eventPtr); /* *-------------------------------------------------------------- * * Tk_ManageGeometry -- * * Arrange for a particular procedure to manage the geometry of a given * content window. * * Results: * None. * * Side effects: * Proc becomes the new geometry manager for tkwin, replacing any * previous geometry manager. The geometry manager will be notified (by |
︙ | ︙ | |||
214 215 216 217 218 219 220 | } if (bottom != winPtr->internalBorderBottom) { winPtr->internalBorderBottom = bottom; changed = 1; } /* | | | 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | } if (bottom != winPtr->internalBorderBottom) { winPtr->internalBorderBottom = bottom; changed = 1; } /* * All the content for which this is the container window must now be * repositioned to take account of the new internal border width. To * signal all the geometry managers to do this, trigger a ConfigureNotify * event. This will cause geometry managers to recompute everything. */ if (changed) { TkDoConfigureNotify(winPtr); |
︙ | ︙ | |||
337 338 339 340 341 342 343 | " has slaves managed by %s", name, Tk_PathName(tkwin), winPtr->geomMgrName)); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "FIGHT", NULL); } return TCL_ERROR; } | | | 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | " has slaves managed by %s", name, Tk_PathName(tkwin), winPtr->geomMgrName)); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "FIGHT", NULL); } return TCL_ERROR; } winPtr->geomMgrName = (char *)ckalloc(strlen(name) + 1); strcpy(winPtr->geomMgrName, name); return TCL_OK; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
383 384 385 386 387 388 389 | } /* *---------------------------------------------------------------------- * * Tk_MaintainGeometry -- * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 | } /* *---------------------------------------------------------------------- * * Tk_MaintainGeometry -- * * This procedure is invoked by geometry managers to handle content whose * container's are not their parents. It translates the desired geometry for * the content into the coordinate system of the parent and respositions * the content if it isn't already at the right place. Furthermore, it sets * up event handlers so that if the container (or any of its ancestors up to * the content's parent) is mapped, unmapped, or moved, then the content will * be adjusted to match. * * Results: * None. * * Side effects: * Event handlers are created and state is allocated to keep track of * content. Note: if content was already managed for container by * Tk_MaintainGeometry, then the previous information is replaced with * the new information. The caller must eventually call * Tk_UnmaintainGeometry to eliminate the correspondence (or, the state * is automatically freed when either window is destroyed). * *---------------------------------------------------------------------- */ void Tk_MaintainGeometry( Tk_Window window, /* Window for geometry management. */ Tk_Window container, /* Container for window; must be a descendant of * window's parent. */ int x, int y, /* Desired position of window within container. */ int width, int height) /* Desired dimensions for window. */ { Tcl_HashEntry *hPtr; MaintainContainer *containerPtr; MaintainContent *contentPtr; int isNew, map; Tk_Window ancestor, parent; TkDisplay *dispPtr = ((TkWindow *) container)->dispPtr; ((TkWindow *)window)->maintainerPtr = (TkWindow *)container; ((TkWindow *)window)->maintainerPtr = (TkWindow *)container; if (container == Tk_Parent(window)) { /* * If the window is a direct descendant of the container, don't bother * setting up the extra infrastructure for management, just make a * call to Tk_MoveResizeWindow; the parent/child relationship will * take care of the rest. */ Tk_MoveResizeWindow(window, x, y, width, height); /* * Map the window if the container is already mapped; otherwise, wait * until the container is mapped later (in which case mapping the window * is taken care of elsewhere). */ if (Tk_IsMapped(container)) { Tk_MapWindow(window); } return; } if (!dispPtr->geomInit) { dispPtr->geomInit = 1; Tcl_InitHashTable(&dispPtr->maintainHashTable, TCL_ONE_WORD_KEYS); } /* * See if there is already a MaintainContainer structure for the container; if * not, then create one. */ parent = Tk_Parent(window); hPtr = Tcl_CreateHashEntry(&dispPtr->maintainHashTable, (char *) container, &isNew); if (!isNew) { containerPtr = (MaintainContainer *)Tcl_GetHashValue(hPtr); } else { containerPtr = (MaintainContainer *)ckalloc(sizeof(MaintainContainer)); containerPtr->ancestor = container; containerPtr->checkScheduled = 0; containerPtr->contentPtr = NULL; Tcl_SetHashValue(hPtr, containerPtr); } /* * Create a MaintainContent structure for the window if there isn't already * one. */ for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; contentPtr = contentPtr->nextPtr) { if (contentPtr->content == window) { goto gotContent; } } contentPtr = (MaintainContent *)ckalloc(sizeof(MaintainContent)); contentPtr->content = window; contentPtr->container = container; contentPtr->nextPtr = containerPtr->contentPtr; containerPtr->contentPtr = contentPtr; Tk_CreateEventHandler(window, StructureNotifyMask, MaintainContentProc, contentPtr); /* * Make sure that there are event handlers registered for all the windows * between container and windows's parent (including container but not window's * parent). There may already be handlers for container and some of its * ancestors (containerPtr->ancestor tells how many). */ for (ancestor = container; ancestor != parent; ancestor = Tk_Parent(ancestor)) { if (ancestor == containerPtr->ancestor) { Tk_CreateEventHandler(ancestor, StructureNotifyMask, MaintainContainerProc, containerPtr); containerPtr->ancestor = Tk_Parent(ancestor); } } /* * Fill in up-to-date information in the structure, then update the window * if it's not currently in the right place or state. */ gotContent: contentPtr->x = x; contentPtr->y = y; contentPtr->width = width; contentPtr->height = height; map = 1; for (ancestor = contentPtr->container; ; ancestor = Tk_Parent(ancestor)) { if (!Tk_IsMapped(ancestor) && (ancestor != parent)) { map = 0; } if (ancestor == parent) { if ((x != Tk_X(contentPtr->content)) || (y != Tk_Y(contentPtr->content)) || (width != Tk_Width(contentPtr->content)) || (height != Tk_Height(contentPtr->content))) { Tk_MoveResizeWindow(contentPtr->content, x, y, width, height); } if (map) { Tk_MapWindow(contentPtr->content); } else { Tk_UnmapWindow(contentPtr->content); } break; } x += Tk_X(ancestor) + Tk_Changes(ancestor)->border_width; y += Tk_Y(ancestor) + Tk_Changes(ancestor)->border_width; } } /* *---------------------------------------------------------------------- * * Tk_UnmaintainGeometry -- * * This procedure cancels a previous Tk_MaintainGeometry call, so that * the relationship between window and container is no longer maintained. * * Results: * None. * * Side effects: * The window is unmapped and state is released, so that window won't track * container any more. If we weren't previously managing window relative to * container, then this procedure has no effect. * *---------------------------------------------------------------------- */ void Tk_UnmaintainGeometry( Tk_Window window, /* WIndow for geometry management. */ Tk_Window container) /* Container for window; must be a descendant of * window's parent. */ { Tcl_HashEntry *hPtr; MaintainContainer *containerPtr; MaintainContent *contentPtr, *prevPtr; Tk_Window ancestor; TkDisplay *dispPtr = ((TkWindow *) window)->dispPtr; ((TkWindow *)window)->maintainerPtr = NULL; ((TkWindow *)window)->maintainerPtr = NULL; if (container == Tk_Parent(window)) { /* * If the window is a direct descendant of the container, * Tk_MaintainGeometry will not have set up any of the extra * infrastructure. Don't even bother to look for it, just return. */ return; } if (!dispPtr->geomInit) { dispPtr->geomInit = 1; Tcl_InitHashTable(&dispPtr->maintainHashTable, TCL_ONE_WORD_KEYS); } if (!(((TkWindow *) window)->flags & TK_ALREADY_DEAD)) { Tk_UnmapWindow(window); } hPtr = Tcl_FindHashEntry(&dispPtr->maintainHashTable, container); if (hPtr == NULL) { return; } containerPtr = (MaintainContainer *)Tcl_GetHashValue(hPtr); contentPtr = containerPtr->contentPtr; if (contentPtr->content == window) { containerPtr->contentPtr = contentPtr->nextPtr; } else { for (prevPtr = contentPtr, contentPtr = contentPtr->nextPtr; ; prevPtr = contentPtr, contentPtr = contentPtr->nextPtr) { if (contentPtr == NULL) { return; } if (contentPtr->content == window) { prevPtr->nextPtr = contentPtr->nextPtr; break; } } } Tk_DeleteEventHandler(contentPtr->content, StructureNotifyMask, MaintainContentProc, contentPtr); ckfree(contentPtr); if (containerPtr->contentPtr == NULL) { if (containerPtr->ancestor != NULL) { for (ancestor = container; ; ancestor = Tk_Parent(ancestor)) { Tk_DeleteEventHandler(ancestor, StructureNotifyMask, MaintainContainerProc, containerPtr); if (ancestor == containerPtr->ancestor) { break; } } } if (containerPtr->checkScheduled) { Tcl_CancelIdleCall(MaintainCheckProc, containerPtr); } Tcl_DeleteHashEntry(hPtr); ckfree(containerPtr); } } /* *---------------------------------------------------------------------- * * MaintainContainerProc -- * * This procedure is invoked by the Tk event dispatcher in response to * StructureNotify events on the container or one of its ancestors, on * behalf of Tk_MaintainGeometry. * * Results: * None. * * Side effects: * It schedules a call to MaintainCheckProc, which will eventually caused * the postions and mapped states to be recalculated for all the * maintained windows of the container. Or, if the container window is being * deleted then state is cleaned up. * *---------------------------------------------------------------------- */ static void MaintainContainerProc( ClientData clientData, /* Pointer to MaintainContainer structure for the * container window. */ XEvent *eventPtr) /* Describes what just happened. */ { MaintainContainer *containerPtr = (MaintainContainer *)clientData; MaintainContent *contentPtr; int done; if ((eventPtr->type == ConfigureNotify) || (eventPtr->type == MapNotify) || (eventPtr->type == UnmapNotify)) { if (!containerPtr->checkScheduled) { containerPtr->checkScheduled = 1; Tcl_DoWhenIdle(MaintainCheckProc, containerPtr); } } else if (eventPtr->type == DestroyNotify) { /* * Delete all of the state associated with this container, but be careful * not to use containerPtr after the last window is deleted, since its * memory will have been freed. */ done = 0; do { contentPtr = containerPtr->contentPtr; if (contentPtr->nextPtr == NULL) { done = 1; } Tk_UnmaintainGeometry(contentPtr->content, contentPtr->container); } while (!done); } } /* *---------------------------------------------------------------------- * * MaintainContentProc -- * * This procedure is invoked by the Tk event dispatcher in response to * StructureNotify events on a window being managed by * Tk_MaintainGeometry. * * Results: * None. * * Side effects: * If the event is a DestroyNotify event then the Maintain state and * event handlers for this window are deleted. * *---------------------------------------------------------------------- */ static void MaintainContentProc( ClientData clientData, /* Pointer to MaintainContent structure for * container-window pair. */ XEvent *eventPtr) /* Describes what just happened. */ { MaintainContent *contentPtr = (MaintainContent *)clientData; if (eventPtr->type == DestroyNotify) { Tk_UnmaintainGeometry(contentPtr->content, contentPtr->container); } } /* *---------------------------------------------------------------------- * * MaintainCheckProc -- * * This procedure is invoked by the Tk event dispatcher as an idle * handler, when a container or one of its ancestors has been reconfigured, * mapped, or unmapped. Its job is to scan all of the windows for the * container and reposition them, map them, or unmap them as needed to * maintain their geometry relative to the container. * * Results: * None. * * Side effects: * Windows can get repositioned, mapped, or unmapped. * *---------------------------------------------------------------------- */ static void MaintainCheckProc( ClientData clientData) /* Pointer to MaintainContainer structure for the * container window. */ { MaintainContainer *containerPtr = (MaintainContainer *)clientData; MaintainContent *contentPtr; Tk_Window ancestor, parent; int x, y, map; containerPtr->checkScheduled = 0; for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; contentPtr = contentPtr->nextPtr) { parent = Tk_Parent(contentPtr->content); x = contentPtr->x; y = contentPtr->y; map = 1; for (ancestor = contentPtr->container; ; ancestor = Tk_Parent(ancestor)) { if (!Tk_IsMapped(ancestor) && (ancestor != parent)) { map = 0; } if (ancestor == parent) { if ((x != Tk_X(contentPtr->content)) || (y != Tk_Y(contentPtr->content))) { Tk_MoveWindow(contentPtr->content, x, y); } if (map) { Tk_MapWindow(contentPtr->content); } else { Tk_UnmapWindow(contentPtr->content); } break; } x += Tk_X(ancestor) + Tk_Changes(ancestor)->border_width; y += Tk_Y(ancestor) + Tk_Changes(ancestor)->border_width; } } |
︙ | ︙ |
Changes to generic/tkImage.c.
︙ | ︙ | |||
22 23 24 25 26 27 28 | typedef struct Image { Tk_Window tkwin; /* Window passed to Tk_GetImage (needed to * "re-get" the image later if the manager * changes). */ Display *display; /* Display for tkwin. Needed because when the * image is eventually freed tkwin may not * exist anymore. */ | | | | | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | typedef struct Image { Tk_Window tkwin; /* Window passed to Tk_GetImage (needed to * "re-get" the image later if the manager * changes). */ Display *display; /* Display for tkwin. Needed because when the * image is eventually freed tkwin may not * exist anymore. */ struct ImageModel *modelPtr; /* Model for this image (identifiers image * manager, for example). */ ClientData instanceData; /* One word argument to pass to image manager * when dealing with this image instance. */ Tk_ImageChangedProc *changeProc; /* Code in widget to call when image changes * in a way that affects redisplay. */ ClientData widgetClientData;/* Argument to pass to changeProc. */ struct Image *nextPtr; /* Next in list of all image instances * associated with the same name. */ } Image; /* * For each image model there is one of the following structures, which * represents a name in the image table and all of the images instantiated * from it. Entries in mainPtr->imageTable point to these structures. */ typedef struct ImageModel { Tk_ImageType *typePtr; /* Information about image type. NULL means * that no image manager owns this image: the * image was deleted. */ ClientData modelData; /* One-word argument to pass to image mgr when * dealing with the model, as opposed to * instances. */ int width, height; /* Last known dimensions for image. */ Tcl_HashTable *tablePtr; /* Pointer to hash table containing image (the * imageTable field in some TkMainInfo * structure). */ Tcl_HashEntry *hPtr; /* Hash entry in mainPtr->imageTable for this * structure (used to delete the hash |
︙ | ︙ | |||
78 79 80 81 82 83 84 | static Tcl_ThreadDataKey dataKey; /* * Prototypes for local functions: */ static void ImageTypeThreadExitProc(ClientData clientData); | | | | | | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | static Tcl_ThreadDataKey dataKey; /* * Prototypes for local functions: */ static void ImageTypeThreadExitProc(ClientData clientData); static void DeleteImage(ImageModel *modelPtr); static void EventuallyDeleteImage(ImageModel *modelPtr, int forgetImageHashNow); /* *---------------------------------------------------------------------- * * ImageTypeThreadExitProc -- * * Clean up the registered list of image types. * * Results: * None. * * Side effects: * The thread's linked lists of photo image formats is deleted. * *---------------------------------------------------------------------- */ static void ImageTypeThreadExitProc( TCL_UNUSED(void *)) { Tk_ImageType *freePtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); while (tsdPtr->oldImageTypeList != NULL) { freePtr = tsdPtr->oldImageTypeList; tsdPtr->oldImageTypeList = tsdPtr->oldImageTypeList->nextPtr; ckfree(freePtr); } |
︙ | ︙ | |||
145 146 147 148 149 150 151 | Tk_CreateOldImageType( const Tk_ImageType *typePtr) /* Structure describing the type. All of the * fields except "nextPtr" must be filled in * by caller. */ { Tk_ImageType *copyPtr; | | | | | | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | Tk_CreateOldImageType( const Tk_ImageType *typePtr) /* Structure describing the type. All of the * fields except "nextPtr" must be filled in * by caller. */ { Tk_ImageType *copyPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!tsdPtr->initialized) { tsdPtr->initialized = 1; Tcl_CreateThreadExitHandler(ImageTypeThreadExitProc, NULL); } copyPtr = (Tk_ImageType *)ckalloc(sizeof(Tk_ImageType)); *copyPtr = *typePtr; copyPtr->nextPtr = tsdPtr->oldImageTypeList; tsdPtr->oldImageTypeList = copyPtr; } void Tk_CreateImageType( const Tk_ImageType *typePtr) /* Structure describing the type. All of the * fields except "nextPtr" must be filled in * by caller. */ { Tk_ImageType *copyPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!tsdPtr->initialized) { tsdPtr->initialized = 1; Tcl_CreateThreadExitHandler(ImageTypeThreadExitProc, NULL); } copyPtr = (Tk_ImageType *)ckalloc(sizeof(Tk_ImageType)); *copyPtr = *typePtr; copyPtr->nextPtr = tsdPtr->imageTypeList; tsdPtr->imageTypeList = copyPtr; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
211 212 213 214 215 216 217 | "create", "delete", "height", "inuse", "names", "type", "types", "width", NULL }; enum options { IMAGE_CREATE, IMAGE_DELETE, IMAGE_HEIGHT, IMAGE_INUSE, IMAGE_NAMES, IMAGE_TYPE, IMAGE_TYPES, IMAGE_WIDTH }; | | | | | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | "create", "delete", "height", "inuse", "names", "type", "types", "width", NULL }; enum options { IMAGE_CREATE, IMAGE_DELETE, IMAGE_HEIGHT, IMAGE_INUSE, IMAGE_NAMES, IMAGE_TYPE, IMAGE_TYPES, IMAGE_WIDTH }; TkWindow *winPtr = (TkWindow *)clientData; int i, isNew, firstOption, index; Tk_ImageType *typePtr; ImageModel *modelPtr; Image *imagePtr; Tcl_HashEntry *hPtr; Tcl_HashSearch search; char idString[16 + TCL_INTEGER_SPACE]; TkDisplay *dispPtr = winPtr->dispPtr; const char *arg, *name; Tcl_Obj *resultObj; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?args?"); return TCL_ERROR; } |
︙ | ︙ | |||
293 294 295 296 297 298 299 | TkWindow *topWin; name = arg; firstOption = 4; /* * Need to check if the _command_ that we are about to create is | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | TkWindow *topWin; name = arg; firstOption = 4; /* * Need to check if the _command_ that we are about to create is * the name of the current model widget command (normally "." but * could have been renamed) and fail in that case before a really * nasty and hard to stop crash happens. */ topWin = (TkWindow *) TkToplevelWindowForCommand(interp, name); if (topWin != NULL && winPtr->mainPtr->winPtr == topWin) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "images may not be named the same as the main window", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "SMASH_MAIN", NULL); return TCL_ERROR; } } /* * Create the data structure for the new image. */ hPtr = Tcl_CreateHashEntry(&winPtr->mainPtr->imageTable, name, &isNew); if (isNew) { modelPtr = (ImageModel *)ckalloc(sizeof(ImageModel)); modelPtr->typePtr = NULL; modelPtr->modelData = NULL; modelPtr->width = modelPtr->height = 1; modelPtr->tablePtr = &winPtr->mainPtr->imageTable; modelPtr->hPtr = hPtr; modelPtr->instancePtr = NULL; modelPtr->deleted = 0; modelPtr->winPtr = winPtr->mainPtr->winPtr; Tcl_Preserve(modelPtr->winPtr); Tcl_SetHashValue(hPtr, modelPtr); } else { /* * An image already exists by this name. Disconnect the instances * from the model. */ modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr); if (modelPtr->typePtr != NULL) { for (imagePtr = modelPtr->instancePtr; imagePtr != NULL; imagePtr = imagePtr->nextPtr) { modelPtr->typePtr->freeProc(imagePtr->instanceData, imagePtr->display); imagePtr->changeProc(imagePtr->widgetClientData, 0, 0, modelPtr->width, modelPtr->height, modelPtr->width, modelPtr->height); } modelPtr->typePtr->deleteProc(modelPtr->modelData); modelPtr->typePtr = NULL; } modelPtr->deleted = 0; } /* * Call the image type manager so that it can perform its own * initialization, then re-"get" for any existing instances of the * image. */ objv += firstOption; objc -= firstOption; args = (Tcl_Obj **) objv; if (oldimage) { int i; args = (Tcl_Obj **)ckalloc((objc+1) * sizeof(Tcl_Obj *)); for (i = 0; i < objc; i++) { args[i] = (Tcl_Obj *) Tcl_GetString(objv[i]); } args[objc] = NULL; } Tcl_Preserve(modelPtr); if (typePtr->createProc(interp, name, objc, args, typePtr, (Tk_ImageModel)modelPtr, &modelPtr->modelData) != TCL_OK){ EventuallyDeleteImage(modelPtr, 0); Tcl_Release(modelPtr); if (oldimage) { ckfree(args); } return TCL_ERROR; } Tcl_Release(modelPtr); if (oldimage) { ckfree(args); } modelPtr->typePtr = typePtr; for (imagePtr = modelPtr->instancePtr; imagePtr != NULL; imagePtr = imagePtr->nextPtr) { imagePtr->instanceData = typePtr->getProc(imagePtr->tkwin, modelPtr->modelData); } Tcl_SetObjResult(interp, Tcl_NewStringObj( (const char *)Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), -1)); break; } case IMAGE_DELETE: for (i = 2; i < objc; i++) { arg = Tcl_GetString(objv[i]); hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, arg); if (hPtr == NULL) { goto alreadyDeleted; } modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr); if (modelPtr->deleted) { goto alreadyDeleted; } DeleteImage(modelPtr); } break; case IMAGE_NAMES: if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, NULL); return TCL_ERROR; } hPtr = Tcl_FirstHashEntry(&winPtr->mainPtr->imageTable, &search); resultObj = Tcl_NewObj(); for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr); if (modelPtr->deleted) { continue; } Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( (const char *)Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), -1)); } Tcl_SetObjResult(interp, resultObj); break; case IMAGE_TYPES: if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, NULL); return TCL_ERROR; |
︙ | ︙ | |||
445 446 447 448 449 450 451 | case IMAGE_HEIGHT: case IMAGE_INUSE: case IMAGE_TYPE: case IMAGE_WIDTH: /* * These operations all parse virtually identically. First check to | | | | | | | | | | 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | case IMAGE_HEIGHT: case IMAGE_INUSE: case IMAGE_TYPE: case IMAGE_WIDTH: /* * These operations all parse virtually identically. First check to * see if three args are given. Then get a non-deleted model from the * third arg. */ if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "name"); return TCL_ERROR; } arg = Tcl_GetString(objv[2]); hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, arg); if (hPtr == NULL) { goto alreadyDeleted; } modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr); if (modelPtr->deleted) { goto alreadyDeleted; } /* * Now we read off the specific piece of data we were asked for. */ switch ((enum options) index) { case IMAGE_HEIGHT: Tcl_SetObjResult(interp, Tcl_NewIntObj(modelPtr->height)); break; case IMAGE_INUSE: Tcl_SetObjResult(interp, Tcl_NewBooleanObj( modelPtr->typePtr && modelPtr->instancePtr)); break; case IMAGE_TYPE: if (modelPtr->typePtr != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj(modelPtr->typePtr->name, -1)); } break; case IMAGE_WIDTH: Tcl_SetObjResult(interp, Tcl_NewIntObj(modelPtr->width)); break; default: Tcl_Panic("can't happen"); } break; } return TCL_OK; |
︙ | ︙ | |||
530 531 532 533 534 535 536 | * to redraw. If either dimension is zero then * the image doesn't need to be redrawn * (perhaps all that happened is that its size * changed). */ int imageWidth, int imageHeight) /* New dimensions of image. */ { | | | | | | | | | | 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 | * to redraw. If either dimension is zero then * the image doesn't need to be redrawn * (perhaps all that happened is that its size * changed). */ int imageWidth, int imageHeight) /* New dimensions of image. */ { ImageModel *modelPtr = (ImageModel *) imageModel; Image *imagePtr; modelPtr->width = imageWidth; modelPtr->height = imageHeight; for (imagePtr = modelPtr->instancePtr; imagePtr != NULL; imagePtr = imagePtr->nextPtr) { imagePtr->changeProc(imagePtr->widgetClientData, x, y, width, height, imageWidth, imageHeight); } } /* *---------------------------------------------------------------------- * * Tk_NameOfImage -- * * Given a token for an image model, this function returns the name of * the image. * * Results: * The return value is the string name for imageModel. * * Side effects: * None. * *---------------------------------------------------------------------- */ const char * Tk_NameOfImage( Tk_ImageModel imageModel) /* Token for image. */ { ImageModel *modelPtr = (ImageModel *) imageModel; if (modelPtr->hPtr == NULL) { return NULL; } return (const char *)Tcl_GetHashKey(modelPtr->tablePtr, modelPtr->hPtr); } /* *---------------------------------------------------------------------- * * Tk_GetImage -- * |
︙ | ︙ | |||
606 607 608 609 610 611 612 | const char *name, /* Name of desired image. */ Tk_ImageChangedProc *changeProc, /* Function to invoke when redisplay is needed * because image's pixels or size changed. */ ClientData clientData) /* One-word argument to pass to damageProc. */ { Tcl_HashEntry *hPtr; | | | | | | | | | | | 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 | const char *name, /* Name of desired image. */ Tk_ImageChangedProc *changeProc, /* Function to invoke when redisplay is needed * because image's pixels or size changed. */ ClientData clientData) /* One-word argument to pass to damageProc. */ { Tcl_HashEntry *hPtr; ImageModel *modelPtr; Image *imagePtr; hPtr = Tcl_FindHashEntry(&((TkWindow *) tkwin)->mainPtr->imageTable, name); if (hPtr == NULL) { goto noSuchImage; } modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr); if (modelPtr->typePtr == NULL) { goto noSuchImage; } if (modelPtr->deleted) { goto noSuchImage; } imagePtr = (Image *)ckalloc(sizeof(Image)); imagePtr->tkwin = tkwin; imagePtr->display = Tk_Display(tkwin); imagePtr->modelPtr = modelPtr; imagePtr->instanceData = modelPtr->typePtr->getProc(tkwin, modelPtr->modelData); imagePtr->changeProc = changeProc; imagePtr->widgetClientData = clientData; imagePtr->nextPtr = modelPtr->instancePtr; modelPtr->instancePtr = imagePtr; return (Tk_Image) imagePtr; noSuchImage: if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "image \"%s\" doesn't exist", name)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "IMAGE", name, NULL); |
︙ | ︙ | |||
665 666 667 668 669 670 671 | void Tk_FreeImage( Tk_Image image) /* Token for image that is no longer needed by * a widget. */ { Image *imagePtr = (Image *) image; | | | | | | | | | | | | | | 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | void Tk_FreeImage( Tk_Image image) /* Token for image that is no longer needed by * a widget. */ { Image *imagePtr = (Image *) image; ImageModel *modelPtr = imagePtr->modelPtr; Image *prevPtr; /* * Clean up the particular instance. */ if (modelPtr->typePtr != NULL) { modelPtr->typePtr->freeProc(imagePtr->instanceData, imagePtr->display); } prevPtr = modelPtr->instancePtr; if (prevPtr == imagePtr) { modelPtr->instancePtr = imagePtr->nextPtr; } else { while (prevPtr->nextPtr != imagePtr) { prevPtr = prevPtr->nextPtr; } prevPtr->nextPtr = imagePtr->nextPtr; } ckfree(imagePtr); /* * If there are no more instances left for the model, and if the model * image has been deleted, then delete the model too. */ if ((modelPtr->typePtr == NULL) && (modelPtr->instancePtr == NULL)) { if (modelPtr->hPtr != NULL) { Tcl_DeleteHashEntry(modelPtr->hPtr); } Tcl_Release(modelPtr->winPtr); ckfree(modelPtr); } } /* *---------------------------------------------------------------------- * * Tk_PostscriptImage -- |
︙ | ︙ | |||
737 738 739 740 741 742 743 | Image *imagePtr = (Image *) image; int result; XImage *ximage; Pixmap pmap; GC newGC; XGCValues gcValues; | | | | | | | 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 | Image *imagePtr = (Image *) image; int result; XImage *ximage; Pixmap pmap; GC newGC; XGCValues gcValues; if (imagePtr->modelPtr->typePtr == NULL) { /* * No model for image, so nothing to display on postscript. */ return TCL_OK; } /* * Check if an image specific postscript-generation function exists; * otherwise go on with generic code. */ if (imagePtr->modelPtr->typePtr->postscriptProc != NULL) { return imagePtr->modelPtr->typePtr->postscriptProc( imagePtr->modelPtr->modelData, interp, tkwin, psinfo, x, y, width, height, prepass); } if (prepass) { return TCL_OK; } |
︙ | ︙ | |||
833 834 835 836 837 838 839 | * the Tk_GetImage call for the image. */ int drawableX, int drawableY) /* Coordinates in drawable that correspond to * imageX and imageY. */ { Image *imagePtr = (Image *) image; | | | | | | | | | 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | * the Tk_GetImage call for the image. */ int drawableX, int drawableY) /* Coordinates in drawable that correspond to * imageX and imageY. */ { Image *imagePtr = (Image *) image; if (imagePtr->modelPtr->typePtr == NULL) { /* * No model for image, so nothing to display. */ return; } /* * Clip the redraw area to the area of the image. */ if (imageX < 0) { width += imageX; drawableX -= imageX; imageX = 0; } if (imageY < 0) { height += imageY; drawableY -= imageY; imageY = 0; } if ((imageX + width) > imagePtr->modelPtr->width) { width = imagePtr->modelPtr->width - imageX; } if ((imageY + height) > imagePtr->modelPtr->height) { height = imagePtr->modelPtr->height - imageY; } imagePtr->modelPtr->typePtr->displayProc(imagePtr->instanceData, imagePtr->display, drawable, imageX, imageY, width, height, drawableX, drawableY); } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
891 892 893 894 895 896 897 | Tk_SizeOfImage( Tk_Image image, /* Token for image whose size is wanted. */ int *widthPtr, /* Return width of image here. */ int *heightPtr) /* Return height of image here. */ { Image *imagePtr = (Image *) image; | | | | 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 | Tk_SizeOfImage( Tk_Image image, /* Token for image whose size is wanted. */ int *widthPtr, /* Return width of image here. */ int *heightPtr) /* Return height of image here. */ { Image *imagePtr = (Image *) image; *widthPtr = imagePtr->modelPtr->width; *heightPtr = imagePtr->modelPtr->height; } /* *---------------------------------------------------------------------- * * Tk_DeleteImage -- * |
︙ | ︙ | |||
929 930 931 932 933 934 935 | if (winPtr == NULL) { return; } hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, name); if (hPtr == NULL) { return; } | | | | | | | | | | | | | | | | | 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 | if (winPtr == NULL) { return; } hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, name); if (hPtr == NULL) { return; } DeleteImage((ImageModel *)Tcl_GetHashValue(hPtr)); } /* *---------------------------------------------------------------------- * * DeleteImage -- * * This function is responsible for deleting an image. * * Results: * None. * * Side effects: * The connection is dropped between instances of this image and an image * model. Image instances will redisplay themselves as empty areas, but * existing instances will not be deleted. * *---------------------------------------------------------------------- */ static void DeleteImage( ImageModel *modelPtr) /* Pointer to main data structure for image. */ { Image *imagePtr; Tk_ImageType *typePtr; typePtr = modelPtr->typePtr; modelPtr->typePtr = NULL; if (typePtr != NULL) { for (imagePtr = modelPtr->instancePtr; imagePtr != NULL; imagePtr = imagePtr->nextPtr) { typePtr->freeProc(imagePtr->instanceData, imagePtr->display); imagePtr->changeProc(imagePtr->widgetClientData, 0, 0, modelPtr->width, modelPtr->height, modelPtr->width, modelPtr->height); } typePtr->deleteProc(modelPtr->modelData); } if (modelPtr->instancePtr == NULL) { if (modelPtr->hPtr != NULL) { Tcl_DeleteHashEntry(modelPtr->hPtr); } Tcl_Release(modelPtr->winPtr); ckfree(modelPtr); } else { modelPtr->deleted = 1; } } /* *---------------------------------------------------------------------- * * EventuallyDeleteImage -- |
︙ | ︙ | |||
1000 1001 1002 1003 1004 1005 1006 | * ill effects. * *---------------------------------------------------------------------- */ static void EventuallyDeleteImage( | | | | | | | 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 | * ill effects. * *---------------------------------------------------------------------- */ static void EventuallyDeleteImage( ImageModel *modelPtr, /* Pointer to main data structure for image. */ int forgetImageHashNow) /* Flag to say whether the hash table is about * to vanish. */ { if (forgetImageHashNow) { modelPtr->hPtr = NULL; } if (!modelPtr->deleted) { modelPtr->deleted = 1; Tcl_EventuallyFree(modelPtr, (Tcl_FreeProc *) DeleteImage); } } /* *---------------------------------------------------------------------- * * TkDeleteAllImages -- |
︙ | ︙ | |||
1041 1042 1043 1044 1045 1046 1047 | * going away. */ { Tcl_HashSearch search; Tcl_HashEntry *hPtr; for (hPtr = Tcl_FirstHashEntry(&mainPtr->imageTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { | | | | 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 | * going away. */ { Tcl_HashSearch search; Tcl_HashEntry *hPtr; for (hPtr = Tcl_FirstHashEntry(&mainPtr->imageTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { EventuallyDeleteImage((ImageModel *)Tcl_GetHashValue(hPtr), 1); } Tcl_DeleteHashTable(&mainPtr->imageTable); } /* *---------------------------------------------------------------------- * * Tk_GetImageModelData -- * * Given the name of an image, this function returns the type of the * image and the clientData associated with its model. * * Results: * If there is no image by the given name, then NULL is returned and a * NULL value is stored at *typePtrPtr. Otherwise the return value is the * clientData returned by the createProc when the image was created and a * pointer to the type structure for the image is stored at *typePtrPtr. * |
︙ | ︙ | |||
1077 1078 1079 1080 1081 1082 1083 | const char *name, /* Name of image. */ const Tk_ImageType **typePtrPtr) /* Points to location to fill in with pointer * to type information for image. */ { TkWindow *winPtr = (TkWindow *) Tk_MainWindow(interp); Tcl_HashEntry *hPtr; | | | | | | | 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 | const char *name, /* Name of image. */ const Tk_ImageType **typePtrPtr) /* Points to location to fill in with pointer * to type information for image. */ { TkWindow *winPtr = (TkWindow *) Tk_MainWindow(interp); Tcl_HashEntry *hPtr; ImageModel *modelPtr; hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, name); if (hPtr == NULL) { *typePtrPtr = NULL; return NULL; } modelPtr = (ImageModel *)Tcl_GetHashValue(hPtr); if (modelPtr->deleted) { *typePtrPtr = NULL; return NULL; } *typePtrPtr = modelPtr->typePtr; return modelPtr->modelData; } /* *---------------------------------------------------------------------- * * Tk_SetTSOrigin -- * |
︙ | ︙ | |||
1114 1115 1116 1117 1118 1119 1120 | * Side Effects: * The GCTileStipOrigin is reset in the GC. This will cause the tile * origin to change when the GC is used for drawing. * *---------------------------------------------------------------------- */ | < | 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 | * Side Effects: * The GCTileStipOrigin is reset in the GC. This will cause the tile * origin to change when the GC is used for drawing. * *---------------------------------------------------------------------- */ void Tk_SetTSOrigin( Tk_Window tkwin, GC gc, int x, int y) { while (!Tk_TopWinHierarchy(tkwin)) { |
︙ | ︙ |
Changes to generic/tkImgBmap.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkInt.h" /* | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkInt.h" /* * The following data structure represents the model for a bitmap * image: */ typedef struct BitmapModel { Tk_ImageModel tkModel; /* Tk's token for image model. NULL means the * image is being deleted. */ Tcl_Interp *interp; /* Interpreter for application that is using |
︙ | ︙ | |||
36 37 38 39 40 41 42 | Tk_Uid bgUid; /* Value of -background option (malloc'ed). */ char *fileString; /* Value of -file option (malloc'ed). */ char *dataString; /* Value of -data option (malloc'ed). */ char *maskFileString; /* Value of -maskfile option (malloc'ed). */ char *maskDataString; /* Value of -maskdata option (malloc'ed). */ struct BitmapInstance *instancePtr; /* First in list of all instances associated | | | | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | Tk_Uid bgUid; /* Value of -background option (malloc'ed). */ char *fileString; /* Value of -file option (malloc'ed). */ char *dataString; /* Value of -data option (malloc'ed). */ char *maskFileString; /* Value of -maskfile option (malloc'ed). */ char *maskDataString; /* Value of -maskdata option (malloc'ed). */ struct BitmapInstance *instancePtr; /* First in list of all instances associated * with this model. */ } BitmapModel; /* * The following data structure represents all of the instances of an image * that lie within a particular window: */ typedef struct BitmapInstance { int refCount; /* Number of instances that share this data * structure. */ BitmapModel *modelPtr; /* Pointer to model for image. */ Tk_Window tkwin; /* Window in which the instances will be * displayed. */ XColor *fg; /* Foreground color for displaying image. */ XColor *bg; /* Background color for displaying image. */ Pixmap bitmap; /* The bitmap to display. */ Pixmap mask; /* Mask: only display bitmap pixels where * there are 1's here. */ |
︙ | ︙ | |||
318 319 320 321 322 323 324 | /* *---------------------------------------------------------------------- * * ImgBmapConfigureInstance -- * * This procedure is called to create displaying information for a bitmap | | | | 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | /* *---------------------------------------------------------------------- * * ImgBmapConfigureInstance -- * * This procedure is called to create displaying information for a bitmap * image instance based on the configuration information in the model. * It is invoked both when new instances are created and when the model * is reconfigured. * * Results: * None. * * Side effects: * Generates errors via Tcl_BackgroundException if there are problems in |
︙ | ︙ | |||
747 748 749 750 751 752 753 | * See the user documentation. * *-------------------------------------------------------------- */ static int ImgBmapCmd( | | | 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 | * See the user documentation. * *-------------------------------------------------------------- */ static int ImgBmapCmd( ClientData clientData, /* Information about the image model. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { static const char *const bmapOptions[] = {"cget", "configure", NULL}; BitmapModel *modelPtr = clientData; int index; |
︙ | ︙ | |||
812 813 814 815 816 817 818 | *---------------------------------------------------------------------- */ static ClientData ImgBmapGet( Tk_Window tkwin, /* Window in which the instance will be * used. */ | | | | 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 | *---------------------------------------------------------------------- */ static ClientData ImgBmapGet( Tk_Window tkwin, /* Window in which the instance will be * used. */ ClientData modelData) /* Pointer to our model structure for the * image. */ { BitmapModel *modelPtr = modelData; BitmapInstance *instancePtr; /* * See if there is already an instance for this window. If so then just * re-use it. */ |
︙ | ︙ | |||
989 990 991 992 993 994 995 | } /* *---------------------------------------------------------------------- * * ImgBmapDelete -- * | | | | | 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 | } /* *---------------------------------------------------------------------- * * ImgBmapDelete -- * * This procedure is called by the image code to delete the model * structure for an image. * * Results: * None. * * Side effects: * Resources associated with the image get freed. * *---------------------------------------------------------------------- */ static void ImgBmapDelete( ClientData modelData) /* Pointer to BitmapModel structure for * image. Must not have any more instances. */ { BitmapModel *modelPtr = modelData; if (modelPtr->instancePtr != NULL) { Tcl_Panic("tried to delete bitmap image when instances still exist"); } modelPtr->tkModel = NULL; if (modelPtr->imageCmd != NULL) { Tcl_DeleteCommandFromToken(modelPtr->interp, modelPtr->imageCmd); |
︙ | ︙ |
Changes to generic/tkSelect.c.
︙ | ︙ | |||
121 122 123 124 125 126 127 | ClientData clientData, /* Value to pass to proc. */ Atom format) /* Format in which the selection information * should be returned to the requestor. * XA_STRING is best by far, but anything * listed in the ICCCM will be tolerated * (blech). */ { | | | | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | ClientData clientData, /* Value to pass to proc. */ Atom format) /* Format in which the selection information * should be returned to the requestor. * XA_STRING is best by far, but anything * listed in the ICCCM will be tolerated * (blech). */ { TkSelHandler *selPtr; TkWindow *winPtr = (TkWindow *) tkwin; if (winPtr->dispPtr->multipleAtom == None) { TkSelInit(tkwin); } /* * See if there's already a handler for this target and selection on this * window. If so, re-use it. If not, create a new one. */ for (selPtr = winPtr->selHandlerList; ; selPtr = selPtr->nextPtr) { if (selPtr == NULL) { selPtr = (TkSelHandler *)ckalloc(sizeof(TkSelHandler)); selPtr->nextPtr = winPtr->selHandlerList; winPtr->selHandlerList = selPtr; break; } if ((selPtr->selection == selection) && (selPtr->target == target)) { /* * Special case: when replacing handler created by "selection |
︙ | ︙ | |||
173 174 175 176 177 178 179 | * If the user asked for a STRING handler and we understand * UTF8_STRING, we implicitly create a UTF8_STRING handler for them. */ target = winPtr->dispPtr->utf8Atom; for (selPtr = winPtr->selHandlerList; ; selPtr = selPtr->nextPtr) { if (selPtr == NULL) { | | | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | * If the user asked for a STRING handler and we understand * UTF8_STRING, we implicitly create a UTF8_STRING handler for them. */ target = winPtr->dispPtr->utf8Atom; for (selPtr = winPtr->selHandlerList; ; selPtr = selPtr->nextPtr) { if (selPtr == NULL) { selPtr = (TkSelHandler *)ckalloc(sizeof(TkSelHandler)); selPtr->nextPtr = winPtr->selHandlerList; winPtr->selHandlerList = selPtr; selPtr->selection = selection; selPtr->target = target; selPtr->format = target; /* We want UTF8_STRING format */ selPtr->proc = proc; if (selPtr->proc == HandleTclCommand) { |
︙ | ︙ | |||
235 236 237 238 239 240 241 | Tk_Window tkwin, /* Token for window. */ Atom selection, /* The selection whose handler is to be * removed. */ Atom target) /* The target whose selection handler is to be * removed. */ { TkWindow *winPtr = (TkWindow *) tkwin; | | | | | 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | Tk_Window tkwin, /* Token for window. */ Atom selection, /* The selection whose handler is to be * removed. */ Atom target) /* The target whose selection handler is to be * removed. */ { TkWindow *winPtr = (TkWindow *) tkwin; TkSelHandler *selPtr, *prevPtr; TkSelInProgress *ipPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * Find the selection handler to be deleted, or return if it doesn't * exist. */ |
︙ | ︙ | |||
349 350 351 352 353 354 355 | Tk_Window tkwin, /* Window to become new selection owner. */ Atom selection, /* Selection that window should own. */ Tk_LostSelProc *proc, /* Function to call when selection is taken * away from tkwin. */ ClientData clientData) /* Arbitrary one-word argument to pass to * proc. */ { | | | 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | Tk_Window tkwin, /* Window to become new selection owner. */ Atom selection, /* Selection that window should own. */ Tk_LostSelProc *proc, /* Function to call when selection is taken * away from tkwin. */ ClientData clientData) /* Arbitrary one-word argument to pass to * proc. */ { TkWindow *winPtr = (TkWindow *) tkwin; TkDisplay *dispPtr = winPtr->dispPtr; TkSelectionInfo *infoPtr; Tk_LostSelProc *clearProc = NULL; ClientData clearData = NULL;/* Initialization needed only to prevent * compiler warning. */ if (dispPtr->multipleAtom == None) { |
︙ | ︙ | |||
378 379 380 381 382 383 384 | for (infoPtr = dispPtr->selectionInfoPtr; infoPtr != NULL; infoPtr = infoPtr->nextPtr) { if (infoPtr->selection == selection) { break; } } if (infoPtr == NULL) { | | | 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | for (infoPtr = dispPtr->selectionInfoPtr; infoPtr != NULL; infoPtr = infoPtr->nextPtr) { if (infoPtr->selection == selection) { break; } } if (infoPtr == NULL) { infoPtr = (TkSelectionInfo *)ckalloc(sizeof(TkSelectionInfo)); infoPtr->selection = selection; infoPtr->nextPtr = dispPtr->selectionInfoPtr; dispPtr->selectionInfoPtr = infoPtr; } else if (infoPtr->clearProc != NULL) { if (infoPtr->owner != tkwin) { clearProc = infoPtr->clearProc; clearData = infoPtr->clearData; |
︙ | ︙ | |||
456 457 458 459 460 461 462 | */ void Tk_ClearSelection( Tk_Window tkwin, /* Window that selects a display. */ Atom selection) /* Selection to be cancelled. */ { | | | 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 | */ void Tk_ClearSelection( Tk_Window tkwin, /* Window that selects a display. */ Atom selection) /* Selection to be cancelled. */ { TkWindow *winPtr = (TkWindow *) tkwin; TkDisplay *dispPtr = winPtr->dispPtr; TkSelectionInfo *infoPtr; TkSelectionInfo *prevPtr; TkSelectionInfo *nextPtr; Tk_LostSelProc *clearProc = NULL; ClientData clearData = NULL;/* Initialization needed only to prevent * compiler warning. */ |
︙ | ︙ | |||
552 553 554 555 556 557 558 | Tk_GetSelProc *proc, /* Function to call to process the selection, * once it has been retrieved. */ ClientData clientData) /* Arbitrary value to pass to proc. */ { TkWindow *winPtr = (TkWindow *) tkwin; TkDisplay *dispPtr = winPtr->dispPtr; TkSelectionInfo *infoPtr; | | | | 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | Tk_GetSelProc *proc, /* Function to call to process the selection, * once it has been retrieved. */ ClientData clientData) /* Arbitrary value to pass to proc. */ { TkWindow *winPtr = (TkWindow *) tkwin; TkDisplay *dispPtr = winPtr->dispPtr; TkSelectionInfo *infoPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (dispPtr->multipleAtom == None) { TkSelInit(tkwin); } /* * If the selection is owned by a window managed by this process, then * call the retrieval function directly, rather than going through the X * server (it's dangerous to go through the X server in this case because * it could result in deadlock if an INCR-style selection results). */ for (infoPtr = dispPtr->selectionInfoPtr; infoPtr != NULL; infoPtr = infoPtr->nextPtr) { if (infoPtr->selection == selection) { break; } } if (infoPtr != NULL) { TkSelHandler *selPtr; int offset, result, count; char buffer[TK_SEL_BYTES_AT_ONCE+1]; TkSelInProgress ip; for (selPtr = ((TkWindow *) infoPtr->owner)->selHandlerList; selPtr != NULL; selPtr = selPtr->nextPtr) { if (selPtr->target==target && selPtr->selection==selection) { |
︙ | ︙ | |||
666 667 668 669 670 671 672 | Tk_SelectionObjCmd( ClientData clientData, /* Main window associated with * interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { | | | 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 | Tk_SelectionObjCmd( ClientData clientData, /* Main window associated with * interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = (Tk_Window)clientData; const char *path = NULL; Atom selection; const char *selName = NULL; const char *string; int count, index; Tcl_Obj **objs; static const char *const optionStrings[] = { |
︙ | ︙ | |||
826 827 828 829 830 831 832 | return result; } case SELECTION_HANDLE: { Atom target, format; const char *targetName = NULL; const char *formatName = NULL; | | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | return result; } case SELECTION_HANDLE: { Atom target, format; const char *targetName = NULL; const char *formatName = NULL; CommandInfo *cmdInfoPtr; int cmdLength; static const char *const handleOptionStrings[] = { "-format", "-selection", "-type", NULL }; enum handleOptions { HANDLE_FORMAT, HANDLE_SELECTION, HANDLE_TYPE }; |
︙ | ︙ | |||
900 901 902 903 904 905 906 | } else { format = XA_STRING; } string = Tcl_GetStringFromObj(objs[1], &cmdLength); if (cmdLength == 0) { Tk_DeleteSelHandler(tkwin, selection, target); } else { | | | | 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 | } else { format = XA_STRING; } string = Tcl_GetStringFromObj(objs[1], &cmdLength); if (cmdLength == 0) { Tk_DeleteSelHandler(tkwin, selection, target); } else { cmdInfoPtr = (CommandInfo *)ckalloc(Tk_Offset(CommandInfo, command) + 1 + cmdLength); cmdInfoPtr->interp = interp; cmdInfoPtr->charOffset = 0; cmdInfoPtr->byteOffset = 0; cmdInfoPtr->buffer[0] = '\0'; cmdInfoPtr->cmdLength = cmdLength; memcpy(cmdInfoPtr->command, string, cmdLength + 1); Tk_CreateSelHandler(tkwin, selection, target, HandleTclCommand, cmdInfoPtr, format); } return TCL_OK; } case SELECTION_OWN: { LostCommand *lostPtr; Tcl_Obj *commandObj = NULL; static const char *const ownOptionStrings[] = { "-command", "-displayof", "-selection", NULL }; enum ownOptions { OWN_COMMAND, OWN_DISPLAYOF, OWN_SELECTION }; int ownIndex; |
︙ | ︙ | |||
1004 1005 1006 1007 1008 1009 1010 | if (count == 2) { commandObj = objs[1]; } if (commandObj == NULL) { Tk_OwnSelection(tkwin, selection, NULL, NULL); return TCL_OK; } | | | 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 | if (count == 2) { commandObj = objs[1]; } if (commandObj == NULL) { Tk_OwnSelection(tkwin, selection, NULL, NULL); return TCL_OK; } lostPtr = (LostCommand *)ckalloc(sizeof(LostCommand)); lostPtr->interp = interp; lostPtr->cmdObj = commandObj; Tcl_IncrRefCount(commandObj); Tk_OwnSelection(tkwin, selection, LostSelection, lostPtr); return TCL_OK; } } |
︙ | ︙ | |||
1036 1037 1038 1039 1040 1041 1042 | * *---------------------------------------------------------------------- */ TkSelInProgress * TkSelGetInProgress(void) { | | | 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 | * *---------------------------------------------------------------------- */ TkSelInProgress * TkSelGetInProgress(void) { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); return tsdPtr->pendingPtr; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
1063 1064 1065 1066 1067 1068 1069 | * *---------------------------------------------------------------------- */ void TkSelSetInProgress( TkSelInProgress *pendingPtr) { | | | 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 | * *---------------------------------------------------------------------- */ void TkSelSetInProgress( TkSelInProgress *pendingPtr) { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); tsdPtr->pendingPtr = pendingPtr; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
1088 1089 1090 1091 1092 1093 1094 | * Frees up memory associated with the selection. * *---------------------------------------------------------------------- */ void TkSelDeadWindow( | | | | | | 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 | * Frees up memory associated with the selection. * *---------------------------------------------------------------------- */ void TkSelDeadWindow( TkWindow *winPtr) /* Window that's being deleted. */ { TkSelHandler *selPtr; TkSelInProgress *ipPtr; TkSelectionInfo *infoPtr, *prevPtr, *nextPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * While deleting all the handlers, be careful to check whether * ConvertSelection or TkSelPropProc are about to process one of the * deleted handlers. */ |
︙ | ︙ | |||
1166 1167 1168 1169 1170 1171 1172 | */ void TkSelInit( Tk_Window tkwin) /* Window token (used to find display to * initialize). */ { | | | 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 | */ void TkSelInit( Tk_Window tkwin) /* Window token (used to find display to * initialize). */ { TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; /* * Fetch commonly-used atoms. */ dispPtr->multipleAtom = Tk_InternAtom(tkwin, "MULTIPLE"); dispPtr->incrAtom = Tk_InternAtom(tkwin, "INCR"); |
︙ | ︙ | |||
1217 1218 1219 1220 1221 1222 1223 | * *---------------------------------------------------------------------- */ void TkSelClearSelection( Tk_Window tkwin, /* Window for which event was targeted. */ | | | | 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 | * *---------------------------------------------------------------------- */ void TkSelClearSelection( Tk_Window tkwin, /* Window for which event was targeted. */ XEvent *eventPtr) /* X SelectionClear event. */ { TkWindow *winPtr = (TkWindow *) tkwin; TkDisplay *dispPtr = winPtr->dispPtr; TkSelectionInfo *infoPtr; TkSelectionInfo *prevPtr; /* * Invoke clear function for window that just lost the selection. This * code is a bit tricky, because any callbacks due to selection changes |
︙ | ︙ | |||
1281 1282 1283 1284 1285 1286 1287 | * Side effects: * Bytes get appended to the dynamic string pointed to by the clientData * argument. * *-------------------------------------------------------------- */ | < | | | 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 | * Side effects: * Bytes get appended to the dynamic string pointed to by the clientData * argument. * *-------------------------------------------------------------- */ static int SelGetProc( ClientData clientData, /* Dynamic string holding partially assembled * selection. */ TCL_UNUSED(Tcl_Interp *), /* Interpreter used for error reporting (not * used). */ const char *portion) /* New information to be appended. */ { Tcl_DStringAppend((Tcl_DString *)clientData, portion, -1); return TCL_OK; } /* *---------------------------------------------------------------------- * * HandleTclCommand -- |
︙ | ︙ | |||
1407 1408 1409 1410 1411 1412 1413 | while (p < string) { p += TkUtfToUniChar(p, &ch); numChars++; } cmdInfoPtr->charOffset += numChars; length = p - string; if (length > 0) { | | | 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 | while (p < string) { p += TkUtfToUniChar(p, &ch); numChars++; } cmdInfoPtr->charOffset += numChars; length = p - string; if (length > 0) { strncpy(cmdInfoPtr->buffer, string, length); } cmdInfoPtr->buffer[length] = '\0'; } cmdInfoPtr->byteOffset += count + extraBytes; } count += extraBytes; } else { |
︙ | ︙ | |||
1466 1467 1468 1469 1470 1471 1472 | TkSelectionInfo *infoPtr, /* Info about selection being retrieved. */ Atom target, /* Desired form of selection. */ char *buffer, /* Place to put selection characters. */ int maxBytes, /* Maximum # of bytes to store at buffer. */ Atom *typePtr) /* Store here the type of the selection, for * use in converting to proper X format. */ { | | | | 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 | TkSelectionInfo *infoPtr, /* Info about selection being retrieved. */ Atom target, /* Desired form of selection. */ char *buffer, /* Place to put selection characters. */ int maxBytes, /* Maximum # of bytes to store at buffer. */ Atom *typePtr) /* Store here the type of the selection, for * use in converting to proper X format. */ { TkWindow *winPtr = (TkWindow *) infoPtr->owner; TkDisplay *dispPtr = winPtr->dispPtr; if (target == dispPtr->timestampAtom) { if (maxBytes < 20) { return -1; } sprintf(buffer, "0x%x", (unsigned int) infoPtr->time); *typePtr = XA_INTEGER; return strlen(buffer); } if (target == dispPtr->targetsAtom) { TkSelHandler *selPtr; int length; Tcl_DString ds; if (maxBytes < 50) { return -1; } Tcl_DStringInit(&ds); |
︙ | ︙ | |||
1505 1506 1507 1508 1509 1510 1511 | } } length = Tcl_DStringLength(&ds); if (length >= maxBytes) { Tcl_DStringFree(&ds); return -1; } | | | 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 | } } length = Tcl_DStringLength(&ds); if (length >= maxBytes) { Tcl_DStringFree(&ds); return -1; } memcpy(buffer, Tcl_DStringValue(&ds), length + 1); Tcl_DStringFree(&ds); *typePtr = XA_ATOM; return length; } if (target == dispPtr->applicationAtom) { int length; |
︙ | ︙ | |||
1562 1563 1564 1565 1566 1567 1568 | *---------------------------------------------------------------------- */ static void LostSelection( ClientData clientData) /* Pointer to LostCommand structure. */ { | | | 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 | *---------------------------------------------------------------------- */ static void LostSelection( ClientData clientData) /* Pointer to LostCommand structure. */ { LostCommand *lostPtr = (LostCommand *)clientData; Tcl_Interp *interp = lostPtr->interp; Tcl_InterpState savedState; int code; Tcl_Preserve(interp); /* |
︙ | ︙ |
Changes to generic/tkStubInit.c.
︙ | ︙ | |||
55 56 57 58 59 60 61 | #define TkUnixSetMenubar_ TkUnixSetMenubar #define TkWmCleanup_ TkWmCleanup #define TkSendCleanup_ TkSendCleanup #define TkpTestsendCmd_ TkpTestsendCmd #define TkGenWMConfigureEvent_ TkGenWMConfigureEvent #define TkGenerateActivateEvents_ TkGenerateActivateEvents | | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #define TkUnixSetMenubar_ TkUnixSetMenubar #define TkWmCleanup_ TkWmCleanup #define TkSendCleanup_ TkSendCleanup #define TkpTestsendCmd_ TkpTestsendCmd #define TkGenWMConfigureEvent_ TkGenWMConfigureEvent #define TkGenerateActivateEvents_ TkGenerateActivateEvents #if !defined(MAC_OSX_TK) && defined(MAC_OSX_TCL) # undef TkpWillDrawWidget # undef TkpRedrawWidget static int doNothing(void) { /* dummy implementation, no need to do anything */ return 0; |
︙ | ︙ |
Changes to generic/tkText.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | * Copyright (c) 1994-1996 Sun Microsystems, Inc. * Copyright (c) 1999 by Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ | | | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | * Copyright (c) 1994-1996 Sun Microsystems, Inc. * Copyright (c) 1999 by Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkInt.h" #include "tkUndo.h" #include "default.h" #if defined(MAC_OSX_TK) #define Style TkStyle #define DInfo TkDInfo #endif /* |
︙ | ︙ | |||
457 458 459 460 461 462 463 | int Tk_TextObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { | | | 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 | int Tk_TextObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = (Tk_Window)clientData; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?"); return TCL_ERROR; } return CreateWidget(NULL, tkwin, interp, NULL, objc, objv); |
︙ | ︙ | |||
498 499 500 501 502 503 504 | Tk_Window tkwin, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ const TkText *parent, /* If non-NULL then take default start, end * from this parent. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { | | | | | 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | Tk_Window tkwin, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ const TkText *parent, /* If non-NULL then take default start, end * from this parent. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { TkText *textPtr; Tk_OptionTable optionTable; TkTextIndex startIndex; Tk_Window newWin; /* * Create the window. */ newWin = Tk_CreateWindowFromPath(interp, tkwin, Tcl_GetString(objv[1]), NULL); if (newWin == NULL) { return TCL_ERROR; } /* * Create the text widget and initialize everything to zero, then set the * necessary initial (non-NULL) values. It is important that the 'set' tag * and 'insert', 'current' mark pointers are all NULL to start. */ textPtr = (TkText *)ckalloc(sizeof(TkText)); memset(textPtr, 0, sizeof(TkText)); textPtr->tkwin = newWin; textPtr->display = Tk_Display(newWin); textPtr->interp = interp; textPtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(textPtr->tkwin), TextWidgetObjCmd, textPtr, TextCmdDeletedProc); if (sharedPtr == NULL) { sharedPtr = (TkSharedText *)ckalloc(sizeof(TkSharedText)); memset(sharedPtr, 0, sizeof(TkSharedText)); sharedPtr->refCount = 0; sharedPtr->peers = NULL; sharedPtr->tree = TkBTreeCreate(sharedPtr); Tcl_InitHashTable(&sharedPtr->tagTable, TCL_STRING_KEYS); |
︙ | ︙ | |||
628 629 630 631 632 633 634 | /* * Note: it is important that textPtr->selTagPtr is NULL before this * initial call. */ textPtr->selTagPtr = TkTextCreateTag(textPtr, "sel", NULL); | | | 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 | /* * Note: it is important that textPtr->selTagPtr is NULL before this * initial call. */ textPtr->selTagPtr = TkTextCreateTag(textPtr, "sel", NULL); textPtr->selTagPtr->reliefString = (char *) ckalloc(sizeof(DEF_TEXT_SELECT_RELIEF)); strcpy(textPtr->selTagPtr->reliefString, DEF_TEXT_SELECT_RELIEF); Tk_GetRelief(interp, DEF_TEXT_SELECT_RELIEF, &textPtr->selTagPtr->relief); textPtr->currentMarkPtr = TkTextSetMark(textPtr, "current", &startIndex); textPtr->insertMarkPtr = TkTextSetMark(textPtr, "insert", &startIndex); /* |
︙ | ︙ | |||
695 696 697 698 699 700 701 | static int TextWidgetObjCmd( ClientData clientData, /* Information about text widget. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { | | | 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 | static int TextWidgetObjCmd( ClientData clientData, /* Information about text widget. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { TkText *textPtr = (TkText *)clientData; int result = TCL_OK; int index; static const char *const optionStrings[] = { "bbox", "cget", "compare", "configure", "count", "debug", "delete", "dlineinfo", "dump", "edit", "get", "image", "index", "insert", "mark", "peer", "pendingsync", "replace", "scan", "search", |
︙ | ︙ | |||
860 861 862 863 864 865 866 | if (indexToPtr == NULL) { result = TCL_ERROR; goto done; } for (i = 2; i < objc-2; i++) { int value; | | | < | 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 | if (indexToPtr == NULL) { result = TCL_ERROR; goto done; } for (i = 2; i < objc-2; i++) { int value; int length; const char *option = Tcl_GetStringFromObj(objv[i], &length); char c; if (length < 2 || option[0] != '-') { goto badOption; } c = option[1]; if (c == 'c' && !strncmp("-chars", option, length)) { value = CountIndices(textPtr, indexFromPtr, indexToPtr, COUNT_CHARS); |
︙ | ︙ | |||
1122 1123 1124 1125 1126 1127 1128 | TkTextIndex *indices, *ixStart, *ixEnd, *lastStart; char *useIdx; int i; objc -= 2; objv += 2; | | | 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 | TkTextIndex *indices, *ixStart, *ixEnd, *lastStart; char *useIdx; int i; objc -= 2; objv += 2; indices = (TkTextIndex *)ckalloc((objc + 1) * sizeof(TkTextIndex)); /* * First pass verifies that all indices are valid. */ for (i = 0; i < objc; i++) { const TkTextIndex *indexPtr = |
︙ | ︙ | |||
1150 1151 1152 1153 1154 1155 1156 | if (objc & 1) { indices[i] = indices[i-1]; TkTextIndexForwChars(NULL, &indices[i], 1, &indices[i], COUNT_INDICES); objc++; } | | | | 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 | if (objc & 1) { indices[i] = indices[i-1]; TkTextIndexForwChars(NULL, &indices[i], 1, &indices[i], COUNT_INDICES); objc++; } useIdx = (char *)ckalloc(objc); memset(useIdx, 0, objc); /* * Do a decreasing order sort so that we delete the end ranges * first to maintain index consistency. */ qsort(indices, (size_t) objc / 2, |
︙ | ︙ | |||
1256 1257 1258 1259 1260 1261 1262 | case TEXT_EDIT: result = TextEditCmd(textPtr, interp, objc, objv); break; case TEXT_GET: { Tcl_Obj *objPtr = NULL; int i, found = 0, visible = 0; const char *name; | | | < | < | 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 | case TEXT_EDIT: result = TextEditCmd(textPtr, interp, objc, objv); break; case TEXT_GET: { Tcl_Obj *objPtr = NULL; int i, found = 0, visible = 0; const char *name; int length; if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, "?-displaychars? ?--? index1 ?index2 ...?"); result = TCL_ERROR; goto done; } /* * Simple, restrictive argument parsing. The only options are -- and * -displaychars (or any unique prefix). */ i = 2; if (objc > 3) { name = Tcl_GetStringFromObj(objv[i], &length); if (length > 1 && name[0] == '-') { if (strncmp("-displaychars", name, length) == 0) { i++; visible = 1; name = Tcl_GetStringFromObj(objv[i], &length); } if ((i < objc-1) && (length == 2) && !strcmp("--", name)) { i++; } } } |
︙ | ︙ | |||
1606 1607 1608 1609 1610 1611 1612 | static int SharedTextObjCmd( ClientData clientData, /* Information about shared test B-tree. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { | | | 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 | static int SharedTextObjCmd( ClientData clientData, /* Information about shared test B-tree. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { TkSharedText *sharedPtr = (TkSharedText *)clientData; int result = TCL_OK; int index; static const char *const optionStrings[] = { "delete", "insert", NULL }; enum options { |
︙ | ︙ | |||
1976 1977 1978 1979 1980 1981 1982 | /* * Free up any embedded windows which belong to this widget. */ for (hPtr = Tcl_FirstHashEntry(&sharedTextPtr->windowTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { TkTextEmbWindowClient *loop; | | | 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 | /* * Free up any embedded windows which belong to this widget. */ for (hPtr = Tcl_FirstHashEntry(&sharedTextPtr->windowTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { TkTextEmbWindowClient *loop; TkTextSegment *ewPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr); loop = ewPtr->body.ew.clients; if (loop->textPtr == textPtr) { ewPtr->body.ew.clients = loop->next; TkTextWinFreeClient(hPtr, loop); } else { TkTextEmbWindowClient *client = ewPtr->body.ew.clients; |
︙ | ︙ | |||
2008 2009 2010 2011 2012 2013 2014 | * everything in one go, more quickly. */ TkBTreeDestroy(sharedTextPtr->tree); for (hPtr = Tcl_FirstHashEntry(&sharedTextPtr->tagTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { | | | 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 | * everything in one go, more quickly. */ TkBTreeDestroy(sharedTextPtr->tree); for (hPtr = Tcl_FirstHashEntry(&sharedTextPtr->tagTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { tagPtr = (TkTextTag *)Tcl_GetHashValue(hPtr); /* * No need to use 'TkTextDeleteTag' since we've already removed * the B-tree completely. */ TkTextFreeTag(textPtr, tagPtr); |
︙ | ︙ | |||
2074 2075 2076 2077 2078 2079 2080 | * *---------------------------------------------------------------------- */ static int ConfigureText( Tcl_Interp *interp, /* Used for error reporting. */ | | | 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 | * *---------------------------------------------------------------------- */ static int ConfigureText( Tcl_Interp *interp, /* Used for error reporting. */ TkText *textPtr, /* Information about widget; may or may not * already have values for some fields. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_SavedOptions savedOptions; int oldExport = (textPtr->exportSelection) && (!Tcl_IsSafe(textPtr->interp)); int mask = 0; |
︙ | ︙ | |||
2377 2378 2379 2380 2381 2382 2383 | *--------------------------------------------------------------------------- */ static void TextWorldChangedCallback( ClientData instanceData) /* Information about widget. */ { | | | 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 | *--------------------------------------------------------------------------- */ static void TextWorldChangedCallback( ClientData instanceData) /* Information about widget. */ { TkText *textPtr = (TkText *)instanceData; TextWorldChanged(textPtr, TK_TEXT_LINE_GEOMETRY); } /* *--------------------------------------------------------------------------- * |
︙ | ︙ | |||
2466 2467 2468 2469 2470 2471 2472 | * *-------------------------------------------------------------- */ static void TextEventProc( ClientData clientData, /* Information about window. */ | | | | 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 | * *-------------------------------------------------------------- */ static void TextEventProc( ClientData clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { TkText *textPtr = (TkText *)clientData; TkTextIndex index, index2; if (eventPtr->type == Expose) { TkTextRedrawRegion(textPtr, eventPtr->xexpose.x, eventPtr->xexpose.y, eventPtr->xexpose.width, eventPtr->xexpose.height); } else if (eventPtr->type == ConfigureNotify) { |
︙ | ︙ | |||
2577 2578 2579 2580 2581 2582 2583 | *---------------------------------------------------------------------- */ static void TextCmdDeletedProc( ClientData clientData) /* Pointer to widget record for widget. */ { | | | 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 | *---------------------------------------------------------------------- */ static void TextCmdDeletedProc( ClientData clientData) /* Pointer to widget record for widget. */ { TkText *textPtr = (TkText *)clientData; Tk_Window tkwin = textPtr->tkwin; /* * This function could be invoked either because the window was destroyed * and the command was then deleted (in which this flag is already set) or * because the command was deleted, and then this function destroys the * widget. |
︙ | ︙ | |||
2630 2631 2632 2633 2634 2635 2636 | * modified if the index is not valid for * insertion (e.g. if at "end"). */ Tcl_Obj *stringPtr, /* Null-terminated string containing new * information to add to text. */ int viewUpdate) /* Update the view if set. */ { int lineIndex; | | | < | 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 | * modified if the index is not valid for * insertion (e.g. if at "end"). */ Tcl_Obj *stringPtr, /* Null-terminated string containing new * information to add to text. */ int viewUpdate) /* Update the view if set. */ { int lineIndex; int length; TkText *tPtr; int *lineAndByteIndex; int resetViewCount; int pixels[2*PIXEL_CLIENTS]; const char *string = Tcl_GetStringFromObj(stringPtr, &length); if (sharedTextPtr == NULL) { sharedTextPtr = textPtr->sharedTextPtr; } /* * Don't allow insertions on the last (dummy) line of the text. This is * the only place in this function where the indexPtr is modified. |
︙ | ︙ | |||
2663 2664 2665 2666 2667 2668 2669 | * insertion. If the insertion occurs on the top line of the widget * (textPtr->topIndex), then we have to recompute topIndex after the * insertion, since the insertion could invalidate it. */ resetViewCount = 0; if (sharedTextPtr->refCount > PIXEL_CLIENTS) { | | | 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 | * insertion. If the insertion occurs on the top line of the widget * (textPtr->topIndex), then we have to recompute topIndex after the * insertion, since the insertion could invalidate it. */ resetViewCount = 0; if (sharedTextPtr->refCount > PIXEL_CLIENTS) { lineAndByteIndex = (int *)ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount); } else { lineAndByteIndex = pixels; } for (tPtr = sharedTextPtr->peers; tPtr != NULL ; tPtr = tPtr->next) { lineAndByteIndex[resetViewCount] = -1; if (indexPtr->linePtr == tPtr->topIndex.linePtr) { lineAndByteIndex[resetViewCount] = |
︙ | ︙ | |||
2912 2913 2914 2915 2916 2917 2918 | TextUndoRedoCallback( Tcl_Interp *interp, /* Current interpreter. */ ClientData clientData, /* Passed from undo code, but contains our * shared text data structure. */ Tcl_Obj *objPtr) /* Arguments of a command to be handled by the * shared text data structure. */ { | | | 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 | TextUndoRedoCallback( Tcl_Interp *interp, /* Current interpreter. */ ClientData clientData, /* Passed from undo code, but contains our * shared text data structure. */ Tcl_Obj *objPtr) /* Arguments of a command to be handled by the * shared text data structure. */ { TkSharedText *sharedPtr = (TkSharedText *)clientData; int res, objc; Tcl_Obj **objv; TkText *textPtr; res = Tcl_ListObjGetElements(interp, objPtr, &objc, &objv); if (res != TCL_OK) { return res; |
︙ | ︙ | |||
3151 3152 3153 3154 3155 3156 3157 | * For speed, we remove all tags from the range first. If we don't * do this, the code below can (when there are many tags) grow * non-linearly in execution time. */ for (i=0, hPtr=Tcl_FirstHashEntry(&sharedTextPtr->tagTable, &search); hPtr != NULL; i++, hPtr = Tcl_NextHashEntry(&search)) { | < < | | 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 | * For speed, we remove all tags from the range first. If we don't * do this, the code below can (when there are many tags) grow * non-linearly in execution time. */ for (i=0, hPtr=Tcl_FirstHashEntry(&sharedTextPtr->tagTable, &search); hPtr != NULL; i++, hPtr = Tcl_NextHashEntry(&search)) { TkBTreeTag(&index1, &index2, (TkTextTag *)Tcl_GetHashValue(hPtr), 0); } /* * Special case for the sel tag which is not in the hash table. We * need to do this once for each peer text widget. */ |
︙ | ︙ | |||
3187 3188 3189 3190 3191 3192 3193 | * first character will be, then do the deletion, then reset the view. */ TkTextChanged(sharedTextPtr, NULL, &index1, &index2); resetViewCount = 0; if (sharedTextPtr->refCount > PIXEL_CLIENTS) { | | | 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 | * first character will be, then do the deletion, then reset the view. */ TkTextChanged(sharedTextPtr, NULL, &index1, &index2); resetViewCount = 0; if (sharedTextPtr->refCount > PIXEL_CLIENTS) { lineAndByteIndex = (int *)ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount); } else { lineAndByteIndex = pixels; } for (tPtr = sharedTextPtr->peers; tPtr != NULL ; tPtr = tPtr->next) { int line = 0; int byteIndex = 0; int resetView = 0; |
︙ | ︙ | |||
3376 3377 3378 3379 3380 3381 3382 | int offset, /* Offset within selection of first character * to be returned. */ char *buffer, /* Location in which to place selection. */ int maxBytes) /* Maximum number of bytes to place at buffer, * not including terminating NULL * character. */ { | | | 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 | int offset, /* Offset within selection of first character * to be returned. */ char *buffer, /* Location in which to place selection. */ int maxBytes) /* Maximum number of bytes to place at buffer, * not including terminating NULL * character. */ { TkText *textPtr = (TkText *)clientData; TkTextIndex eof; int count, chunkSize, offsetInSeg; TkTextSearch search; TkTextSegment *segPtr; if ((!textPtr->exportSelection) || Tcl_IsSafe(textPtr->interp)) { return -1; |
︙ | ︙ | |||
3460 3461 3462 3463 3464 3465 3466 | break; } } } if ((segPtr->typePtr == &tkTextCharType) && !TkTextIsElided(textPtr, &textPtr->selIndex, NULL)) { memcpy(buffer, segPtr->body.chars + offsetInSeg, | | | 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 | break; } } } if ((segPtr->typePtr == &tkTextCharType) && !TkTextIsElided(textPtr, &textPtr->selIndex, NULL)) { memcpy(buffer, segPtr->body.chars + offsetInSeg, chunkSize); buffer += chunkSize; maxBytes -= chunkSize; count += chunkSize; } TkTextIndexForwBytes(textPtr, &textPtr->selIndex, chunkSize, &textPtr->selIndex); } |
︙ | ︙ | |||
3507 3508 3509 3510 3511 3512 3513 | *---------------------------------------------------------------------- */ void TkTextLostSelection( ClientData clientData) /* Information about text widget. */ { | | | 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 | *---------------------------------------------------------------------- */ void TkTextLostSelection( ClientData clientData) /* Information about text widget. */ { TkText *textPtr = (TkText *)clientData; if (TkpAlwaysShowSelection(textPtr->tkwin)) { TkTextIndex start, end; if ((!textPtr->exportSelection) || Tcl_IsSafe(textPtr->interp)) { return; } |
︙ | ︙ | |||
3592 3593 3594 3595 3596 3597 3598 | *---------------------------------------------------------------------- */ static void TextBlinkProc( ClientData clientData) /* Pointer to record describing text. */ { | | | 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 | *---------------------------------------------------------------------- */ static void TextBlinkProc( ClientData clientData) /* Pointer to record describing text. */ { TkText *textPtr = (TkText *)clientData; TkTextIndex index; int x, y, w, h, charWidth; if ((textPtr->state == TK_TEXT_STATE_DISABLED) || !(textPtr->flags & GOT_FOCUS) || (textPtr->insertOffTime == 0)) { if (!(textPtr->flags & GOT_FOCUS) && (textPtr->insertUnfocussed != TK_TEXT_INSERT_NOFOCUS_NONE)) { |
︙ | ︙ | |||
3972 3973 3974 3975 3976 3977 3978 | SearchSpec *searchSpecPtr, /* Contains other search parameters. */ int *linePosPtr, /* For returning the line number. */ int *offsetPosPtr) /* For returning the text offset in the * line. */ { const TkTextIndex *indexPtr; int line; | | | 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 | SearchSpec *searchSpecPtr, /* Contains other search parameters. */ int *linePosPtr, /* For returning the line number. */ int *offsetPosPtr) /* For returning the text offset in the * line. */ { const TkTextIndex *indexPtr; int line; TkText *textPtr = (TkText *)searchSpecPtr->clientData; indexPtr = TkTextGetIndexFromObj(interp, textPtr, objPtr); if (indexPtr == NULL) { return TCL_ERROR; } line = TkBTreeLinesTo(textPtr, indexPtr->linePtr); |
︙ | ︙ | |||
4037 4038 4039 4040 4041 4042 4043 | /* Search parameters. */ TkTextLine *linePtr, /* The line we're looking at. */ int byteIndex) /* Index into the line. */ { TkTextSegment *segPtr; TkTextIndex curIndex; int index, leftToScan; | | | 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 | /* Search parameters. */ TkTextLine *linePtr, /* The line we're looking at. */ int byteIndex) /* Index into the line. */ { TkTextSegment *segPtr; TkTextIndex curIndex; int index, leftToScan; TkText *textPtr = (TkText *)searchSpecPtr->clientData; index = 0; curIndex.tree = textPtr->sharedTextPtr->tree; curIndex.linePtr = linePtr; curIndex.byteIndex = 0; for (segPtr = linePtr->segPtr, leftToScan = byteIndex; leftToScan > 0; curIndex.byteIndex += segPtr->size, segPtr = segPtr->nextPtr) { |
︙ | ︙ | |||
4107 4108 4109 4110 4111 4112 4113 | * incremented by the number of additional * logical lines which are merged into this * one by newlines being elided. */ { TkTextLine *linePtr, *thisLinePtr; TkTextIndex curIndex; TkTextSegment *segPtr; | | | 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 | * incremented by the number of additional * logical lines which are merged into this * one by newlines being elided. */ { TkTextLine *linePtr, *thisLinePtr; TkTextIndex curIndex; TkTextSegment *segPtr; TkText *textPtr = (TkText *)searchSpecPtr->clientData; int nothingYet = 1; /* * Extract the text from the line. */ linePtr = TkBTreeFindLine(textPtr->sharedTextPtr->tree, textPtr, lineNum); |
︙ | ︙ | |||
4229 4230 4231 4232 4233 4234 4235 | * type. */ { int numChars; int leftToScan; TkTextIndex curIndex, foundIndex; TkTextSegment *segPtr; TkTextLine *linePtr; | | | 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 | * type. */ { int numChars; int leftToScan; TkTextIndex curIndex, foundIndex; TkTextSegment *segPtr; TkTextLine *linePtr; TkText *textPtr = (TkText *)searchSpecPtr->clientData; if (lineNum == searchSpecPtr->stopLine) { /* * If the current index is on the wrong side of the stopIndex, then * the item we just found is actually outside the acceptable range, * and the search is over. */ |
︙ | ︙ | |||
4280 4281 4282 4283 4284 4285 4286 | * 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. */ | | | 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 | * 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. */ linePtr = (TkTextLine *)clientData; if (linePtr == NULL) { linePtr = TkBTreeFindLine(textPtr->sharedTextPtr->tree, textPtr, lineNum); } curIndex.tree = textPtr->sharedTextPtr->tree; |
︙ | ︙ | |||
4490 4491 4492 4493 4494 4495 4496 | } } /* * Parse the elements of the list one at a time to fill in the array. */ | | | | 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 | } } /* * Parse the elements of the list one at a time to fill in the array. */ tabArrayPtr = (TkTextTabArray *)ckalloc(Tk_Offset(TkTextTabArray, tabs) + count * sizeof(TkTextTab)); tabArrayPtr->numTabs = 0; prevStop = 0.0; lastStop = 0.0; for (i = 0, tabPtr = &tabArrayPtr->tabs[0]; i < objc; i++, tabPtr++) { int index; /* |
︙ | ︙ | |||
4617 4618 4619 4620 4621 4622 4623 | * side effects). * *---------------------------------------------------------------------- */ static int TextDumpCmd( | | | 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 | * side effects). * *---------------------------------------------------------------------- */ static int TextDumpCmd( TkText *textPtr, /* Information about text widget. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. Someone else has already * parsed this command enough to know that * objv[1] is "dump". */ { TkTextIndex index1, index2; |
︙ | ︙ | |||
4704 4705 4706 4707 4708 4709 4710 | return TCL_ERROR; } arg++; atEnd = 0; if (objc == arg) { TkTextIndexForwChars(NULL, &index1, 1, &index2, COUNT_INDICES); } else { | | | < | 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 | return TCL_ERROR; } arg++; atEnd = 0; if (objc == arg) { TkTextIndexForwChars(NULL, &index1, 1, &index2, COUNT_INDICES); } else { int length; const char *str; if (TkTextGetObjIndex(interp, textPtr, objv[arg], &index2) != TCL_OK) { return TCL_ERROR; } str = Tcl_GetStringFromObj(objv[arg], &length); if (strncmp(str, "end", length) == 0) { atEnd = 1; } } if (TkTextIndexCmp(&index1, &index2) >= 0) { return TCL_OK; } |
︙ | ︙ | |||
4855 4856 4857 4858 4859 4860 4861 | * To avoid modifying the string in place we copy over just * the segment that we want. Since DumpSegment can modify the * text, we could not confidently revert the modification * here. */ int length = last - first; | | | 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 | * To avoid modifying the string in place we copy over just * the segment that we want. Since DumpSegment can modify the * text, we could not confidently revert the modification * here. */ int length = last - first; char *range = (char *)ckalloc(length + 1); memcpy(range, segPtr->body.chars + first, length); range[length] = '\0'; TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr, lineno, offset + first, &index); lineChanged = DumpSegment(textPtr, interp, "text", range, |
︙ | ︙ | |||
4886 4887 4888 4889 4890 4891 4892 | name = "insert"; } else if (segPtr == textPtr->currentMarkPtr) { name = "current"; } else if (markPtr->hPtr == NULL) { name = NULL; lineChanged = 0; } else { | | | 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 | name = "insert"; } else if (segPtr == textPtr->currentMarkPtr) { name = "current"; } else if (markPtr->hPtr == NULL) { name = NULL; lineChanged = 0; } else { name = (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, markPtr->hPtr); } if (name != NULL) { TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr, lineno, offset, &index); lineChanged = DumpSegment(textPtr, interp, "mark", name, command, &index, what); |
︙ | ︙ | |||
5012 5013 5014 5015 5016 5017 5018 | DumpSegment( TkText *textPtr, Tcl_Interp *interp, const char *key, /* Segment type key. */ const char *value, /* Segment value. */ Tcl_Obj *command, /* Script callback. */ const TkTextIndex *index, /* index with line/byte position info. */ | | | 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 | DumpSegment( TkText *textPtr, Tcl_Interp *interp, const char *key, /* Segment type key. */ const char *value, /* Segment value. */ Tcl_Obj *command, /* Script callback. */ const TkTextIndex *index, /* index with line/byte position info. */ TCL_UNUSED(int)) /* Look for TK_DUMP_INDEX bit. */ { char buffer[TK_POS_CHARS]; Tcl_Obj *values[3], *tuple; TkTextPrintIndex(textPtr, index, buffer); values[0] = Tcl_NewStringObj(key, -1); values[1] = Tcl_NewStringObj(value, -1); |
︙ | ︙ | |||
5514 5515 5516 5517 5518 5519 5520 | *---------------------------------------------------------------------- */ void TkTextRunAfterSyncCmd( ClientData clientData) /* Information about text widget. */ { | | | 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 | *---------------------------------------------------------------------- */ void TkTextRunAfterSyncCmd( ClientData clientData) /* Information about text widget. */ { TkText *textPtr = (TkText *)clientData; int code; if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) { /* * The widget has been deleted. Don't do anything. */ |
︙ | ︙ | |||
5588 5589 5590 5591 5592 5593 5594 | /* * Find the optional end location, similarly. */ if (toPtr != NULL) { const TkTextIndex *indexToPtr, *indexFromPtr; | | | 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 | /* * Find the optional end location, similarly. */ if (toPtr != NULL) { const TkTextIndex *indexToPtr, *indexFromPtr; TkText *textPtr = (TkText *)searchSpecPtr->clientData; indexToPtr = TkTextGetIndexFromObj(interp, textPtr, toPtr); if (indexToPtr == NULL) { return TCL_ERROR; } indexFromPtr = TkTextGetIndexFromObj(interp, textPtr, fromPtr); |
︙ | ︙ | |||
5669 5670 5671 5672 5673 5674 5675 | * pattern. Must have a refCount > 0. */ { /* * For exact searches these are utf-8 char* offsets, for regexp searches * they are Unicode char offsets. */ | | > | 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 | * pattern. Must have a refCount > 0. */ { /* * For exact searches these are utf-8 char* offsets, for regexp searches * they are Unicode char offsets. */ int firstOffset, lastOffset; int matchOffset, matchLength; int passes; int lineNum = searchSpecPtr->startLine; int code = TCL_OK; Tcl_Obj *theLine; int alreadySearchOffset = -1; const char *pattern = NULL; /* For exact searches only. */ |
︙ | ︙ | |||
5742 5743 5744 5745 5746 5747 5748 | /* * We only need to set the matchLength once for exact searches, and we * do it here. It is also used below as the actual pattern length, so * it has dual purpose. */ | | < | 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 | /* * We only need to set the matchLength once for exact searches, and we * do it here. It is also used below as the actual pattern length, so * it has dual purpose. */ pattern = Tcl_GetStringFromObj(patObj, &matchLength); nl = strchr(pattern, '\n'); /* * If there is no newline, or it is the very end of the string, then * we don't need any special treatment, since single-line matching * will work fine. */ |
︙ | ︙ | |||
5912 5913 5914 5915 5916 5917 5918 | p = startOfLine + alreadySearchOffset; alreadySearchOffset = -1; } else { p = startOfLine + lastOffset -1; } while (p >= startOfLine + firstOffset) { if (matchLength == 0 || (p[0] == c && !strncmp( | | | 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 | p = startOfLine + alreadySearchOffset; alreadySearchOffset = -1; } else { p = startOfLine + lastOffset -1; } while (p >= startOfLine + firstOffset) { if (matchLength == 0 || (p[0] == c && !strncmp( p, pattern, matchLength))) { goto backwardsMatch; } p--; } break; } else { p = strstr(startOfLine + firstOffset, pattern); |
︙ | ︙ | |||
5941 5942 5943 5944 5945 5946 5947 | } else { /* * Multi-line match has only one possible match position, * because we know where the '\n' is. */ p = startOfLine + lastOffset - firstNewLine - 1; | | | 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 | } else { /* * Multi-line match has only one possible match position, * because we know where the '\n' is. */ p = startOfLine + lastOffset - firstNewLine - 1; if (strncmp(p, pattern, firstNewLine + 1)) { /* * No match. */ break; } else { int extraLines = 1; |
︙ | ︙ | |||
6007 6008 6009 6010 6011 6012 6013 | if ((lastTotal - skipFirst) >= matchLength) { /* * We now have enough text to match, so we * make a final test and break whatever the * result. */ | | | 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 | if ((lastTotal - skipFirst) >= matchLength) { /* * We now have enough text to match, so we * make a final test and break whatever the * result. */ if (strncmp(p, pattern, matchLength)) { p = NULL; } break; } else { /* * Not enough text yet, but check the prefix. */ |
︙ | ︙ | |||
6255 6256 6257 6258 6259 6260 6261 | * This means we often add and search one more line * than might be necessary if Tcl were able to give us * a correct value of info.extendStart under all * circumstances. */ if ((match && | | | | 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 | * This means we often add and search one more line * than might be necessary if Tcl were able to give us * a correct value of info.extendStart under all * circumstances. */ if ((match && firstOffset + info.matches[0].end != lastTotal && firstOffset + info.matches[0].end < prevFullLine) || info.extendStart < 0) { break; } /* * If there is a match, but that match starts after * the end of the first line, then we'll handle that |
︙ | ︙ | |||
6325 6326 6327 6328 6329 6330 6331 | - info.matches[0].start; if (lastNonOverlap != -1) { /* * Possible overlap or enclosure. */ | | | | 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 | - info.matches[0].start; if (lastNonOverlap != -1) { /* * Possible overlap or enclosure. */ if (thisOffset - lastNonOverlap >= lastBackwardsMatchOffset + matchLength){ /* * Totally encloses previous match, so * forget the previous match. */ lastBackwardsLineMatch = -1; } else if ((thisOffset - lastNonOverlap) |
︙ | ︙ | |||
6430 6431 6432 6433 6434 6435 6436 | if (matches == matchNum) { /* * We've run out of space in our normal store, so * we must allocate space for these backwards * matches on the heap. */ | | | 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 | if (matches == matchNum) { /* * We've run out of space in our normal store, so * we must allocate space for these backwards * matches on the heap. */ int *newArray = (int *) ckalloc(4 * matchNum * sizeof(int)); memcpy(newArray, storeMatch, matchNum*sizeof(int)); memcpy(newArray + 2*matchNum, storeLength, matchNum * sizeof(int)); if (storeMatch != smArray) { ckfree(storeMatch); } |
︙ | ︙ | |||
6691 6692 6693 6694 6695 6696 6697 | * Creates a new Tcl_Obj. * *---------------------------------------------------------------------- */ static Tcl_Obj * GetLineStartEnd( | | | | 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 | * Creates a new Tcl_Obj. * *---------------------------------------------------------------------- */ static Tcl_Obj * GetLineStartEnd( TCL_UNUSED(void *), TCL_UNUSED(Tk_Window), char *recordPtr, /* Pointer to widget record. */ int internalOffset) /* Offset within *recordPtr containing the * line value. */ { TkTextLine *linePtr = *(TkTextLine **)(recordPtr + internalOffset); if (linePtr == NULL) { |
︙ | ︙ | |||
6726 6727 6728 6729 6730 6731 6732 | * that the specified string was empty and that is acceptable. * *---------------------------------------------------------------------- */ static int SetLineStartEnd( | | | | 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 | * that the specified string was empty and that is acceptable. * *---------------------------------------------------------------------- */ static int SetLineStartEnd( TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interp; may be used for errors. */ TCL_UNUSED(Tk_Window), /* Window for which option is being set. */ Tcl_Obj **value, /* Pointer to the pointer to the value object. * We use a pointer to the pointer because we * may need to return a value (NULL). */ char *recordPtr, /* Pointer to storage for the widget record. */ int internalOffset, /* Offset within *recordPtr at which the * internal value is to be stored. */ char *oldInternalPtr, /* Pointer to storage for the old value. */ |
︙ | ︙ | |||
6785 6786 6787 6788 6789 6790 6791 | * Restores the old value. * *---------------------------------------------------------------------- */ static void RestoreLineStartEnd( | | | | 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 | * Restores the old value. * *---------------------------------------------------------------------- */ static void RestoreLineStartEnd( TCL_UNUSED(void *), TCL_UNUSED(Tk_Window), char *internalPtr, /* Pointer to storage for value. */ char *oldInternalPtr) /* Pointer to old value. */ { *(TkTextLine **)internalPtr = *(TkTextLine **)oldInternalPtr; } /* |
︙ | ︙ | |||
6844 6845 6846 6847 6848 6849 6850 | * Depends on option; see below. * *---------------------------------------------------------------------- */ int TkpTesttextCmd( | | | | 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 | * Depends on option; see below. * *---------------------------------------------------------------------- */ int TkpTesttextCmd( TCL_UNUSED(void *), /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { TkText *textPtr; size_t len; int lineIndex, byteIndex, byteOffset; TkTextIndex index; char buf[64]; Tcl_CmdInfo info; if (objc < 3) { return TCL_ERROR; } if (Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &info) == 0) { return TCL_ERROR; } textPtr = (TkText *)info.objClientData; len = strlen(Tcl_GetString(objv[2])); if (strncmp(Tcl_GetString(objv[2]), "byteindex", len) == 0) { if (objc != 5) { return TCL_ERROR; } lineIndex = atoi(Tcl_GetString(objv[3])) - 1; byteIndex = atoi(Tcl_GetString(objv[4])); |
︙ | ︙ |
Changes to generic/tkTextDisp.c.
︙ | ︙ | |||
440 441 442 443 444 445 446 | * points to one of the following structures: */ #if !TK_LAYOUT_WITH_BASE_CHUNKS typedef struct CharInfo { int numBytes; /* Number of bytes to display. */ | | | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | * points to one of the following structures: */ #if !TK_LAYOUT_WITH_BASE_CHUNKS typedef struct CharInfo { int numBytes; /* Number of bytes to display. */ char chars[1]; /* UTF characters to display. * Allocated as large as necessary. THIS MUST BE THE LAST * FIELD IN THE STRUCTURE. */ } CharInfo; #else /* TK_LAYOUT_WITH_BASE_CHUNKS */ typedef struct CharInfo { TkTextDispChunk *baseChunkPtr; |
︙ | ︙ | |||
654 655 656 657 658 659 660 | *---------------------------------------------------------------------- */ void TkTextCreateDInfo( TkText *textPtr) /* Overall information for text widget. */ { | | | | 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 | *---------------------------------------------------------------------- */ void TkTextCreateDInfo( TkText *textPtr) /* Overall information for text widget. */ { TextDInfo *dInfoPtr; XGCValues gcValues; dInfoPtr = (TextDInfo *)ckalloc(sizeof(TextDInfo)); Tcl_InitHashTable(&dInfoPtr->styleTable, sizeof(StyleValues)/sizeof(int)); dInfoPtr->dLinePtr = NULL; dInfoPtr->copyGC = NULL; gcValues.graphics_exposures = True; dInfoPtr->scrollGC = Tk_GetGC(textPtr->tkwin, GCGraphicsExposures, &gcValues); dInfoPtr->topOfEof = 0; |
︙ | ︙ | |||
713 714 715 716 717 718 719 | *---------------------------------------------------------------------- */ void TkTextFreeDInfo( TkText *textPtr) /* Overall information for text widget. */ { | | | 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 | *---------------------------------------------------------------------- */ void TkTextFreeDInfo( TkText *textPtr) /* Overall information for text widget. */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; /* * Be careful to free up styleTable *after* freeing up all the DLines, so * that the hash table is still intact to free up the style-related * information from the lines. Once the lines are all free then styleTable * will be empty. */ |
︙ | ︙ | |||
769 770 771 772 773 774 775 | static TextStyle * GetStyle( TkText *textPtr, /* Overall information about text widget. */ const TkTextIndex *indexPtr)/* The character in the text for which display * information is wanted. */ { TkTextTag **tagPtrs; | | | 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 | static TextStyle * GetStyle( TkText *textPtr, /* Overall information about text widget. */ const TkTextIndex *indexPtr)/* The character in the text for which display * information is wanted. */ { TkTextTag **tagPtrs; TkTextTag *tagPtr; StyleValues styleValues; TextStyle *stylePtr; Tcl_HashEntry *hPtr; int numTags, isNew, i; int isSelected; XGCValues gcValues; unsigned long mask; |
︙ | ︙ | |||
998 999 1000 1001 1002 1003 1004 | /* * Use an existing style if there's one around that matches. */ hPtr = Tcl_CreateHashEntry(&textPtr->dInfoPtr->styleTable, (char *) &styleValues, &isNew); if (!isNew) { | | | | 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 | /* * Use an existing style if there's one around that matches. */ hPtr = Tcl_CreateHashEntry(&textPtr->dInfoPtr->styleTable, (char *) &styleValues, &isNew); if (!isNew) { stylePtr = (TextStyle *)Tcl_GetHashValue(hPtr); stylePtr->refCount++; return stylePtr; } /* * No existing style matched. Make a new one. */ stylePtr = (TextStyle *)ckalloc(sizeof(TextStyle)); stylePtr->refCount = 1; if (styleValues.border != NULL) { gcValues.foreground = Tk_3DBorderColor(styleValues.border)->pixel; mask = GCForeground; if (styleValues.bgStipple != None) { gcValues.stipple = styleValues.bgStipple; gcValues.fill_style = FillStippled; |
︙ | ︙ | |||
1065 1066 1067 1068 1069 1070 1071 | * *---------------------------------------------------------------------- */ static void FreeStyle( TkText *textPtr, /* Information about overall widget. */ | | | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | * *---------------------------------------------------------------------- */ static void FreeStyle( TkText *textPtr, /* Information about overall widget. */ TextStyle *stylePtr) /* Information about style to free. */ { stylePtr->refCount--; if (stylePtr->refCount == 0) { if (stylePtr->bgGC != NULL) { Tk_FreeGC(textPtr->display, stylePtr->bgGC); } |
︙ | ︙ | |||
1128 1129 1130 1131 1132 1133 1134 | static DLine * LayoutDLine( TkText *textPtr, /* Overall information about text widget. */ const TkTextIndex *indexPtr)/* Beginning of display line. May not * necessarily point to a character * segment. */ { | | | 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 | static DLine * LayoutDLine( TkText *textPtr, /* Overall information about text widget. */ const TkTextIndex *indexPtr)/* Beginning of display line. May not * necessarily point to a character * segment. */ { DLine *dlPtr; /* New display line. */ TkTextSegment *segPtr; /* Current segment in text. */ TkTextDispChunk *lastChunkPtr; /* Last chunk allocated so far for line. */ TkTextDispChunk *chunkPtr; /* Current chunk. */ TkTextIndex curIndex; TkTextDispChunk *breakChunkPtr; /* Chunk containing best word break point, if |
︙ | ︙ | |||
1182 1183 1184 1185 1186 1187 1188 | StyleValues *sValuePtr; TkTextElideInfo info; /* Keep track of elide state. */ /* * Create and initialize a new DLine structure. */ | | | 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 | StyleValues *sValuePtr; TkTextElideInfo info; /* Keep track of elide state. */ /* * Create and initialize a new DLine structure. */ dlPtr = (DLine *)ckalloc(sizeof(DLine)); dlPtr->index = *indexPtr; dlPtr->byteCount = 0; dlPtr->y = 0; dlPtr->oldY = 0; /* Only set to avoid compiler warnings. */ dlPtr->height = 0; dlPtr->baseline = 0; dlPtr->chunkPtr = NULL; |
︙ | ︙ | |||
1431 1432 1433 1434 1435 1436 1437 | if (segPtr->typePtr->layoutProc == NULL) { segPtr = segPtr->nextPtr; byteOffset = 0; continue; } if (chunkPtr == NULL) { | | | 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 | if (segPtr->typePtr->layoutProc == NULL) { segPtr = segPtr->nextPtr; byteOffset = 0; continue; } if (chunkPtr == NULL) { chunkPtr = (TkTextDispChunk *)ckalloc(sizeof(TkTextDispChunk)); chunkPtr->nextPtr = NULL; chunkPtr->clientData = NULL; } chunkPtr->stylePtr = GetStyle(textPtr, &curIndex); elide = chunkPtr->stylePtr->sValuePtr->elide; /* |
︙ | ︙ | |||
1829 1830 1831 1832 1833 1834 1835 | *---------------------------------------------------------------------- */ static void UpdateDisplayInfo( TkText *textPtr) /* Text widget to update. */ { | | | | 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 | *---------------------------------------------------------------------- */ static void UpdateDisplayInfo( TkText *textPtr) /* Text widget to update. */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; DLine *dlPtr, *prevPtr; TkTextIndex index; TkTextLine *lastLinePtr; int y, maxY, xPixelOffset, maxOffset, lineHeight; if (!(dInfoPtr->flags & DINFO_OUT_OF_DATE)) { return; } |
︙ | ︙ | |||
1867 1868 1869 1870 1871 1872 1873 | lastLinePtr = TkBTreeFindLine(textPtr->sharedTextPtr->tree, textPtr, TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr)); dlPtr = dInfoPtr->dLinePtr; prevPtr = NULL; y = dInfoPtr->y - dInfoPtr->newTopPixelOffset; maxY = dInfoPtr->maxY; while (1) { | | | 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 | lastLinePtr = TkBTreeFindLine(textPtr->sharedTextPtr->tree, textPtr, TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr)); dlPtr = dInfoPtr->dLinePtr; prevPtr = NULL; y = dInfoPtr->y - dInfoPtr->newTopPixelOffset; maxY = dInfoPtr->maxY; while (1) { DLine *newPtr; if (index.linePtr == lastLinePtr) { break; } /* * There are three possibilities right now: |
︙ | ︙ | |||
1978 1979 1980 1981 1982 1983 1984 | /* * If we switched text lines, delete any DLines left for the old text * line. */ if (index.linePtr != prevPtr->index.linePtr) { | | | 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 | /* * If we switched text lines, delete any DLines left for the old text * line. */ if (index.linePtr != prevPtr->index.linePtr) { DLine *nextPtr; nextPtr = dlPtr; while ((nextPtr != NULL) && (nextPtr->index.linePtr == prevPtr->index.linePtr)) { nextPtr = nextPtr->nextPtr; } if (nextPtr != dlPtr) { |
︙ | ︙ | |||
2347 2348 2349 2350 2351 2352 2353 | * *---------------------------------------------------------------------- */ static void FreeDLines( TkText *textPtr, /* Information about overall text widget. */ | | | | | | 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 | * *---------------------------------------------------------------------- */ static void FreeDLines( TkText *textPtr, /* Information about overall text widget. */ DLine *firstPtr, /* Pointer to first DLine to free up. */ DLine *lastPtr, /* Pointer to DLine just after last one to * free (NULL means everything starting with * firstPtr). */ int action) /* DLINE_UNLINK means DLines are currently * linked into the list rooted at * textPtr->dInfoPtr->dLinePtr and they have * to be unlinked. DLINE_FREE means just free * without unlinking. DLINE_FREE_TEMP means * the DLine given is just a temporary one and * we shouldn't invalidate anything for the * overall widget. */ { TkTextDispChunk *chunkPtr, *nextChunkPtr; DLine *nextDLinePtr; if (action == DLINE_FREE_TEMP) { lineHeightsRecalculated++; if (tkTextDebug) { char string[TK_POS_CHARS]; /* * Debugging is enabled, so keep a log of all the lines whose * height was recalculated. The test suite uses this information. */ TkTextPrintIndex(textPtr, &firstPtr->index, string); LOG("tk_textHeightCalc", string); } } else if (action == DLINE_UNLINK) { if (textPtr->dInfoPtr->dLinePtr == firstPtr) { textPtr->dInfoPtr->dLinePtr = lastPtr; } else { DLine *prevPtr; for (prevPtr = textPtr->dInfoPtr->dLinePtr; prevPtr->nextPtr != firstPtr; prevPtr = prevPtr->nextPtr) { /* Empty loop body. */ } prevPtr->nextPtr = lastPtr; } |
︙ | ︙ | |||
2428 2429 2430 2431 2432 2433 2434 | * *---------------------------------------------------------------------- */ static void DisplayDLine( TkText *textPtr, /* Text widget in which to draw line. */ | | | | 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 | * *---------------------------------------------------------------------- */ static void DisplayDLine( TkText *textPtr, /* Text widget in which to draw line. */ DLine *dlPtr, /* Information about line to draw. */ DLine *prevPtr, /* Line just before one to draw, or NULL if * dlPtr is the top line. */ Pixmap pixmap) /* Pixmap to use for double-buffering. Caller * must make sure it's large enough to hold * line. */ { TkTextDispChunk *chunkPtr; TextDInfo *dInfoPtr = textPtr->dInfoPtr; Display *display; int height, y_off; #ifndef TK_NO_DOUBLE_BUFFERING const int y = 0; #else const int y = dlPtr->y; |
︙ | ︙ | |||
2607 2608 2609 2610 2611 2612 2613 | * *-------------------------------------------------------------- */ static void DisplayLineBackground( TkText *textPtr, /* Text widget containing line. */ | | | 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 | * *-------------------------------------------------------------- */ static void DisplayLineBackground( TkText *textPtr, /* Text widget containing line. */ DLine *dlPtr, /* Information about line to draw. */ DLine *prevPtr, /* Line just above dlPtr, or NULL if dlPtr is * the top-most line in the window. */ Pixmap pixmap) /* Pixmap to use for double-buffering. Caller * must make sure it's large enough to hold * line. Caller must also have filled it with * the background color for the widget. */ { |
︙ | ︙ | |||
3003 3004 3005 3006 3007 3008 3009 | *---------------------------------------------------------------------- */ static void AsyncUpdateLineMetrics( ClientData clientData) /* Information about widget. */ { | | | 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 | *---------------------------------------------------------------------- */ static void AsyncUpdateLineMetrics( ClientData clientData) /* Information about widget. */ { TkText *textPtr = (TkText *)clientData; TextDInfo *dInfoPtr = textPtr->dInfoPtr; int lineNum; dInfoPtr->lineUpdateTimer = NULL; if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED) || !Tk_IsMapped(textPtr->tkwin)) { |
︙ | ︙ | |||
4160 4161 4162 4163 4164 4165 4166 | *---------------------------------------------------------------------- */ static void DisplayText( ClientData clientData) /* Information about widget. */ { | | | | 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 | *---------------------------------------------------------------------- */ static void DisplayText( ClientData clientData) /* Information about widget. */ { TkText *textPtr = (TkText *)clientData; TextDInfo *dInfoPtr = textPtr->dInfoPtr; DLine *dlPtr; DLine *prevPtr; Pixmap pixmap; int maxHeight, borders; int bottomY = 0; /* Initialization needed only to stop compiler * warnings. */ Tcl_Interp *interp; |
︙ | ︙ | |||
4250 4251 4252 4253 4254 4255 4256 | * scrolling (copying from other parts of the screen). We have to be * particularly careful with the top and bottom lines of the display, * since these may only be partially visible and therefore not helpful for * some scrolling purposes. */ for (dlPtr = dInfoPtr->dLinePtr; dlPtr != NULL; dlPtr = dlPtr->nextPtr) { | | | 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 | * scrolling (copying from other parts of the screen). We have to be * particularly careful with the top and bottom lines of the display, * since these may only be partially visible and therefore not helpful for * some scrolling purposes. */ for (dlPtr = dInfoPtr->dLinePtr; dlPtr != NULL; dlPtr = dlPtr->nextPtr) { DLine *dlPtr2; int offset, height, y, oldY; TkRegion damageRgn; /* * These tests are, in order: * * 1. If the line is already marked as invalid |
︙ | ︙ | |||
4548 4549 4550 4551 4552 4553 4554 | * Otherwise, everything else moves, but the embedded window * doesn't! * * So, we loop through all the chunks, calling the display * proc of embedded windows only. */ #endif | | | 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 | * Otherwise, everything else moves, but the embedded window * doesn't! * * So, we loop through all the chunks, calling the display * proc of embedded windows only. */ #endif TkTextDispChunk *chunkPtr; for (chunkPtr = dlPtr->chunkPtr; (chunkPtr != NULL); chunkPtr = chunkPtr->nextPtr) { int x; if (chunkPtr->displayProc != TkTextEmbWinDisplayProc) { continue; } |
︙ | ︙ | |||
4750 4751 4752 4753 4754 4755 4756 | */ static void TextInvalidateRegion( TkText *textPtr, /* Widget record for text widget. */ TkRegion region) /* Region of area to redraw. */ { | | | 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 | */ static void TextInvalidateRegion( TkText *textPtr, /* Widget record for text widget. */ TkRegion region) /* Region of area to redraw. */ { DLine *dlPtr; TextDInfo *dInfoPtr = textPtr->dInfoPtr; int maxY, inset; XRectangle rect; /* * Find all lines that overlap the given region and mark them for * redisplay. |
︙ | ︙ | |||
5008 5009 5010 5011 5012 5013 5014 | TkTextIndex *index2Ptr, /* Character just after last one to consider * for redisplay. NULL means process all the * characters in the text. */ TkTextTag *tagPtr, /* Information about tag. */ int withTag) /* 1 means redraw characters that have the * tag, 0 means redraw those without. */ { | | | 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 | TkTextIndex *index2Ptr, /* Character just after last one to consider * for redisplay. NULL means process all the * characters in the text. */ TkTextTag *tagPtr, /* Information about tag. */ int withTag) /* 1 means redraw characters that have the * tag, 0 means redraw those without. */ { DLine *dlPtr; DLine *endPtr; int tagOn; TkTextSearch search; TextDInfo *dInfoPtr = textPtr->dInfoPtr; TkTextIndex *curIndexPtr; TkTextIndex endOfText, *endIndexPtr; |
︙ | ︙ | |||
5348 5349 5350 5351 5352 5353 5354 | * line, don't nudge it up or down by a few * pixels just to make sure it is entirely * displayed. Positive numbers indicate the * number of pixels of the index's line which * are to be off the top of the screen. */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; | | | 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 | * line, don't nudge it up or down by a few * pixels just to make sure it is entirely * displayed. Positive numbers indicate the * number of pixels of the index's line which * are to be off the top of the screen. */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; DLine *dlPtr; int bottomY, close, lineIndex; TkTextIndex tmpIndex, rounded; int lineHeight; /* * If the specified position is the extra line at the end of the text, * round it back to the last real line. |
︙ | ︙ | |||
6176 6177 6178 6179 6180 6181 6182 | /* * Next, handle the old syntax: "pathName yview ?-pickplace? where" */ pickPlace = 0; if (Tcl_GetString(objv[2])[0] == '-') { | | | 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 | /* * Next, handle the old syntax: "pathName yview ?-pickplace? where" */ pickPlace = 0; if (Tcl_GetString(objv[2])[0] == '-') { const char *switchStr = Tcl_GetStringFromObj(objv[2], &switchLength); if ((switchLength >= 2) && (strncmp(switchStr, "-pickplace", (unsigned) switchLength) == 0)) { pickPlace = 1; if (objc != 4) { Tcl_WrongNumArgs(interp, 3, objv, "lineNum|index"); |
︙ | ︙ | |||
6354 6355 6356 6357 6358 6359 6360 | * See the user documentation. * *-------------------------------------------------------------- */ int TkTextScanCmd( | | | 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 | * See the user documentation. * *-------------------------------------------------------------- */ int TkTextScanCmd( TkText *textPtr, /* Information about text widget. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. Someone else has already * parsed this command enough to know that * objv[1] is "scan". */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; |
︙ | ︙ | |||
6840 6841 6842 6843 6844 6845 6846 | *---------------------------------------------------------------------- */ static void AsyncUpdateYScrollbar( ClientData clientData) /* Information about widget. */ { | | | 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 | *---------------------------------------------------------------------- */ static void AsyncUpdateYScrollbar( ClientData clientData) /* Information about widget. */ { TkText *textPtr = (TkText *)clientData; textPtr->dInfoPtr->scrollbarTimer = NULL; if (!(textPtr->flags & DESTROYED)) { GetYView(textPtr->interp, textPtr, 1); } |
︙ | ︙ | |||
6875 6876 6877 6878 6879 6880 6881 | * *---------------------------------------------------------------------- */ static DLine * FindDLine( TkText *textPtr, /* Widget record for text widget. */ | | | 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 | * *---------------------------------------------------------------------- */ static DLine * FindDLine( TkText *textPtr, /* Widget record for text widget. */ DLine *dlPtr, /* Pointer to first in list of DLines to * search. */ const TkTextIndex *indexPtr)/* Index of desired character. */ { DLine *dlPtrPrev; TkTextIndex indexPtr2; if (dlPtr == NULL) { |
︙ | ︙ | |||
7045 7046 7047 7048 7049 7050 7051 | * the character nearest to (x,y). */ int *nearest) /* If non-NULL then gets set to 0 if (x,y) is * actually over the returned index, and 1 if * it is just nearby (e.g. if x,y is on the * border of the widget). */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; | | | 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 | * the character nearest to (x,y). */ int *nearest) /* If non-NULL then gets set to 0 if (x,y) is * actually over the returned index, and 1 if * it is just nearby (e.g. if x,y is on the * border of the widget). */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; DLine *dlPtr, *validDlPtr; int nearby = 0; /* * Make sure that all of the layout information about what's displayed * where on the screen is up-to-date. */ |
︙ | ︙ | |||
7147 7148 7149 7150 7151 7152 7153 | * line. */ int x, /* Pixel x coordinate of point in widget's * window. */ TkTextIndex *indexPtr) /* This index gets filled in with the index of * the character nearest to x. */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; | | | 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 | * line. */ int x, /* Pixel x coordinate of point in widget's * window. */ TkTextIndex *indexPtr) /* This index gets filled in with the index of * the character nearest to x. */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; TkTextDispChunk *chunkPtr; /* * Scan through the line's chunks to find the one that contains the * desired x-coordinate. Before doing this, translate the x-coordinate * from the coordinate system of the window to the coordinate system of * the line (to take account of x-scrolling). */ |
︙ | ︙ | |||
7275 7276 7277 7278 7279 7280 7281 | DlineXOfIndex( TkText *textPtr, /* Widget record for text widget. */ DLine *dlPtr, /* Display information for this display * line. */ int byteIndex) /* The byte index for which we want the * coordinate. */ { | | | 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 | DlineXOfIndex( TkText *textPtr, /* Widget record for text widget. */ DLine *dlPtr, /* Display information for this display * line. */ int byteIndex) /* The byte index for which we want the * coordinate. */ { TkTextDispChunk *chunkPtr = dlPtr->chunkPtr; int x = 0; if (byteIndex == 0 || chunkPtr == NULL) { return x; } /* |
︙ | ︙ | |||
7345 7346 7347 7348 7349 7350 7351 | int *charWidthPtr) /* If the 'index' is at the end of a display * line and therefore takes up a very large * width, this is used to return the smaller * width actually desired by the index. */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; DLine *dlPtr; | | | 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 | int *charWidthPtr) /* If the 'index' is at the end of a display * line and therefore takes up a very large * width, this is used to return the smaller * width actually desired by the index. */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; DLine *dlPtr; TkTextDispChunk *chunkPtr; int byteCount; /* * Make sure that all of the screen layout information is up to date. */ if (dInfoPtr->flags & DINFO_OUT_OF_DATE) { |
︙ | ︙ | |||
7537 7538 7539 7540 7541 7542 7543 | /* * Get bounding-box information about an elided chunk. */ static void ElideBboxProc( | | | | | | | | 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 | /* * Get bounding-box information about an elided chunk. */ static void ElideBboxProc( TCL_UNUSED(TkText *), TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */ TCL_UNUSED(int), /* Index of desired character within the * chunk. */ int y, /* Topmost pixel in area allocated for this * line. */ TCL_UNUSED(int), /* Height of line, in pixels. */ TCL_UNUSED(int), /* Location of line's baseline, in pixels * measured down from y. */ int *xPtr, int *yPtr, /* Gets filled in with coords of character's * upper-left pixel. X-coord is in same * coordinate system as chunkPtr->x. */ int *widthPtr, /* Gets filled in with width of character, in * pixels. */ int *heightPtr) /* Gets filled in with height of character, in * pixels. */ { *xPtr = chunkPtr->x; *yPtr = y; *widthPtr = *heightPtr = 0; } /* * Measure an elided chunk. */ static int ElideMeasureProc( TCL_UNUSED(TkTextDispChunk *), /* Chunk containing desired coord. */ TCL_UNUSED(int)) /* X-coordinate, in same coordinate system as * chunkPtr->x. */ { return 0 /*chunkPtr->numBytes - 1*/; } /* *-------------------------------------------------------------- |
︙ | ︙ | |||
7595 7596 7597 7598 7599 7600 7601 | * Memory is allocated to hold additional information about the chunk. * *-------------------------------------------------------------- */ int TkTextCharLayoutProc( | | | | | 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 | * Memory is allocated to hold additional information about the chunk. * *-------------------------------------------------------------- */ int TkTextCharLayoutProc( TCL_UNUSED(TkText *), /* Text widget being layed out. */ TCL_UNUSED(TkTextIndex *), /* Index of first character to lay out * (corresponds to segPtr and offset). */ TkTextSegment *segPtr, /* Segment being layed out. */ int byteOffset, /* Byte offset within segment of first * character to consider. */ int maxX, /* Chunk must not occupy pixels at this * position or higher. */ int maxBytes, /* Chunk must not include more than this many * characters. */ int noCharsYet, /* Non-zero means no characters have been * assigned to this display line yet. */ TkWrapMode wrapMode, /* How to handle line wrapping: * TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, or * TEXT_WRAPMODE_WORD. */ TkTextDispChunk *chunkPtr) /* Structure to fill in with information about * this chunk. The x field has already been * set by the caller. */ { Tk_Font tkfont; int nextX, bytesThatFit, count; CharInfo *ciPtr; |
︙ | ︙ | |||
7761 7762 7763 7764 7765 7766 7767 | chunkPtr->minAscent = fm.ascent + chunkPtr->stylePtr->sValuePtr->offset; chunkPtr->minDescent = fm.descent - chunkPtr->stylePtr->sValuePtr->offset; chunkPtr->minHeight = 0; chunkPtr->width = nextX - chunkPtr->x; chunkPtr->breakIndex = -1; #if !TK_LAYOUT_WITH_BASE_CHUNKS | | | | 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 | chunkPtr->minAscent = fm.ascent + chunkPtr->stylePtr->sValuePtr->offset; chunkPtr->minDescent = fm.descent - chunkPtr->stylePtr->sValuePtr->offset; chunkPtr->minHeight = 0; chunkPtr->width = nextX - chunkPtr->x; chunkPtr->breakIndex = -1; #if !TK_LAYOUT_WITH_BASE_CHUNKS ciPtr = (CharInfo *)ckalloc((Tk_Offset(CharInfo, chars) + 1) + bytesThatFit); chunkPtr->clientData = ciPtr; memcpy(ciPtr->chars, p, bytesThatFit); #endif /* TK_LAYOUT_WITH_BASE_CHUNKS */ ciPtr->numBytes = bytesThatFit; if (p[bytesThatFit - 1] == '\n') { ciPtr->numBytes--; } |
︙ | ︙ | |||
7874 7875 7876 7877 7878 7879 7880 | * for unlimited. */ int flags, /* Flags to pass to MeasureChars. */ int *nextXPtr) /* The function puts the newly calculated * right border x-position of the span * here. */ { Tk_Font tkfont = chunkPtr->stylePtr->sValuePtr->tkfont; | | | 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 | * for unlimited. */ int flags, /* Flags to pass to MeasureChars. */ int *nextXPtr) /* The function puts the newly calculated * right border x-position of the span * here. */ { Tk_Font tkfont = chunkPtr->stylePtr->sValuePtr->tkfont; CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData; #if !TK_LAYOUT_WITH_BASE_CHUNKS if (chars == NULL) { chars = ciPtr->chars; charsLen = ciPtr->numBytes; } if (end == -1) { |
︙ | ︙ | |||
7949 7950 7951 7952 7953 7954 7955 | * Graphics are drawn. * *-------------------------------------------------------------- */ static void CharDisplayProc( | | | | | | 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 | * Graphics are drawn. * *-------------------------------------------------------------- */ static void CharDisplayProc( TCL_UNUSED(TkText *), TkTextDispChunk *chunkPtr, /* Chunk that is to be drawn. */ int x, /* X-position in dst at which to draw this * chunk (may differ from the x-position in * the chunk because of scrolling). */ int y, /* Y-position at which to draw this chunk in * dst. */ TCL_UNUSED(int), /* Total height of line. */ int baseline, /* Offset of baseline from y. */ Display *display, /* Display to use for drawing. */ Drawable dst, /* Pixmap or window in which to draw chunk. */ TCL_UNUSED(int)) /* Y-coordinate in text window that * corresponds to y. */ { CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData; const char *string; TextStyle *stylePtr; StyleValues *sValuePtr; int numBytes, offsetBytes, offsetX; #if TK_DRAW_IN_CONTEXT BaseCharInfo *bciPtr; #endif /* TK_DRAW_IN_CONTEXT */ |
︙ | ︙ | |||
8111 8112 8113 8114 8115 8116 8117 | * Memory and other resources get freed. * *-------------------------------------------------------------- */ static void CharUndisplayProc( | | | | 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 | * Memory and other resources get freed. * *-------------------------------------------------------------- */ static void CharUndisplayProc( TCL_UNUSED(TkText *), /* Overall information about text widget. */ TkTextDispChunk *chunkPtr) /* Chunk that is about to be freed. */ { CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData; if (ciPtr) { #if TK_LAYOUT_WITH_BASE_CHUNKS if (chunkPtr == ciPtr->baseChunkPtr) { /* * Basechunks are undisplayed first, when DLines are freed or * partially freed, so this makes sure we don't access their data |
︙ | ︙ | |||
8200 8201 8202 8203 8204 8205 8206 | * None. * *-------------------------------------------------------------- */ static void CharBboxProc( | | | | | 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 | * None. * *-------------------------------------------------------------- */ static void CharBboxProc( TCL_UNUSED(TkText *), TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */ int byteIndex, /* Byte offset of desired character within the * chunk. */ int y, /* Topmost pixel in area allocated for this * line. */ TCL_UNUSED(int), /* Height of line, in pixels. */ int baseline, /* Location of line's baseline, in pixels * measured down from y. */ int *xPtr, int *yPtr, /* Gets filled in with coords of character's * upper-left pixel. X-coord is in same * coordinate system as chunkPtr->x. */ int *widthPtr, /* Gets filled in with width of character, in * pixels. */ int *heightPtr) /* Gets filled in with height of character, in * pixels. */ { CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData; int maxX; maxX = chunkPtr->width + chunkPtr->x; CharChunkMeasureChars(chunkPtr, NULL, 0, 0, byteIndex, chunkPtr->x, -1, 0, xPtr); if (byteIndex == ciPtr->numBytes) { |
︙ | ︙ | |||
8380 8381 8382 8383 8384 8385 8386 | decimalChunkPtr = NULL; decimal = gotDigit = 0; for (chunkPtr2 = chunkPtr->nextPtr; chunkPtr2 != NULL; chunkPtr2 = chunkPtr2->nextPtr) { if (chunkPtr2->displayProc != CharDisplayProc) { continue; } | | | | 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 | decimalChunkPtr = NULL; decimal = gotDigit = 0; for (chunkPtr2 = chunkPtr->nextPtr; chunkPtr2 != NULL; chunkPtr2 = chunkPtr2->nextPtr) { if (chunkPtr2->displayProc != CharDisplayProc) { continue; } ciPtr = (CharInfo *)chunkPtr2->clientData; for (p = ciPtr->chars, i = 0; i < ciPtr->numBytes; p++, i++) { if (isdigit(UCHAR(*p))) { gotDigit = 1; } else if ((*p == '.') || (*p == ',')) { decimal = p-ciPtr->chars; decimalChunkPtr = chunkPtr2; } else if (gotDigit) { if (decimalChunkPtr == NULL) { decimal = p-ciPtr->chars; decimalChunkPtr = chunkPtr2; } goto endOfNumber; } } } endOfNumber: if (decimalChunkPtr != NULL) { int curX; ciPtr = (CharInfo *)decimalChunkPtr->clientData; CharChunkMeasureChars(decimalChunkPtr, NULL, 0, 0, decimal, decimalChunkPtr->x, -1, 0, &curX); desired = tabX - (curX - x); goto update; } /* |
︙ | ︙ | |||
8672 8673 8674 8675 8676 8677 8678 | int flags, /* Flags to pass to Tk_MeasureChars. */ int *nextXPtr) /* Return x-position of terminating character * here. */ { int curX, width, ch; const char *special, *end, *start; | | | 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 | int flags, /* Flags to pass to Tk_MeasureChars. */ int *nextXPtr) /* Return x-position of terminating character * here. */ { int curX, width, ch; const char *special, *end, *start; ch = 0; curX = startX; start = source + rangeStart; end = start + rangeLength; special = start; while (start < end) { if (start >= special) { /* |
︙ | ︙ |
Changes to generic/ttk/ttkManager.c.
︙ | ︙ | |||
459 460 461 462 463 464 465 | Tcl_SetErrorCode(interp, "TTK", "SLAVE", "INDEX", NULL); return TCL_ERROR; } *indexPtr = index; return TCL_OK; } | | | 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | Tcl_SetErrorCode(interp, "TTK", "SLAVE", "INDEX", NULL); return TCL_ERROR; } *indexPtr = index; return TCL_OK; } /* Try interpreting as a window name; */ if ((*string == '.') && (tkwin = Tk_NameToWindow(interp, string, mgr->window))) { index = Ttk_ContentIndex(mgr, tkwin); if (index < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s is not managed by %s", string, |
︙ | ︙ | |||
501 502 503 504 505 506 507 | while (fromIndex < toIndex) { mgr->content[fromIndex] = mgr->content[fromIndex + 1]; ++fromIndex; } /* ASSERT: fromIndex == toIndex */ mgr->content[fromIndex] = moved; | | | | | | | | | | | | | 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 | while (fromIndex < toIndex) { mgr->content[fromIndex] = mgr->content[fromIndex + 1]; ++fromIndex; } /* ASSERT: fromIndex == toIndex */ mgr->content[fromIndex] = moved; /* Schedule a relayout. In general, rearranging content * may also change the size: */ ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED); } /* ++ Ttk_Maintainable(interp, window, container) -- * Utility routine. Verifies that 'container' may be used to maintain * the geometry of 'window' via Tk_MaintainGeometry: * * + 'container' is either 'window's parent -OR- * + 'container is a descendant of 'window's parent. * + 'window' is not a toplevel window * + 'window' belongs to the same toplevel as 'container' * * Returns: 1 if OK; otherwise 0, leaving an error message in 'interp'. */ int Ttk_Maintainable(Tcl_Interp *interp, Tk_Window window, Tk_Window container) { Tk_Window ancestor = container, parent = Tk_Parent(window); if (Tk_IsTopLevel(window) || window == container) { goto badWindow; } while (ancestor != parent) { if (Tk_IsTopLevel(ancestor)) { goto badWindow; } ancestor = Tk_Parent(ancestor); } return 1; badWindow: Tcl_SetObjResult(interp, Tcl_ObjPrintf("can't add %s as slave of %s", Tk_PathName(window), Tk_PathName(container))); Tcl_SetErrorCode(interp, "TTK", "GEOMETRY", "MAINTAINABLE", NULL); return 0; } |
Changes to macosx/tkMacOSXInit.c.
︙ | ︙ | |||
318 319 320 321 322 323 324 | * Since it is possible for TkInit to be called multiple times and we * don't want to do the following initialization multiple times we protect * against doing it more than once. */ if (!initialized) { struct stat st; | < | 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | * Since it is possible for TkInit to be called multiple times and we * don't want to do the following initialization multiple times we protect * against doing it more than once. */ if (!initialized) { struct stat st; initialized = 1; /* * Initialize/check OS version variable for runtime checks. */ #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 |
︙ | ︙ | |||
373 374 375 376 377 378 379 | @"NSStringDrawingTypesetterBehavior", nil]]; [TKApplication sharedApplication]; [pool drain]; [NSApp _setup:interp]; /* | | < | | | | | | > | | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | @"NSStringDrawingTypesetterBehavior", nil]]; [TKApplication sharedApplication]; [pool drain]; [NSApp _setup:interp]; /* * WARNING: The finishLaunching method runs asynchronously. This * creates a race between the initialization of the NSApplication and * the initialization of Tk. If Tk wins the race bad things happen * with the root window (see below). If the NSApplication wins then an * AppleEvent created during launch, e.g. by dropping a file icon on * the application icon, will be delivered before the procedure meant * to to handle the AppleEvent has been defined. This is now handled * by processing the AppleEvent as an idle task. See * tkMacOSXHLEvents.c. */ [NSApp finishLaunching]; /* * Create a Tk event source based on the Appkit event queue. */ |
︙ | ︙ | |||
410 411 412 413 414 415 416 | * NSApplication initialization wins the race, avoiding these bad * window behaviors. */ Tcl_DoOneEvent(TCL_WINDOW_EVENTS | TCL_DONT_WAIT); /* | | > | < < | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > | 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | * NSApplication initialization wins the race, avoiding these bad * window behaviors. */ Tcl_DoOneEvent(TCL_WINDOW_EVENTS | TCL_DONT_WAIT); /* * If we don't have a TTY or stdin is a special character file of * length 0, (e.g. /dev/null, which is what Finder sets when double * clicking Wish) then use the Tk based console interpreter. */ if (!isatty(0) && (fstat(0, &st) || (S_ISCHR(st.st_mode) && st.st_blocks == 0))) { if (getenv("TK_CONSOLE")) { Tk_InitConsoleChannels(interp); Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDIN)); Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDOUT)); Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDERR)); /* * Only show the console if we don't have a startup script and * tcl_interactive hasn't been set already. */ if (Tcl_GetStartupScript(NULL) == NULL) { const char *intvar = Tcl_GetVar2(interp, "tcl_interactive", NULL, TCL_GLOBAL_ONLY); if (intvar == NULL) { Tcl_SetVar2(interp, "tcl_interactive", NULL, "1", TCL_GLOBAL_ONLY); } } if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) { return TCL_ERROR; } } else { /* * When launched as a macOS application with no console, * redirect stderr and stdout to /dev/null. This avoids waiting * forever for those files to become writable if the underlying * Tcl program tries to write to them with a puts command. */ FILE *null = fopen("/dev/null", "w"); dup2(fileno(null), STDOUT_FILENO); dup2(fileno(null), STDERR_FILENO); } } /* * Now we can run initialization routines which require that both the * NSApplication and the Tcl interpreter have been created and * initialized. |
︙ | ︙ | |||
469 470 471 472 473 474 475 476 477 478 479 480 481 482 | TkMacOSXStandardAboutPanelObjCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap", TkMacOSXIconBitmapObjCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath", TkMacOSXGetAppPathCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "::tk::mac::macOSVersion", TkMacOSVersionObjCmd, NULL, NULL); return TCL_OK; } /* *---------------------------------------------------------------------- * * TkpGetAppName -- | > > > > > > > > > > > > | 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 | TkMacOSXStandardAboutPanelObjCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap", TkMacOSXIconBitmapObjCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath", TkMacOSXGetAppPathCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "::tk::mac::macOSVersion", TkMacOSVersionObjCmd, NULL, NULL); /* * The root window has been created and mapped, but XMapWindow deferred its * call to makeKeyAndOrderFront because the first call to XMapWindow * occurs too early in the initialization process for that. Process idle * tasks now, so the root window is configured, then order it front. */ while(Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}; for (NSWindow *window in [NSApp windows]) { [window makeKeyAndOrderFront:NSApp]; } return TCL_OK; } /* *---------------------------------------------------------------------- * * TkpGetAppName -- |
︙ | ︙ |
Changes to macosx/tkMacOSXMenu.c.
︙ | ︙ | |||
1161 1162 1163 1164 1165 1166 1167 | return; } for (TkMenuEntry *cascadeEntryPtr = menuPtr->menuRefPtr->parentEntryPtr; cascadeEntryPtr; cascadeEntryPtr = cascadeEntryPtr->nextCascadePtr) { if (cascadeEntryPtr->menuPtr->menuType == MENUBAR && cascadeEntryPtr->menuPtr->masterMenuPtr->tkwin) { | | | | 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 | return; } for (TkMenuEntry *cascadeEntryPtr = menuPtr->menuRefPtr->parentEntryPtr; cascadeEntryPtr; cascadeEntryPtr = cascadeEntryPtr->nextCascadePtr) { if (cascadeEntryPtr->menuPtr->menuType == MENUBAR && cascadeEntryPtr->menuPtr->masterMenuPtr->tkwin) { TkMenu *mainMenuPtr = cascadeEntryPtr->menuPtr->masterMenuPtr; int i = 0; Tcl_DString ds; Tcl_DStringInit(&ds); Tcl_DStringAppend(&ds, Tk_PathName(mainMenuPtr->tkwin), -1); while (specialMenus[i].name) { Tcl_DStringAppend(&ds, specialMenus[i].name, specialMenus[i].len); if (strcmp(Tcl_DStringValue(&ds), Tk_PathName(menuPtr->masterMenuPtr->tkwin)) == 0) { cascadeEntryPtr->entryFlags |= specialMenus[i].flag; } else { |
︙ | ︙ |
Changes to macosx/tkMacOSXSubwindows.c.
︙ | ︙ | |||
139 140 141 142 143 144 145 146 147 148 149 150 151 152 | if (!window) { return BadWindow; } MacDrawable *macWin = (MacDrawable *)window; TkWindow *winPtr = macWin->winPtr; NSWindow *win = TkMacOSXGetNSWindowForDrawable(window); XEvent event; /* * Under certain situations it's possible for this function to be called * before the toplevel window it's associated with has actually been * mapped. In that case we need to create the real Macintosh window now as * this function as well as other X functions assume that the portPtr is * valid. | > | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | if (!window) { return BadWindow; } MacDrawable *macWin = (MacDrawable *)window; TkWindow *winPtr = macWin->winPtr; NSWindow *win = TkMacOSXGetNSWindowForDrawable(window); XEvent event; static Bool initialized = NO; /* * Under certain situations it's possible for this function to be called * before the toplevel window it's associated with has actually been * mapped. In that case we need to create the real Macintosh window now as * this function as well as other X functions assume that the portPtr is * valid. |
︙ | ︙ | |||
168 169 170 171 172 173 174 | * root window is mapped before applicationDidFinishLaunching * returns. Forcing the app to activate too early can make the menu * bar unresponsive. */ TkMacOSXApplyWindowAttributes(winPtr, win); [win setExcludedFromWindowsMenu:NO]; | | > | | | | > | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | * root window is mapped before applicationDidFinishLaunching * returns. Forcing the app to activate too early can make the menu * bar unresponsive. */ TkMacOSXApplyWindowAttributes(winPtr, win); [win setExcludedFromWindowsMenu:NO]; [NSApp activateIgnoringOtherApps:initialized]; [view addTkDirtyRect: [view bounds]]; if (initialized) { if ([win canBecomeKeyWindow]) { [win makeKeyAndOrderFront:NSApp]; } else { [win orderFrontRegardless]; } } } else { TkWindow *contWinPtr = TkpGetOtherWindow(winPtr); /* * Rebuild the container's clipping region and display * the window. |
︙ | ︙ | |||
229 230 231 232 233 234 235 | [view addTkDirtyRect:[view bounds]]; } /* * Generate VisibilityNotify events for window and all mapped children. */ | > | | | | | > > > | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | [view addTkDirtyRect:[view bounds]]; } /* * Generate VisibilityNotify events for window and all mapped children. */ if (initialized) { event.xany.send_event = False; event.xany.display = display; event.xvisibility.type = VisibilityNotify; event.xvisibility.state = VisibilityUnobscured; NotifyVisibility(winPtr, &event); } else { initialized = YES; } return Success; } /* *---------------------------------------------------------------------- * * NotifyVisibility -- |
︙ | ︙ |
Changes to macosx/tkMacOSXWm.c.
︙ | ︙ | |||
670 671 672 673 674 675 676 | { WmInfo *wmPtr = (WmInfo *)ckalloc(sizeof(WmInfo)); wmPtr->winPtr = winPtr; wmPtr->reparent = None; wmPtr->titleUid = NULL; wmPtr->iconName = NULL; | | | 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 | { WmInfo *wmPtr = (WmInfo *)ckalloc(sizeof(WmInfo)); wmPtr->winPtr = winPtr; wmPtr->reparent = None; wmPtr->titleUid = NULL; wmPtr->iconName = NULL; wmPtr->container = NULL; wmPtr->hints.flags = InputHint | StateHint; wmPtr->hints.input = True; wmPtr->hints.initial_state = NormalState; wmPtr->hints.icon_pixmap = None; wmPtr->hints.icon_window = None; wmPtr->hints.icon_x = wmPtr->hints.icon_y = 0; wmPtr->hints.icon_mask = None; |
︙ | ︙ | |||
946 947 948 949 950 951 952 | for (Transient *transientPtr = wmPtr->transientPtr; transientPtr != NULL; transientPtr = transientPtr->nextPtr) { TkWindow *winPtr2 = transientPtr->winPtr; TkWindow *containerPtr = (TkWindow *)TkGetTransientMaster(winPtr2); if (containerPtr == winPtr) { wmPtr2 = winPtr2->wmInfoPtr; | | | 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 | for (Transient *transientPtr = wmPtr->transientPtr; transientPtr != NULL; transientPtr = transientPtr->nextPtr) { TkWindow *winPtr2 = transientPtr->winPtr; TkWindow *containerPtr = (TkWindow *)TkGetTransientMaster(winPtr2); if (containerPtr == winPtr) { wmPtr2 = winPtr2->wmInfoPtr; wmPtr2->container = NULL; } } while (wmPtr->transientPtr != NULL) { Transient *transientPtr = wmPtr->transientPtr; wmPtr->transientPtr = transientPtr->nextPtr; |
︙ | ︙ | |||
1823 1824 1825 1826 1827 1828 1829 | return TCL_ERROR; } TkpWmSetState(winPtr, TkMacOSXIsWindowZoomed(winPtr) ? ZoomState : NormalState); [win setExcludedFromWindowsMenu:NO]; TkMacOSXApplyWindowAttributes(winPtr, win); | | | 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 | return TCL_ERROR; } TkpWmSetState(winPtr, TkMacOSXIsWindowZoomed(winPtr) ? ZoomState : NormalState); [win setExcludedFromWindowsMenu:NO]; TkMacOSXApplyWindowAttributes(winPtr, win); [win orderFront:NSApp]; if (wmPtr->icon) { Tk_UnmapWindow((Tk_Window)wmPtr->icon); } /* * If this window has a transient, the transient must also be deiconified if * it was withdrawn by the container. |
︙ | ︙ | |||
2349 2350 2351 2352 2353 2354 2355 | if (Tk_Attributes((Tk_Window)winPtr)->override_redirect) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": override-redirect flag is set", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; | | | 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 | if (Tk_Attributes((Tk_Window)winPtr)->override_redirect) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": override-redirect flag is set", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } else if (wmPtr->container != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": it is a transient", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "TRANSIENT", NULL); return TCL_ERROR; } else if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify %s: it is an icon for %s", |
︙ | ︙ | |||
3489 3490 3491 3492 3493 3494 3495 | Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": override-redirect flag is set", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } | | | 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 | Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": override-redirect flag is set", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } if (wmPtr->container != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": it is a transient", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "TRANSIENT", NULL); return TCL_ERROR; } |
︙ | ︙ | |||
3616 3617 3618 3619 3620 3621 3622 | Transient *transient; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?master?"); return TCL_ERROR; } if (objc == 3) { | | | | 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 | Transient *transient; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?master?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->container != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(wmPtr->container), -1)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { RemoveTransient(winPtr); } else { if (TkGetWindowFromObj(interp, tkwin, objv[3], &container) != TCL_OK) { |
︙ | ︙ | |||
3661 3662 3663 3664 3665 3666 3667 | "can't make \"%s\" a master: it is an icon for %s", Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL); return TCL_ERROR; } for (w = containerPtr; w != NULL && w->wmInfoPtr != NULL; | | | 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 | "can't make \"%s\" a master: it is an icon for %s", Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL); return TCL_ERROR; } for (w = containerPtr; w != NULL && w->wmInfoPtr != NULL; w = (TkWindow *)w->wmInfoPtr->container) { if (w == winPtr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "setting \"%s\" as master creates a transient/master cycle", Tk_PathName(containerPtr))); Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL); return TCL_ERROR; } |
︙ | ︙ | |||
3697 3698 3699 3700 3701 3702 3703 | if ((wmPtr2->hints.initial_state == WithdrawnState || wmPtr2->hints.initial_state == IconicState) && wmPtr->hints.initial_state != WithdrawnState) { TkpWmSetState(winPtr, WithdrawnState); transient->flags |= WITHDRAWN_BY_CONTAINER; } | | | 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 | if ((wmPtr2->hints.initial_state == WithdrawnState || wmPtr2->hints.initial_state == IconicState) && wmPtr->hints.initial_state != WithdrawnState) { TkpWmSetState(winPtr, WithdrawnState); transient->flags |= WITHDRAWN_BY_CONTAINER; } wmPtr->container = (Tk_Window)containerPtr; } ApplyContainerOverrideChanges(winPtr, NULL); return TCL_OK; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
3730 3731 3732 3733 3734 3735 3736 | RemoveTransient( TkWindow *winPtr) { WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2; TkWindow *containerPtr; Transient *transPtr, *temp; | | | | | 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 | RemoveTransient( TkWindow *winPtr) { WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2; TkWindow *containerPtr; Transient *transPtr, *temp; if (wmPtr == NULL || wmPtr->container == NULL) { return; } containerPtr = (TkWindow *)wmPtr->container; wmPtr2 = containerPtr->wmInfoPtr; if (wmPtr2 == NULL) { return; } wmPtr->container= NULL; transPtr = wmPtr2->transientPtr; while (transPtr != NULL) { if (transPtr->winPtr != winPtr) { break; } temp = transPtr->nextPtr; ckfree(transPtr); |
︙ | ︙ | |||
5371 5372 5373 5374 5375 5376 5377 | */ Tk_Window TkGetTransientMaster( TkWindow *winPtr) { if (winPtr->wmInfoPtr != NULL) { | | | 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 | */ Tk_Window TkGetTransientMaster( TkWindow *winPtr) { if (winPtr->wmInfoPtr != NULL) { return (Tk_Window)winPtr->wmInfoPtr->container; } return NULL; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 | NSNonactivatingPanelMask|NSHUDWindowMask)) ? [TKPanel class] : [TKWindow class]); NSRect structureRect = [winClass frameRectForContentRect:NSZeroRect styleMask:styleMask]; NSRect contentRect = NSMakeRect(5 - structureRect.origin.x, TkMacOSXZeroScreenHeight() - (TkMacOSXZeroScreenTop() + 5 + structureRect.origin.y + structureRect.size.height + 200), 200, 200); TKWindow *window = [[winClass alloc] initWithContentRect:contentRect styleMask:styleMask backing:NSBackingStoreBuffered defer:YES]; if (!window) { Tcl_Panic("couldn't allocate new Mac window"); } TKContentView *contentView = [[TKContentView alloc] initWithFrame:NSZeroRect]; | > > | 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 | NSNonactivatingPanelMask|NSHUDWindowMask)) ? [TKPanel class] : [TKWindow class]); NSRect structureRect = [winClass frameRectForContentRect:NSZeroRect styleMask:styleMask]; NSRect contentRect = NSMakeRect(5 - structureRect.origin.x, TkMacOSXZeroScreenHeight() - (TkMacOSXZeroScreenTop() + 5 + structureRect.origin.y + structureRect.size.height + 200), 200, 200); if (wmPtr->hints.initial_state == WithdrawnState) { } TKWindow *window = [[winClass alloc] initWithContentRect:contentRect styleMask:styleMask backing:NSBackingStoreBuffered defer:YES]; if (!window) { Tcl_Panic("couldn't allocate new Mac window"); } TKContentView *contentView = [[TKContentView alloc] initWithFrame:NSZeroRect]; |
︙ | ︙ | |||
6643 6644 6645 6646 6647 6648 6649 | TkMacOSXApplyWindowAttributes( TkWindow *winPtr, NSWindow *macWindow) { WmInfo *wmPtr = winPtr->wmInfoPtr; ApplyWindowAttributeFlagChanges(winPtr, macWindow, 0, 0, 0, 1); | | | 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 | TkMacOSXApplyWindowAttributes( TkWindow *winPtr, NSWindow *macWindow) { WmInfo *wmPtr = winPtr->wmInfoPtr; ApplyWindowAttributeFlagChanges(winPtr, macWindow, 0, 0, 0, 1); if (wmPtr->container != NULL || winPtr->atts.override_redirect) { ApplyContainerOverrideChanges(winPtr, macWindow); } } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
6777 6778 6779 6780 6781 6782 6783 | if (!(macWindow.styleMask & NSUtilityWindowMask)) { /* * Exclude overrideredirect, transient, and "help"-styled * windows from moving into their own fullscreen space. */ if ((winPtr->atts.override_redirect) || | | | 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 | if (!(macWindow.styleMask & NSUtilityWindowMask)) { /* * Exclude overrideredirect, transient, and "help"-styled * windows from moving into their own fullscreen space. */ if ((winPtr->atts.override_redirect) || (wmPtr->container != NULL) || (winPtr->wmInfoPtr->macClass == kHelpWindowClass)) { b |= (NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorFullScreenAuxiliary); } else { b |= NSWindowCollectionBehaviorFullScreenPrimary; /* |
︙ | ︙ | |||
6885 6886 6887 6888 6889 6890 6891 | if ([NSApp macOSVersion] == 100600) { styleMask = 0; } else { styleMask &= ~NSTitledWindowMask; } } else { if (wmPtr->macClass == kSimpleWindowClass && | | | 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 | if ([NSApp macOSVersion] == 100600) { styleMask = 0; } else { styleMask &= ~NSTitledWindowMask; } } else { if (wmPtr->macClass == kSimpleWindowClass && (oldAttributes & kWindowNoActivatesAttribute)) { wmPtr->macClass = kDocumentWindowClass; wmPtr->attributes = macClassAttrs[kDocumentWindowClass].defaultAttrs; } wmPtr->attributes &= ~kWindowNoActivatesAttribute; if ([NSApp macOSVersion] == 100600) { styleMask = NSTitledWindowMask | |
︙ | ︙ | |||
6917 6918 6919 6920 6921 6922 6923 | wmPtr->yInParent = structureRect.origin.y + structureRect.size.height; wmPtr->parentWidth = winPtr->changes.width + structureRect.size.width; wmPtr->parentHeight = winPtr->changes.height + structureRect.size.height; if (winPtr->atts.override_redirect) { [macWindow setExcludedFromWindowsMenu:YES]; [macWindow setStyleMask:styleMask]; if (wmPtr->hints.initial_state == NormalState) { | | | | | | 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 | wmPtr->yInParent = structureRect.origin.y + structureRect.size.height; wmPtr->parentWidth = winPtr->changes.width + structureRect.size.width; wmPtr->parentHeight = winPtr->changes.height + structureRect.size.height; if (winPtr->atts.override_redirect) { [macWindow setExcludedFromWindowsMenu:YES]; [macWindow setStyleMask:styleMask]; if (wmPtr->hints.initial_state == NormalState) { [macWindow orderFront:NSApp]; } if (wmPtr->container != NULL) { wmPtr->flags |= WM_TOPMOST; } else { wmPtr->flags &= ~WM_TOPMOST; } } else { const char *title = winPtr->wmInfoPtr->titleUid; if (!title) { title = winPtr->nameUid; } [macWindow setStyleMask:styleMask]; [macWindow setTitle:[NSString stringWithUTF8String:title]]; [macWindow setExcludedFromWindowsMenu:NO]; wmPtr->flags &= ~WM_TOPMOST; } if (wmPtr->container != None) { TkWindow *containerWinPtr = (TkWindow *)wmPtr->container; if (containerWinPtr && (containerWinPtr->window != None) && TkMacOSXHostToplevelExists(containerWinPtr)) { NSWindow *containerMacWin = TkMacOSXGetNSWindowForDrawable( containerWinPtr->window); /* |
︙ | ︙ |
Changes to macosx/tkMacOSXWm.h.
︙ | ︙ | |||
62 63 64 65 66 67 68 | * that is a child of the root window (may not * be window's immediate parent). If the window * isn't reparented, this has the value * None. */ Tk_Uid titleUid; /* Title to display in window caption. If NULL, * use name of widget. */ char *iconName; /* Name to display in icon. */ | | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | * that is a child of the root window (may not * be window's immediate parent). If the window * isn't reparented, this has the value * None. */ Tk_Uid titleUid; /* Title to display in window caption. If NULL, * use name of widget. */ char *iconName; /* Name to display in icon. */ Tk_Window container; /* Container window for TRANSIENT_FOR property, * or None. */ XWMHints hints; /* Various pieces of information for window * manager. */ char *leaderName; /* Path name of leader of window group * (corresponds to hints.window_group). * Malloc-ed. Note: this field doesn't get * updated if leader is destroyed. */ |
︙ | ︙ |
Changes to macosx/ttkMacOSXTheme.c.
︙ | ︙ | |||
389 390 391 392 393 394 395 | CGRect bounds, CGFloat radius, CGColorRef color) { CGPathRef path; CHECK_RADIUS(radius, bounds) | < > > > > | 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | CGRect bounds, CGFloat radius, CGColorRef color) { CGPathRef path; CHECK_RADIUS(radius, bounds) path = CGPathCreateWithRoundedRect(bounds, radius, radius, NULL); if (!path) { return; } CGContextSetFillColorWithColor(context, color); CGContextBeginPath(context); CGContextAddPath(context, path); CGContextFillPath(context); CFRelease(path); } /*---------------------------------------------------------------------- |
︙ | ︙ |
Changes to tests/safe.test.
︙ | ︙ | |||
195 196 197 198 199 200 201 | } -result {} test safe-5.1 {loading Tk in safe interps without parent's clearance} -body { set i [safe::interpCreate] interp eval $i {load {} Tk} } -cleanup { safe::interpDelete $i | | | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | } -result {} test safe-5.1 {loading Tk in safe interps without parent's clearance} -body { set i [safe::interpCreate] interp eval $i {load {} Tk} } -cleanup { safe::interpDelete $i } -returnCodes error -match glob -result {*not allowed} test safe-5.2 {multi-level Tk loading with clearance} -setup { set safeParent [safe::interpCreate] } -body { # No error shall occur in that test and no window shall remain at the end. set i [safe::interpCreate [list $safeParent x]] safe::loadTk $i interp eval $i { |
︙ | ︙ |
Changes to tests/ttk/combobox.test.
︙ | ︙ | |||
34 35 36 37 38 39 40 | } -result 2 test combobox-2.3 "current -- change value" -body { .cb set "b" .cb current } -result 1 | | | | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | } -result 2 test combobox-2.3 "current -- change value" -body { .cb set "b" .cb current } -result 1 test combobox-2.4 "current -- value not in list" -body { .cb set "z" .cb current } -result -1 test combobox-2.5 "current -- set to end index" -body { .cb configure -values [list a b c d e thelastone] .cb current end .cb get } -result thelastone test combobox-2.6 "current -- set to unknown index" -body { .cb configure -values [list a b c d e] .cb current notanindex } -returnCodes error -result {Incorrect index notanindex} test combobox-2.end "Cleanup" -body { destroy .cb } test combobox-3 "Read postoffset value dynamically from current style" -body { ttk::combobox .cb -values [list a b c] -style "DerivedStyle.TCombobox" pack .cb -expand true -fill both ttk::style configure DerivedStyle.TCombobox -postoffset [list 25 0 0 0] ttk::combobox::Post .cb expr {[winfo rootx .cb.popdown] - [winfo rootx .cb]} } -result 25 -cleanup { destroy .cb } |
︙ | ︙ |
Changes to tests/ttk/image.test.
︙ | ︙ | |||
19 20 21 22 23 24 25 | pack [set w [ttk::label .ttk_image20 -image test.image]] tkwait visibility $w image delete test.image update } -cleanup { destroy .ttk_image20 } -result {} | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | pack [set w [ttk::label .ttk_image20 -image test.image]] tkwait visibility $w image delete test.image update } -cleanup { destroy .ttk_image20 } -result {} test image-2.1 "Deletion of displayed image (checkbutton)" -setup { image create photo test.image -width 10 -height 10 } -body { pack [set w [ttk::checkbutton .ttk_image21 -image test.image]] tkwait visibility $w image delete test.image update |
︙ | ︙ |
Changes to tests/ttk/panedwindow.test.
︙ | ︙ | |||
106 107 108 109 110 111 112 | test panedwindow-2.end "Cleanup" -body { destroy .pw } # # ... # test panedwindow-3.0 "configure pane" -body { ttk::panedwindow .pw | | | | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | test panedwindow-2.end "Cleanup" -body { destroy .pw } # # ... # test panedwindow-3.0 "configure pane" -body { ttk::panedwindow .pw .pw add [listbox .pw.lb1] .pw add [listbox .pw.lb2] .pw pane 1 -weight 2 .pw pane 1 -weight } -result 2 test panedwindow-3.1 "configure pane -- errors" -body { .pw pane 1 -weight -4 } -returnCodes 1 -match glob -result "-weight must be nonnegative" |
︙ | ︙ | |||
249 250 251 252 253 254 255 | wm geometry . {} ttk::panedwindow .pw -orient vertical frame .pw.f1 -width 100 -height 50 frame .pw.f2 -width 100 -height 50 list [winfo reqwidth .pw.f1] [winfo reqheight .pw.f1] | | | 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | wm geometry . {} ttk::panedwindow .pw -orient vertical frame .pw.f1 -width 100 -height 50 frame .pw.f2 -width 100 -height 50 list [winfo reqwidth .pw.f1] [winfo reqheight .pw.f1] } -result [list 100 50] test paned-propagation-1 "Initial request size" -body { .pw add .pw.f1 .pw add .pw.f2 propagate-geometry list [winfo reqwidth .pw] [winfo reqheight .pw] } -result [list 100 105] |
︙ | ︙ |
Changes to tests/ttk/scrollbar.test.
︙ | ︙ | |||
14 15 16 17 18 19 20 | test scrollbar-swapout-1 "Don't use core scrollbars on OSX..." \ -constraints { coreScrollbar } -body { ttk::scrollbar .sb -command "yadda" list [winfo class .sb] [.sb cget -command] | | | | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | test scrollbar-swapout-1 "Don't use core scrollbars on OSX..." \ -constraints { coreScrollbar } -body { ttk::scrollbar .sb -command "yadda" list [winfo class .sb] [.sb cget -command] } -result [list TScrollbar yadda] -cleanup { destroy .sb } test scrollbar-swapout-2 "... regardless of whether -style ..." \ -constraints { coreScrollbar } -body { ttk::style layout Vertical.Custom.TScrollbar \ [ttk::style layout Vertical.TScrollbar] ; # See #1833339 ttk::scrollbar .sb -command "yadda" -style Custom.TScrollbar list [winfo class .sb] [.sb cget -command] [.sb cget -style] } -result [list TScrollbar yadda Custom.TScrollbar] -cleanup { destroy .sb } test scrollbar-swapout-3 "... or -class is specified." -constraints { coreScrollbar } -body { ttk::scrollbar .sb -command "yadda" -class Custom.TScrollbar list [winfo class .sb] [.sb cget -command] } -result [list Custom.TScrollbar yadda] -cleanup { destroy .sb } test scrollbar-1.0 "Setup" -body { ttk::scrollbar .tsb |
︙ | ︙ |
Changes to tests/ttk/treetags.test.
︙ | ︙ | |||
101 102 103 104 105 106 107 | } -result [list [list] [list item2] [list]] test treetags-1.8 "tag names" -body { lsort [$tv tag names] } -result [list tag1 tag2 tag3] test treetags-1.9 "tag names - tag added to item" -body { | | | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | } -result [list [list] [list item2] [list]] test treetags-1.8 "tag names" -body { lsort [$tv tag names] } -result [list tag1 tag2 tag3] test treetags-1.9 "tag names - tag added to item" -body { $tv item item1 -tags tag4 lsort [$tv tag names] } -result [list tag1 tag2 tag3 tag4] test treetags-1.10 "tag names - tag configured" -body { $tv tag configure tag5 lsort [$tv tag names] } -result [list tag1 tag2 tag3 tag4 tag5] |
︙ | ︙ | |||
197 198 199 200 201 202 203 | $tv tag configure tag2 -font {times 20} } test treetags-3.4 "stomp tags in tag binding procedure" -body { set result [list] $tv tag bind rm1 <<Remove>> { lappend ::result rm1 [%W focus] <<Remove>> } $tv tag bind rm2 <<Remove>> { | | | | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | $tv tag configure tag2 -font {times 20} } test treetags-3.4 "stomp tags in tag binding procedure" -body { set result [list] $tv tag bind rm1 <<Remove>> { lappend ::result rm1 [%W focus] <<Remove>> } $tv tag bind rm2 <<Remove>> { lappend ::result rm2 [%W focus] <<Remove>> %W item [%W focus] -tags {tag1} } $tv tag bind rm3 <<Remove>> { lappend ::result rm3 [%W focus] <<Remove>> } $tv item item1 -tags {rm1 rm2 rm3} $tv focus item1 event generate $tv <<Remove>> set result } -cleanup { treeConstraints $tv } -result [list rm1 item1 <<Remove>> rm2 item1 <<Remove>> rm3 item1 <<Remove>>] # test treetags-end "Cleanup" -body { destroy $tv } tcltest::cleanupTests |
Changes to tests/ttk/treeview.test.
︙ | ︙ | |||
725 726 727 728 729 730 731 | .tv item $item -tags } -cleanup { destroy .tv } -result [list] test treeview-368fa4561e "indicators cannot be clicked on leafs" -setup { pack [ttk::treeview .tv] | | | | 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 | .tv item $item -tags } -cleanup { destroy .tv } -result [list] test treeview-368fa4561e "indicators cannot be clicked on leafs" -setup { pack [ttk::treeview .tv] .tv insert {} end -id foo -text "<-- (1) Click the blank space to my left" update } -body { foreach {x y w h} [.tv bbox foo #0] {} set res [.tv item foo -open] # using $h even for x computation is intentional here in order to simulate # a mouse click on the (invisible since we're on a leaf) indicator event generate .tv <ButtonPress-1> \ -x [expr {$x + $h / 2}] \ -y [expr {$y + $h / 2}] lappend res [.tv item foo -open] .tv insert foo end -text "sub" lappend res [.tv item foo -open] } -cleanup { destroy .tv } -result {0 0 0} test treeview-ce470f20fd-1 "dragging further than the right edge of the treeview is allowed" -setup { pack [ttk::treeview .tv] .tv heading #0 -text "Drag my right edge -->" update } -body { set res [.tv column #0 -width] .tv drag #0 400 lappend res [expr {[.tv column #0 -width] > $res}] } -cleanup { destroy .tv |
︙ | ︙ | |||
814 815 816 817 818 819 820 | } .tv configure -displaycolumns {colB colA colC} nostretch .tv .tv column colA -width 50 ; .tv column bar -width 60 ; # slack created update idletasks ; # redisplay treeview } -body { # only some columns are displayed (and in a different order than declared | | | 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 | } .tv configure -displaycolumns {colB colA colC} nostretch .tv .tv column colA -width 50 ; .tv column bar -width 60 ; # slack created update idletasks ; # redisplay treeview } -body { # only some columns are displayed (and in a different order than declared # in -columns), a non-displayed column becomes stretchable --> nothing # happens set origTreeWidth [winfo width .tv] set res [list [.tv column bar -width] [.tv column colA -width]] .tv column bar -stretch 1 update idletasks ; # no change, widget redisplayed lappend res [.tv column bar -width] [.tv column colA -width] # this column becomes visible --> widget resizes |
︙ | ︙ |
Changes to tests/ttk/ttk.test.
︙ | ︙ | |||
203 204 205 206 207 208 209 | } -result 1 test ttk-2.8 "bug 3223850: button state disabled during click" -setup { destroy .b set ttk28 {} pack [ttk::button .b -command {set ::ttk28 failed}] update | | | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | } -result 1 test ttk-2.8 "bug 3223850: button state disabled during click" -setup { destroy .b set ttk28 {} pack [ttk::button .b -command {set ::ttk28 failed}] update } -body { bind .b <ButtonPress-1> {after 0 {.b configure -state disabled}} after 1 {event generate .b <ButtonPress-1>} after 20 {event generate .b <ButtonRelease-1>} set aid [after 100 {set ::ttk28 [.b instate {disabled !pressed}]}] vwait ::ttk28 after cancel $aid set ttk28 |
︙ | ︙ |
Changes to tests/ttk/validate.test.
︙ | ︙ | |||
157 158 159 160 161 162 163 | test validate-1.18 {entry widget validation} -constraints coreEntry -body { .e configure -validate all set ::e nextdata list [.e cget -validate] $::vVals } -result {none {.e -1 -1 nextdata newdata {} all forced}} # DIFFERENCE: ttk::entry doesn't validate when setting linked -variable | | | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | test validate-1.18 {entry widget validation} -constraints coreEntry -body { .e configure -validate all set ::e nextdata list [.e cget -validate] $::vVals } -result {none {.e -1 -1 nextdata newdata {} all forced}} # DIFFERENCE: ttk::entry doesn't validate when setting linked -variable # DIFFERENCE: ttk::entry doesn't disable validation proc doval {W d i P s S v V} { set ::vVals [list $W $d $i $P $s $S $v $V] set ::e mydata return 1 } |
︙ | ︙ |
Changes to unix/Makefile.in.
︙ | ︙ | |||
1527 1528 1529 1530 1531 1532 1533 | mkdir -p RPMS/i386 rpmbuild -bb THIS.TK.SPEC mv RPMS/i386/*.rpm . rm -rf RPMS THIS.TK.SPEC # # Target to create a proper Tk distribution from information in the | | | 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 | mkdir -p RPMS/i386 rpmbuild -bb THIS.TK.SPEC mv RPMS/i386/*.rpm . rm -rf RPMS THIS.TK.SPEC # # Target to create a proper Tk distribution from information in the # source directory. DISTDIR must be defined to indicate where # to put the distribution. DISTDIR must be an absolute path name. # DISTROOT = /tmp/dist DISTNAME = tk${VERSION}${PATCH_LEVEL} ZIPNAME = tk${MAJOR_VERSION}${MINOR_VERSION}${PATCH_LEVEL}-src.zip DISTDIR = $(DISTROOT)/$(DISTNAME) |
︙ | ︙ |
Changes to unix/tkUnixWm.c.
︙ | ︙ | |||
23 24 25 26 27 28 29 | typedef struct ProtocolHandler { Atom protocol; /* Identifies the protocol. */ struct ProtocolHandler *nextPtr; /* Next in list of protocol handlers for the * same top-level window, or NULL for end of * list. */ | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | typedef struct ProtocolHandler { Atom protocol; /* Identifies the protocol. */ struct ProtocolHandler *nextPtr; /* Next in list of protocol handlers for the * same top-level window, or NULL for end of * list. */ Tcl_Interp *interp; /* Interpreter in which to invoke command. */ char command[1]; /* Tcl command to invoke when a client message * for this protocol arrives. The actual size * of the structure varies to accommodate the * needs of the actual command. THIS MUST BE * THE LAST FIELD OF THE STRUCTURE. */ } ProtocolHandler; |
︙ | ︙ | |||
78 79 80 81 82 83 84 | char *iconName; /* Name to display in icon. Malloced. */ XWMHints hints; /* Various pieces of information for window * manager. */ char *leaderName; /* Path name of leader of window group * (corresponds to hints.window_group). * Malloc-ed. Note: this field doesn't get * updated if leader is destroyed. */ | | | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | char *iconName; /* Name to display in icon. Malloced. */ XWMHints hints; /* Various pieces of information for window * manager. */ char *leaderName; /* Path name of leader of window group * (corresponds to hints.window_group). * Malloc-ed. Note: this field doesn't get * updated if leader is destroyed. */ TkWindow *containerPtr; /* Container window for TRANSIENT_FOR property, * or NULL. */ Tk_Window icon; /* Window to use as icon for this window, or * NULL. */ Tk_Window iconFor; /* Window for which this window is icon, or * NULL if this isn't an icon for anyone. */ int withdrawn; /* Non-zero means window has been withdrawn. */ |
︙ | ︙ | |||
255 256 257 258 259 260 261 | * allow the user to change the width of the * window (controlled by "wm resizable" command). * WM_HEIGHT_NOT_RESIZABLE - non-zero means that we're not supposed to * allow the user to change the height of the * window (controlled by "wm resizable" command). * WM_WITHDRAWN - non-zero means that this window has explicitly * been withdrawn. If it's a transient, it should | | | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | * allow the user to change the width of the * window (controlled by "wm resizable" command). * WM_HEIGHT_NOT_RESIZABLE - non-zero means that we're not supposed to * allow the user to change the height of the * window (controlled by "wm resizable" command). * WM_WITHDRAWN - non-zero means that this window has explicitly * been withdrawn. If it's a transient, it should * not mirror state changes in the container. */ #define WM_NEVER_MAPPED 1 #define WM_UPDATE_PENDING 2 #define WM_NEGATIVE_X 4 #define WM_NEGATIVE_Y 8 #define WM_UPDATE_SIZE_HINTS 0x10 |
︙ | ︙ | |||
567 568 569 570 571 572 573 | register WmInfo *wmPtr; TkDisplay *dispPtr = winPtr->dispPtr; wmPtr = ckalloc(sizeof(WmInfo)); memset(wmPtr, 0, sizeof(WmInfo)); wmPtr->winPtr = winPtr; wmPtr->reparent = None; | | | 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 | register WmInfo *wmPtr; TkDisplay *dispPtr = winPtr->dispPtr; wmPtr = ckalloc(sizeof(WmInfo)); memset(wmPtr, 0, sizeof(WmInfo)); wmPtr->winPtr = winPtr; wmPtr->reparent = None; wmPtr->containerPtr = NULL; wmPtr->numTransients = 0; wmPtr->hints.flags = InputHint | StateHint; wmPtr->hints.input = True; wmPtr->hints.initial_state = NormalState; wmPtr->hints.icon_pixmap = None; wmPtr->hints.icon_window = None; wmPtr->hints.icon_x = wmPtr->hints.icon_y = 0; |
︙ | ︙ | |||
680 681 682 683 684 685 686 | * Store all the window-manager-related information for the window. */ TkWmSetClass(winPtr); UpdateTitle(winPtr); UpdatePhotoIcon(winPtr); | | | | | | 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 | * Store all the window-manager-related information for the window. */ TkWmSetClass(winPtr); UpdateTitle(winPtr); UpdatePhotoIcon(winPtr); if (wmPtr->containerPtr != NULL) { /* * Don't map a transient if the container is not mapped. */ if (!Tk_IsMapped(wmPtr->containerPtr)) { wmPtr->withdrawn = 1; wmPtr->hints.initial_state = WithdrawnState; } /* * Make sure that we actually set the transient-for property, even * if we are withdrawn. [Bug 1163496] */ XSetTransientForHint(winPtr->display, wmPtr->wrapperPtr->window, wmPtr->containerPtr->wmInfoPtr->wrapperPtr->window); } wmPtr->flags |= WM_UPDATE_SIZE_HINTS; UpdateHints(winPtr); UpdateWmProtocols(wmPtr); if (wmPtr->cmdArgv != NULL) { UpdateCommand(winPtr); |
︙ | ︙ | |||
905 906 907 908 909 910 911 | ckfree(wmPtr->clientMachine); } if (wmPtr->flags & WM_UPDATE_PENDING) { Tcl_CancelIdleCall(UpdateGeometryInfo, winPtr); } /* | | | | | | | | | | | 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 | ckfree(wmPtr->clientMachine); } if (wmPtr->flags & WM_UPDATE_PENDING) { Tcl_CancelIdleCall(UpdateGeometryInfo, winPtr); } /* * Reset all transient windows whose container is the dead window. */ for (wmPtr2 = winPtr->dispPtr->firstWmPtr; wmPtr2 != NULL; wmPtr2 = wmPtr2->nextPtr) { if (wmPtr2->containerPtr == winPtr) { wmPtr->numTransients--; Tk_DeleteEventHandler((Tk_Window) wmPtr2->containerPtr, StructureNotifyMask, WmWaitMapProc, wmPtr2->winPtr); wmPtr2->containerPtr = NULL; if (!(wmPtr2->flags & WM_NEVER_MAPPED)) { XDeleteProperty(winPtr->display, wmPtr2->wrapperPtr->window, Tk_InternAtom((Tk_Window) winPtr, "WM_TRANSIENT_FOR")); /* * FIXME: Need a call like Win32's UpdateWrapper() so we can * recreate the wrapper and get rid of the transient window * decorations. */ } } } /* ASSERT: numTransients == 0 [Bug 1789819] */ if (wmPtr->containerPtr != NULL) { wmPtr2 = wmPtr->containerPtr->wmInfoPtr; /* * If we had a container, tell them that we aren't tied to them anymore */ if (wmPtr2 != NULL) { wmPtr2->numTransients--; } Tk_DeleteEventHandler((Tk_Window) wmPtr->containerPtr, StructureNotifyMask, WmWaitMapProc, winPtr); wmPtr->containerPtr = NULL; } ckfree(wmPtr); winPtr->wmInfoPtr = NULL; } /* *-------------------------------------------------------------- |
︙ | ︙ | |||
2216 2217 2218 2219 2220 2221 2222 | Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": override-redirect flag is set", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } | | | 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 | Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": override-redirect flag is set", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } if (wmPtr->containerPtr != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": it is a transient", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "TRANSIENT", NULL); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { |
︙ | ︙ | |||
3404 3405 3406 3407 3408 3409 3410 | Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": override-redirect flag is set", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } | | | 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 | Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": override-redirect flag is set", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } if (wmPtr->containerPtr != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": it is a transient", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "TRANSIENT", NULL); return TCL_ERROR; } |
︙ | ︙ | |||
3528 3529 3530 3531 3532 3533 3534 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; TkWindow *containerPtr = wmPtr->containerPtr, *w; WmInfo *wmPtr2; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?master?"); return TCL_ERROR; } if (objc == 3) { if (containerPtr != NULL) { Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window) containerPtr)); } return TCL_OK; } if (Tcl_GetString(objv[3])[0] == '\0') { if (containerPtr != NULL) { /* * If we had a container, tell them that we aren't tied to them * anymore */ containerPtr->wmInfoPtr->numTransients--; Tk_DeleteEventHandler((Tk_Window) containerPtr, StructureNotifyMask, WmWaitMapProc, winPtr); /* * FIXME: Need a call like Win32's UpdateWrapper() so we can * recreate the wrapper and get rid of the transient window * decorations. */ } wmPtr->containerPtr = NULL; } else { Tk_Window container; if (TkGetWindowFromObj(interp, tkwin, objv[3], &container)!=TCL_OK) { return TCL_ERROR; } containerPtr = (TkWindow *) container; while (!Tk_TopWinHierarchy(containerPtr)) { /* * Ensure that the container window is actually a Tk toplevel. */ containerPtr = containerPtr->parentPtr; } Tk_MakeWindowExist((Tk_Window) containerPtr); if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't make \"%s\" a transient: it is an icon for %s", Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL); return TCL_ERROR; } wmPtr2 = containerPtr->wmInfoPtr; if (wmPtr2->wrapperPtr == NULL) { CreateWrapper(wmPtr2); } if (wmPtr2->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't make \"%s\" a master: it is an icon for %s", Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL); return TCL_ERROR; } for (w = containerPtr; w != NULL && w->wmInfoPtr != NULL; w = (TkWindow *)w->wmInfoPtr->containerPtr) { if (w == winPtr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "setting \"%s\" as master creates a transient/master cycle", Tk_PathName(containerPtr))); Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL); return TCL_ERROR; } } if (containerPtr != wmPtr->containerPtr) { /* * Remove old container map/unmap binding before setting the new * container. The event handler will ensure that transient states * reflect the state of the container. */ if (wmPtr->containerPtr != NULL) { wmPtr->containerPtr->wmInfoPtr->numTransients--; Tk_DeleteEventHandler((Tk_Window) wmPtr->containerPtr, StructureNotifyMask, WmWaitMapProc, winPtr); } containerPtr->wmInfoPtr->numTransients++; Tk_CreateEventHandler((Tk_Window) containerPtr, StructureNotifyMask, WmWaitMapProc, winPtr); wmPtr->containerPtr = containerPtr; } } if (!(wmPtr->flags & WM_NEVER_MAPPED)) { if (wmPtr->containerPtr != NULL && !Tk_IsMapped(wmPtr->containerPtr)) { if (TkpWmSetState(winPtr, WithdrawnState) == 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "couldn't send withdraw message to window manager", -1)); Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL); return TCL_ERROR; } } else { if (wmPtr->containerPtr != NULL) { XSetTransientForHint(winPtr->display, wmPtr->wrapperPtr->window, wmPtr->containerPtr->wmInfoPtr->wrapperPtr->window); } else { XDeleteProperty(winPtr->display, wmPtr->wrapperPtr->window, Tk_InternAtom((Tk_Window) winPtr,"WM_TRANSIENT_FOR")); } } } return TCL_OK; |
︙ | ︙ | |||
3717 3718 3719 3720 3721 3722 3723 | Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } } /* * Invoked when a MapNotify or UnmapNotify event is delivered for a toplevel | | | | | 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 | Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } } /* * Invoked when a MapNotify or UnmapNotify event is delivered for a toplevel * that is the container of a transient toplevel. */ static void WmWaitMapProc( ClientData clientData, /* Pointer to window. */ XEvent *eventPtr) /* Information about event. */ { TkWindow *winPtr = clientData; TkWindow *containerPtr = winPtr->wmInfoPtr->containerPtr; if (containerPtr == NULL) { return; } if (eventPtr->type == MapNotify) { if (!(winPtr->wmInfoPtr->flags & WM_WITHDRAWN)) { (void) TkpWmSetState(winPtr, NormalState); } |
︙ | ︙ |
Changes to win/Makefile.in.
︙ | ︙ | |||
136 137 138 139 140 141 142 | TEST_DLL_FILE = tktest$(VER)${DLLSUFFIX} TEST_LIB_FILE = @LIBPREFIX@tktest$(VER)${LIBSUFFIX} SHARED_LIBRARIES = $(TK_DLL_FILE) $(TK_STUB_LIB_FILE) STATIC_LIBRARIES = $(TK_LIB_FILE) WISH = wish$(VER)${EXESUFFIX} | | | | | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | TEST_DLL_FILE = tktest$(VER)${DLLSUFFIX} TEST_LIB_FILE = @LIBPREFIX@tktest$(VER)${LIBSUFFIX} SHARED_LIBRARIES = $(TK_DLL_FILE) $(TK_STUB_LIB_FILE) STATIC_LIBRARIES = $(TK_LIB_FILE) WISH = wish$(VER)${EXESUFFIX} TKTEST = tktest.exe CAT32 = cat32.exe MAN2TCL = man2tcl.exe @SET_MAKE@ # Setting the VPATH variable to a list of paths will cause the # makefile to look into these paths when resolving .c to .obj # dependencies. |
︙ | ︙ | |||
180 181 182 183 184 185 186 | RES = @RES@ TK_RES = @TK_RES@ AC_FLAGS = @EXTRA_CFLAGS@ @DEFS@ @TCL_DEFS@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ @LDFLAGS_DEFAULT@ LDFLAGS_CONSOLE = @LDFLAGS_CONSOLE@ LDFLAGS_WINDOW = @LDFLAGS_WINDOW@ | < | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | RES = @RES@ TK_RES = @TK_RES@ AC_FLAGS = @EXTRA_CFLAGS@ @DEFS@ @TCL_DEFS@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ @LDFLAGS_DEFAULT@ LDFLAGS_CONSOLE = @LDFLAGS_CONSOLE@ LDFLAGS_WINDOW = @LDFLAGS_WINDOW@ OBJEXT = @OBJEXT@ STLIB_LD = @STLIB_LD@ SHLIB_LD = @SHLIB_LD@ SHLIB_LD_LIBS = @SHLIB_LD_LIBS@ SHLIB_CFLAGS = @SHLIB_CFLAGS@ SHLIB_SUFFIX = @SHLIB_SUFFIX@ VER = @TK_MAJOR_VERSION@@TK_MINOR_VERSION@ |
︙ | ︙ | |||
702 703 704 705 706 707 708 | .rc.$(RES): $(RC) @RC_OUT@ $@ @RC_TYPE@ @RC_DEFINES@ @RC_INCLUDE@ "$(GENERIC_DIR_NATIVE)" @RC_INCLUDE@ "$(TCL_GENERIC_NATIVE)" @RC_INCLUDE@ "$(RC_DIR_NATIVE)" @DEPARG@ depend: cleanhelp: | | | 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 | .rc.$(RES): $(RC) @RC_OUT@ $@ @RC_TYPE@ @RC_DEFINES@ @RC_INCLUDE@ "$(GENERIC_DIR_NATIVE)" @RC_INCLUDE@ "$(TCL_GENERIC_NATIVE)" @RC_INCLUDE@ "$(RC_DIR_NATIVE)" @DEPARG@ depend: cleanhelp: $(RM) *.hlp *.cnt *.hpj *.GID *.rtf man2tcl.exe clean: cleanhelp $(RM) *.lib *.a *.exp *.dll *.res *.${OBJEXT} *~ \#* TAGS a.out $(RM) $(WISH) $(TKTEST) $(CAT32) $(RM) *.pch *.ilk *.pdb distclean: clean |
︙ | ︙ |
Changes to win/tkWinWm.c.
︙ | ︙ | |||
53 54 55 56 57 58 59 | typedef struct ProtocolHandler { Atom protocol; /* Identifies the protocol. */ struct ProtocolHandler *nextPtr; /* Next in list of protocol handlers for the * same top-level window, or NULL for end of * list. */ | | | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | typedef struct ProtocolHandler { Atom protocol; /* Identifies the protocol. */ struct ProtocolHandler *nextPtr; /* Next in list of protocol handlers for the * same top-level window, or NULL for end of * list. */ Tcl_Interp *interp; /* Interpreter in which to invoke command. */ char command[1]; /* Tcl command to invoke when a client message * for this protocol arrives. The actual size * of the structure varies to accommodate the * needs of the actual command. THIS MUST BE * THE LAST FIELD OF THE STRUCTURE. */ } ProtocolHandler; |
︙ | ︙ | |||
173 174 175 176 177 178 179 | char *iconName; /* Name to display in icon. Malloced. */ XWMHints hints; /* Various pieces of information for window * manager. */ char *leaderName; /* Path name of leader of window group * (corresponds to hints.window_group). * Malloc-ed. Note: this field doesn't get * updated if leader is destroyed. */ | | | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | char *iconName; /* Name to display in icon. Malloced. */ XWMHints hints; /* Various pieces of information for window * manager. */ char *leaderName; /* Path name of leader of window group * (corresponds to hints.window_group). * Malloc-ed. Note: this field doesn't get * updated if leader is destroyed. */ TkWindow *containerPtr; /* Container window for TRANSIENT_FOR property, * or NULL. */ Tk_Window icon; /* Window to use as icon for this window, or * NULL. */ Tk_Window iconFor; /* Window for which this window is icon, or * NULL if this isn't an icon for anyone. */ /* |
︙ | ︙ | |||
311 312 313 314 315 316 317 | * allow the user to change the width of the * window (controlled by "wm resizable" command). * WM_HEIGHT_NOT_RESIZABLE - Non-zero means that we're not supposed to * allow the user to change the height of the * window (controlled by "wm resizable" command). * WM_WITHDRAWN - Non-zero means that this window has explicitly * been withdrawn. If it's a transient, it should | | | 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | * allow the user to change the width of the * window (controlled by "wm resizable" command). * WM_HEIGHT_NOT_RESIZABLE - Non-zero means that we're not supposed to * allow the user to change the height of the * window (controlled by "wm resizable" command). * WM_WITHDRAWN - Non-zero means that this window has explicitly * been withdrawn. If it's a transient, it should * not mirror state changes in the container. * WM_FULLSCREEN - Non-zero means that this window has been placed * in the full screen mode. It should be mapped at * 0,0 and be the width and height of the screen. */ #define WM_NEVER_MAPPED (1<<0) #define WM_UPDATE_PENDING (1<<1) |
︙ | ︙ | |||
2050 2051 2052 2053 2054 2055 2056 | wmPtr->exStyle = EX_OVERRIDE_STYLE; /* * Parent must be desktop even if we have a transient parent. */ parentHWND = GetDesktopWindow(); | | | | | 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 | wmPtr->exStyle = EX_OVERRIDE_STYLE; /* * Parent must be desktop even if we have a transient parent. */ parentHWND = GetDesktopWindow(); if (wmPtr->containerPtr) { wmPtr->style |= WS_CHILD; } else { wmPtr->style |= WS_POPUP; } } else if (wmPtr->flags & WM_FULLSCREEN) { wmPtr->style = WM_FULLSCREEN_STYLE; wmPtr->exStyle = EX_FULLSCREEN_STYLE; } else if (wmPtr->containerPtr) { wmPtr->style = WM_TRANSIENT_STYLE; wmPtr->exStyle = EX_TRANSIENT_STYLE; parentHWND = Tk_GetHWND(Tk_WindowId(wmPtr->containerPtr)); if (! ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) && (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE))) { wmPtr->style |= WS_THICKFRAME; } } else { wmPtr->style = WM_TOPLEVEL_STYLE; wmPtr->exStyle = EX_TOPLEVEL_STYLE; |
︙ | ︙ | |||
2200 2201 2202 2203 2204 2205 2206 | if (oldWrapper && (oldWrapper != wmPtr->wrapper) && (oldWrapper != GetDesktopWindow())) { SetWindowLongPtrW(oldWrapper, GWLP_USERDATA, (LONG_PTR) 0); if (wmPtr->numTransients > 0) { /* * Unset the current wrapper as the parent for all transient | | | | 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 | if (oldWrapper && (oldWrapper != wmPtr->wrapper) && (oldWrapper != GetDesktopWindow())) { SetWindowLongPtrW(oldWrapper, GWLP_USERDATA, (LONG_PTR) 0); if (wmPtr->numTransients > 0) { /* * Unset the current wrapper as the parent for all transient * children for whom this is the container */ WmInfo *wmPtr2; childStateInfo = (int *)ckalloc(wmPtr->numTransients * sizeof(int)); state = 0; for (wmPtr2 = winPtr->dispPtr->firstWmPtr; wmPtr2 != NULL; wmPtr2 = wmPtr2->nextPtr) { if (wmPtr2->containerPtr == winPtr && !(wmPtr2->flags & WM_NEVER_MAPPED)) { childStateInfo[state++] = wmPtr2->hints.initial_state; SetParent(TkWinGetHWND(wmPtr2->winPtr->window), NULL); } } } |
︙ | ︙ | |||
2288 2289 2290 2291 2292 2293 2294 | SetMenu(wmPtr->wrapper, wmPtr->hMenu); wmPtr->flags &= ~WM_SYNC_PENDING; } if (childStateInfo) { if (wmPtr->numTransients > 0) { /* | | | | 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 | SetMenu(wmPtr->wrapper, wmPtr->hMenu); wmPtr->flags &= ~WM_SYNC_PENDING; } if (childStateInfo) { if (wmPtr->numTransients > 0) { /* * Reset all transient children for whom this is the container. */ WmInfo *wmPtr2; state = 0; for (wmPtr2 = winPtr->dispPtr->firstWmPtr; wmPtr2 != NULL; wmPtr2 = wmPtr2->nextPtr) { if (wmPtr2->containerPtr == winPtr && !(wmPtr2->flags & WM_NEVER_MAPPED)) { UpdateWrapper(wmPtr2->winPtr); TkpWmSetState(wmPtr2->winPtr, childStateInfo[state++]); } } } |
︙ | ︙ | |||
2361 2362 2363 2364 2365 2366 2367 | if (!tsdPtr->initialized) { InitWm(); } if (wmPtr->flags & WM_NEVER_MAPPED) { /* | | | | 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 | if (!tsdPtr->initialized) { InitWm(); } if (wmPtr->flags & WM_NEVER_MAPPED) { /* * Don't map a transient if the container is not mapped. */ if (wmPtr->containerPtr != NULL && !Tk_IsMapped(wmPtr->containerPtr)) { wmPtr->hints.initial_state = WithdrawnState; return; } } else { if (wmPtr->hints.initial_state == WithdrawnState) { return; } |
︙ | ︙ | |||
2606 2607 2608 2609 2610 2611 2612 | prevPtr->nextPtr = wmPtr->nextPtr; break; } } } /* | | | | | | 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 | prevPtr->nextPtr = wmPtr->nextPtr; break; } } } /* * Reset all transient windows whose container is the dead window. */ for (wmPtr2 = winPtr->dispPtr->firstWmPtr; wmPtr2 != NULL; wmPtr2 = wmPtr2->nextPtr) { if (wmPtr2->containerPtr == winPtr) { wmPtr->numTransients--; Tk_DeleteEventHandler((Tk_Window) wmPtr2->containerPtr, VisibilityChangeMask|StructureNotifyMask, WmWaitVisibilityOrMapProc, wmPtr2->winPtr); wmPtr2->containerPtr = NULL; if ((wmPtr2->wrapper != NULL) && !(wmPtr2->flags & (WM_NEVER_MAPPED))) { UpdateWrapper(wmPtr2->winPtr); } } } if (wmPtr->numTransients != 0) |
︙ | ︙ | |||
2666 2667 2668 2669 2670 2671 2672 | } if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); } if (wmPtr->flags & WM_UPDATE_PENDING) { Tcl_CancelIdleCall(UpdateGeometryInfo, winPtr); } | | | | | | | 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 | } if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); } if (wmPtr->flags & WM_UPDATE_PENDING) { Tcl_CancelIdleCall(UpdateGeometryInfo, winPtr); } if (wmPtr->containerPtr != NULL) { wmPtr2 = wmPtr->containerPtr->wmInfoPtr; /* * If we had a container, tell them that we aren't tied to them anymore. */ if (wmPtr2 != NULL) { wmPtr2->numTransients--; } Tk_DeleteEventHandler((Tk_Window) wmPtr->containerPtr, VisibilityChangeMask|StructureNotifyMask, WmWaitVisibilityOrMapProc, winPtr); wmPtr->containerPtr = NULL; } if (wmPtr->crefObj != NULL) { Tcl_DecrRefCount(wmPtr->crefObj); wmPtr->crefObj = NULL; } /* |
︙ | ︙ | |||
4150 4151 4152 4153 4154 4155 4156 | Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": override-redirect flag is set", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } | | | 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 | Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": override-redirect flag is set", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } if (wmPtr->containerPtr != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": it is a transient", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "TRANSIENT", NULL); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { |
︙ | ︙ | |||
5399 5400 5401 5402 5403 5404 5405 | Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": override-redirect flag is set", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } | | | 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 | Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": override-redirect flag is set", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } if (wmPtr->containerPtr != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": it is a transient", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "TRANSIENT", NULL); return TCL_ERROR; } |
︙ | ︙ | |||
5545 5546 5547 5548 5549 5550 5551 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; TkWindow *containerPtr = wmPtr->containerPtr, **containerPtrPtr = &containerPtr, *w; WmInfo *wmPtr2; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?master?"); return TCL_ERROR; } if (objc == 3) { if (containerPtr != NULL) { Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window) containerPtr)); } return TCL_OK; } if (Tcl_GetString(objv[3])[0] == '\0') { if (containerPtr != NULL) { /* * If we had a container, tell them that we aren't tied to them * anymore. */ containerPtr->wmInfoPtr->numTransients--; Tk_DeleteEventHandler((Tk_Window) containerPtr, VisibilityChangeMask|StructureNotifyMask, WmWaitVisibilityOrMapProc, winPtr); } wmPtr->containerPtr = NULL; } else { if (TkGetWindowFromObj(interp, tkwin, objv[3], (Tk_Window *) containerPtrPtr) != TCL_OK) { return TCL_ERROR; } while (!Tk_TopWinHierarchy(containerPtr)) { /* * Ensure that the container window is actually a Tk toplevel. */ containerPtr = containerPtr->parentPtr; } Tk_MakeWindowExist((Tk_Window) containerPtr); if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't make \"%s\" a transient: it is an icon for %s", Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL); return TCL_ERROR; } wmPtr2 = containerPtr->wmInfoPtr; if (wmPtr2->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't make \"%s\" a master: it is an icon for %s", Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL); return TCL_ERROR; } for (w = containerPtr; w != NULL && w->wmInfoPtr != NULL; w = (TkWindow *)w->wmInfoPtr->containerPtr) { if (w == winPtr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "setting \"%s\" as master creates a transient/master cycle", Tk_PathName(containerPtr))); Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL); return TCL_ERROR; } } if (containerPtr != wmPtr->containerPtr) { /* * Remove old container map/unmap binding before setting the new * container. The event handler will ensure that transient states * reflect the state of the container. */ if (wmPtr->containerPtr != NULL) { wmPtr->containerPtr->wmInfoPtr->numTransients--; Tk_DeleteEventHandler((Tk_Window) wmPtr->containerPtr, VisibilityChangeMask|StructureNotifyMask, WmWaitVisibilityOrMapProc, winPtr); } containerPtr->wmInfoPtr->numTransients++; Tk_CreateEventHandler((Tk_Window) containerPtr, VisibilityChangeMask|StructureNotifyMask, WmWaitVisibilityOrMapProc, winPtr); wmPtr->containerPtr = containerPtr; } } if (!((wmPtr->flags & WM_NEVER_MAPPED) && !(winPtr->flags & TK_EMBEDDED))) { if (wmPtr->containerPtr != NULL && !Tk_IsMapped(wmPtr->containerPtr)) { TkpWmSetState(winPtr, WithdrawnState); } else { UpdateWrapper(winPtr); } } return TCL_OK; } |
︙ | ︙ | |||
5724 5725 5726 5727 5728 5729 5730 | static void WmWaitVisibilityOrMapProc( ClientData clientData, /* Pointer to window. */ XEvent *eventPtr) /* Information about event. */ { TkWindow *winPtr = (TkWindow *)clientData; | | | | | 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 | static void WmWaitVisibilityOrMapProc( ClientData clientData, /* Pointer to window. */ XEvent *eventPtr) /* Information about event. */ { TkWindow *winPtr = (TkWindow *)clientData; TkWindow *containerPtr = winPtr->wmInfoPtr->containerPtr; if (containerPtr == NULL) return; if (eventPtr->type == MapNotify) { if (!(winPtr->wmInfoPtr->flags & WM_WITHDRAWN)) { TkpWmSetState(winPtr, NormalState); } } else if (eventPtr->type == UnmapNotify) { TkpWmSetState(winPtr, WithdrawnState); } if (eventPtr->type == VisibilityNotify) { int state = containerPtr->wmInfoPtr->hints.initial_state; if ((state == NormalState) || (state == ZoomState)) { state = winPtr->wmInfoPtr->hints.initial_state; if ((state == NormalState) || (state == ZoomState)) { UpdateWrapper(winPtr); } } |
︙ | ︙ |
Changes to xlib/xgc.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkInt.h" #if !defined(MAC_OSX_TK) # include <X11/Xlib.h> | < < > > > > > > > > > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkInt.h" #if !defined(MAC_OSX_TK) # include <X11/Xlib.h> # define TkpInitGCCache(gc) # define TkpFreeGCCache(gc) # define TkpGetGCCache(gc) #else # include <tkMacOSXInt.h> # include <X11/Xlib.h> # include <X11/X.h> # define Cursor XCursor # define Region XRegion #endif #undef TkSetRegion #define MAX_DASH_LIST_SIZE 10 typedef struct { XGCValues gc; char dash[MAX_DASH_LIST_SIZE]; #ifdef MAC_OSX_TK TkpGCCache cache; #endif } XGCValuesWithCache; /* *---------------------------------------------------------------------- * * AllocClipMask -- * * Static helper proc to allocate new or clear existing TkpClipMask. * |
︙ | ︙ | |||
109 110 111 112 113 114 115 | /* * In order to have room for a dash list, MAX_DASH_LIST_SIZE extra chars * are defined, which is invisible from the outside. The list is assumed * to end with a 0-char, so this must be set explicitly during * initialization. */ | < < | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | /* * In order to have room for a dash list, MAX_DASH_LIST_SIZE extra chars * are defined, which is invisible from the outside. The list is assumed * to end with a 0-char, so this must be set explicitly during * initialization. */ gp = (GC)ckalloc(sizeof(XGCValuesWithCache)); if (!gp) { return NULL; } #define InitField(name,maskbit,default) \ (gp->name = (mask & (maskbit)) ? values->name : (default)) |
︙ | ︙ | |||
174 175 176 177 178 179 180 | * None. * *---------------------------------------------------------------------- */ TkpGCCache* TkpGetGCCache(GC gc) { | | < | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | * None. * *---------------------------------------------------------------------- */ TkpGCCache* TkpGetGCCache(GC gc) { return (gc ? &((XGCValuesWithCache *)gc)->cache : NULL); } #endif /* *---------------------------------------------------------------------- * * XChangeGC -- |
︙ | ︙ |