Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | Generate -errorcode values to go with errors. Generate messages and postscript using Tcl_Obj API, not the string result API. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
961ae24a3f55411658e21fcc7bccbc40 |
User & Date: | dkf 2012-08-27 19:48:23 |
2012-08-30
| ||
17:54 | Unbreak windows problems with commit [961ae24a3f] as well. check-in: a6f5a336 user: andreask tags: trunk | |
17:31 | Unbreak AIX, replaced use of C99 comments in commit [961ae24a3f] (2012-08-27) with C89-style. check-in: d39e4518 user: andreask tags: trunk | |
2012-08-28
| ||
11:00 | Note potential incompatibility introduced by new virtual events. Emiliano Gavilan reports that this impacts tkcon's history features. check-in: bcd40d0b user: dkf tags: trunk | |
2012-08-27
| ||
19:48 | Generate -errorcode values to go with errors. Generate messages and postscript using Tcl_Obj API, not the string result API. check-in: 961ae24a user: dkf tags: trunk | |
17:50 | merge trunk Closed-Leaf check-in: b20a0d33 user: dkf tags: tk-errorcodes | |
17:47 | Remove accidental commit of merge conflict, resolved to original code. check-in: 538be101 user: dkf tags: trunk | |
Changes to ChangeLog.
1 2 3 4 5 6 7 | 2012-08-24 Donal K. Fellows <[email protected]> * library/tkfbox.tcl (GlobFiltered): [Bug 3558535]: Factor out the filtered-sorted globbing code into one procedure that knows how to avoid nasty problems when non-list filters are used. This allows the rest of the [tk_getOpenFile] implementation to be ignorant of the considerable complexities of globbing. | > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 2012-08-27 Donal K. Fellows <[email protected]> * (very many files): Reworked the generation of error messages and postscript so that they no longer made nearly as much use of the Tcl interpreter's string result code, in the process substantially reducing the amount of ad-hoc stack buffers used for message generation. There should be no observable changes from this except that Tk now causes the ::errorCode variable to be set meaningfully in virtually all places where errors are generated. 2012-08-24 Donal K. Fellows <[email protected]> * library/tkfbox.tcl (GlobFiltered): [Bug 3558535]: Factor out the filtered-sorted globbing code into one procedure that knows how to avoid nasty problems when non-list filters are used. This allows the rest of the [tk_getOpenFile] implementation to be ignorant of the considerable complexities of globbing. |
︙ | ︙ |
Changes to carbon/tkMacOSXButton.c.
︙ | ︙ | |||
974 975 976 977 978 979 980 | SetControlValue(mbPtr->control, 1); } else if (butPtr->flags & TRISTATED) { SetControlValue(mbPtr->control, 2); } else { SetControlValue(mbPtr->control, 0); } | | | 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 | SetControlValue(mbPtr->control, 1); } else if (butPtr->flags & TRISTATED) { SetControlValue(mbPtr->control, 2); } else { SetControlValue(mbPtr->control, 0); } active = !!(mbPtr->flags & ACTIVE); if (active != IsControlActive(mbPtr->control)) { if (active) { ChkErr(ActivateControl, mbPtr->control); } else { ChkErr(DeactivateControl, mbPtr->control); } } |
︙ | ︙ | |||
1391 1392 1393 1394 1395 1396 1397 | return; } if (eventPtr->type == ActivateNotify) { mbPtr->flags |= ACTIVE; } else { mbPtr->flags &= ~ACTIVE; } | | | 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 | return; } if (eventPtr->type == ActivateNotify) { mbPtr->flags |= ACTIVE; } else { mbPtr->flags &= ~ACTIVE; } if (!(buttonPtr->flags & REDRAW_PENDING)) { Tcl_DoWhenIdle(TkpDisplayButton, (ClientData) buttonPtr); buttonPtr->flags |= REDRAW_PENDING; } } } /* |
︙ | ︙ |
Changes to carbon/tkMacOSXClipboard.c.
︙ | ︙ | |||
57 58 59 60 61 62 63 | && (target == XA_STRING)) { /* * Get the scrap from the Macintosh global clipboard. */ err = ChkErr(GetCurrentScrap, &scrapRef); if (err != noErr) { | | | > > | | | | > > | | > > > | | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 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 118 119 120 121 122 123 124 125 126 127 128 129 130 | && (target == XA_STRING)) { /* * Get the scrap from the Macintosh global clipboard. */ err = ChkErr(GetCurrentScrap, &scrapRef); if (err != noErr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s GetCurrentScrap failed.", Tk_GetAtomName(tkwin, selection))); Tcl_SetErrorCode(interp, "TK", "SELECTION", "SCRAP", NULL); return TCL_ERROR; } /* * Try UNICODE first */ err = ChkErr(GetScrapFlavorSize, scrapRef, kScrapFlavorTypeUnicode, &length); if (err == noErr && length > 0) { Tcl_DString ds; char *data; buf = ckalloc(length + 2); buf[length] = 0; buf[length+1] = 0; /* 2-byte unicode null */ err = ChkErr(GetScrapFlavorData, scrapRef, kScrapFlavorTypeUnicode, &length, buf); if (err == noErr) { Tcl_DStringInit(&ds); Tcl_UniCharToUtfDString((Tcl_UniChar *) buf, Tcl_UniCharLen((Tcl_UniChar *) buf), &ds); for (data = Tcl_DStringValue(&ds); *data != '\0'; data++) { if (*data == '\r') { *data = '\n'; } } result = proc(clientData, interp, Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); ckfree(buf); return result; } } err = ChkErr(GetScrapFlavorSize, scrapRef, 'TEXT', &length); if (err != noErr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s GetScrapFlavorSize failed.", Tk_GetAtomName(tkwin, selection))); Tcl_SetErrorCode(interp, "TK", "SELECTION", "FLAVORSIZE", NULL); return TCL_ERROR; } if (length > 0) { Tcl_DString encodedText; char *data; buf = ckalloc(length + 1); buf[length] = 0; err = ChkErr(GetScrapFlavorData, scrapRef, 'TEXT', &length, buf); if (err != noErr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s GetScrapFlavorData failed.", Tk_GetAtomName(tkwin, selection))); Tcl_SetErrorCode(interp, "TK", "SELECTION", "FLAVORDATA", NULL); return TCL_ERROR; } /* * Tcl expects '\n' not '\r' as the line break character. */ for (data = buf; *data != '\0'; data++) { |
︙ | ︙ | |||
132 133 134 135 136 137 138 | Tcl_DStringFree(&encodedText); ckfree(buf); return result; } } | | | | > | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | Tcl_DStringFree(&encodedText); ckfree(buf); return result; } } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s selection doesn't exist or form \"%s\" not defined", Tk_GetAtomName(tkwin, selection), Tk_GetAtomName(tkwin, target))); Tcl_SetErrorCode(interp, "TK", "SELECTION", "EXISTS", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * TkSetSelectionOwner -- |
︙ | ︙ |
Changes to carbon/tkMacOSXCursor.c.
︙ | ︙ | |||
261 262 263 264 265 266 267 | ckfree(argv); } } } if (macCursorPtr->macCursor == NULL) { ckfree(macCursorPtr); | > | > | 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | ckfree(argv); } } } if (macCursorPtr->macCursor == NULL) { ckfree(macCursorPtr); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad cursor spec \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "CURSOR", NULL); return NULL; } return (TkCursor *) macCursorPtr; } /* *---------------------------------------------------------------------- |
︙ | ︙ |
Changes to carbon/tkMacOSXDialog.c.
︙ | ︙ | |||
85 86 87 88 89 90 91 | char *initialFile, AEDescList *selectDescPtr, CFStringRef title, CFStringRef message, const char *initialType, int multiple, int confirmOverwrite, int isOpen, Tk_Window parent); static int HandleInitialDirectory(Tcl_Interp *interp, char *initialFile, char *initialDir, FSRef *dirRef, | | > | | 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 | char *initialFile, AEDescList *selectDescPtr, CFStringRef title, CFStringRef message, const char *initialType, int multiple, int confirmOverwrite, int isOpen, Tk_Window parent); static int HandleInitialDirectory(Tcl_Interp *interp, char *initialFile, char *initialDir, FSRef *dirRef, AEDescList *selectDescPtr, AEDesc *dirDescPtr, const char *dlgType); /* * Have we initialized the file dialog subsystem */ static int fileDlgInited = 0; /* * Filter and hook functions used by the tk_getOpenFile and tk_getSaveFile * commands. */ static NavObjectFilterUPP openFileFilterUPP; static NavEventUPP openFileEventUPP; /* *---------------------------------------------------------------------- * * Tk_ChooseColorObjCmd -- * * This procedure implements the color dialog box for the Mac platform. * See the user documentation for details on what it does. |
︙ | ︙ | |||
148 149 150 151 152 153 154 | bzero(&cpinfo, sizeof(cpinfo)); cpinfo.theColor.color.rgb.red = color.red; cpinfo.theColor.color.rgb.green = color.green; cpinfo.theColor.color.rgb.blue = color.blue; for (i = 1; i < objc; i += 2) { int index; | | > | < | | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | bzero(&cpinfo, sizeof(cpinfo)); cpinfo.theColor.color.rgb.red = color.red; cpinfo.theColor.color.rgb.green = color.green; cpinfo.theColor.color.rgb.blue = color.blue; for (i = 1; i < objc; i += 2) { int index; const char *value; if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "COLORDIALOG", "VALUE", NULL); goto end; } value = Tcl_GetString(objv[i + 1]); switch ((enum options) index) { case COLOR_INITIAL: { XColor *colorPtr; |
︙ | ︙ | |||
221 222 223 224 225 226 227 | Tcl_ResetResult(interp); } result = TCL_OK; end: return result; } | | | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | Tcl_ResetResult(interp); } result = TCL_OK; end: return result; } /* *---------------------------------------------------------------------- * * Tk_GetOpenFileObjCmd -- * * This procedure implements the "open file" dialog box for the Mac * platform. See the user documentation for details on what it does. |
︙ | ︙ | |||
278 279 280 281 282 283 284 | ofd.initialType = -1; ofd.popupItem = OPEN_POPUP_ITEM; ofd.usePopup = 1; for (i = 1; i < objc; i += 2) { char *choice; int index, choiceLen; | < > | < | | 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | ofd.initialType = -1; ofd.popupItem = OPEN_POPUP_ITEM; ofd.usePopup = 1; for (i = 1; i < objc; i += 2) { char *choice; int index, choiceLen; Tcl_Obj *types; if (Tcl_GetIndexFromObj(interp, objv[i], openOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL); goto end; } switch (index) { case OPEN_DEFAULT: break; case OPEN_FILETYPES: |
︙ | ︙ | |||
351 352 353 354 355 356 357 | case OPEN_TYPEVARIABLE: typeVariablePtr = objv[i + 1]; break; } } if (HandleInitialDirectory(interp, initialFile, initialDir, &dirRef, | | | 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | case OPEN_TYPEVARIABLE: typeVariablePtr = objv[i + 1]; break; } } if (HandleInitialDirectory(interp, initialFile, initialDir, &dirRef, &selectDesc, &initialDesc, "FILEDIALOG") != TCL_OK) { goto end; } if (initialDesc.descriptorType == typeFSRef) { initialPtr = &initialDesc; } if (typeVariablePtr) { initialtype = Tcl_GetVar(interp, Tcl_GetString(typeVariablePtr), 0); |
︙ | ︙ | |||
390 391 392 393 394 395 396 | CFRelease(title); } if (message) { CFRelease(message); } return result; } | | | 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | CFRelease(title); } if (message) { CFRelease(message); } return result; } /* *---------------------------------------------------------------------- * * Tk_GetSaveFileObjCmd -- * * Same as Tk_GetOpenFileCmd but opens a "save file" dialog box instead. * |
︙ | ︙ | |||
442 443 444 445 446 447 448 | } TkInitFileFilters(&ofd.fl); ofd.curType = 0; ofd.usePopup = 0; for (i = 1; i < objc; i += 2) { | | > | < | | | 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 | } TkInitFileFilters(&ofd.fl); ofd.curType = 0; ofd.usePopup = 0; for (i = 1; i < objc; i += 2) { char *choice; int index, choiceLen; Tcl_Obj *types; if (Tcl_GetIndexFromObj(interp, objv[i], saveOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL); goto end; } switch (index) { case SAVE_DEFAULT: break; case SAVE_FILETYPES: types = objv[i + 1]; if (TkGetFileFilters(interp, &ofd.fl, types, 0) != TCL_OK) { goto end; } break; case SAVE_INITDIR: choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen); /* empty strings should be like no selection given */ if (choiceLen && HandleInitialDirectory(interp, NULL, choice, &dirRef, NULL, &initialDesc, "FILEDIALOG") != TCL_OK) { goto end; } break; case SAVE_INITFILE: initialFile = Tcl_GetStringFromObj(objv[i + 1], &choiceLen); /* empty strings should be like no selection given */ if (choiceLen == 0) { |
︙ | ︙ | |||
529 530 531 532 533 534 535 | CFRelease(title); } if (message) { CFRelease(message); } return result; } | | | 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 | CFRelease(title); } if (message) { CFRelease(message); } return result; } /* *---------------------------------------------------------------------- * * Tk_ChooseDirectoryObjCmd -- * * This procedure implements the "tk_chooseDirectory" dialog box for the * MacOS X platform. See the user documentation for details on what it |
︙ | ︙ | |||
574 575 576 577 578 579 580 | }; if (!fileDlgInited) { InitFileDialogs(); } for (i = 1; i < objc; i += 2) { | | > | < | | | 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 | }; if (!fileDlgInited) { InitFileDialogs(); } for (i = 1; i < objc; i += 2) { char *choice; int index, choiceLen; if (Tcl_GetIndexFromObj(interp, objv[i], chooseOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "DIRDIALOG", "VALUE", NULL); goto end; } switch (index) { case CHOOSE_INITDIR: choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen); if (choiceLen && HandleInitialDirectory(interp, NULL, choice, &dirRef, NULL, &initialDesc, "DIRDIALOG") != TCL_OK) { goto end; } break; case CHOOSE_MESSAGE: choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen); if (message) { CFRelease(message); |
︙ | ︙ | |||
641 642 643 644 645 646 647 | CFRelease(title); } if (message) { CFRelease(message); } return result; } | | | 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 | CFRelease(title); } if (message) { CFRelease(message); } return result; } /* *---------------------------------------------------------------------- * * HandleInitialDirectory -- * * Helper for -initialdir setup. * |
︙ | ︙ | |||
665 666 667 668 669 670 671 | int HandleInitialDirectory( Tcl_Interp *interp, char *initialFile, char *initialDir, FSRef *dirRef, AEDescList *selectDescPtr, | | > > | | | | > > | 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 | int HandleInitialDirectory( Tcl_Interp *interp, char *initialFile, char *initialDir, FSRef *dirRef, AEDescList *selectDescPtr, AEDesc *dirDescPtr, const char *dlgType) { Tcl_DString ds; OSStatus err; Boolean isDirectory; char *dirName = NULL; int result = TCL_ERROR; if (initialDir) { dirName = Tcl_TranslateFileName(interp, initialDir, &ds); if (dirName == NULL) { goto end; } err = ChkErr(FSPathMakeRef, (unsigned char *) dirName, dirRef, &isDirectory); if (err != noErr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad directory \"%s\"", initialDir)); Tcl_SetErrorCode(interp, "TK", dlgType, "NO_INITDIR", NULL); goto end; } if (!isDirectory) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "-intialdir \"%s\" is a file, not a directory.", initialDir)); Tcl_SetErrorCode(interp, "TK", dlgType, "BAD_INITDIR", NULL); goto end; } ChkErr(AECreateDesc, typeFSRef, dirRef, sizeof(*dirRef), dirDescPtr); } if (initialFile && selectDescPtr) { FSRef fileRef; |
︙ | ︙ | |||
711 712 713 714 715 716 717 | } ChkErr(AECreateList, NULL, 0, false, selectDescPtr); err = ChkErr(FSPathMakeRef, (unsigned char *) namePtr, &fileRef, &isDirectory); if (err != noErr) { | | | > > | | 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 | } ChkErr(AECreateList, NULL, 0, false, selectDescPtr); err = ChkErr(FSPathMakeRef, (unsigned char *) namePtr, &fileRef, &isDirectory); if (err != noErr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad initialfile \"%s\" file does not exist.", initialFile)); Tcl_SetErrorCode(interp, "TK", dlgType, "NO_INITFILE", NULL); goto end; } ChkErr(AECreateDesc, typeFSRef, &fileRef, sizeof(fileRef), &fileDesc); ChkErr(AEPutDesc, selectDescPtr, 1, &fileDesc); ChkErr(AEDisposeDesc, &fileDesc); } result = TCL_OK; end: if (dirName) { Tcl_DStringFree(&ds); } return result; } /* *---------------------------------------------------------------------- * * InitFileDialogs -- * * Initialize file dialog subsystem. * |
︙ | ︙ | |||
750 751 752 753 754 755 756 | void InitFileDialogs(void) { fileDlgInited = 1; openFileFilterUPP = NewNavObjectFilterUPP(OpenFileFilterProc); openFileEventUPP = NewNavEventUPP(OpenEventProc); } | | | 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 | void InitFileDialogs(void) { fileDlgInited = 1; openFileFilterUPP = NewNavObjectFilterUPP(OpenFileFilterProc); openFileEventUPP = NewNavEventUPP(OpenEventProc); } /* *---------------------------------------------------------------------- * * NavServicesGetFile -- * * Common wrapper for NavServices API. * |
︙ | ︙ | |||
1035 1036 1037 1038 1039 1040 1041 | ckfree(menuItemNames); } if (options.popupExtension) { CFRelease(options.popupExtension); } return result; } | | | 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 | ckfree(menuItemNames); } if (options.popupExtension) { CFRelease(options.popupExtension); } return result; } /* *---------------------------------------------------------------------- * * OpenEventProc -- * * NavServices event handling callback. * |
︙ | ︙ | |||
1120 1121 1122 1123 1124 1125 1126 | NavDialogDispose(callBackParams->context); break; case kNavCBEvent: TkMacOSXRunTclEventLoop(); break; } } | | | 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 | NavDialogDispose(callBackParams->context); break; case kNavCBEvent: TkMacOSXRunTclEventLoop(); break; } } /* *---------------------------------------------------------------------- * * OpenFileFilterProc -- * * NavServices file filter callback. * |
︙ | ︙ | |||
1217 1218 1219 1220 1221 1222 1223 | } } Tcl_DStringFree(&fileNameDString); } } return (result == MATCHED); } | | | 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 | } } Tcl_DStringFree(&fileNameDString); } } return (result == MATCHED); } /* *---------------------------------------------------------------------- * * MatchOneType -- * * Match a file with one file type in the list of file types. * |
︙ | ︙ | |||
1334 1335 1336 1337 1338 1339 1340 | if (globMatched && (macMatched || (fileType == 0))) { return MATCHED; } } return UNMATCHED; } | | | 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 | if (globMatched && (macMatched || (fileType == 0))) { return MATCHED; } } return UNMATCHED; } /* *---------------------------------------------------------------------- * * TkAboutDlg -- * * Displays the default Tk About box. This code uses Macintosh resources * to define the content of the About Box. |
︙ | ︙ | |||
1373 1374 1375 1376 1377 1378 1379 | while (itemHit != 1) { ModalDialog(NULL, &itemHit); } TkMacOSXTrackingLoop(0); DisposeDialog(aboutDlog); SelectWindow(ActiveNonFloatingWindow()); } | | | 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 | while (itemHit != 1) { ModalDialog(NULL, &itemHit); } TkMacOSXTrackingLoop(0); DisposeDialog(aboutDlog); SelectWindow(ActiveNonFloatingWindow()); } /* *---------------------------------------------------------------------- * * Tk_MessageBoxObjCmd -- * * Implements the tk_messageBox in native Mac OS X style. * |
︙ | ︙ | |||
1482 1483 1484 1485 1486 1487 1488 | paramCFStringRec.movable = true; paramCFStringRec.helpButton = false; paramCFStringRec.defaultButton = kAlertStdAlertOKButton; paramCFStringRec.cancelButton = kAlertStdAlertCancelButton; for (i = 1; i < objc; i += 2) { int iconIndex; | < > | < | | 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 | paramCFStringRec.movable = true; paramCFStringRec.helpButton = false; paramCFStringRec.defaultButton = kAlertStdAlertOKButton; paramCFStringRec.cancelButton = kAlertStdAlertCancelButton; for (i = 1; i < objc; i += 2) { int iconIndex; if (Tcl_GetIndexFromObj(interp, objv[i], movableAlertStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "MSGBOX", "VALUE", NULL); goto end; } switch (index) { case ALERT_DEFAULT: /* * Need to postpone processing of this option until we are sure to |
︙ | ︙ | |||
1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 | */ defaultNativeButtonIndex = buttonIndexAndTypeToNativeButtonIndex[typeIndex][defaultButtonIndex]; if (defaultNativeButtonIndex == 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj("Illegal default option", -1)); goto end; } paramCFStringRec.defaultButton = defaultNativeButtonIndex; if (paramCFStringRec.cancelButton == defaultNativeButtonIndex) { paramCFStringRec.cancelButton = 0; } } | > | 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 | */ defaultNativeButtonIndex = buttonIndexAndTypeToNativeButtonIndex[typeIndex][defaultButtonIndex]; if (defaultNativeButtonIndex == 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj("Illegal default option", -1)); Tcl_SetErrorCode(interp, "TK", "MSGBOX", "DEFAULT", NULL); goto end; } paramCFStringRec.defaultButton = defaultNativeButtonIndex; if (paramCFStringRec.cancelButton == defaultNativeButtonIndex) { paramCFStringRec.cancelButton = 0; } } |
︙ | ︙ | |||
1701 1702 1703 1704 1705 1706 1707 | CFRelease(finemessageTextCF); } if (messageTextCF) { CFRelease(messageTextCF); } return result; } | | | 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 | CFRelease(finemessageTextCF); } if (messageTextCF) { CFRelease(messageTextCF); } return result; } /* *---------------------------------------------------------------------- * * AlertHandler -- * * Carbon event handler for the Standard Sheet dialog. * |
︙ | ︙ | |||
2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 | Tcl_SetObjResult(interp, dictObj); } return r; } for (i = 1; i < objc; i += 2) { int optionIndex, len; if (Tcl_GetIndexFromObj(interp, objv[i], fontchooserOptionStrings, "option", 0, &optionIndex) != TCL_OK) { return TCL_ERROR; } if (objc == 2) { /* With one option and no arg, return the current value */ Tcl_SetObjResult(interp, FontchooserCget(fcdPtr, optionIndex)); return TCL_OK; } if (i + 1 == objc) { | > | | > | | | > | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | > | | | | | | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 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 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 | Tcl_SetObjResult(interp, dictObj); } return r; } for (i = 1; i < objc; i += 2) { int optionIndex, len; if (Tcl_GetIndexFromObj(interp, objv[i], fontchooserOptionStrings, "option", 0, &optionIndex) != TCL_OK) { return TCL_ERROR; } if (objc == 2) { /* With one option and no arg, return the current value */ Tcl_SetObjResult(interp, FontchooserCget(fcdPtr, optionIndex)); return TCL_OK; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "FONTDIALOG", "VALUE", NULL); return TCL_ERROR; } switch (optionIndex) { case FontchooserVisible: { const char *msg = "cannot change read-only option " "\"-visible\": use the show or hide command"; Tcl_SetObjResult(interp, Tcl_NewStringObj(msg, -1)); Tcl_SetErrorCode(interp, "TK", "FONTDIALOG", "READONLY", NULL); return TCL_ERROR; } case FontchooserParent: { Tk_Window parent = Tk_NameToWindow(interp, Tcl_GetString(objv[i+1]), tkwin); if (parent == None) { return TCL_ERROR; } if (fcdPtr->parent) { Tk_DeleteEventHandler(fcdPtr->parent, StructureNotifyMask, FontchooserParentEventHandler, fcdPtr); } fcdPtr->parent = parent; Tk_CreateEventHandler(fcdPtr->parent, StructureNotifyMask, FontchooserParentEventHandler, fcdPtr); break; } case FontchooserTitle: if (fcdPtr->titleObj) { Tcl_DecrRefCount(fcdPtr->titleObj); } Tcl_GetStringFromObj(objv[i+1], &len); if (len) { fcdPtr->titleObj = objv[i+1]; if (Tcl_IsShared(fcdPtr->titleObj)) { fcdPtr->titleObj = Tcl_DuplicateObj(fcdPtr->titleObj); } Tcl_IncrRefCount(fcdPtr->titleObj); } else { fcdPtr->titleObj = NULL; } break; case FontchooserFont: Tcl_GetStringFromObj(objv[i+1], &len); if (len) { Tk_Font f = Tk_AllocFontFromObj(interp, tkwin, objv[i+1]); if (f) { ATSUStyle atsuStyle; TkMacOSXFMFontInfoForFont(f, &fontPanelFontFamily, &fontPanelFontStyle, &fontPanelFontSize, &atsuStyle); ChkErr(SetFontInfoForSelection, kFontSelectionATSUIType, 1, &atsuStyle, NULL); Tk_FreeFont(f); } else { return TCL_ERROR; } } else { fontPanelFontFamily = kInvalidFontFamily; ChkErr(SetFontInfoForSelection, kFontSelectionATSUIType, 0, NULL, NULL); } if (FPIsFontPanelVisible()) { TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged"); } break; case FontchooserCmd: if (fcdPtr->cmdObj) { Tcl_DecrRefCount(fcdPtr->cmdObj); } Tcl_GetStringFromObj(objv[i+1], &len); if (len) { fcdPtr->cmdObj = objv[i+1]; if (Tcl_IsShared(fcdPtr->cmdObj)) { fcdPtr->cmdObj = Tcl_DuplicateObj(fcdPtr->cmdObj); } Tcl_IncrRefCount(fcdPtr->cmdObj); } else { fcdPtr->cmdObj = NULL; } break; } } return TCL_OK; } /* * ---------------------------------------------------------------------- |
︙ | ︙ |
Changes to carbon/tkMacOSXEmbed.c.
︙ | ︙ | |||
204 205 206 207 208 209 210 | { TkWindow *winPtr = (TkWindow *) tkwin; TkWindow *usePtr; MacDrawable *parent, *macWin; Container *containerPtr; if (winPtr->window != None) { | > | | | < | | > > | < | 204 205 206 207 208 209 210 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 237 238 239 240 241 242 243 | { TkWindow *winPtr = (TkWindow *) tkwin; TkWindow *usePtr; MacDrawable *parent, *macWin; Container *containerPtr; if (winPtr->window != None) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't modify container after widget is created", -1)); Tcl_SetErrorCode(interp, "TK", "EMBED", "POST_CREATE", NULL); return TCL_ERROR; } /* * Decode the container pointer, and look for it among the list of * available containers. * * N.B. For now, we are limiting the containers to be in the same Tk * application as tkwin, since otherwise they would not be in our list of * containers. */ if (Tcl_GetInt(interp, string, (int*) &parent) != TCL_OK) { return TCL_ERROR; } usePtr = (TkWindow *) Tk_IdToWindow(winPtr->display, (Window) parent); if (usePtr != NULL && !(usePtr->flags & TK_CONTAINER)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" doesn't have -container option set", usePtr->pathName)); Tcl_SetErrorCode(interp, "TK", "EMBED", "CONTAINER", NULL); return TCL_ERROR; } /* * The code below can probably be simplified given we have already * discovered 'usePtr' above. */ |
︙ | ︙ | |||
308 309 310 311 312 313 314 | * If someone has registered an in process embedding handler, then * see if it can handle this window... */ if (tkMacOSXEmbedHandler == NULL || tkMacOSXEmbedHandler->registerWinProc((int) parent, (Tk_Window) winPtr) != TCL_OK) { | | | > > | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | * If someone has registered an in process embedding handler, then * see if it can handle this window... */ if (tkMacOSXEmbedHandler == NULL || tkMacOSXEmbedHandler->registerWinProc((int) parent, (Tk_Window) winPtr) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "The window ID %s does not correspond to a valid Tk Window", string)); Tcl_SetErrorCode(interp, "TK", "EMBED", "HANDLE", NULL); return TCL_ERROR; } else { containerPtr = ckalloc(sizeof(Container)); containerPtr->parentPtr = NULL; containerPtr->embedded = (Window) macWin; containerPtr->embeddedPtr = macWin->winPtr; |
︙ | ︙ |
Changes to carbon/tkMacOSXMenu.c.
︙ | ︙ | |||
527 528 529 530 531 532 533 | if (curID == 2000) { curID = 0; } } } if (!found) { | | | > > | 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | if (curID == 2000) { curID = 0; } } } if (!found) { Tcl_SetObjResult(menuPtr->interp, Tcl_NewStringObj( "No more menus can be allocated.", -1)); Tcl_SetErrorCode(menuPtr->interp, "TK", "MENU", "SYSTEM_RESOURCES", NULL); return TCL_ERROR; } Tcl_SetHashValue(commandEntryPtr, menuPtr); *menuIDPtr = returnID; return TCL_OK; } |
︙ | ︙ | |||
678 679 680 681 682 683 684 | error = TkMacOSXGetNewMenuID(menuPtr->interp, menuPtr, 0, &menuID); if (error != TCL_OK) { return error; } err = ChkErr(CreateNewMenu, menuID, kMenuAttrDoNotUseUserCommandKeys, &macMenuHdl); if (err != noErr) { | > | > > | | > | | | 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 | error = TkMacOSXGetNewMenuID(menuPtr->interp, menuPtr, 0, &menuID); if (error != TCL_OK) { return error; } err = ChkErr(CreateNewMenu, menuID, kMenuAttrDoNotUseUserCommandKeys, &macMenuHdl); if (err != noErr) { Tcl_SetObjResult(menuPtr->interp, Tcl_NewStringObj( "CreateNewMenu failed.", -1)); Tcl_SetErrorCode(menuPtr->interp, "TK", "MENU", "CREATE", NULL); return TCL_ERROR; } cfStr = CFStringCreateWithCString(NULL, Tk_PathName(menuPtr->tkwin), kCFStringEncodingUTF8); if (!cfStr) { Tcl_SetObjResult(menuPtr->interp, Tcl_NewStringObj( "CFStringCreateWithCString failed.", -1)); Tcl_SetErrorCode(menuPtr->interp, "TK", "MENU", "CREATE_STRING",NULL); return TCL_ERROR; } err = ChkErr(SetMenuTitleWithCFString, macMenuHdl, cfStr); CFRelease(cfStr); if (err != noErr) { Tcl_SetObjResult(menuPtr->interp, Tcl_NewStringObj( "SetMenuTitleWithCFString failed.", -1)); Tcl_SetErrorCode(menuPtr->interp, "TK", "MENU", "SET_TITLE", NULL); return TCL_ERROR; } menuPtr->platformData = ckalloc(sizeof(MacMenu)); ((MacMenu *) menuPtr->platformData)->menuHdl = macMenuHdl; #ifdef USE_TK_MDEF |
︙ | ︙ | |||
1542 1543 1544 1545 1546 1547 1548 | int y) /* The global y-coordinate */ { MenuHandle macMenuHdl = ((MacMenu *) menuPtr->platformData)->menuHdl; long popUpResult; int result; if (inPostMenu > 0) { | | | > | 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 | int y) /* The global y-coordinate */ { MenuHandle macMenuHdl = ((MacMenu *) menuPtr->platformData)->menuHdl; long popUpResult; int result; if (inPostMenu > 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Cannot call post menu while already posting menu", -1)); Tcl_SetErrorCode(interp, "TK", "MENU", "POSTING", NULL); result = TCL_ERROR; } else { short menuID; Window window; int oldWidth = menuPtr->totalWidth; inPostMenu++; |
︙ | ︙ | |||
2244 2245 2246 2247 2248 2249 2250 | helpMenuRef->menuPtr, newIndex); } } } else { Tcl_HashEntry *commandEntryPtr = Tcl_FindHashEntry(&commandTable, (char*)(intptr_t)menuID); if (commandEntryPtr != NULL) { | | | 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 | helpMenuRef->menuPtr, newIndex); } } } else { Tcl_HashEntry *commandEntryPtr = Tcl_FindHashEntry(&commandTable, (char*)(intptr_t)menuID); if (commandEntryPtr != NULL) { TkMenu *menuPtr = Tcl_GetHashValue(commandEntryPtr); if ((currentAppleMenuID == menuID) && (index > menuPtr->numEntries + 1)) { /* * We don't need to do anything here, the standard * Application event handler will open the built-in Apple * menu item for us. |
︙ | ︙ | |||
2361 2362 2363 2364 2365 2366 2367 | (UInt8*)&geometryPtr->accelGlyph, 1, kTextEncodingMacKeyboardGlyphs, false); if (cfStr) { width = MeasureThemeText(cfStr, kThemeMenuItemCmdKeyFont); CFRelease(cfStr); } } | | | 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 | (UInt8*)&geometryPtr->accelGlyph, 1, kTextEncodingMacKeyboardGlyphs, false); if (cfStr) { width = MeasureThemeText(cfStr, kThemeMenuItemCmdKeyFont); CFRelease(cfStr); } } if (!(mePtr->entryFlags & ENTRY_ACCEL_MASK)) { if (!geometryPtr->accelGlyph) { width = Tk_TextWidth(tkfont, accel, mePtr->accelLength); } *textWidthPtr = maxWidth; if (width < maxWidth) { *modWidthPtr = 0; } else { |
︙ | ︙ | |||
2625 2626 2627 2628 2629 2630 2631 | case ENTRY_DISABLED: drawState = kThemeStateInactive; break; default: drawState = kThemeStateActive; break; } | | | 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 | case ENTRY_DISABLED: drawState = kThemeStateInactive; break; default: drawState = kThemeStateActive; break; } if (!(mePtr->entryFlags & ENTRY_ACCEL_MASK)) { leftEdge -= geometryPtr->modifierWidth; } if (geometryPtr->accelGlyph) { Rect bounds = {y, leftEdge, y + height, leftEdge + geometryPtr->accelTextWidth}; cfStr = CFStringCreateWithBytes(NULL, |
︙ | ︙ |
Changes to carbon/tkMacOSXMenubutton.c.
︙ | ︙ | |||
930 931 932 933 934 935 936 | XEvent *eventPtr) /* Information about event. */ { TkMenuButton *buttonPtr = (TkMenuButton *) clientData; MacMenuButton *mbPtr = (MacMenuButton *) clientData; if (eventPtr->type == ActivateNotify || eventPtr->type == DeactivateNotify) { | | | | | 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 | XEvent *eventPtr) /* Information about event. */ { TkMenuButton *buttonPtr = (TkMenuButton *) clientData; MacMenuButton *mbPtr = (MacMenuButton *) clientData; if (eventPtr->type == ActivateNotify || eventPtr->type == DeactivateNotify) { if ((buttonPtr->tkwin == NULL) || !Tk_IsMapped(buttonPtr->tkwin)) { return; } if (eventPtr->type == ActivateNotify) { mbPtr->flags |= ACTIVE; } else { mbPtr->flags &= ~ACTIVE; } if (!(buttonPtr->flags & REDRAW_PENDING)) { Tcl_DoWhenIdle(TkpDisplayMenuButton, buttonPtr); buttonPtr->flags |= REDRAW_PENDING; } } } |
Changes to carbon/tkMacOSXWindowEvent.c.
︙ | ︙ | |||
881 882 883 884 885 886 887 | protPtr = protPtr->nextPtr) { if (protocol == protPtr->protocol) { Tcl_Preserve(protPtr); interp = protPtr->interp; Tcl_Preserve(interp); result = Tcl_GlobalEval(interp, protPtr->command); if (result != TCL_OK) { | < | > | < | 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 | protPtr = protPtr->nextPtr) { if (protocol == protPtr->protocol) { Tcl_Preserve(protPtr); interp = protPtr->interp; Tcl_Preserve(interp); result = Tcl_GlobalEval(interp, protPtr->command); if (result != TCL_OK) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( "\n (command for \"%s\" window manager protocol)", Tk_GetAtomName((Tk_Window) winPtr, protocol))); Tcl_BackgroundException(interp, result); } Tcl_Release(interp); Tcl_Release(protPtr); return; } } |
︙ | ︙ |
Changes to carbon/tkMacOSXWm.c.
︙ | ︙ | |||
205 206 207 208 209 210 211 | static WindowGroupRef WmGetWindowGroup(TkWindow *winPtr); static void GetMinSize(TkWindow *winPtr, int *minWidthPtr, int *minHeightPtr); static void GetMaxSize(TkWindow *winPtr, int *maxWidthPtr, int *maxHeightPtr); static void RemapWindows(TkWindow *winPtr, MacDrawable *parentWin); | | | 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | static WindowGroupRef WmGetWindowGroup(TkWindow *winPtr); static void GetMinSize(TkWindow *winPtr, int *minWidthPtr, int *minHeightPtr); static void GetMaxSize(TkWindow *winPtr, int *maxWidthPtr, int *maxHeightPtr); static void RemapWindows(TkWindow *winPtr, MacDrawable *parentWin); /* *---------------------------------------------------------------------- * * TkWmNewWindow -- * * This procedure is invoked whenever a new top-level window is created. * Its job is to initialize the WmInfo structure for the window. |
︙ | ︙ | |||
301 302 303 304 305 306 307 | /* * Arrange for geometry requests to be reflected from the window to the * window manager. */ Tk_ManageGeometry((Tk_Window) winPtr, &wmMgrType, (ClientData) 0); } | | | 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | /* * Arrange for geometry requests to be reflected from the window to the * window manager. */ Tk_ManageGeometry((Tk_Window) winPtr, &wmMgrType, (ClientData) 0); } /* *---------------------------------------------------------------------- * * TkWmMapWindow -- * * This procedure is invoked to map a top-level window. This module gets * a chance to update all window-manager-related information in |
︙ | ︙ | |||
400 401 402 403 404 405 406 | /* * Map the window. */ XMapWindow(winPtr->display, winPtr->window); } | | | 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | /* * Map the window. */ XMapWindow(winPtr->display, winPtr->window); } /* *---------------------------------------------------------------------- * * TkWmUnmapWindow -- * * This procedure is invoked to unmap a top-level window. On the * Macintosh all we do is call XUnmapWindow. |
︙ | ︙ | |||
425 426 427 428 429 430 431 | void TkWmUnmapWindow( TkWindow *winPtr) /* Top-level window that's about to be * mapped. */ { XUnmapWindow(winPtr->display, winPtr->window); } | | | 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | void TkWmUnmapWindow( TkWindow *winPtr) /* Top-level window that's about to be * mapped. */ { XUnmapWindow(winPtr->display, winPtr->window); } /* *---------------------------------------------------------------------- * * TkWmDeadWindow -- * * This procedure is invoked when a top-level window is about to be * deleted. It cleans up the wm-related data structures for the window. |
︙ | ︙ | |||
496 497 498 499 500 501 502 | } if (wmPtr->flags & WM_UPDATE_PENDING) { Tk_CancelIdleCall(UpdateGeometryInfo, winPtr); } ckfree(wmPtr); winPtr->wmInfoPtr = NULL; } | | | 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | } if (wmPtr->flags & WM_UPDATE_PENDING) { Tk_CancelIdleCall(UpdateGeometryInfo, winPtr); } ckfree(wmPtr); winPtr->wmInfoPtr = NULL; } /* *---------------------------------------------------------------------- * * TkWmSetClass -- * * This procedure is invoked whenever a top-level window's class is * changed. If the window has been mapped then this procedure updates the |
︙ | ︙ | |||
522 523 524 525 526 527 528 | void TkWmSetClass( TkWindow *winPtr) /* Newly-created top-level window. */ { return; } | | | 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 | void TkWmSetClass( TkWindow *winPtr) /* Newly-created top-level window. */ { return; } /* *---------------------------------------------------------------------- * * Tk_WmObjCmd -- * * This procedure is invoked to process the "wm" Tcl command. See the * user documentation for details on what it does. |
︙ | ︙ | |||
581 582 583 584 585 586 587 | wrongNumArgs: Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg ...?"); return TCL_ERROR; } argv1 = Tcl_GetStringFromObj(objv[1], &length); if ((argv1[0] == 't') && (strncmp(argv1, "tracing", length) == 0) | | | | | | > > | 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 | wrongNumArgs: Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg ...?"); return TCL_ERROR; } argv1 = Tcl_GetStringFromObj(objv[1], &length); if ((argv1[0] == 't') && (strncmp(argv1, "tracing", length) == 0) && (length >= 3)) { if ((objc != 2) && (objc != 3)) { Tcl_WrongNumArgs(interp, 2, objv, "?boolean?"); return TCL_ERROR; } if (objc == 2) { Tcl_SetObjResult(interp, Tcl_NewBooleanObj(wmTracing)); return TCL_OK; } return Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing); } if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, &index) != TCL_OK) { return TCL_ERROR; } if (objc < 3) { goto wrongNumArgs; } if (TkGetWindowFromObj(interp, tkwin, objv[2], (Tk_Window *) &winPtr) != TCL_OK) { return TCL_ERROR; } if (!Tk_IsTopLevel(winPtr) && (index != WMOPT_MANAGE) && (index != WMOPT_FORGET)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't a top-level window", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TOPLEVEL", winPtr->pathName, NULL); return TCL_ERROR; } switch ((enum options) index) { case WMOPT_ASPECT: return WmAspectCmd(tkwin, winPtr, interp, objc, objv); case WMOPT_ATTRIBUTES: |
︙ | ︙ | |||
683 684 685 686 687 688 689 | case WMOPT_WITHDRAW: return WmWithdrawCmd(tkwin, winPtr, interp, objc, objv); } /* This should not happen */ return TCL_ERROR; } | | | 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 | case WMOPT_WITHDRAW: return WmWithdrawCmd(tkwin, winPtr, interp, objc, objv); } /* This should not happen */ return TCL_ERROR; } /* *---------------------------------------------------------------------- * * WmAspectCmd -- * * This procedure is invoked to process the "wm aspect" Tcl command. See * the user documentation for details on what it does. |
︙ | ︙ | |||
719 720 721 722 723 724 725 | if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?minNumer minDenom maxNumer maxDenom?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & PAspect) { | | | | > | | > | > | | 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 | if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?minNumer minDenom maxNumer maxDenom?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & PAspect) { Tcl_Obj *aspect[4]; aspect[0] = Tcl_NewIntObj(wmPtr->minAspect.x); aspect[1] = Tcl_NewIntObj(wmPtr->minAspect.y); aspect[2] = Tcl_NewIntObj(wmPtr->maxAspect.x); aspect[3] = Tcl_NewIntObj(wmPtr->maxAspect.y); Tcl_SetObjResult(interp, Tcl_NewListObj(4, aspect)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->sizeHintsFlags &= ~PAspect; } else { if ((Tcl_GetIntFromObj(interp, objv[3], &numer1) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &denom1) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[5], &numer2) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[6], &denom2) != TCL_OK)) { return TCL_ERROR; } if ((numer1 <= 0) || (denom1 <= 0) || (numer2 <= 0) || (denom2 <= 0)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "aspect number can't be <= 0", -1)); Tcl_SetErrorCode(interp, "TK", "WM", "ASPECT", NULL); return TCL_ERROR; } wmPtr->minAspect.x = numer1; wmPtr->minAspect.y = denom1; wmPtr->maxAspect.x = numer2; wmPtr->maxAspect.y = denom2; wmPtr->sizeHintsFlags |= PAspect; } wmPtr->flags |= WM_UPDATE_SIZE_HINTS; WmUpdateGeom(wmPtr, winPtr); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmSetAttribute -- * * Helper routine for WmAttributesCmd. Sets the value of the specified * attribute. |
︙ | ︙ | |||
928 929 930 931 932 933 934 | break; case _WMATT_LAST_ATTRIBUTE: default: return TCL_ERROR; } return TCL_OK; } | | | 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 | break; case _WMATT_LAST_ATTRIBUTE: default: return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- * * WmGetAttribute -- * * Helper routine for WmAttributesCmd. Returns the current value of the * specified attribute. |
︙ | ︙ | |||
1003 1004 1005 1006 1007 1008 1009 | break; case _WMATT_LAST_ATTRIBUTE: default: break; } return result; } | | | 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 | break; case _WMATT_LAST_ATTRIBUTE: default: break; } return result; } /* *---------------------------------------------------------------------- * * WmAttributesCmd -- * * This procedure is invoked to process the "wm attributes" Tcl command. * See the user documentation for details on what it does. |
︙ | ︙ | |||
1041 1042 1043 1044 1045 1046 1047 | } if (!TkMacOSXHostToplevelExists(winPtr)) { TkMacOSXMakeRealWindowExist(winPtr); } macWindow = TkMacOSXDrawableWindow(winPtr->window); if (objc == 3) { /* wm attributes $win */ | | | | | | | | 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 | } if (!TkMacOSXHostToplevelExists(winPtr)) { TkMacOSXMakeRealWindowExist(winPtr); } macWindow = TkMacOSXDrawableWindow(winPtr->window); if (objc == 3) { /* wm attributes $win */ Tcl_Obj *result = Tcl_NewObj(); for (attribute = 0; attribute < _WMATT_LAST_ATTRIBUTE; ++attribute) { Tcl_ListObjAppendElement(NULL, result, Tcl_NewStringObj(WmAttributeNames[attribute], -1)); Tcl_ListObjAppendElement(NULL, result, WmGetAttribute(winPtr, macWindow, attribute)); } Tcl_SetObjResult(interp, result); } else if (objc == 4) { /* wm attributes $win -attribute */ if (Tcl_GetIndexFromObj(interp, objv[3], WmAttributeNames, "attribute", 0, &attribute) != TCL_OK) { return TCL_ERROR; } Tcl_SetObjResult(interp, WmGetAttribute(winPtr, macWindow, attribute)); } else if ((objc - 3) % 2 == 0) { /* wm attributes $win -att value... */ int i; for (i = 3; i < objc; i += 2) { if (Tcl_GetIndexFromObj(interp, objv[i], WmAttributeNames, "attribute", 0, &attribute) != TCL_OK) { return TCL_ERROR; } if (WmSetAttribute(winPtr, macWindow, interp, attribute, objv[i+1]) != TCL_OK) { return TCL_ERROR; } } } else { Tcl_WrongNumArgs(interp, 2, objv, "window ?-attribute ?value ...??"); return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- * * WmClientCmd -- * * This procedure is invoked to process the "wm client" Tcl command. See * the user documentation for details on what it does. |
︙ | ︙ | |||
1111 1112 1113 1114 1115 1116 1117 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->clientMachine != NULL) { | > | | | 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->clientMachine != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->clientMachine, -1)); } return TCL_OK; } argv3 = Tcl_GetStringFromObj(objv[3], &length); if (argv3[0] == 0) { if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); wmPtr->clientMachine = NULL; } return TCL_OK; } if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); } wmPtr->clientMachine = ckalloc(length + 1); strcpy(wmPtr->clientMachine, argv3); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmColormapwindowsCmd -- * * This procedure is invoked to process the "wm colormapwindows" Tcl * command. See the user documentation for details on what it does. |
︙ | ︙ | |||
1157 1158 1159 1160 1161 1162 1163 | 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; | | < | > | > | > | | 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 | 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 **cmapList, *winPtr2; int i, windowObjc, gotToplevel = 0; Tcl_Obj **windowObjv, *resultObj; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?windowList?"); return TCL_ERROR; } if (objc == 3) { Tk_MakeWindowExist((Tk_Window) winPtr); resultObj = Tcl_NewObj(); for (i = 0; i < wmPtr->cmapCount; i++) { if ((i == (wmPtr->cmapCount-1)) && (wmPtr->flags & WM_ADDED_TOPLEVEL_COLORMAP)) { break; } Tcl_ListObjAppendElement(NULL, resultObj, TkNewWindowObj((Tk_Window) wmPtr->cmapList[i])); } Tcl_SetObjResult(interp, resultObj); return TCL_OK; } if (Tcl_ListObjGetElements(interp, objv[3], &windowObjc, &windowObjv) != TCL_OK) { return TCL_ERROR; } cmapList = ckalloc((windowObjc+1) * sizeof(TkWindow*)); for (i = 0; i < windowObjc; i++) { if (TkGetWindowFromObj(interp, tkwin, windowObjv[i], (Tk_Window *) &winPtr2) != TCL_OK) { ckfree(cmapList); |
︙ | ︙ | |||
1217 1218 1219 1220 1221 1222 1223 | /* * On the Macintosh all of this is just an excercise in compatability as * we don't support colormaps. If we did they would be installed here. */ return TCL_OK; } | | | 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 | /* * On the Macintosh all of this is just an excercise in compatability as * we don't support colormaps. If we did they would be installed here. */ return TCL_OK; } /* *---------------------------------------------------------------------- * * WmCommandCmd -- * * This procedure is invoked to process the "wm command" Tcl command. See * the user documentation for details on what it does. |
︙ | ︙ | |||
1254 1255 1256 1257 1258 1259 1260 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?value?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->cmdArgv != NULL) { | | | | 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?value?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->cmdArgv != NULL) { argv3 = Tcl_Merge(wmPtr->cmdArgc, wmPtr->cmdArgv); Tcl_SetObjResult(interp, Tcl_NewStringObj(argv3, -1)); ckfree(argv3); } return TCL_OK; } argv3 = Tcl_GetString(objv[3]); if (argv3[0] == 0) { if (wmPtr->cmdArgv != NULL) { |
︙ | ︙ | |||
1278 1279 1280 1281 1282 1283 1284 | if (wmPtr->cmdArgv != NULL) { ckfree(wmPtr->cmdArgv); } wmPtr->cmdArgc = cmdArgc; wmPtr->cmdArgv = cmdArgv; return TCL_OK; } | | | 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 | if (wmPtr->cmdArgv != NULL) { ckfree(wmPtr->cmdArgv); } wmPtr->cmdArgc = cmdArgc; wmPtr->cmdArgv = cmdArgv; return TCL_OK; } /* *---------------------------------------------------------------------- * * WmDeiconifyCmd -- * * This procedure is invoked to process the "wm deiconify" Tcl command. * See the user documentation for details on what it does. |
︙ | ︙ | |||
1311 1312 1313 1314 1315 1316 1317 | register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { | > | | > | | > > | | 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 | register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't deiconify %s: it is an icon for %s", Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "DEICONIFY", "ICON", NULL); return TCL_ERROR; } if (winPtr->flags & TK_EMBEDDED) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't deiconify %s: it is an embedded window", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "DEICONIFY", "EMBEDDED", NULL); return TCL_ERROR; } TkpWmSetState(winPtr, TkMacOSXIsWindowZoomed(winPtr) ? ZoomState : NormalState); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmFocusmodelCmd -- * * This procedure is invoked to process the "wm focusmodel" Tcl command. * See the user documentation for details on what it does. |
︙ | ︙ | |||
1362 1363 1364 1365 1366 1367 1368 | int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?"); return TCL_ERROR; } if (objc == 3) { | > | < | | 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 | int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?"); return TCL_ERROR; } if (objc == 3) { Tcl_SetObjResult(interp, Tcl_NewStringObj( wmPtr->hints.input ? "passive" : "active", -1)); return TCL_OK; } if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } if (index == OPT_ACTIVE) { wmPtr->hints.input = False; } else { /* OPT_PASSIVE */ wmPtr->hints.input = True; } return TCL_OK; } /* *---------------------------------------------------------------------- * * WmForgetCmd -- * * This procedure is invoked to process the "wm forget" Tcl command. * See the user documentation for details on what it does. |
︙ | ︙ | |||
1405 1406 1407 1408 1409 1410 1411 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { #if 1 | > | > | 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { #if 1 Tcl_SetObjResult(interp, Tcl_NewStringObj( "wm forget is not yet supported", -1)); Tcl_SetErrorCode(interp, "TK", "WM", "UNSUPPORTED", NULL); return TCL_ERROR; #else register Tk_Window frameWin = (Tk_Window)winPtr; char *oldClass = (char*)Tk_Class(frameWin); if (Tk_IsTopLevel(frameWin)) { MacDrawable *macWin = (MacDrawable *) winPtr->window; |
︙ | ︙ | |||
1440 1441 1442 1443 1444 1445 1446 | TkMapTopFrame(frameWin); } else { /* Already not managed by wm - ignore it */ } return TCL_OK; #endif } | | | 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 | TkMapTopFrame(frameWin); } else { /* Already not managed by wm - ignore it */ } return TCL_OK; #endif } /* *---------------------------------------------------------------------- * * WmFrameCmd -- * * This procedure is invoked to process the "wm frame" Tcl command. See * the user documentation for details on what it does. |
︙ | ︙ | |||
1468 1469 1470 1471 1472 1473 1474 | 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; Window window; | < | < | | 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 | 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; Window window; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } window = wmPtr->reparent; if (window == None) { window = Tk_WindowId((Tk_Window) winPtr); } Tcl_SetObjResult(interp, Tcl_ObjPrintf("0x%x", (unsigned) window)); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmGeometryCmd -- * * This procedure is invoked to process the "wm geometry" Tcl command. * See the user documentation for details on what it does. |
︙ | ︙ | |||
1518 1519 1520 1521 1522 1523 1524 | char *argv3; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newGeometry?"); return TCL_ERROR; } if (objc == 3) { | < < | | < | | 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 | char *argv3; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newGeometry?"); return TCL_ERROR; } if (objc == 3) { xSign = (wmPtr->flags & WM_NEGATIVE_X) ? '-' : '+'; ySign = (wmPtr->flags & WM_NEGATIVE_Y) ? '-' : '+'; if (wmPtr->gridWin != NULL) { width = wmPtr->reqGridWidth + (winPtr->changes.width - winPtr->reqWidth)/wmPtr->widthInc; height = wmPtr->reqGridHeight + (winPtr->changes.height - winPtr->reqHeight)/wmPtr->heightInc; } else { width = winPtr->changes.width; height = winPtr->changes.height; } Tcl_SetObjResult(interp, Tcl_ObjPrintf("%dx%d%c%d%c%d", width, height, xSign, wmPtr->x, ySign, wmPtr->y)); return TCL_OK; } argv3 = Tcl_GetString(objv[3]); if (*argv3 == '\0') { wmPtr->width = -1; wmPtr->height = -1; WmUpdateGeom(wmPtr, winPtr); return TCL_OK; } return ParseGeometry(interp, argv3, winPtr); } /* *---------------------------------------------------------------------- * * WmGridCmd -- * * This procedure is invoked to process the "wm grid" Tcl command. See * the user documentation for details on what it does. |
︙ | ︙ | |||
1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 | 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; int reqWidth, reqHeight, widthInc, heightInc; if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?baseWidth baseHeight widthInc heightInc?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & PBaseSize) { | > | | | > | | | 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 | 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; int reqWidth, reqHeight, widthInc, heightInc; const char *errorMsg; if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?baseWidth baseHeight widthInc heightInc?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & PBaseSize) { Tcl_Obj *grid[4]; grid[0] = Tcl_NewIntObj(wmPtr->reqGridWidth); grid[1] = Tcl_NewIntObj(wmPtr->reqGridHeight); grid[2] = Tcl_NewIntObj(wmPtr->widthInc); grid[3] = Tcl_NewIntObj(wmPtr->heightInc); Tcl_SetObjResult(interp, Tcl_NewListObj(4, grid)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { /* * Turn off gridding and reset the width and height to make sense as * ungridded numbers. |
︙ | ︙ | |||
1613 1614 1615 1616 1617 1618 1619 | if ((Tcl_GetIntFromObj(interp, objv[3], &reqWidth) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &reqHeight) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[5], &widthInc) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[6], &heightInc)!=TCL_OK)) { return TCL_ERROR; } if (reqWidth < 0) { | | | < | | < < > | | < < > | | < > | > > > > | > | 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 | if ((Tcl_GetIntFromObj(interp, objv[3], &reqWidth) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &reqHeight) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[5], &widthInc) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[6], &heightInc)!=TCL_OK)) { return TCL_ERROR; } if (reqWidth < 0) { errorMsg = "baseWidth can't be < 0"; goto error; } else if (reqHeight < 0) { errorMsg = "baseHeight can't be < 0"; goto error; } else if (widthInc <= 0) { errorMsg = "widthInc can't be <= 0"; goto error; } else if (heightInc <= 0) { errorMsg = "heightInc can't be <= 0"; goto error; } Tk_SetGrid((Tk_Window) winPtr, reqWidth, reqHeight, widthInc, heightInc); } wmPtr->flags |= WM_UPDATE_SIZE_HINTS; WmUpdateGeom(wmPtr, winPtr); return TCL_OK; error: Tcl_SetObjResult(interp, Tcl_NewStringObj(errorMsg, -1)); Tcl_SetErrorCode(interp, "TK", "WM", "GRID", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * WmGroupCmd -- * * This procedure is invoked to process the "wm group" Tcl command. See * the user documentation for details on what it does. |
︙ | ︙ | |||
1672 1673 1674 1675 1676 1677 1678 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & WindowGroupHint) { | | | 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & WindowGroupHint) { Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->leaderName, -1)); } return TCL_OK; } argv3 = Tcl_GetStringFromObj(objv[3], &length); if (*argv3 == '\0') { wmPtr->hints.flags &= ~WindowGroupHint; if (wmPtr->leaderName != NULL) { |
︙ | ︙ | |||
1698 1699 1700 1701 1702 1703 1704 | wmPtr->hints.window_group = Tk_WindowId(tkwin2); wmPtr->hints.flags |= WindowGroupHint; wmPtr->leaderName = ckalloc(length + 1); strcpy(wmPtr->leaderName, argv3); } return TCL_OK; } | | | 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 | wmPtr->hints.window_group = Tk_WindowId(tkwin2); wmPtr->hints.flags |= WindowGroupHint; wmPtr->leaderName = ckalloc(length + 1); strcpy(wmPtr->leaderName, argv3); } return TCL_OK; } /* *---------------------------------------------------------------------- * * WmIconbitmapCmd -- * * This procedure is invoked to process the "wm iconbitmap" Tcl command. * See the user documentation for details on what it does. |
︙ | ︙ | |||
1735 1736 1737 1738 1739 1740 1741 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconPixmapHint) { | > | | | 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconPixmapHint) { Tcl_SetObjResult(interp, Tcl_NewStringObj( Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_pixmap), -1)); } return TCL_OK; } str = Tcl_GetStringFromObj(objv[3], &len); if (winPtr->window == None) { Tk_MakeWindowExist((Tk_Window) winPtr); } |
︙ | ︙ | |||
1766 1767 1768 1769 1770 1771 1772 | return TCL_ERROR; } wmPtr->hints.icon_pixmap = pixmap; wmPtr->hints.flags |= IconPixmapHint; } return TCL_OK; } | | | 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 | return TCL_ERROR; } wmPtr->hints.icon_pixmap = pixmap; wmPtr->hints.flags |= IconPixmapHint; } return TCL_OK; } /* *---------------------------------------------------------------------- * * WmIconifyCmd -- * * This procedure is invoked to process the "wm iconify" Tcl command. See * the user documentation for details on what it does. |
︙ | ︙ | |||
1797 1798 1799 1800 1801 1802 1803 1804 | Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) { | > | | > > > < | | | > < | | > | > < | | | > > > | | 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 | Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } 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->master != None) { 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", winPtr->pathName, Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "ICON", NULL); return TCL_ERROR; } else if (winPtr->flags & TK_EMBEDDED) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify %s: it is an embedded window", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "EMBEDDED", NULL); return TCL_ERROR; } TkpWmSetState(winPtr, IconicState); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmIconmaskCmd -- * * This procedure is invoked to process the "wm iconmask" Tcl command. * See the user documentation for details on what it does. |
︙ | ︙ | |||
1856 1857 1858 1859 1860 1861 1862 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconMaskHint) { | > | | | | 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconMaskHint) { Tcl_SetObjResult(interp, Tcl_NewStringObj( Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_mask), -1)); } return TCL_OK; } argv3 = Tcl_GetString(objv[3]); if (*argv3 == '\0') { if (wmPtr->hints.icon_mask != None) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_mask); } wmPtr->hints.flags &= ~IconMaskHint; } else { pixmap = Tk_GetBitmap(interp, tkwin, argv3); if (pixmap == None) { return TCL_ERROR; } wmPtr->hints.icon_mask = pixmap; wmPtr->hints.flags |= IconMaskHint; } return TCL_OK; } /* *---------------------------------------------------------------------- * * WmIconnameCmd -- * * This procedure is invoked to process the "wm iconname" Tcl command. * See the user documentation for details on what it does. |
︙ | ︙ | |||
1929 1930 1931 1932 1933 1934 1935 | wmPtr->iconName = ckalloc(length + 1); strcpy(wmPtr->iconName, argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName); } return TCL_OK; } | | | 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 | wmPtr->iconName = ckalloc(length + 1); strcpy(wmPtr->iconName, argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName); } return TCL_OK; } /* *---------------------------------------------------------------------- * * WmIconphotoCmd -- * * This procedure is invoked to process the "wm iconphoto" Tcl command. * See the user documentation for details on what it does. Not yet |
︙ | ︙ | |||
1981 1982 1983 1984 1985 1986 1987 | * Iterate over all images to retrieve their sizes, in order to allocate a * buffer large enough to hold all images. */ for (i = 3 + isDefault; i < objc; i++) { photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i])); if (photo == NULL) { | | | > > | | 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 | * Iterate over all images to retrieve their sizes, in order to allocate a * buffer large enough to hold all images. */ for (i = 3 + isDefault; i < objc; i++) { photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i])); if (photo == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't use \"%s\" as iconphoto: not a photo image", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL); return TCL_ERROR; } Tk_PhotoGetSize(photo, &width, &height); } /* * TODO: This requires implementation for OS X, but we silently return for * now. */ return TCL_OK; } /* *---------------------------------------------------------------------- * * WmIconpositionCmd -- * * This procedure is invoked to process the "wm iconposition" Tcl * command. See the user documentation for details on what it does. |
︙ | ︙ | |||
2030 2031 2032 2033 2034 2035 2036 | if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconPositionHint) { | | | | | | | | 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 | if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconPositionHint) { Tcl_Obj *pos[2]; pos[0] = Tcl_NewIntObj(wmPtr->hints.icon_x); pos[1] = Tcl_NewIntObj(wmPtr->hints.icon_y); Tcl_SetObjResult(interp, Tcl_NewListObj(2, pos)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->hints.flags &= ~IconPositionHint; } else { if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)){ return TCL_ERROR; } wmPtr->hints.icon_x = x; wmPtr->hints.icon_y = y; wmPtr->hints.flags |= IconPositionHint; } return TCL_OK; } /* *---------------------------------------------------------------------- * * WmIconwindowCmd -- * * This procedure is invoked to process the "wm iconwindow" Tcl command. * See the user documentation for details on what it does. |
︙ | ︙ | |||
2087 2088 2089 2090 2091 2092 2093 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->icon != NULL) { | | | | > > > | | | > | 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->icon != NULL) { Tcl_SetObjResult(interp, TkNewWindowObj(wmPtr->icon)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->hints.flags &= ~IconWindowHint; if (wmPtr->icon != NULL) { wmPtr2 = ((TkWindow *) wmPtr->icon)->wmInfoPtr; wmPtr2->iconFor = NULL; wmPtr2->hints.initial_state = WithdrawnState; } wmPtr->icon = NULL; } else { if (TkGetWindowFromObj(interp, tkwin, objv[3], &tkwin2) != TCL_OK) { return TCL_ERROR; } if (!Tk_IsTopLevel(tkwin2)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't use %s as icon window: not at top level", Tk_PathName(tkwin2))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONWINDOW", "TOPLEVEL", NULL); return TCL_ERROR; } wmPtr2 = ((TkWindow *) tkwin2)->wmInfoPtr; if (wmPtr2->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s is already an icon for %s", Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONWINDOW", "ICON", NULL); return TCL_ERROR; } if (wmPtr->icon != NULL) { WmInfo *wmPtr3 = ((TkWindow *) wmPtr->icon)->wmInfoPtr; wmPtr3->iconFor = NULL; } Tk_MakeWindowExist(tkwin2); |
︙ | ︙ | |||
2134 2135 2136 2137 2138 2139 2140 | */ Tk_UnmapWindow(tkwin2); } } return TCL_OK; } | | | 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 | */ Tk_UnmapWindow(tkwin2); } } return TCL_OK; } /* *---------------------------------------------------------------------- * * WmManageCmd -- * * This procedure is invoked to process the "wm manage" Tcl command. See * the user documentation for details on what it does. |
︙ | ︙ | |||
2161 2162 2163 2164 2165 2166 2167 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { #if 1 | > | > | | | > > | 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 | Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { #if 1 Tcl_SetObjResult(interp, Tcl_NewStringObj( "wm manage is not yet supported", -1)); Tcl_SetErrorCode(interp, "TK", "WM", "UNSUPPORTED", NULL); return TCL_ERROR; #else register Tk_Window frameWin = (Tk_Window)winPtr; register WmInfo *wmPtr = winPtr->wmInfoPtr; char *oldClass = (char*)Tk_Class(frameWin); if (!Tk_IsTopLevel(frameWin)) { MacDrawable *macWin = (MacDrawable *) winPtr->window; if (!Tk_IsManageable(frameWin)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" is not manageable: must be a" " frame, labelframe or toplevel", Tk_PathName(frameWin))); Tcl_SetErrorCode(interp, "TK", "WM", "MANAGE", NULL); return TCL_ERROR; } TkFocusSplit(winPtr); Tk_UnmapWindow(frameWin); if (wmPtr == NULL) { TkWmNewWindow(winPtr); if (winPtr->window == None) { |
︙ | ︙ | |||
2202 2203 2204 2205 2206 2207 2208 | TkMapTopFrame(frameWin); } else if (Tk_IsTopLevel(frameWin)) { /* Already managed by wm - ignore it */ } return TCL_OK; #endif } | | | 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 | TkMapTopFrame(frameWin); } else if (Tk_IsTopLevel(frameWin)) { /* Already managed by wm - ignore it */ } return TCL_OK; #endif } /* *---------------------------------------------------------------------- * * WmMaxsizeCmd -- * * This procedure is invoked to process the "wm maxsize" Tcl command. See * the user documentation for details on what it does. |
︙ | ︙ | |||
2236 2237 2238 2239 2240 2241 2242 | int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { | | > | | | | | 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 | int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { Tcl_Obj *size[2]; GetMaxSize(winPtr, &width, &height); size[0] = Tcl_NewIntObj(width); size[1] = Tcl_NewIntObj(height); Tcl_SetObjResult(interp, Tcl_NewListObj(2, size)); return TCL_OK; } if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &height) != TCL_OK)) { return TCL_ERROR; } wmPtr->maxWidth = width; wmPtr->maxHeight = height; wmPtr->flags |= WM_UPDATE_SIZE_HINTS; WmUpdateGeom(wmPtr, winPtr); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmMinsizeCmd -- * * This procedure is invoked to process the "wm minsize" Tcl command. See * the user documentation for details on what it does. |
︙ | ︙ | |||
2287 2288 2289 2290 2291 2292 2293 | int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { | | > | | | | 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 | int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { Tcl_Obj *size[2]; GetMinSize(winPtr, &width, &height); size[0] = Tcl_NewIntObj(width); size[1] = Tcl_NewIntObj(height); Tcl_SetObjResult(interp, Tcl_NewListObj(2, size)); return TCL_OK; } if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &height) != TCL_OK)) { return TCL_ERROR; } wmPtr->minWidth = width; wmPtr->minHeight = height; wmPtr->flags |= WM_UPDATE_SIZE_HINTS; WmUpdateGeom(wmPtr, winPtr); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmOverrideredirectCmd -- * * This procedure is invoked to process the "wm overrideredirect" Tcl * command. See the user documentation for details on what it does. |
︙ | ︙ | |||
2350 2351 2352 2353 2354 2355 2356 | return TCL_ERROR; } atts.override_redirect = (boolean) ? True : False; Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect, &atts); ApplyMasterOverrideChanges(winPtr, NULL); return TCL_OK; } | | | 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 | return TCL_ERROR; } atts.override_redirect = (boolean) ? True : False; Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect, &atts); ApplyMasterOverrideChanges(winPtr, NULL); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmPositionfromCmd -- * * This procedure is invoked to process the "wm positionfrom" Tcl * command. See the user documentation for details on what it does. |
︙ | ︙ | |||
2389 2390 2391 2392 2393 2394 2395 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & USPosition) { | | | | 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & USPosition) { Tcl_SetObjResult(interp, Tcl_NewStringObj("user", -1)); } else if (wmPtr->sizeHintsFlags & PPosition) { Tcl_SetObjResult(interp, Tcl_NewStringObj("program", -1)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->sizeHintsFlags &= ~(USPosition|PPosition); } else { if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, |
︙ | ︙ | |||
2414 2415 2416 2417 2418 2419 2420 | wmPtr->sizeHintsFlags |= PPosition; } } wmPtr->flags |= WM_UPDATE_SIZE_HINTS; WmUpdateGeom(wmPtr, winPtr); return TCL_OK; } | | | 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 | wmPtr->sizeHintsFlags |= PPosition; } } wmPtr->flags |= WM_UPDATE_SIZE_HINTS; WmUpdateGeom(wmPtr, winPtr); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmProtocolCmd -- * * This procedure is invoked to process the "wm protocol" Tcl command. * See the user documentation for details on what it does. |
︙ | ︙ | |||
2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 | Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; register ProtocolHandler *protPtr, *prevPtr; Atom protocol; char *cmd; int cmdLength; if ((objc < 3) || (objc > 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?"); return TCL_ERROR; } if (objc == 3) { /* * Return a list of all defined protocols for the window. */ for (protPtr = wmPtr->protPtr; protPtr != NULL; protPtr = protPtr->nextPtr) { | > > | | > > | | 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 | Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; register ProtocolHandler *protPtr, *prevPtr; Atom protocol; char *cmd; int cmdLength; Tcl_Obj *resultObj; if ((objc < 3) || (objc > 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?"); return TCL_ERROR; } if (objc == 3) { /* * Return a list of all defined protocols for the window. */ resultObj = Tcl_NewObj(); for (protPtr = wmPtr->protPtr; protPtr != NULL; protPtr = protPtr->nextPtr) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( Tk_GetAtomName((Tk_Window)winPtr, protPtr->protocol),-1)); } Tcl_SetObjResult(interp, resultObj); return TCL_OK; } protocol = Tk_InternAtom((Tk_Window) winPtr, Tcl_GetString(objv[3])); if (objc == 4) { /* * Return the command to handle a given protocol. */ for (protPtr = wmPtr->protPtr; protPtr != NULL; protPtr = protPtr->nextPtr) { if (protPtr->protocol == protocol) { Tcl_SetObjResult(interp, Tcl_NewStringObj(protPtr->command, -1)); return TCL_OK; } } return TCL_OK; } /* |
︙ | ︙ | |||
2506 2507 2508 2509 2510 2511 2512 | protPtr->nextPtr = wmPtr->protPtr; wmPtr->protPtr = protPtr; protPtr->interp = interp; strcpy(protPtr->command, cmd); } return TCL_OK; } | | | 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 | protPtr->nextPtr = wmPtr->protPtr; wmPtr->protPtr = protPtr; protPtr->interp = interp; strcpy(protPtr->command, cmd); } return TCL_OK; } /* *---------------------------------------------------------------------- * * WmResizableCmd -- * * This procedure is invoked to process the "wm resizable" Tcl command. * See the user documentation for details on what it does. |
︙ | ︙ | |||
2541 2542 2543 2544 2545 2546 2547 | WindowAttributes oldAttributes = wmPtr->attributes; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { | | < | | | | | 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 | WindowAttributes oldAttributes = wmPtr->attributes; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { Tcl_Obj *resize[2]; resize[0] = Tcl_NewBooleanObj(!(wmPtr->flags & WM_WIDTH_NOT_RESIZABLE)); resize[1] = Tcl_NewBooleanObj(!(wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE)); Tcl_SetObjResult(interp, Tcl_NewListObj(2, resize)); return TCL_OK; } if ((Tcl_GetBooleanFromObj(interp, objv[3], &width) != TCL_OK) || (Tcl_GetBooleanFromObj(interp, objv[4], &height) != TCL_OK)) { return TCL_ERROR; } if (width) { wmPtr->flags &= ~WM_WIDTH_NOT_RESIZABLE; wmPtr->attributes |= kWindowHorizontalZoomAttribute; } else { wmPtr->flags |= WM_WIDTH_NOT_RESIZABLE; |
︙ | ︙ | |||
2574 2575 2576 2577 2578 2579 2580 | if (width || height) { wmPtr->attributes |= kWindowResizableAttribute; } else { wmPtr->attributes &= ~kWindowResizableAttribute; } wmPtr->flags |= WM_UPDATE_SIZE_HINTS; if (wmPtr->scrollWinPtr != NULL) { | | < | | 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 | if (width || height) { wmPtr->attributes |= kWindowResizableAttribute; } else { wmPtr->attributes &= ~kWindowResizableAttribute; } wmPtr->flags |= WM_UPDATE_SIZE_HINTS; if (wmPtr->scrollWinPtr != NULL) { TkScrollbarEventuallyRedraw(wmPtr->scrollWinPtr->instanceData); } WmUpdateGeom(wmPtr, winPtr); ApplyWindowClassAttributeChanges(winPtr, NULL, wmPtr->macClass, oldAttributes, 1); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmSizefromCmd -- * * This procedure is invoked to process the "wm sizefrom" Tcl command. * See the user documentation for details on what it does. |
︙ | ︙ | |||
2621 2622 2623 2624 2625 2626 2627 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & USSize) { | | | | 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & USSize) { Tcl_SetObjResult(interp, Tcl_NewStringObj("user", -1)); } else if (wmPtr->sizeHintsFlags & PSize) { Tcl_SetObjResult(interp, Tcl_NewStringObj("program", -1)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->sizeHintsFlags &= ~(USSize|PSize); } else { |
︙ | ︙ | |||
2647 2648 2649 2650 2651 2652 2653 | wmPtr->sizeHintsFlags |= PSize; } } wmPtr->flags |= WM_UPDATE_SIZE_HINTS; WmUpdateGeom(wmPtr, winPtr); return TCL_OK; } | | | 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 | wmPtr->sizeHintsFlags |= PSize; } } wmPtr->flags |= WM_UPDATE_SIZE_HINTS; WmUpdateGeom(wmPtr, winPtr); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmStackorderCmd -- * * This procedure is invoked to process the "wm stackorder" Tcl command. * See the user documentation for details on what it does. |
︙ | ︙ | |||
2673 2674 2675 2676 2677 2678 2679 | WmStackorderCmd( 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. */ { | | | > | > > > | | > > | | | | > > | | > < < | | | > > | > | | | | | | 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 | WmStackorderCmd( 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. */ { TkWindow **windows, **windowPtr; static const char *const optionStrings[] = { "isabove", "isbelow", NULL }; enum options { OPT_ISABOVE, OPT_ISBELOW }; Tcl_Obj *resultObj; int index; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?isabove|isbelow window?"); return TCL_ERROR; } if (objc == 3) { windows = TkWmStackorderToplevel(winPtr); if (windows == NULL) { Tcl_Panic("TkWmStackorderToplevel failed"); } resultObj = Tcl_NewObj(); for (windowPtr = windows; *windowPtr ; windowPtr++) { Tcl_ListObjAppendElement(NULL, resultObj, TkNewWindowObj((Tk_Window) *windowPtr)); } Tcl_SetObjResult(interp, resultObj); ckfree(windows); return TCL_OK; } else { TkWindow *winPtr2; int index1 = -1, index2 = -1, result; if (TkGetWindowFromObj(interp, tkwin, objv[4], (Tk_Window *) &winPtr2) != TCL_OK) { return TCL_ERROR; } if (!Tk_IsTopLevel(winPtr2)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't a top-level window", winPtr2->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "TOPLEVEL", NULL); return TCL_ERROR; } if (!Tk_IsMapped(winPtr)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't mapped", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", NULL); return TCL_ERROR; } else if (!Tk_IsMapped(winPtr2)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't mapped", winPtr2->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", NULL); return TCL_ERROR; } /* * Lookup stacking order of all toplevels that are children of "." and * find the position of winPtr and winPtr2 in the stacking order. */ windows = TkWmStackorderToplevel(winPtr->mainPtr->winPtr); if (windows == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "TkWmStackorderToplevel failed", -1)); Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "FAIL", NULL); return TCL_ERROR; } for (windowPtr = windows; *windowPtr ; windowPtr++) { if (*windowPtr == winPtr) { index1 = windowPtr - windows; } if (*windowPtr == winPtr2) { index2 = windowPtr - windows; } } if (index1 == -1) { Tcl_Panic("winPtr window not found"); } if (index2 == -1) { Tcl_Panic("winPtr2 window not found"); |
︙ | ︙ | |||
2765 2766 2767 2768 2769 2770 2771 | result = index1 < index2; } Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result)); return TCL_OK; } return TCL_OK; } | | | 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 | result = index1 < index2; } Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result)); return TCL_OK; } return TCL_OK; } /* *---------------------------------------------------------------------- * * WmStateCmd -- * * This procedure is invoked to process the "wm state" Tcl command. See * the user documentation for details on what it does. |
︙ | ︙ | |||
2804 2805 2806 2807 2808 2809 2810 | if ((objc < 3) || (objc > 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?state?"); return TCL_ERROR; } if (objc == 4) { if (wmPtr->iconFor != NULL) { | | | | > > | | > | | | > > > | | > > > | | | | | | | 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 | if ((objc < 3) || (objc > 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?state?"); return TCL_ERROR; } if (objc == 4) { if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't change state of %s: it is an icon for %s", Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "ICON", NULL); return TCL_ERROR; } if (winPtr->flags & TK_EMBEDDED) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't change state of %s: it is an embedded window", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "EMBEDDED", NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } if (index == OPT_NORMAL) { TkpWmSetState(winPtr, NormalState); /* * This varies from 'wm deiconify' because it does not force the * window to be raised and receive focus */ } else if (index == OPT_ICONIC) { 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", "STATE", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } if (wmPtr->master != None) { 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; } TkpWmSetState(winPtr, IconicState); } else if (index == OPT_WITHDRAWN) { TkpWmSetState(winPtr, WithdrawnState); } else { /* OPT_ZOOMED */ TkpWmSetState(winPtr, ZoomState); } } else if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj("icon", -1)); } else { if (wmPtr->hints.initial_state == NormalState || wmPtr->hints.initial_state == ZoomState) { wmPtr->hints.initial_state = (TkMacOSXIsWindowZoomed(winPtr) ? ZoomState : NormalState); } switch (wmPtr->hints.initial_state) { case NormalState: Tcl_SetObjResult(interp, Tcl_NewStringObj("normal", -1)); break; case IconicState: Tcl_SetObjResult(interp, Tcl_NewStringObj("iconic", -1)); break; case WithdrawnState: Tcl_SetObjResult(interp, Tcl_NewStringObj("withdrawn", -1)); break; case ZoomState: Tcl_SetObjResult(interp, Tcl_NewStringObj("zoomed", -1)); break; } } return TCL_OK; } /* *---------------------------------------------------------------------- * * WmTitleCmd -- * * This procedure is invoked to process the "wm title" Tcl command. See * the user documentation for details on what it does. |
︙ | ︙ | |||
2904 2905 2906 2907 2908 2909 2910 | int length; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?"); return TCL_ERROR; } if (objc == 3) { | | | | | 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 | int length; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?"); return TCL_ERROR; } if (objc == 3) { Tcl_SetObjResult(interp, Tcl_NewStringObj( wmPtr->titleUid ? wmPtr->titleUid : winPtr->nameUid, -1)); return TCL_OK; } argv3 = Tcl_GetStringFromObj(objv[3], &length); wmPtr->titleUid = Tk_GetUid(argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED) && !Tk_IsEmbedded(winPtr)) { TkSetWMName(winPtr, wmPtr->titleUid); } return TCL_OK; } /* *---------------------------------------------------------------------- * * WmTransientCmd -- * * This procedure is invoked to process the "wm transient" Tcl command. * See the user documentation for details on what it does. |
︙ | ︙ | |||
2953 2954 2955 2956 2957 2958 2959 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?master?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->master != None) { | > | | | | > | | | > | | > | | 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?master?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->master != None) { Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->masterWindowName, -1)); } return TCL_OK; } if (Tcl_GetString(objv[3])[0] == '\0') { wmPtr->master = None; if (wmPtr->masterWindowName != NULL) { ckfree(wmPtr->masterWindowName); } wmPtr->masterWindowName = NULL; } else { if (TkGetWindowFromObj(interp, tkwin, objv[3], &master) != TCL_OK) { return TCL_ERROR; } Tk_MakeWindowExist(master); 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 = ((TkWindow *) master)->wmInfoPtr; /* Under some circumstances, wmPtr2 is NULL here */ if (wmPtr2 != NULL && 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; } if ((TkWindow *) master == winPtr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't make \"%s\" its own master", Tk_PathName(winPtr))); Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL); return TCL_ERROR; } argv3 = Tcl_GetStringFromObj(objv[3], &length); wmPtr->master = Tk_WindowId(master); if (wmPtr->masterWindowName != NULL) { ckfree(wmPtr->masterWindowName); } wmPtr->masterWindowName = ckalloc(length+1); strcpy(wmPtr->masterWindowName, argv3); } ApplyMasterOverrideChanges(winPtr, NULL); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmWithdrawCmd -- * * This procedure is invoked to process the "wm withdraw" Tcl command. * See the user documentation for details on what it does. |
︙ | ︙ | |||
3036 3037 3038 3039 3040 3041 3042 | register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { | > | | > | | | 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 | register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't withdraw %s: it is an icon for %s", Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "WITHDRAW", "ICON", NULL); return TCL_ERROR; } TkpWmSetState(winPtr, WithdrawnState); return TCL_OK; } /* * Invoked by those wm subcommands that affect geometry. * Schedules a geometry update. */ static void WmUpdateGeom( WmInfo *wmPtr, TkWindow *winPtr) { if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } } /* *---------------------------------------------------------------------- * * Tk_SetGrid -- * * This procedure is invoked by a widget when it wishes to set a grid * coordinate system that controls the size of a top-level window. It |
︙ | ︙ | |||
3165 3166 3167 3168 3169 3170 3171 | wmPtr->sizeHintsFlags |= PBaseSize|PResizeInc; wmPtr->flags |= WM_UPDATE_SIZE_HINTS; if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } } | | | 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 | wmPtr->sizeHintsFlags |= PBaseSize|PResizeInc; wmPtr->flags |= WM_UPDATE_SIZE_HINTS; if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } } /* *---------------------------------------------------------------------- * * Tk_UnsetGrid -- * * This procedure cancels the effect of a previous call to Tk_SetGrid. * |
︙ | ︙ | |||
3222 3223 3224 3225 3226 3227 3228 | wmPtr->flags |= WM_UPDATE_SIZE_HINTS; if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } } | | | 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 | wmPtr->flags |= WM_UPDATE_SIZE_HINTS; if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } } /* *---------------------------------------------------------------------- * * TopLevelEventProc -- * * This procedure is invoked when a top-level (or other externally- * managed window) is restructured in any way. |
︙ | ︙ | |||
3272 3273 3274 3275 3276 3277 3278 | if (wmTracing) { TkMacOSXDbgMsg("TopLevelEventProc: %s deleted", winPtr->pathName); } } else if (eventPtr->type == ReparentNotify) { Tcl_Panic("recieved unwanted reparent event"); } } | | | 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 | if (wmTracing) { TkMacOSXDbgMsg("TopLevelEventProc: %s deleted", winPtr->pathName); } } else if (eventPtr->type == ReparentNotify) { Tcl_Panic("recieved unwanted reparent event"); } } /* *---------------------------------------------------------------------- * * TopLevelReqProc -- * * This procedure is invoked by the geometry manager whenever the * requested size for a top-level window is changed. |
︙ | ︙ | |||
3307 3308 3309 3310 3311 3312 3313 | wmPtr = winPtr->wmInfoPtr; wmPtr->flags |= WM_UPDATE_SIZE_HINTS; if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } } | | | 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 | wmPtr = winPtr->wmInfoPtr; wmPtr->flags |= WM_UPDATE_SIZE_HINTS; if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } } /* *---------------------------------------------------------------------- * * UpdateGeometryInfo -- * * This procedure is invoked when a top-level window is first mapped, and * also as a when-idle procedure, to bring the geometry and/or position |
︙ | ︙ | |||
3434 3435 3436 3437 3438 3439 3440 | * of this code. */ if (wmPtr->flags & WM_NEGATIVE_X) { x = wmPtr->vRootWidth - wmPtr->x - (width + (wmPtr->parentWidth - winPtr->changes.width)); } else { | | | | | 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 | * of this code. */ if (wmPtr->flags & WM_NEGATIVE_X) { x = wmPtr->vRootWidth - wmPtr->x - (width + (wmPtr->parentWidth - winPtr->changes.width)); } else { x = wmPtr->x; } if (wmPtr->flags & WM_NEGATIVE_Y) { y = wmPtr->vRootHeight - wmPtr->y - (height + (wmPtr->parentHeight - winPtr->changes.height)); } else { y = wmPtr->y; } /* * If the window's size is going to change and the window is supposed to * not be resizable by the user, then we have to update the size hints. * There may also be a size-hint-update request pending from somewhere * else, too. */ if (((width != winPtr->changes.width) || (height != winPtr->changes.height)) && (wmPtr->gridWin == NULL) && !(wmPtr->sizeHintsFlags & (PMinSize|PMaxSize))) { wmPtr->flags |= WM_UPDATE_SIZE_HINTS; } if (wmPtr->flags & WM_UPDATE_SIZE_HINTS) { UpdateSizeHints(winPtr); } /* |
︙ | ︙ | |||
3524 3525 3526 3527 3528 3529 3530 | } wmPtr->flags |= WM_SYNC_PENDING; XResizeWindow(winPtr->display, winPtr->window, (unsigned) width, (unsigned) height); wmPtr->flags &= ~WM_SYNC_PENDING; } } | | | 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 | } wmPtr->flags |= WM_SYNC_PENDING; XResizeWindow(winPtr->display, winPtr->window, (unsigned) width, (unsigned) height); wmPtr->flags &= ~WM_SYNC_PENDING; } } /* *---------------------------------------------------------------------- * * UpdateSizeHints -- * * This procedure is called to update the window manager's size hints * information from the information in a WmInfo structure. |
︙ | ︙ | |||
3550 3551 3552 3553 3554 3555 3556 | UpdateSizeHints( TkWindow *winPtr) { WmInfo *wmPtr = winPtr->wmInfoPtr; wmPtr->flags &= ~WM_UPDATE_SIZE_HINTS; } | | | 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 | UpdateSizeHints( TkWindow *winPtr) { WmInfo *wmPtr = winPtr->wmInfoPtr; wmPtr->flags &= ~WM_UPDATE_SIZE_HINTS; } /* *---------------------------------------------------------------------- * * ParseGeometry -- * * This procedure parses a geometry string and updates information used * to control the geometry of a top-level window. |
︙ | ︙ | |||
3653 3654 3655 3656 3657 3658 3659 | /* * Assume that the geometry information came from the user, unless an * explicit source has been specified. Otherwise most window managers * assume that the size hints were program-specified and they ignore * them. */ | | | 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 | /* * Assume that the geometry information came from the user, unless an * explicit source has been specified. Otherwise most window managers * assume that the size hints were program-specified and they ignore * them. */ if (!(wmPtr->sizeHintsFlags & (USPosition|PPosition))) { wmPtr->sizeHintsFlags |= USPosition; flags |= WM_UPDATE_SIZE_HINTS; } } /* * Everything was parsed OK. Update the fields of *wmPtr and arrange for |
︙ | ︙ | |||
3688 3689 3690 3691 3692 3693 3694 | if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } return TCL_OK; error: | > | > | | 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 | if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } return TCL_OK; error: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad geometry specifier \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "GEOMETRY", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * Tk_GetRootCoords -- * * Given a token for a window, this procedure traces through the window's * lineage to find the (virtual) root-window coordinates corresponding to |
︙ | ︙ | |||
3787 3788 3789 3790 3791 3792 3793 | y += winPtr->changes.y + winPtr->changes.border_width; } winPtr = winPtr->parentPtr; } *xPtr = x; *yPtr = y; } | | | 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 | y += winPtr->changes.y + winPtr->changes.border_width; } winPtr = winPtr->parentPtr; } *xPtr = x; *yPtr = y; } /* *---------------------------------------------------------------------- * * Tk_CoordsToWindow -- * * This is a Macintosh specific implementation of this function. Given * the root coordinates of a point, this procedure returns the token for |
︙ | ︙ | |||
3907 3908 3909 3910 3911 3912 3913 | if (nextPtr == NULL) { break; } winPtr = nextPtr; } return (Tk_Window) winPtr; } | | | 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 | if (nextPtr == NULL) { break; } winPtr = nextPtr; } return (Tk_Window) winPtr; } /* *---------------------------------------------------------------------- * * Tk_TopCoordsToWindow -- * * Given a Tk Window, and coordinates of a point relative to that window * this procedure returns the top-most child of the window (excluding |
︙ | ︙ | |||
4000 4001 4002 4003 4004 4005 4006 | x -= winPtr->changes.x; y -= winPtr->changes.y; } *newX = x; *newY = y; return (Tk_Window) winPtr; } | | | 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 | x -= winPtr->changes.x; y -= winPtr->changes.y; } *newX = x; *newY = y; return (Tk_Window) winPtr; } /* *---------------------------------------------------------------------- * * UpdateVRootGeometry -- * * This procedure is called to update all the virtual root geometry * information in wmPtr. |
︙ | ︙ | |||
4067 4068 4069 4070 4071 4072 4073 | * The virtual root is gone! Pretend that it never existed. */ wmPtr->vRoot = None; goto noVRoot; } } | | | 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 | * The virtual root is gone! Pretend that it never existed. */ wmPtr->vRoot = None; goto noVRoot; } } /* *---------------------------------------------------------------------- * * Tk_GetVRootGeometry -- * * This procedure returns information about the virtual root window * corresponding to a particular Tk window. |
︙ | ︙ | |||
4124 4125 4126 4127 4128 4129 4130 | UpdateVRootGeometry(wmPtr); } *xPtr = wmPtr->vRootX; *yPtr = wmPtr->vRootY; *widthPtr = wmPtr->vRootWidth; *heightPtr = wmPtr->vRootHeight; } | | | 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 | UpdateVRootGeometry(wmPtr); } *xPtr = wmPtr->vRootX; *yPtr = wmPtr->vRootY; *widthPtr = wmPtr->vRootWidth; *heightPtr = wmPtr->vRootHeight; } /* *---------------------------------------------------------------------- * * Tk_MoveToplevelWindow -- * * This procedure is called instead of Tk_MoveWindow to adjust the x-y * location of a top-level window. It delays the actual move to a later |
︙ | ︙ | |||
4160 4161 4162 4163 4164 4165 4166 | if (!(winPtr->flags & TK_TOP_LEVEL)) { Tcl_Panic("Tk_MoveToplevelWindow called with non-toplevel window"); } wmPtr->x = x; wmPtr->y = y; wmPtr->flags |= WM_MOVE_PENDING; wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y); | | | | 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 | if (!(winPtr->flags & TK_TOP_LEVEL)) { Tcl_Panic("Tk_MoveToplevelWindow called with non-toplevel window"); } wmPtr->x = x; wmPtr->y = y; wmPtr->flags |= WM_MOVE_PENDING; wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y); if (!(wmPtr->sizeHintsFlags & (USPosition|PPosition))) { wmPtr->sizeHintsFlags |= USPosition; wmPtr->flags |= WM_UPDATE_SIZE_HINTS; } /* * If the window has already been mapped, must bring its geometry * up-to-date immediately, otherwise an event might arrive from the server * that would overwrite wmPtr->x and wmPtr->y and lose the new position. */ if (!(wmPtr->flags & WM_NEVER_MAPPED)) { if (wmPtr->flags & WM_UPDATE_PENDING) { Tk_CancelIdleCall(UpdateGeometryInfo, winPtr); } UpdateGeometryInfo(winPtr); } } /* *---------------------------------------------------------------------- * * TkWmRestackToplevel -- * * This procedure restacks a top-level window. * |
︙ | ︙ | |||
4292 4293 4294 4295 4296 4297 4298 | if (tmpWindow != NULL) { SelectWindow(tmpWindow); } } SendBehind(macWindow, otherMacWindow); } } | | | 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 | if (tmpWindow != NULL) { SelectWindow(tmpWindow); } } SendBehind(macWindow, otherMacWindow); } } /* *---------------------------------------------------------------------- * * TkWmAddToColormapWindows -- * * This procedure is called to add a given window to the * WM_COLORMAP_WINDOWS property for its top-level, if it isn't already |
︙ | ︙ | |||
4383 4384 4385 4386 4387 4388 4389 | topPtr->wmInfoPtr->cmapCount = count+1; /* * On the Macintosh all of this is just an excercise in compatability as * we don't support colormaps. If we did they would be installed here. */ } | | | 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 | topPtr->wmInfoPtr->cmapCount = count+1; /* * On the Macintosh all of this is just an excercise in compatability as * we don't support colormaps. If we did they would be installed here. */ } /* *---------------------------------------------------------------------- * * TkWmRemoveFromColormapWindows -- * * This procedure is called to remove a given window from the * WM_COLORMAP_WINDOWS property for its top-level. It is invoked when |
︙ | ︙ | |||
4452 4453 4454 4455 4456 4457 4458 | oldPtr[j] = oldPtr[j+1]; } topPtr->wmInfoPtr->cmapCount = count - 1; break; } } } | | | 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 | oldPtr[j] = oldPtr[j+1]; } topPtr->wmInfoPtr->cmapCount = count - 1; break; } } } /* *---------------------------------------------------------------------- * * TkGetPointerCoords -- * * Fetch the position of the mouse pointer. * |
︙ | ︙ | |||
4480 4481 4482 4483 4484 4485 4486 | TkGetPointerCoords( Tk_Window tkwin, /* Toplevel window that identifies screen on * which lookup is to be done. */ int *xPtr, int *yPtr) /* Store pointer coordinates here. */ { XQueryPointer(NULL, None, NULL, NULL, xPtr, yPtr, NULL, NULL, NULL); } | | | 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 | TkGetPointerCoords( Tk_Window tkwin, /* Toplevel window that identifies screen on * which lookup is to be done. */ int *xPtr, int *yPtr) /* Store pointer coordinates here. */ { XQueryPointer(NULL, None, NULL, NULL, xPtr, yPtr, NULL, NULL, NULL); } /* *---------------------------------------------------------------------- * * InitialWindowBounds -- * * This function calculates the initial bounds for a new Mac toplevel * window. Unless the geometry is specified by the user this code will |
︙ | ︙ | |||
4539 4540 4541 4542 4543 4544 4545 | } geometry->left = wmPtr->x; geometry->top = wmPtr->y; geometry->right = wmPtr->x + winPtr->changes.width; geometry->bottom = wmPtr->y + winPtr->changes.height; } | | | 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 | } geometry->left = wmPtr->x; geometry->top = wmPtr->y; geometry->right = wmPtr->x + winPtr->changes.width; geometry->bottom = wmPtr->y + winPtr->changes.height; } /* *---------------------------------------------------------------------- * * TkMacOSXResizable -- * * This function determines if the passed in window is part of a toplevel * window that is resizable. If the window is resizable in the x, y or |
︙ | ︙ | |||
4579 4580 4581 4582 4583 4584 4585 | if ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) && (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE)) { return false; } else { return true; } } | | | 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 | if ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) && (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE)) { return false; } else { return true; } } /* *---------------------------------------------------------------------- * * TkMacOSXGrowToplevel -- * * The function is invoked when the user clicks in the grow region of a * Tk window. The function will handle the dragging procedure and not |
︙ | ︙ | |||
4647 4648 4649 4650 4651 4652 4653 | limits.left = base + (minWidth * wmPtr->widthInc); limits.right = base + (maxWidth * wmPtr->widthInc); base = winPtr->reqHeight - (wmPtr->reqGridHeight * wmPtr->heightInc); if (base < 0) { base = 0; } | | | 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 | limits.left = base + (minWidth * wmPtr->widthInc); limits.right = base + (maxWidth * wmPtr->widthInc); base = winPtr->reqHeight - (wmPtr->reqGridHeight * wmPtr->heightInc); if (base < 0) { base = 0; } limits.top = base + (minHeight * wmPtr->heightInc); limits.bottom = base + (maxHeight * wmPtr->heightInc); } else { limits.left = minWidth; limits.right = maxWidth; limits.top = minHeight; limits.bottom = maxHeight; } |
︙ | ︙ | |||
4702 4703 4704 4705 4706 4707 4708 | TkMacOSXTrackingLoop(0); if (resizeResult) { return true; } } return false; } | | | 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 | TkMacOSXTrackingLoop(0); if (resizeResult) { return true; } } return false; } /* *---------------------------------------------------------------------- * * TkSetWMName -- * * Set the title for a toplevel window. If the window is embedded, do not * change the window title. |
︙ | ︙ | |||
4740 4741 4742 4743 4744 4745 4746 | if (title) { WindowRef macWin = TkMacOSXDrawableWindow(winPtr->window); SetWindowTitleWithCFString(macWin, title); CFRelease(title); } } | | | 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 | if (title) { WindowRef macWin = TkMacOSXDrawableWindow(winPtr->window); SetWindowTitleWithCFString(macWin, title); CFRelease(title); } } /* *---------------------------------------------------------------------- * * TkGetTransientMaster -- * * If the passed window has the TRANSIENT_FOR property set this will * return the master window. Otherwise it will return None. |
︙ | ︙ | |||
4767 4768 4769 4770 4771 4772 4773 | TkWindow *winPtr) { if (winPtr->wmInfoPtr != NULL) { return winPtr->wmInfoPtr->master; } return None; } | | | 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 | TkWindow *winPtr) { if (winPtr->wmInfoPtr != NULL) { return winPtr->wmInfoPtr->master; } return None; } /* *---------------------------------------------------------------------- * * TkMacOSXGetXWindow -- * * Returns the X window Id associated with the given WindowRef. * |
︙ | ︙ | |||
4799 4800 4801 4802 4803 4804 4805 | } hPtr = Tcl_FindHashEntry(&windowTable, (char *) macWinPtr); if (hPtr == NULL) { return None; } return (Window) Tcl_GetHashValue(hPtr); } | | | 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 | } hPtr = Tcl_FindHashEntry(&windowTable, (char *) macWinPtr); if (hPtr == NULL) { return None; } return (Window) Tcl_GetHashValue(hPtr); } /* *---------------------------------------------------------------------- * * TkMacOSXIsWindowZoomed -- * * Ask Carbon if the given window is in the zoomed out state. Because * dragging & growing a window can change the Carbon zoom state, we |
︙ | ︙ | |||
4858 4859 4860 4861 4862 4863 4864 | } else { idealSize.v = maxHeight; } return IsWindowInStandardState(TkMacOSXDrawableWindow(winPtr->window), &idealSize, NULL); } | | | 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 | } else { idealSize.v = maxHeight; } return IsWindowInStandardState(TkMacOSXDrawableWindow(winPtr->window), &idealSize, NULL); } /* *---------------------------------------------------------------------- * * TkMacOSXZoomToplevel -- * * The function is invoked when the user clicks in the zoom region of a * Tk window or when the window state is set/unset to "zoomed" manually. |
︙ | ︙ | |||
4880 4881 4882 4883 4884 4885 4886 | * The window may be resized & events placed on Tk's queue. * *---------------------------------------------------------------------- */ int TkMacOSXZoomToplevel( | | | 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 | * The window may be resized & events placed on Tk's queue. * *---------------------------------------------------------------------- */ int TkMacOSXZoomToplevel( void *whichWindow, /* The Macintosh window to zoom. */ short zoomPart) /* Either inZoomIn or inZoomOut */ { Window window; TkDisplay *dispPtr; TkWindow *winPtr; WmInfo *wmPtr; Point idealSize; |
︙ | ︙ | |||
4942 4943 4944 4945 4946 4947 4948 | if (err != noErr) { return false; } wmPtr->hints.initial_state = (zoomPart == inZoomIn ? NormalState : ZoomState); return true; } | | | 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 | if (err != noErr) { return false; } wmPtr->hints.initial_state = (zoomPart == inZoomIn ? NormalState : ZoomState); return true; } /* *---------------------------------------------------------------------- * * TkUnsupported1Cmd -- * * This procedure is invoked to process the * "::tk::unsupported::MacWindowStyle" Tcl command. This command allows |
︙ | ︙ | |||
4990 4991 4992 4993 4994 4995 4996 | winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin); if (winPtr == NULL) { return TCL_ERROR; } if (!(winPtr->flags & TK_TOP_LEVEL)) { | | < | > | | 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 | winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin); if (winPtr == NULL) { return TCL_ERROR; } if (!(winPtr->flags & TK_TOP_LEVEL)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't a top-level window", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WINDOWSTYLE", "TOPLEVEL", NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[1], subcmds, "option", 0, &index) != TCL_OK) { return TCL_ERROR; } if (((enum SubCmds) index) == TKMWS_STYLE) { if ((objc < 3) || (objc > 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?class attributes?"); return TCL_ERROR; } return WmWinStyle(interp, winPtr, objc, objv); } /* won't be reached */ return TCL_ERROR; } /* *---------------------------------------------------------------------- * * WmWinStyle -- * * This procedure is invoked to process the * "::tk::unsupported::MacWindowStyle style" subcommand. This command |
︙ | ︙ | |||
5138 5139 5140 5141 5142 5143 5144 | break; } } if (newResult == NULL) { Tcl_Panic("invalid class"); } | | | | | | 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 | break; } } if (newResult == NULL) { Tcl_Panic("invalid class"); } attributeList = Tcl_NewObj(); attributes = wmPtr->attributes; for (i = 0; compositeAttrMap[i].strValue != NULL; i++) { UInt32 intValue = compositeAttrMap[i].intValue; if (intValue && (attributes & intValue) == intValue) { Tcl_ListObjAppendElement(NULL, attributeList, Tcl_NewStringObj(compositeAttrMap[i].strValue, -1)); attributes &= ~intValue; break; } } for (i = 0; attrMap[i].strValue != NULL; i++) { if (attributes & attrMap[i].intValue) { Tcl_ListObjAppendElement(NULL, attributeList, Tcl_NewStringObj(attrMap[i].strValue, -1)); } } Tcl_ListObjAppendElement(NULL, newResult, attributeList); Tcl_SetObjResult(interp, newResult); } } else if (objc == 4) { if (Tcl_GetIndexFromObjStruct(interp, objv[3], styleMap, sizeof(struct StrIntMap), "style", 0, &index) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
5212 5213 5214 5215 5216 5217 5218 | badClassAttrs: wmPtr->macClass = oldClass; wmPtr->attributes = oldAttributes; return TCL_ERROR; } return TCL_OK; } | | | 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 | badClassAttrs: wmPtr->macClass = oldClass; wmPtr->attributes = oldAttributes; return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- * * TkpMakeMenuWindow -- * * Configure the window to be either a undecorated pull-down (or pop-up) * menu, or as a toplevel floating menu (palette). |
︙ | ︙ | |||
5250 5251 5252 5253 5254 5255 5256 | } else { winPtr->wmInfoPtr->macClass = kFloatingWindowClass; winPtr->wmInfoPtr->attributes = kWindowStandardFloatingAttributes; winPtr->wmInfoPtr->flags |= WM_WIDTH_NOT_RESIZABLE; winPtr->wmInfoPtr->flags |= WM_HEIGHT_NOT_RESIZABLE; } } | | | 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 | } else { winPtr->wmInfoPtr->macClass = kFloatingWindowClass; winPtr->wmInfoPtr->attributes = kWindowStandardFloatingAttributes; winPtr->wmInfoPtr->flags |= WM_WIDTH_NOT_RESIZABLE; winPtr->wmInfoPtr->flags |= WM_HEIGHT_NOT_RESIZABLE; } } /* *---------------------------------------------------------------------- * * TkMacOSXMakeRealWindowExist -- * * This function finally creates the real Macintosh window that the Mac * actually understands. |
︙ | ︙ | |||
5355 5356 5357 5358 5359 5360 5361 | wmPtr->xInParent = strWidths.left; wmPtr->yInParent = strWidths.top; structureW = strWidths.left + strWidths.right; structureH = strWidths.top + strWidths.bottom; wmPtr->parentWidth = winPtr->changes.width + structureW; wmPtr->parentHeight = winPtr->changes.height + structureH; InitialWindowBounds(winPtr, newWindow, &geometry); | | | 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 | wmPtr->xInParent = strWidths.left; wmPtr->yInParent = strWidths.top; structureW = strWidths.left + strWidths.right; structureH = strWidths.top + strWidths.bottom; wmPtr->parentWidth = winPtr->changes.width + structureW; wmPtr->parentHeight = winPtr->changes.height + structureH; InitialWindowBounds(winPtr, newWindow, &geometry); geometry.right += structureW; geometry.bottom += structureH; ChkErr(SetWindowBounds, newWindow, kWindowStructureRgn, &geometry); TkMacOSXInstallWindowCarbonEventHandler(NULL, newWindow); if (ChkErr(CreateRootControl, newWindow, &rootControl) != noErr ) { Tcl_Panic("couldn't create root control for new Mac window"); } |
︙ | ︙ | |||
5401 5402 5403 5404 5405 5406 5407 | #ifdef TK_MAC_DEBUG_WINDOWS TkMacOSXInitNamedDebugSymbol(HIToolbox, void, DebugPrintWindow, WindowRef); if (DebugPrintWindow) { DebugPrintWindow(newWindow); } #endif /* TK_MAC_DEBUG_WINDOWS */ } | | | 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 | #ifdef TK_MAC_DEBUG_WINDOWS TkMacOSXInitNamedDebugSymbol(HIToolbox, void, DebugPrintWindow, WindowRef); if (DebugPrintWindow) { DebugPrintWindow(newWindow); } #endif /* TK_MAC_DEBUG_WINDOWS */ } /* *---------------------------------------------------------------------- * * TkMacOSXRegisterOffScreenWindow -- * * This function adds the passed in Off Screen Port to the hash table * that maps Mac windows to root X windows. |
︙ | ︙ | |||
5437 5438 5439 5440 5441 5442 5443 | } valueHashPtr = Tcl_CreateHashEntry(&windowTable, (char *) portPtr, &isNew); if (!isNew) { Tcl_Panic("Same macintosh window allocated twice!"); } Tcl_SetHashValue(valueHashPtr, window); } | | | 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 | } valueHashPtr = Tcl_CreateHashEntry(&windowTable, (char *) portPtr, &isNew); if (!isNew) { Tcl_Panic("Same macintosh window allocated twice!"); } Tcl_SetHashValue(valueHashPtr, window); } /* *---------------------------------------------------------------------- * * TkMacOSXUnregisterMacWindow -- * * Given a macintosh port window, this function removes the association * between this window and the root X window that Tk cares about. |
︙ | ︙ | |||
5471 5472 5473 5474 5475 5476 5477 | entryPtr = Tcl_FindHashEntry(&windowTable,(char *) macWinPtr); if (!entryPtr) { TkMacOSXDbgMsg("Failed to find window %08x", (int) macWinPtr); } else { Tcl_DeleteHashEntry(entryPtr); } } | | | 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 | entryPtr = Tcl_FindHashEntry(&windowTable,(char *) macWinPtr); if (!entryPtr) { TkMacOSXDbgMsg("Failed to find window %08x", (int) macWinPtr); } else { Tcl_DeleteHashEntry(entryPtr); } } /* *---------------------------------------------------------------------- * * TkMacOSXSetScrollbarGrow -- * * Sets a flag for a toplevel window indicating that the passed Tk * scrollbar window will display the grow region for the toplevel window. |
︙ | ︙ | |||
5503 5504 5505 5506 5507 5508 5509 | winPtr->privatePtr->toplevel->winPtr->wmInfoPtr->scrollWinPtr = winPtr; } else if (winPtr->privatePtr->toplevel->winPtr->wmInfoPtr->scrollWinPtr == winPtr) { winPtr->privatePtr->toplevel->flags &= ~TK_SCROLLBAR_GROW; winPtr->privatePtr->toplevel->winPtr->wmInfoPtr->scrollWinPtr = NULL; } } | | | 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 | winPtr->privatePtr->toplevel->winPtr->wmInfoPtr->scrollWinPtr = winPtr; } else if (winPtr->privatePtr->toplevel->winPtr->wmInfoPtr->scrollWinPtr == winPtr) { winPtr->privatePtr->toplevel->flags &= ~TK_SCROLLBAR_GROW; winPtr->privatePtr->toplevel->winPtr->wmInfoPtr->scrollWinPtr = NULL; } } /* *---------------------------------------------------------------------- * * TkWmFocusToplevel -- * * This is a utility procedure invoked by focus-management code. It * exists because of the extra wrapper windows that exist under Unix; its |
︙ | ︙ | |||
5536 5537 5538 5539 5540 5541 5542 | * event. */ { if (!(winPtr->flags & TK_TOP_LEVEL)) { return NULL; } return winPtr; } | | | 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 | * event. */ { if (!(winPtr->flags & TK_TOP_LEVEL)) { return NULL; } return winPtr; } /* *---------------------------------------------------------------------- * * TkpGetWrapperWindow -- * * This is a utility procedure invoked by focus-management code. It maps * to the wrapper for a top-level, which is just the same as the |
︙ | ︙ | |||
5566 5567 5568 5569 5570 5571 5572 | * event. */ { if (!(winPtr->flags & TK_TOP_LEVEL)) { return NULL; } return winPtr; } | | | 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 | * event. */ { if (!(winPtr->flags & TK_TOP_LEVEL)) { return NULL; } return winPtr; } /* *---------------------------------------------------------------------- * * TkpWmSetState -- * * Sets the window manager state for the wrapper window of a given * toplevel window. |
︙ | ︙ | |||
5626 5627 5628 5629 5630 5631 5632 | Tk_MapWindow((Tk_Window) winPtr); if (IsWindowCollapsable(macWin) && IsWindowCollapsed(macWin)) { CollapseWindow(macWin, false); } TkMacOSXZoomToplevel(macWin, inZoomOut); } } | | | 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 | Tk_MapWindow((Tk_Window) winPtr); if (IsWindowCollapsable(macWin) && IsWindowCollapsed(macWin)) { CollapseWindow(macWin, false); } TkMacOSXZoomToplevel(macWin, inZoomOut); } } /* *---------------------------------------------------------------------- * * TkpIsWindowFloating -- * * Returns 1 if a window is floating, 0 otherwise. * |
︙ | ︙ | |||
5656 5657 5658 5659 5660 5661 5662 | if (wRef == NULL) { return 0; } GetWindowClass(wRef, &class); return (class == kFloatingWindowClass); } | | | 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 | if (wRef == NULL) { return 0; } GetWindowClass(wRef, &class); return (class == kFloatingWindowClass); } /* *---------------------------------------------------------------------- * * TkMacOSXWindowClass -- * * Returns OS X window class of window * |
︙ | ︙ | |||
5679 5680 5681 5682 5683 5684 5685 | MODULE_SCOPE WindowClass TkMacOSXWindowClass( TkWindow *winPtr) { return winPtr->wmInfoPtr->macClass; } | | | 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 | MODULE_SCOPE WindowClass TkMacOSXWindowClass( TkWindow *winPtr) { return winPtr->wmInfoPtr->macClass; } /* *-------------------------------------------------------------- * * TkMacOSXWindowOffset -- * * Determines the x and y offset from the orgin of the toplevel window * dressing (the structure region, i.e. title bar) and the orgin of the |
︙ | ︙ | |||
5714 5715 5716 5717 5718 5719 5720 | window = TkMacOSXGetXWindow(wRef); dispPtr = TkGetDisplayList(); winPtr = (TkWindow *) Tk_IdToWindow(dispPtr->display, window); *xOffset = winPtr->wmInfoPtr->xInParent; *yOffset = winPtr->wmInfoPtr->yInParent; } | | | 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 | window = TkMacOSXGetXWindow(wRef); dispPtr = TkGetDisplayList(); winPtr = (TkWindow *) Tk_IdToWindow(dispPtr->display, window); *xOffset = winPtr->wmInfoPtr->xInParent; *yOffset = winPtr->wmInfoPtr->yInParent; } /* *---------------------------------------------------------------------- * * TkpGetMS -- * * Return a relative time in milliseconds. It doesn't matter when the * epoch was. |
︙ | ︙ | |||
5740 5741 5742 5743 5744 5745 5746 | TkpGetMS(void) { Tcl_Time now; Tcl_GetTime(&now); return (long) now.sec * 1000 + now.usec / 1000; } | | | 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 | TkpGetMS(void) { Tcl_Time now; Tcl_GetTime(&now); return (long) now.sec * 1000 + now.usec / 1000; } /* *---------------------------------------------------------------------- * * XSetInputFocus -- * * Change the focus window for the application. * |
︙ | ︙ | |||
5768 5769 5770 5771 5772 5773 5774 | int revert_to, Time time) { /* * Don't need to do a thing. Tk manages the focus for us. */ } | | | 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 | int revert_to, Time time) { /* * Don't need to do a thing. Tk manages the focus for us. */ } /* *---------------------------------------------------------------------- * * TkpChangeFocus -- * * This procedure is a stub on the Mac because we always own the focus if * we are a front most application. |
︙ | ︙ | |||
5814 5815 5816 5817 5818 5819 5820 | * server request. This marks the position at which we changed the focus, * so we can distinguish FocusIn and FocusOut events on either side of the * mark. */ return NextRequest(winPtr->display); } | | | 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 | * server request. This marks the position at which we changed the focus, * so we can distinguish FocusIn and FocusOut events on either side of the * mark. */ return NextRequest(winPtr->display); } /* *---------------------------------------------------------------------- * * WmStackorderToplevelWrapperMap -- * * This procedure will create a table that maps the reparent wrapper X id * for a toplevel to the TkWindow structure that is wraps. Tk keeps track |
︙ | ︙ | |||
5861 5862 5863 5864 5865 5866 5867 | } for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { WmStackorderToplevelWrapperMap(childPtr, display, table); } } | | | 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 | } for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { WmStackorderToplevelWrapperMap(childPtr, display, table); } } /* *---------------------------------------------------------------------- * * TkWmStackorderToplevel -- * * This procedure returns the stack order of toplevel windows. * |
︙ | ︙ | |||
5884 5885 5886 5887 5888 5889 5890 | */ TkWindow ** TkWmStackorderToplevel( TkWindow *parentPtr) /* Parent toplevel window. */ { WindowRef frontWindow; | | | 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 | */ TkWindow ** TkWmStackorderToplevel( TkWindow *parentPtr) /* Parent toplevel window. */ { WindowRef frontWindow; TkWindow *childWinPtr, **windows, **windowPtr; Tcl_HashTable table; Tcl_HashEntry *hPtr; Tcl_HashSearch search; /* * Map mac windows to a TkWindow of the wrapped toplevel. */ |
︙ | ︙ | |||
5919 5920 5921 5922 5923 5924 5925 | } frontWindow = GetFrontWindowOfClass(kAllWindowClasses, false); if (frontWindow == NULL) { ckfree(windows); windows = NULL; } else { | | | | | | | 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 | } frontWindow = GetFrontWindowOfClass(kAllWindowClasses, false); if (frontWindow == NULL) { ckfree(windows); windows = NULL; } else { windowPtr = windows + table.numEntries; *windowPtr-- = NULL; while (frontWindow != NULL) { hPtr = Tcl_FindHashEntry(&table, (char *) frontWindow); if (hPtr != NULL) { childWinPtr = Tcl_GetHashValue(hPtr); *windowPtr-- = childWinPtr; } frontWindow = GetNextWindow(frontWindow); } if (windowPtr != windows-1) { Tcl_Panic("num matched toplevel windows does not equal num " "children"); } } done: Tcl_DeleteHashTable(&table); return windows; } /* *---------------------------------------------------------------------- * * ApplyWindowClassAttributeChanges -- * * This procedure applies carbon window class and attribute changes. * |
︙ | ︙ | |||
6030 6031 6032 6033 6034 6035 6036 | wmPtr->yInParent = strWidths.top; wmPtr->parentWidth = winPtr->changes.width + strWidths.left + strWidths.right; wmPtr->parentHeight = winPtr->changes.height + strWidths.top + strWidths.bottom; } } | | | 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 | wmPtr->yInParent = strWidths.top; wmPtr->parentWidth = winPtr->changes.width + strWidths.left + strWidths.right; wmPtr->parentHeight = winPtr->changes.height + strWidths.top + strWidths.bottom; } } /* *---------------------------------------------------------------------- * * ApplyMasterOverrideChanges -- * * This procedure applies changes to override_redirect or master. * |
︙ | ︙ | |||
6096 6097 6098 6099 6100 6101 6102 | } group = WmGetWindowGroup(winPtr); if (group && group != GetWindowGroup(macWindow)) { ChkErr(SetWindowGroup, macWindow, group); } } } | | | 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 | } group = WmGetWindowGroup(winPtr); if (group && group != GetWindowGroup(macWindow)) { ChkErr(SetWindowGroup, macWindow, group); } } } /* *---------------------------------------------------------------------- * * WmGetWindowGroup -- * * Gets the window group a toplevel should be placed in. * |
︙ | ︙ | |||
6150 6151 6152 6153 6154 6155 6156 | } } if (!group) { group = GetWindowGroupOfClass(wmPtr->macClass); } return group; } | | | 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 | } } if (!group) { group = GetWindowGroupOfClass(wmPtr->macClass); } return group; } /* *---------------------------------------------------------------------- * * TkMacOSXMakeFullscreen -- * * This procedure sets a fullscreen window to the size of the screen. * |
︙ | ︙ | |||
6178 6179 6180 6181 6182 6183 6184 | int fullscreen, Tcl_Interp *interp) { WmInfo *wmPtr = winPtr->wmInfoPtr; int result = TCL_OK, wasFullscreen = (wmPtr->flags & WM_FULLSCREEN); if (fullscreen) { | | | | | > | | 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 | int fullscreen, Tcl_Interp *interp) { WmInfo *wmPtr = winPtr->wmInfoPtr; int result = TCL_OK, wasFullscreen = (wmPtr->flags & WM_FULLSCREEN); if (fullscreen) { int screenWidth = WidthOfScreen(Tk_Screen(winPtr)); int screenHeight = HeightOfScreen(Tk_Screen(winPtr)); /* * Check max width and height if set by the user. */ if ((wmPtr->maxWidth > 0 && wmPtr->maxWidth < screenWidth) || (wmPtr->maxHeight > 0 && wmPtr->maxHeight < screenHeight)) { if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't set fullscreen attribute for \"%s\": max" " width/height is too small", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "FULLSCREEN", "CONSTRAINT_FAILURE", NULL); } result = TCL_ERROR; wmPtr->flags &= ~WM_FULLSCREEN; } else { Rect bounds, screenBounds = {0, 0, screenHeight, screenWidth}; ChkErr(GetWindowBounds, window, kWindowContentRgn, &bounds); |
︙ | ︙ | |||
6235 6236 6237 6238 6239 6240 6241 | wmPtr->flags |= WM_SYNC_PENDING; ChkErr(SetWindowBounds, window, kWindowStructureRgn, &bounds); wmPtr->flags &= ~WM_SYNC_PENDING; } TkMacOSXEnterExitFullscreen(winPtr, IsWindowActive(window)); return result; } | | | 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 | wmPtr->flags |= WM_SYNC_PENDING; ChkErr(SetWindowBounds, window, kWindowStructureRgn, &bounds); wmPtr->flags &= ~WM_SYNC_PENDING; } TkMacOSXEnterExitFullscreen(winPtr, IsWindowActive(window)); return result; } /* *---------------------------------------------------------------------- * * TkMacOSXEnterExitFullscreen -- * * This procedure enters or exits fullscreen mode if required. * |
︙ | ︙ | |||
6283 6284 6285 6286 6287 6288 6289 | } } else { if (mode != kUIModeNormal) { ChkErr(SetSystemUIMode, kUIModeNormal, 0); } } } | | | 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 | } } else { if (mode != kUIModeNormal) { ChkErr(SetSystemUIMode, kUIModeNormal, 0); } } } /* *---------------------------------------------------------------------- * * GetMinSize -- * * This function computes the current minWidth and minHeight values for a * window, taking into account the possibility that they may be |
︙ | ︙ | |||
6380 6381 6382 6383 6384 6385 6386 | } if (minHeight < wmPtr->minHeight) { minHeight = wmPtr->minHeight; } *minWidthPtr = minWidth; *minHeightPtr = minHeight; } | | | 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 | } if (minHeight < wmPtr->minHeight) { minHeight = wmPtr->minHeight; } *minWidthPtr = minWidth; *minHeightPtr = minHeight; } /* *---------------------------------------------------------------------- * * GetMaxSize -- * * This function computes the current maxWidth and maxHeight values for a * window, taking into account the possibility that they may be |
︙ | ︙ | |||
6436 6437 6438 6439 6440 6441 6442 | if (wmPtr->gridWin != NULL) { maxHeight = wmPtr->reqGridHeight + (maxHeight - winPtr->reqHeight)/wmPtr->heightInc; } *maxHeightPtr = maxHeight; } } | | | 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 | if (wmPtr->gridWin != NULL) { maxHeight = wmPtr->reqGridHeight + (maxHeight - winPtr->reqHeight)/wmPtr->heightInc; } *maxHeightPtr = maxHeight; } } /* *---------------------------------------------------------------------- * * RemapWindows * * Adjust parent/child relation ships of the given window hierarchy. * |
︙ | ︙ | |||
6482 6483 6484 6485 6486 6487 6488 | /* Repeat for all the children */ for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { RemapWindows(childPtr, (MacDrawable *) winPtr->window); } } | | | 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 | /* Repeat for all the children */ for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { RemapWindows(childPtr, (MacDrawable *) winPtr->window); } } /* * Local Variables: * fill-column: 78 * c-basic-offset: 4 * End: */ |
Changes to generic/tk3d.c.
︙ | ︙ | |||
669 670 671 672 673 674 675 | } else if ((c == 'r') && (strncmp(name, "ridge", length) == 0)) { *reliefPtr = TK_RELIEF_RIDGE; } else if ((c == 's') && (strncmp(name, "solid", length) == 0)) { *reliefPtr = TK_RELIEF_SOLID; } else if ((c == 's') && (strncmp(name, "sunken", length) == 0)) { *reliefPtr = TK_RELIEF_SUNKEN; } else { | < | | | | | 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 | } else if ((c == 'r') && (strncmp(name, "ridge", length) == 0)) { *reliefPtr = TK_RELIEF_RIDGE; } else if ((c == 's') && (strncmp(name, "solid", length) == 0)) { *reliefPtr = TK_RELIEF_SOLID; } else if ((c == 's') && (strncmp(name, "sunken", length) == 0)) { *reliefPtr = TK_RELIEF_SUNKEN; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad relief \"%.50s\": must be %s", name, "flat, groove, raised, ridge, solid, or sunken")); Tcl_SetErrorCode(interp, "TK", "VALUE", "RELIEF", NULL); return TCL_ERROR; } return TCL_OK; } /* *-------------------------------------------------------------- |
︙ | ︙ |
Changes to generic/tkArgv.c.
︙ | ︙ | |||
66 67 68 69 70 71 72 | const Tk_ArgvInfo *argTable, /* Array of option descriptions */ int flags) /* Or'ed combination of various flag bits, * such as TK_ARGV_NO_DEFAULTS. */ { register const Tk_ArgvInfo *infoPtr; /* Pointer to the current entry in the table * of argument descriptions. */ | | > | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | const Tk_ArgvInfo *argTable, /* Array of option descriptions */ int flags) /* Or'ed combination of various flag bits, * such as TK_ARGV_NO_DEFAULTS. */ { register const Tk_ArgvInfo *infoPtr; /* Pointer to the current entry in the table * of argument descriptions. */ const Tk_ArgvInfo *matchPtr;/* Descriptor that matches current argument. */ const char *curArg; /* Current argument */ register char c; /* Second character of current arg (used for * quick check for matching; use 2nd char. * because first char. will almost always be * '-'). */ int srcIndex; /* Location from which to read next argument * from argv. */ int dstIndex; /* Index into argv to which next unused * argument should be copied (never greater * than srcIndex). */ int argc; /* # arguments in argv still to process. */ size_t length; /* Number of characters in current argument. */ char *endPtr; /* Used for identifying junk in arguments. */ int i; if (flags & TK_ARGV_DONT_SKIP_FIRST_ARG) { srcIndex = dstIndex = 0; argc = *argcPtr; } else { srcIndex = dstIndex = 1; |
︙ | ︙ | |||
135 136 137 138 139 140 141 | matchPtr = infoPtr; goto gotMatch; } if (flags & TK_ARGV_NO_ABBREV) { continue; } if (matchPtr != NULL) { | > | > | > | > | < < | | | | > | | | | | | < | | < < | | | | | | > | | | | < | 136 137 138 139 140 141 142 143 144 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 188 189 190 191 192 193 194 195 196 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 222 223 224 225 226 227 228 229 230 231 232 233 234 | matchPtr = infoPtr; goto gotMatch; } if (flags & TK_ARGV_NO_ABBREV) { continue; } if (matchPtr != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "ambiguous option \"%s\"", curArg)); Tcl_SetErrorCode(interp, "TK", "ARG", "AMBIGUOUS", curArg, NULL); return TCL_ERROR; } matchPtr = infoPtr; } } if (matchPtr == NULL) { /* * Unrecognized argument. Just copy it down, unless the caller * prefers an error to be registered. */ if (flags & TK_ARGV_NO_LEFTOVERS) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unrecognized argument \"%s\"", curArg)); Tcl_SetErrorCode(interp, "TK", "ARG", "UNRECOGNIZED", curArg, NULL); return TCL_ERROR; } argv[dstIndex] = curArg; dstIndex++; continue; } /* * Take the appropriate action based on the option type */ gotMatch: infoPtr = matchPtr; switch (infoPtr->type) { case TK_ARGV_CONSTANT: *((int *) infoPtr->dst) = PTR2INT(infoPtr->src); break; case TK_ARGV_INT: if (argc == 0) { goto missingArg; } *((int *) infoPtr->dst) = strtol(argv[srcIndex], &endPtr, 0); if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "expected %s argument for \"%s\" but got \"%s\"", "integer", infoPtr->key, argv[srcIndex])); Tcl_SetErrorCode(interp, "TK", "ARG", "INTEGER", curArg,NULL); return TCL_ERROR; } srcIndex++; argc--; break; case TK_ARGV_STRING: if (argc == 0) { goto missingArg; } *((const char **) infoPtr->dst) = argv[srcIndex]; srcIndex++; argc--; break; case TK_ARGV_UID: if (argc == 0) { goto missingArg; } *((Tk_Uid *) infoPtr->dst) = Tk_GetUid(argv[srcIndex]); srcIndex++; argc--; break; case TK_ARGV_REST: *((int *) infoPtr->dst) = dstIndex; goto argsDone; case TK_ARGV_FLOAT: if (argc == 0) { goto missingArg; } *((double *) infoPtr->dst) = strtod(argv[srcIndex], &endPtr); if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "expected %s argument for \"%s\" but got \"%s\"", "floating-point", infoPtr->key, argv[srcIndex])); Tcl_SetErrorCode(interp, "TK", "ARG", "FLOAT", curArg, NULL); return TCL_ERROR; } srcIndex++; argc--; break; case TK_ARGV_FUNC: { typedef int (ArgvFunc)(char *, const char *, const char *); ArgvFunc *handlerProc = (ArgvFunc *) infoPtr->src; if (handlerProc(infoPtr->dst, infoPtr->key, argv[srcIndex])) { srcIndex++; |
︙ | ︙ | |||
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | if (argc < 0) { return TCL_ERROR; } break; } case TK_ARGV_HELP: PrintUsage(interp, argTable, flags); return TCL_ERROR; case TK_ARGV_CONST_OPTION: Tk_AddOption(tkwin, infoPtr->dst, infoPtr->src, TK_INTERACTIVE_PRIO); break; case TK_ARGV_OPTION_VALUE: if (argc < 1) { goto missingArg; } Tk_AddOption(tkwin, infoPtr->dst, argv[srcIndex], TK_INTERACTIVE_PRIO); srcIndex++; argc--; break; case TK_ARGV_OPTION_NAME_VALUE: if (argc < 2) { | > | | > > > | < | | | < | | > | 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | if (argc < 0) { return TCL_ERROR; } break; } case TK_ARGV_HELP: PrintUsage(interp, argTable, flags); Tcl_SetErrorCode(interp, "TK", "ARG", "HELP", NULL); return TCL_ERROR; case TK_ARGV_CONST_OPTION: Tk_AddOption(tkwin, infoPtr->dst, infoPtr->src, TK_INTERACTIVE_PRIO); break; case TK_ARGV_OPTION_VALUE: if (argc < 1) { goto missingArg; } Tk_AddOption(tkwin, infoPtr->dst, argv[srcIndex], TK_INTERACTIVE_PRIO); srcIndex++; argc--; break; case TK_ARGV_OPTION_NAME_VALUE: if (argc < 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "\"%s\" option requires two following arguments", curArg)); Tcl_SetErrorCode(interp, "TK", "ARG", "NAME_VALUE", curArg, NULL); return TCL_ERROR; } Tk_AddOption(tkwin, argv[srcIndex], argv[srcIndex+1], TK_INTERACTIVE_PRIO); srcIndex += 2; argc -= 2; break; default: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad argument type %d in Tk_ArgvInfo", infoPtr->type)); Tcl_SetErrorCode(interp, "TK", "API_ABUSE", NULL); return TCL_ERROR; } } /* * If we broke out of the loop because of an OPT_REST argument, copy the * remaining arguments down. */ argsDone: while (argc) { argv[dstIndex] = argv[srcIndex]; srcIndex++; dstIndex++; argc--; } argv[dstIndex] = NULL; *argcPtr = dstIndex; return TCL_OK; missingArg: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "\"%s\" option requires an additional argument", curArg)); Tcl_SetErrorCode(interp, "TK", "ARG", "MISSING", curArg, NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * PrintUsage -- |
︙ | ︙ | |||
324 325 326 327 328 329 330 | *---------------------------------------------------------------------- */ static void PrintUsage( Tcl_Interp *interp, /* Place information in this interp's result * area. */ | | | > | | | | | > | < > | < > | < | > | 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 | *---------------------------------------------------------------------- */ static void PrintUsage( Tcl_Interp *interp, /* Place information in this interp's result * area. */ const Tk_ArgvInfo *argTable,/* Array of command-specific argument * descriptions. */ int flags) /* If the TK_ARGV_NO_DEFAULTS bit is set in * this word, then don't generate information * for default options. */ { register const Tk_ArgvInfo *infoPtr; size_t width, i, numSpaces; Tcl_Obj *message; /* * First, compute the width of the widest option key, so that we can make * everything line up. */ width = 4; for (i = 0; i < 2; i++) { for (infoPtr = i ? defaultTable : argTable; infoPtr->type != TK_ARGV_END; infoPtr++) { size_t length; if (infoPtr->key == NULL) { continue; } length = strlen(infoPtr->key); if (length > width) { width = length; } } } message = Tcl_NewStringObj("Command-specific options:", -1); for (i = 0; ; i++) { for (infoPtr = i ? defaultTable : argTable; infoPtr->type != TK_ARGV_END; infoPtr++) { if ((infoPtr->type == TK_ARGV_HELP) && (infoPtr->key == NULL)) { Tcl_AppendPrintfToObj(message, "\n%s", infoPtr->help); continue; } Tcl_AppendPrintfToObj(message, "\n %s:", infoPtr->key); numSpaces = width + 1 - strlen(infoPtr->key); while (numSpaces-- > 0) { Tcl_AppendToObj(message, " ", 1); } Tcl_AppendToObj(message, infoPtr->help, -1); switch (infoPtr->type) { case TK_ARGV_INT: Tcl_AppendPrintfToObj(message, "\n\t\tDefault value: %d", *((int *) infoPtr->dst)); break; case TK_ARGV_FLOAT: Tcl_AppendPrintfToObj(message, "\n\t\tDefault value: %f", *((double *) infoPtr->dst)); break; case TK_ARGV_STRING: { char *string = *((char **) infoPtr->dst); if (string != NULL) { Tcl_AppendPrintfToObj(message, "\n\t\tDefault value: \"%s\"", string); } break; } default: break; } } if ((flags & TK_ARGV_NO_DEFAULTS) || (i > 0)) { break; } Tcl_AppendToObj(message, "\nGeneric options for all commands:", -1); } Tcl_SetObjResult(interp, message); } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkBind.c.
︙ | ︙ | |||
616 617 618 619 620 621 622 | static PatSeq * FindSequence(Tcl_Interp *interp, Tcl_HashTable *patternTablePtr, ClientData object, const char *eventString, int create, int allowVirtual, unsigned long *maskPtr); static void GetAllVirtualEvents(Tcl_Interp *interp, VirtualEventTable *vetPtr); static char * GetField(char *p, char *copy, int size); | | | 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 | static PatSeq * FindSequence(Tcl_Interp *interp, Tcl_HashTable *patternTablePtr, ClientData object, const char *eventString, int create, int allowVirtual, unsigned long *maskPtr); static void GetAllVirtualEvents(Tcl_Interp *interp, VirtualEventTable *vetPtr); static char * GetField(char *p, char *copy, int size); static Tcl_Obj * GetPatternObj(PatSeq *psPtr); static int GetVirtualEvent(Tcl_Interp *interp, VirtualEventTable *vetPtr, Tcl_Obj *virtName); static Tk_Uid GetVirtualEventUid(Tcl_Interp *interp, char *virtString); static int HandleEventGenerate(Tcl_Interp *interp, Tk_Window main, int objc, Tcl_Obj *const objv[]); static void InitVirtualEventTable(VirtualEventTable *vetPtr); |
︙ | ︙ | |||
1090 1091 1092 1093 1094 1095 1096 | Tk_GetAllBindings( Tcl_Interp *interp, /* Interpreter returning result or error. */ Tk_BindingTable bindPtr, /* Table in which to look for bindings. */ ClientData object) /* Token for object. */ { PatSeq *psPtr; Tcl_HashEntry *hPtr; | | | > < < | | | 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | Tk_GetAllBindings( Tcl_Interp *interp, /* Interpreter returning result or error. */ Tk_BindingTable bindPtr, /* Table in which to look for bindings. */ ClientData object) /* Token for object. */ { PatSeq *psPtr; Tcl_HashEntry *hPtr; Tcl_Obj *resultObj; hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, (char *) object); if (hPtr == NULL) { return; } resultObj = Tcl_NewObj(); for (psPtr = Tcl_GetHashValue(hPtr); psPtr != NULL; psPtr = psPtr->nextObjPtr) { /* * For each binding, output information about each of the patterns in * its sequence. */ Tcl_ListObjAppendElement(NULL, resultObj, GetPatternObj(psPtr)); } Tcl_SetObjResult(interp, resultObj); } /* *-------------------------------------------------------------- * * Tk_DeleteAllBindings -- * |
︙ | ︙ | |||
1219 1220 1221 1222 1223 1224 1225 | ScreenInfo *screenPtr; BindInfo *bindInfoPtr; TkDisplay *oldDispPtr; XEvent *ringPtr; PatSeq *vMatchDetailList, *vMatchNoDetailList; int flags, oldScreen; Tcl_Interp *interp; | | > | 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 | ScreenInfo *screenPtr; BindInfo *bindInfoPtr; TkDisplay *oldDispPtr; XEvent *ringPtr; PatSeq *vMatchDetailList, *vMatchNoDetailList; int flags, oldScreen; Tcl_Interp *interp; Tcl_DString scripts; Tcl_InterpState interpState; Detail detail; char *p, *end; TkWindow *winPtr = (TkWindow *) tkwin; PatternTableKey key; /* * Ignore events on windows that don't have names: these are windows like |
︙ | ︙ | |||
1449 1450 1451 1452 1453 1454 1455 | * 2. The binding's action can potentially delete the binding, so bindPtr * may not point to anything valid once the action completes. Thus we * have to save bindPtr->interp in a local variable in order to restore * the result. */ interp = bindPtr->interp; | < | | | 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 | * 2. The binding's action can potentially delete the binding, so bindPtr * may not point to anything valid once the action completes. Thus we * have to save bindPtr->interp in a local variable in order to restore * the result. */ interp = bindPtr->interp; /* * Save information about the current screen, then invoke a script if the * screen has changed. */ interpState = Tcl_SaveInterpState(interp, TCL_OK); screenPtr = &bindInfoPtr->screenInfo; oldDispPtr = screenPtr->curDispPtr; oldScreen = screenPtr->curScreenIndex; if ((dispPtr != screenPtr->curDispPtr) || (Tk_ScreenNumber(tkwin) != screenPtr->curScreenIndex)) { screenPtr->curDispPtr = dispPtr; screenPtr->curScreenIndex = Tk_ScreenNumber(tkwin); ChangeScreen(interp, dispPtr->name, screenPtr->curScreenIndex); } p = Tcl_DStringValue(&scripts); end = p + Tcl_DStringLength(&scripts); /* * Be careful when dereferencing screenPtr or bindInfoPtr. If we evaluate * something that destroys ".", bindInfoPtr would have been freed, but we * can tell that by first checking to see if winPtr->mainPtr == NULL. */ Tcl_Preserve(bindInfoPtr); while (p < end) { int len = (int) strlen(p); |
︙ | ︙ | |||
1519 1520 1521 1522 1523 1524 1525 | * no longer current. Change the current display back again. */ screenPtr->curDispPtr = oldDispPtr; screenPtr->curScreenIndex = oldScreen; ChangeScreen(interp, oldDispPtr->name, oldScreen); } | | | 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 | * no longer current. Change the current display back again. */ screenPtr->curDispPtr = oldDispPtr; screenPtr->curScreenIndex = oldScreen; ChangeScreen(interp, oldDispPtr->name, oldScreen); } (void) Tcl_RestoreInterpState(interp, interpState); Tcl_DStringFree(&scripts); Tcl_Release(bindInfoPtr); } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
2767 2768 2769 2770 2771 2772 2773 | static int GetVirtualEvent( Tcl_Interp *interp, /* Interpreter for reporting. */ VirtualEventTable *vetPtr, /* Table in which to look for event. */ Tcl_Obj *virtName) /* String describing virtual event. */ { Tcl_HashEntry *vhPtr; | < > < | | | < | | 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 | static int GetVirtualEvent( Tcl_Interp *interp, /* Interpreter for reporting. */ VirtualEventTable *vetPtr, /* Table in which to look for event. */ Tcl_Obj *virtName) /* String describing virtual event. */ { Tcl_HashEntry *vhPtr; int iPhys; PhysicalsOwned *poPtr; Tk_Uid virtUid; Tcl_Obj *resultObj; virtUid = GetVirtualEventUid(interp, Tcl_GetString(virtName)); if (virtUid == NULL) { return TCL_ERROR; } vhPtr = Tcl_FindHashEntry(&vetPtr->nameTable, virtUid); if (vhPtr == NULL) { return TCL_OK; } resultObj = Tcl_NewObj(); poPtr = Tcl_GetHashValue(vhPtr); for (iPhys = 0; iPhys < poPtr->numOwned; iPhys++) { Tcl_ListObjAppendElement(NULL, resultObj, GetPatternObj(poPtr->patSeqs[iPhys])); } Tcl_SetObjResult(interp, resultObj); return TCL_OK; } /* *-------------------------------------------------------------- * |
︙ | ︙ | |||
2820 2821 2822 2823 2824 2825 2826 | static void GetAllVirtualEvents( Tcl_Interp *interp, /* Interpreter returning result. */ VirtualEventTable *vetPtr) /* Table containing events. */ { Tcl_HashEntry *hPtr; Tcl_HashSearch search; | | < | < | | < < | < | 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 | static void GetAllVirtualEvents( Tcl_Interp *interp, /* Interpreter returning result. */ VirtualEventTable *vetPtr) /* Table containing events. */ { Tcl_HashEntry *hPtr; Tcl_HashSearch search; Tcl_Obj *resultObj; resultObj = Tcl_NewObj(); hPtr = Tcl_FirstHashEntry(&vetPtr->nameTable, &search); for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_ObjPrintf( "<<%s>>", (char *) Tcl_GetHashKey(hPtr->tablePtr, hPtr))); } Tcl_SetObjResult(interp, resultObj); } /* *--------------------------------------------------------------------------- * * HandleEventGenerate -- * |
︙ | ︙ | |||
2920 2921 2922 2923 2924 2925 2926 | } else if (NameToWindow(interp, mainWin, objv[0], &tkwin) != TCL_OK) { return TCL_ERROR; } mainPtr = (TkWindow *) mainWin; if ((tkwin == NULL) || (mainPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr)) { | | | > > > > | < > > | < > | 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 | } else if (NameToWindow(interp, mainWin, objv[0], &tkwin) != TCL_OK) { return TCL_ERROR; } mainPtr = (TkWindow *) mainWin; if ((tkwin == NULL) || (mainPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window id \"%s\" doesn't exist in this application", Tcl_GetString(objv[0]))); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW", Tcl_GetString(objv[0]), NULL); return TCL_ERROR; } name = Tcl_GetString(objv[1]); p = name; eventMask = 0; userDataObj = NULL; count = ParseEventDescription(interp, &p, &pat, &eventMask); if (count == 0) { return TCL_ERROR; } if (count != 1) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Double or Triple modifier not allowed", -1)); Tcl_SetErrorCode(interp, "TK", "EVENT", "BAD_MODIFIER", NULL); return TCL_ERROR; } if (*p != '\0') { Tcl_SetObjResult(interp, Tcl_NewStringObj( "only one event specification allowed", -1)); Tcl_SetErrorCode(interp, "TK", "EVENT", "MULTIPLE", NULL); return TCL_ERROR; } memset(&event, 0, sizeof(event)); event.general.xany.type = pat.eventType; event.general.xany.serial = NextRequest(Tk_Display(tkwin)); event.general.xany.send_event = False; |
︙ | ︙ | |||
3017 3018 3019 3020 3021 3022 3023 | /* * This test occurs after Tcl_GetIndexFromObj() so that "event * generate <Button> -xyz" will return the error message that * "-xyz" is a bad option, rather than that the value for "-xyz" * is missing. */ | | | > | 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 | /* * This test occurs after Tcl_GetIndexFromObj() so that "event * generate <Button> -xyz" will return the error message that * "-xyz" is a bad option, rather than that the value for "-xyz" * is missing. */ Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(optionPtr))); Tcl_SetErrorCode(interp, "TK", "EVENT", "MISSING_VALUE", NULL); return TCL_ERROR; } switch ((enum field) index) { case EVENT_WARP: if (Tcl_GetBooleanFromObj(interp, valuePtr, &warp) != TCL_OK) { return TCL_ERROR; |
︙ | ︙ | |||
3159 3160 3161 3162 3163 3164 3165 | case EVENT_KEYSYM: { KeySym keysym; const char *value; value = Tcl_GetString(valuePtr); keysym = TkStringToKeysym(value); if (keysym == NoSymbol) { | > | > > | > | | 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 | case EVENT_KEYSYM: { KeySym keysym; const char *value; value = Tcl_GetString(valuePtr); keysym = TkStringToKeysym(value); if (keysym == NoSymbol) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown keysym \"%s\"", value)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYSYM", value, NULL); return TCL_ERROR; } TkpSetKeycodeAndState(tkwin, keysym, &event.general); if (event.general.xkey.keycode == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "no keycode for keysym \"%s\"", value)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYCODE", value, NULL); return TCL_ERROR; } if (!(flags & KEY) || (event.general.xkey.type == MouseWheelEvent)) { goto badopt; } break; |
︙ | ︙ | |||
3396 3397 3398 3399 3400 3401 3402 | goto badopt; } break; } continue; badopt: | > | | > | 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 | goto badopt; } break; } continue; badopt: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s event doesn't accept \"%s\" option", name, Tcl_GetString(optionPtr))); Tcl_SetErrorCode(interp, "TK", "EVENT", "BAD_OPTION", NULL); return TCL_ERROR; } /* * Don't generate events for windows that don't exist yet. */ |
︙ | ︙ | |||
3491 3492 3493 3494 3495 3496 3497 | goto badWindow; } } *tkwinPtr = tkwin; return TCL_OK; badWindow: | > | > | 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 | goto badWindow; } } *tkwinPtr = tkwin; return TCL_OK; badWindow: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad window name/identifier \"%s\"", name)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW_ID", name, NULL); return TCL_ERROR; } /* *------------------------------------------------------------------------- * * DoWarp -- |
︙ | ︙ | |||
3554 3555 3556 3557 3558 3559 3560 | Tk_Uid uid; size_t length; length = strlen(virtString); if (length < 5 || virtString[0] != '<' || virtString[1] != '<' || virtString[length - 2] != '>' || virtString[length - 1] != '>') { | | | > | 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 | Tk_Uid uid; size_t length; length = strlen(virtString); if (length < 5 || virtString[0] != '<' || virtString[1] != '<' || virtString[length - 2] != '>' || virtString[length - 1] != '>') { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "virtual event \"%s\" is badly formed", virtString)); Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "MALFORMED", NULL); return NULL; } virtString[length - 2] = '\0'; uid = Tk_GetUid(virtString + 2); virtString[length - 2] = '>'; return uid; |
︙ | ︙ | |||
3647 3648 3649 3650 3651 3652 3653 | count = ParseEventDescription(interp, &p, patPtr, &eventMask); if (count == 0) { return NULL; } if (eventMask & VirtualEventMask) { if (allowVirtual == 0) { | | | > > | 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 | count = ParseEventDescription(interp, &p, patPtr, &eventMask); if (count == 0) { return NULL; } if (eventMask & VirtualEventMask) { if (allowVirtual == 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "virtual event not allowed in definition of another virtual event", -1)); Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "INNER", NULL); return NULL; } virtualFound = 1; } /* * Replicate events for DOUBLE, TRIPLE, QUADRUPLE. |
︙ | ︙ | |||
3675 3676 3677 3678 3679 3680 3681 | *------------------------------------------------------------- * Step 2: find the sequence in the binding table if it exists, and add a * new sequence to the table if it doesn't. *------------------------------------------------------------- */ if (numPats == 0) { | > | > > | > | | 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 | *------------------------------------------------------------- * Step 2: find the sequence in the binding table if it exists, and add a * new sequence to the table if it doesn't. *------------------------------------------------------------- */ if (numPats == 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "no events specified in binding", -1)); Tcl_SetErrorCode(interp, "TK", "EVENT", "NO_EVENTS", NULL); return NULL; } if ((numPats > 1) && (virtualFound != 0)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "virtual events may not be composed", -1)); Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "COMPOSITION", NULL); return NULL; } patPtr = &pats[EVENT_BUFFER_SIZE-numPats]; memset(&key, 0, sizeof(key)); key.object = object; key.type = patPtr->eventType; |
︙ | ︙ | |||
3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 | patPtr->detail.keySym = TkStringToKeysym(string); if (patPtr->detail.keySym == NoSymbol) { if (isprint(UCHAR(*p))) { patPtr->detail.keySym = *p; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad ASCII character 0x%x", UCHAR(*p))); count = 0; goto done; } } p++; goto end; } | > | 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 | patPtr->detail.keySym = TkStringToKeysym(string); if (patPtr->detail.keySym == NoSymbol) { if (isprint(UCHAR(*p))) { patPtr->detail.keySym = *p; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad ASCII character 0x%x", UCHAR(*p))); Tcl_SetErrorCode(interp, "TK", "EVENT", "BAD_CHAR", NULL); count = 0; goto done; } } p++; goto end; } |
︙ | ︙ | |||
3840 3841 3842 3843 3844 3845 3846 | * '>'. */ char *field = p + 1; p = strchr(field, '>'); if (p == field) { | > | > | > | > | | 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 | * '>'. */ char *field = p + 1; p = strchr(field, '>'); if (p == field) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "virtual event \"<<>>\" is badly formed", -1)); Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "MALFORMED", NULL); count = 0; goto done; } if ((p == NULL) || (p[1] != '>')) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "missing \">\" in virtual binding", -1)); Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "MALFORMED", NULL); count = 0; goto done; } *p = '\0'; patPtr->eventType = VirtualEvent; eventMask = VirtualEventMask; patPtr->detail.name = Tk_GetUid(field); |
︙ | ︙ | |||
3913 3914 3915 3916 3917 3918 3919 | if (*field != '\0') { if ((*field >= '1') && (*field <= '5') && (field[1] == '\0')) { if (eventFlags == 0) { patPtr->eventType = ButtonPress; eventMask = ButtonPressMask; } else if (eventFlags & KEY) { goto getKeysym; | | | | > > > | > | | | | > > | < > | | | > | > | 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 | if (*field != '\0') { if ((*field >= '1') && (*field <= '5') && (field[1] == '\0')) { if (eventFlags == 0) { patPtr->eventType = ButtonPress; eventMask = ButtonPressMask; } else if (eventFlags & KEY) { goto getKeysym; } else if (!(eventFlags & BUTTON)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "specified button \"%s\" for non-button event", field)); Tcl_SetErrorCode(interp, "TK", "EVENT", "NON_BUTTON", NULL); count = 0; goto done; } patPtr->detail.button = (*field - '0'); } else { getKeysym: patPtr->detail.keySym = TkStringToKeysym(field); if (patPtr->detail.keySym == NoSymbol) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad event type or keysym \"%s\"", field)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYSYM", field, NULL); count = 0; goto done; } if (eventFlags == 0) { patPtr->eventType = KeyPress; eventMask = KeyPressMask; } else if (!(eventFlags & KEY)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "specified keysym \"%s\" for non-key event", field)); Tcl_SetErrorCode(interp, "TK", "EVENT", "NON_KEY", NULL); count = 0; goto done; } } } else if (eventFlags == 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "no event type or button # or keysym", -1)); Tcl_SetErrorCode(interp, "TK", "EVENT", "UNMODIFIABLE", NULL); count = 0; goto done; } while ((*p == '-') || isspace(UCHAR(*p))) { p++; } if (*p != '>') { while (*p != '\0') { p++; if (*p == '>') { Tcl_SetObjResult(interp, Tcl_NewStringObj( "extra characters after detail in binding", -1)); Tcl_SetErrorCode(interp, "TK", "EVENT", "PAST_DETAIL", NULL); count = 0; goto done; } } Tcl_SetObjResult(interp, Tcl_NewStringObj( "missing \">\" in binding", -1)); Tcl_SetErrorCode(interp, "TK", "EVENT", "MALFORMED", NULL); count = 0; goto done; } p++; end: *eventStringPtr += (p - Tcl_DStringValue(©)); |
︙ | ︙ | |||
4016 4017 4018 4019 4020 4021 4022 | *copy = '\0'; return p; } /* *--------------------------------------------------------------------------- * | | | | | | | | < < > | | | > < | < | | | | | < | | | | < | > > | 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 | *copy = '\0'; return p; } /* *--------------------------------------------------------------------------- * * GetPatternObj -- * * Produce a string version of the given event, for displaying to the * user. * * Results: * The string is returned as a Tcl_Obj. * * Side effects: * It is the caller's responsibility to arrange for the object to be * released; it starts with a refCount of zero. * *--------------------------------------------------------------------------- */ static Tcl_Obj * GetPatternObj( PatSeq *psPtr) { Pattern *patPtr; int patsLeft, needMods; const ModInfo *modPtr; const EventInfo *eiPtr; Tcl_Obj *patternObj = Tcl_NewObj(); /* * The order of the patterns in the sequence is backwards from the order * in which they must be output. */ for (patsLeft = psPtr->numPats, patPtr = &psPtr->pats[psPtr->numPats - 1]; patsLeft > 0; patsLeft--, patPtr--) { /* * Check for simple case of an ASCII character. */ if ((patPtr->eventType == KeyPress) && !(psPtr->flags & PAT_NEARBY) && (patPtr->needMods == 0) && (patPtr->detail.keySym < 128) && isprint(UCHAR(patPtr->detail.keySym)) && (patPtr->detail.keySym != '<') && (patPtr->detail.keySym != ' ')) { char c = (char) patPtr->detail.keySym; Tcl_AppendToObj(patternObj, &c, 1); continue; } /* * Check for virtual event. */ if (patPtr->eventType == VirtualEvent) { Tcl_AppendPrintfToObj(patternObj, "<<%s>>", patPtr->detail.name); continue; } /* * It's a more general event specification. First check for "Double", * "Triple", "Quadruple", then modifiers, then event type, then keysym * or button detail. */ Tcl_AppendToObj(patternObj, "<", 1); if ((psPtr->flags & PAT_NEARBY) && (patsLeft > 1) && (memcmp(patPtr, patPtr-1, sizeof(Pattern)) == 0)) { patsLeft--; patPtr--; if ((patsLeft > 1) && (memcmp(patPtr, patPtr-1, sizeof(Pattern)) == 0)) { patsLeft--; patPtr--; if ((patsLeft > 1) && (memcmp(patPtr, patPtr-1, sizeof(Pattern)) == 0)) { patsLeft--; patPtr--; Tcl_AppendToObj(patternObj, "Quadruple-", 10); } else { Tcl_AppendToObj(patternObj, "Triple-", 7); } } else { Tcl_AppendToObj(patternObj, "Double-", 7); } } for (needMods = patPtr->needMods, modPtr = modArray; needMods != 0; modPtr++) { if (modPtr->mask & needMods) { needMods &= ~modPtr->mask; Tcl_AppendPrintfToObj(patternObj, "%s-", modPtr->name); } } for (eiPtr = eventArray; eiPtr->name != NULL; eiPtr++) { if (eiPtr->type == patPtr->eventType) { Tcl_AppendToObj(patternObj, eiPtr->name, -1); if (patPtr->detail.clientData != 0) { Tcl_AppendToObj(patternObj, "-", 1); } break; } } if (patPtr->detail.clientData != 0) { if ((patPtr->eventType == KeyPress) || (patPtr->eventType == KeyRelease)) { const char *string = TkKeysymToString(patPtr->detail.keySym); if (string != NULL) { Tcl_AppendToObj(patternObj, string, -1); } } else { Tcl_AppendPrintfToObj(patternObj, "%d", patPtr->detail.button); } } Tcl_AppendToObj(patternObj, ">", 1); } return patternObj; } /* *---------------------------------------------------------------------- * * TkStringToKeysym -- * |
︙ | ︙ |
Changes to generic/tkBitmap.c.
︙ | ︙ | |||
338 339 340 341 342 343 344 | */ if (*string == '@') { /* INTL: ISO char */ Tcl_DString buffer; int result; if (Tcl_IsSafe(interp)) { | > | > | > | | | | > > | 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 | */ if (*string == '@') { /* INTL: ISO char */ Tcl_DString buffer; int result; if (Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't specify bitmap with '@' in a safe interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "BITMAP_FILE", NULL); goto error; } /* * Note that we need to cast away the const from the string because * Tcl_TranslateFileName is non-const, even though it doesn't modify * the string. */ string = Tcl_TranslateFileName(interp, (char *) string + 1, &buffer); if (string == NULL) { goto error; } result = TkReadBitmapFile(Tk_Display(tkwin), RootWindowOfScreen(Tk_Screen(tkwin)), string, (unsigned int *) &width, (unsigned int *) &height, &bitmap, &dummy2, &dummy2); if (result != BitmapSuccess) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error reading bitmap file \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "BITMAP", "FILE_ERROR", NULL); } Tcl_DStringFree(&buffer); goto error; } Tcl_DStringFree(&buffer); } else { predefHashPtr = Tcl_FindHashEntry(&tsdPtr->predefBitmapTable, string); if (predefHashPtr == NULL) { /* * The following platform specific call allows the user to define * bitmaps that may only exist during run time. If it returns None * nothing was found and we return the error. */ bitmap = TkpGetNativeAppBitmap(Tk_Display(tkwin), string, &width, &height); if (bitmap == None) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bitmap \"%s\" not defined", string)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "BITMAP", string, NULL); } goto error; } } else { predefPtr = Tcl_GetHashValue(predefHashPtr); width = predefPtr->width; height = predefPtr->height; |
︙ | ︙ | |||
483 484 485 486 487 488 489 | if (!tsdPtr->initialized) { BitmapInit(NULL); } predefHashPtr = Tcl_CreateHashEntry(&tsdPtr->predefBitmapTable, name, &isNew); if (!isNew) { | > | | | 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | if (!tsdPtr->initialized) { BitmapInit(NULL); } predefHashPtr = Tcl_CreateHashEntry(&tsdPtr->predefBitmapTable, name, &isNew); if (!isNew) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bitmap \"%s\" is already defined", name)); Tcl_SetErrorCode(interp, "TK", "BITMAP", "EXISTS", NULL); return TCL_ERROR; } predefPtr = ckalloc(sizeof(TkPredefBitmap)); predefPtr->source = source; predefPtr->width = width; predefPtr->height = height; predefPtr->native = 0; |
︙ | ︙ |
Changes to generic/tkBusy.c.
︙ | ︙ | |||
683 684 685 686 687 688 689 | if (TkGetWindowFromObj(interp, Tk_MainWindow(interp), windowObj, &tkwin) != TCL_OK) { return NULL; } hPtr = Tcl_FindHashEntry(busyTablePtr, (char *) tkwin); if (hPtr == NULL) { | > | > | | 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 | if (TkGetWindowFromObj(interp, Tk_MainWindow(interp), windowObj, &tkwin) != TCL_OK) { return NULL; } hPtr = Tcl_FindHashEntry(busyTablePtr, (char *) tkwin); if (hPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't find busy window \"%s\"", Tcl_GetString(windowObj))); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "BUSY", Tcl_GetString(windowObj), NULL); return NULL; } return Tcl_GetHashValue(hPtr); } /* *---------------------------------------------------------------------- |
︙ | ︙ |
Changes to generic/tkCanvArc.c.
︙ | ︙ | |||
340 341 342 343 344 345 346 | * modified. */ int objc, /* Number of coordinates supplied in objv. */ Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */ { ArcItem *arcPtr = (ArcItem *) itemPtr; if (objc == 0) { | | < < > | < | < | < | < | | | > < | | | | 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 | * modified. */ int objc, /* Number of coordinates supplied in objv. */ Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */ { ArcItem *arcPtr = (ArcItem *) itemPtr; if (objc == 0) { Tcl_Obj *objs[4]; objs[0] = Tcl_NewDoubleObj(arcPtr->bbox[0]); objs[1] = Tcl_NewDoubleObj(arcPtr->bbox[1]); objs[2] = Tcl_NewDoubleObj(arcPtr->bbox[2]); objs[3] = Tcl_NewDoubleObj(arcPtr->bbox[3]); Tcl_SetObjResult(interp, Tcl_NewListObj(4, objs)); } else if ((objc == 1)||(objc == 4)) { if (objc==1) { if (Tcl_ListObjGetElements(interp, objv[0], &objc, (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; } else if (objc != 4) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # coordinates: expected 4, got %d", objc)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "ARC", NULL); return TCL_ERROR; } } if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0], &arcPtr->bbox[0]) != TCL_OK) || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1], &arcPtr->bbox[1]) != TCL_OK) || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[2], &arcPtr->bbox[2]) != TCL_OK) || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[3], &arcPtr->bbox[3]) != TCL_OK)) { return TCL_ERROR; } ComputeArcBbox(canvas, arcPtr); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # coordinates: expected 0 or 4, got %d", objc)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "ARC", NULL); return TCL_ERROR; } return TCL_OK; } /* *-------------------------------------------------------------- |
︙ | ︙ | |||
1819 1820 1821 1822 1823 1824 1825 | Tk_Canvas canvas, /* Information about overall canvas. */ Tk_Item *itemPtr, /* Item for which Postscript is wanted. */ int prepass) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ { ArcItem *arcPtr = (ArcItem *) itemPtr; | < > > | 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 | Tk_Canvas canvas, /* Information about overall canvas. */ Tk_Item *itemPtr, /* Item for which Postscript is wanted. */ int prepass) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ { ArcItem *arcPtr = (ArcItem *) itemPtr; double y1, y2, ang1, ang2; XColor *color; Pixmap stipple; XColor *fillColor; Pixmap fillStipple; Tk_State state = itemPtr->state; Tcl_Obj *psObj; Tcl_InterpState interpState; y1 = Tk_CanvasPsY(canvas, arcPtr->bbox[1]); y2 = Tk_CanvasPsY(canvas, arcPtr->bbox[3]); ang1 = arcPtr->start; ang2 = ang1 + arcPtr->extent; if (ang2 < ang1) { ang1 = ang2; |
︙ | ︙ | |||
1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 | fillColor = arcPtr->disabledFillColor; } if (arcPtr->disabledFillStipple!=None) { fillStipple = arcPtr->disabledFillStipple; } } /* * If the arc is filled, output Postscript for the interior region of the * arc. */ if (arcPtr->fillGC != None) { | > > > > > > > > > | | | | < < > | | | | | < > > > > | > < > > > | | > > | < < | | > > > | < > > > | > > | | < > > > | > | < > > | | > > | | < > > > | > < > > | > > > > > > > > > > > > | 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 | fillColor = arcPtr->disabledFillColor; } if (arcPtr->disabledFillStipple!=None) { fillStipple = arcPtr->disabledFillStipple; } } /* * Make our working space. */ psObj = Tcl_NewObj(); interpState = Tcl_SaveInterpState(interp, TCL_OK); /* * If the arc is filled, output Postscript for the interior region of the * arc. */ if (arcPtr->fillGC != None) { Tcl_AppendPrintfToObj(psObj, "matrix currentmatrix\n" "%.15g %.15g translate %.15g %.15g scale\n", (arcPtr->bbox[0] + arcPtr->bbox[2])/2, (y1 + y2)/2, (arcPtr->bbox[2] - arcPtr->bbox[0])/2, (y1 - y2)/2); if (arcPtr->style != CHORD_STYLE) { Tcl_AppendToObj(psObj, "0 0 moveto ", -1); } Tcl_AppendPrintfToObj(psObj, "0 0 1 %.15g %.15g arc closepath\nsetmatrix\n", ang1, ang2); Tcl_ResetResult(interp); if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (fillStipple != None) { Tcl_AppendToObj(psObj, "clip ", -1); Tcl_ResetResult(interp); if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (arcPtr->outline.gc != None) { Tcl_AppendToObj(psObj, "grestore gsave\n", -1); } } else { Tcl_AppendToObj(psObj, "fill\n", -1); } } /* * If there's an outline for the arc, draw it. */ if (arcPtr->outline.gc != None) { Tcl_AppendPrintfToObj(psObj, "matrix currentmatrix\n" "%.15g %.15g translate %.15g %.15g scale\n", (arcPtr->bbox[0] + arcPtr->bbox[2])/2, (y1 + y2)/2, (arcPtr->bbox[2] - arcPtr->bbox[0])/2, (y1 - y2)/2); Tcl_AppendPrintfToObj(psObj, "0 0 1 %.15g %.15g arc\nsetmatrix\n0 setlinecap\n", ang1, ang2); Tcl_ResetResult(interp); if (Tk_CanvasPsOutline(canvas, itemPtr, &arcPtr->outline) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (arcPtr->style != ARC_STYLE) { Tcl_AppendToObj(psObj, "grestore gsave\n", -1); Tcl_ResetResult(interp); if (arcPtr->style == CHORD_STYLE) { Tk_CanvasPsPath(interp, canvas, arcPtr->outlinePtr, CHORD_OUTLINE_PTS); } else { Tk_CanvasPsPath(interp, canvas, arcPtr->outlinePtr, PIE_OUTLINE1_PTS); if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (stipple != None) { Tcl_AppendToObj(psObj, "clip ", -1); Tcl_ResetResult(interp); if (Tk_CanvasPsStipple(interp, canvas, stipple) !=TCL_OK){ goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); } else { Tcl_AppendToObj(psObj, "fill\n", -1); } Tcl_AppendToObj(psObj, "grestore gsave\n", -1); Tcl_ResetResult(interp); Tk_CanvasPsPath(interp, canvas, arcPtr->outlinePtr + 2*PIE_OUTLINE1_PTS, PIE_OUTLINE2_PTS); } if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (stipple != None) { Tcl_AppendToObj(psObj, "clip ", -1); Tcl_ResetResult(interp); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); } else { Tcl_AppendToObj(psObj, "fill\n", -1); } } } /* * Plug the accumulated postscript back into the result. */ (void) Tcl_RestoreInterpState(interp, interpState); Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj); Tcl_DecrRefCount(psObj); return TCL_OK; error: Tcl_DiscardInterpState(interpState); Tcl_DecrRefCount(psObj); return TCL_ERROR; } /* *-------------------------------------------------------------- * * StyleParseProc -- * |
︙ | ︙ | |||
2017 2018 2019 2020 2021 2022 2023 | return TCL_OK; } if ((c == 'p') && (strncmp(value, "pieslice", length) == 0)) { *stylePtr = PIESLICE_STYLE; return TCL_OK; } | | | > > | 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 | return TCL_OK; } if ((c == 'p') && (strncmp(value, "pieslice", length) == 0)) { *stylePtr = PIESLICE_STYLE; return TCL_OK; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad -style option \"%s\": must be arc, chord, or pieslice", value)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARC_STYLE", NULL); *stylePtr = PIESLICE_STYLE; return TCL_ERROR; } /* *-------------------------------------------------------------- * |
︙ | ︙ |
Changes to generic/tkCanvBmap.c.
︙ | ︙ | |||
245 246 247 248 249 250 251 | Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */ { BitmapItem *bmapPtr = (BitmapItem *) itemPtr; if (objc == 0) { Tcl_Obj *obj = Tcl_NewObj(); | < | < | < | | | > < | | | | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */ { BitmapItem *bmapPtr = (BitmapItem *) itemPtr; if (objc == 0) { Tcl_Obj *obj = Tcl_NewObj(); Tcl_ListObjAppendElement(NULL, obj, Tcl_NewDoubleObj(bmapPtr->x)); Tcl_ListObjAppendElement(NULL, obj, Tcl_NewDoubleObj(bmapPtr->y)); Tcl_SetObjResult(interp, obj); } else if (objc < 3) { if (objc == 1) { if (Tcl_ListObjGetElements(interp, objv[0], &objc, (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; } else if (objc != 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # coordinates: expected 2, got %d", objc)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "BITMAP", NULL); return TCL_ERROR; } } if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0], &bmapPtr->x) != TCL_OK) || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1], &bmapPtr->y) != TCL_OK)) { return TCL_ERROR; } ComputeBitmapBbox(canvas, bmapPtr); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # coordinates: expected 0 or 2, got %d", objc)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "BITMAP", NULL); return TCL_ERROR; } return TCL_OK; } /* *-------------------------------------------------------------- |
︙ | ︙ | |||
849 850 851 852 853 854 855 | * information; 0 means final Postscript is * being created. */ { BitmapItem *bmapPtr = (BitmapItem *) itemPtr; double x, y; int width, height, rowsAtOnce, rowsThisTime; int curRow; | < > > | 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 | * information; 0 means final Postscript is * being created. */ { BitmapItem *bmapPtr = (BitmapItem *) itemPtr; double x, y; int width, height, rowsAtOnce, rowsThisTime; int curRow; XColor *fgColor; XColor *bgColor; Pixmap bitmap; Tk_State state = itemPtr->state; Tcl_Obj *psObj; Tcl_InterpState interpState; if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } fgColor = bmapPtr->fgColor; bgColor = bmapPtr->bgColor; bitmap = bmapPtr->bitmap; |
︙ | ︙ | |||
908 909 910 911 912 913 914 915 916 917 918 919 | case TK_ANCHOR_SE: x -= width; break; case TK_ANCHOR_S: x -= width/2.0; break; case TK_ANCHOR_SW: break; case TK_ANCHOR_W: y -= height/2.0; break; case TK_ANCHOR_CENTER: x -= width/2.0; y -= height/2.0; break; } /* * Color the background, if there is one. */ if (bgColor != NULL) { | > > > > > > > | | > | | > < > > | > > < > > > | | | < > > > > | | > > | | > > > > | > | > | > > > | > > > > | > > > | | 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 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 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 | case TK_ANCHOR_SE: x -= width; break; case TK_ANCHOR_S: x -= width/2.0; break; case TK_ANCHOR_SW: break; case TK_ANCHOR_W: y -= height/2.0; break; case TK_ANCHOR_CENTER: x -= width/2.0; y -= height/2.0; break; } /* * Make our working space. */ psObj = Tcl_NewObj(); interpState = Tcl_SaveInterpState(interp, TCL_OK); /* * Color the background, if there is one. */ if (bgColor != NULL) { Tcl_AppendPrintfToObj(psObj, "%.15g %.15g moveto %d 0 rlineto 0 %d rlineto " "%d 0 rlineto closepath\n", x, y, width, height, -width); Tcl_ResetResult(interp); if (Tk_CanvasPsColor(interp, canvas, bgColor) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); Tcl_AppendToObj(psObj, "fill\n", -1); } /* * Draw the bitmap, if there is a foreground color. If the bitmap is very * large, then chop it up into multiple bitmaps, each consisting of one or * more rows. This is needed because Postscript can't handle single * strings longer than 64 KBytes long. */ if (fgColor != NULL) { Tcl_ResetResult(interp); if (Tk_CanvasPsColor(interp, canvas, fgColor) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (width > 60000) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't generate Postscript for bitmaps more than 60000" " pixels wide", -1)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", NULL); goto error; } rowsAtOnce = 60000/width; if (rowsAtOnce < 1) { rowsAtOnce = 1; } Tcl_AppendPrintfToObj(psObj, "%.15g %.15g translate\n", x, y+height); for (curRow = 0; curRow < height; curRow += rowsAtOnce) { rowsThisTime = rowsAtOnce; if (rowsThisTime > (height - curRow)) { rowsThisTime = height - curRow; } Tcl_AppendPrintfToObj(psObj, "0 -%.15g translate\n%d %d true matrix {\n", (double) rowsThisTime, width, rowsThisTime); Tcl_ResetResult(interp); if (Tk_CanvasPsBitmap(interp, canvas, bitmap, 0, curRow, width, rowsThisTime) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); Tcl_AppendToObj(psObj, "\n} imagemask\n", -1); } } /* * Plug the accumulated postscript back into the result. */ (void) Tcl_RestoreInterpState(interp, interpState); Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj); Tcl_DecrRefCount(psObj); return TCL_OK; error: Tcl_DiscardInterpState(interpState); Tcl_DecrRefCount(psObj); return TCL_ERROR; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkCanvImg.c.
︙ | ︙ | |||
228 229 230 231 232 233 234 | * modified. */ int objc, /* Number of coordinates supplied in objv. */ Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */ { ImageItem *imgPtr = (ImageItem *) itemPtr; if (objc == 0) { | | | < | < | < | | | > | > < | | | | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | * modified. */ int objc, /* Number of coordinates supplied in objv. */ Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */ { ImageItem *imgPtr = (ImageItem *) itemPtr; if (objc == 0) { Tcl_Obj *objs[2]; objs[0] = Tcl_NewDoubleObj(imgPtr->x); objs[1] = Tcl_NewDoubleObj(imgPtr->y); Tcl_SetObjResult(interp, Tcl_NewListObj(2, objs)); } else if (objc < 3) { if (objc==1) { if (Tcl_ListObjGetElements(interp, objv[0], &objc, (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; } else if (objc != 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # coordinates: expected 2, got %d", objc)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "IMAGE", NULL); return TCL_ERROR; } } if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0], &imgPtr->x) != TCL_OK) || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1], &imgPtr->y) != TCL_OK)) { return TCL_ERROR; } ComputeImageBbox(canvas, imgPtr); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # coordinates: expected 0 or 2, got %d", objc)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "IMAGE", NULL); return TCL_ERROR; } return TCL_OK; } /* *-------------------------------------------------------------- |
︙ | ︙ | |||
693 694 695 696 697 698 699 | Tk_Item *itemPtr, /* Item for which Postscript is wanted. */ int prepass) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created.*/ { ImageItem *imgPtr = (ImageItem *) itemPtr; Tk_Window canvasWin = Tk_CanvasTkwin(canvas); | < < | | 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 | Tk_Item *itemPtr, /* Item for which Postscript is wanted. */ int prepass) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created.*/ { ImageItem *imgPtr = (ImageItem *) itemPtr; Tk_Window canvasWin = Tk_CanvasTkwin(canvas); double x, y; int width, height; Tk_Image image; Tk_State state = itemPtr->state; if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } image = imgPtr->image; if (Canvas(canvas)->currentItemPtr == itemPtr) { if (imgPtr->activeImage != NULL) { image = imgPtr->activeImage; |
︙ | ︙ | |||
744 745 746 747 748 749 750 | case TK_ANCHOR_S: x -= width/2.0; break; case TK_ANCHOR_SW: break; case TK_ANCHOR_W: y -= height/2.0; break; case TK_ANCHOR_CENTER: x -= width/2.0; y -= height/2.0; break; } if (!prepass) { | > | > > | > > > | 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 | case TK_ANCHOR_S: x -= width/2.0; break; case TK_ANCHOR_SW: break; case TK_ANCHOR_W: y -= height/2.0; break; case TK_ANCHOR_CENTER: x -= width/2.0; y -= height/2.0; break; } if (!prepass) { Tcl_Obj *psObj = Tcl_GetObjResult(interp); if (Tcl_IsShared(psObj)) { psObj = Tcl_DuplicateObj(psObj); Tcl_SetObjResult(interp, psObj); } Tcl_AppendPrintfToObj(psObj, "%.15g %.15g translate\n", x, y); } return Tk_PostscriptImage(image, interp, canvasWin, ((TkCanvas *) canvas)->psInfo, 0, 0, width, height, prepass); } /* |
︙ | ︙ |
Changes to generic/tkCanvLine.c.
︙ | ︙ | |||
71 72 73 74 75 76 77 | /* * Prototypes for functions defined in this file: */ static int ArrowheadPostscript(Tcl_Interp *interp, Tk_Canvas canvas, LineItem *linePtr, | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | /* * Prototypes for functions defined in this file: */ static int ArrowheadPostscript(Tcl_Interp *interp, Tk_Canvas canvas, LineItem *linePtr, double *arrowPtr, Tcl_Obj *psObj); static void ComputeLineBbox(Tk_Canvas canvas, LineItem *linePtr); static int ConfigureLine(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[], int flags); static int ConfigureArrows(Tk_Canvas canvas, LineItem *linePtr); static int CreateLine(Tcl_Interp *interp, Tk_Canvas canvas, struct Tk_Item *itemPtr, |
︙ | ︙ | |||
387 388 389 390 391 392 393 | if (objc == 1) { if (Tcl_ListObjGetElements(interp, objv[0], &objc, (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; } } if (objc & 1) { | < | | | | < | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | 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 | if (objc == 1) { if (Tcl_ListObjGetElements(interp, objv[0], &objc, (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; } } if (objc & 1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # coordinates: expected an even number, got %d", objc)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "LINE", NULL); return TCL_ERROR; } else if (objc < 4) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # coordinates: expected at least 4, got %d", objc)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "LINE", NULL); return TCL_ERROR; } numPoints = objc/2; if (linePtr->numPoints != numPoints) { coordPtr = ckalloc(sizeof(double) * objc); if (linePtr->coordPtr != NULL) { ckfree(linePtr->coordPtr); } linePtr->coordPtr = coordPtr; linePtr->numPoints = numPoints; } coordPtr = linePtr->coordPtr; for (i = 0; i < objc ; i++) { if (Tk_CanvasGetCoordFromObj(interp, canvas, objv[i], coordPtr++) != TCL_OK) { return TCL_ERROR; } } /* * Update arrowheads by throwing away any existing arrow-head information * and calling ConfigureArrows to recompute it. */ if (linePtr->firstArrowPtr != NULL) { ckfree(linePtr->firstArrowPtr); linePtr->firstArrowPtr = NULL; } if (linePtr->lastArrowPtr != NULL) { ckfree(linePtr->lastArrowPtr); linePtr->lastArrowPtr = NULL; } if (linePtr->arrow != ARROWS_NONE) { ConfigureArrows(canvas, linePtr); } ComputeLineBbox(canvas, linePtr); return TCL_OK; } /* *-------------------------------------------------------------- * * ConfigureLine -- |
︙ | ︙ | |||
1748 1749 1750 1751 1752 1753 1754 | int length; const char *string = Tcl_GetStringFromObj(obj, &length); if (string[0] == 'e') { if (strncmp(string, "end", (unsigned) length) == 0) { *indexPtr = 2*linePtr->numPoints; } else { | < < < < < | < < < | 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 | int length; const char *string = Tcl_GetStringFromObj(obj, &length); if (string[0] == 'e') { if (strncmp(string, "end", (unsigned) length) == 0) { *indexPtr = 2*linePtr->numPoints; } else { goto badIndex; } } else if (string[0] == '@') { int i; double x, y, bestDist, dist, *coordPtr; char *end; const char *p; |
︙ | ︙ | |||
1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 | if (*indexPtr < 0){ *indexPtr = 0; } else if (*indexPtr > (2*linePtr->numPoints)) { *indexPtr = (2*linePtr->numPoints); } } return TCL_OK; } /* *-------------------------------------------------------------- * * TranslateLine -- * | > > > > > > > > > > > | 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 | if (*indexPtr < 0){ *indexPtr = 0; } else if (*indexPtr > (2*linePtr->numPoints)) { *indexPtr = (2*linePtr->numPoints); } } return TCL_OK; /* * Some of the paths here leave messages in interp->result, so we have to * clear it out before storing our own message. */ badIndex: Tcl_ResetResult(interp); Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "LINE", NULL); return TCL_ERROR; } /* *-------------------------------------------------------------- * * TranslateLine -- * |
︙ | ︙ | |||
1890 1891 1892 1893 1894 1895 1896 | const char **argv = NULL; if (offset != Tk_Offset(LineItem, arrowShapeA)) { Tcl_Panic("ParseArrowShape received bogus offset"); } if (Tcl_SplitList(interp, (char *) value, &argc, &argv) != TCL_OK) { | | < < < < < < < < | > > > > > > > > > > > > | 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 | const char **argv = NULL; if (offset != Tk_Offset(LineItem, arrowShapeA)) { Tcl_Panic("ParseArrowShape received bogus offset"); } if (Tcl_SplitList(interp, (char *) value, &argc, &argv) != TCL_OK) { goto syntaxError; } else if (argc != 3) { goto syntaxError; } if ((Tk_CanvasGetCoord(interp, linePtr->canvas, argv[0], &a) != TCL_OK) || (Tk_CanvasGetCoord(interp, linePtr->canvas, argv[1], &b) != TCL_OK) || (Tk_CanvasGetCoord(interp, linePtr->canvas, argv[2], &c) != TCL_OK)) { goto syntaxError; } linePtr->arrowShapeA = (float) a; linePtr->arrowShapeB = (float) b; linePtr->arrowShapeC = (float) c; ckfree(argv); return TCL_OK; syntaxError: Tcl_ResetResult(interp); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad arrow shape \"%s\": must be list with three numbers", value)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARROW_SHAPE", NULL); if (argv != NULL) { ckfree(argv); } return TCL_ERROR; } /* *-------------------------------------------------------------- * * PrintArrowShape -- * |
︙ | ︙ | |||
2010 2011 2012 2013 2014 2015 2016 | return TCL_OK; } if ((c == 'b') && (strncmp(value, "both", length) == 0)) { *arrowPtr = ARROWS_BOTH; return TCL_OK; } | | | > > | 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 | return TCL_OK; } if ((c == 'b') && (strncmp(value, "both", length) == 0)) { *arrowPtr = ARROWS_BOTH; return TCL_OK; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad arrow spec \"%s\": must be none, first, last, or both", value)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARROW", NULL); *arrowPtr = ARROWS_NONE; return TCL_ERROR; } /* *-------------------------------------------------------------- * |
︙ | ︙ | |||
2248 2249 2250 2251 2252 2253 2254 | Tk_Canvas canvas, /* Information about overall canvas. */ Tk_Item *itemPtr, /* Item for which Postscript is wanted. */ int prepass) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ { LineItem *linePtr = (LineItem *) itemPtr; | < | < > > | 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 | Tk_Canvas canvas, /* Information about overall canvas. */ Tk_Item *itemPtr, /* Item for which Postscript is wanted. */ int prepass) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ { LineItem *linePtr = (LineItem *) itemPtr; int style; double width; XColor *color; Pixmap stipple; Tk_State state = itemPtr->state; Tcl_Obj *psObj; Tcl_InterpState interpState; if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } width = linePtr->outline.width; color = linePtr->outline.color; |
︙ | ︙ | |||
2289 2290 2291 2292 2293 2294 2295 2296 | } } if (color == NULL || linePtr->numPoints < 1 || linePtr->coordPtr == NULL){ return TCL_OK; } if (linePtr->numPoints == 1) { | > > > > > > > > > > > > | | | > > < > > > > | < > > | < > > > | 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 | } } if (color == NULL || linePtr->numPoints < 1 || linePtr->coordPtr == NULL){ return TCL_OK; } /* * Make our working space. */ psObj = Tcl_NewObj(); interpState = Tcl_SaveInterpState(interp, TCL_OK); /* * Check if we're just doing a "pixel". */ if (linePtr->numPoints == 1) { Tcl_AppendToObj(psObj, "matrix currentmatrix\n", -1); Tcl_AppendPrintfToObj(psObj, "%.15g %.15g translate %.15g %.15g", linePtr->coordPtr[0], Tk_CanvasPsY(canvas, linePtr->coordPtr[1]), width/2.0, width/2.0); Tcl_AppendToObj(psObj, " scale 1 0 moveto 0 0 1 0 360 arc\nsetmatrix\n", -1); Tcl_ResetResult(interp); if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (stipple != None) { Tcl_AppendToObj(psObj, "clip ", -1); Tcl_ResetResult(interp); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); } else { Tcl_AppendToObj(psObj, "fill\n", -1); } goto done; } /* * Generate a path for the line's center-line (do this differently for * straight lines and smoothed lines). */ Tcl_ResetResult(interp); if ((!linePtr->smooth) || (linePtr->numPoints < 3)) { Tk_CanvasPsPath(interp, canvas, linePtr->coordPtr, linePtr->numPoints); } else if ((stipple == None) && linePtr->smooth->postscriptProc) { linePtr->smooth->postscriptProc(interp, canvas, linePtr->coordPtr, linePtr->numPoints, linePtr->splineSteps); } else { /* |
︙ | ︙ | |||
2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 | numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr, linePtr->numPoints, linePtr->splineSteps, NULL, pointPtr); Tk_CanvasPsPath(interp, canvas, pointPtr, numPoints); if (pointPtr != staticPoints) { ckfree(pointPtr); } } /* * Set other line-drawing parameters and stroke out the line. */ | > < | | > > | < | | > > | > < > > | | | | | > > > | > > > | > > > > > | > > > | | | > | > > > > > | > > | | 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 | numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr, linePtr->numPoints, linePtr->splineSteps, NULL, pointPtr); Tk_CanvasPsPath(interp, canvas, pointPtr, numPoints); if (pointPtr != staticPoints) { ckfree(pointPtr); } } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); /* * Set other line-drawing parameters and stroke out the line. */ if (linePtr->capStyle == CapRound) { style = 1; } else if (linePtr->capStyle == CapProjecting) { style = 2; } else { style = 0; } Tcl_AppendPrintfToObj(psObj, "%d setlinecap\n", style); if (linePtr->joinStyle == JoinRound) { style = 1; } else if (linePtr->joinStyle == JoinBevel) { style = 2; } else { style = 0; } Tcl_AppendPrintfToObj(psObj, "%d setlinejoin\n", style); Tcl_ResetResult(interp); if (Tk_CanvasPsOutline(canvas, itemPtr, &linePtr->outline) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); /* * Output polygons for the arrowheads, if there are any. */ if (linePtr->firstArrowPtr != NULL) { if (stipple != None) { Tcl_AppendToObj(psObj, "grestore gsave\n", -1); } if (ArrowheadPostscript(interp, canvas, linePtr, linePtr->firstArrowPtr, psObj) != TCL_OK) { goto error; } } if (linePtr->lastArrowPtr != NULL) { if (stipple != None) { Tcl_AppendToObj(psObj, "grestore gsave\n", -1); } if (ArrowheadPostscript(interp, canvas, linePtr, linePtr->lastArrowPtr, psObj) != TCL_OK) { goto error; } } /* * Plug the accumulated postscript back into the result. */ done: (void) Tcl_RestoreInterpState(interp, interpState); Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj); Tcl_DecrRefCount(psObj); return TCL_OK; error: Tcl_DiscardInterpState(interpState); Tcl_DecrRefCount(psObj); return TCL_ERROR; } /* *-------------------------------------------------------------- * * ArrowheadPostscript -- * * This function is called to generate Postscript for an arrowhead for a * line item. * * Results: * The return value is a standard Tcl result. If an error occurs in * generating Postscript then an error message is left in the interp's * result, replacing whatever used to be there. If no error occurs, then * Postscript for the arrowhead is appended to the given object. * * Side effects: * None. * *-------------------------------------------------------------- */ static int ArrowheadPostscript( Tcl_Interp *interp, /* Leave error message here; non-error results * will be discarded by caller. */ Tk_Canvas canvas, /* Information about overall canvas. */ LineItem *linePtr, /* Line item for which Postscript is being * generated. */ double *arrowPtr, /* Pointer to first of five points describing * arrowhead polygon. */ Tcl_Obj *psObj) /* Append postscript to this object. */ { Pixmap stipple; Tk_State state = linePtr->header.state; if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } stipple = linePtr->outline.stipple; if (Canvas(canvas)->currentItemPtr == (Tk_Item *) linePtr) { if (linePtr->outline.activeStipple!=None) { stipple = linePtr->outline.activeStipple; } } else if (state == TK_STATE_DISABLED) { if (linePtr->outline.activeStipple!=None) { stipple = linePtr->outline.disabledStipple; } } Tcl_ResetResult(interp); Tk_CanvasPsPath(interp, canvas, arrowPtr, PTS_IN_ARROW); Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (stipple != None) { Tcl_AppendToObj(psObj, "clip ", -1); Tcl_ResetResult(interp); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) { return TCL_ERROR; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); } else { Tcl_AppendToObj(psObj, "fill\n", -1); } return TCL_OK; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkCanvPoly.c.
︙ | ︙ | |||
355 356 357 358 359 360 361 362 363 364 365 366 367 368 | return TCL_ERROR; } } if (objc & 1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # coordinates: expected an even number, got %d", objc)); return TCL_ERROR; } numPoints = objc/2; if (polyPtr->pointsAllocated <= numPoints) { if (polyPtr->coordPtr != NULL) { ckfree(polyPtr->coordPtr); | > | 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | return TCL_ERROR; } } if (objc & 1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # coordinates: expected an even number, got %d", objc)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "POLYGON", NULL); return TCL_ERROR; } numPoints = objc/2; if (polyPtr->pointsAllocated <= numPoints) { if (polyPtr->coordPtr != NULL) { ckfree(polyPtr->coordPtr); |
︙ | ︙ | |||
1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 | /* * Some of the paths here leave messages in interp->result, so we have to * clear it out before storing our own message. */ badIndex: Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string)); return TCL_ERROR; } /* *-------------------------------------------------------------- * * TranslatePolygon -- | > | 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 | /* * Some of the paths here leave messages in interp->result, so we have to * clear it out before storing our own message. */ badIndex: Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "POLY", NULL); return TCL_ERROR; } /* *-------------------------------------------------------------- * * TranslatePolygon -- |
︙ | ︙ | |||
1795 1796 1797 1798 1799 1800 1801 | Tk_Canvas canvas, /* Information about overall canvas. */ Tk_Item *itemPtr, /* Item for which Postscript is wanted. */ int prepass) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ { PolygonItem *polyPtr = (PolygonItem *) itemPtr; | | > > | 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 | Tk_Canvas canvas, /* Information about overall canvas. */ Tk_Item *itemPtr, /* Item for which Postscript is wanted. */ int prepass) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ { PolygonItem *polyPtr = (PolygonItem *) itemPtr; int style; XColor *color; XColor *fillColor; Pixmap stipple; Pixmap fillStipple; Tk_State state = itemPtr->state; double width; Tcl_Obj *psObj; Tcl_InterpState interpState; if (polyPtr->numPoints < 2 || polyPtr->coordPtr == NULL) { return TCL_OK; } if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; |
︙ | ︙ | |||
1848 1849 1850 1851 1852 1853 1854 1855 1856 | if (polyPtr->disabledFillColor != NULL) { fillColor = polyPtr->disabledFillColor; } if (polyPtr->disabledFillStipple != None) { fillStipple = polyPtr->disabledFillStipple; } } if (polyPtr->numPoints == 2) { if (color == NULL) { | > > > > > > > > < > | | > < > > > > | > < > > | < > > | > > > | > < > > > | | > > | | | > | > > > > > | > > > | > > > > > | > > > | | 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 | if (polyPtr->disabledFillColor != NULL) { fillColor = polyPtr->disabledFillColor; } if (polyPtr->disabledFillStipple != None) { fillStipple = polyPtr->disabledFillStipple; } } /* * Make our working space. */ psObj = Tcl_NewObj(); interpState = Tcl_SaveInterpState(interp, TCL_OK); if (polyPtr->numPoints == 2) { if (color == NULL) { goto done; } /* * Create a point by using a small circle. (Printer pixels are too * tiny to be used directly...) */ Tcl_AppendPrintfToObj(psObj, "matrix currentmatrix\n" /* save state */ "%.15g %.15g translate " /* go to drawing location */ "%.15g %.15g scale " /* scale the drawing */ "1 0 moveto " /* correct for origin */ "0 0 1 0 360 arc\n" /* make the circle */ "setmatrix\n", /* restore state */ polyPtr->coordPtr[0], Tk_CanvasPsY(canvas, polyPtr->coordPtr[1]), width/2.0, width/2.0); /* * Color it in. */ Tcl_ResetResult(interp); if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (stipple != None) { Tcl_AppendToObj(psObj, "clip ", -1); Tcl_ResetResult(interp); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); } else { Tcl_AppendToObj(psObj, "fill\n", -1); } goto done; } /* * Fill the area of the polygon. */ if (fillColor != NULL && polyPtr->numPoints > 3) { Tcl_ResetResult(interp); if (!polyPtr->smooth || !polyPtr->smooth->postscriptProc) { Tk_CanvasPsPath(interp, canvas, polyPtr->coordPtr, polyPtr->numPoints); } else { polyPtr->smooth->postscriptProc(interp, canvas, polyPtr->coordPtr, polyPtr->numPoints, polyPtr->splineSteps); } if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (fillStipple != None) { Tcl_AppendToObj(psObj, "eoclip ", -1); Tcl_ResetResult(interp); if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (color != NULL) { Tcl_AppendToObj(psObj, "grestore gsave\n", -1); } } else { Tcl_AppendToObj(psObj, "eofill\n", -1); } } /* * Now draw the outline, if there is one. */ if (color != NULL) { Tcl_ResetResult(interp); if (!polyPtr->smooth || !polyPtr->smooth->postscriptProc) { Tk_CanvasPsPath(interp, canvas, polyPtr->coordPtr, polyPtr->numPoints); } else { polyPtr->smooth->postscriptProc(interp, canvas, polyPtr->coordPtr, polyPtr->numPoints, polyPtr->splineSteps); } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (polyPtr->joinStyle == JoinRound) { style = 1; } else if (polyPtr->joinStyle == JoinBevel) { style = 2; } else { style = 0; } Tcl_AppendPrintfToObj(psObj, "%d setlinejoin 1 setlinecap\n", style); Tcl_ResetResult(interp); if (Tk_CanvasPsOutline(canvas, itemPtr, &polyPtr->outline) != TCL_OK){ goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); } /* * Plug the accumulated postscript back into the result. */ done: (void) Tcl_RestoreInterpState(interp, interpState); Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj); Tcl_DecrRefCount(psObj); return TCL_OK; error: Tcl_DiscardInterpState(interpState); Tcl_DecrRefCount(psObj); return TCL_ERROR; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkCanvPs.c.
︙ | ︙ | |||
130 131 132 133 134 135 136 137 138 139 140 141 142 143 | /* * Forward declarations for functions defined later in this file: */ static int GetPostscriptPoints(Tcl_Interp *interp, char *string, double *doublePtr); /* *-------------------------------------------------------------- * * TkCanvPostscriptCmd -- * * This function is invoked to process the "postscript" options of the | > > > > | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | /* * Forward declarations for functions defined later in this file: */ static int GetPostscriptPoints(Tcl_Interp *interp, char *string, double *doublePtr); static void PostscriptBitmap(Tk_Window tkwin, Pixmap bitmap, int startX, int startY, int width, int height, Tcl_Obj *psObj); static inline Tcl_Obj * GetPostscriptBuffer(Tcl_Interp *interp); /* *-------------------------------------------------------------- * * TkCanvPostscriptCmd -- * * This function is invoked to process the "postscript" options of the |
︙ | ︙ | |||
162 163 164 165 166 167 168 169 170 | const char **argv) /* Argument strings. Caller has already parsed * this command enough to know that argv[1] is * "postscript". */ { TkPostscriptInfo psInfo, *psInfoPtr = &psInfo; Tk_PostscriptInfo oldInfoPtr; int result; Tk_Item *itemPtr; #define STRING_LENGTH 400 | > < > | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | const char **argv) /* Argument strings. Caller has already parsed * this command enough to know that argv[1] is * "postscript". */ { TkPostscriptInfo psInfo, *psInfoPtr = &psInfo; Tk_PostscriptInfo oldInfoPtr; int result; int written; Tk_Item *itemPtr; #define STRING_LENGTH 400 const char *p; time_t now; size_t length; Tk_Window tkwin = canvasPtr->tkwin; Tcl_HashSearch search; Tcl_HashEntry *hPtr; Tcl_DString buffer; Tcl_Obj *preambleObj; Tcl_Obj *psObj; int deltaX = 0, deltaY = 0; /* Offset of lower-left corner of area to be * marked up, measured in canvas units from * the positioning point on the page (reflects * anchor position). Initial values needed * only to stop compiler warnings. */ /* |
︙ | ︙ | |||
196 197 198 199 200 201 202 203 204 205 206 207 208 209 | preambleObj = Tcl_GetVar2Ex(interp, "::tk::ps_preamble", NULL, TCL_LEAVE_ERR_MSG); if (preambleObj == NULL) { return TCL_ERROR; } Tcl_IncrRefCount(preambleObj); Tcl_ResetResult(interp); /* * Initialize the data structure describing Postscript generation, then * process all the arguments to fill the data structure in. */ oldInfoPtr = canvasPtr->psInfo; | > | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | preambleObj = Tcl_GetVar2Ex(interp, "::tk::ps_preamble", NULL, TCL_LEAVE_ERR_MSG); if (preambleObj == NULL) { return TCL_ERROR; } Tcl_IncrRefCount(preambleObj); Tcl_ResetResult(interp); psObj = Tcl_NewObj(); /* * Initialize the data structure describing Postscript generation, then * process all the arguments to fill the data structure in. */ oldInfoPtr = canvasPtr->psInfo; |
︙ | ︙ | |||
317 318 319 320 321 322 323 | if (strncmp(psInfo.colorMode, "monochrome", length) == 0) { psInfo.colorLevel = 0; } else if (strncmp(psInfo.colorMode, "gray", length) == 0) { psInfo.colorLevel = 1; } else if (strncmp(psInfo.colorMode, "color", length) == 0) { psInfo.colorLevel = 2; } else { | | | > > > | | > > | | | 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 | if (strncmp(psInfo.colorMode, "monochrome", length) == 0) { psInfo.colorLevel = 0; } else if (strncmp(psInfo.colorMode, "gray", length) == 0) { psInfo.colorLevel = 1; } else if (strncmp(psInfo.colorMode, "color", length) == 0) { psInfo.colorLevel = 2; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad color mode \"%s\": must be monochrome, gray, or color", psInfo.colorMode)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "COLORMODE", NULL); result = TCL_ERROR; goto cleanup; } } if (psInfo.fileName != NULL) { /* * Check that -file and -channel are not both specified. */ if (psInfo.channelName != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't specify both -file and -channel", -1)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "USAGE", NULL); result = TCL_ERROR; goto cleanup; } /* * Check that we are not in a safe interpreter. If we are, disallow * the -file specification. */ if (Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't specify -file in a safe interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "PS_FILE", NULL); result = TCL_ERROR; goto cleanup; } p = Tcl_TranslateFileName(interp, psInfo.fileName, &buffer); if (p == NULL) { goto cleanup; |
︙ | ︙ | |||
371 372 373 374 375 376 377 | */ psInfo.chan = Tcl_GetChannel(interp, psInfo.channelName, &mode); if (psInfo.chan == (Tcl_Channel) NULL) { result = TCL_ERROR; goto cleanup; } | | | | > > | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | */ psInfo.chan = Tcl_GetChannel(interp, psInfo.channelName, &mode); if (psInfo.chan == (Tcl_Channel) NULL) { result = TCL_ERROR; goto cleanup; } if (!(mode & TCL_WRITABLE)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "channel \"%s\" wasn't opened for writing", psInfo.channelName)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "UNWRITABLE",NULL); result = TCL_ERROR; goto cleanup; } } /* * Make a pre-pass over all of the items, generating Postscript and then |
︙ | ︙ | |||
418 419 420 421 422 423 424 | psInfo.prepass = 0; /* * Generate the header and prolog for the Postscript. */ if (psInfo.prolog) { | > | | > | | > | < | | > | > | | | | | | | | | | | | | > > > > | > > > > > > | < > | | | | > | < | > | | | | < | > > | > | | | < | > | > < | | | < > > > | > | > > > > | > | | > > | | | > > > > > | > > > | 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 | psInfo.prepass = 0; /* * Generate the header and prolog for the Postscript. */ if (psInfo.prolog) { Tcl_AppendToObj(psObj, "%!PS-Adobe-3.0 EPSF-3.0\n" "%%Creator: Tk Canvas Widget\n", -1); #ifdef HAVE_PW_GECOS if (!Tcl_IsSafe(interp)) { struct passwd *pwPtr = getpwuid(getuid()); /* INTL: Native. */ Tcl_AppendPrintfToObj(psObj, "%%%%For: %s\n", (pwPtr ? pwPtr->pw_gecos : "Unknown")); endpwent(); } #endif /* HAVE_PW_GECOS */ Tcl_AppendPrintfToObj(psObj, "%%%%Title: Window %s\n", Tk_PathName(tkwin)); time(&now); Tcl_AppendPrintfToObj(psObj, "%%%%CreationDate: %s", ctime(&now)); /* INTL: Native. */ if (!psInfo.rotate) { Tcl_AppendPrintfToObj(psObj, "%%%%BoundingBox: %d %d %d %d\n", (int) (psInfo.pageX + psInfo.scale*deltaX), (int) (psInfo.pageY + psInfo.scale*deltaY), (int) (psInfo.pageX + psInfo.scale*(deltaX + psInfo.width) + 1.0), (int) (psInfo.pageY + psInfo.scale*(deltaY + psInfo.height) + 1.0)); } else { Tcl_AppendPrintfToObj(psObj, "%%%%BoundingBox: %d %d %d %d\n", (int) (psInfo.pageX - psInfo.scale*(deltaY+psInfo.height)), (int) (psInfo.pageY + psInfo.scale*deltaX), (int) (psInfo.pageX - psInfo.scale*deltaY + 1.0), (int) (psInfo.pageY + psInfo.scale*(deltaX + psInfo.width) + 1.0)); } Tcl_AppendPrintfToObj(psObj, "%%%%Pages: 1\n" "%%%%DocumentData: Clean7Bit\n" "%%%%Orientation: %s\n", psInfo.rotate ? "Landscape" : "Portrait"); p = "%%%%DocumentNeededResources: font %s\n"; for (hPtr = Tcl_FirstHashEntry(&psInfo.fontTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { Tcl_AppendPrintfToObj(psObj, p, Tcl_GetHashKey(&psInfo.fontTable, hPtr)); p = "%%%%+ font %s\n"; } Tcl_AppendToObj(psObj, "%%EndComments\n\n", -1); /* * Insert the prolog */ Tcl_AppendObjToObj(psObj, preambleObj); if (psInfo.chan != NULL) { written = Tcl_WriteObj(psInfo.chan, psObj); if (written == -1) { channelWriteFailed: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "problem writing postscript data to channel: %s", Tcl_PosixError(interp))); result = TCL_ERROR; goto cleanup; } Tcl_DecrRefCount(psObj); psObj = Tcl_NewObj(); } /* * Document setup: set the color level and include fonts. */ Tcl_AppendPrintfToObj(psObj, "%%%%BeginSetup\n/CL %d def\n", psInfo.colorLevel); for (hPtr = Tcl_FirstHashEntry(&psInfo.fontTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { Tcl_AppendPrintfToObj(psObj, "%%%%IncludeResource: font %s\n", (char *) Tcl_GetHashKey(&psInfo.fontTable, hPtr)); } Tcl_AppendToObj(psObj, "%%EndSetup\n\n", -1); /* * Page setup: move to page positioning point, rotate if needed, set * scale factor, offset for proper anchor position, and set clip * region. */ Tcl_AppendToObj(psObj, "%%Page: 1 1\nsave\n", -1); Tcl_AppendPrintfToObj(psObj, "%.1f %.1f translate\n", psInfo.pageX, psInfo.pageY); if (psInfo.rotate) { Tcl_AppendToObj(psObj, "90 rotate\n", -1); } Tcl_AppendPrintfToObj(psObj, "%.4g %.4g scale\n", psInfo.scale, psInfo.scale); Tcl_AppendPrintfToObj(psObj, "%d %d translate\n", deltaX - psInfo.x, deltaY); Tcl_AppendPrintfToObj(psObj, "%d %.15g moveto %d %.15g lineto %d %.15g lineto %d %.15g " "lineto closepath clip newpath\n", psInfo.x, Tk_PostscriptY((double)psInfo.y, (Tk_PostscriptInfo)psInfoPtr), psInfo.x2, Tk_PostscriptY((double)psInfo.y, (Tk_PostscriptInfo)psInfoPtr), psInfo.x2, Tk_PostscriptY((double)psInfo.y2, (Tk_PostscriptInfo)psInfoPtr), psInfo.x, Tk_PostscriptY((double)psInfo.y2, (Tk_PostscriptInfo)psInfoPtr)); if (psInfo.chan != NULL) { written = Tcl_WriteObj(psInfo.chan, psObj); if (written == -1) { goto channelWriteFailed; } Tcl_DecrRefCount(psObj); psObj = Tcl_NewObj(); } } /* * Iterate through all the items, having each relevant one draw itself. * Quit if any of the items returns an error. */ result = TCL_OK; for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL; itemPtr = itemPtr->nextPtr) { if ((itemPtr->x1 >= psInfo.x2) || (itemPtr->x2 < psInfo.x) || (itemPtr->y1 >= psInfo.y2) || (itemPtr->y2 < psInfo.y)) { continue; } if (itemPtr->typePtr->postscriptProc == NULL) { continue; } if (itemPtr->state == TK_STATE_HIDDEN) { continue; } Tcl_ResetResult(interp); result = itemPtr->typePtr->postscriptProc(interp, (Tk_Canvas) canvasPtr, itemPtr, 0); if (result != TCL_OK) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( "\n (generating Postscript for item %d)", itemPtr->id)); goto cleanup; } Tcl_AppendToObj(psObj, "gsave\n", -1); Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); Tcl_AppendToObj(psObj, "grestore\n", -1); if (psInfo.chan != NULL) { written = Tcl_WriteObj(psInfo.chan, psObj); if (written == -1) { goto channelWriteFailed; } Tcl_DecrRefCount(psObj); psObj = Tcl_NewObj(); } } /* * Output page-end information, such as commands to print the page and * document trailer stuff. */ if (psInfo.prolog) { Tcl_AppendToObj(psObj, "restore showpage\n\n" "%%Trailer\n" "end\n" "%%EOF\n", -1); if (psInfo.chan != NULL) { Tcl_WriteObj(psInfo.chan, psObj); if (written == -1) { goto channelWriteFailed; } } } if (psInfo.chan == NULL) { Tcl_SetObjResult(interp, psObj); psObj = Tcl_NewObj(); } /* * Clean up psInfo to release malloc'ed stuff. */ cleanup: |
︙ | ︙ | |||
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 | } if (psInfo.channelName != NULL) { ckfree(psInfo.channelName); } Tcl_DeleteHashTable(&psInfo.fontTable); canvasPtr->psInfo = (Tk_PostscriptInfo) oldInfoPtr; Tcl_DecrRefCount(preambleObj); return result; } /* *-------------------------------------------------------------- * * Tk_PostscriptColor -- * * This function is called by individual canvas items when they want to | > > > > > > > > > > > > > > | 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 | } if (psInfo.channelName != NULL) { ckfree(psInfo.channelName); } Tcl_DeleteHashTable(&psInfo.fontTable); canvasPtr->psInfo = (Tk_PostscriptInfo) oldInfoPtr; Tcl_DecrRefCount(preambleObj); Tcl_DecrRefCount(psObj); return result; } static inline Tcl_Obj * GetPostscriptBuffer( Tcl_Interp *interp) { Tcl_Obj *psObj = Tcl_GetObjResult(interp); if (Tcl_IsShared(psObj)) { psObj = Tcl_DuplicateObj(psObj); Tcl_SetObjResult(interp, psObj); } return psObj; } /* *-------------------------------------------------------------- * * Tk_PostscriptColor -- * * This function is called by individual canvas items when they want to |
︙ | ︙ | |||
641 642 643 644 645 646 647 | int Tk_PostscriptColor( Tcl_Interp *interp, Tk_PostscriptInfo psInfo, /* Postscript info. */ XColor *colorPtr) /* Information about color. */ { TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo; | < < < < | > > | < | < | < | > | < | 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 | int Tk_PostscriptColor( Tcl_Interp *interp, Tk_PostscriptInfo psInfo, /* Postscript info. */ XColor *colorPtr) /* Information about color. */ { TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo; double red, green, blue; if (psInfoPtr->prepass) { return TCL_OK; } /* * If there is a color map defined, then look up the color's name in the * map and use the Postscript commands found there, if there are any. */ if (psInfoPtr->colorVar != NULL) { const char *cmdString = Tcl_GetVar2(interp, psInfoPtr->colorVar, Tk_NameOfColor(colorPtr), 0); if (cmdString != NULL) { Tcl_AppendPrintfToObj(GetPostscriptBuffer(interp), "%s\n", cmdString); return TCL_OK; } } /* * No color map entry for this color. Grab the color's intensities and * output Postscript commands for them. Special note: X uses a range of * 0-65535 for intensities, but most displays only use a range of 0-255, * which maps to (0, 256, 512, ... 65280) in the X scale. This means that * there's no way to get perfect white, since the highest intensity is * only 65280 out of 65535. To work around this problem, rescale the X * intensity to a 0-255 scale and use that as the basis for the Postscript * colors. This scheme still won't work if the display only uses 4 bits * per color, but most diplays use at least 8 bits. */ red = ((double) (((int) colorPtr->red) >> 8))/255.0; green = ((double) (((int) colorPtr->green) >> 8))/255.0; blue = ((double) (((int) colorPtr->blue) >> 8))/255.0; Tcl_AppendPrintfToObj(GetPostscriptBuffer(interp), "%.3f %.3f %.3f setrgbcolor AdjustColor\n", red, green, blue); return TCL_OK; } /* *-------------------------------------------------------------- * * Tk_PostscriptFont -- |
︙ | ︙ | |||
719 720 721 722 723 724 725 | Tk_PostscriptFont( Tcl_Interp *interp, Tk_PostscriptInfo psInfo, /* Postscript Info. */ Tk_Font tkfont) /* Information about font in which text is to * be printed. */ { TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo; | < > < < | > | | | > > < | | | < | < < < > > > | < < | < < < | 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 | Tk_PostscriptFont( Tcl_Interp *interp, Tk_PostscriptInfo psInfo, /* Postscript Info. */ Tk_Font tkfont) /* Information about font in which text is to * be printed. */ { TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo; Tcl_DString ds; int i, points; const char *fontname; /* * First, look up the font's name in the font map, if there is one. If * there is an entry for this font, it consists of a list containing font * name and size. Use this information. */ if (psInfoPtr->fontVar != NULL) { const char *name = Tk_NameOfFont(tkfont); Tcl_Obj **objv; int objc; double size; Tcl_Obj *list = Tcl_GetVar2Ex(interp, psInfoPtr->fontVar, name, 0); if (list != NULL) { if (Tcl_ListObjGetElements(interp, list, &objc, &objv) != TCL_OK || objc != 2 || (fontname = Tcl_GetString(objv[0]))[0] == '\0' || strchr(fontname, ' ') != NULL || Tcl_GetDoubleFromObj(interp, objv[1], &size) != TCL_OK || size <= 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad font map entry for \"%s\": \"%s\"", name, Tcl_GetString(list))); Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "FONTMAP", NULL); return TCL_ERROR; } Tcl_AppendPrintfToObj(GetPostscriptBuffer(interp), "/%s findfont %d scalefont%s setfont\n", fontname, (int) size, strncasecmp(fontname, "Symbol", 7) ? " ISOEncode" : ""); Tcl_CreateHashEntry(&psInfoPtr->fontTable, fontname, &i); return TCL_OK; } } /* * Nothing in the font map, so fall back to the old guessing technique. */ Tcl_DStringInit(&ds); points = Tk_PostscriptFontName(tkfont, &ds); fontname = Tcl_DStringValue(&ds); Tcl_AppendPrintfToObj(GetPostscriptBuffer(interp), "/%s findfont %d scalefont%s setfont\n", fontname, TkFontGetPoints(psInfoPtr->tkwin, points), strncasecmp(fontname, "Symbol", 7) ? " ISOEncode" : ""); Tcl_CreateHashEntry(&psInfoPtr->fontTable, Tcl_DStringValue(&ds), &i); Tcl_DStringFree(&ds); return TCL_OK; } /* |
︙ | ︙ | |||
814 815 816 817 818 819 820 | Tk_PostscriptInfo psInfo, /* Postscript info. */ Pixmap bitmap, /* Bitmap for which to generate Postscript. */ int startX, int startY, /* Coordinates of upper-left corner of * rectangular region to output. */ int width, int height) /* Height of rectangular region. */ { TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo; | < < < < < < < > > > > > > > > > > > > > > > > > > > > > | > | < | | < > | < | 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 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 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 | Tk_PostscriptInfo psInfo, /* Postscript info. */ Pixmap bitmap, /* Bitmap for which to generate Postscript. */ int startX, int startY, /* Coordinates of upper-left corner of * rectangular region to output. */ int width, int height) /* Height of rectangular region. */ { TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo; if (psInfoPtr->prepass) { return TCL_OK; } PostscriptBitmap(tkwin, bitmap, startX, startY, width, height, GetPostscriptBuffer(interp)); return TCL_OK; } static void PostscriptBitmap( Tk_Window tkwin, Pixmap bitmap, /* Bitmap for which to generate Postscript. */ int startX, int startY, /* Coordinates of upper-left corner of * rectangular region to output. */ int width, int height, /* Height of rectangular region. */ Tcl_Obj *psObj) /* Where to append the postscript. */ { XImage *imagePtr; int charsInLine, x, y, lastX, lastY, value, mask; unsigned int totalWidth, totalHeight; Window dummyRoot; int dummyX, dummyY; unsigned dummyBorderwidth, dummyDepth; /* * The following call should probably be a call to Tk_SizeOfBitmap * instead, but it seems that we are occasionally invoked by custom item * types that create their own bitmaps without registering them with Tk. * XGetGeometry is a bit slower than Tk_SizeOfBitmap, but it shouldn't * matter here. */ XGetGeometry(Tk_Display(tkwin), bitmap, &dummyRoot, (int *) &dummyX, (int *) &dummyY, (unsigned int *) &totalWidth, (unsigned int *) &totalHeight, &dummyBorderwidth, &dummyDepth); imagePtr = XGetImage(Tk_Display(tkwin), bitmap, 0, 0, totalWidth, totalHeight, 1, XYPixmap); Tcl_AppendToObj(psObj, "<", -1); mask = 0x80; value = 0; charsInLine = 0; lastX = startX + width - 1; lastY = startY + height - 1; for (y = lastY; y >= startY; y--) { for (x = startX; x <= lastX; x++) { if (XGetPixel(imagePtr, x, y)) { value |= mask; } mask >>= 1; if (mask == 0) { Tcl_AppendPrintfToObj(psObj, "%02x", value); mask = 0x80; value = 0; charsInLine += 2; if (charsInLine >= 60) { Tcl_AppendToObj(psObj, "\n", -1); charsInLine = 0; } } } if (mask != 0x80) { Tcl_AppendPrintfToObj(psObj, "%02x", value); mask = 0x80; value = 0; charsInLine += 2; } } Tcl_AppendToObj(psObj, ">", -1); XDestroyImage(imagePtr); } /* *-------------------------------------------------------------- * * Tk_PostscriptStipple -- * |
︙ | ︙ | |||
908 909 910 911 912 913 914 | Tk_Window tkwin, Tk_PostscriptInfo psInfo, /* Interpreter for returning Postscript or * error message. */ Pixmap bitmap) /* Bitmap to use for stippling. */ { TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo; int width, height; | < > < < < < < | > > > | | 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 | Tk_Window tkwin, Tk_PostscriptInfo psInfo, /* Interpreter for returning Postscript or * error message. */ Pixmap bitmap) /* Bitmap to use for stippling. */ { TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo; int width, height; Window dummyRoot; int dummyX, dummyY; unsigned dummyBorderwidth, dummyDepth; Tcl_Obj *psObj; if (psInfoPtr->prepass) { return TCL_OK; } /* * The following call should probably be a call to Tk_SizeOfBitmap * instead, but it seems that we are occasionally invoked by custom item * types that create their own bitmaps without registering them with Tk. * XGetGeometry is a bit slower than Tk_SizeOfBitmap, but it shouldn't * matter here. */ XGetGeometry(Tk_Display(tkwin), bitmap, &dummyRoot, (int *) &dummyX, (int *) &dummyY, (unsigned *) &width, (unsigned *) &height, &dummyBorderwidth, &dummyDepth); psObj = GetPostscriptBuffer(interp); Tcl_AppendPrintfToObj(psObj, "%d %d ", width, height); PostscriptBitmap(tkwin, bitmap, 0, 0, width, height, psObj); Tcl_AppendToObj(psObj, " StippleFill\n", -1); return TCL_OK; } /* *-------------------------------------------------------------- * * Tk_PostscriptY -- |
︙ | ︙ | |||
994 995 996 997 998 999 1000 | Tk_PostscriptInfo psInfo, /* Canvas on whose behalf Postscript is being * generated. */ double *coordPtr, /* Pointer to first in array of 2*numPoints * coordinates giving points for path. */ int numPoints) /* Number of points at *coordPtr. */ { TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo; | | > > | | < | | < | 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 | Tk_PostscriptInfo psInfo, /* Canvas on whose behalf Postscript is being * generated. */ double *coordPtr, /* Pointer to first in array of 2*numPoints * coordinates giving points for path. */ int numPoints) /* Number of points at *coordPtr. */ { TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo; Tcl_Obj *psObj; if (psInfoPtr->prepass) { return; } psObj = GetPostscriptBuffer(interp); Tcl_AppendPrintfToObj(psObj, "%.15g %.15g moveto\n", coordPtr[0], Tk_PostscriptY(coordPtr[1], psInfo)); for (numPoints--, coordPtr += 2; numPoints > 0; numPoints--, coordPtr += 2) { Tcl_AppendPrintfToObj(psObj, "%.15g %.15g lineto\n", coordPtr[0], Tk_PostscriptY(coordPtr[1], psInfo)); } } /* *-------------------------------------------------------------- * * GetPostscriptPoints -- |
︙ | ︙ | |||
1077 1078 1079 1080 1081 1082 1083 | if (*end != 0) { goto error; } *doublePtr = d; return TCL_OK; error: | | > | 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 | if (*end != 0) { goto error; } *doublePtr = d; return TCL_OK; error: Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad distance \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "POINTS", NULL); return TCL_ERROR; } /* *-------------------------------------------------------------- * * TkImageGetColor -- |
︙ | ︙ | |||
1191 1192 1193 1194 1195 1196 1197 | Tk_Window tkwin, Tk_PostscriptInfo psInfo, /* postscript info */ XImage *ximage, /* Image to draw */ int x, int y, /* First pixel to output */ int width, int height) /* Width and height of area */ { TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo; | < | > | 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 | Tk_Window tkwin, Tk_PostscriptInfo psInfo, /* postscript info */ XImage *ximage, /* Image to draw */ int x, int y, /* First pixel to output */ int width, int height) /* Width and height of area */ { TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo; int xx, yy, band, maxRows; double red, green, blue; int bytesPerLine = 0, maxWidth = 0; int level = psInfoPtr->colorLevel; Colormap cmap; int i, ncolors; Visual *visual; TkColormapData cdata; Tcl_Obj *psObj; if (psInfoPtr->prepass) { return TCL_OK; } cmap = Tk_Colormap(tkwin); visual = Tk_Visual(tkwin); |
︙ | ︙ | |||
1285 1286 1287 1288 1289 1290 1291 | case 0: bytesPerLine = (width + 7) / 8; maxWidth = 240000; break; case 1: bytesPerLine = width; maxWidth = 60000; break; default: bytesPerLine = 3 * width; maxWidth = 20000; break; } if (bytesPerLine > 60000) { Tcl_ResetResult(interp); | | | | | > | < | < | < | 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 | case 0: bytesPerLine = (width + 7) / 8; maxWidth = 240000; break; case 1: bytesPerLine = width; maxWidth = 60000; break; default: bytesPerLine = 3 * width; maxWidth = 20000; break; } if (bytesPerLine > 60000) { Tcl_ResetResult(interp); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't generate Postscript for images more than %d pixels wide", maxWidth)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", NULL); ckfree(cdata.colors); return TCL_ERROR; } maxRows = 60000 / bytesPerLine; psObj = GetPostscriptBuffer(interp); for (band = height-1; band >= 0; band -= maxRows) { int rows = (band >= maxRows) ? maxRows : band + 1; int lineLen = 0; switch (level) { case 0: Tcl_AppendPrintfToObj(psObj, "%d %d 1 matrix {\n<", width, rows); break; case 1: Tcl_AppendPrintfToObj(psObj, "%d %d 8 matrix {\n<", width, rows); break; default: Tcl_AppendPrintfToObj(psObj, "%d %d 8 matrix {\n<", width, rows); break; } for (yy = band; yy > band - rows; yy--) { switch (level) { case 0: { /* * Generate data for image in monochrome mode. No attempt at |
︙ | ︙ | |||
1332 1333 1334 1335 1336 1337 1338 | TkImageGetColor(&cdata, XGetPixel(ximage, xx, yy), &red, &green, &blue); if (0.30 * red + 0.59 * green + 0.11 * blue > 0.5) { data |= mask; } mask >>= 1; if (mask == 0) { | | < | | | | < | | > | < | | < | | | < | < | 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 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 1465 1466 1467 1468 1469 1470 1471 | TkImageGetColor(&cdata, XGetPixel(ximage, xx, yy), &red, &green, &blue); if (0.30 * red + 0.59 * green + 0.11 * blue > 0.5) { data |= mask; } mask >>= 1; if (mask == 0) { Tcl_AppendPrintfToObj(psObj, "%02X", data); lineLen += 2; if (lineLen > 60) { lineLen = 0; Tcl_AppendToObj(psObj, "\n", -1); } mask = 0x80; data = 0x00; } } if ((width % 8) != 0) { Tcl_AppendPrintfToObj(psObj, "%02X", data); mask = 0x80; data = 0x00; } break; } case 1: /* * Generate data in gray mode; in this case, take a weighted * sum of the red, green, and blue values. */ for (xx = x; xx < x+width; xx ++) { TkImageGetColor(&cdata, XGetPixel(ximage, xx, yy), &red, &green, &blue); Tcl_AppendPrintfToObj(psObj, "%02X", (int) floor(0.5 + 255.0 * (0.30 * red + 0.59 * green + 0.11 * blue))); lineLen += 2; if (lineLen > 60) { lineLen = 0; Tcl_AppendToObj(psObj, "\n", -1); } } break; default: /* * Finally, color mode. Here, just output the red, green, and * blue values directly. */ for (xx = x; xx < x+width; xx++) { TkImageGetColor(&cdata, XGetPixel(ximage, xx, yy), &red, &green, &blue); Tcl_AppendPrintfToObj(psObj, "%02X%02X%02X", (int) floor(0.5 + 255.0 * red), (int) floor(0.5 + 255.0 * green), (int) floor(0.5 + 255.0 * blue)); lineLen += 6; if (lineLen > 60) { lineLen = 0; Tcl_AppendToObj(psObj, "\n", -1); } } break; } } switch (level) { case 0: case 1: Tcl_AppendToObj(psObj, ">\n} image\n", -1); break; default: Tcl_AppendToObj(psObj, ">\n} false 3 colorimage\n", -1); break; } Tcl_AppendPrintfToObj(psObj, "0 %d translate\n", rows); } ckfree(cdata.colors); return TCL_OK; } /* *-------------------------------------------------------------- |
︙ | ︙ | |||
1437 1438 1439 1440 1441 1442 1443 | Tcl_Interp *interp, Tk_PhotoImageBlock *blockPtr, Tk_PostscriptInfo psInfo, int width, int height) { TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo; int colorLevel = psInfoPtr->colorLevel; | | < | > | 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 | Tcl_Interp *interp, Tk_PhotoImageBlock *blockPtr, Tk_PostscriptInfo psInfo, int width, int height) { TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo; int colorLevel = psInfoPtr->colorLevel; const char *displayOperation, *decode; unsigned char *pixelPtr; int bpc, xx, yy, lineLen, alpha; float red, green, blue; int bytesPerLine = 0, maxWidth = 0; unsigned char opaque = 255; unsigned char *alphaPtr; int alphaOffset, alphaPitch, alphaIncr; Tcl_Obj *psObj; if (psInfoPtr->prepass) { return TCL_OK; } if (colorLevel != 0) { /* |
︙ | ︙ | |||
1478 1479 1480 1481 1482 1483 1484 | switch (colorLevel) { case 0: bytesPerLine = (width + 7) / 8; maxWidth = 240000; break; case 1: bytesPerLine = width; maxWidth = 60000; break; default: bytesPerLine = 3 * width; maxWidth = 20000; break; } if (bytesPerLine > 60000) { Tcl_ResetResult(interp); | | | | | > | | | | | | | < | | < < | < | < > | | 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 | switch (colorLevel) { case 0: bytesPerLine = (width + 7) / 8; maxWidth = 240000; break; case 1: bytesPerLine = width; maxWidth = 60000; break; default: bytesPerLine = 3 * width; maxWidth = 20000; break; } if (bytesPerLine > 60000) { Tcl_ResetResult(interp); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't generate Postscript for images more than %d pixels wide", maxWidth)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", NULL); return TCL_ERROR; } /* * Set up the postscript code except for the image-data stream. */ psObj = GetPostscriptBuffer(interp); switch (colorLevel) { case 0: Tcl_AppendToObj(psObj, "/DeviceGray setcolorspace\n\n", -1); decode = "1 0"; bpc = 1; break; case 1: Tcl_AppendToObj(psObj, "/DeviceGray setcolorspace\n\n", -1); decode = "0 1"; bpc = 8; break; default: Tcl_AppendToObj(psObj, "/DeviceRGB setcolorspace\n\n", -1); decode = "0 1 0 1 0 1"; bpc = 8; break; } Tcl_AppendPrintfToObj(psObj, "<<\n /ImageType 1\n" " /Width %d\n /Height %d\n /BitsPerComponent %d\n" " /DataSource currentfile\n /ASCIIHexDecode filter\n" " /ImageMatrix [1 0 0 -1 0 %d]\n /Decode [%s]\n>>\n" "1 %s\n", width, height, bpc, height, decode, displayOperation); /* * Check the PhotoImageBlock information. We assume that: * if pixelSize is 1,2 or 4, the image is R,G,B,A; * if pixelSize is 3, the image is R,G,B and offset[3] is bogus. */ |
︙ | ︙ | |||
1577 1578 1579 1580 1581 1582 1583 | if ((alpha != 0) && (0.3086*red + 0.6094*green + 0.082*blue < 128)) { data |= mask; } mask >>= 1; if (mask == 0) { | | < | | < | 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 | if ((alpha != 0) && (0.3086*red + 0.6094*green + 0.082*blue < 128)) { data |= mask; } mask >>= 1; if (mask == 0) { Tcl_AppendPrintfToObj(psObj, "%02X", data); lineLen += 2; if (lineLen >= 60) { lineLen = 0; Tcl_AppendToObj(psObj, "\n", -1); } mask = 0x80; data = 0x00; } } if ((width % 8) != 0) { Tcl_AppendPrintfToObj(psObj, "%02X", data); mask = 0x80; data = 0x00; } mask = 0x80; data = 0x00; for (xx=0 ; xx<width ; xx++) { |
︙ | ︙ | |||
1618 1619 1620 1621 1622 1623 1624 | if ((alpha != 0) && (0.3086*red + 0.6094*green + 0.082*blue >= 128)) { data |= mask; } mask >>= 1; if (mask == 0) { | | < | | < | < | | < | | < | | < | > > > | > | 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 | if ((alpha != 0) && (0.3086*red + 0.6094*green + 0.082*blue >= 128)) { data |= mask; } mask >>= 1; if (mask == 0) { Tcl_AppendPrintfToObj(psObj, "%02X", data); lineLen += 2; if (lineLen >= 60) { lineLen = 0; Tcl_AppendToObj(psObj, "\n", -1); } mask = 0x80; data = 0x00; } } if ((width % 8) != 0) { Tcl_AppendPrintfToObj(psObj, "%02X", data); mask = 0x80; data = 0x00; } break; } case 1: { /* * Generate transparency data. We must prevent a transparent value * of 0 because of a bug in some HP printers. */ for (xx = 0; xx < width; xx ++) { alpha = *(alphaPtr + (yy * alphaPitch) + (xx * alphaIncr) + alphaOffset); Tcl_AppendPrintfToObj(psObj, "%02X", alpha | 0x01); lineLen += 2; if (lineLen >= 60) { lineLen = 0; Tcl_AppendToObj(psObj, "\n", -1); } } /* * Generate data in gray mode; in this case, take a weighted sum * of the red, green, and blue values. */ for (xx = 0; xx < width; xx ++) { pixelPtr = blockPtr->pixelPtr + (yy * blockPtr->pitch) + (xx *blockPtr->pixelSize); red = pixelPtr[blockPtr->offset[0]]; green = pixelPtr[blockPtr->offset[1]]; blue = pixelPtr[blockPtr->offset[2]]; Tcl_AppendPrintfToObj(psObj, "%02X", (int) floor(0.5 + ( 0.3086 * red + 0.6094 * green + 0.0820 * blue))); lineLen += 2; if (lineLen >= 60) { lineLen = 0; Tcl_AppendToObj(psObj, "\n", -1); } } break; } default: /* * Generate transparency data. We must prevent a transparent value * of 0 because of a bug in some HP printers. */ for (xx = 0; xx < width; xx ++) { alpha = *(alphaPtr + (yy * alphaPitch) + (xx * alphaIncr) + alphaOffset); Tcl_AppendPrintfToObj(psObj, "%02X", alpha | 0x01); lineLen += 2; if (lineLen >= 60) { lineLen = 0; Tcl_AppendToObj(psObj, "\n", -1); } } /* * Finally, color mode. Here, just output the red, green, and blue * values directly. */ for (xx = 0; xx < width; xx ++) { pixelPtr = blockPtr->pixelPtr + (yy * blockPtr->pitch) + (xx * blockPtr->pixelSize); Tcl_AppendPrintfToObj(psObj, "%02X%02X%02X", pixelPtr[blockPtr->offset[0]], pixelPtr[blockPtr->offset[1]], pixelPtr[blockPtr->offset[2]]); lineLen += 6; if (lineLen >= 60) { lineLen = 0; Tcl_AppendToObj(psObj, "\n", -1); } } break; } } /* * The end-of-data marker. */ Tcl_AppendToObj(psObj, ">\n", -1); return TCL_OK; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkCanvText.c.
︙ | ︙ | |||
334 335 336 337 338 339 340 | Tcl_Obj *obj = Tcl_NewObj(); Tcl_Obj *subobj = Tcl_NewDoubleObj(textPtr->x); Tcl_ListObjAppendElement(interp, obj, subobj); subobj = Tcl_NewDoubleObj(textPtr->y); Tcl_ListObjAppendElement(interp, obj, subobj); Tcl_SetObjResult(interp, obj); | > | > > > > > > | | | | | | | > | | | | | | | | | | < < < < < | 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 | Tcl_Obj *obj = Tcl_NewObj(); Tcl_Obj *subobj = Tcl_NewDoubleObj(textPtr->x); Tcl_ListObjAppendElement(interp, obj, subobj); subobj = Tcl_NewDoubleObj(textPtr->y); Tcl_ListObjAppendElement(interp, obj, subobj); Tcl_SetObjResult(interp, obj); return TCL_OK; } else if (objc > 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # coordinates: expected 0 or 2, got %d", objc)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "TEXT", NULL); return TCL_ERROR; } if (objc == 1) { if (Tcl_ListObjGetElements(interp, objv[0], &objc, (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; } else if (objc != 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # coordinates: expected 2, got %d", objc)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "TEXT", NULL); return TCL_ERROR; } } if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0], &textPtr->x) != TCL_OK) || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1], &textPtr->y) != TCL_OK)) { return TCL_ERROR; } ComputeTextBbox(canvas, textPtr); return TCL_OK; } /* *-------------------------------------------------------------- * * ConfigureText -- |
︙ | ︙ | |||
1352 1353 1354 1355 1356 1357 1358 | *indexPtr = textPtr->numChars; } else if ((c == 'i') && (strncmp(string, "insert", (unsigned) length) == 0)) { *indexPtr = textPtr->insertPos; } else if ((c == 's') && (length >= 5) && (strncmp(string, "sel.first", (unsigned) length) == 0)) { if (textInfoPtr->selItemPtr != itemPtr) { | > | > > | > | 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 | *indexPtr = textPtr->numChars; } else if ((c == 'i') && (strncmp(string, "insert", (unsigned) length) == 0)) { *indexPtr = textPtr->insertPos; } else if ((c == 's') && (length >= 5) && (strncmp(string, "sel.first", (unsigned) length) == 0)) { if (textInfoPtr->selItemPtr != itemPtr) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "selection isn't in item", -1)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "UNSELECTED", NULL); return TCL_ERROR; } *indexPtr = textInfoPtr->selectFirst; } else if ((c == 's') && (length >= 5) && (strncmp(string, "sel.last", (unsigned) length) == 0)) { if (textInfoPtr->selItemPtr != itemPtr) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "selection isn't in item", -1)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "UNSELECTED", NULL); return TCL_ERROR; } *indexPtr = textInfoPtr->selectLast; } else if (c == '@') { int x, y; double tmp, c = textPtr->cosine, s = textPtr->sine; char *end; |
︙ | ︙ | |||
1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 | /* * Some of the paths here leave messages in the interp's result, so we * have to clear it out before storing our own message. */ badIndex: Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string)); return TCL_ERROR; } return TCL_OK; } /* *-------------------------------------------------------------- | > | 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 | /* * Some of the paths here leave messages in the interp's result, so we * have to clear it out before storing our own message. */ badIndex: Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "TEXT", NULL); return TCL_ERROR; } return TCL_OK; } /* *-------------------------------------------------------------- |
︙ | ︙ | |||
1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 | TextItem *textPtr = (TextItem *) itemPtr; double x, y; Tk_FontMetrics fm; const char *justify; XColor *color; Pixmap stipple; Tk_State state = itemPtr->state; if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } color = textPtr->color; stipple = textPtr->stipple; if (state == TK_STATE_HIDDEN || textPtr->color == NULL || | > > | 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 | TextItem *textPtr = (TextItem *) itemPtr; double x, y; Tk_FontMetrics fm; const char *justify; XColor *color; Pixmap stipple; Tk_State state = itemPtr->state; Tcl_Obj *psObj; Tcl_InterpState interpState; if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } color = textPtr->color; stipple = textPtr->stipple; if (state == TK_STATE_HIDDEN || textPtr->color == NULL || |
︙ | ︙ | |||
1557 1558 1559 1560 1561 1562 1563 1564 | color = textPtr->disabledColor; } if (textPtr->disabledStipple != None) { stipple = textPtr->disabledStipple; } } if (Tk_CanvasPsFont(interp, canvas, textPtr->tkfont) != TCL_OK) { | > > > > > > > > > > > > < > > > < > > > < > > > | < < | | < | < > > > > > > | > > > > > > > > > > > > > | 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 | color = textPtr->disabledColor; } if (textPtr->disabledStipple != None) { stipple = textPtr->disabledStipple; } } /* * Make our working space. */ psObj = Tcl_NewObj(); interpState = Tcl_SaveInterpState(interp, TCL_OK); /* * Generate postscript. */ Tcl_ResetResult(interp); if (Tk_CanvasPsFont(interp, canvas, textPtr->tkfont) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (prepass != 0) { goto done; } Tcl_ResetResult(interp); if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (stipple != None) { Tcl_ResetResult(interp); Tk_CanvasPsStipple(interp, canvas, stipple); Tcl_AppendPrintfToObj(psObj, "/StippleText {\n %s} bind def\n", Tcl_GetString(Tcl_GetObjResult(interp))); } x = 0; y = 0; justify = NULL; /* lint. */ switch (textPtr->anchor) { case TK_ANCHOR_NW: x = 0; y = 0; break; case TK_ANCHOR_N: x = 1; y = 0; break; case TK_ANCHOR_NE: x = 2; y = 0; break; case TK_ANCHOR_E: x = 2; y = 1; break; case TK_ANCHOR_SE: x = 2; y = 2; break; case TK_ANCHOR_S: x = 1; y = 2; break; case TK_ANCHOR_SW: x = 0; y = 2; break; case TK_ANCHOR_W: x = 0; y = 1; break; case TK_ANCHOR_CENTER: x = 1; y = 1; break; } switch (textPtr->justify) { case TK_JUSTIFY_LEFT: justify = "0"; break; case TK_JUSTIFY_CENTER: justify = "0.5"; break; case TK_JUSTIFY_RIGHT: justify = "1"; break; } Tk_GetFontMetrics(textPtr->tkfont, &fm); Tcl_AppendPrintfToObj(psObj, "%.15g %.15g %.15g [\n", textPtr->angle, textPtr->x, Tk_CanvasPsY(canvas, textPtr->y)); Tcl_ResetResult(interp); Tk_TextLayoutToPostscript(interp, textPtr->textLayout); Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); Tcl_AppendPrintfToObj(psObj, "] %d %g %g %s %s DrawText\n", fm.linespace, x / -2.0, y / 2.0, justify, ((stipple == None) ? "false" : "true")); /* * Plug the accumulated postscript back into the result. */ done: (void) Tcl_RestoreInterpState(interp, interpState); Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj); Tcl_DecrRefCount(psObj); return TCL_OK; error: Tcl_DiscardInterpState(interpState); Tcl_DecrRefCount(psObj); return TCL_ERROR; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkCanvUtil.c.
︙ | ︙ | |||
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | static void SmoothMethodCleanupProc(ClientData clientData, Tcl_Interp *interp); static SmoothAssocData *InitSmoothMethods(Tcl_Interp *interp); static int DashConvert(char *l, const char *p, int n, double width); static void TranslateAndAppendCoords(TkCanvas *canvPtr, double x, double y, XPoint *outArr, int numOut); #define ABS(a) ((a>=0)?(a):(-(a))) /* *---------------------------------------------------------------------- * * Tk_CanvasTkwin -- * * Given a token for a canvas, this function returns the widget that | > > > > > > > > > > > > > > | 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 | static void SmoothMethodCleanupProc(ClientData clientData, Tcl_Interp *interp); static SmoothAssocData *InitSmoothMethods(Tcl_Interp *interp); static int DashConvert(char *l, const char *p, int n, double width); static void TranslateAndAppendCoords(TkCanvas *canvPtr, double x, double y, XPoint *outArr, int numOut); static inline Tcl_Obj * GetPostscriptBuffer(Tcl_Interp *interp); #define ABS(a) ((a>=0)?(a):(-(a))) static inline Tcl_Obj * GetPostscriptBuffer( Tcl_Interp *interp) { Tcl_Obj *psObj = Tcl_GetObjResult(interp); if (Tcl_IsShared(psObj)) { psObj = Tcl_DuplicateObj(psObj); Tcl_SetObjResult(interp, psObj); } return psObj; } /* *---------------------------------------------------------------------- * * Tk_CanvasTkwin -- * * Given a token for a canvas, this function returns the widget that |
︙ | ︙ | |||
752 753 754 755 756 757 758 | /* * Search the list of installed smooth methods. */ while (methods != NULL) { if (strncmp(value, methods->smooth.name, length) == 0) { if (smooth != NULL) { | > | > | | 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 | /* * Search the list of installed smooth methods. */ while (methods != NULL) { if (strncmp(value, methods->smooth.name, length) == 0) { if (smooth != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "ambiguous smooth method \"%s\"", value)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "SMOOTH", value, NULL); return TCL_ERROR; } smooth = &methods->smooth; } methods = methods->nextPtr; } if (smooth) { |
︙ | ︙ | |||
874 875 876 877 878 879 880 | Tcl_ResetResult(interp); goto badDashList; } if ((unsigned) ABS(dash->number) > sizeof(char *)) { ckfree(dash->pattern.pt); } | | | < | | | > | | > > | 890 891 892 893 894 895 896 897 898 899 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 930 931 932 933 934 935 936 937 938 | Tcl_ResetResult(interp); goto badDashList; } if ((unsigned) ABS(dash->number) > sizeof(char *)) { ckfree(dash->pattern.pt); } if (argc > (int) sizeof(char *)) { dash->pattern.pt = pt = ckalloc(argc); } else { pt = dash->pattern.array; } dash->number = argc; largv = argv; while (argc > 0) { if (Tcl_GetInt(interp, *largv, &i) != TCL_OK || i < 1 || i>255) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "expected integer in the range 1..255 but got \"%s\"", *largv)); Tcl_SetErrorCode(interp, "TK", "VALUE", "DASH", NULL); goto syntaxError; } *pt++ = i; argc--; largv++; } if (argv != NULL) { ckfree(argv); } return TCL_OK; /* * Something went wrong. Generate error message, clean up and return. */ badDashList: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad dash list \"%s\": must be a list of integers or a format like \"-..\"", value)); Tcl_SetErrorCode(interp, "TK", "VALUE", "DASH", NULL); syntaxError: if (argv != NULL) { ckfree(argv); } if ((unsigned) ABS(dash->number) > sizeof(char *)) { ckfree(dash->pattern.pt); } |
︙ | ︙ | |||
1248 1249 1250 1251 1252 1253 1254 | /* *-------------------------------------------------------------- * * Tk_ResetOutlineGC * | | | | | 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 | /* *-------------------------------------------------------------- * * Tk_ResetOutlineGC * * Restores the GC to the situation before Tk_ChangeOutlineGC() was * called. This function should be called just after the dashed item is * drawn, because the GC is supposed to be read-only. * * Results: * 1 if there is a stipple pattern, and 0 otherwise. * * Side effects: * GC is updated. * |
︙ | ︙ | |||
1357 1358 1359 1360 1361 1362 1363 | int Tk_CanvasPsOutline( Tk_Canvas canvas, Tk_Item *item, Tk_Outline *outline) { | | | > | | < < < < < < < > | > > | | | < | | | | > > | < > > < | > | > | | | | < | < < | > > > | < < | < < < > > > > > | | | 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 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 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 | int Tk_CanvasPsOutline( Tk_Canvas canvas, Tk_Item *item, Tk_Outline *outline) { char pattern[11]; int i; char *ptr, *lptr = pattern; Tcl_Interp *interp = Canvas(canvas)->interp; double width = outline->width; Tk_Dash *dash = &outline->dash; XColor *color = outline->color; Pixmap stipple = outline->stipple; Tk_State state = item->state; Tcl_Obj *psObj = GetPostscriptBuffer(interp); if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } if (Canvas(canvas)->currentItemPtr == item) { if (outline->activeWidth > width) { width = outline->activeWidth; } if (outline->activeDash.number > 0) { dash = &outline->activeDash; } if (outline->activeColor != NULL) { color = outline->activeColor; } if (outline->activeStipple != None) { stipple = outline->activeStipple; } } else if (state == TK_STATE_DISABLED) { if (outline->disabledWidth > 0) { width = outline->disabledWidth; } if (outline->disabledDash.number > 0) { dash = &outline->disabledDash; } if (outline->disabledColor != NULL) { color = outline->disabledColor; } if (outline->disabledStipple != None) { stipple = outline->disabledStipple; } } Tcl_AppendPrintfToObj(psObj, "%.15g setlinewidth\n", width); ptr = ((unsigned) ABS(dash->number) > sizeof(char *)) ? dash->pattern.pt : dash->pattern.array; Tcl_AppendToObj(psObj, "[", -1); if (dash->number > 0) { Tcl_Obj *converted; char *p = ptr; converted = Tcl_ObjPrintf("%d", *p++ & 0xff); for (i = dash->number-1 ; i>=0 ; i--) { Tcl_AppendPrintfToObj(converted, " %d", *p++ & 0xff); } Tcl_AppendObjToObj(psObj, converted); if (dash->number & 1) { Tcl_AppendToObj(psObj, " ", -1); Tcl_AppendObjToObj(psObj, converted); } Tcl_DecrRefCount(converted); Tcl_AppendPrintfToObj(psObj, "] %d setdash\n", outline->offset); } else if (dash->number < 0) { if (dash->number < -5) { lptr = ckalloc(1 - 2*dash->number); } i = DashConvert(lptr, ptr, -dash->number, width); if (i > 0) { char *p = lptr; Tcl_AppendPrintfToObj(psObj, "%d", *p++ & 0xff); for (; --i>0 ;) { Tcl_AppendPrintfToObj(psObj, " %d", *p++ & 0xff); } Tcl_AppendPrintfToObj(psObj, "] %d setdash\n", outline->offset); } else { Tcl_AppendToObj(psObj, "] 0 setdash\n", -1); } if (lptr != pattern) { ckfree(lptr); } } else { Tcl_AppendToObj(psObj, "] 0 setdash\n", -1); } if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) { return TCL_ERROR; } /* * Note that psObj might hold an invalid reference now. */ if (stipple != None) { Tcl_AppendToObj(GetPostscriptBuffer(interp), "StrokeClip ", -1); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) { return TCL_ERROR; } } else { Tcl_AppendToObj(GetPostscriptBuffer(interp), "stroke\n", -1); } return TCL_OK; } /* *-------------------------------------------------------------- |
︙ | ︙ | |||
1727 1728 1729 1730 1731 1732 1733 | limit[2] = -lft; limit[3] = btm; /* * This is the loop that makes the four passes through the data. */ | | | | 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 | limit[2] = -lft; limit[3] = btm; /* * This is the loop that makes the four passes through the data. */ for (j=0; j<4; j++) { double xClip = limit[j]; int inside = a[0] < xClip; double priorY = a[1]; numOutput = 0; /* * Clip everything to the right of xClip. Store the results in b[] * rotated by 90 degrees clockwise. */ for (i=0; i<numVertex; i++) { double x = a[i*2]; double y = a[i*2 + 1]; if (x >= xClip) { /* * The current vertex is to the right of xClip. */ |
︙ | ︙ | |||
1829 1830 1831 1832 1833 1834 1835 | } /* * All clipping is now finished. Convert the coordinates from doubles into * XPoints and translate the origin for the drawable. */ | | | 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 | } /* * All clipping is now finished. Convert the coordinates from doubles into * XPoints and translate the origin for the drawable. */ for (i=0; i<numVertex; i++) { TranslateAndAppendCoords(canvPtr, a[i*2], a[i*2+1], outArr, i); } if (tempArr != staticSpace) { ckfree(tempArr); } return numOutput; } |
︙ | ︙ |
Changes to generic/tkCanvWind.c.
︙ | ︙ | |||
242 243 244 245 246 247 248 | * modified. */ int objc, /* Number of coordinates supplied in objv. */ Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */ { WindowItem *winItemPtr = (WindowItem *) itemPtr; if (objc == 0) { | | > | < | < | < | | | > < | | | | 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | * modified. */ int objc, /* Number of coordinates supplied in objv. */ Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */ { WindowItem *winItemPtr = (WindowItem *) itemPtr; if (objc == 0) { Tcl_Obj *objs[2]; objs[0] = Tcl_NewDoubleObj(winItemPtr->x); objs[1] = Tcl_NewDoubleObj(winItemPtr->y); Tcl_SetObjResult(interp, Tcl_NewListObj(2, objs)); } else if (objc < 3) { if (objc==1) { if (Tcl_ListObjGetElements(interp, objv[0], &objc, (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; } else if (objc != 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # coordinates: expected 2, got %d", objc)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "WINDOW", NULL); return TCL_ERROR; } } if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0], &winItemPtr->x) != TCL_OK) || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1], &winItemPtr->y) != TCL_OK)) { return TCL_ERROR; } ComputeWindowBbox(canvas, winItemPtr); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # coordinates: expected 0 or 2, got %d", objc)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "WINDOW", NULL); return TCL_ERROR; } return TCL_OK; } /* *-------------------------------------------------------------- |
︙ | ︙ | |||
338 339 340 341 342 343 344 | * Make sure that the canvas is either the parent of the window * associated with the item or a descendant of that parent. Also, * don't allow a top-of-hierarchy window to be managed inside a * canvas. */ parent = Tk_Parent(winItemPtr->tkwin); | | < | 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | * Make sure that the canvas is either the parent of the window * associated with the item or a descendant of that parent. Also, * don't allow a top-of-hierarchy window to be managed inside a * canvas. */ parent = Tk_Parent(winItemPtr->tkwin); for (ancestor = canvasTkwin ;; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (((Tk_FakeWin *) ancestor)->flags & TK_TOP_HIERARCHY) { goto badWindow; } } |
︙ | ︙ | |||
371 372 373 374 375 376 377 | } } ComputeWindowBbox(canvas, winItemPtr); return TCL_OK; badWindow: | | | > > | 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | } } ComputeWindowBbox(canvas, winItemPtr); return TCL_OK; badWindow: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't use %s in a window item of this canvas", Tk_PathName(winItemPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); winItemPtr->tkwin = NULL; return TCL_ERROR; } /* *-------------------------------------------------------------- * |
︙ | ︙ | |||
823 824 825 826 827 828 829 | CanvasPsWindow( Tcl_Interp *interp, /* Leave Postscript or error message here. */ Tk_Window tkwin, /* window to be printed */ Tk_Canvas canvas, /* Information about overall canvas. */ double x, double y, /* origin of window. */ int width, int height) /* width/height of window. */ { | < < > > > > > > > | > < < < | | > | < < | > | | > | < < | < | < < | 822 823 824 825 826 827 828 829 830 831 832 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 | CanvasPsWindow( Tcl_Interp *interp, /* Leave Postscript or error message here. */ Tk_Window tkwin, /* window to be printed */ Tk_Canvas canvas, /* Information about overall canvas. */ double x, double y, /* origin of window. */ int width, int height) /* width/height of window. */ { XImage *ximage; int result; #ifdef X_GetImage Tk_ErrorHandler handle; #endif Tcl_Obj *cmdObj, *psObj; Tcl_InterpState interpState = Tcl_SaveInterpState(interp, TCL_OK); /* * Locate the subwindow within the wider window. */ psObj = Tcl_ObjPrintf( "\n%%%% %s item (%s, %d x %d)\n" // Comment "%.15g %.15g translate\n", // Position Tk_Class(tkwin), Tk_PathName(tkwin), width, height, x, y); /* * First try if the widget has its own "postscript" command. If it exists, * this will produce much better postscript than when a pixmap is used. */ Tcl_ResetResult(interp); cmdObj = Tcl_ObjPrintf("%s postscript -prolog 0", Tk_PathName(tkwin)); Tcl_IncrRefCount(cmdObj); result = Tcl_EvalObjEx(interp, cmdObj, 0); Tcl_DecrRefCount(cmdObj); if (result == TCL_OK) { Tcl_AppendPrintfToObj(psObj, "50 dict begin\nsave\ngsave\n" "0 %d moveto %d 0 rlineto 0 -%d rlineto -%d 0 rlineto closepath\n" "1.000 1.000 1.000 setrgbcolor AdjustColor\nfill\ngrestore\n", height, width, height, width); Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); Tcl_AppendToObj(psObj, "\nrestore\nend\n\n\n", -1); goto done; } /* * If the window is off the screen it will generate a BadMatch/XError. We * catch any BadMatch errors here */ #ifdef X_GetImage |
︙ | ︙ | |||
886 887 888 889 890 891 892 | (unsigned) width, (unsigned) height, AllPlanes, ZPixmap); #ifdef X_GetImage Tk_DeleteErrorHandler(handle); #endif if (ximage == NULL) { | | | | | | | | > > > > > > > > > > > > > > | 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 | (unsigned) width, (unsigned) height, AllPlanes, ZPixmap); #ifdef X_GetImage Tk_DeleteErrorHandler(handle); #endif if (ximage == NULL) { result = TCL_OK; } else { Tcl_ResetResult(interp); result = TkPostscriptImage(interp, tkwin, Canvas(canvas)->psInfo, ximage, 0, 0, width, height); Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); XDestroyImage(ximage); } /* * Plug the accumulated postscript back into the result. */ done: if (result == TCL_OK) { (void) Tcl_RestoreInterpState(interp, interpState); Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj); } else { Tcl_DiscardInterpState(interpState); } Tcl_DecrRefCount(psObj); return result; } /* *-------------------------------------------------------------- * * ScaleWinItem -- |
︙ | ︙ |
Changes to generic/tkCanvas.c.
︙ | ︙ | |||
265 266 267 268 269 270 271 | Tcl_Obj *const *argv); static void CanvasWorldChanged(ClientData instanceData); static int ConfigureCanvas(Tcl_Interp *interp, TkCanvas *canvasPtr, int argc, Tcl_Obj *const *argv, int flags); static void DestroyCanvas(char *memPtr); static void DisplayCanvas(ClientData clientData); | | | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | Tcl_Obj *const *argv); static void CanvasWorldChanged(ClientData instanceData); static int ConfigureCanvas(Tcl_Interp *interp, TkCanvas *canvasPtr, int argc, Tcl_Obj *const *argv, int flags); static void DestroyCanvas(char *memPtr); static void DisplayCanvas(ClientData clientData); static void DoItem(Tcl_Obj *accumObj, Tk_Item *itemPtr, Tk_Uid tag); static void EventuallyRedrawItem(TkCanvas *canvasPtr, Tk_Item *itemPtr); #ifdef USE_OLD_TAG_SEARCH static int FindItems(Tcl_Interp *interp, TkCanvas *canvasPtr, int argc, Tcl_Obj *const *argv, Tcl_Obj *newTagObj, int first); |
︙ | ︙ | |||
329 330 331 332 333 334 335 | /* * Macros that significantly simplify all code that finds items. */ #ifdef USE_OLD_TAG_SEARCH #define FIRST_CANVAS_ITEM_MATCHING(objPtr,searchPtrPtr,errorExitClause) \ | | | | | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | /* * Macros that significantly simplify all code that finds items. */ #ifdef USE_OLD_TAG_SEARCH #define FIRST_CANVAS_ITEM_MATCHING(objPtr,searchPtrPtr,errorExitClause) \ itemPtr = StartTagSearch(canvasPtr,(objPtr),&search) #define FOR_EVERY_CANVAS_ITEM_MATCHING(objPtr,searchPtrPtr,errorExitClause) \ for (itemPtr = StartTagSearch(canvasPtr, (objPtr), &search); \ itemPtr != NULL; itemPtr = NextItem(&search)) #define FIND_ITEMS(objPtr, n) \ FindItems(interp, canvasPtr, objc, objv, (objPtr), (n)) #define RELINK_ITEMS(objPtr, itemPtr) \ RelinkItems(canvasPtr, (objPtr), (itemPtr)) #else /* USE_OLD_TAG_SEARCH */ #define FIRST_CANVAS_ITEM_MATCHING(objPtr,searchPtrPtr,errorExitClause) \ if ((result=TagSearchScan(canvasPtr,(objPtr),(searchPtrPtr))) != TCL_OK){ \ |
︙ | ︙ | |||
924 925 926 927 928 929 930 | entryPtr = Tcl_FindHashEntry(&canvasPtr->idTable, (char *) id); if (entryPtr != NULL) { itemPtr = Tcl_GetHashValue(entryPtr); object = itemPtr; } if (object == NULL) { | | | > > | 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 | entryPtr = Tcl_FindHashEntry(&canvasPtr->idTable, (char *) id); if (entryPtr != NULL) { itemPtr = Tcl_GetHashValue(entryPtr); object = itemPtr; } if (object == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "item \"%s\" doesn't exist", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "CANVAS_ITEM", Tcl_GetString(objv[2]), NULL); result = TCL_ERROR; goto done; } } else { bindByTag: object = Tk_GetUid(Tcl_GetString(objv[2])); } |
︙ | ︙ | |||
949 950 951 952 953 954 955 | (char *) INT2PTR(searchPtr->id)); if (entryPtr != NULL) { itemPtr = Tcl_GetHashValue(entryPtr); object = itemPtr; } if (object == 0) { | | | > > | 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 | (char *) INT2PTR(searchPtr->id)); if (entryPtr != NULL) { itemPtr = Tcl_GetHashValue(entryPtr); object = itemPtr; } if (object == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "item \"%s\" doesn't exist", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "CANVAS_ITEM", Tcl_GetString(objv[2]), NULL); result = TCL_ERROR; goto done; } } else { object = (ClientData) searchPtr->expr->uid; } #endif /* USE_OLD_TAG_SEARCH */ |
︙ | ︙ | |||
1026 1027 1028 1029 1030 1031 1032 | if (mask & (unsigned) ~(ButtonMotionMask|Button1MotionMask |Button2MotionMask|Button3MotionMask|Button4MotionMask |Button5MotionMask|ButtonPressMask|ButtonReleaseMask |EnterWindowMask|LeaveWindowMask|KeyPressMask |KeyReleaseMask|PointerMotionMask|VirtualEventMask)) { Tk_DeleteBinding(interp, canvasPtr->bindingTable, object, Tcl_GetString(objv[3])); | | | | | | 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 | if (mask & (unsigned) ~(ButtonMotionMask|Button1MotionMask |Button2MotionMask|Button3MotionMask|Button4MotionMask |Button5MotionMask|ButtonPressMask|ButtonReleaseMask |EnterWindowMask|LeaveWindowMask|KeyPressMask |KeyReleaseMask|PointerMotionMask|VirtualEventMask)) { Tk_DeleteBinding(interp, canvasPtr->bindingTable, object, Tcl_GetString(objv[3])); Tcl_SetObjResult(interp, Tcl_NewStringObj( "requested illegal events; only key, button, motion," " enter, leave, and virtual events may be used", -1)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "BAD_EVENTS", NULL); result = TCL_ERROR; goto done; } } else if (objc == 4) { const char *command; command = Tk_GetBinding(interp, canvasPtr->bindingTable, |
︙ | ︙ | |||
1270 1271 1272 1273 1274 1275 1276 | * Can unlock now because we no longer look at the fields of the * matched item type that are potentially modified by other threads. */ Tcl_MutexUnlock(&typeListMutex); if (matchPtr == NULL) { badType: | | | > > | 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 | * Can unlock now because we no longer look at the fields of the * matched item type that are potentially modified by other threads. */ Tcl_MutexUnlock(&typeListMutex); if (matchPtr == NULL) { badType: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown or ambiguous item type \"%s\"", arg)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "CANVAS_ITEM_TYPE", arg, NULL); result = TCL_ERROR; goto done; } if (objc < 4) { /* * Allow more specific error return. */ |
︙ | ︙ | |||
1497 1498 1499 1500 1501 1502 1503 1504 | Tcl_WrongNumArgs(interp, 2, objv, "tagOrId"); result = TCL_ERROR; goto done; } FIRST_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto done); if (itemPtr != NULL) { int i; for (i = 0; i < itemPtr->numTags; i++) { | > > > | > | 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 | Tcl_WrongNumArgs(interp, 2, objv, "tagOrId"); result = TCL_ERROR; goto done; } FIRST_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto done); if (itemPtr != NULL) { int i; Tcl_Obj *resultObj = Tcl_NewObj(); for (i = 0; i < itemPtr->numTags; i++) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(itemPtr->tagPtr[i], -1)); } Tcl_SetObjResult(interp, resultObj); } break; case CANV_ICURSOR: { int index; if (objc != 4) { Tcl_WrongNumArgs(interp, 2, objv, "tagOrId index"); |
︙ | ︙ | |||
1541 1542 1543 1544 1545 1546 1547 | } FOR_EVERY_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto done) { if (itemPtr->typePtr->indexProc != NULL) { break; } } if (itemPtr == NULL) { | > | | > | 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 | } FOR_EVERY_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto done) { if (itemPtr->typePtr->indexProc != NULL) { break; } } if (itemPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't find an indexable item \"%s\"", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TK", "CANVAS", "INDEXABLE_ITEM", NULL); result = TCL_ERROR; goto done; } result = ItemIndex(canvasPtr, itemPtr, objv[3], &index); if (result != TCL_OK) { goto done; } |
︙ | ︙ | |||
1643 1644 1645 1646 1647 1648 1649 | */ if (objc == 3) { itemPtr = NULL; } else { FIRST_CANVAS_ITEM_MATCHING(objv[3], &searchPtr, goto done); if (itemPtr == NULL) { | | | > > | 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 | */ if (objc == 3) { itemPtr = NULL; } else { FIRST_CANVAS_ITEM_MATCHING(objv[3], &searchPtr, goto done); if (itemPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "tagOrId \"%s\" doesn't match any items", Tcl_GetString(objv[3]))); Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM", NULL); result = TCL_ERROR; goto done; } itemPtr = itemPtr->prevPtr; } RELINK_ITEMS(objv[2], itemPtr); break; |
︙ | ︙ | |||
1768 1769 1770 1771 1772 1773 1774 | prevPtr = canvasPtr->lastItemPtr; } else { prevPtr = NULL; FOR_EVERY_CANVAS_ITEM_MATCHING(objv[3], &searchPtr, goto done) { prevPtr = itemPtr; } if (prevPtr == NULL) { | | | > > | 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 | prevPtr = canvasPtr->lastItemPtr; } else { prevPtr = NULL; FOR_EVERY_CANVAS_ITEM_MATCHING(objv[3], &searchPtr, goto done) { prevPtr = itemPtr; } if (prevPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "tagOrId \"%s\" doesn't match any items", Tcl_GetString(objv[3]))); Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM", NULL); result = TCL_ERROR; goto done; } } RELINK_ITEMS(objv[2], prevPtr); break; } |
︙ | ︙ | |||
1843 1844 1845 1846 1847 1848 1849 | objv[4], &yOrigin) != TCL_OK) || (Tcl_GetDoubleFromObj(interp, objv[5], &xScale)!=TCL_OK) || (Tcl_GetDoubleFromObj(interp, objv[6], &yScale)!=TCL_OK)) { result = TCL_ERROR; goto done; } if ((xScale == 0.0) || (yScale == 0.0)) { | > | > | 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 | objv[4], &yOrigin) != TCL_OK) || (Tcl_GetDoubleFromObj(interp, objv[5], &xScale)!=TCL_OK) || (Tcl_GetDoubleFromObj(interp, objv[6], &yScale)!=TCL_OK)) { result = TCL_ERROR; goto done; } if ((xScale == 0.0) || (yScale == 0.0)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "scale factor cannot be zero", -1)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "BAD_SCALE", NULL); result = TCL_ERROR; goto done; } FOR_EVERY_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto done) { EventuallyRedrawItem(canvasPtr, itemPtr); ItemScale(canvasPtr, itemPtr, xOrigin, yOrigin, xScale, yScale); EventuallyRedrawItem(canvasPtr, itemPtr); |
︙ | ︙ | |||
1921 1922 1923 1924 1925 1926 1927 | FOR_EVERY_CANVAS_ITEM_MATCHING(objv[3], &searchPtr, goto done) { if ((itemPtr->typePtr->indexProc != NULL) && (itemPtr->typePtr->selectionProc != NULL)){ break; } } if (itemPtr == NULL) { | | | | > > | 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 | FOR_EVERY_CANVAS_ITEM_MATCHING(objv[3], &searchPtr, goto done) { if ((itemPtr->typePtr->indexProc != NULL) && (itemPtr->typePtr->selectionProc != NULL)){ break; } } if (itemPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't find an indexable and selectable item \"%s\"", Tcl_GetString(objv[3]))); Tcl_SetErrorCode(interp, "TK", "CANVAS", "SELECTABLE_ITEM", NULL); result = TCL_ERROR; goto done; } } if (objc == 5) { result = ItemIndex(canvasPtr, itemPtr, objv[4], &index); if (result != TCL_OK) { |
︙ | ︙ | |||
2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 | } break; case CANV_XVIEW: { int count, type; int newX = 0; /* Initialization needed only to prevent gcc * warnings. */ double fraction; if (objc == 2) { Tcl_SetObjResult(interp, ScrollFractions( canvasPtr->xOrigin + canvasPtr->inset, canvasPtr->xOrigin + Tk_Width(canvasPtr->tkwin) - canvasPtr->inset, canvasPtr->scrollX1, canvasPtr->scrollX2)); | > > > | | < | | | | | | | | | | | | | | | | | | | | < | | | < | | | | < > > > | | < | | | | | | | | | | | < | | | | < | | | | < | | | < | | | | < | 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 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 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 | } break; case CANV_XVIEW: { int count, type; int newX = 0; /* Initialization needed only to prevent gcc * warnings. */ double fraction; const char **args; if (objc == 2) { Tcl_SetObjResult(interp, ScrollFractions( canvasPtr->xOrigin + canvasPtr->inset, canvasPtr->xOrigin + Tk_Width(canvasPtr->tkwin) - canvasPtr->inset, canvasPtr->scrollX1, canvasPtr->scrollX2)); break; } args = TkGetStringsFromObjs(objc, objv); type = Tk_GetScrollInfo(interp, objc, args, &fraction, &count); if (args != NULL) { ckfree(args); } switch (type) { case TK_SCROLL_ERROR: result = TCL_ERROR; goto done; case TK_SCROLL_MOVETO: newX = canvasPtr->scrollX1 - canvasPtr->inset + (int) (fraction * (canvasPtr->scrollX2 - canvasPtr->scrollX1) + 0.5); break; case TK_SCROLL_PAGES: newX = (int) (canvasPtr->xOrigin + count * .9 * (Tk_Width(canvasPtr->tkwin) - 2*canvasPtr->inset)); break; case TK_SCROLL_UNITS: if (canvasPtr->xScrollIncrement > 0) { newX = canvasPtr->xOrigin + count*canvasPtr->xScrollIncrement; } else { newX = (int) (canvasPtr->xOrigin + count * .1 * (Tk_Width(canvasPtr->tkwin) - 2*canvasPtr->inset)); } break; } CanvasSetOrigin(canvasPtr, newX, canvasPtr->yOrigin); break; } case CANV_YVIEW: { int count, type; int newY = 0; /* Initialization needed only to prevent gcc * warnings. */ double fraction; const char **args; if (objc == 2) { Tcl_SetObjResult(interp, ScrollFractions( canvasPtr->yOrigin + canvasPtr->inset, canvasPtr->yOrigin + Tk_Height(canvasPtr->tkwin) - canvasPtr->inset, canvasPtr->scrollY1, canvasPtr->scrollY2)); break; } args = TkGetStringsFromObjs(objc, objv); type = Tk_GetScrollInfo(interp, objc, args, &fraction, &count); if (args != NULL) { ckfree(args); } switch (type) { case TK_SCROLL_ERROR: result = TCL_ERROR; goto done; case TK_SCROLL_MOVETO: newY = canvasPtr->scrollY1 - canvasPtr->inset + (int) ( fraction*(canvasPtr->scrollY2-canvasPtr->scrollY1) + 0.5); break; case TK_SCROLL_PAGES: newY = (int) (canvasPtr->yOrigin + count * .9 * (Tk_Height(canvasPtr->tkwin) - 2*canvasPtr->inset)); break; case TK_SCROLL_UNITS: if (canvasPtr->yScrollIncrement > 0) { newY = canvasPtr->yOrigin + count*canvasPtr->yScrollIncrement; } else { newY = (int) (canvasPtr->yOrigin + count * .1 * (Tk_Height(canvasPtr->tkwin) - 2*canvasPtr->inset)); } break; } CanvasSetOrigin(canvasPtr, canvasPtr->xOrigin, newY); break; } } done: #ifndef USE_OLD_TAG_SEARCH TagSearchDestroy(searchPtr); |
︙ | ︙ | |||
2298 2299 2300 2301 2302 2303 2304 | const char **argv2; if (Tcl_SplitList(canvasPtr->interp, canvasPtr->regionString, &argc2, &argv2) != TCL_OK) { return TCL_ERROR; } if (argc2 != 4) { | | | > | 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 | const char **argv2; if (Tcl_SplitList(canvasPtr->interp, canvasPtr->regionString, &argc2, &argv2) != TCL_OK) { return TCL_ERROR; } if (argc2 != 4) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad scrollRegion \"%s\"", canvasPtr->regionString)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "SCROLL_REGION", NULL); badRegion: ckfree(canvasPtr->regionString); ckfree(argv2); canvasPtr->regionString = NULL; return TCL_ERROR; } if ((Tk_GetPixels(canvasPtr->interp, canvasPtr->tkwin, |
︙ | ︙ | |||
3579 3580 3581 3582 3583 3584 3585 | case '\t': case '\n': case '\r': break; case '!': /* Negate next tag or subexpr */ if (looking_for_tag > 1) { | | | > > | 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 | case '\t': case '\n': case '\r': break; case '!': /* Negate next tag or subexpr */ if (looking_for_tag > 1) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "too many '!' in tag search expression", -1)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH", "COMPLEXITY", NULL); return TCL_ERROR; } looking_for_tag++; negate_result = 1; break; case '(': /* Scan (negated) subexpr recursively */ |
︙ | ︙ | |||
3627 3628 3629 3630 3631 3632 3633 | if (c == '"') { found_endquote = 1; break; } *tag++ = c; } if (!found_endquote) { | | | > | | | > > | | | > | | 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 | if (c == '"') { found_endquote = 1; break; } *tag++ = c; } if (!found_endquote) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "missing endquote in tag search expression", -1)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH", "ENDQUOTE", NULL); return TCL_ERROR; } if (!(tag - searchPtr->rewritebuffer)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "null quoted tag string in tag search expression", -1)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH", "EMPTY", NULL); return TCL_ERROR; } *tag++ = '\0'; expr->uids[expr->index++] = Tk_GetUid(searchPtr->rewritebuffer); looking_for_tag = 0; found_tag = 1; break; case '&': /* Illegal chars when looking for tag */ case '|': case '^': case ')': Tcl_SetObjResult(interp, Tcl_NewStringObj( "unexpected operator in tag search expression", -1)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH", "UNEXPECTED", NULL); return TCL_ERROR; default: /* Unquoted tag string */ if (negate_result) { expr->uids[expr->index++] = searchUids->negtagvalUid; negate_result = 0; } else { |
︙ | ︙ | |||
3712 3713 3714 3715 3716 3717 3718 | case '\n': case '\r': break; case '&': /* AND operator */ c = searchPtr->string[searchPtr->stringIndex++]; if (c != '&') { | | | > > | | > > | | > > > | > | 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 | case '\n': case '\r': break; case '&': /* AND operator */ c = searchPtr->string[searchPtr->stringIndex++]; if (c != '&') { Tcl_SetObjResult(interp, Tcl_NewStringObj( "singleton '&' in tag search expression", -1)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH", "INCOMPLETE_OP", NULL); return TCL_ERROR; } expr->uids[expr->index++] = searchUids->andUid; looking_for_tag = 1; break; case '|': /* OR operator */ c = searchPtr->string[searchPtr->stringIndex++]; if (c != '|') { Tcl_SetObjResult(interp, Tcl_NewStringObj( "singleton '|' in tag search expression", -1)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH", "INCOMPLETE_OP", NULL); return TCL_ERROR; } expr->uids[expr->index++] = searchUids->orUid; looking_for_tag = 1; break; case '^': /* XOR operator */ expr->uids[expr->index++] = searchUids->xorUid; looking_for_tag = 1; break; case ')': /* End subexpression */ expr->uids[expr->index++] = searchUids->endparenUid; goto breakwhile; default: /* syntax error */ Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid boolean operator in tag search expression", -1)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH", "BAD_OP", NULL); return TCL_ERROR; } } } breakwhile: if (found_tag && !looking_for_tag) { return TCL_OK; } Tcl_SetObjResult(interp, Tcl_NewStringObj( "missing tag in tag search expression", -1)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH", "NO_TAG", NULL); return TCL_ERROR; } /* *-------------------------------------------------------------- * * TagSearchEvalExpr -- |
︙ | ︙ | |||
4134 4135 4136 4137 4138 4139 4140 | /* *-------------------------------------------------------------- * * DoItem -- * * This is a utility function called by FindItems. It either adds | | | | | | < | < < | 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 | /* *-------------------------------------------------------------- * * DoItem -- * * This is a utility function called by FindItems. It either adds * itemPtr's id to the list being constructed, or it adds a new tag to * itemPtr, depending on the value of tag. * * Results: * None. * * Side effects: * If tag is NULL then itemPtr's id is added as an element to the * supplied object; otherwise tag is added to itemPtr's list of tags. * *-------------------------------------------------------------- */ static void DoItem( Tcl_Obj *accumObj, /* Object in which to (possibly) record item * id. */ Tk_Item *itemPtr, /* Item to (possibly) modify. */ Tk_Uid tag) /* Tag to add to those already present for * item, or NULL. */ { Tk_Uid *tagPtr; int count; /* * Handle the "add-to-result" case and return, if appropriate. */ if (tag == NULL) { Tcl_ListObjAppendElement(NULL, accumObj, Tcl_NewIntObj(itemPtr->id)); return; } for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags; count > 0; tagPtr++, count--) { if (tag == *tagPtr) { return; |
︙ | ︙ | |||
4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 | { #ifdef USE_OLD_TAG_SEARCH TagSearch search; #endif /* USE_OLD_TAG_SEARCH */ Tk_Item *itemPtr; Tk_Uid uid; int index, result; static const char *const optionStrings[] = { "above", "all", "below", "closest", "enclosed", "overlapping", "withtag", NULL }; enum options { CANV_ABOVE, CANV_ALL, CANV_BELOW, CANV_CLOSEST, CANV_ENCLOSED, CANV_OVERLAPPING, CANV_WITHTAG | > | 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 | { #ifdef USE_OLD_TAG_SEARCH TagSearch search; #endif /* USE_OLD_TAG_SEARCH */ Tk_Item *itemPtr; Tk_Uid uid; int index, result; Tcl_Obj *resultObj; static const char *const optionStrings[] = { "above", "all", "below", "closest", "enclosed", "overlapping", "withtag", NULL }; enum options { CANV_ABOVE, CANV_ALL, CANV_BELOW, CANV_CLOSEST, CANV_ENCLOSED, CANV_OVERLAPPING, CANV_WITHTAG |
︙ | ︙ | |||
4284 4285 4286 4287 4288 4289 4290 | return TCL_ERROR; } FOR_EVERY_CANVAS_ITEM_MATCHING(objv[first+1], searchPtrPtr, return TCL_ERROR) { lastPtr = itemPtr; } if ((lastPtr != NULL) && (lastPtr->nextPtr != NULL)) { | > | > > | > | | | < > | 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 | return TCL_ERROR; } FOR_EVERY_CANVAS_ITEM_MATCHING(objv[first+1], searchPtrPtr, return TCL_ERROR) { lastPtr = itemPtr; } if ((lastPtr != NULL) && (lastPtr->nextPtr != NULL)) { resultObj = Tcl_NewObj(); DoItem(resultObj, lastPtr->nextPtr, uid); Tcl_SetObjResult(interp, resultObj); } break; } case CANV_ALL: if (objc != first+1) { Tcl_WrongNumArgs(interp, first+1, objv, NULL); return TCL_ERROR; } resultObj = Tcl_NewObj(); for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL; itemPtr = itemPtr->nextPtr) { DoItem(resultObj, itemPtr, uid); } Tcl_SetObjResult(interp, resultObj); break; case CANV_BELOW: if (objc != first+2) { Tcl_WrongNumArgs(interp, first+1, objv, "tagOrId"); return TCL_ERROR; } FIRST_CANVAS_ITEM_MATCHING(objv[first+1], searchPtrPtr, return TCL_ERROR); if ((itemPtr != NULL) && (itemPtr->prevPtr != NULL)) { resultObj = Tcl_NewObj(); DoItem(resultObj, itemPtr->prevPtr, uid); Tcl_SetObjResult(interp, resultObj); } break; case CANV_CLOSEST: { double closestDist; Tk_Item *startPtr, *closestPtr; double coords[2], halo; int x1, y1, x2, y2; |
︙ | ︙ | |||
4335 4336 4337 4338 4339 4340 4341 | } if (objc > first+3) { if (Tk_CanvasGetCoordFromObj(interp, (Tk_Canvas) canvasPtr, objv[first+3], &halo) != TCL_OK) { return TCL_ERROR; } if (halo < 0.0) { | > | < | 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 | } if (objc > first+3) { if (Tk_CanvasGetCoordFromObj(interp, (Tk_Canvas) canvasPtr, objv[first+3], &halo) != TCL_OK) { return TCL_ERROR; } if (halo < 0.0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't have negative halo value \"%f\"", halo)); return TCL_ERROR; } } else { halo = 0.0; } /* |
︙ | ︙ | |||
4400 4401 4402 4403 4404 4405 4406 | while (1) { itemPtr = itemPtr->nextPtr; if (itemPtr == NULL) { itemPtr = canvasPtr->firstItemPtr; } if (itemPtr == startPtr) { | > | > | 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 | while (1) { itemPtr = itemPtr->nextPtr; if (itemPtr == NULL) { itemPtr = canvasPtr->firstItemPtr; } if (itemPtr == startPtr) { resultObj = Tcl_NewObj(); DoItem(resultObj, closestPtr, uid); Tcl_SetObjResult(interp, resultObj); return TCL_OK; } if (itemPtr->state == TK_STATE_HIDDEN || (itemPtr->state == TK_STATE_NULL && canvasPtr->canvas_state == TK_STATE_HIDDEN)) { continue; } |
︙ | ︙ | |||
4438 4439 4440 4441 4442 4443 4444 4445 | } return FindArea(interp, canvasPtr, objv+first+1, uid, 0); case CANV_WITHTAG: if (objc != first+2) { Tcl_WrongNumArgs(interp, first+1, objv, "tagOrId"); return TCL_ERROR; } FOR_EVERY_CANVAS_ITEM_MATCHING(objv[first+1], searchPtrPtr, | > | | > > > > > | 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 | } return FindArea(interp, canvasPtr, objv+first+1, uid, 0); case CANV_WITHTAG: if (objc != first+2) { Tcl_WrongNumArgs(interp, first+1, objv, "tagOrId"); return TCL_ERROR; } resultObj = Tcl_NewObj(); FOR_EVERY_CANVAS_ITEM_MATCHING(objv[first+1], searchPtrPtr, goto badWithTagSearch) { DoItem(resultObj, itemPtr, uid); } Tcl_SetObjResult(interp, resultObj); return TCL_OK; badWithTagSearch: Tcl_DecrRefCount(resultObj); return TCL_ERROR; } return TCL_OK; } /* *-------------------------------------------------------------- * |
︙ | ︙ | |||
4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 | * result. */ int enclosed) /* 0 means overlapping or enclosed items are * OK, 1 means only enclosed items are OK. */ { double rect[4], tmp; int x1, y1, x2, y2; Tk_Item *itemPtr; if ((Tk_CanvasGetCoordFromObj(interp, (Tk_Canvas) canvasPtr, objv[0], &rect[0]) != TCL_OK) || (Tk_CanvasGetCoordFromObj(interp,(Tk_Canvas)canvasPtr,objv[1], &rect[1]) != TCL_OK) || (Tk_CanvasGetCoordFromObj(interp,(Tk_Canvas)canvasPtr,objv[2], &rect[2]) != TCL_OK) | > | 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 | * result. */ int enclosed) /* 0 means overlapping or enclosed items are * OK, 1 means only enclosed items are OK. */ { double rect[4], tmp; int x1, y1, x2, y2; Tk_Item *itemPtr; Tcl_Obj *resultObj; if ((Tk_CanvasGetCoordFromObj(interp, (Tk_Canvas) canvasPtr, objv[0], &rect[0]) != TCL_OK) || (Tk_CanvasGetCoordFromObj(interp,(Tk_Canvas)canvasPtr,objv[1], &rect[1]) != TCL_OK) || (Tk_CanvasGetCoordFromObj(interp,(Tk_Canvas)canvasPtr,objv[2], &rect[2]) != TCL_OK) |
︙ | ︙ | |||
4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 | * item-specific code except for items that are close. */ x1 = (int) (rect[0] - 1.0); y1 = (int) (rect[1] - 1.0); x2 = (int) (rect[2] + 1.0); y2 = (int) (rect[3] + 1.0); for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL; itemPtr = itemPtr->nextPtr) { if (itemPtr->state == TK_STATE_HIDDEN || (itemPtr->state == TK_STATE_NULL && canvasPtr->canvas_state == TK_STATE_HIDDEN)) { continue; } if ((itemPtr->x1 >= x2) || (itemPtr->x2 <= x1) || (itemPtr->y1 >= y2) || (itemPtr->y2 <= y1)) { continue; } if (ItemOverlap(canvasPtr, itemPtr, rect) >= enclosed) { | > | > | 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 | * item-specific code except for items that are close. */ x1 = (int) (rect[0] - 1.0); y1 = (int) (rect[1] - 1.0); x2 = (int) (rect[2] + 1.0); y2 = (int) (rect[3] + 1.0); resultObj = Tcl_NewObj(); for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL; itemPtr = itemPtr->nextPtr) { if (itemPtr->state == TK_STATE_HIDDEN || (itemPtr->state == TK_STATE_NULL && canvasPtr->canvas_state == TK_STATE_HIDDEN)) { continue; } if ((itemPtr->x1 >= x2) || (itemPtr->x2 <= x1) || (itemPtr->y1 >= y2) || (itemPtr->y2 <= y1)) { continue; } if (ItemOverlap(canvasPtr, itemPtr, rect) >= enclosed) { DoItem(resultObj, itemPtr, uid); } } Tcl_SetObjResult(interp, resultObj); return TCL_OK; } /* *-------------------------------------------------------------- * * RelinkItems -- |
︙ | ︙ |
Changes to generic/tkClipboard.c.
︙ | ︙ | |||
363 364 365 366 367 368 369 | targetPtr->format = format; targetPtr->firstBufferPtr = targetPtr->lastBufferPtr = NULL; targetPtr->nextPtr = dispPtr->clipTargetPtr; dispPtr->clipTargetPtr = targetPtr; Tk_CreateSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom, type, ClipboardHandler, targetPtr, format); } else if (targetPtr->format != format) { | | | > | | > | 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | targetPtr->format = format; targetPtr->firstBufferPtr = targetPtr->lastBufferPtr = NULL; targetPtr->nextPtr = dispPtr->clipTargetPtr; dispPtr->clipTargetPtr = targetPtr; Tk_CreateSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom, type, ClipboardHandler, targetPtr, format); } else if (targetPtr->format != format) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "format \"%s\" does not match current format \"%s\" for %s", Tk_GetAtomName(tkwin, format), Tk_GetAtomName(tkwin, targetPtr->format), Tk_GetAtomName(tkwin, type))); Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "FORMAT_MISMATCH", NULL); return TCL_ERROR; } /* * Append a new buffer to the buffer chain. */ |
︙ | ︙ | |||
470 471 472 473 474 475 476 | /* * Increment i so that it points to the value for the flag instead * of the flag itself. */ i++; if (i >= objc) { | | | > | 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | /* * Increment i so that it points to the value for the flag instead * of the flag itself. */ i++; if (i >= objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", string)); Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "VALUE", NULL); return TCL_ERROR; } switch ((enum appendOptions) subIndex) { case APPEND_DISPLAYOF: path = Tcl_GetString(objv[i]); break; case APPEND_FORMAT: |
︙ | ︙ | |||
559 560 561 562 563 564 565 | } if (Tcl_GetIndexFromObj(interp, objv[i], getOptionStrings, "option", 0, &subIndex) != TCL_OK) { return TCL_ERROR; } i++; if (i >= objc) { | | | > | 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 | } if (Tcl_GetIndexFromObj(interp, objv[i], getOptionStrings, "option", 0, &subIndex) != TCL_OK) { return TCL_ERROR; } i++; if (i >= objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", string)); Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "VALUE", NULL); return TCL_ERROR; } switch ((enum getOptions) subIndex) { case APPEND_DISPLAYOF: path = Tcl_GetString(objv[i]); break; case APPEND_TYPE: |
︙ | ︙ | |||
695 696 697 698 699 700 701 | /* ARGSUSED */ static int ClipboardGetProc( ClientData clientData, /* Dynamic string holding partially assembled * selection. */ Tcl_Interp *interp, /* Interpreter used for error reporting (not * used). */ | | < | 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 | /* ARGSUSED */ static int ClipboardGetProc( ClientData clientData, /* Dynamic string holding partially assembled * selection. */ Tcl_Interp *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; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkCmds.c.
︙ | ︙ | |||
229 230 231 232 233 234 235 | command = Tk_GetBinding(interp, winPtr->mainPtr->bindingTable, object, Tcl_GetString(objv[2])); if (command == NULL) { Tcl_ResetResult(interp); return TCL_OK; } | | | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | command = Tk_GetBinding(interp, winPtr->mainPtr->bindingTable, object, Tcl_GetString(objv[2])); if (command == NULL) { Tcl_ResetResult(interp); return TCL_OK; } Tcl_SetObjResult(interp, Tcl_NewStringObj(command, -1)); } else { Tk_GetAllBindings(interp, winPtr->mainPtr->bindingTable, object); } return TCL_OK; } /* |
︙ | ︙ | |||
357 358 359 360 361 362 363 | winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[1]), tkwin); if (winPtr == NULL) { return TCL_ERROR; } if (objc == 2) { listPtr = Tcl_NewObj(); | < | | | | | | < | 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 | winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[1]), tkwin); if (winPtr == NULL) { return TCL_ERROR; } if (objc == 2) { listPtr = Tcl_NewObj(); if (winPtr->numTags == 0) { Tcl_ListObjAppendElement(NULL, listPtr, Tcl_NewStringObj(winPtr->pathName, -1)); Tcl_ListObjAppendElement(NULL, listPtr, Tcl_NewStringObj(winPtr->classUid, -1)); winPtr2 = winPtr; while ((winPtr2 != NULL) && !(Tk_TopWinHierarchy(winPtr2))) { winPtr2 = winPtr2->parentPtr; } if ((winPtr != winPtr2) && (winPtr2 != NULL)) { Tcl_ListObjAppendElement(NULL, listPtr, Tcl_NewStringObj(winPtr2->pathName, -1)); } Tcl_ListObjAppendElement(NULL, listPtr, Tcl_NewStringObj("all", -1)); } else { for (i = 0; i < winPtr->numTags; i++) { Tcl_ListObjAppendElement(NULL, listPtr, Tcl_NewStringObj((char *) winPtr->tagPtr[i], -1)); } } Tcl_SetObjResult(interp, listPtr); return TCL_OK; } if (winPtr->tagPtr != NULL) { TkFreeBindingTags(winPtr); } if (Tcl_ListObjGetElements(interp, objv[2], &length, &tags) != TCL_OK) { return TCL_ERROR; |
︙ | ︙ | |||
551 552 553 554 555 556 557 | } else { other = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), mainwin); if (other == NULL) { return TCL_ERROR; } } if (Tk_RestackWindow(tkwin, Below, other) != TCL_OK) { | > > | | > > > > | | 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | } else { other = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), mainwin); if (other == NULL) { return TCL_ERROR; } } if (Tk_RestackWindow(tkwin, Below, other) != TCL_OK) { if (other) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't lower \"%s\" below \"%s\"", Tcl_GetString(objv[1]), Tcl_GetString(objv[2]))); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't lower \"%s\" to bottom", Tcl_GetString(objv[1]))); } Tcl_SetErrorCode(interp, "TK", "RESTACK", "LOWER", NULL); return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
605 606 607 608 609 610 611 | } else { other = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), mainwin); if (other == NULL) { return TCL_ERROR; } } if (Tk_RestackWindow(tkwin, Above, other) != TCL_OK) { | > > > | > > | > | | 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | } else { other = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), mainwin); if (other == NULL) { return TCL_ERROR; } } if (Tk_RestackWindow(tkwin, Above, other) != TCL_OK) { if (other) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't raise \"%s\" above \"%s\"", Tcl_GetString(objv[1]), Tcl_GetString(objv[2]))); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't raise \"%s\" to top", Tcl_GetString(objv[1]))); } Tcl_SetErrorCode(interp, "TK", "RESTACK", "RAISE", NULL); return TCL_ERROR; } return TCL_OK; } /* * ---------------------------------------------------------------------- |
︙ | ︙ | |||
671 672 673 674 675 676 677 | Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = clientData; TkWindow *winPtr; const char *string; if (Tcl_IsSafe(interp)) { | | | | | | 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 | Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = clientData; TkWindow *winPtr; const char *string; if (Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "appname not accessible in a safe interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "APPLICATION", NULL); return TCL_ERROR; } winPtr = (TkWindow *) tkwin; if (objc > 2) { Tcl_WrongNumArgs(interp, 1, objv, "?newName?"); return TCL_ERROR; } if (objc == 2) { string = Tcl_GetString(objv[1]); winPtr->nameUid = Tk_GetUid(Tk_SetAppName(tkwin, string)); } Tcl_SetObjResult(interp, Tcl_NewStringObj(winPtr->nameUid, -1)); return TCL_OK; } int CaretCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ |
︙ | ︙ | |||
796 797 798 799 800 801 802 | { Tk_Window tkwin = clientData; Screen *screenPtr; int skip, width, height; double d; if (Tcl_IsSafe(interp)) { | > | < > | 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 | { Tk_Window tkwin = clientData; Screen *screenPtr; int skip, width, height; double d; if (Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "scaling not accessible in a safe interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "SCALING", NULL); return TCL_ERROR; } skip = TkGetDisplayOf(interp, objc - 1, objv + 1, &tkwin); if (skip < 0) { return TCL_ERROR; } |
︙ | ︙ | |||
845 846 847 848 849 850 851 | Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = clientData; TkDisplay *dispPtr; int skip; if (Tcl_IsSafe(interp)) { | | | | | 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 | Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = clientData; TkDisplay *dispPtr; int skip; if (Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "useinputmethods not accessible in a safe interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "INPUT_METHODS", NULL); return TCL_ERROR; } skip = TkGetDisplayOf(interp, objc-1, objv+1, &tkwin); if (skip < 0) { return TCL_ERROR; } |
︙ | ︙ | |||
929 930 931 932 933 934 935 | } if (objc - skip == 1) { long inactive; inactive = (Tcl_IsSafe(interp) ? -1 : Tk_GetUserInactiveTime(Tk_Display(tkwin))); Tcl_SetObjResult(interp, Tcl_NewLongObj(inactive)); | < < < < | > > > | | > | 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 | } if (objc - skip == 1) { long inactive; inactive = (Tcl_IsSafe(interp) ? -1 : Tk_GetUserInactiveTime(Tk_Display(tkwin))); Tcl_SetObjResult(interp, Tcl_NewLongObj(inactive)); } else if (objc - skip == 2) { const char *string; string = Tcl_GetString(objv[objc-1]); if (strcmp(string, "reset") != 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad option \"%s\": must be reset", string)); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "option", string, NULL); return TCL_ERROR; } if (Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "resetting the user inactivity timer " "is not allowed in a safe interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "INACTIVITY_TIMER", NULL); return TCL_ERROR; } Tk_ResetUserInactiveTime(Tk_Display(tkwin)); Tcl_ResetResult(interp); } else { Tcl_WrongNumArgs(interp, 1, objv, "?-displayof window? ?reset?"); return TCL_ERROR; |
︙ | ︙ | |||
1046 1047 1048 1049 1050 1051 1052 | if ((done != 0) && (done != 1)) { /* * Note that we do not delete the event handler because it was * deleted automatically when the window was destroyed. */ Tcl_ResetResult(interp); | | | > > | 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 | if ((done != 0) && (done != 1)) { /* * Note that we do not delete the event handler because it was * deleted automatically when the window was destroyed. */ Tcl_ResetResult(interp); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" was deleted before its visibility changed", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TK", "WAIT", "PREMATURE", NULL); return TCL_ERROR; } Tk_DeleteEventHandler(window, VisibilityChangeMask|StructureNotifyMask, WaitVisibilityProc, &done); break; } |
︙ | ︙ | |||
1125 1126 1127 1128 1129 1130 1131 | ClientData clientData, /* Pointer to integer to set to 1. */ XEvent *eventPtr) /* Information about event (not used). */ { int *donePtr = clientData; if (eventPtr->type == VisibilityNotify) { *donePtr = 1; | < | | 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 | ClientData clientData, /* Pointer to integer to set to 1. */ XEvent *eventPtr) /* Information about event (not used). */ { int *donePtr = clientData; if (eventPtr->type == VisibilityNotify) { *donePtr = 1; } else if (eventPtr->type == DestroyNotify) { *donePtr = 2; } } static void WaitWindowProc( ClientData clientData, /* Pointer to integer to set to 1. */ |
︙ | ︙ | |||
1580 1581 1582 1583 1584 1585 1586 | } objv += skip; if (Tcl_GetLongFromObj(interp, objv[2], &id) != TCL_OK) { return TCL_ERROR; } name = Tk_GetAtomName(tkwin, (Atom) id); if (strcmp(name, "?bad atom?") == 0) { | > | > | | 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 | } objv += skip; if (Tcl_GetLongFromObj(interp, objv[2], &id) != TCL_OK) { return TCL_ERROR; } name = Tk_GetAtomName(tkwin, (Atom) id); if (strcmp(name, "?bad atom?") == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "no atom exists with id \"%s\"", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "ATOM", Tcl_GetString(objv[2]), NULL); return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewStringObj(name, -1)); break; } case WIN_CONTAINING: skip = TkGetDisplayOf(interp, objc - 2, objv + 2, &tkwin); |
︙ | ︙ | |||
1639 1640 1641 1642 1643 1644 1645 | string = Tcl_GetString(objv[2 + skip]); if (TkpScanWindowId(interp, string, &id) != TCL_OK) { return TCL_ERROR; } winPtr = (TkWindow *) Tk_IdToWindow(Tk_Display(tkwin), id); if ((winPtr == NULL) || (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr)) { | | | > > | 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 | string = Tcl_GetString(objv[2 + skip]); if (TkpScanWindowId(interp, string, &id) != TCL_OK) { return TCL_ERROR; } winPtr = (TkWindow *) Tk_IdToWindow(Tk_Display(tkwin), id); if ((winPtr == NULL) || (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window id \"%s\" doesn't exist in this application", string)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW", string, NULL); return TCL_ERROR; } /* * If the window is a utility window with no associated path (such as * a wrapper window or send communication window), just return an * empty string. |
︙ | ︙ | |||
1760 1761 1762 1763 1764 1765 1766 | return TCL_ERROR; } template.screen = Tk_ScreenNumber(tkwin); visInfoPtr = XGetVisualInfo(Tk_Display(tkwin), VisualScreenMask, &template, &count); if (visInfoPtr == NULL) { | > | < > | 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 | return TCL_ERROR; } template.screen = Tk_ScreenNumber(tkwin); visInfoPtr = XGetVisualInfo(Tk_Display(tkwin), VisualScreenMask, &template, &count); if (visInfoPtr == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't find any visuals for screen", -1)); Tcl_SetErrorCode(interp, "TK", "VISUAL", "NONE", NULL); return TCL_ERROR; } resultPtr = Tcl_NewObj(); for (i = 0; i < count; i++) { string = TkFindStateString(visualMap, visInfoPtr[i].class); if (string == NULL) { strcpy(buf, "unknown"); |
︙ | ︙ | |||
1856 1857 1858 1859 1860 1861 1862 | TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; if ((objc != 2) && (objc != 3)) { Tcl_WrongNumArgs(interp, 1, objv, "tracing ?boolean?"); return TCL_ERROR; } if (objc == 2) { | | | | 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 | TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; if ((objc != 2) && (objc != 3)) { Tcl_WrongNumArgs(interp, 1, objv, "tracing ?boolean?"); return TCL_ERROR; } if (objc == 2) { Tcl_SetObjResult(interp, Tcl_NewBooleanObj( dispPtr->flags & TK_DISPLAY_WM_TRACING)); return TCL_OK; } if (Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing) != TCL_OK) { return TCL_ERROR; } if (wmTracing) { dispPtr->flags |= TK_DISPLAY_WM_TRACING; |
︙ | ︙ | |||
1882 1883 1884 1885 1886 1887 1888 | winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin); if (winPtr == NULL) { return TCL_ERROR; } if (!(winPtr->flags & TK_TOP_LEVEL)) { | | | > > | 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 | winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin); if (winPtr == NULL) { return TCL_ERROR; } if (!(winPtr->flags & TK_TOP_LEVEL)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't a top-level window", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TOPLEVEL", winPtr->pathName, NULL); return TCL_ERROR; } switch ((enum options) index) { case TKWM_ASPECT: TkpWmAspectCmd(interp, tkwin, winPtr, objc, objv); break; |
︙ | ︙ | |||
2054 2055 2056 2057 2058 2059 2060 | if (objc < 1) { return 0; } string = Tcl_GetStringFromObj(objv[0], &length); if ((length >= 2) && (strncmp(string, "-displayof", (unsigned) length) == 0)) { if (objc < 2) { | > | < > | 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 | if (objc < 1) { return 0; } string = Tcl_GetStringFromObj(objv[0], &length); if ((length >= 2) && (strncmp(string, "-displayof", (unsigned) length) == 0)) { if (objc < 2) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "value for \"-displayof\" missing", -1)); Tcl_SetErrorCode(interp, "TK", "NO_VALUE", "DISPLAYOF", NULL); return -1; } *tkwinPtr = Tk_NameToWindow(interp, Tcl_GetString(objv[1]), *tkwinPtr); if (*tkwinPtr == NULL) { return -1; } return 2; |
︙ | ︙ | |||
2093 2094 2095 2096 2097 2098 2099 | int TkDeadAppCmd( ClientData clientData, /* Dummy. */ Tcl_Interp *interp, /* Current interpreter. */ int argc, /* Number of arguments. */ const char **argv) /* Argument strings. */ { | | | > | 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 | int TkDeadAppCmd( ClientData clientData, /* Dummy. */ Tcl_Interp *interp, /* Current interpreter. */ int argc, /* Number of arguments. */ const char **argv) /* Argument strings. */ { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't invoke \"%s\" command: application has been destroyed", argv[0])); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * GetTopHierarchy -- |
︙ | ︙ |
Changes to generic/tkColor.c.
︙ | ︙ | |||
220 221 222 223 224 225 226 | * The name isn't currently known. Map from the name to a pixel value. */ tkColPtr = TkpGetColor(tkwin, name); if (tkColPtr == NULL) { if (interp != NULL) { if (*name == '#') { | > | | > | | | 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | * The name isn't currently known. Map from the name to a pixel value. */ tkColPtr = TkpGetColor(tkwin, name); if (tkColPtr == NULL) { if (interp != NULL) { if (*name == '#') { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid color name \"%s\"", name)); Tcl_SetErrorCode(interp, "TK", "VALUE", "COLOR", NULL); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown color name \"%s\"", name)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "COLOR", name, NULL); } } if (isNew) { Tcl_DeleteHashEntry(nameHashPtr); } return NULL; } |
︙ | ︙ | |||
368 369 370 371 372 373 374 | } else { ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); sprintf(tsdPtr->rgbString, "#%04x%04x%04x", colorPtr->red, colorPtr->green, colorPtr->blue); | > | | | > | 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | } else { ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); sprintf(tsdPtr->rgbString, "#%04x%04x%04x", colorPtr->red, colorPtr->green, colorPtr->blue); /* * If the string has the form #RSRSTUTUVWVW (where equal letters * denote equal hexdigits) then this is equivalent to #RSTUVW. Then * output the shorter form. */ if ((tsdPtr->rgbString[1] == tsdPtr->rgbString[3]) && (tsdPtr->rgbString[2] == tsdPtr->rgbString[4]) && (tsdPtr->rgbString[5] == tsdPtr->rgbString[7]) && (tsdPtr->rgbString[6] == tsdPtr->rgbString[8]) && (tsdPtr->rgbString[9] == tsdPtr->rgbString[11]) && (tsdPtr->rgbString[10] == tsdPtr->rgbString[12])) { tsdPtr->rgbString[3] = tsdPtr->rgbString[5]; |
︙ | ︙ |
Changes to generic/tkConfig.c.
︙ | ︙ | |||
201 202 203 204 205 206 207 | * See if a table has already been created for this template. If so, just * reuse the existing table. */ hashEntryPtr = Tcl_CreateHashEntry(hashTablePtr, (char *) templatePtr, &newEntry); if (!newEntry) { | | | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | * See if a table has already been created for this template. If so, just * reuse the existing table. */ hashEntryPtr = Tcl_CreateHashEntry(hashTablePtr, (char *) templatePtr, &newEntry); if (!newEntry) { tablePtr = Tcl_GetHashValue(hashEntryPtr); tablePtr->refCount++; return (Tk_OptionTable) tablePtr; } /* * Count the number of options in the template, then create the table * structure. |
︙ | ︙ | |||
387 388 389 390 391 392 393 | DestroyOptionHashTable( ClientData clientData, /* The hash table we are destroying */ Tcl_Interp *interp) /* The interpreter we are destroying */ { Tcl_HashTable *hashTablePtr = clientData; Tcl_HashSearch search; Tcl_HashEntry *hashEntryPtr; | < | | 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | DestroyOptionHashTable( ClientData clientData, /* The hash table we are destroying */ Tcl_Interp *interp) /* The interpreter we are destroying */ { Tcl_HashTable *hashTablePtr = clientData; Tcl_HashSearch search; Tcl_HashEntry *hashEntryPtr; for (hashEntryPtr = Tcl_FirstHashEntry(hashTablePtr, &search); hashEntryPtr != NULL; hashEntryPtr = Tcl_NextHashEntry(&search)) { OptionTable *tablePtr = Tcl_GetHashValue(hashEntryPtr); /* * The following statements do two tricky things: * 1. They ensure that the option table is deleted, even if there are * outstanding references to it. * 2. They ensure that Tk_DeleteOptionTable doesn't delete other * tables chained from this one; we'll do it when we come across |
︙ | ︙ | |||
942 943 944 945 946 947 948 | &valuePtr, recordPtr, optionPtr->specPtr->internalOffset, (char *)oldInternalPtr, optionPtr->specPtr->flags) != TCL_OK) { return TCL_ERROR; } break; } | < < < > | | | < | 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 | &valuePtr, recordPtr, optionPtr->specPtr->internalOffset, (char *)oldInternalPtr, optionPtr->specPtr->flags) != TCL_OK) { return TCL_ERROR; } break; } default: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad config table: unknown type %d", optionPtr->specPtr->type)); Tcl_SetErrorCode(interp, "TK", "BAD_CONFIG", NULL); return TCL_ERROR; } /* * Release resources associated with the old value, if we're not returning * it to the caller, then install the new object value into the record. */ |
︙ | ︙ | |||
1157 1158 1159 1160 1161 1162 1163 | objPtr->internalRep.twoPtrValue.ptr2 = (void *) bestPtr; objPtr->typePtr = &optionObjType; tablePtr->refCount2++; return bestPtr; error: if (interp != NULL) { | > | > | 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 | objPtr->internalRep.twoPtrValue.ptr2 = (void *) bestPtr; objPtr->typePtr = &optionObjType; tablePtr->refCount2++; return bestPtr; error: if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown option \"%s\"", name)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "OPTION", name, NULL); } return NULL; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
1224 1225 1226 1227 1228 1229 1230 | */ static int SetOptionFromAny( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ register Tcl_Obj *objPtr) /* The object to convert. */ { | | > | | | 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 | */ static int SetOptionFromAny( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ register Tcl_Obj *objPtr) /* The object to convert. */ { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't convert value to option except via GetOptionFromObj API", -1)); Tcl_SetErrorCode(interp, "TK", "API_ABUSE", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * FreeOptionInternalRep -- * * Part of the option Tcl object type implementation. Frees the storage * associated with a option object's internal representation unless it |
︙ | ︙ | |||
1342 1343 1344 1345 1346 1347 1348 | } if (optionPtr->specPtr->type == TK_OPTION_SYNONYM) { optionPtr = optionPtr->extra.synonymPtr; } if (objc < 2) { if (interp != NULL) { | > | | > | 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 | } if (optionPtr->specPtr->type == TK_OPTION_SYNONYM) { optionPtr = optionPtr->extra.synonymPtr; } if (objc < 2) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetStringFromObj(*objv, NULL))); Tcl_SetErrorCode(interp, "TK", "VALUE_MISSING", NULL); goto error; } } if ((savePtr != NULL) && (lastSavePtr->numItems >= TK_NUM_SAVED_OPTIONS)) { /* * We've run out of space for saving old option values. Allocate |
︙ | ︙ | |||
1365 1366 1367 1368 1369 1370 1371 | newSavePtr->nextPtr = NULL; lastSavePtr->nextPtr = newSavePtr; lastSavePtr = newSavePtr; } if (DoObjConfig(interp, recordPtr, optionPtr, objv[1], tkwin, (savePtr != NULL) ? &lastSavePtr->items[lastSavePtr->numItems] : NULL) != TCL_OK) { | < | | | < | 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 | newSavePtr->nextPtr = NULL; lastSavePtr->nextPtr = newSavePtr; lastSavePtr = newSavePtr; } if (DoObjConfig(interp, recordPtr, optionPtr, objv[1], tkwin, (savePtr != NULL) ? &lastSavePtr->items[lastSavePtr->numItems] : NULL) != TCL_OK) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( "\n (processing \"%.40s\" option)", Tcl_GetStringFromObj(*objv, NULL))); goto error; } if (savePtr != NULL) { lastSavePtr->numItems++; } mask |= optionPtr->specPtr->typeMask; } |
︙ | ︙ | |||
1767 1768 1769 1770 1771 1772 1773 | * * Tk_GetOptionInfo -- * * Returns a list object containing complete information about either a * single option or all the configuration options in a table. * * Results: | < | 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 | * * Tk_GetOptionInfo -- * * Returns a list object containing complete information about either a * single option or all the configuration options in a table. * * Results: * This function normally returns a pointer to an object. If namePtr * isn't NULL, then the result object is a list with five elements: the * option's name, its database name, database class, default value, and * current value. If the option is a synonym then the list will contain * only two values: the option name and the name of the option it refers * to. If namePtr is NULL, then information is returned for every option * in the option table: the result will have one sub-list (in the form |
︙ | ︙ | |||
2150 2151 2152 2153 2154 2155 2156 | OptionTable *tablePtr = (OptionTable *) table; Tcl_HashTable *hashTablePtr; Tcl_HashEntry *hashEntryPtr; Tcl_HashSearch search; Tcl_Obj *objPtr; objPtr = Tcl_NewObj(); | | < | 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 | OptionTable *tablePtr = (OptionTable *) table; Tcl_HashTable *hashTablePtr; Tcl_HashEntry *hashEntryPtr; Tcl_HashSearch search; Tcl_Obj *objPtr; objPtr = Tcl_NewObj(); hashTablePtr = Tcl_GetAssocData(interp, OPTION_HASH_KEY, NULL); if (hashTablePtr == NULL) { return objPtr; } /* * Scan all the tables for this interpreter to make sure that the one we * want still is valid. |
︙ | ︙ |
Changes to generic/tkConsole.c.
︙ | ︙ | |||
743 744 745 746 747 748 749 | Tcl_Preserve(consoleInterp); result = Tcl_GlobalEvalObj(consoleInterp, cmd); Tcl_SetReturnOptions(interp, Tcl_GetReturnOptions(consoleInterp, result)); Tcl_SetObjResult(interp, Tcl_GetObjResult(consoleInterp)); Tcl_Release(consoleInterp); } else { | > | > | 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 | Tcl_Preserve(consoleInterp); result = Tcl_GlobalEvalObj(consoleInterp, cmd); Tcl_SetReturnOptions(interp, Tcl_GetReturnOptions(consoleInterp, result)); Tcl_SetObjResult(interp, Tcl_GetObjResult(consoleInterp)); Tcl_Release(consoleInterp); } else { Tcl_SetObjResult(interp, Tcl_NewStringObj( "no active console interp", -1)); Tcl_SetErrorCode(interp, "TK", "CONSOLE", "NONE", NULL); result = TCL_ERROR; } Tcl_DecrRefCount(cmd); return result; } /* |
︙ | ︙ | |||
792 793 794 795 796 797 798 | if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "script"); return TCL_ERROR; } if ((otherInterp == NULL) || Tcl_InterpDeleted(otherInterp)) { | > | > | 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 | if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "script"); return TCL_ERROR; } if ((otherInterp == NULL) || Tcl_InterpDeleted(otherInterp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "no active master interp", -1)); Tcl_SetErrorCode(interp, "TK", "CONSOLE", "NO_INTERP", NULL); return TCL_ERROR; } Tcl_Preserve(otherInterp); switch ((enum option) index) { case OTHER_EVAL: result = Tcl_GlobalEvalObj(otherInterp, objv[2]); |
︙ | ︙ |
Changes to generic/tkCursor.c.
︙ | ︙ | |||
348 349 350 351 352 353 354 | /* * No suitable cursor exists yet. Make one using the data available and * add it to the database. */ if (TkParseColor(dataKey.display, Tk_Colormap(tkwin), fg, &fgColor) == 0) { | > | > > | > | 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | /* * No suitable cursor exists yet. Make one using the data available and * add it to the database. */ if (TkParseColor(dataKey.display, Tk_Colormap(tkwin), fg, &fgColor) == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid color name \"%s\"", fg)); Tcl_SetErrorCode(interp, "TK", "VALUE", "CURSOR", "COLOR", NULL); goto error; } if (TkParseColor(dataKey.display, Tk_Colormap(tkwin), bg, &bgColor) == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid color name \"%s\"", bg)); Tcl_SetErrorCode(interp, "TK", "VALUE", "CURSOR", "COLOR", NULL); goto error; } cursorPtr = TkCreateCursorFromData(tkwin, source, mask, width, height, xHot, yHot, fgColor, bgColor); if (cursorPtr == NULL) { |
︙ | ︙ |
Changes to generic/tkEntry.c.
︙ | ︙ | |||
445 446 447 448 449 450 451 | * The structure below defines widget class behavior by means of functions * that can be invoked from generic window code. */ static const Tk_ClassProcs entryClass = { sizeof(Tk_ClassProcs), /* size */ EntryWorldChanged, /* worldChangedProc */ | | | | 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | * The structure below defines widget class behavior by means of functions * that can be invoked from generic window code. */ static const Tk_ClassProcs entryClass = { sizeof(Tk_ClassProcs), /* size */ EntryWorldChanged, /* worldChangedProc */ NULL, /* createProc */ NULL /* modalProc */ }; /* *-------------------------------------------------------------- * * Tk_EntryObjCmd -- * |
︙ | ︙ | |||
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 | return result; } Tcl_Preserve(entryPtr); switch ((enum entryCmd) cmdIndex) { case COMMAND_BBOX: { int index, x, y, width, height; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "index"); goto error; } if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), &index) != TCL_OK) { goto error; } if ((index == entryPtr->numChars) && (index > 0)) { index--; } Tk_CharBbox(entryPtr->textLayout, index, &x, &y, &width, &height); | > > > > > | < | 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 | return result; } Tcl_Preserve(entryPtr); switch ((enum entryCmd) cmdIndex) { case COMMAND_BBOX: { int index, x, y, width, height; Tcl_Obj *bbox[4]; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "index"); goto error; } if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), &index) != TCL_OK) { goto error; } if ((index == entryPtr->numChars) && (index > 0)) { index--; } Tk_CharBbox(entryPtr->textLayout, index, &x, &y, &width, &height); bbox[0] = Tcl_NewIntObj(x + entryPtr->layoutX); bbox[1] = Tcl_NewIntObj(y + entryPtr->layoutY); bbox[2] = Tcl_NewIntObj(width); bbox[3] = Tcl_NewIntObj(height); Tcl_SetObjResult(interp, Tcl_NewListObj(4, bbox)); break; } case COMMAND_CGET: if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "option"); goto error; |
︙ | ︙ | |||
751 752 753 754 755 756 757 | && (strncmp(minorCmd, "mark", strlen(minorCmd)) == 0)) { entryPtr->scanMarkX = x; entryPtr->scanMarkIndex = entryPtr->leftIndex; } else if ((minorCmd[0] == 'd') && (strncmp(minorCmd, "dragto", strlen(minorCmd)) == 0)) { EntryScanTo(entryPtr, x); } else { | | | > > | | 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 | && (strncmp(minorCmd, "mark", strlen(minorCmd)) == 0)) { entryPtr->scanMarkX = x; entryPtr->scanMarkIndex = entryPtr->leftIndex; } else if ((minorCmd[0] == 'd') && (strncmp(minorCmd, "dragto", strlen(minorCmd)) == 0)) { EntryScanTo(entryPtr, x); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad scan option \"%s\": must be mark or dragto", minorCmd)); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "scan option", minorCmd, NULL); goto error; } break; } case COMMAND_SELECTION: { int index, index2; |
︙ | ︙ | |||
847 848 849 850 851 852 853 | case SELECTION_PRESENT: if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); goto error; } Tcl_SetObjResult(interp, | | | 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 | case SELECTION_PRESENT: if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); goto error; } Tcl_SetObjResult(interp, Tcl_NewBooleanObj(entryPtr->selectFirst >= 0)); goto done; case SELECTION_RANGE: if (objc != 5) { Tcl_WrongNumArgs(interp, 3, objv, "start end"); goto error; } |
︙ | ︙ | |||
908 909 910 911 912 913 914 | selIndex = entryPtr->validate; entryPtr->validate = VALIDATE_ALL; code = EntryValidateChange(entryPtr, NULL, entryPtr->string, -1, VALIDATE_FORCED); if (entryPtr->validate != VALIDATE_NONE) { entryPtr->validate = selIndex; } | | | | < | | | 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 | selIndex = entryPtr->validate; entryPtr->validate = VALIDATE_ALL; code = EntryValidateChange(entryPtr, NULL, entryPtr->string, -1, VALIDATE_FORCED); if (entryPtr->validate != VALIDATE_NONE) { entryPtr->validate = selIndex; } Tcl_SetObjResult(interp, Tcl_NewBooleanObj(code == TCL_OK)); break; } case COMMAND_XVIEW: { int index; if (objc == 2) { double first, last; Tcl_Obj *span[2]; EntryVisibleRange(entryPtr, &first, &last); span[0] = Tcl_NewDoubleObj(first); span[1] = Tcl_NewDoubleObj(last); Tcl_SetObjResult(interp, Tcl_NewListObj(2, span)); goto done; } else if (objc == 3) { if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), &index) != TCL_OK) { goto error; } } else { |
︙ | ︙ | |||
1161 1162 1163 1164 1165 1166 1167 | } if (entryPtr->insertBorderWidth > entryPtr->insertWidth/2) { entryPtr->insertBorderWidth = entryPtr->insertWidth/2; } if (entryPtr->type == TK_SPINBOX) { if (sbPtr->fromValue > sbPtr->toValue) { | | | > > | > | | > > | 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 | } if (entryPtr->insertBorderWidth > entryPtr->insertWidth/2) { entryPtr->insertBorderWidth = entryPtr->insertWidth/2; } if (entryPtr->type == TK_SPINBOX) { if (sbPtr->fromValue > sbPtr->toValue) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "-to value must be greater than -from value", -1)); Tcl_SetErrorCode(interp, "TK", "SPINBOX", "RANGE_SANITY", NULL); continue; } if (sbPtr->reqFormat && (oldFormat != sbPtr->reqFormat)) { /* * Make sure that the given format is somewhat correct, and * calculate the minimum space we'll need for the values as * strings. */ int min, max; size_t formatLen, formatSpace = TCL_DOUBLE_SPACE; char fbuf[4], *fmt = sbPtr->reqFormat; formatLen = strlen(fmt); if ((fmt[0] != '%') || (fmt[formatLen-1] != 'f')) { badFormatOpt: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad spinbox format specifier \"%s\"", sbPtr->reqFormat)); Tcl_SetErrorCode(interp, "TK", "SPINBOX", "FORMAT_SANITY", NULL); continue; } if ((sscanf(fmt, "%%%d.%d%[f]", &min, &max, fbuf) == 3) && (max >= 0)) { formatSpace = min + max + 1; } else if (((sscanf(fmt, "%%.%d%[f]", &min, fbuf) == 2) || (sscanf(fmt, "%%%d%[f]", &min, fbuf) == 2) |
︙ | ︙ | |||
2524 2525 2526 2527 2528 2529 2530 | goto badIndex; } *indexPtr = entryPtr->insertPos; break; case 's': if (entryPtr->selectFirst < 0) { Tcl_ResetResult(interp); | > | | > > > | 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 | goto badIndex; } *indexPtr = entryPtr->insertPos; break; case 's': if (entryPtr->selectFirst < 0) { Tcl_ResetResult(interp); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "selection isn't in widget %s", Tk_PathName(entryPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", (entryPtr->type == TK_ENTRY) ? "ENTRY" : "SPINBOX", "NO_SELECTION", NULL); return TCL_ERROR; } if (length < 5) { goto badIndex; } if (strncmp(string, "sel.first", length) == 0) { *indexPtr = entryPtr->selectFirst; |
︙ | ︙ | |||
2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 | } } return TCL_OK; badIndex: Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad %s index \"%s\"", (entryPtr->type == TK_ENTRY) ? "entry" : "spinbox", string)); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * EntryScanTo -- | > > > | 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 | } } return TCL_OK; badIndex: Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad %s index \"%s\"", (entryPtr->type == TK_ENTRY) ? "entry" : "spinbox", string)); Tcl_SetErrorCode(interp, "TK", (entryPtr->type == TK_ENTRY) ? "ENTRY" : "SPINBOX", "BAD_INDEX", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * EntryScanTo -- |
︙ | ︙ | |||
2931 2932 2933 2934 2935 2936 2937 | Tcl_Preserve(interp); EntryVisibleRange(entryPtr, &first, &last); Tcl_PrintDouble(NULL, first, firstStr); Tcl_PrintDouble(NULL, last, lastStr); code = Tcl_VarEval(interp, entryPtr->scrollCmd, " ", firstStr, " ", lastStr, NULL); if (code != TCL_OK) { | | | | < | 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 | Tcl_Preserve(interp); EntryVisibleRange(entryPtr, &first, &last); Tcl_PrintDouble(NULL, first, firstStr); Tcl_PrintDouble(NULL, last, lastStr); code = Tcl_VarEval(interp, entryPtr->scrollCmd, " ", firstStr, " ", lastStr, NULL); if (code != TCL_OK) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( "\n (horizontal scrolling command executed by %s)", Tk_PathName(entryPtr->tkwin))); Tcl_BackgroundException(interp, code); } Tcl_ResetResult(interp); Tcl_Release(interp); } /* |
︙ | ︙ | |||
3137 3138 3139 3140 3141 3142 3143 | /* * We accept TCL_OK and TCL_RETURN as valid return codes from the command * callback. */ if (code != TCL_OK && code != TCL_RETURN) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( | | | | 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 | /* * We accept TCL_OK and TCL_RETURN as valid return codes from the command * callback. */ if (code != TCL_OK && code != TCL_RETURN) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( "\n (in validation command executed by %s)", Tk_PathName(entryPtr->tkwin))); Tcl_BackgroundException(interp, code); return TCL_ERROR; } /* * The command callback should return an acceptable Tcl boolean. */ if (Tcl_GetBooleanFromObj(interp, Tcl_GetObjResult(interp), &bool) != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (invalid boolean result from validation command)"); Tcl_BackgroundError(interp); Tcl_ResetResult(interp); return TCL_ERROR; } Tcl_ResetResult(interp); return (bool ? TCL_OK : TCL_BREAK); |
︙ | ︙ | |||
3276 3277 3278 3279 3280 3281 3282 | change, newValue, index, type, &script); Tcl_DStringAppend(&script, "", 1); p = Tcl_DStringValue(&script); result = Tcl_EvalEx(entryPtr->interp, p, -1, TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); if (result != TCL_OK) { Tcl_AddErrorInfo(entryPtr->interp, | | | 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 | change, newValue, index, type, &script); Tcl_DStringAppend(&script, "", 1); p = Tcl_DStringValue(&script); result = Tcl_EvalEx(entryPtr->interp, p, -1, TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); if (result != TCL_OK) { Tcl_AddErrorInfo(entryPtr->interp, "\n (in invalidcommand executed by entry)"); Tcl_BackgroundException(entryPtr->interp, result); code = TCL_ERROR; entryPtr->validate = VALIDATE_NONE; } Tcl_DStringFree(&script); /* |
︙ | ︙ | |||
3588 3589 3590 3591 3592 3593 3594 | Tk_DestroyWindow(entryPtr->tkwin); return TCL_ERROR; } if (ConfigureEntry(interp, entryPtr, objc-2, objv+2, 0) != TCL_OK) { goto error; } | | | 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 | Tk_DestroyWindow(entryPtr->tkwin); return TCL_ERROR; } if (ConfigureEntry(interp, entryPtr, objc-2, objv+2, 0) != TCL_OK) { goto error; } Tcl_SetObjResult(interp, TkNewWindowObj(entryPtr->tkwin)); return TCL_OK; error: Tk_DestroyWindow(entryPtr->tkwin); return TCL_ERROR; } |
︙ | ︙ | |||
3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 | return result; } Tcl_Preserve(entryPtr); switch ((enum sbCmd) cmdIndex) { case SB_CMD_BBOX: { int index, x, y, width, height; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "index"); goto error; } if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), &index) != TCL_OK) { goto error; } if ((index == entryPtr->numChars) && (index > 0)) { index--; } Tk_CharBbox(entryPtr->textLayout, index, &x, &y, &width, &height); | > > > > > | < | 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 | return result; } Tcl_Preserve(entryPtr); switch ((enum sbCmd) cmdIndex) { case SB_CMD_BBOX: { int index, x, y, width, height; Tcl_Obj *bbox[4]; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "index"); goto error; } if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), &index) != TCL_OK) { goto error; } if ((index == entryPtr->numChars) && (index > 0)) { index--; } Tk_CharBbox(entryPtr->textLayout, index, &x, &y, &width, &height); bbox[0] = Tcl_NewIntObj(x + entryPtr->layoutX); bbox[1] = Tcl_NewIntObj(y + entryPtr->layoutY); bbox[2] = Tcl_NewIntObj(width); bbox[3] = Tcl_NewIntObj(height); Tcl_SetObjResult(interp, Tcl_NewListObj(4, bbox)); break; } case SB_CMD_CGET: if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "option"); goto error; |
︙ | ︙ | |||
3826 3827 3828 3829 3830 3831 3832 | && (strncmp(minorCmd, "mark", strlen(minorCmd)) == 0)) { entryPtr->scanMarkX = x; entryPtr->scanMarkIndex = entryPtr->leftIndex; } else if ((minorCmd[0] == 'd') && (strncmp(minorCmd, "dragto", strlen(minorCmd)) == 0)) { EntryScanTo(entryPtr, x); } else { | | | > > | | 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 | && (strncmp(minorCmd, "mark", strlen(minorCmd)) == 0)) { entryPtr->scanMarkX = x; entryPtr->scanMarkIndex = entryPtr->leftIndex; } else if ((minorCmd[0] == 'd') && (strncmp(minorCmd, "dragto", strlen(minorCmd)) == 0)) { EntryScanTo(entryPtr, x); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad scan option \"%s\": must be mark or dragto", minorCmd)); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "scan option", minorCmd, NULL); goto error; } break; } case SB_CMD_SELECTION: { int index, index2; |
︙ | ︙ | |||
3921 3922 3923 3924 3925 3926 3927 | break; case SB_SEL_PRESENT: if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); goto error; } | | | | 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 | break; case SB_SEL_PRESENT: if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); goto error; } Tcl_SetObjResult(interp, Tcl_NewBooleanObj( entryPtr->selectFirst >= 0)); goto done; case SB_SEL_RANGE: if (objc != 5) { Tcl_WrongNumArgs(interp, 3, objv, "start end"); goto error; } |
︙ | ︙ | |||
4026 4027 4028 4029 4030 4031 4032 | } case SB_CMD_XVIEW: { int index; if (objc == 2) { double first, last; | | | < | | | 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 | } case SB_CMD_XVIEW: { int index; if (objc == 2) { double first, last; Tcl_Obj *span[2]; EntryVisibleRange(entryPtr, &first, &last); span[0] = Tcl_NewDoubleObj(first); span[1] = Tcl_NewDoubleObj(last); Tcl_SetObjResult(interp, Tcl_NewListObj(2, span)); goto done; } else if (objc == 3) { if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), &index) != TCL_OK) { goto error; } } else { |
︙ | ︙ | |||
4280 4281 4282 4283 4284 4285 4286 | Tcl_DStringAppend(&script, "", 1); code = Tcl_EvalEx(interp, Tcl_DStringValue(&script), -1, TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); Tcl_DStringFree(&script); if (code != TCL_OK) { | | > | 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 | Tcl_DStringAppend(&script, "", 1); code = Tcl_EvalEx(interp, Tcl_DStringValue(&script), -1, TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); Tcl_DStringFree(&script); if (code != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (in command executed by spinbox)"); Tcl_BackgroundException(interp, code); /* * Yes, it's an error, but a bg one, so we return OK */ return TCL_OK; |
︙ | ︙ |
Changes to generic/tkEvent.c.
︙ | ︙ | |||
1332 1333 1334 1335 1336 1337 1338 | } else { InvokeClientMessageHandlers(tsdPtr, (Tk_Window) winPtr, eventPtr); } } } else { for (handlerPtr = winPtr->handlerList; handlerPtr != NULL; ) { | | | 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 | } else { InvokeClientMessageHandlers(tsdPtr, (Tk_Window) winPtr, eventPtr); } } } else { for (handlerPtr = winPtr->handlerList; handlerPtr != NULL; ) { if (handlerPtr->mask & mask) { ip.nextHandler = handlerPtr->nextPtr; handlerPtr->proc(handlerPtr->clientData, eventPtr); handlerPtr = ip.nextHandler; } else { handlerPtr = handlerPtr->nextPtr; } } |
︙ | ︙ |
Changes to generic/tkFileFilter.c.
︙ | ︙ | |||
116 117 118 119 120 121 122 | if (Tcl_ListObjGetElements(interp, listObjv[i], &count, &typeInfo) != TCL_OK) { return TCL_ERROR; } if (count != 2 && count != 3) { | | | | | > > | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | if (Tcl_ListObjGetElements(interp, listObjv[i], &count, &typeInfo) != TCL_OK) { return TCL_ERROR; } if (count != 2 && count != 3) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad file type \"%s\", should be " "\"typeName {extension ?extensions ...?} " "?{macType ?macTypes ...?}?\"", Tcl_GetString(listObjv[i]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "FILE_TYPE", NULL); return TCL_ERROR; } filterPtr = GetFilter(flistPtr, Tcl_GetString(typeInfo[0])); if (AddClause(interp, filterPtr, typeInfo[1], (count==2 ? NULL : typeInfo[2]), isWindows) != TCL_OK) { |
︙ | ︙ | |||
285 286 287 288 289 290 291 | */ Tcl_UtfToExternalDString(macRoman, strType, len, &osTypeDS); len = Tcl_DStringLength(&osTypeDS); Tcl_DStringFree(&osTypeDS); } if (len != 4) { | > | | > | 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | */ Tcl_UtfToExternalDString(macRoman, strType, len, &osTypeDS); len = Tcl_DStringLength(&osTypeDS); Tcl_DStringFree(&osTypeDS); } if (len != 4) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad Macintosh file type \"%s\"", Tcl_GetString(ostypeList[i]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "MAC_TYPE", NULL); code = TCL_ERROR; goto done; } } } /* |
︙ | ︙ |
Changes to generic/tkFocus.c.
︙ | ︙ | |||
111 112 113 114 115 116 117 | Tcl_Obj *const objv[]) /* Argument objects. */ { static const char *const focusOptions[] = { "-displayof", "-force", "-lastfor", NULL }; Tk_Window tkwin = clientData; TkWindow *winPtr = clientData; | | | > | | | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | Tcl_Obj *const objv[]) /* Argument objects. */ { static const char *const focusOptions[] = { "-displayof", "-force", "-lastfor", NULL }; Tk_Window tkwin = clientData; TkWindow *winPtr = clientData; TkWindow *newPtr, *topLevelPtr; ToplevelFocusInfo *tlFocusPtr; const char *windowName; int index; /* * If invoked with no arguments, just return the current focus window. */ if (objc == 1) { Tk_Window focusWin = (Tk_Window) TkGetFocusWin(winPtr); if (focusWin != NULL) { Tcl_SetObjResult(interp, TkNewWindowObj(focusWin)); } return TCL_OK; } /* * If invoked with a single argument beginning with "." then focus on that * window. |
︙ | ︙ | |||
176 177 178 179 180 181 182 | windowName = Tcl_GetString(objv[2]); newPtr = (TkWindow *) Tk_NameToWindow(interp, windowName, tkwin); if (newPtr == NULL) { return TCL_ERROR; } newPtr = TkGetFocusWin(newPtr); if (newPtr != NULL) { | | | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | windowName = Tcl_GetString(objv[2]); newPtr = (TkWindow *) Tk_NameToWindow(interp, windowName, tkwin); if (newPtr == NULL) { return TCL_ERROR; } newPtr = TkGetFocusWin(newPtr); if (newPtr != NULL) { Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window) newPtr)); } break; case 1: /* -force */ windowName = Tcl_GetString(objv[2]); /* * The empty string case exists for backwards compatibility. |
︙ | ︙ | |||
209 210 211 212 213 214 215 | topLevelPtr = topLevelPtr->parentPtr) { if (!(topLevelPtr->flags & TK_TOP_HIERARCHY)) { continue; } for (tlFocusPtr = newPtr->mainPtr->tlFocusPtr; tlFocusPtr != NULL; tlFocusPtr = tlFocusPtr->nextPtr) { if (tlFocusPtr->topLevelPtr == topLevelPtr) { | | | | | 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | topLevelPtr = topLevelPtr->parentPtr) { if (!(topLevelPtr->flags & TK_TOP_HIERARCHY)) { continue; } for (tlFocusPtr = newPtr->mainPtr->tlFocusPtr; tlFocusPtr != NULL; tlFocusPtr = tlFocusPtr->nextPtr) { if (tlFocusPtr->topLevelPtr == topLevelPtr) { Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window) tlFocusPtr->focusWinPtr)); return TCL_OK; } } Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window) topLevelPtr)); return TCL_OK; } break; default: Tcl_Panic("bad const entries to focusOptions in focus command"); } return TCL_OK; |
︙ | ︙ |
Changes to generic/tkFont.c.
︙ | ︙ | |||
435 436 437 438 439 440 441 | hPtr = Tcl_FirstHashEntry(&fiPtr->namedTable, &search); while (hPtr != NULL) { ckfree(Tcl_GetHashValue(hPtr)); hPtr = Tcl_NextHashEntry(&search); } Tcl_DeleteHashTable(&fiPtr->namedTable); | | | 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | hPtr = Tcl_FirstHashEntry(&fiPtr->namedTable, &search); while (hPtr != NULL) { ckfree(Tcl_GetHashValue(hPtr)); hPtr = Tcl_NextHashEntry(&search); } Tcl_DeleteHashTable(&fiPtr->namedTable); if (fiPtr->updatePending) { Tcl_CancelIdleCall(TheWorldHasChanged, fiPtr); } ckfree(fiPtr); } /* *--------------------------------------------------------------------------- |
︙ | ︙ | |||
565 566 567 568 569 570 571 572 573 574 575 576 577 578 | if (Tcl_GetCharLength(charPtr) != 1) { resultPtr = Tcl_NewStringObj( "expected a single character but got \"", -1); Tcl_AppendLimitedToObj(resultPtr, Tcl_GetString(charPtr), -1, 40, "..."); Tcl_AppendToObj(resultPtr, "\"", -1); Tcl_SetObjResult(interp, resultPtr); return TCL_ERROR; } uniChar = Tcl_GetUniChar(charPtr, 0); } /* * Find the font. | > | 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | if (Tcl_GetCharLength(charPtr) != 1) { resultPtr = Tcl_NewStringObj( "expected a single character but got \"", -1); Tcl_AppendLimitedToObj(resultPtr, Tcl_GetString(charPtr), -1, 40, "..."); Tcl_AppendToObj(resultPtr, "\"", -1); Tcl_SetObjResult(interp, resultPtr); Tcl_SetErrorCode(interp, "TK", "VALUE", "FONT_SAMPLE", NULL); return TCL_ERROR; } uniChar = Tcl_GetUniChar(charPtr, 0); } /* * Find the font. |
︙ | ︙ | |||
611 612 613 614 615 616 617 | } string = Tcl_GetString(objv[2]); namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, string); nfPtr = NULL; /* lint. */ if (namedHashPtr != NULL) { nfPtr = Tcl_GetHashValue(namedHashPtr); } | | | | > | 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 | } string = Tcl_GetString(objv[2]); namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, string); nfPtr = NULL; /* lint. */ if (namedHashPtr != NULL) { nfPtr = 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; } if (objc == 3) { objPtr = NULL; } else if (objc == 4) { objPtr = objv[3]; } else { |
︙ | ︙ | |||
666 667 668 669 670 671 672 | if (ConfigAttributesObj(interp, tkwin, objc - skip, objv + skip, &fa) != TCL_OK) { return TCL_ERROR; } if (TkCreateNamedFont(interp, tkwin, name, &fa) != TCL_OK) { return TCL_ERROR; } | | | | 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 | if (ConfigAttributesObj(interp, tkwin, objc - skip, objv + skip, &fa) != TCL_OK) { return TCL_ERROR; } if (TkCreateNamedFont(interp, tkwin, name, &fa) != TCL_OK) { return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewStringObj(name, -1)); break; } case FONT_DELETE: { int i, result = TCL_OK; const char *string; /* * Delete the named font. If there are still widgets using this font, * then it isn't deleted right away. */ if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, "fontname ?fontname ...?"); return TCL_ERROR; } for (i = 2; (i < objc) && (result == TCL_OK); i++) { string = Tcl_GetString(objv[i]); result = TkDeleteNamedFont(interp, tkwin, string); } return result; } case FONT_FAMILIES: { int skip = TkGetDisplayOf(interp, objc - 2, objv + 2, &tkwin); |
︙ | ︙ | |||
722 723 724 725 726 727 728 | return TCL_ERROR; } tkfont = Tk_AllocFontFromObj(interp, tkwin, objv[2]); if (tkfont == NULL) { return TCL_ERROR; } string = Tcl_GetStringFromObj(objv[3 + skip], &length); | | | | 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 | return TCL_ERROR; } tkfont = Tk_AllocFontFromObj(interp, tkwin, objv[2]); if (tkfont == NULL) { return TCL_ERROR; } string = Tcl_GetStringFromObj(objv[3 + skip], &length); Tcl_SetObjResult(interp, Tcl_NewIntObj( Tk_TextWidth(tkfont, string, length))); Tk_FreeFont(tkfont); break; } case FONT_METRICS: { Tk_Font tkfont; int skip, index, i; const TkFontMetrics *fmPtr; |
︙ | ︙ | |||
788 789 790 791 792 793 794 | return TCL_ERROR; } resultPtr = Tcl_NewObj(); namedHashPtr = Tcl_FirstHashEntry(&fiPtr->namedTable, &search); while (namedHashPtr != NULL) { NamedFont *nfPtr = Tcl_GetHashValue(namedHashPtr); | | | 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 | return TCL_ERROR; } resultPtr = Tcl_NewObj(); namedHashPtr = Tcl_FirstHashEntry(&fiPtr->namedTable, &search); while (namedHashPtr != NULL) { NamedFont *nfPtr = Tcl_GetHashValue(namedHashPtr); if (!nfPtr->deletePending) { char *string = Tcl_GetHashKey(&fiPtr->namedTable, namedHashPtr); Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(string, -1)); } namedHashPtr = Tcl_NextHashEntry(&search); |
︙ | ︙ | |||
849 850 851 852 853 854 855 | cacheHashPtr = Tcl_FirstHashEntry(&fiPtr->fontCache, &search); while (cacheHashPtr != NULL) { for (fontPtr = Tcl_GetHashValue(cacheHashPtr); fontPtr != NULL; fontPtr = fontPtr->nextPtr) { if (fontPtr->namedHashPtr == namedHashPtr) { TkpGetFontFromAttributes(fontPtr, tkwin, &nfPtr->fa); | | | 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 | cacheHashPtr = Tcl_FirstHashEntry(&fiPtr->fontCache, &search); while (cacheHashPtr != NULL) { for (fontPtr = 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); } |
︙ | ︙ | |||
943 944 945 946 947 948 949 | Tcl_HashEntry *namedHashPtr; int isNew; NamedFont *nfPtr; namedHashPtr = Tcl_CreateHashEntry(&fiPtr->namedTable, name, &isNew); if (!isNew) { nfPtr = Tcl_GetHashValue(namedHashPtr); | | | | > | 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 | Tcl_HashEntry *namedHashPtr; int isNew; NamedFont *nfPtr; namedHashPtr = Tcl_CreateHashEntry(&fiPtr->namedTable, name, &isNew); if (!isNew) { nfPtr = 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; } /* * Recreating a named font with the same name as a previous named * font. Some widgets were still using that named font, so they need |
︙ | ︙ | |||
996 997 998 999 1000 1001 1002 | TkFontInfo *fiPtr = ((TkWindow *) tkwin)->mainPtr->fontInfoPtr; NamedFont *nfPtr; Tcl_HashEntry *namedHashPtr; namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, name); if (namedHashPtr == NULL) { if (interp) { | | | > | 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 | TkFontInfo *fiPtr = ((TkWindow *) tkwin)->mainPtr->fontInfoPtr; NamedFont *nfPtr; Tcl_HashEntry *namedHashPtr; namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, name); if (namedHashPtr == NULL) { 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 = Tcl_GetHashValue(namedHashPtr); if (nfPtr->refCount != 0) { nfPtr->deletePending = 1; } else { |
︙ | ︙ | |||
1179 1180 1181 1182 1183 1184 1185 | * Detect the system font engine going wrong and fail more gracefully. */ if (fontPtr == NULL) { if (isNew) { Tcl_DeleteHashEntry(cacheHashPtr); } | > | | > | 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 | * Detect the system font engine going wrong and fail more gracefully. */ if (fontPtr == NULL) { if (isNew) { Tcl_DeleteHashEntry(cacheHashPtr); } Tcl_SetObjResult(interp, Tcl_NewStringObj( "failed to allocate font due to internal system font engine" " problem", -1)); Tcl_SetErrorCode(interp, "TK", "FONT", "INTERNAL_PROBLEM", NULL); return NULL; } fontPtr->resourceRefCount = 1; fontPtr->objRefCount = 1; fontPtr->cacheHashPtr = cacheHashPtr; fontPtr->namedHashPtr = namedHashPtr; |
︙ | ︙ | |||
1417 1418 1419 1420 1421 1422 1423 | /* * 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 = Tcl_GetHashValue(fontPtr->namedHashPtr); nfPtr->refCount--; | | | 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 | /* * 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 = Tcl_GetHashValue(fontPtr->namedHashPtr); nfPtr->refCount--; if ((nfPtr->refCount == 0) && nfPtr->deletePending) { Tcl_DeleteHashEntry(fontPtr->namedHashPtr); ckfree(nfPtr); } } prevPtr = Tcl_GetHashValue(fontPtr->cacheHashPtr); if (prevPtr == fontPtr) { |
︙ | ︙ | |||
1745 1746 1747 1748 1749 1750 1751 | /* * Get the string to use for the slant. */ slantString = NULL; if (fontPtr->fa.slant == TK_FS_ROMAN) { | < > | 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 | /* * Get the string to use for the slant. */ slantString = NULL; if (fontPtr->fa.slant == TK_FS_ROMAN) { /* Do nothing */ } else if ((strcmp(family, "Helvetica") == 0) || (strcmp(family, "Courier") == 0) || (strcmp(family, "AvantGarde") == 0)) { slantString = "Oblique"; } else { slantString = "Italic"; } |
︙ | ︙ | |||
2133 2134 2135 2136 2137 2138 2139 | } /* * If last line ends with a newline, then we need to make a 0 width chunk * on the next line. Otherwise "Hello" and "Hello\n" are the same height. */ | | | 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 | } /* * If last line ends with a newline, then we need to make a 0 width chunk * on the next line. Otherwise "Hello" and "Hello\n" are the same height. */ if ((layoutPtr->numChunks > 0) && !(flags & TK_IGNORE_NEWLINES)) { if (layoutPtr->chunks[layoutPtr->numChunks - 1].start[0] == '\n') { chunkPtr = NewChunk(&layoutPtr, &maxChunks, start, 0, curX, curX, baseline); chunkPtr->numDisplayChars = -1; Tcl_DStringAppend(&lineBuffer, (char *) &curX, sizeof(curX)); baseline += height; } |
︙ | ︙ | |||
2895 2896 2897 2898 2899 2900 2901 | left = x; top = y; right = x + width; bottom = y + height; result = 0; for (i = 0; i < layoutPtr->numChunks; i++) { | | | 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 | left = x; top = y; right = x + width; bottom = y + height; result = 0; for (i = 0; i < layoutPtr->numChunks; i++) { if ((chunkPtr->start[0] == '\n') || (chunkPtr->numBytes == 0)) { /* * Newline characters and empty chunks are not counted when * computing area intersection (but tab characters would still be * considered). */ chunkPtr++; |
︙ | ︙ | |||
3231 3232 3233 3234 3235 3236 3237 | void Tk_TextLayoutToPostscript( Tcl_Interp *interp, /* Filled with Postscript code. */ Tk_TextLayout layout) /* The layout to be rendered. */ { TextLayout *layoutPtr = (TextLayout *) layout; | < < | > > | < > > < | < < < | < < < < < > | < | > | | | | | | | | | < < | < | | | | | < | | | | | | | | | | | > | | | | | | < | > | > | < < > | | < | > | < > > | | | | | | | | | < < < < | < < < < < < < | < | < < < < < < < < | | 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 | void Tk_TextLayoutToPostscript( Tcl_Interp *interp, /* Filled with Postscript code. */ Tk_TextLayout layout) /* The layout to be rendered. */ { TextLayout *layoutPtr = (TextLayout *) layout; LayoutChunk *chunkPtr = layoutPtr->chunks; int baseline = chunkPtr->y; Tcl_Obj *psObj = Tcl_NewObj(); int i, j, len; const char *p, *glyphname; char uindex[5], c, *ps; Tcl_UniChar ch; Tcl_AppendToObj(psObj, "[(", -1); for (i = 0; i < layoutPtr->numChunks; i++, chunkPtr++) { if (baseline != chunkPtr->y) { Tcl_AppendToObj(psObj, ")]\n[(", -1); baseline = chunkPtr->y; } if (chunkPtr->numDisplayChars <= 0) { if (chunkPtr->start[0] == '\t') { Tcl_AppendToObj(psObj, "\\t", -1); } continue; } for (p=chunkPtr->start, j=0; j<chunkPtr->numDisplayChars; j++) { /* * INTL: We only handle symbols that have an encoding as a glyph * from the standard set defined by Adobe. The rest get punted. * Eventually this should be revised to handle more sophsticiated * international postscript fonts. */ p += Tcl_UtfToUniChar(p, &ch); if ((ch == '(') || (ch == ')') || (ch == '\\') || (ch < 0x20)) { /* * Tricky point: the "03" is necessary in the sprintf below, * so that a full three digits of octal are always generated. * Without the "03", a number following this sequence could be * interpreted by Postscript as part of this sequence. */ Tcl_AppendPrintfToObj(psObj, "\\%03o", ch); continue; } else if (ch <= 0x7f) { /* * Normal ASCII character. */ c = (char) ch; Tcl_AppendToObj(psObj, &c, 1); continue; } /* * This character doesn't belong to the ASCII character set, so we * use the full glyph name. */ sprintf(uindex, "%04X", ch); /* endianness? */ glyphname = Tcl_GetVar2(interp, "::tk::psglyphs", uindex, 0); if (glyphname) { ps = Tcl_GetStringFromObj(psObj, &len); if (ps[len-1] == '(') { /* * In-place edit. Ewww! */ ps[len-1] = '/'; } else { Tcl_AppendToObj(psObj, ")/", -1); } Tcl_AppendToObj(psObj, glyphname, -1); Tcl_AppendToObj(psObj, "(", -1); } else { /* * No known mapping for the character into the space of * PostScript glyphs. Ignore it. :-( */ #ifdef TK_DEBUG_POSTSCRIPT_OUTPUT fprintf(stderr, "Warning: no mapping to PostScript " "glyphs for \\u%04x\n", ch); #endif } } } Tcl_AppendToObj(psObj, ")]\n", -1); Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj); Tcl_DecrRefCount(psObj); } /* *--------------------------------------------------------------------------- * * ConfigAttributesObj -- * |
︙ | ︙ | |||
3399 3400 3401 3402 3403 3404 3405 | /* * This test occurs after Tcl_GetIndexFromObj() so that "font * create xyz -xyz" will return the error message that "-xyz" is a * bad option, rather than that the value for "-xyz" is missing. */ if (interp != NULL) { | | > | > | 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 | /* * This test occurs after Tcl_GetIndexFromObj() so that "font * create xyz -xyz" will return the error message that "-xyz" is a * bad option, rather than that the value for "-xyz" is missing. */ if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" option missing", Tcl_GetString(optionPtr))); Tcl_SetErrorCode(interp, "TK", "FONT", "NO_ATTRIBUTE", NULL); } return TCL_ERROR; } switch (index) { case FONT_FAMILY: value = Tcl_GetString(valuePtr); |
︙ | ︙ | |||
3594 3595 3596 3597 3598 3599 3600 | */ if (string[1] == '*') { goto xlfd; } dash = strchr(string + 1, '-'); if ((dash != NULL) | | | 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 | */ if (string[1] == '*') { goto xlfd; } dash = strchr(string + 1, '-'); if ((dash != NULL) && !isspace(UCHAR(dash[-1]))) { /* INTL: ISO space */ goto xlfd; } if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
3642 3643 3644 3645 3646 3647 3648 | * Wasn't an XLFD or "-option value" string. Try it as a "font size style" * list. */ if ((Tcl_ListObjGetElements(NULL, objPtr, &objc, &objv) != TCL_OK) || (objc < 1)) { if (interp != NULL) { | > | | | 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 | * Wasn't an XLFD or "-option value" string. Try it as a "font size style" * list. */ if ((Tcl_ListObjGetElements(NULL, objPtr, &objc, &objv) != TCL_OK) || (objc < 1)) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "font \"%s\" doesn't exist", string)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "FONT", string, NULL); } return TCL_ERROR; } faPtr->family = Tk_GetUid(Tcl_GetString(objv[0])); if (objc > 1) { if (Tcl_GetIntFromObj(interp, objv[1], &n) != TCL_OK) { |
︙ | ︙ | |||
3690 3691 3692 3693 3694 3695 3696 | } /* * Unknown style. */ if (interp != NULL) { | > | > | | 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 | } /* * Unknown style. */ if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown font style \"%s\"", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "FONT_STYLE", Tcl_GetString(objv[i]), NULL); } return TCL_ERROR; } return TCL_OK; } /* |
︙ | ︙ | |||
3844 3845 3846 3847 3848 3849 3850 | * then assume the above incorrect form was used and shift all the rest of * the fields right by one, so the number gets interpreted as a pixelsize. * This fix is so that we don't get a million reports that "it works under * X (as a native font name), but gives a syntax error under Windows (as a * parsed set of attributes)". */ | | | 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 | * then assume the above incorrect form was used and shift all the rest of * the fields right by one, so the number gets interpreted as a pixelsize. * This fix is so that we don't get a million reports that "it works under * X (as a native font name), but gives a syntax error under Windows (as a * parsed set of attributes)". */ if ((i > XLFD_ADD_STYLE) && FieldSpecified(field[XLFD_ADD_STYLE])) { if (atoi(field[XLFD_ADD_STYLE]) != 0) { for (j = XLFD_NUMFIELDS - 1; j >= XLFD_ADD_STYLE; j--) { field[j + 1] = field[j]; } field[XLFD_ADD_STYLE] = NULL; i++; } |
︙ | ︙ | |||
4073 4074 4075 4076 4077 4078 4079 | * TkFontGetAliasList -- * * Given a font name, find the list of all aliases for that font name. * One of the names in this list will probably be the name that this * platform expects when asking for the font. * * Results: | < | 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 | * TkFontGetAliasList -- * * Given a font name, find the list of all aliases for that font name. * One of the names in this list will probably be the name that this * platform expects when asking for the font. * * Results: * As above. The return value is NULL if the font name has no aliases. * * Side effects: * None. * *------------------------------------------------------------------------- */ |
︙ | ︙ | |||
4243 4244 4245 4246 4247 4248 4249 | int TkFontGetFirstTextLayout( Tk_TextLayout layout, /* Layout information, from a previous call to * Tk_ComputeTextLayout(). */ Tk_Font *font, char *dst) { | | < | | 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 | int TkFontGetFirstTextLayout( Tk_TextLayout layout, /* Layout information, from a previous call to * Tk_ComputeTextLayout(). */ Tk_Font *font, char *dst) { TextLayout *layoutPtr = (TextLayout *) layout; LayoutChunk *chunkPtr; int numBytesInChunk; 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, (size_t) numBytesInChunk); |
︙ | ︙ |
Changes to generic/tkFrame.c.
︙ | ︙ | |||
330 331 332 333 334 335 336 | * The structure below defines frame class behavior by means of functions that * can be invoked from generic window code. */ static const Tk_ClassProcs frameClass = { sizeof(Tk_ClassProcs), /* size */ FrameWorldChanged, /* worldChangedProc */ | | | | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | * The structure below defines frame class behavior by means of functions that * can be invoked from generic window code. */ static const Tk_ClassProcs frameClass = { sizeof(Tk_ClassProcs), /* size */ FrameWorldChanged, /* worldChangedProc */ NULL, /* createProc */ NULL /* modalProc */ }; /* * The structure below defines the official type record for the labelframe's * geometry manager: */ |
︙ | ︙ | |||
461 462 463 464 465 466 467 | { Tk_Window tkwin; Frame *framePtr; Tk_OptionTable optionTable; Tk_Window newWin; const char *className, *screenName, *visualName, *colormapName; const char *arg, *useOption; | | | 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | { Tk_Window tkwin; Frame *framePtr; Tk_OptionTable optionTable; Tk_Window newWin; const char *className, *screenName, *visualName, *colormapName; const char *arg, *useOption; int i, length, depth; unsigned int mask; Colormap colormap; Visual *visual; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?"); return TCL_ERROR; |
︙ | ︙ | |||
492 493 494 495 496 497 498 | className = colormapName = screenName = visualName = useOption = NULL; colormap = None; for (i = 2; i < objc; i += 2) { arg = Tcl_GetStringFromObj(objv[i], &length); if (length < 2) { continue; } | < | | | | | | 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 | className = colormapName = screenName = visualName = useOption = NULL; colormap = None; for (i = 2; i < objc; i += 2) { arg = Tcl_GetStringFromObj(objv[i], &length); if (length < 2) { continue; } if ((arg[1] == 'c') && (length >= 3) && (strncmp(arg, "-class", (unsigned) length) == 0)) { className = Tcl_GetString(objv[i+1]); } else if ((arg[1] == 'c') && (length >= 3) && (strncmp(arg, "-colormap", (unsigned) length) == 0)) { colormapName = Tcl_GetString(objv[i+1]); } else if ((arg[1] == 's') && (type == TYPE_TOPLEVEL) && (strncmp(arg, "-screen", (unsigned) length) == 0)) { screenName = Tcl_GetString(objv[i+1]); } else if ((arg[1] == 'u') && (type == TYPE_TOPLEVEL) && (strncmp(arg, "-use", (unsigned) length) == 0)) { useOption = Tcl_GetString(objv[i+1]); } else if ((arg[1] == 'v') && (strncmp(arg, "-visual", (unsigned) length) == 0)) { visualName = Tcl_GetString(objv[i+1]); } } /* * Create the window, and deal with the special options -use, -classname, |
︙ | ︙ | |||
544 545 546 547 548 549 550 | screenName); } else if (appName == NULL) { /* * This occurs when someone tried to create a frame/toplevel while we * are being destroyed. Let an error be thrown. */ | | | > | > | | | | | | | | | | < | 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 | screenName); } else if (appName == NULL) { /* * This occurs when someone tried to create a frame/toplevel while we * are being destroyed. Let an error be thrown. */ Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unable to create widget \"%s\"", Tcl_GetString(objv[1]))); Tcl_SetErrorCode(interp, "TK", "APPLICATION_GONE", NULL); return TCL_ERROR; } else { /* * We were called from Tk_Init; create a new application. */ newWin = TkCreateMainWindow(interp, screenName, appName); } if (newWin == NULL) { goto error; } /* * Mark Tk frames as suitable candidates for [wm manage]. */ ((TkWindow *) newWin)->flags |= TK_WM_MANAGEABLE; if (className == NULL) { className = Tk_GetOption(newWin, "class", "Class"); if (className == NULL) { className = classNames[type]; } } Tk_SetClass(newWin, className); if (useOption == NULL) { useOption = Tk_GetOption(newWin, "use", "Use"); } if ((useOption != NULL) && (*useOption != 0) && (TkpUseWindow(interp, newWin, useOption) != TCL_OK)) { goto error; } if (visualName == NULL) { visualName = Tk_GetOption(newWin, "visual", "Visual"); } if (colormapName == NULL) { colormapName = Tk_GetOption(newWin, "colormap", "Colormap"); } |
︙ | ︙ | |||
626 627 628 629 630 631 632 | if (type == TYPE_LABELFRAME) { framePtr = ckalloc(sizeof(Labelframe)); memset(framePtr, 0, sizeof(Labelframe)); } else { framePtr = ckalloc(sizeof(Frame)); memset(framePtr, 0, sizeof(Frame)); } | | | | | < | | 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 | if (type == TYPE_LABELFRAME) { framePtr = ckalloc(sizeof(Labelframe)); memset(framePtr, 0, sizeof(Labelframe)); } else { framePtr = ckalloc(sizeof(Frame)); memset(framePtr, 0, sizeof(Frame)); } framePtr->tkwin = newWin; framePtr->display = Tk_Display(newWin); framePtr->interp = interp; framePtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(newWin), FrameWidgetObjCmd, framePtr, FrameCmdDeletedProc); framePtr->optionTable = optionTable; framePtr->type = type; framePtr->colormap = colormap; framePtr->relief = TK_RELIEF_FLAT; framePtr->cursor = None; if (framePtr->type == TYPE_LABELFRAME) { |
︙ | ︙ | |||
661 662 663 664 665 666 667 | } Tk_CreateEventHandler(newWin, mask, FrameEventProc, framePtr); if ((Tk_InitOptions(interp, (char *) framePtr, optionTable, newWin) != TCL_OK) || (ConfigureFrame(interp, framePtr, objc-2, objv+2) != TCL_OK)) { goto error; } | | | | < | | > > | 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 | } Tk_CreateEventHandler(newWin, mask, FrameEventProc, framePtr); if ((Tk_InitOptions(interp, (char *) framePtr, optionTable, newWin) != TCL_OK) || (ConfigureFrame(interp, framePtr, objc-2, objv+2) != TCL_OK)) { goto error; } if (framePtr->isContainer) { if (framePtr->useThis != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "windows cannot have both the -use and the -container" " option set", -1)); Tcl_SetErrorCode(interp, "TK", "FRAME", "CONTAINMENT", NULL); goto error; } TkpMakeContainer(framePtr->tkwin); } if (type == TYPE_TOPLEVEL) { Tcl_DoWhenIdle(MapFrame, framePtr); } Tcl_SetObjResult(interp, TkNewWindowObj(newWin)); return TCL_OK; |
︙ | ︙ | |||
761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 | /* * Don't allow the options -class, -colormap, -container, -screen, * -use, or -visual to be changed. */ for (i = 2; i < objc; i++) { const char *arg = Tcl_GetStringFromObj(objv[i], &length); if (length < 2) { continue; } c = arg[1]; if (((c == 'c') && (length >= 2) && (strncmp(arg, "-class", (unsigned)length) == 0)) || ((c == 'c') && (length >= 3) && (strncmp(arg, "-colormap", (unsigned)length) == 0)) || ((c == 'c') && (length >= 3) && (strncmp(arg, "-container", (unsigned)length) == 0)) || ((c == 's') && (framePtr->type == TYPE_TOPLEVEL) && (strncmp(arg, "-screen", (unsigned)length) == 0)) || ((c == 'u') && (framePtr->type == TYPE_TOPLEVEL) && (strncmp(arg, "-use", (unsigned)length) == 0)) || ((c == 'v') && (strncmp(arg, "-visual", (unsigned)length) == 0))) { #ifdef SUPPORT_CONFIG_EMBEDDED if (c == 'u') { const char *string = Tcl_GetString(objv[i+1]); if (TkpUseWindow(interp, framePtr->tkwin, string) != TCL_OK) { result = TCL_ERROR; goto done; } | > > < < < < | | | | > > > | | < | 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 | /* * Don't allow the options -class, -colormap, -container, -screen, * -use, or -visual to be changed. */ for (i = 2; i < objc; i++) { const char *arg = Tcl_GetStringFromObj(objv[i], &length); if (length < 2) { continue; } c = arg[1]; if (((c == 'c') && (length >= 2) && (strncmp(arg, "-class", (unsigned)length) == 0)) || ((c == 'c') && (length >= 3) && (strncmp(arg, "-colormap", (unsigned)length) == 0)) || ((c == 'c') && (length >= 3) && (strncmp(arg, "-container", (unsigned)length) == 0)) || ((c == 's') && (framePtr->type == TYPE_TOPLEVEL) && (strncmp(arg, "-screen", (unsigned)length) == 0)) || ((c == 'u') && (framePtr->type == TYPE_TOPLEVEL) && (strncmp(arg, "-use", (unsigned)length) == 0)) || ((c == 'v') && (strncmp(arg, "-visual", (unsigned)length) == 0))) { #ifdef SUPPORT_CONFIG_EMBEDDED if (c == 'u') { const char *string = Tcl_GetString(objv[i+1]); if (TkpUseWindow(interp, framePtr->tkwin, string) != TCL_OK) { result = TCL_ERROR; goto done; } continue; } #endif Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't modify %s option after widget is created", arg)); Tcl_SetErrorCode(interp, "TK", "FRAME", "CREATE_ONLY", NULL); result = TCL_ERROR; goto done; } } result = ConfigureFrame(interp, framePtr, objc-2, objv+2); } break; } |
︙ | ︙ | |||
1007 1008 1009 1010 1011 1012 1013 | for (ancestor = framePtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } sibling = ancestor; if (Tk_IsTopLevel(ancestor)) { | | < < < < < | | > > > > > > > > | 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 | for (ancestor = framePtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } sibling = ancestor; if (Tk_IsTopLevel(ancestor)) { goto badLabelWindow; } } if (Tk_IsTopLevel(labelframePtr->labelWin)) { goto badLabelWindow; } if (labelframePtr->labelWin == framePtr->tkwin) { goto badLabelWindow; } Tk_CreateEventHandler(labelframePtr->labelWin, StructureNotifyMask, FrameStructureProc, framePtr); Tk_ManageGeometry(labelframePtr->labelWin, &frameGeomType, framePtr); /* * If the frame is not parent to the label, make sure the * label is above its sibling in the stacking order. */ if (sibling != NULL) { Tk_RestackWindow(labelframePtr->labelWin, Above, sibling); } } } } FrameWorldChanged(framePtr); return TCL_OK; badLabelWindow: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't use %s as label in this frame", Tk_PathName(labelframePtr->labelWin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); labelframePtr->labelWin = NULL; return TCL_ERROR; } /* *--------------------------------------------------------------------------- * * FrameWorldChanged -- * |
︙ | ︙ |
Changes to generic/tkGeometry.c.
︙ | ︙ | |||
317 318 319 320 321 322 323 | * *---------------------------------------------------------------------- */ int TkSetGeometryMaster( Tcl_Interp *interp, /* Current interpreter, for error. */ | | > > | < | | > | 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 | * *---------------------------------------------------------------------- */ int TkSetGeometryMaster( Tcl_Interp *interp, /* Current interpreter, for error. */ Tk_Window tkwin, /* Window that will have geometry master * set. */ const char *master) /* The master identity. */ { register TkWindow *winPtr = (TkWindow *) tkwin; if (winPtr->geometryMaster != NULL && strcmp(winPtr->geometryMaster, master) == 0) { return TCL_OK; } if (winPtr->geometryMaster != NULL) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "cannot use geometry manager %s inside %s which already" " has slaves managed by %s", master, Tk_PathName(tkwin), winPtr->geometryMaster)); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "FIGHT", NULL); } return TCL_ERROR; } winPtr->geometryMaster = ckalloc(strlen(master) + 1); strcpy(winPtr->geometryMaster, master); return TCL_OK; |
︙ | ︙ | |||
360 361 362 363 364 365 366 | * The geometry master is cleared for the window. * *---------------------------------------------------------------------- */ void TkFreeGeometryMaster( | | > | | 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | * The geometry master is cleared for the window. * *---------------------------------------------------------------------- */ void TkFreeGeometryMaster( Tk_Window tkwin, /* Window that will have geometry master * cleared. */ const char *master) /* The master identity. */ { register TkWindow *winPtr = (TkWindow *) tkwin; if (winPtr->geometryMaster != NULL && strcmp(winPtr->geometryMaster, master) != 0) { Tcl_Panic("Trying to free %s from geometry manager %s", winPtr->geometryMaster, master); |
︙ | ︙ |
Changes to generic/tkGet.c.
︙ | ︙ | |||
148 149 150 151 152 153 154 | *anchorPtr = TK_ANCHOR_CENTER; return TCL_OK; } goto error; } error: | > | | > | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | *anchorPtr = TK_ANCHOR_CENTER; return TCL_OK; } goto error; } error: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad anchor position \"%s\": must be" " n, ne, e, se, s, sw, w, nw, or center", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "ANCHOR", NULL); return TCL_ERROR; } /* *-------------------------------------------------------------- * * Tk_NameOfAnchor -- |
︙ | ︙ | |||
233 234 235 236 237 238 239 | return TCL_OK; } if ((c == 'r') && (strncmp(string, "round", length) == 0)) { *joinPtr = JoinRound; return TCL_OK; } | | | > > | 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | return TCL_OK; } if ((c == 'r') && (strncmp(string, "round", length) == 0)) { *joinPtr = JoinRound; return TCL_OK; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad join style \"%s\": must be bevel, miter, or round", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "JOIN", NULL); return TCL_ERROR; } /* *-------------------------------------------------------------- * * Tk_NameOfJoinStyle -- |
︙ | ︙ | |||
312 313 314 315 316 317 318 | return TCL_OK; } if ((c == 'r') && (strncmp(string, "round", length) == 0)) { *capPtr = CapRound; return TCL_OK; } | | | > > | 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | return TCL_OK; } if ((c == 'r') && (strncmp(string, "round", length) == 0)) { *capPtr = CapRound; return TCL_OK; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad cap style \"%s\": must be butt, projecting, or round", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "CAP", NULL); return TCL_ERROR; } /* *-------------------------------------------------------------- * * Tk_NameOfCapStyle -- |
︙ | ︙ | |||
428 429 430 431 432 433 434 | return TCL_OK; } if ((c == 'c') && (strncmp(string, "center", length) == 0)) { *justifyPtr = TK_JUSTIFY_CENTER; return TCL_OK; } | | | > > | 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | return TCL_OK; } if ((c == 'c') && (strncmp(string, "center", length) == 0)) { *justifyPtr = TK_JUSTIFY_CENTER; return TCL_OK; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad justification \"%s\": must be left, right, or center", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "JUSTIFY", NULL); return TCL_ERROR; } /* *-------------------------------------------------------------- * * Tk_NameOfJustify -- |
︙ | ︙ | |||
564 565 566 567 568 569 570 | double *doublePtr) /* Place to store converted result. */ { char *end; double d; d = strtod(string, &end); if (end == string) { | | < < | 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | double *doublePtr) /* Place to store converted result. */ { char *end; double d; d = strtod(string, &end); if (end == string) { goto error; } while ((*end != '\0') && isspace(UCHAR(*end))) { end++; } switch (*end) { case 0: d /= WidthOfScreen(Tk_Screen(tkwin)); |
︙ | ︙ | |||
602 603 604 605 606 607 608 609 610 611 612 613 614 615 | end++; } if (*end != 0) { goto error; } *doublePtr = d; return TCL_OK; } /* *-------------------------------------------------------------- * * Tk_GetPixels -- * | > > > > > > | 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 | end++; } if (*end != 0) { goto error; } *doublePtr = d; return TCL_OK; error: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad screen distance \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "SCREEN_DISTANCE", NULL); return TCL_ERROR; } /* *-------------------------------------------------------------- * * Tk_GetPixels -- * |
︙ | ︙ | |||
680 681 682 683 684 685 686 | double *doublePtr) /* Place to store converted result. */ { char *end; double d; d = strtod((char *) string, &end); if (end == string) { | | < < | 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 | double *doublePtr) /* Place to store converted result. */ { char *end; double d; d = strtod((char *) string, &end); if (end == string) { goto error; } while ((*end != '\0') && isspace(UCHAR(*end))) { end++; } switch (*end) { case 0: break; |
︙ | ︙ | |||
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 | end++; } if (*end != 0) { goto error; } *doublePtr = d; return TCL_OK; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ | > > > > > > | 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | end++; } if (*end != 0) { goto error; } *doublePtr = d; return TCL_OK; error: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad screen distance \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "FRACTIONAL_PIXELS", NULL); return TCL_ERROR; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkGrab.c.
︙ | ︙ | |||
207 208 209 210 211 212 213 | * read: * wrong # args: should be "cmd ?-global? window" or "cmd option * ?arg ...?" * We can fake it with Tcl_WrongNumArgs if we assume the command name * is "grab", but if it has been aliased, the message will be * incorrect. */ | | | | | > > > > > | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | * read: * wrong # args: should be "cmd ?-global? window" or "cmd option * ?arg ...?" * We can fake it with Tcl_WrongNumArgs if we assume the command name * is "grab", but if it has been aliased, the message will be * incorrect. */ Tcl_WrongNumArgs(interp, 1, objv, "?-global? window"); Tcl_AppendResult(interp, " or \"", Tcl_GetString(objv[0]), " option ?arg ...?\"", NULL); /* This API not exposed: * ((Interp *) interp)->flags |= INTERP_ALTERNATE_WRONG_ARGS; Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); */ return TCL_ERROR; } /* * First check for a window name or "-global" as the first argument. */ |
︙ | ︙ | |||
273 274 275 276 277 278 279 | tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), clientData); if (tkwin == NULL) { return TCL_ERROR; } dispPtr = ((TkWindow *) tkwin)->dispPtr; if (dispPtr->eventualGrabWinPtr != NULL) { | > | < > > | | > | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), clientData); if (tkwin == NULL) { return TCL_ERROR; } dispPtr = ((TkWindow *) tkwin)->dispPtr; if (dispPtr->eventualGrabWinPtr != NULL) { Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window) dispPtr->eventualGrabWinPtr)); } } else { Tcl_Obj *resultObj = Tcl_NewObj(); for (dispPtr = TkGetDisplayList(); dispPtr != NULL; dispPtr = dispPtr->nextPtr) { if (dispPtr->eventualGrabWinPtr != NULL) { Tcl_ListObjAppendElement(NULL, resultObj, TkNewWindowObj( (Tk_Window) dispPtr->eventualGrabWinPtr)); } } Tcl_SetObjResult(interp, resultObj); } return TCL_OK; case GRABCMD_RELEASE: /* [grab release window] */ if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "release window"); |
︙ | ︙ | |||
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | return TCL_ERROR; } return Tk_Grab(interp, tkwin, globalGrab); case GRABCMD_STATUS: { /* [grab status window] */ TkWindow *winPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "status window"); return TCL_ERROR; } winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[2]), clientData); if (winPtr == NULL) { return TCL_ERROR; } dispPtr = winPtr->dispPtr; if (dispPtr->eventualGrabWinPtr != winPtr) { | > | | | > | 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 | return TCL_ERROR; } return Tk_Grab(interp, tkwin, globalGrab); case GRABCMD_STATUS: { /* [grab status window] */ TkWindow *winPtr; const char *statusString; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "status window"); return TCL_ERROR; } winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[2]), clientData); if (winPtr == NULL) { return TCL_ERROR; } dispPtr = winPtr->dispPtr; if (dispPtr->eventualGrabWinPtr != winPtr) { statusString = "none"; } else if (dispPtr->grabFlags & GRAB_GLOBAL) { statusString = "global"; } else { statusString = "local"; } Tcl_SetObjResult(interp, Tcl_NewStringObj(statusString, -1)); break; } } return TCL_OK; } |
︙ | ︙ | |||
406 407 408 409 410 411 412 | ReleaseButtonGrab(dispPtr); if (dispPtr->eventualGrabWinPtr != NULL) { if ((dispPtr->eventualGrabWinPtr == winPtr) && (grabGlobal == ((dispPtr->grabFlags & GRAB_GLOBAL) != 0))) { return TCL_OK; } if (dispPtr->eventualGrabWinPtr->mainPtr != winPtr->mainPtr) { | | < < < | | | 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 | ReleaseButtonGrab(dispPtr); if (dispPtr->eventualGrabWinPtr != NULL) { if ((dispPtr->eventualGrabWinPtr == winPtr) && (grabGlobal == ((dispPtr->grabFlags & GRAB_GLOBAL) != 0))) { return TCL_OK; } if (dispPtr->eventualGrabWinPtr->mainPtr != winPtr->mainPtr) { goto alreadyGrabbed; } Tk_Ungrab((Tk_Window) dispPtr->eventualGrabWinPtr); } Tk_MakeWindowExist(tkwin); #ifndef MAC_OSX_TK if (!grabGlobal) #else if (0) #endif /* MAC_OSX_TK */ { Window dummy1, dummy2; int dummy3, dummy4, dummy5, dummy6; unsigned int state; /* * Local grab. However, if any mouse buttons are down, turn it into a * global grab temporarily, until the last button goes up. This does * two things: (a) it makes sure that we see the button-up event; and * (b) it allows us to track mouse motion among all of the windows of * this application. */ dispPtr->grabFlags &= ~(GRAB_GLOBAL|GRAB_TEMP_GLOBAL); XQueryPointer(dispPtr->display, winPtr->window, &dummy1, &dummy2, &dummy3, &dummy4, &dummy5, &dummy6, &state); if (state & ALL_BUTTONS) { dispPtr->grabFlags |= GRAB_TEMP_GLOBAL; goto setGlobalGrab; } } else { dispPtr->grabFlags |= GRAB_GLOBAL; setGlobalGrab: |
︙ | ︙ | |||
475 476 477 478 479 480 481 | None, CurrentTime); if (grabResult != AlreadyGrabbed) { break; } Tcl_Sleep(100); } if (grabResult != 0) { | | < < < < < < < < < < < < < < < < < < < | 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | None, CurrentTime); if (grabResult != AlreadyGrabbed) { break; } Tcl_Sleep(100); } if (grabResult != 0) { goto grabError; } grabResult = XGrabKeyboard(dispPtr->display, Tk_WindowId(tkwin), False, GrabModeAsync, GrabModeAsync, CurrentTime); if (grabResult != 0) { XUngrabPointer(dispPtr->display, CurrentTime); goto grabError; } |
︙ | ︙ | |||
542 543 544 545 546 547 548 549 550 551 552 553 554 555 | MovePointer2(dispPtr->serverWinPtr, winPtr, NotifyGrab, 1, 0); break; } } } QueueGrabWindowChange(dispPtr, winPtr); return TCL_OK; } /* *---------------------------------------------------------------------- * * Tk_Ungrab -- * | > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | MovePointer2(dispPtr->serverWinPtr, winPtr, NotifyGrab, 1, 0); break; } } } QueueGrabWindowChange(dispPtr, winPtr); return TCL_OK; grabError: if (grabResult == GrabNotViewable) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "grab failed: window not viewable", -1)); Tcl_SetErrorCode(interp, "TK", "GRAB", "UNVIEWABLE", NULL); } else if (grabResult == AlreadyGrabbed) { alreadyGrabbed: Tcl_SetObjResult(interp, Tcl_NewStringObj( "grab failed: another application has grab", -1)); Tcl_SetErrorCode(interp, "TK", "GRAB", "GRABBED", NULL); } else if (grabResult == GrabFrozen) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "grab failed: keyboard or pointer frozen", -1)); Tcl_SetErrorCode(interp, "TK", "GRAB", "FROZEN", NULL); } else if (grabResult == GrabInvalidTime) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "grab failed: invalid time", -1)); Tcl_SetErrorCode(interp, "TK", "GRAB", "BAD_TIME", NULL); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "grab failed for unknown reason (code %d)", grabResult)); Tcl_SetErrorCode(interp, "TK", "GRAB", "UNKNOWN", NULL); } return TCL_ERROR; } /* *---------------------------------------------------------------------- * * Tk_Ungrab -- * |
︙ | ︙ | |||
842 843 844 845 846 847 848 | if (outsideGrabTree) { winPtr2 = dispPtr->grabWinPtr; /* Note 5. */ } else { winPtr2 = winPtr; /* Note 5. */ } } if (eventPtr->type == ButtonPress) { | | | 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 | if (outsideGrabTree) { winPtr2 = dispPtr->grabWinPtr; /* Note 5. */ } else { winPtr2 = winPtr; /* Note 5. */ } } if (eventPtr->type == ButtonPress) { if (!(eventPtr->xbutton.state & ALL_BUTTONS)) { if (outsideGrabTree) { TkChangeEventWindow(eventPtr, dispPtr->grabWinPtr); Tk_QueueWindowEvent(eventPtr, TCL_QUEUE_HEAD); return 0; /* Note 2. */ } if (!(dispPtr->grabFlags & GRAB_GLOBAL)) { /* Note 6. */ serial = NextRequest(dispPtr->display); |
︙ | ︙ |
Changes to generic/tkGrid.c.
︙ | ︙ | |||
297 298 299 300 301 302 303 | static int ResolveConstraints(Gridder *gridPtr, int rowOrColumn, int maxOffset); static void SetGridSize(Gridder *gridPtr); static int SetSlaveColumn(Tcl_Interp *interp, Gridder *slavePtr, int column, int numCols); static int SetSlaveRow(Tcl_Interp *interp, Gridder *slavePtr, int row, int numRows); | | | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | static int ResolveConstraints(Gridder *gridPtr, int rowOrColumn, int maxOffset); static void SetGridSize(Gridder *gridPtr); static int SetSlaveColumn(Tcl_Interp *interp, Gridder *slavePtr, int column, int numCols); static int SetSlaveRow(Tcl_Interp *interp, Gridder *slavePtr, int row, int numRows); static Tcl_Obj * StickyToObj(int flags); static int StringToSticky(const char *string); static void Unlink(Gridder *gridPtr); static const Tk_GeomMgr gridMgrType = { "grid", /* name */ GridReqProc, /* requestProc */ GridLostSlaveProc, /* lostSlaveProc */ |
︙ | ︙ | |||
398 399 400 401 402 403 404 | case GRID_COLUMNCONFIGURE: case GRID_ROWCONFIGURE: return GridRowColumnConfigureCommand(tkwin, interp, objc, objv); } /* This should not happen */ | | > | 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | case GRID_COLUMNCONFIGURE: case GRID_ROWCONFIGURE: return GridRowColumnConfigureCommand(tkwin, interp, objc, objv); } /* This should not happen */ Tcl_SetObjResult(interp, Tcl_NewStringObj("internal error in grid", -1)); Tcl_SetErrorCode(interp, "TK", "API_ABUSE", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * GridAnchorCommand -- |
︙ | ︙ | |||
443 444 445 446 447 448 449 | if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { return TCL_ERROR; } masterPtr = GetGrid(master); if (objc == 3) { gridPtr = masterPtr->masterDataPtr; | | | > | 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { return TCL_ERROR; } masterPtr = GetGrid(master); if (objc == 3) { gridPtr = masterPtr->masterDataPtr; Tcl_SetObjResult(interp, Tcl_NewStringObj( Tk_NameOfAnchor(gridPtr?gridPtr->anchor:GRID_DEFAULT_ANCHOR), -1)); return TCL_OK; } InitMasterData(masterPtr); gridPtr = masterPtr->masterDataPtr; old = gridPtr->anchor; if (Tk_GetAnchorFromObj(interp, objv[3], &gridPtr->anchor) != TCL_OK) { |
︙ | ︙ | |||
716 717 718 719 720 721 722 | Tk_Window tkwin, /* Main window of the application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register Gridder *slavePtr; Tk_Window slave; | | | > | | | > > > | > | | | | | > | | | 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 | Tk_Window tkwin, /* Main window of the application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register Gridder *slavePtr; Tk_Window slave; Tcl_Obj *infoObj; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (TkGetWindowFromObj(interp, tkwin, objv[2], &slave) != TCL_OK) { return TCL_ERROR; } slavePtr = GetGrid(slave); if (slavePtr->masterPtr == NULL) { Tcl_ResetResult(interp); return TCL_OK; } infoObj = Tcl_NewObj(); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-in", -1), TkNewWindowObj(slavePtr->masterPtr->tkwin)); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-column", -1), Tcl_NewIntObj(slavePtr->column)); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-row", -1), Tcl_NewIntObj(slavePtr->row)); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-columnspan", -1), Tcl_NewIntObj(slavePtr->numCols)); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-rowspan", -1), Tcl_NewIntObj(slavePtr->numRows)); TkAppendPadAmount(infoObj, "-ipadx", slavePtr->iPadX/2, slavePtr->iPadX); TkAppendPadAmount(infoObj, "-ipady", slavePtr->iPadY/2, slavePtr->iPadY); TkAppendPadAmount(infoObj, "-padx", slavePtr->padLeft, slavePtr->padX); TkAppendPadAmount(infoObj, "-pady", slavePtr->padTop, slavePtr->padY); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-sticky", -1), StickyToObj(slavePtr->sticky)); Tcl_SetObjResult(interp, infoObj); return TCL_OK; } /* *---------------------------------------------------------------------- * * GridLocationCommand -- |
︙ | ︙ | |||
990 991 992 993 994 995 996 | Tcl_DecrRefCount(listCopy); return TCL_ERROR; } string = Tcl_GetString(objv[1]); slotType = (*string == 'c') ? COLUMN : ROW; if (lObjc == 0) { | | | | | < | > | > | 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 | Tcl_DecrRefCount(listCopy); return TCL_ERROR; } string = Tcl_GetString(objv[1]); slotType = (*string == 'c') ? COLUMN : ROW; if (lObjc == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf("no %s indices specified", (slotType == COLUMN) ? "column" : "row")); Tcl_SetErrorCode(interp, "TK", "GRID", "NO_INDEX", NULL); Tcl_DecrRefCount(listCopy); return TCL_ERROR; } masterPtr = GetGrid(master); first = 0; /* lint */ last = 0; /* lint */ if ((objc == 4) || (objc == 5)) { if (lObjc != 1) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "must specify a single element on retrieval", -1)); Tcl_SetErrorCode(interp, "TK", "GRID", "USAGE", NULL); Tcl_DecrRefCount(listCopy); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, lObjv[0], &slot) != TCL_OK) { Tcl_AppendResult(interp, " (when retrieving options only integer indices are " "allowed)", NULL); Tcl_SetErrorCode(interp, "TK", "GRID", "INDEX_FORMAT", NULL); Tcl_DecrRefCount(listCopy); return TCL_ERROR; } ok = CheckSlotData(masterPtr, slot, slotType, /* checkOnly */ 1); if (ok == TCL_OK) { slotPtr = (slotType == COLUMN) ? masterPtr->masterDataPtr->columnPtr : |
︙ | ︙ | |||
1069 1070 1071 1072 1073 1074 1075 | if (Tcl_GetIndexFromObj(interp, objv[4], optionStrings, "option", 0, &index) != TCL_OK) { Tcl_DecrRefCount(listCopy); return TCL_ERROR; } if (index == ROWCOL_MINSIZE) { | | | | | | | | | | 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 | if (Tcl_GetIndexFromObj(interp, objv[4], optionStrings, "option", 0, &index) != TCL_OK) { Tcl_DecrRefCount(listCopy); return TCL_ERROR; } if (index == ROWCOL_MINSIZE) { Tcl_SetObjResult(interp, Tcl_NewIntObj( (ok == TCL_OK) ? slotPtr[slot].minSize : 0)); } else if (index == ROWCOL_WEIGHT) { Tcl_SetObjResult(interp, Tcl_NewIntObj( (ok == TCL_OK) ? slotPtr[slot].weight : 0)); } else if (index == ROWCOL_UNIFORM) { Tk_Uid value = (ok == TCL_OK) ? slotPtr[slot].uniform : ""; Tcl_SetObjResult(interp, Tcl_NewStringObj( (value == NULL) ? "" : value, -1)); } else if (index == ROWCOL_PAD) { Tcl_SetObjResult(interp, Tcl_NewIntObj( (ok == TCL_OK) ? slotPtr[slot].pad : 0)); } Tcl_DecrRefCount(listCopy); return TCL_OK; } for (j = 0; j < lObjc; j++) { int allSlaves = 0; |
︙ | ︙ | |||
1114 1115 1116 1117 1118 1119 1120 | == TCL_OK) { /* * Is it gridded in this master? */ slavePtr = GetGrid(slave); if (slavePtr->masterPtr != masterPtr) { | | < | | > | < | > | | | > | | 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 | == TCL_OK) { /* * Is it gridded in this master? */ slavePtr = GetGrid(slave); if (slavePtr->masterPtr != masterPtr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "the window \"%s\" is not managed by \"%s\"", Tcl_GetString(lObjv[j]), Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TK", "GRID", "NOT_MASTER", NULL); Tcl_DecrRefCount(listCopy); return TCL_ERROR; } } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "illegal index \"%s\"", Tcl_GetString(lObjv[j]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID_INDEX", NULL); Tcl_DecrRefCount(listCopy); return TCL_ERROR; } /* * The outer loop is only to handle "all". */ do { if (slavePtr != NULL) { first = (slotType == COLUMN) ? slavePtr->column : slavePtr->row; last = first - 1 + ((slotType == COLUMN) ? slavePtr->numCols : slavePtr->numRows); } for (slot = first; slot <= last; slot++) { ok = CheckSlotData(masterPtr, slot, slotType, /*checkOnly*/ 0); if (ok != TCL_OK) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "\"%s\" is out of range", Tcl_GetString(lObjv[j]))); Tcl_SetErrorCode(interp, "TK", "GRID", "INDEX_RANGE", NULL); Tcl_DecrRefCount(listCopy); return TCL_ERROR; } slotPtr = (slotType == COLUMN) ? masterPtr->masterDataPtr->columnPtr : masterPtr->masterDataPtr->rowPtr; |
︙ | ︙ | |||
1181 1182 1183 1184 1185 1186 1187 | } else if (index == ROWCOL_WEIGHT) { int wt; if (Tcl_GetIntFromObj(interp,objv[i+1],&wt)!=TCL_OK) { Tcl_DecrRefCount(listCopy); return TCL_ERROR; } else if (wt < 0) { | < < < < > < < < < > | 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 | } else if (index == ROWCOL_WEIGHT) { int wt; if (Tcl_GetIntFromObj(interp,objv[i+1],&wt)!=TCL_OK) { Tcl_DecrRefCount(listCopy); return TCL_ERROR; } else if (wt < 0) { Tcl_DecrRefCount(listCopy); goto negativeIndex; } else { slotPtr[slot].weight = wt; } } else if (index == ROWCOL_UNIFORM) { slotPtr[slot].uniform = Tk_GetUid(Tcl_GetString(objv[i+1])); if (slotPtr[slot].uniform != NULL && slotPtr[slot].uniform[0] == 0) { slotPtr[slot].uniform = NULL; } } else if (index == ROWCOL_PAD) { if (Tk_GetPixelsFromObj(interp, master, objv[i+1], &size) != TCL_OK) { Tcl_DecrRefCount(listCopy); return TCL_ERROR; } else if (size < 0) { Tcl_DecrRefCount(listCopy); goto negativeIndex; } else { slotPtr[slot].pad = size; } } } } if (slavePtr != NULL) { |
︙ | ︙ | |||
1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 | *masterPtr->abortPtr = 1; } if (!(masterPtr->flags & REQUESTED_RELAYOUT)) { masterPtr->flags |= REQUESTED_RELAYOUT; Tcl_DoWhenIdle(ArrangeGrid, masterPtr); } return TCL_OK; } /* *---------------------------------------------------------------------- * * GridSizeCommand -- * | > > > > > > > | 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 | *masterPtr->abortPtr = 1; } if (!(masterPtr->flags & REQUESTED_RELAYOUT)) { masterPtr->flags |= REQUESTED_RELAYOUT; Tcl_DoWhenIdle(ArrangeGrid, masterPtr); } return TCL_OK; negativeIndex: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid arg \"%s\": should be non-negative", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "GRID", "NEG_INDEX", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * GridSizeCommand -- * |
︙ | ︙ | |||
1357 1358 1359 1360 1361 1362 1363 | &index) != TCL_OK) { return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[i+1], &value) != TCL_OK) { return TCL_ERROR; } if (value < 0) { | | | > | | | 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 | &index) != TCL_OK) { return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[i+1], &value) != TCL_OK) { return TCL_ERROR; } if (value < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%d is an invalid value: should NOT be < 0", value)); Tcl_SetErrorCode(interp, "TK", "GRID", "NEG_INDEX", NULL); return TCL_ERROR; } if (index == SLAVES_COLUMN) { column = value; } else { row = value; } } if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { return TCL_ERROR; } masterPtr = GetGrid(master); res = Tcl_NewListObj(0, NULL); for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; slavePtr = slavePtr->nextPtr) { if ((column >= 0) && (slavePtr->column > column || slavePtr->column+slavePtr->numCols-1 < column)) { continue; } if ((row >= 0) && (slavePtr->row > row || slavePtr->row+slavePtr->numRows-1 < row)) { continue; } Tcl_ListObjAppendElement(interp,res, TkNewWindowObj(slavePtr->tkwin)); } Tcl_SetObjResult(interp, res); return TCL_OK; |
︙ | ︙ | |||
2524 2525 2526 2527 2528 2529 2530 | int newColumn, newNumCols, lastCol; newColumn = (column >= 0) ? column : slavePtr->column; newNumCols = (numCols >= 1) ? numCols : slavePtr->numCols; lastCol = ((newColumn >= 0) ? newColumn : 0) + newNumCols; if (lastCol >= MAX_ELEMENT) { | | > | 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 | int newColumn, newNumCols, lastCol; newColumn = (column >= 0) ? column : slavePtr->column; newNumCols = (numCols >= 1) ? numCols : slavePtr->numCols; lastCol = ((newColumn >= 0) ? newColumn : 0) + newNumCols; if (lastCol >= MAX_ELEMENT) { Tcl_SetObjResult(interp, Tcl_NewStringObj("column out of bounds",-1)); Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_COLUMN", NULL); return TCL_ERROR; } slavePtr->column = newColumn; slavePtr->numCols = newNumCols; return TCL_OK; } |
︙ | ︙ | |||
2564 2565 2566 2567 2568 2569 2570 | int newRow, newNumRows, lastRow; newRow = (row >= 0) ? row : slavePtr->row; newNumRows = (numRows >= 1) ? numRows : slavePtr->numRows; lastRow = ((newRow >= 0) ? newRow : 0) + newNumRows; if (lastRow >= MAX_ELEMENT) { | | > | 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 | int newRow, newNumRows, lastRow; newRow = (row >= 0) ? row : slavePtr->row; newNumRows = (numRows >= 1) ? numRows : slavePtr->numRows; lastRow = ((newRow >= 0) ? newRow : 0) + newNumRows; if (lastRow >= MAX_ELEMENT) { Tcl_SetObjResult(interp, Tcl_NewStringObj("row out of bounds", -1)); Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_ROW", NULL); return TCL_ERROR; } slavePtr->row = newRow; slavePtr->numRows = newNumRows; return TCL_OK; } |
︙ | ︙ | |||
2988 2989 2990 2991 2992 2993 2994 | InitMasterData(masterPtr); } } numWindows++; continue; } if (length > 1 && i == 0) { | | | > | | | > | | > | | > > > | > | 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 | InitMasterData(masterPtr); } } numWindows++; continue; } if (length > 1 && i == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad argument \"%s\": must be name of window", string)); Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_PARAMETER", NULL); return TCL_ERROR; } if (length > 1 && firstChar == '-') { break; } if (length > 1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unexpected parameter \"%s\" in configure list:" " should be window name or option", string)); Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_PARAMETER", NULL); return TCL_ERROR; } if ((firstChar == REL_HORIZ) && ((numWindows == 0) || (prevChar == REL_SKIP) || (prevChar == REL_VERT))) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "must specify window before shortcut '-'", -1)); Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL); return TCL_ERROR; } if ((firstChar == REL_VERT) || (firstChar == REL_SKIP) || (firstChar == REL_HORIZ)) { continue; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid window shortcut, \"%s\" should be '-', 'x', or '^'", string)); Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL); return TCL_ERROR; } numWindows = i; if ((objc - numWindows) & 1) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "extra option or option with no value", -1)); Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_PARAMETER", NULL); return TCL_ERROR; } /* * Go through all options looking for -in and -row, which are needed to be * found first to handle the special case where ^ is used on a row without * windows names, but with an -in option. Since all options are checked |
︙ | ︙ | |||
3047 3048 3049 3050 3051 3052 3053 | return TCL_ERROR; } masterPtr = GetGrid(other); InitMasterData(masterPtr); } else if (index == CONF_ROW) { if (Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK || tmp < 0) { | | | | | | 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 | return TCL_ERROR; } masterPtr = GetGrid(other); InitMasterData(masterPtr); } else if (index == CONF_ROW) { if (Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK || tmp < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad row value \"%s\": must be a non-negative integer", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "POSITIVE_INT", NULL); return TCL_ERROR; } defaultRow = tmp; } } /* |
︙ | ︙ | |||
3112 3113 3114 3115 3116 3117 3118 | } if (TkGetWindowFromObj(interp, tkwin, objv[j], &slave) != TCL_OK) { return TCL_ERROR; } if (Tk_TopWinHierarchy(slave)) { | | | > > | 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 | } if (TkGetWindowFromObj(interp, tkwin, objv[j], &slave) != TCL_OK) { return TCL_ERROR; } if (Tk_TopWinHierarchy(slave)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't manage \"%s\": it's a top-level window", Tcl_GetString(objv[j]))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL); return TCL_ERROR; } slavePtr = GetGrid(slave); /* * The following statement is taken from tkPack.c: * |
︙ | ︙ | |||
3140 3141 3142 3143 3144 3145 3146 | for (i = numWindows; i < objc; i += 2) { Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option", 0, &index); switch ((enum options) index) { case CONF_COLUMN: if (Tcl_GetIntFromObj(NULL, objv[i+1], &tmp) != TCL_OK || tmp < 0) { | > | | < > > | | | > | < > > | > | | > | | < > > | | < > | > | < > > | | < > | 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 | for (i = numWindows; i < objc; i += 2) { Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option", 0, &index); switch ((enum options) index) { case CONF_COLUMN: if (Tcl_GetIntFromObj(NULL, objv[i+1], &tmp) != TCL_OK || tmp < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad column value \"%s\": must be a non-negative integer", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "COLUMN", NULL); return TCL_ERROR; } if (SetSlaveColumn(interp, slavePtr, tmp, -1) != TCL_OK) { return TCL_ERROR; } break; case CONF_COLUMNSPAN: if (Tcl_GetIntFromObj(NULL, objv[i+1], &tmp) != TCL_OK || tmp <= 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad columnspan value \"%s\": must be a positive integer", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "SPAN", NULL); return TCL_ERROR; } if (SetSlaveColumn(interp, slavePtr, -1, tmp) != TCL_OK) { return TCL_ERROR; } break; case CONF_IN: if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other) != TCL_OK) { return TCL_ERROR; } if (other == slave) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "window can't be managed in itself", -1)); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL); return TCL_ERROR; } positionGiven = 1; masterPtr = GetGrid(other); InitMasterData(masterPtr); break; case CONF_STICKY: { int sticky = StringToSticky(Tcl_GetString(objv[i+1])); if (sticky == -1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad stickyness value \"%s\": must be" " a string containing n, e, s, and/or w", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "STICKY", NULL); return TCL_ERROR; } slavePtr->sticky = sticky; break; } case CONF_IPADX: if ((Tk_GetPixelsFromObj(NULL, slave, objv[i+1], &tmp) != TCL_OK) || (tmp < 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad ipadx value \"%s\": must be positive screen distance", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL); return TCL_ERROR; } slavePtr->iPadX = tmp * 2; break; case CONF_IPADY: if ((Tk_GetPixelsFromObj(NULL, slave, objv[i+1], &tmp) != TCL_OK) || (tmp < 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad ipady value \"%s\": must be positive screen distance", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL); return TCL_ERROR; } slavePtr->iPadY = tmp * 2; break; case CONF_PADX: if (TkParsePadAmount(interp, tkwin, objv[i+1], &slavePtr->padLeft, &slavePtr->padX) != TCL_OK) { return TCL_ERROR; } break; case CONF_PADY: if (TkParsePadAmount(interp, tkwin, objv[i+1], &slavePtr->padTop, &slavePtr->padY) != TCL_OK) { return TCL_ERROR; } break; case CONF_ROW: if (Tcl_GetIntFromObj(NULL, objv[i+1], &tmp) != TCL_OK || tmp < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad row value \"%s\": must be a non-negative integer", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "COLUMN", NULL); return TCL_ERROR; } if (SetSlaveRow(interp, slavePtr, tmp, -1) != TCL_OK) { return TCL_ERROR; } break; case CONF_ROWSPAN: if ((Tcl_GetIntFromObj(NULL, objv[i+1], &tmp) != TCL_OK) || tmp <= 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad rowspan value \"%s\": must be a positive integer", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "SPAN", NULL); return TCL_ERROR; } if (SetSlaveRow(interp, slavePtr, -1, tmp) != TCL_OK) { return TCL_ERROR; } break; } |
︙ | ︙ | |||
3301 3302 3303 3304 3305 3306 3307 | */ for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (Tk_TopWinHierarchy(ancestor)) { | > | | > | > | | | 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 | */ for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (Tk_TopWinHierarchy(ancestor)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't put %s inside %s", Tcl_GetString(objv[j]), Tk_PathName(masterPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); Unlink(slavePtr); return TCL_ERROR; } } /* * Try to make sure our master isn't managed by us. */ if (masterPtr->masterPtr == slavePtr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't put %s inside %s, would cause management loop", Tcl_GetString(objv[j]), Tk_PathName(masterPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL); Unlink(slavePtr); return TCL_ERROR; } Tk_ManageGeometry(slave, &gridMgrType, slavePtr); if (!(masterPtr->flags & DONT_PROPAGATE)) { |
︙ | ︙ | |||
3375 3376 3377 3378 3379 3380 3381 | * Now look for all the "^"'s. */ lastWindow = NULL; numSkip = 0; for (j = 0; j < numWindows; j++) { struct Gridder *otherPtr; | | | > | > | 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 | * Now look for all the "^"'s. */ lastWindow = NULL; numSkip = 0; for (j = 0; j < numWindows; j++) { struct Gridder *otherPtr; int match; /* Found a match for the ^ */ int lastRow, lastColumn; /* Implied end of table. */ string = Tcl_GetString(objv[j]); firstChar = string[0]; if (firstChar == '.') { lastWindow = string; numSkip = 0; } if (firstChar == REL_SKIP) { numSkip++; } if (firstChar != REL_VERT) { continue; } if (masterPtr == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't use '^', cant find master", -1)); Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL); return TCL_ERROR; } /* * Count the number of consecutive ^'s starting from this position. */ |
︙ | ︙ | |||
3445 3446 3447 3448 3449 3450 3451 | lastWindow = Tk_PathName(slavePtr->tkwin); numSkip = 0; break; } } } if (!match) { | > | | > | > | | | | | < > > | | | | | | | | | < < < < | 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 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 | lastWindow = Tk_PathName(slavePtr->tkwin); numSkip = 0; break; } } } if (!match) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't find slave to extend with \"^\"", -1)); Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL); return TCL_ERROR; } } if (masterPtr == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't determine master window", -1)); Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL); return TCL_ERROR; } SetGridSize(masterPtr); /* * If we have emptied this master from slaves it means we are no longer * handling it and should mark it as free. */ if (masterPtr->slavePtr == NULL && masterPtr->flags & ALLOCED_MASTER) { TkFreeGeometryMaster(masterPtr->tkwin, "grid"); masterPtr->flags &= ~ALLOCED_MASTER; } return TCL_OK; } /* *---------------------------------------------------------------------- * * StickyToObj * * Converts the internal boolean combination of "sticky" bits onto a Tcl * list element containing zero or more of n, s, e, or w. * * Results: * A new object is returned that holds the sticky representation. * * Side effects: * none. * *---------------------------------------------------------------------- */ static Tcl_Obj * StickyToObj( int flags) /* The sticky flags. */ { int count = 0; char buffer[4]; if (flags & STICK_NORTH) { buffer[count++] = 'n'; } if (flags & STICK_EAST) { buffer[count++] = 'e'; } if (flags & STICK_SOUTH) { buffer[count++] = 's'; } if (flags & STICK_WEST) { buffer[count++] = 'w'; } return Tcl_NewStringObj(buffer, count); } /* *---------------------------------------------------------------------- * * StringToSticky -- * |
︙ | ︙ |
Changes to generic/tkImage.c.
︙ | ︙ | |||
221 222 223 224 225 226 227 228 229 230 231 232 233 234 | ImageMaster *masterPtr; Image *imagePtr; Tcl_HashEntry *hPtr; Tcl_HashSearch search; char idString[16 + TCL_INTEGER_SPACE]; TkDisplay *dispPtr = winPtr->dispPtr; const char *arg, *name; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?args?"); return TCL_ERROR; } | > | 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | ImageMaster *masterPtr; 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 = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?args?"); return TCL_ERROR; } |
︙ | ︙ | |||
267 268 269 270 271 272 273 | if ((*arg == typePtr->name[0]) && (strcmp(arg, typePtr->name) == 0)) { break; } } } if (typePtr == NULL) { | | > | | 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | if ((*arg == typePtr->name[0]) && (strcmp(arg, typePtr->name) == 0)) { break; } } } if (typePtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "image type \"%s\" doesn't exist", arg)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "IMAGE_TYPE", arg, NULL); return TCL_ERROR; } /* * Figure out a name to use for the new image. */ |
︙ | ︙ | |||
300 301 302 303 304 305 306 | * the name of the current master 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) { | | | > > | 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | * the name of the current master 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. */ |
︙ | ︙ | |||
383 384 385 386 387 388 389 | } masterPtr->typePtr = typePtr; for (imagePtr = masterPtr->instancePtr; imagePtr != NULL; imagePtr = imagePtr->nextPtr) { imagePtr->instanceData = typePtr->getProc(imagePtr->tkwin, masterPtr->masterData); } | | | < | 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | } masterPtr->typePtr = typePtr; for (imagePtr = masterPtr->instancePtr; imagePtr != NULL; imagePtr = imagePtr->nextPtr) { imagePtr->instanceData = typePtr->getProc(imagePtr->tkwin, masterPtr->masterData); } Tcl_SetObjResult(interp, Tcl_NewStringObj( 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) { |
︙ | ︙ | |||
408 409 410 411 412 413 414 415 416 417 418 419 | break; case IMAGE_NAMES: if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, NULL); return TCL_ERROR; } hPtr = Tcl_FirstHashEntry(&winPtr->mainPtr->imageTable, &search); for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { masterPtr = Tcl_GetHashValue(hPtr); if (masterPtr->deleted) { continue; } | > | | > > > | > | > | 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 | 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)) { masterPtr = Tcl_GetHashValue(hPtr); if (masterPtr->deleted) { continue; } Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( 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; } resultObj = Tcl_NewObj(); for (typePtr = tsdPtr->imageTypeList; typePtr != NULL; typePtr = typePtr->nextPtr) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( typePtr->name, -1)); } for (typePtr = tsdPtr->oldImageTypeList; typePtr != NULL; typePtr = typePtr->nextPtr) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( typePtr->name, -1)); } Tcl_SetObjResult(interp, resultObj); break; case IMAGE_HEIGHT: case IMAGE_INUSE: case IMAGE_TYPE: case IMAGE_WIDTH: /* |
︙ | ︙ | |||
486 487 488 489 490 491 492 | Tcl_Panic("can't happen"); } break; } return TCL_OK; alreadyDeleted: | | > | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | Tcl_Panic("can't happen"); } break; } return TCL_OK; alreadyDeleted: Tcl_SetObjResult(interp, Tcl_ObjPrintf("image \"%s\" doesn't exist",arg)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "IMAGE", arg, NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * Tk_ImageChanged -- |
︙ | ︙ | |||
626 627 628 629 630 631 632 | imagePtr->widgetClientData = clientData; imagePtr->nextPtr = masterPtr->instancePtr; masterPtr->instancePtr = imagePtr; return (Tk_Image) imagePtr; noSuchImage: if (interp) { | > | > | 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 | imagePtr->widgetClientData = clientData; imagePtr->nextPtr = masterPtr->instancePtr; masterPtr->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); } return NULL; } /* *---------------------------------------------------------------------- * |
︙ | ︙ |
Changes to generic/tkImgBmap.c.
︙ | ︙ | |||
148 149 150 151 152 153 154 | static int ImgBmapCmd(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj *const objv[]); static void ImgBmapCmdDeletedProc(ClientData clientData); static void ImgBmapConfigureInstance(BitmapInstance *instancePtr); static int ImgBmapConfigureMaster(BitmapMaster *masterPtr, int argc, Tcl_Obj *const objv[], int flags); static int NextBitmapWord(ParseInfo *parseInfoPtr); | | | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | static int ImgBmapCmd(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj *const objv[]); static void ImgBmapCmdDeletedProc(ClientData clientData); static void ImgBmapConfigureInstance(BitmapInstance *instancePtr); static int ImgBmapConfigureMaster(BitmapMaster *masterPtr, int argc, Tcl_Obj *const objv[], int flags); static int NextBitmapWord(ParseInfo *parseInfoPtr); /* *---------------------------------------------------------------------- * * ImgBmapCreate -- * * This procedure is called by the Tk image code to create "test" images. * |
︙ | ︙ | |||
203 204 205 206 207 208 209 | if (ImgBmapConfigureMaster(masterPtr, argc, argv, 0) != TCL_OK) { ImgBmapDelete(masterPtr); return TCL_ERROR; } *clientDataPtr = masterPtr; return TCL_OK; } | | | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | if (ImgBmapConfigureMaster(masterPtr, argc, argv, 0) != TCL_OK) { ImgBmapDelete(masterPtr); return TCL_ERROR; } *clientDataPtr = masterPtr; return TCL_OK; } /* *---------------------------------------------------------------------- * * ImgBmapConfigureMaster -- * * This procedure is called when a bitmap image is created or * reconfigured. It process configuration options and resets any |
︙ | ︙ | |||
238 239 240 241 242 243 244 | * as TK_CONFIG_ARGV_ONLY. */ { BitmapInstance *instancePtr; int maskWidth, maskHeight, dummy1, dummy2; const char **argv = ckalloc((objc+1) * sizeof(char *)); for (dummy1 = 0; dummy1 < objc; dummy1++) { | | | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | * as TK_CONFIG_ARGV_ONLY. */ { BitmapInstance *instancePtr; int maskWidth, maskHeight, dummy1, dummy2; const char **argv = ckalloc((objc+1) * sizeof(char *)); for (dummy1 = 0; dummy1 < objc; dummy1++) { argv[dummy1] = Tcl_GetString(objv[dummy1]); } argv[objc] = NULL; if (Tk_ConfigureWidget(masterPtr->interp, Tk_MainWindow(masterPtr->interp), configSpecs, objc, argv, (char *) masterPtr, flags) != TCL_OK) { ckfree(argv); return TCL_ERROR; |
︙ | ︙ | |||
273 274 275 276 277 278 279 | if (masterPtr->maskData != NULL) { ckfree(masterPtr->maskData); masterPtr->maskData = NULL; } if ((masterPtr->maskFileString != NULL) || (masterPtr->maskDataString != NULL)) { if (masterPtr->data == NULL) { | > | < > > | | > > | | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 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 | if (masterPtr->maskData != NULL) { ckfree(masterPtr->maskData); masterPtr->maskData = NULL; } if ((masterPtr->maskFileString != NULL) || (masterPtr->maskDataString != NULL)) { if (masterPtr->data == NULL) { Tcl_SetObjResult(masterPtr->interp, Tcl_NewStringObj( "can't have mask without bitmap", -1)); Tcl_SetErrorCode(masterPtr->interp, "TK", "IMAGE", "BITMAP", "NO_BITMAP", NULL); return TCL_ERROR; } masterPtr->maskData = TkGetBitmapData(masterPtr->interp, masterPtr->maskDataString, masterPtr->maskFileString, &maskWidth, &maskHeight, &dummy1, &dummy2); if (masterPtr->maskData == NULL) { return TCL_ERROR; } if ((maskWidth != masterPtr->width) || (maskHeight != masterPtr->height)) { ckfree(masterPtr->maskData); masterPtr->maskData = NULL; Tcl_SetObjResult(masterPtr->interp, Tcl_NewStringObj( "bitmap and mask have different sizes", -1)); Tcl_SetErrorCode(masterPtr->interp, "TK", "IMAGE", "BITMAP", "MASK_SIZE", NULL); return TCL_ERROR; } } /* * Cycle through all of the instances of this image, regenerating the * information for each instance. Then force the image to be redisplayed * everywhere that it is used. */ for (instancePtr = masterPtr->instancePtr; instancePtr != NULL; instancePtr = instancePtr->nextPtr) { ImgBmapConfigureInstance(instancePtr); } Tk_ImageChanged(masterPtr->tkMaster, 0, 0, masterPtr->width, masterPtr->height, masterPtr->width, masterPtr->height); return TCL_OK; } /* *---------------------------------------------------------------------- * * ImgBmapConfigureInstance -- * * This procedure is called to create displaying information for a bitmap * image instance based on the configuration information in the master. |
︙ | ︙ | |||
442 443 444 445 446 447 448 | } instancePtr->gc = None; Tcl_AppendObjToErrorInfo(masterPtr->interp, Tcl_ObjPrintf( "\n (while configuring image \"%s\")", Tk_NameOfImage( masterPtr->tkMaster))); Tcl_BackgroundError(masterPtr->interp); } | | | 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | } instancePtr->gc = None; Tcl_AppendObjToErrorInfo(masterPtr->interp, Tcl_ObjPrintf( "\n (while configuring image \"%s\")", Tk_NameOfImage( masterPtr->tkMaster))); Tcl_BackgroundError(masterPtr->interp); } /* *---------------------------------------------------------------------- * * TkGetBitmapData -- * * Given a file name or ASCII string, this procedure parses the file or * string contents to produce binary data for a bitmap. |
︙ | ︙ | |||
469 470 471 472 473 474 475 | *---------------------------------------------------------------------- */ char * TkGetBitmapData( Tcl_Interp *interp, /* For reporting errors, or NULL. */ const char *string, /* String describing bitmap. May be NULL. */ | | > | > | > | | | 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 | *---------------------------------------------------------------------- */ char * TkGetBitmapData( Tcl_Interp *interp, /* For reporting errors, or NULL. */ const char *string, /* String describing bitmap. May be NULL. */ const char *fileName, /* Name of file containing bitmap description. * Used only if string is NULL. Must not be * NULL if string is NULL. */ int *widthPtr, int *heightPtr, /* Dimensions of bitmap get returned here. */ int *hotXPtr, int *hotYPtr) /* Position of hot spot or -1,-1. */ { int width, height, numBytes, hotX, hotY; const char *expandedFileName; char *p, *end; ParseInfo pi; char *data = NULL; Tcl_DString buffer; pi.string = string; if (string == NULL) { if ((interp != NULL) && Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't get bitmap data from a file in a safe interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "BITMAP_FILE", NULL); return NULL; } expandedFileName = Tcl_TranslateFileName(interp, fileName, &buffer); if (expandedFileName == NULL) { return NULL; } pi.chan = Tcl_OpenFileChannel(interp, expandedFileName, "r", 0); Tcl_DStringFree(&buffer); if (pi.chan == NULL) { if (interp != NULL) { Tcl_ResetResult(interp); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't read bitmap file \"%s\": %s", fileName, Tcl_PosixError(interp))); } return NULL; } if (Tcl_SetChannelOption(interp, pi.chan, "-translation", "binary") != TCL_OK) { return NULL; |
︙ | ︙ | |||
589 590 591 592 593 594 595 | } if ((pi.word[0] == '{') && (pi.word[1] == 0)) { goto getData; } } } else if ((pi.word[0] == '{') && (pi.word[1] == 0)) { if (interp != NULL) { | > | | > > | 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | } if ((pi.word[0] == '{') && (pi.word[1] == 0)) { goto getData; } } } else if ((pi.word[0] == '{') && (pi.word[1] == 0)) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "format error in bitmap data; looks like it's an" " obsolete X10 bitmap file", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "BITMAP", "OBSOLETE", NULL); } goto errorCleanup; } } /* * Now we've read everything but the data. Allocate an array and read in |
︙ | ︙ | |||
632 633 634 635 636 637 638 | *heightPtr = height; *hotXPtr = hotX; *hotYPtr = hotY; return data; error: if (interp != NULL) { | > | > | | 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 | *heightPtr = height; *hotXPtr = hotX; *hotYPtr = hotY; return data; error: if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "format error in bitmap data", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "BITMAP", "FORMAT", NULL); } errorCleanup: if (data != NULL) { ckfree(data); } if (pi.chan != NULL) { Tcl_Close(NULL, pi.chan); } return NULL; } /* *---------------------------------------------------------------------- * * NextBitmapWord -- * * This procedure retrieves the next word of information (stuff between * commas or white space) from a bitmap description. |
︙ | ︙ | |||
714 715 716 717 718 719 720 | } if (parseInfoPtr->wordLength == 0) { return TCL_ERROR; } parseInfoPtr->word[parseInfoPtr->wordLength] = 0; return TCL_OK; } | | | 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 | } if (parseInfoPtr->wordLength == 0) { return TCL_ERROR; } parseInfoPtr->word[parseInfoPtr->wordLength] = 0; return TCL_OK; } /* *-------------------------------------------------------------- * * ImgBmapCmd -- * * This procedure is invoked to process the Tcl command that corresponds * to an image managed by this module. See the user documentation for |
︙ | ︙ | |||
777 778 779 780 781 782 783 | TK_CONFIG_ARGV_ONLY); } default: Tcl_Panic("bad const entries to bmapOptions in ImgBmapCmd"); return TCL_OK; } } | | | 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 | TK_CONFIG_ARGV_ONLY); } default: Tcl_Panic("bad const entries to bmapOptions in ImgBmapCmd"); return TCL_OK; } } /* *---------------------------------------------------------------------- * * ImgBmapGet -- * * This procedure is called for each use of a bitmap image in a widget. * |
︙ | ︙ | |||
848 849 850 851 852 853 854 | if (instancePtr->nextPtr == NULL) { Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, masterPtr->width, masterPtr->height); } return instancePtr; } | | | 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 | if (instancePtr->nextPtr == NULL) { Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, masterPtr->width, masterPtr->height); } return instancePtr; } /* *---------------------------------------------------------------------- * * ImgBmapDisplay -- * * This procedure is invoked to draw a bitmap image. * |
︙ | ︙ | |||
908 909 910 911 912 913 914 | XCopyPlane(display, instancePtr->bitmap, drawable, instancePtr->gc, imageX, imageY, (unsigned) width, (unsigned) height, drawableX, drawableY, 1); if (masking) { XSetClipOrigin(display, instancePtr->gc, 0, 0); } } | | | 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 | XCopyPlane(display, instancePtr->bitmap, drawable, instancePtr->gc, imageX, imageY, (unsigned) width, (unsigned) height, drawableX, drawableY, 1); if (masking) { XSetClipOrigin(display, instancePtr->gc, 0, 0); } } /* *---------------------------------------------------------------------- * * ImgBmapFree -- * * This procedure is called when a widget ceases to use a particular * instance of an image. |
︙ | ︙ | |||
971 972 973 974 975 976 977 | prevPtr->nextPtr != instancePtr; prevPtr = prevPtr->nextPtr) { /* Empty loop body */ } prevPtr->nextPtr = instancePtr->nextPtr; } ckfree(instancePtr); } | | | 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 | prevPtr->nextPtr != instancePtr; prevPtr = prevPtr->nextPtr) { /* Empty loop body */ } prevPtr->nextPtr = instancePtr->nextPtr; } ckfree(instancePtr); } /* *---------------------------------------------------------------------- * * ImgBmapDelete -- * * This procedure is called by the image code to delete the master * structure for an image. |
︙ | ︙ | |||
1012 1013 1014 1015 1016 1017 1018 | } if (masterPtr->maskData != NULL) { ckfree(masterPtr->maskData); } Tk_FreeOptions(configSpecs, (char *) masterPtr, NULL, 0); ckfree(masterPtr); } | | | 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 | } if (masterPtr->maskData != NULL) { ckfree(masterPtr->maskData); } Tk_FreeOptions(configSpecs, (char *) masterPtr, NULL, 0); ckfree(masterPtr); } /* *---------------------------------------------------------------------- * * ImgBmapCmdDeletedProc -- * * This procedure is invoked when the image command for an image is * deleted. It deletes the image. |
︙ | ︙ | |||
1042 1043 1044 1045 1046 1047 1048 | BitmapMaster *masterPtr = clientData; masterPtr->imageCmd = NULL; if (masterPtr->tkMaster != NULL) { Tk_DeleteImage(masterPtr->interp, Tk_NameOfImage(masterPtr->tkMaster)); } } | | | 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 | BitmapMaster *masterPtr = clientData; masterPtr->imageCmd = NULL; if (masterPtr->tkMaster != NULL) { Tk_DeleteImage(masterPtr->interp, Tk_NameOfImage(masterPtr->tkMaster)); } } /* *---------------------------------------------------------------------- * * GetByte -- * * Get the next byte from the open channel. * |
︙ | ︙ | |||
1073 1074 1075 1076 1077 1078 1079 | size = Tcl_Read(chan, &buffer, 1); if (size <= 0) { return EOF; } else { return buffer; } } | | < | 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 | size = Tcl_Read(chan, &buffer, 1); if (size <= 0) { return EOF; } else { return buffer; } } /* *---------------------------------------------------------------------- * * ImgBmapPsImagemask -- * * This procedure generates postscript suitable for rendering a single * bitmap of an image. A single bitmap image might contain both a |
︙ | ︙ | |||
1096 1097 1098 1099 1100 1101 1102 | * * 2. The origin of the postscript coordinate system is set to the * lower left corner of the bitmap. * * 3. The postscript coordinate system has been scaled so that the * entire bitmap is one unit squared. * | < < < < < < > | | | | < | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 | * * 2. The origin of the postscript coordinate system is set to the * lower left corner of the bitmap. * * 3. The postscript coordinate system has been scaled so that the * entire bitmap is one unit squared. * * Results: * None. * * Side effects: * Postscript code is appended to psObj. * *---------------------------------------------------------------------- */ static void ImgBmapPsImagemask( Tcl_Obj *psObj, /* Append postscript to this buffer. */ int width, int height, /* Width and height of the bitmap in pixels */ char *data) /* Data for the bitmap. */ { int i, j, nBytePerRow; /* * The bit order of bitmaps in Tk is the opposite of the bit order that * postscript uses. (In Tk, the least significant bit is on the right side * of the bitmap and in postscript the least significant bit is shown on * the left.) The following array is used to reverse the order of bits * within a byte so that the bits will be in the order postscript expects. |
︙ | ︙ | |||
1146 1147 1148 1149 1150 1151 1152 | 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255, }; | < < < < < < | | < | | | | < | | < | < | > | > > > > > > > > > > > > > > > > > > > > > | | < | | < > < > > > | | | > | | < > < > > > | | > | > > > | > > > > | > > > | | | 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 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 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 | 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255, }; Tcl_AppendPrintfToObj(psObj, "0 0 moveto %d %d true [%d 0 0 %d 0 %d] {<\n", width, height, width, -height, height); nBytePerRow = (width + 7) / 8; for (i=0; i<height; i++) { for (j=0; j<nBytePerRow; j++) { Tcl_AppendPrintfToObj(psObj, " %02x", bit_reverse[0xff & data[i*nBytePerRow + j]]); } Tcl_AppendToObj(psObj, "\n", -1); } Tcl_AppendToObj(psObj, ">} imagemask \n", -1); } /* *---------------------------------------------------------------------- * * ImgBmapPostscript -- * * This procedure generates postscript for rendering a bitmap image. * * Results: * On success, this routine writes postscript code into interp->result * and returns TCL_OK TCL_ERROR is returned and an error message is left * in interp->result if anything goes wrong. * * Side effects: * None. * *---------------------------------------------------------------------- */ static int ImgBmapPostscript( ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psinfo, int x, int y, int width, int height, int prepass) { BitmapMaster *masterPtr = clientData; Tcl_InterpState interpState; Tcl_Obj *psObj; if (prepass) { return TCL_OK; } /* * There is nothing to do for bitmaps with zero width or height. */ if (width<=0 || height<=0 || masterPtr->width<=0 || masterPtr->height<=0){ return TCL_OK; } /* * Some postscript implementations cannot handle bitmap strings longer * than about 60k characters. If the bitmap data is that big or bigger, * we bail out. */ if (masterPtr->width*masterPtr->height > 60000) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "unable to generate postscript for bitmaps larger than 60000" " pixels", -1)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", NULL); return TCL_ERROR; } /* * Make our working space. */ psObj = Tcl_NewObj(); interpState = Tcl_SaveInterpState(interp, TCL_OK); /* * Translate the origin of the coordinate system to be the lower-left * corner of the bitmap and adjust the scale of the coordinate system so * that entire bitmap covers one square unit of the page. The calling * function put a "gsave" into the postscript and will add a "grestore" at * after this routine returns, so it is safe to make whatever changes are * necessary here. */ if (x != 0 || y != 0) { Tcl_AppendPrintfToObj(psObj, "%d %d moveto\n", x, y); } if (width != 1 || height != 1) { Tcl_AppendPrintfToObj(psObj, "%d %d scale\n", width, height); } /* * Color the background, if there is one. This step is skipped if the * background is transparent. If the background is not transparent and * there is no background mask, then color the complete rectangle that * encloses the bitmap. If there is a background mask, then only apply * color to the bits specified by the mask. */ if ((masterPtr->bgUid != NULL) && (masterPtr->bgUid[0] != '\000')) { XColor color; TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), masterPtr->bgUid, &color); Tcl_ResetResult(interp); if (Tk_PostscriptColor(interp, psinfo, &color) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (masterPtr->maskData == NULL) { Tcl_AppendToObj(psObj, "0 0 moveto 1 0 rlineto 0 1 rlineto -1 0 rlineto " "closepath fill\n", -1); } else { ImgBmapPsImagemask(psObj, masterPtr->width, masterPtr->height, masterPtr->maskData); } } /* * Draw the bitmap foreground, assuming there is one. */ if ((masterPtr->fgUid != NULL) && (masterPtr->data != NULL)) { XColor color; TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), masterPtr->fgUid, &color); Tcl_ResetResult(interp); if (Tk_PostscriptColor(interp, psinfo, &color) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); ImgBmapPsImagemask(psObj, masterPtr->width, masterPtr->height, masterPtr->data); } /* * Plug the accumulated postscript back into the result. */ (void) Tcl_RestoreInterpState(interp, interpState); Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj); Tcl_DecrRefCount(psObj); return TCL_OK; error: Tcl_DiscardInterpState(interpState); Tcl_DecrRefCount(psObj); return TCL_ERROR; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkImgGIF.c.
︙ | ︙ | |||
426 427 428 429 430 431 432 | } for (i = 1; i < argc; i++) { if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option name", 0, &nBytes) != TCL_OK) { return TCL_ERROR; } if (i == (argc-1)) { | > | | > > | | | | > > | > | 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 | } for (i = 1; i < argc; i++) { if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option name", 0, &nBytes) != TCL_OK) { return TCL_ERROR; } if (i == (argc-1)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "no value given for \"%s\" option", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "OPT_VALUE", NULL); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[++i], &index) != TCL_OK) { return TCL_ERROR; } } /* * Read the GIF file header and check for some sanity. */ if (!ReadGIFHeader(gifConfPtr, chan, &fileWidth, &fileHeight)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't read GIF header from file \"%s\"", fileName)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "HEADER", NULL); return TCL_ERROR; } if ((fileWidth <= 0) || (fileHeight <= 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "GIF image file \"%s\" has dimension(s) <= 0", fileName)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "BOGUS_SIZE", NULL); return TCL_ERROR; } /* * Get the general colormap information. */ if (Fread(gifConfPtr, buf, 1, 3, chan) != 3) { return TCL_OK; } bitPixel = 2 << (buf[0] & 0x07); if (BitSet(buf[0], LOCALCOLORMAP)) { /* Global Colormap */ if (!ReadColorMap(gifConfPtr, chan, bitPixel, colorMap)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "error reading color map", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "COLOR_MAP", NULL); return TCL_ERROR; } } if ((srcX + width) > fileWidth) { width = fileWidth - srcX; } |
︙ | ︙ | |||
497 498 499 500 501 502 503 | while (1) { if (Fread(gifConfPtr, buf, 1, 1, chan) != 1) { /* * Premature end of image. */ | | | > > > | > | | > > > | > | | | > > | 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 | while (1) { if (Fread(gifConfPtr, buf, 1, 1, chan) != 1) { /* * Premature end of image. */ Tcl_SetObjResult(interp, Tcl_NewStringObj( "premature end of image data for this index", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "PREMATURE_END", NULL); goto error; } switch (buf[0]) { case GIF_TERMINATOR: Tcl_SetObjResult(interp, Tcl_NewStringObj( "no image data for this index", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "NO_DATA", NULL); goto error; case GIF_EXTENSION: /* * This is a GIF extension. */ if (Fread(gifConfPtr, buf, 1, 1, chan) != 1) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "error reading extension function code in GIF image", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "BAD_EXT", NULL); goto error; } if (DoExtension(gifConfPtr, chan, buf[0], gifConfPtr->workingBuffer, &transparent) < 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "error reading extension in GIF image", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "BAD_EXT", NULL); goto error; } continue; case GIF_START: if (Fread(gifConfPtr, buf, 1, 9, chan) != 9) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "couldn't read left/top/width/height in GIF image", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "DIMENSIONS", NULL); goto error; } break; default: /* * Not a valid start character; ignore it. */ |
︙ | ︙ | |||
557 558 559 560 561 562 563 | if (index--) { /* * This is not the GIF frame we want to read: skip it. */ if (BitSet(buf[8], LOCALCOLORMAP)) { if (!ReadColorMap(gifConfPtr, chan, bitPixel, colorMap)) { | > | > > | 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | if (index--) { /* * This is not the GIF frame we want to read: skip it. */ if (BitSet(buf[8], LOCALCOLORMAP)) { if (!ReadColorMap(gifConfPtr, chan, bitPixel, colorMap)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "error reading color map", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "COLOR_MAP", NULL); goto error; } } /* * If we've not yet allocated a trash buffer, do so now. */ |
︙ | ︙ | |||
604 605 606 607 608 609 610 | /* * Found the frame we want to read. Next, check for a local color map for * this frame. */ if (BitSet(buf[8], LOCALCOLORMAP)) { if (!ReadColorMap(gifConfPtr, chan, bitPixel, colorMap)) { | > | > | 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | /* * Found the frame we want to read. Next, check for a local color map for * this frame. */ if (BitSet(buf[8], LOCALCOLORMAP)) { if (!ReadColorMap(gifConfPtr, chan, bitPixel, colorMap)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "error reading color map", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "COLOR_MAP", NULL); goto error; } } /* * Extract the location within the overall visible image to put the data * in this frame, together with the size of this frame. |
︙ | ︙ | |||
655 656 657 658 659 660 661 | block.offset[2] = 2; block.offset[3] = (transparent>=0) ? 3 : 0; block.pitch = block.pixelSize * imageWidth; nBytes = block.pitch * imageHeight; block.pixelPtr = ckalloc(nBytes); if (ReadImage(gifConfPtr, interp, block.pixelPtr, chan, imageWidth, | | | | 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 | block.offset[2] = 2; block.offset[3] = (transparent>=0) ? 3 : 0; block.pitch = block.pixelSize * imageWidth; nBytes = block.pitch * imageHeight; block.pixelPtr = ckalloc(nBytes); if (ReadImage(gifConfPtr, interp, block.pixelPtr, chan, imageWidth, imageHeight, colorMap, srcX, srcY, BitSet(buf[8], INTERLACE), transparent) != TCL_OK) { ckfree(block.pixelPtr); goto error; } if (Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY, width, height, TK_PHOTO_COMPOSITE_SET) != TCL_OK) { ckfree(block.pixelPtr); goto error; } ckfree(block.pixelPtr); } /* * We've successfully read the GIF frame (or there was nothing to read, * which suits as well). We're done. */ Tcl_SetObjResult(interp, Tcl_NewStringObj(tkImgFmtGIF.name, -1)); result = TCL_OK; error: /* * If a trash buffer has been allocated, free it now. */ |
︙ | ︙ | |||
899 900 901 902 903 904 905 | int label, unsigned char *buf, int *transparent) { int count; switch (label) { | | | | | | 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 | int label, unsigned char *buf, int *transparent) { int count; switch (label) { case 0x01: /* Plain Text Extension */ break; case 0xff: /* Application Extension */ break; case 0xfe: /* Comment Extension */ do { count = GetDataBlock(gifConfPtr, chan, buf); } while (count > 0); return count; case 0xf9: /* Graphic Control Extension */ count = GetDataBlock(gifConfPtr, chan, buf); if (count < 0) { return 1; } if ((buf[0] & 0x1) != 0) { *transparent = buf[3]; } |
︙ | ︙ | |||
1007 1008 1009 1010 1011 1012 1013 | int code, firstCode, v; /* * Initialize the decoder */ if (Fread(gifConfPtr, &initialCodeSize, 1, 1, chan) <= 0) { | | | | > | 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 | int code, firstCode, v; /* * Initialize the decoder */ if (Fread(gifConfPtr, &initialCodeSize, 1, 1, chan) <= 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error reading GIF image: %s", Tcl_PosixError(interp))); return TCL_ERROR; } if (initialCodeSize > MAX_LWZ_BITS) { Tcl_SetObjResult(interp, Tcl_NewStringObj("malformed image", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "MALFORMED", NULL); return TCL_ERROR; } if (transparent != -1) { cmap[transparent][CM_RED] = 0; cmap[transparent][CM_GREEN] = 0; cmap[transparent][CM_BLUE] = 0; |
︙ | ︙ | |||
1412 1413 1414 1415 1416 1417 1418 | if (handle->length-- <= 0) { return GIF_DONE; } c = char64(*handle->data); handle->data++; } while (c == GIF_SPACE); | | | 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 | if (handle->length-- <= 0) { return GIF_DONE; } c = char64(*handle->data); handle->data++; } while (c == GIF_SPACE); if (c > GIF_SPECIAL) { handle->state = GIF_DONE; return handle->c; } switch (handle->state++) { case 0: handle->c = c<<2; |
︙ | ︙ | |||
1685 1686 1687 1688 1689 1690 1691 | width = blockPtr->width; height = blockPtr->height; state.pixelOffset = blockPtr->pixelPtr + blockPtr->offset[0]; state.pixelPitch = blockPtr->pitch; SaveMap(&state, blockPtr); if (state.num >= MAXCOLORMAPSIZE) { | | > | 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 | width = blockPtr->width; height = blockPtr->height; state.pixelOffset = blockPtr->pixelPtr + blockPtr->offset[0]; state.pixelPitch = blockPtr->pitch; SaveMap(&state, blockPtr); if (state.num >= MAXCOLORMAPSIZE) { Tcl_SetObjResult(interp, Tcl_NewStringObj("too many colors", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "COLORFUL", NULL); return TCL_ERROR; } if (state.num<2) { state.num = 2; } c = LSB(width); writeProc(handle, (char *) &c, 1); |
︙ | ︙ |
Changes to generic/tkImgPNG.c.
︙ | ︙ | |||
330 331 332 333 334 335 336 | /* * Initialize Zlib inflate/deflate stream. */ if (Tcl_ZlibStreamInit(NULL, dir, TCL_ZLIB_FORMAT_ZLIB, TCL_ZLIB_COMPRESS_DEFAULT, NULL, &pngPtr->stream) != TCL_OK) { | > | > | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | /* * Initialize Zlib inflate/deflate stream. */ if (Tcl_ZlibStreamInit(NULL, dir, TCL_ZLIB_FORMAT_ZLIB, TCL_ZLIB_COMPRESS_DEFAULT, NULL, &pngPtr->stream) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "zlib initialization failed", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "ZLIB_INIT", NULL); if (objPtr) { Tcl_DecrRefCount(objPtr); } return TCL_ERROR; } return TCL_OK; |
︙ | ︙ | |||
511 512 513 514 515 516 517 | if (c64 & PNG64_SPECIAL) { break; } } if (destSz) { | > | > | 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 | if (c64 & PNG64_SPECIAL) { break; } } if (destSz) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "unexpected end of image data", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "EARLY_END", NULL); return TCL_ERROR; } return TCL_OK; } /* |
︙ | ︙ | |||
553 554 555 556 557 558 559 | unsigned long *crcPtr) { /* * Check to make sure the number of requested bytes are available. */ if (pngPtr->strDataLen < destSz) { | > | > | 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | unsigned long *crcPtr) { /* * Check to make sure the number of requested bytes are available. */ if (pngPtr->strDataLen < destSz) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "unexpected end of image data", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "EARLY_END", NULL); return TCL_ERROR; } while (destSz) { int blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ); memcpy(destPtr, pngPtr->strDataBuf, blockSz); |
︙ | ︙ | |||
614 615 616 617 618 619 620 | return ReadByteArray(interp, pngPtr, destPtr, destSz, crcPtr); } while (destSz) { int blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ); blockSz = Tcl_Read(pngPtr->channel, (char *)destPtr, blockSz); | < < < < < > | | 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | return ReadByteArray(interp, pngPtr, destPtr, destSz, crcPtr); } while (destSz) { int blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ); blockSz = Tcl_Read(pngPtr->channel, (char *)destPtr, blockSz); if (blockSz < 0) { /* TODO: failure info... */ Tcl_SetObjResult(interp, Tcl_ObjPrintf( "channel read failed: %s", Tcl_PosixError(interp))); return TCL_ERROR; } /* * Update CRC, pointer, and remaining count if anything was read. */ |
︙ | ︙ | |||
643 644 645 646 647 648 649 | } /* * Check for EOF before all desired data was read. */ if (destSz && Tcl_Eof(pngPtr->channel)) { | > | > | 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 | } /* * Check for EOF before all desired data was read. */ if (destSz && Tcl_Eof(pngPtr->channel)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "unexpected end of file", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "EOF", NULL); return TCL_ERROR; } } return TCL_OK; } |
︙ | ︙ | |||
728 729 730 731 732 733 734 | } /* * Compare the read CRC to what we calculate to make sure they match. */ if (calculated != chunked) { | | > | 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 | } /* * Compare the read CRC to what we calculate to make sure they match. */ if (calculated != chunked) { Tcl_SetObjResult(interp, Tcl_NewStringObj("CRC check failed", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "CRC", NULL); return TCL_ERROR; } return TCL_OK; } /* |
︙ | ︙ | |||
878 879 880 881 882 883 884 | if (ReadData(interp, pngPtr, pc, 4, NULL) == TCL_ERROR) { return TCL_ERROR; } temp = PNG_INT32(pc[0], pc[1], pc[2], pc[3]); if (temp > INT_MAX) { | | | > > | 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 | if (ReadData(interp, pngPtr, pc, 4, NULL) == TCL_ERROR) { return TCL_ERROR; } temp = PNG_INT32(pc[0], pc[1], pc[2], pc[3]); if (temp > INT_MAX) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "chunk size is out of supported range on this architecture", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "OUTSIZE", NULL); return TCL_ERROR; } chunkSz = (int) temp; crc = Tcl_ZlibCRC32(0, NULL, 0); /* |
︙ | ︙ | |||
963 964 965 966 967 968 969 | default: /* * Unknown chunk type. If it's critical, we can't continue. */ if (!(chunkType & PNG_CF_ANCILLARY)) { | > > > > > > | | > > > | > > > > > > > > > > > > | > > | 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 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 | default: /* * Unknown chunk type. If it's critical, we can't continue. */ if (!(chunkType & PNG_CF_ANCILLARY)) { if (chunkType & PNG_INT32(128,128,128,128)) { /* * No nice ASCII conversion; shouldn't happen either, but * we'll be doubly careful. */ Tcl_SetObjResult(interp, Tcl_NewStringObj( "encountered an unsupported criticial chunk type", -1)); } else { char typeString[5]; typeString[0] = (char) ((chunkType >> 24) & 255); typeString[1] = (char) ((chunkType >> 16) & 255); typeString[2] = (char) ((chunkType >> 8) & 255); typeString[3] = (char) (chunkType & 255); typeString[4] = '\0'; Tcl_SetObjResult(interp, Tcl_ObjPrintf( "encountered an unsupported criticial chunk type" " \"%s\"", typeString)); } Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "UNSUPPORTED_CRITICAL", NULL); return TCL_ERROR; } /* * Check to see if the chunk type has legal bytes. */ for (i=0 ; i<4 ; i++) { if ((pc[i] < 65) || (pc[i] > 122) || ((pc[i] > 90) && (pc[i] < 97))) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid chunk type", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "INVALID_CHUNK", NULL); return TCL_ERROR; } } /* * It seems to be an otherwise legally labelled ancillary chunk * that we don't want, so skip it after at least checking its CRC. |
︙ | ︙ | |||
1032 1033 1034 1035 1036 1037 1038 | */ static int CheckColor( Tcl_Interp *interp, PNGImage *pngPtr) { | < | | | | > > > > | | < < | < | < | 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 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 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 | */ static int CheckColor( Tcl_Interp *interp, PNGImage *pngPtr) { int offset; /* * Verify the color type is valid and the bit depth is allowed. */ switch (pngPtr->colorType) { case PNG_COLOR_GRAY: pngPtr->numChannels = 1; if ((1 != pngPtr->bitDepth) && (2 != pngPtr->bitDepth) && (4 != pngPtr->bitDepth) && (8 != pngPtr->bitDepth) && (16 != pngPtr->bitDepth)) { goto unsupportedDepth; } break; case PNG_COLOR_RGB: pngPtr->numChannels = 3; if ((8 != pngPtr->bitDepth) && (16 != pngPtr->bitDepth)) { goto unsupportedDepth; } break; case PNG_COLOR_PLTE: pngPtr->numChannels = 1; if ((1 != pngPtr->bitDepth) && (2 != pngPtr->bitDepth) && (4 != pngPtr->bitDepth) && (8 != pngPtr->bitDepth)) { goto unsupportedDepth; } break; case PNG_COLOR_GRAYALPHA: pngPtr->numChannels = 2; if ((8 != pngPtr->bitDepth) && (16 != pngPtr->bitDepth)) { goto unsupportedDepth; } break; case PNG_COLOR_RGBA: pngPtr->numChannels = 4; if ((8 != pngPtr->bitDepth) && (16 != pngPtr->bitDepth)) { unsupportedDepth: Tcl_SetObjResult(interp, Tcl_NewStringObj( "bit depth is not allowed for given color type", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_DEPTH", NULL); return TCL_ERROR; } break; default: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown color type field %d", pngPtr->colorType)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "UNKNOWN_COLOR", NULL); return TCL_ERROR; } /* * Set up the Tk photo block's pixel size and channel offsets. offset * array elements should already be 0 from the memset during InitPNGImage. */ |
︙ | ︙ | |||
1113 1114 1115 1116 1117 1118 1119 | /* * Calculate the block pitch, which is the number of bytes per line in the * image, given image width and depth of color. Make sure that it it isn't * larger than Tk can handle. */ if (pngPtr->block.width > INT_MAX / pngPtr->block.pixelSize) { | | | | > | | > > | 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 | /* * Calculate the block pitch, which is the number of bytes per line in the * image, given image width and depth of color. Make sure that it it isn't * larger than Tk can handle. */ if (pngPtr->block.width > INT_MAX / pngPtr->block.pixelSize) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "image pitch is out of supported range on this architecture", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "PITCH", NULL); return TCL_ERROR; } pngPtr->block.pitch = pngPtr->block.pixelSize * pngPtr->block.width; /* * Calculate the total size of the image as represented to Tk given pitch * and image height. Make sure that it isn't larger than Tk can handle. */ if (pngPtr->block.height > INT_MAX / pngPtr->block.pitch) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "image total size is out of supported range on this architecture", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "SIZE", NULL); return TCL_ERROR; } pngPtr->blockLen = pngPtr->block.height * pngPtr->block.pitch; /* * Determine number of bytes per pixel in the source for later use. |
︙ | ︙ | |||
1155 1156 1157 1158 1159 1160 1161 | case PNG_COLOR_GRAYALPHA: pngPtr->bytesPerPixel = (pngPtr->bitDepth > 8) ? 4 : 2; break; case PNG_COLOR_RGBA: pngPtr->bytesPerPixel = (pngPtr->bitDepth > 8) ? 8 : 4; break; default: | | | > | 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 | case PNG_COLOR_GRAYALPHA: pngPtr->bytesPerPixel = (pngPtr->bitDepth > 8) ? 4 : 2; break; case PNG_COLOR_RGBA: pngPtr->bytesPerPixel = (pngPtr->bitDepth > 8) ? 8 : 4; break; default: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown color type %d", pngPtr->colorType)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "UNKNOWN_COLOR", NULL); return TCL_ERROR; } /* * Calculate scale factor for bit depths less than 8, in order to adjust * them to a minimum of 8 bits per pixel in the Tk image. */ |
︙ | ︙ | |||
1236 1237 1238 1239 1240 1241 1242 | return TCL_ERROR; } mismatch = memcmp(sigBuf, pngSignature, PNG_SIG_SZ); } if (mismatch) { | > | < > > | > > | > | | | > | 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 | return TCL_ERROR; } mismatch = memcmp(sigBuf, pngSignature, PNG_SIG_SZ); } if (mismatch) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "data stream does not have a PNG signature", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "NO_SIG", NULL); return TCL_ERROR; } if (ReadChunkHeader(interp, pngPtr, &chunkSz, &chunkType, &crc) == TCL_ERROR) { return TCL_ERROR; } /* * Read in the IHDR (header) chunk for width, height, etc. * * The first chunk in the file must be the IHDR (headr) chunk. */ if (chunkType != CHUNK_IHDR) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "expected IHDR chunk type", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "NO_IHDR", NULL); return TCL_ERROR; } if (chunkSz != 13) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid IHDR chunk size", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_IHDR", NULL); return TCL_ERROR; } /* * Read and verify the image width and height to be sure Tk can handle its * dimensions. The PNG specification does not permit zero-width or * zero-height images. */ if (ReadInt32(interp, pngPtr, &width, &crc) == TCL_ERROR) { return TCL_ERROR; } if (ReadInt32(interp, pngPtr, &height, &crc) == TCL_ERROR) { return TCL_ERROR; } if (!width || !height || (width > INT_MAX) || (height > INT_MAX)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "image dimensions are invalid or beyond architecture limits", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "DIMENSIONS", NULL); return TCL_ERROR; } /* * Set height and width for the Tk photo block. */ |
︙ | ︙ | |||
1321 1322 1323 1324 1325 1326 1327 | * Only one compression method is currently defined by the standard. */ if (ReadData(interp, pngPtr, &pngPtr->compression, 1, &crc) == TCL_ERROR) { return TCL_ERROR; } | | > | > | > | > > | > | 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 | * Only one compression method is currently defined by the standard. */ if (ReadData(interp, pngPtr, &pngPtr->compression, 1, &crc) == TCL_ERROR) { return TCL_ERROR; } if (pngPtr->compression != PNG_COMPRESS_DEFLATE) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown compression method %d", pngPtr->compression)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_COMPRESS", NULL); return TCL_ERROR; } /* * Only one filter method is currently defined by the standard; the method * has five actual filter types associated with it. */ if (ReadData(interp, pngPtr, &pngPtr->filter, 1, &crc) == TCL_ERROR) { return TCL_ERROR; } if (pngPtr->filter != PNG_FILTMETH_STANDARD) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown filter method %d", pngPtr->filter)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_FILTER", NULL); return TCL_ERROR; } if (ReadData(interp, pngPtr, &pngPtr->interlace, 1, &crc) == TCL_ERROR) { return TCL_ERROR; } switch (pngPtr->interlace) { case PNG_INTERLACE_NONE: case PNG_INTERLACE_ADAM7: break; default: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown interlace method %d", pngPtr->interlace)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_INTERLACE", NULL); return TCL_ERROR; } return CheckCRC(interp, pngPtr, crc); } /* |
︙ | ︙ | |||
1393 1394 1395 1396 1397 1398 1399 | /* * This chunk is mandatory for color type 3 and forbidden for 2 and 6. */ switch (pngPtr->colorType) { case PNG_COLOR_GRAY: case PNG_COLOR_GRAYALPHA: | > | > | > | > | 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 1465 1466 1467 1468 1469 1470 1471 | /* * This chunk is mandatory for color type 3 and forbidden for 2 and 6. */ switch (pngPtr->colorType) { case PNG_COLOR_GRAY: case PNG_COLOR_GRAYALPHA: Tcl_SetObjResult(interp, Tcl_NewStringObj( "PLTE chunk type forbidden for grayscale", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "PLTE_UNEXPECTED", NULL); return TCL_ERROR; default: break; } /* * The palette chunk contains from 1 to 256 palette entries. Each entry * consists of a 3-byte RGB value. It must therefore contain a non-zero * multiple of 3 bytes, up to 768. */ if (!chunkSz || (chunkSz > PNG_PLTE_MAXSZ) || (chunkSz % 3)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid palette chunk size", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_PLTE", NULL); return TCL_ERROR; } /* * Read the palette contents and stash them for later, possibly. */ |
︙ | ︙ | |||
1470 1471 1472 1473 1474 1475 1476 | int chunkSz, unsigned long crc) { unsigned char buffer[PNG_TRNS_MAXSZ]; int i; if (pngPtr->colorType & PNG_COLOR_ALPHA) { | | | > > | > | 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 | int chunkSz, unsigned long crc) { unsigned char buffer[PNG_TRNS_MAXSZ]; int i; if (pngPtr->colorType & PNG_COLOR_ALPHA) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "tRNS chunk not allowed color types with a full alpha channel", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "INVALID_TRNS", NULL); return TCL_ERROR; } /* * For indexed color, there is up to one single-byte transparency value * per palette entry (thus a max of 256). */ if (chunkSz > PNG_TRNS_MAXSZ) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid tRNS chunk size", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_TRNS", NULL); return TCL_ERROR; } /* * Read in the raw transparency information. */ |
︙ | ︙ | |||
1511 1512 1513 1514 1515 1516 1517 | /* * The number of tRNS entries must be less than or equal to the number * of PLTE entries, and consists of a single-byte alpha level for the * corresponding PLTE entry. */ if (chunkSz > pngPtr->paletteLen) { | | | | | | | > | 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 | /* * The number of tRNS entries must be less than or equal to the number * of PLTE entries, and consists of a single-byte alpha level for the * corresponding PLTE entry. */ if (chunkSz > pngPtr->paletteLen) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "size of tRNS chunk is too large for the palette", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "TRNS_SIZE", NULL); return TCL_ERROR; } for (i=0 ; i<chunkSz ; i++) { pngPtr->palette[i].alpha = buffer[i]; } break; case PNG_COLOR_GRAY: /* * Grayscale uses a single 2-byte gray level, which we'll store in * palette index 0, since we're not using the palette. */ if (chunkSz != 2) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid tRNS chunk size - must 2 bytes for grayscale", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_TRNS", NULL); return TCL_ERROR; } /* * According to the PNG specs, if the bit depth is less than 16, then * only the lower byte is used. */ |
︙ | ︙ | |||
1555 1556 1557 1558 1559 1560 1561 | case PNG_COLOR_RGB: /* * TrueColor uses a single RRGGBB triplet. */ if (chunkSz != 6) { | | | | | 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 | case PNG_COLOR_RGB: /* * TrueColor uses a single RRGGBB triplet. */ if (chunkSz != 6) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid tRNS chunk size - must 6 bytes for RGB", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_TRNS", NULL); return TCL_ERROR; } /* * According to the PNG specs, if the bit depth is less than 16, then * only the lower byte is used. But the tRNS chunk still contains two * bytes per channel. |
︙ | ︙ | |||
1738 1739 1740 1741 1742 1743 1744 | while (raw < end) { *raw++ += *rawBpp++; } } break; default: | > | > | 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 | while (raw < end) { *raw++ += *rawBpp++; } } break; default: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid filter type %d", *thisLine)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_FILTER", NULL); return TCL_ERROR; } return TCL_OK; } /* |
︙ | ︙ | |||
1905 1906 1907 1908 1909 1910 1911 | /* * Apply boolean transparency via tRNS data if necessary (where * necessary means a tRNS chunk was provided and we're not using an * alpha channel or indexed alpha). */ if ((PNG_COLOR_PLTE != pngPtr->colorType) && | | | 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 | /* * Apply boolean transparency via tRNS data if necessary (where * necessary means a tRNS chunk was provided and we're not using an * alpha channel or indexed alpha). */ if ((PNG_COLOR_PLTE != pngPtr->colorType) && !(pngPtr->colorType & PNG_COLOR_ALPHA)) { unsigned char alpha; if (pngPtr->useTRNS) { if (memcmp(lastPixel, pngPtr->transVal, pngPtr->bytesPerPixel) == 0) { alpha = 0x00; } else { |
︙ | ︙ | |||
2045 2046 2047 2048 2049 2050 2051 | unsigned char *inputPtr = NULL; /* * Check for end of zlib stream. */ if (Tcl_ZlibStreamEof(pngPtr->stream)) { | > | > | | 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 | unsigned char *inputPtr = NULL; /* * Check for end of zlib stream. */ if (Tcl_ZlibStreamEof(pngPtr->stream)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "extra data after end of zlib stream", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "EXTRA_DATA", NULL); return TCL_ERROR; } inputObj = Tcl_NewObj(); Tcl_IncrRefCount(inputObj); inputPtr = Tcl_SetByteArrayLength(inputObj, blockSz); |
︙ | ︙ | |||
2085 2086 2087 2088 2089 2090 2091 | pngPtr->phaseSize - len1) == TCL_ERROR) { return TCL_ERROR; } Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, &len2); if (len2 == pngPtr->phaseSize) { if (pngPtr->phase > 7) { | | | | > > | 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 | pngPtr->phaseSize - len1) == TCL_ERROR) { return TCL_ERROR; } Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, &len2); if (len2 == pngPtr->phaseSize) { if (pngPtr->phase > 7) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "extra data after final scan line of final phase", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "EXTRA_DATA", NULL); return TCL_ERROR; } if (DecodeLine(interp, pngPtr) == TCL_ERROR) { return TCL_ERROR; } |
︙ | ︙ | |||
2130 2131 2132 2133 2134 2135 2136 | /* * Ensure that if we've got to the end of the compressed data, we've * also got to the end of the compressed stream. This sanity check is * enforced by most PNG readers. */ if (chunkSz != 0) { | | | > | 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 | /* * Ensure that if we've got to the end of the compressed data, we've * also got to the end of the compressed stream. This sanity check is * enforced by most PNG readers. */ if (chunkSz != 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "compressed data after stream finalize in PNG data", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "EXTRA_DATA", NULL); return TCL_ERROR; } return CheckCRC(interp, pngPtr, crc); } /* |
︙ | ︙ | |||
2267 2268 2269 2270 2271 2272 2273 | case OPT_ALPHA: if (Tcl_GetDoubleFromObj(interp, objv[0], &pngPtr->alpha) == TCL_ERROR) { return TCL_ERROR; } if ((pngPtr->alpha < 0.0) || (pngPtr->alpha > 1.0)) { | | | > | | 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 | case OPT_ALPHA: if (Tcl_GetDoubleFromObj(interp, objv[0], &pngPtr->alpha) == TCL_ERROR) { return TCL_ERROR; } if ((pngPtr->alpha < 0.0) || (pngPtr->alpha > 1.0)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "-alpha value must be between 0.0 and 1.0", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_ALPHA", NULL); return TCL_ERROR; } break; } } return TCL_OK; |
︙ | ︙ | |||
2359 2360 2361 2362 2363 2364 2365 | */ if (ReadChunkHeader(interp, pngPtr, &chunkSz, &chunkType, &crc) == TCL_ERROR) { return TCL_ERROR; } } else if (PNG_COLOR_PLTE == pngPtr->colorType) { | > | < > | 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 | */ if (ReadChunkHeader(interp, pngPtr, &chunkSz, &chunkType, &crc) == TCL_ERROR) { return TCL_ERROR; } } else if (PNG_COLOR_PLTE == pngPtr->colorType) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "PLTE chunk required for indexed color", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "NEED_PLTE", NULL); return TCL_ERROR; } /* * The next chunk may be a tRNS (palette transparency) chunk, depending on * the color type. It must come after the PLTE chunk and before the IDAT * chunk, but can be present if there is no PLTE chunk because it can be |
︙ | ︙ | |||
2395 2396 2397 2398 2399 2400 2401 | } /* * Other ancillary chunk types could appear here, but for now we're only * interested in IDAT. The others should have been skipped. */ | | > | < > | | | > | 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 | } /* * Other ancillary chunk types could appear here, but for now we're only * interested in IDAT. The others should have been skipped. */ if (chunkType != CHUNK_IDAT) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "at least one IDAT chunk is required", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "NEED_IDAT", NULL); return TCL_ERROR; } /* * Expand the photo size (if not set by the user) to provide enough space * for the image being parsed. It does not matter if width or height wrap * to negative here: Tk will not shrink the image. */ if (Tk_PhotoExpand(interp, imageHandle, destX + pngPtr->block.width, destY + pngPtr->block.height) == TCL_ERROR) { return TCL_ERROR; } /* * A scan line consists of one byte for a filter type, plus the number of * bits per color sample times the number of color samples per pixel. */ if (pngPtr->block.width > ((INT_MAX - 1) / (pngPtr->numChannels * 2))) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "line size is out of supported range on this architecture", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "LINE_SIZE", NULL); return TCL_ERROR; } if (16 == pngPtr->bitDepth) { pngPtr->lineSize = 1 + (pngPtr->numChannels * pngPtr->block.width*2); } else { pngPtr->lineSize = 1 + ((pngPtr->numChannels * pngPtr->block.width) / |
︙ | ︙ | |||
2445 2446 2447 2448 2449 2450 2451 | pngPtr->lastLineObj = Tcl_NewObj(); Tcl_IncrRefCount(pngPtr->lastLineObj); pngPtr->thisLineObj = Tcl_NewObj(); Tcl_IncrRefCount(pngPtr->thisLineObj); pngPtr->block.pixelPtr = attemptckalloc(pngPtr->blockLen); if (!pngPtr->block.pixelPtr) { | > | > | 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 | pngPtr->lastLineObj = Tcl_NewObj(); Tcl_IncrRefCount(pngPtr->lastLineObj); pngPtr->thisLineObj = Tcl_NewObj(); Tcl_IncrRefCount(pngPtr->thisLineObj); pngPtr->block.pixelPtr = attemptckalloc(pngPtr->blockLen); if (!pngPtr->block.pixelPtr) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "memory allocation failed", -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); return TCL_ERROR; } /* * Determine size of the first phase if interlaced. Phase size should * always be <= line size, so probably not necessary to check for * arithmetic overflow here: should be covered by line size check. |
︙ | ︙ | |||
2495 2496 2497 2498 2499 2500 2501 | /* * Ensure that we've got to the end of the compressed stream now that * there are no more IDAT segments. This sanity check is enforced by most * PNG readers. */ if (!Tcl_ZlibStreamEof(pngPtr->stream)) { | > | > | 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 | /* * Ensure that we've got to the end of the compressed stream now that * there are no more IDAT segments. This sanity check is enforced by most * PNG readers. */ if (!Tcl_ZlibStreamEof(pngPtr->stream)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "unfinalized data stream in PNG data", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "EXTRA_DATA", NULL); return TCL_ERROR; } /* * Now skip the remaining chunks which we're also not interested in. */ |
︙ | ︙ | |||
2519 2520 2521 2522 2523 2524 2525 | } /* * Got the IEND (end of image) chunk. Do some final checks... */ if (chunkSz) { | > | < > > | > | 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 | } /* * Got the IEND (end of image) chunk. Do some final checks... */ if (chunkSz) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "IEND chunk contents must be empty", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_IEND", NULL); return TCL_ERROR; } /* * Check the CRC on the IEND chunk. */ if (CheckCRC(interp, pngPtr, crc) == TCL_ERROR) { return TCL_ERROR; } /* * TODO: verify that nothing else comes after the IEND chunk, or do we * really care? */ #if 0 if (ReadData(interp, pngPtr, &c, 1, NULL) != TCL_ERROR) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "extra data following IEND chunk", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_IEND", NULL); return TCL_ERROR; } #endif /* * Apply overall image alpha if specified. */ |
︙ | ︙ | |||
2791 2792 2793 2794 2795 2796 2797 | if (pngPtr->objDataPtr) { int objSz; unsigned char *destPtr; Tcl_GetByteArrayFromObj(pngPtr->objDataPtr, &objSz); if (objSz > INT_MAX - srcSz) { | | | | > | > < | | | 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 | if (pngPtr->objDataPtr) { int objSz; unsigned char *destPtr; Tcl_GetByteArrayFromObj(pngPtr->objDataPtr, &objSz); if (objSz > INT_MAX - srcSz) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "image too large to store completely in byte array", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "TOO_LARGE", NULL); return TCL_ERROR; } destPtr = Tcl_SetByteArrayLength(pngPtr->objDataPtr, objSz + srcSz); if (!destPtr) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "memory allocation failed", -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); return TCL_ERROR; } memcpy(destPtr+objSz, srcPtr, srcSz); } else if (Tcl_Write(pngPtr->channel, (const char *) srcPtr, srcSz) < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "write to channel failed: %s", Tcl_PosixError(interp))); return TCL_ERROR; } return TCL_OK; } static inline int |
︙ | ︙ | |||
3123 3124 3125 3126 3127 3128 3129 | */ if (rowNum + 1 == blockPtr->height) { flush = TCL_ZLIB_FINALIZE; } if (Tcl_ZlibStreamPut(pngPtr->stream, pngPtr->thisLineObj, flush) != TCL_OK) { | > | > | 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 | */ if (rowNum + 1 == blockPtr->height) { flush = TCL_ZLIB_FINALIZE; } if (Tcl_ZlibStreamPut(pngPtr->stream, pngPtr->thisLineObj, flush) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "deflate() returned error", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "DEFLATE", NULL); return TCL_ERROR; } /* * Swap line buffers to keep the last around for filtering next. */ |
︙ | ︙ | |||
3297 3298 3299 3300 3301 3302 3303 | */ pngPtr->lineSize = 1 + (pngPtr->bytesPerPixel * blockPtr->width); pngPtr->blockLen = pngPtr->lineSize * blockPtr->height; if ((blockPtr->width > (INT_MAX - 1) / (pngPtr->bytesPerPixel)) || (blockPtr->height > INT_MAX / pngPtr->lineSize)) { | > | < > | 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 | */ pngPtr->lineSize = 1 + (pngPtr->bytesPerPixel * blockPtr->width); pngPtr->blockLen = pngPtr->lineSize * blockPtr->height; if ((blockPtr->width > (INT_MAX - 1) / (pngPtr->bytesPerPixel)) || (blockPtr->height > INT_MAX / pngPtr->lineSize)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "image is too large to encode pixel data", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "TOO_LARGE", NULL); return TCL_ERROR; } pngPtr->lastLineObj = Tcl_NewObj(); Tcl_IncrRefCount(pngPtr->lastLineObj); pngPtr->thisLineObj = Tcl_NewObj(); Tcl_IncrRefCount(pngPtr->thisLineObj); |
︙ | ︙ |
Changes to generic/tkImgPPM.c.
︙ | ︙ | |||
143 144 145 146 147 148 149 | int fileWidth, fileHeight, maxIntensity; int nLines, nBytes, h, type, count; unsigned char *pixelPtr; Tk_PhotoImageBlock block; type = ReadPPMFileHeader(chan, &fileWidth, &fileHeight, &maxIntensity); if (type == 0) { | > | | | | > | | | | < | 143 144 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 | int fileWidth, fileHeight, maxIntensity; int nLines, nBytes, h, type, count; unsigned char *pixelPtr; Tk_PhotoImageBlock block; type = ReadPPMFileHeader(chan, &fileWidth, &fileHeight, &maxIntensity); if (type == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't read raw PPM header from file \"%s\"", fileName)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "NO_HEADER", NULL); return TCL_ERROR; } if ((fileWidth <= 0) || (fileHeight <= 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "PPM image file \"%s\" has dimension(s) <= 0", fileName)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "DIMENSIONS", NULL); return TCL_ERROR; } if ((maxIntensity <= 0) || (maxIntensity >= 256)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "PPM image file \"%s\" has bad maximum intensity value %d", fileName, maxIntensity)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "INTENSITY", NULL); return TCL_ERROR; } if ((srcX + width) > fileWidth) { width = fileWidth - srcX; } if ((srcY + height) > fileHeight) { |
︙ | ︙ | |||
214 215 216 217 218 219 220 | for (h = height; h > 0; h -= nLines) { if (nLines > h) { nLines = h; nBytes = nLines * block.pitch; } count = Tcl_Read(chan, (char *) pixelPtr, nBytes); if (count != nBytes) { | > | < > | | > | 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | for (h = height; h > 0; h -= nLines) { if (nLines > h) { nLines = h; nBytes = nLines * block.pitch; } count = Tcl_Read(chan, (char *) pixelPtr, nBytes); if (count != nBytes) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error reading PPM image file \"%s\": %s", fileName, Tcl_Eof(chan)?"not enough data":Tcl_PosixError(interp))); if (Tcl_Eof(chan)) { Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "EOF", NULL); } ckfree(pixelPtr); return TCL_ERROR; } if (maxIntensity != 255) { unsigned char *p; for (p = pixelPtr; count > 0; count--, p++) { |
︙ | ︙ | |||
321 322 323 324 325 326 327 | if (Tcl_Close(NULL, chan) == 0) { return TCL_OK; } chan = NULL; writeerror: | | | | 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | if (Tcl_Close(NULL, chan) == 0) { return TCL_OK; } chan = NULL; writeerror: Tcl_SetObjResult(interp, Tcl_ObjPrintf("error writing \"%s\": %s", fileName, Tcl_PosixError(interp))); if (chan != NULL) { Tcl_Close(NULL, chan); } return TCL_ERROR; } /* |
︙ | ︙ | |||
478 479 480 481 482 483 484 | int nLines, nBytes, h, type, count, dataSize; unsigned char *pixelPtr, *dataBuffer; Tk_PhotoImageBlock block; type = ReadPPMStringHeader(dataObj, &fileWidth, &fileHeight, &maxIntensity, &dataBuffer, &dataSize); if (type == 0) { | > | | > | | < < < | | > | | 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 | int nLines, nBytes, h, type, count, dataSize; unsigned char *pixelPtr, *dataBuffer; Tk_PhotoImageBlock block; type = ReadPPMStringHeader(dataObj, &fileWidth, &fileHeight, &maxIntensity, &dataBuffer, &dataSize); if (type == 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "couldn't read raw PPM header from string", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "NO_HEADER", NULL); return TCL_ERROR; } if ((fileWidth <= 0) || (fileHeight <= 0)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "PPM image data has dimension(s) <= 0", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "DIMENSIONS", NULL); return TCL_ERROR; } if ((maxIntensity <= 0) || (maxIntensity >= 256)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "PPM image data has bad maximum intensity value %d", maxIntensity)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "INTENSITY", NULL); return TCL_ERROR; } if ((srcX + width) > fileWidth) { width = fileWidth - srcX; } if ((srcY + height) > fileHeight) { |
︙ | ︙ | |||
534 535 536 537 538 539 540 | if (maxIntensity == 255) { /* * We have all the data in memory, so write everything in one go. */ if (block.pitch*height > dataSize) { | > | > | 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | if (maxIntensity == 255) { /* * We have all the data in memory, so write everything in one go. */ if (block.pitch*height > dataSize) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "truncated PPM data", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "TRUNCATED", NULL); return TCL_ERROR; } block.pixelPtr = dataBuffer + srcX * block.pixelSize; block.height = height; return Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY, width, height, TK_PHOTO_COMPOSITE_SET); } |
︙ | ︙ | |||
568 569 570 571 572 573 574 | if (nLines > h) { nLines = h; nBytes = nLines * block.pitch; } if (dataSize < nBytes) { ckfree(pixelPtr); | > | > | 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 | if (nLines > h) { nLines = h; nBytes = nLines * block.pitch; } if (dataSize < nBytes) { ckfree(pixelPtr); Tcl_SetObjResult(interp, Tcl_NewStringObj( "truncated PPM data", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "TRUNCATED", NULL); return TCL_ERROR; } for (p=pixelPtr,count=nBytes ; count>0 ; count--,p++,dataBuffer++) { *p = (((int) *dataBuffer) * 255)/maxIntensity; } dataSize -= nBytes; block.height = nLines; |
︙ | ︙ |
Changes to generic/tkImgPhInstance.c.
︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | colorPtr->flags &= ~DISPOSE_PENDING; } /* * Allocate colors for this color table if necessary. */ | | < | 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 | colorPtr->flags &= ~DISPOSE_PENDING; } /* * Allocate colors for this color table if necessary. */ if ((colorPtr->numColors == 0) && !(colorPtr->flags & BLACK_AND_WHITE)) { AllocateColors(colorPtr); } } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
1100 1101 1102 1103 1104 1105 1106 | { colorPtr->refCount--; if (colorPtr->refCount > 0) { return; } if (force) { | | | | 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 | { colorPtr->refCount--; if (colorPtr->refCount > 0) { return; } if (force) { if (colorPtr->flags & DISPOSE_PENDING) { Tcl_CancelIdleCall(DisposeColorTable, colorPtr); colorPtr->flags &= ~DISPOSE_PENDING; } DisposeColorTable(colorPtr); } else if (!(colorPtr->flags & DISPOSE_PENDING)) { Tcl_DoWhenIdle(DisposeColorTable, colorPtr); colorPtr->flags |= DISPOSE_PENDING; } } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
1809 1810 1811 1812 1813 1814 1815 | c += errPtr[-lineLength] * 5; if (x + 1 < masterPtr->width) { c += errPtr[-lineLength+1] * 3; } } c = ((c + 2056) >> 4) - 128; | | < < > > | 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 | c += errPtr[-lineLength] * 5; if (x + 1 < masterPtr->width) { c += errPtr[-lineLength+1] * 3; } } c = ((c + 2056) >> 4) - 128; if (masterPtr->flags & COLOR_IMAGE) { c += (unsigned) (srcPtr[0] * 11 + srcPtr[1] * 16 + srcPtr[2] * 5 + 16) >> 5; } else { c += srcPtr[0]; } srcPtr += 4; if (c < 0) { c = 0; } else if (c > 255) { c = 255; |
︙ | ︙ | |||
1882 1883 1884 1885 1886 1887 1888 | c += errPtr[-lineLength] * 5; if (x + 1 < masterPtr->width) { c += errPtr[-lineLength+1] * 3; } } c = ((c + 2056) >> 4) - 128; | | < < > > | 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 | c += errPtr[-lineLength] * 5; if (x + 1 < masterPtr->width) { c += errPtr[-lineLength+1] * 3; } } c = ((c + 2056) >> 4) - 128; if (masterPtr->flags & COLOR_IMAGE) { c += (unsigned)(srcPtr[0] * 11 + srcPtr[1] * 16 + srcPtr[2] * 5 + 16) >> 5; } else { c += srcPtr[0]; } srcPtr += 4; if (c < 0) { c = 0; } else if (c > 255) { c = 255; |
︙ | ︙ |
Changes to generic/tkImgPhoto.c.
︙ | ︙ | |||
500 501 502 503 504 505 506 | if (length > 1 && !strncmp(arg, "-data", (unsigned) length)) { Tcl_AppendResult(interp, "-data {} {} {}", NULL); if (masterPtr->dataString) { /* * TODO: Modifying result is bad! */ | | | | 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 | if (length > 1 && !strncmp(arg, "-data", (unsigned) length)) { Tcl_AppendResult(interp, "-data {} {} {}", NULL); if (masterPtr->dataString) { /* * TODO: Modifying result is bad! */ Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp), masterPtr->dataString); } else { Tcl_AppendResult(interp, " {}", NULL); } return TCL_OK; } else if (length > 1 && !strncmp(arg, "-format", (unsigned) length)) { Tcl_AppendResult(interp, "-format {} {} {}", NULL); if (masterPtr->format) { /* * TODO: Modifying result is bad! */ Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp), masterPtr->format); } else { Tcl_AppendResult(interp, " {}", NULL); } return TCL_OK; } else { return Tk_ConfigureInfo(interp, Tk_MainWindow(interp), |
︙ | ︙ | |||
558 559 560 561 562 563 564 | /* * Look for the source image and get a pointer to its image data. * Check the values given for the -from option. */ srcHandle = Tk_FindPhoto(interp, Tcl_GetString(options.name)); if (srcHandle == NULL) { | | > | > | | | > > | 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 | /* * Look for the source image and get a pointer to its image data. * Check the values given for the -from option. */ srcHandle = Tk_FindPhoto(interp, Tcl_GetString(options.name)); if (srcHandle == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "image \"%s\" doesn't exist or is not a photo image", Tcl_GetString(options.name))); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO", Tcl_GetString(options.name), NULL); return TCL_ERROR; } Tk_PhotoGetImage(srcHandle, &block); if ((options.fromX2 > block.width) || (options.fromY2 > block.height) || (options.fromX2 > block.width) || (options.fromY2 > block.height)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "coordinates for -from option extend outside source image", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL); return TCL_ERROR; } /* * Hack to pass through the message that the place we're coming from * has a simple alpha channel. */ |
︙ | ︙ | |||
620 621 622 623 624 625 626 | /* * Set the destination image size if the -shrink option was specified. */ if (options.options & OPT_SHRINK) { if (ImgPhotoSetSize(masterPtr, options.toX2, options.toY2) != TCL_OK) { | | | > | 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | /* * Set the destination image size if the -shrink option was specified. */ if (options.options & OPT_SHRINK) { if (ImgPhotoSetSize(masterPtr, options.toX2, options.toY2) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); return TCL_ERROR; } } /* * Copy the image data over using Tk_PhotoPutZoomedBlock. */ |
︙ | ︙ | |||
668 669 670 671 672 673 674 | Tcl_WrongNumArgs(interp, 2, objv, "?-option value ...?"); return TCL_ERROR; } if ((options.fromX > masterPtr->width) || (options.fromY > masterPtr->height) || (options.fromX2 > masterPtr->width) || (options.fromY2 > masterPtr->height)) { | > | | | | 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 | Tcl_WrongNumArgs(interp, 2, objv, "?-option value ...?"); return TCL_ERROR; } if ((options.fromX > masterPtr->width) || (options.fromY > masterPtr->height) || (options.fromX2 > masterPtr->width) || (options.fromY2 > masterPtr->height)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "coordinates for -from option extend outside image", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL); return TCL_ERROR; } /* * Fill in default values for unspecified parameters. */ if (!(options.options & OPT_FROM) || (options.fromX2 < 0)) { options.fromX2 = masterPtr->width; options.fromY2 = masterPtr->height; } /* * Search for an appropriate image string format handler. */ |
︙ | ︙ | |||
715 716 717 718 719 720 721 | stringWriteProc = imageFormat->stringWriteProc; break; } } } } if (stringWriteProc == NULL) { | > | | | > > | 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 | stringWriteProc = imageFormat->stringWriteProc; break; } } } } if (stringWriteProc == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "image string format \"%s\" is %s", Tcl_GetString(options.format), (matched ? "not supported" : "unknown"))); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT", Tcl_GetString(options.format), NULL); return TCL_ERROR; } } else { stringWriteProc = ImgStringWrite; } /* |
︙ | ︙ | |||
766 767 768 769 770 771 772 | } case PHOTO_GET: { /* * photo get command - first parse and check parameters. */ | | | | > > > | > | | | 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 | } case PHOTO_GET: { /* * photo get command - first parse and check parameters. */ Tcl_Obj *channels[3]; if (objc != 4) { Tcl_WrongNumArgs(interp, 2, objv, "x y"); return TCL_ERROR; } if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK)) { return TCL_ERROR; } if ((x < 0) || (x >= masterPtr->width) || (y < 0) || (y >= masterPtr->height)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s get: coordinates out of range", Tcl_GetString(objv[0]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES", NULL); return TCL_ERROR; } /* * Extract the value of the desired pixel and format it as a string. */ pixelPtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4; channels[0] = Tcl_NewIntObj(pixelPtr[0]); channels[1] = Tcl_NewIntObj(pixelPtr[1]); channels[2] = Tcl_NewIntObj(pixelPtr[2]); Tcl_SetObjResult(interp, Tcl_NewListObj(3, channels)); return TCL_OK; } case PHOTO_PUT: /* * photo put command - first parse the options and colors specified. */ |
︙ | ︙ | |||
816 817 818 819 820 821 822 | } if (MatchStringFormat(interp, options.name ? objv[2]:NULL, options.format, &imageFormat, &imageWidth, &imageHeight, &oldformat) == TCL_OK) { Tcl_Obj *format, *data; | | | 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 | } if (MatchStringFormat(interp, options.name ? objv[2]:NULL, options.format, &imageFormat, &imageWidth, &imageHeight, &oldformat) == TCL_OK) { Tcl_Obj *format, *data; if (!(options.options & OPT_TO) || (options.toX2 < 0)) { options.toX2 = options.toX + imageWidth; options.toY2 = options.toY + imageHeight; } if (imageWidth > options.toX2 - options.toX) { imageWidth = options.toX2 - options.toX; } if (imageHeight > options.toY2 - options.toY) { |
︙ | ︙ | |||
872 873 874 875 876 877 878 | break; } dataWidth = listObjc; pixelPtr = ckalloc(dataWidth * dataHeight * 3); block.pixelPtr = pixelPtr; } else if (listObjc != dataWidth) { | > | | > > | 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 | break; } dataWidth = listObjc; pixelPtr = ckalloc(dataWidth * dataHeight * 3); block.pixelPtr = pixelPtr; } else if (listObjc != dataWidth) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "all elements of color list must have the same" " number of elements", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "NON_RECTANGULAR", NULL); break; } for (x = 0; x < dataWidth; ++x) { const char *colorString = Tcl_GetString(listObjv[x]); XColor color; int tmpr, tmpg, tmpb; |
︙ | ︙ | |||
916 917 918 919 920 921 922 | continue; } } } if (!TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), colorString, &color)) { | | | > | 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 | continue; } } } if (!TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), colorString, &color)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't parse color \"%s\"", colorString)); Tcl_SetErrorCode(interp, "TK", "VALUE", "COLOR", NULL); break; } *pixelPtr++ = color.red >> 8; *pixelPtr++ = color.green >> 8; *pixelPtr++ = color.blue >> 8; } if (x < dataWidth) { |
︙ | ︙ | |||
988 989 990 991 992 993 994 | } /* * Prevent file system access in safe interpreters. */ if (Tcl_IsSafe(interp)) { | | | > | 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 | } /* * Prevent file system access in safe interpreters. */ if (Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't get image from a file in a safe interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", NULL); return TCL_ERROR; } /* * Open the image file and look for a handler for it. */ |
︙ | ︙ | |||
1027 1028 1029 1030 1031 1032 1033 | /* * Check the values given for the -from option. */ if ((options.fromX > imageWidth) || (options.fromY > imageHeight) || (options.fromX2 > imageWidth) || (options.fromY2 > imageHeight)) { | | | > > | > | > | 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 | /* * Check the values given for the -from option. */ if ((options.fromX > imageWidth) || (options.fromY > imageHeight) || (options.fromX2 > imageWidth) || (options.fromY2 > imageHeight)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "coordinates for -from option extend outside source image", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL); Tcl_Close(NULL, chan); return TCL_ERROR; } if (!(options.options & OPT_FROM) || (options.fromX2 < 0)) { width = imageWidth - options.fromX; height = imageHeight - options.fromY; } else { width = options.fromX2 - options.fromX; height = options.fromY2 - options.fromY; } /* * If the -shrink option was specified, set the size of the image. */ if (options.options & OPT_SHRINK) { if (ImgPhotoSetSize(masterPtr, options.toX + width, options.toY + height) != TCL_OK) { Tcl_ResetResult(interp); Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); return TCL_ERROR; } } /* * Call the handler's file read function to read the data into the * image. |
︙ | ︙ | |||
1139 1140 1141 1142 1143 1144 1145 | } if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)) { return TCL_ERROR; } if ((x < 0) || (x >= masterPtr->width) || (y < 0) || (y >= masterPtr->height)) { | | | > > > | 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 | } if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)) { return TCL_ERROR; } if ((x < 0) || (x >= masterPtr->width) || (y < 0) || (y >= masterPtr->height)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s transparency get: coordinates out of range", Tcl_GetString(objv[0]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES", NULL); return TCL_ERROR; } testBox.x = x; testBox.y = y; testBox.width = 1; testBox.height = 1; |
︙ | ︙ | |||
1176 1177 1178 1179 1180 1181 1182 | || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK) || (Tcl_GetBooleanFromObj(interp, objv[5], &transFlag) != TCL_OK)) { return TCL_ERROR; } if ((x < 0) || (x >= masterPtr->width) || (y < 0) || (y >= masterPtr->height)) { | | | > > > | 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 | || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK) || (Tcl_GetBooleanFromObj(interp, objv[5], &transFlag) != TCL_OK)) { return TCL_ERROR; } if ((x < 0) || (x >= masterPtr->width) || (y < 0) || (y >= masterPtr->height)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s transparency set: coordinates out of range", Tcl_GetString(objv[0]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES", NULL); return TCL_ERROR; } setBox.x = x; setBox.y = y; setBox.width = 1; setBox.height = 1; |
︙ | ︙ | |||
1240 1241 1242 1243 1244 1245 1246 | int usedExt; /* * Prevent file system access in safe interpreters. */ if (Tcl_IsSafe(interp)) { | | | > | 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 | int usedExt; /* * Prevent file system access in safe interpreters. */ if (Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't write image to a file in a safe interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", NULL); return TCL_ERROR; } /* * photo write command - first parse and check any options given. */ |
︙ | ︙ | |||
1266 1267 1268 1269 1270 1271 1272 | Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?"); return TCL_ERROR; } if ((options.fromX > masterPtr->width) || (options.fromY > masterPtr->height) || (options.fromX2 > masterPtr->width) || (options.fromY2 > masterPtr->height)) { | > | | | 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 | Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?"); return TCL_ERROR; } if ((options.fromX > masterPtr->width) || (options.fromY > masterPtr->height) || (options.fromX2 > masterPtr->width) || (options.fromY2 > masterPtr->height)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "coordinates for -from option extend outside image", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL); return TCL_ERROR; } /* * Fill in default values for unspecified parameters. Note that a * missing -format flag results in us having a guess from the file * extension. [Bug 2983824] |
︙ | ︙ | |||
1334 1335 1336 1337 1338 1339 1340 | usedExt = 0; fmtString = NULL; goto redoFormatLookup; } if (imageFormat == NULL) { if (fmtString == NULL) { | > | | | < < | | | > > | | < | 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 | usedExt = 0; fmtString = NULL; goto redoFormatLookup; } if (imageFormat == NULL) { if (fmtString == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "no available image file format has file writing" " capability", -1)); } else if (!matched) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "image file format \"%s\" is unknown", fmtString)); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "image file format \"%s\" has no file writing capability", fmtString)); } Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT", fmtString, NULL); return TCL_ERROR; } /* * Call the handler's file write function to write out the image. */ |
︙ | ︙ | |||
1437 1438 1439 1440 1441 1442 1443 1444 1445 | * current command. */ int *optIndexPtr, /* Points to a variable containing the current * index in objv; this variable is updated by * this function. */ int objc, /* Number of arguments in objv[]. */ Tcl_Obj *const objv[]) /* Arguments to be parsed. */ { int index, c, bit, currentBit, length; int values[4], numValues, maxValues, argIndex; | > > > > > | > | > | < | < < < < < | < < < < < < < < < < < | > > | | | | < < < < < | > > | | < < < < < | < < < < | < < < | | | | | | | | < < < < < > | < < | < | 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 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 | * current command. */ int *optIndexPtr, /* Points to a variable containing the current * index in objv; this variable is updated by * this function. */ int objc, /* Number of arguments in objv[]. */ Tcl_Obj *const objv[]) /* Arguments to be parsed. */ { static const char *const compositingRules[] = { "overlay", "set", /* Note that these must match the * TK_PHOTO_COMPOSITE_* constants. */ NULL }; int index, c, bit, currentBit, length; int values[4], numValues, maxValues, argIndex; const char *option, *expandedOption, *needed; const char *const *listPtr; Tcl_Obj *msgObj; for (index = *optIndexPtr; index < objc; *optIndexPtr = ++index) { /* * We can have one value specified without an option; it goes into * optPtr->name. */ expandedOption = option = Tcl_GetStringFromObj(objv[index], &length); if (option[0] != '-') { if (optPtr->name == NULL) { optPtr->name = objv[index]; continue; } break; } /* * Work out which option this is. */ c = option[0]; bit = 0; currentBit = 1; for (listPtr = optionNames; *listPtr != NULL; ++listPtr) { if ((c == *listPtr[0]) && (strncmp(option, *listPtr, (size_t) length) == 0)) { expandedOption = *listPtr; if (bit != 0) { goto unknownOrAmbiguousOption; } bit = currentBit; } currentBit <<= 1; } /* * If this option is not recognized and allowed, put an error message * in the interpreter and return. */ if (!(allowedOptions & bit)) { goto unknownOrAmbiguousOption; } /* * For the -from, -to, -zoom and -subsample options, parse the values * given. Report an error if too few or too many values are given. */ if (bit == OPT_BACKGROUND) { /* * The -background option takes a single XColor value. */ if (index + 1 >= objc) { goto oneValueRequired; } *optIndexPtr = ++index; optPtr->background = Tk_GetColor(interp, Tk_MainWindow(interp), Tk_GetUid(Tcl_GetString(objv[index]))); if (!optPtr->background) { return TCL_ERROR; } } else if (bit == OPT_FORMAT) { /* * The -format option takes a single string value. Note that * parsing this is outside the scope of this function. */ if (index + 1 >= objc) { goto oneValueRequired; } *optIndexPtr = ++index; optPtr->format = objv[index]; } else if (bit == OPT_COMPOSITE) { /* * The -compositingrule option takes a single value from a * well-known set. */ if (index + 1 >= objc) { goto oneValueRequired; } index++; if (Tcl_GetIndexFromObj(interp, objv[index], compositingRules, "compositing rule", 0, &optPtr->compositingRule) != TCL_OK) { return TCL_ERROR; } *optIndexPtr = index; } else if ((bit != OPT_SHRINK) && (bit != OPT_GRAYSCALE)) { const char *val; maxValues = ((bit == OPT_FROM) || (bit == OPT_TO)) ? 4 : 2; argIndex = index + 1; for (numValues = 0; numValues < maxValues; ++numValues) { if (argIndex >= objc) { break; } val = Tcl_GetString(objv[argIndex]); if ((argIndex < objc) && (isdigit(UCHAR(val[0])) || ((val[0] == '-') && isdigit(UCHAR(val[1]))))) { if (Tcl_GetInt(interp, val, &values[numValues]) != TCL_OK) { return TCL_ERROR; } } else { break; } argIndex++; } if (numValues == 0) { goto manyValuesRequired; } *optIndexPtr = (index += numValues); /* * Y values default to the corresponding X value if not specified. */ |
︙ | ︙ | |||
1614 1615 1616 1617 1618 1619 1620 | * the SubcommandOptions structure. */ switch (bit) { case OPT_FROM: if ((values[0] < 0) || (values[1] < 0) || ((numValues > 2) && ((values[2] < 0) || (values[3] < 0)))) { | < | < > < | < > < | < > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 | * the SubcommandOptions structure. */ switch (bit) { case OPT_FROM: if ((values[0] < 0) || (values[1] < 0) || ((numValues > 2) && ((values[2] < 0) || (values[3] < 0)))) { needed = "non-negative"; goto numberOutOfRange; } if (numValues <= 2) { optPtr->fromX = values[0]; optPtr->fromY = values[1]; optPtr->fromX2 = -1; optPtr->fromY2 = -1; } else { optPtr->fromX = MIN(values[0], values[2]); optPtr->fromY = MIN(values[1], values[3]); optPtr->fromX2 = MAX(values[0], values[2]); optPtr->fromY2 = MAX(values[1], values[3]); } break; case OPT_SUBSAMPLE: optPtr->subsampleX = values[0]; optPtr->subsampleY = values[1]; break; case OPT_TO: if ((values[0] < 0) || (values[1] < 0) || ((numValues > 2) && ((values[2] < 0) || (values[3] < 0)))) { needed = "non-negative"; goto numberOutOfRange; } if (numValues <= 2) { optPtr->toX = values[0]; optPtr->toY = values[1]; optPtr->toX2 = -1; optPtr->toY2 = -1; } else { optPtr->toX = MIN(values[0], values[2]); optPtr->toY = MIN(values[1], values[3]); optPtr->toX2 = MAX(values[0], values[2]); optPtr->toY2 = MAX(values[1], values[3]); } break; case OPT_ZOOM: if ((values[0] <= 0) || (values[1] <= 0)) { needed = "positive"; goto numberOutOfRange; } optPtr->zoomX = values[0]; optPtr->zoomY = values[1]; break; } } /* * Remember that we saw this option. */ optPtr->options |= bit; } return TCL_OK; /* * Exception generation. */ oneValueRequired: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "the \"%s\" option requires a value", expandedOption)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", NULL); return TCL_ERROR; manyValuesRequired: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "the \"%s\" option requires one %s integer values", expandedOption, (maxValues == 2) ? "or two": "to four")); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", NULL); return TCL_ERROR; numberOutOfRange: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value(s) for the %s option must be %s", expandedOption, needed)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_VALUE", NULL); return TCL_ERROR; unknownOrAmbiguousOption: msgObj = Tcl_ObjPrintf("unrecognized option \"%s\": must be ", option); bit = 1; for (listPtr = optionNames; *listPtr != NULL; ++listPtr) { if (allowedOptions & bit) { if (allowedOptions & (bit - 1)) { if (allowedOptions & ~((bit << 1) - 1)) { Tcl_AppendToObj(msgObj, ", ", -1); } else { Tcl_AppendToObj(msgObj, ", or ", -1); } } Tcl_AppendToObj(msgObj, *listPtr, -1); } bit <<= 1; } Tcl_SetObjResult(interp, msgObj); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * ImgPhotoConfigureMaster -- * |
︙ | ︙ | |||
1726 1727 1728 1729 1730 1731 1732 | if ((args[j][1] == 'd') && !strncmp(args[j], "-data", (size_t) length)) { if (++i < objc) { data = objv[i]; j--; } else { ckfree(args); | | | > > | | > > | 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 | if ((args[j][1] == 'd') && !strncmp(args[j], "-data", (size_t) length)) { if (++i < objc) { data = objv[i]; j--; } else { ckfree(args); Tcl_SetObjResult(interp, Tcl_NewStringObj( "value for \"-data\" missing", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", NULL); return TCL_ERROR; } } else if ((args[j][1] == 'f') && !strncmp(args[j], "-format", (size_t) length)) { if (++i < objc) { format = objv[i]; j--; } else { ckfree(args); Tcl_SetObjResult(interp, Tcl_NewStringObj( "value for \"-format\" missing", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", NULL); return TCL_ERROR; } } } } /* |
︙ | ︙ | |||
1828 1829 1830 1831 1832 1833 1834 | /* * Set the image to the user-requested size, if any, and make sure storage * is correctly allocated for this image. */ if (ImgPhotoSetSize(masterPtr, masterPtr->width, masterPtr->height) != TCL_OK) { | | | > | | > > | 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 | /* * Set the image to the user-requested size, if any, and make sure storage * is correctly allocated for this image. */ if (ImgPhotoSetSize(masterPtr, masterPtr->width, masterPtr->height) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); goto errorExit; } /* * Read in the image from the file or string if the user has specified the * -file or -data option. */ if ((masterPtr->fileString != NULL) && ((masterPtr->fileString != oldFileString) || (masterPtr->format != oldFormat))) { /* * Prevent file system access in a safe interpreter. */ if (Tcl_IsSafe(interp)) { Tcl_ResetResult(interp); Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't get image from a file in a safe interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", NULL); goto errorExit; } chan = Tcl_OpenFileChannel(interp, masterPtr->fileString, "r", 0); if (chan == NULL) { goto errorExit; } |
︙ | ︙ | |||
1872 1873 1874 1875 1876 1877 1878 | &imageHeight, &oldformat) != TCL_OK)) { Tcl_Close(NULL, chan); goto errorExit; } result = ImgPhotoSetSize(masterPtr, imageWidth, imageHeight); if (result != TCL_OK) { Tcl_Close(NULL, chan); | | | > | 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 | &imageHeight, &oldformat) != TCL_OK)) { Tcl_Close(NULL, chan); goto errorExit; } result = ImgPhotoSetSize(masterPtr, imageWidth, imageHeight); if (result != TCL_OK) { Tcl_Close(NULL, chan); Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); goto errorExit; } tempformat = masterPtr->format; if (oldformat && tempformat) { tempformat = (Tcl_Obj *) Tcl_GetString(tempformat); } result = imageFormat->fileReadProc(interp, chan, |
︙ | ︙ | |||
1902 1903 1904 1905 1906 1907 1908 | if (MatchStringFormat(interp, masterPtr->dataString, masterPtr->format, &imageFormat, &imageWidth, &imageHeight, &oldformat) != TCL_OK) { goto errorExit; } if (ImgPhotoSetSize(masterPtr, imageWidth, imageHeight) != TCL_OK) { | | | > | 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 | if (MatchStringFormat(interp, masterPtr->dataString, masterPtr->format, &imageFormat, &imageWidth, &imageHeight, &oldformat) != TCL_OK) { goto errorExit; } if (ImgPhotoSetSize(masterPtr, imageWidth, imageHeight) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); goto errorExit; } tempformat = masterPtr->format; tempdata = masterPtr->dataString; if (oldformat) { if (tempformat) { tempformat = (Tcl_Obj *) Tcl_GetString(tempformat); |
︙ | ︙ | |||
2347 2348 2349 2350 2351 2352 2353 | if (formatObj != NULL) { if (strncasecmp(formatString, formatPtr->name, strlen(formatPtr->name)) != 0) { continue; } matched = 1; if (formatPtr->fileMatchProc == NULL) { | > | | > > | 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 | if (formatObj != NULL) { if (strncasecmp(formatString, formatPtr->name, strlen(formatPtr->name)) != 0) { continue; } matched = 1; if (formatPtr->fileMatchProc == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "-file option isn't supported for %s images", formatString)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "NOT_FILE_FORMAT", NULL); return TCL_ERROR; } } if (formatPtr->fileMatchProc != NULL) { (void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET); if (formatPtr->fileMatchProc(chan, fileName, formatObj, |
︙ | ︙ | |||
2378 2379 2380 2381 2382 2383 2384 | if (formatString != NULL) { if (strncasecmp(formatString, formatPtr->name, strlen(formatPtr->name)) != 0) { continue; } matched = 1; if (formatPtr->fileMatchProc == NULL) { | > | | > > | 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 | if (formatString != NULL) { if (strncasecmp(formatString, formatPtr->name, strlen(formatPtr->name)) != 0) { continue; } matched = 1; if (formatPtr->fileMatchProc == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "-file option isn't supported for %s images", formatString)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "NOT_FILE_FORMAT", NULL); return TCL_ERROR; } } if (formatPtr->fileMatchProc != NULL) { (void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET); if (formatPtr->fileMatchProc(chan, fileName, (Tcl_Obj *) formatString, widthPtr, heightPtr, interp)) { |
︙ | ︙ | |||
2401 2402 2403 2404 2405 2406 2407 | } } } } if (formatPtr == NULL) { if ((formatObj != NULL) && !matched) { | | | > > > | | > > | | 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 | } } } } if (formatPtr == NULL) { if ((formatObj != NULL) && !matched) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "image file format \"%s\" is not supported", formatString)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT", formatString, NULL); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't recognize data in image file \"%s\"", fileName)); Tcl_SetErrorCode(interp, "TK", "PHOTO", "IMAGE", "UNRECOGNIZED_DATA", NULL); } return TCL_ERROR; } *imageFormatPtr = formatPtr; *oldformat = useoldformat; (void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET); |
︙ | ︙ | |||
2476 2477 2478 2479 2480 2481 2482 | if (formatObj != NULL) { if (strncasecmp(formatString, formatPtr->name, strlen(formatPtr->name)) != 0) { continue; } matched = 1; if (formatPtr->stringMatchProc == NULL) { | > | | > > | 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 | if (formatObj != NULL) { if (strncasecmp(formatString, formatPtr->name, strlen(formatPtr->name)) != 0) { continue; } matched = 1; if (formatPtr->stringMatchProc == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "-data option isn't supported for %s images", formatString)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "NOT_DATA_FORMAT", NULL); return TCL_ERROR; } } if ((formatPtr->stringMatchProc != NULL) && (formatPtr->stringReadProc != NULL) && formatPtr->stringMatchProc(data, formatObj, widthPtr, heightPtr, interp)) { |
︙ | ︙ | |||
2500 2501 2502 2503 2504 2505 2506 | if (formatObj != NULL) { if (strncasecmp(formatString, formatPtr->name, strlen(formatPtr->name)) != 0) { continue; } matched = 1; if (formatPtr->stringMatchProc == NULL) { | > | | > > | | > > > | > > | 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 | if (formatObj != NULL) { if (strncasecmp(formatString, formatPtr->name, strlen(formatPtr->name)) != 0) { continue; } matched = 1; if (formatPtr->stringMatchProc == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "-data option isn't supported for %s images", formatString)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "NOT_DATA_FORMAT", NULL); return TCL_ERROR; } } if ((formatPtr->stringMatchProc != NULL) && (formatPtr->stringReadProc != NULL) && formatPtr->stringMatchProc( (Tcl_Obj *) Tcl_GetString(data), (Tcl_Obj *) formatString, widthPtr, heightPtr, interp)) { break; } } } if (formatPtr == NULL) { if ((formatObj != NULL) && !matched) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "image format \"%s\" is not supported", formatString)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT", formatString, NULL); } else { Tcl_SetObjResult(interp, Tcl_NewStringObj( "couldn't recognize image data", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "UNRECOGNIZED_DATA", NULL); } return TCL_ERROR; } *imageFormatPtr = formatPtr; *oldformat = useoldformat; return TCL_OK; |
︙ | ︙ | |||
2637 2638 2639 2640 2641 2642 2643 | yEnd = y + height; if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) { int sameSrc = (blockPtr->pixelPtr == masterPtr->pix32); if (ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width), MAX(yEnd, masterPtr->height)) == TCL_ERROR) { if (interp != NULL) { | | | > | 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 | yEnd = y + height; if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) { int sameSrc = (blockPtr->pixelPtr == masterPtr->pix32); if (ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width), MAX(yEnd, masterPtr->height)) == TCL_ERROR) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); } return TCL_ERROR; } if (sameSrc) { blockPtr->pixelPtr = masterPtr->pix32; blockPtr->pitch = masterPtr->width * 4; } |
︙ | ︙ | |||
3033 3034 3035 3036 3037 3038 3039 | yEnd = y + height; if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) { int sameSrc = (blockPtr->pixelPtr == masterPtr->pix32); if (ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width), MAX(yEnd, masterPtr->height)) == TCL_ERROR) { if (interp != NULL) { | | | > | 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 | yEnd = y + height; if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) { int sameSrc = (blockPtr->pixelPtr == masterPtr->pix32); if (ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width), MAX(yEnd, masterPtr->height)) == TCL_ERROR) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); } return TCL_ERROR; } if (sameSrc) { blockPtr->pixelPtr = masterPtr->pix32; blockPtr->pitch = masterPtr->width * 4; } |
︙ | ︙ | |||
3431 3432 3433 3434 3435 3436 3437 | if (height <= masterPtr->height) { height = masterPtr->height; } if ((width != masterPtr->width) || (height != masterPtr->height)) { if (ImgPhotoSetSize(masterPtr, MAX(width, masterPtr->width), MAX(height, masterPtr->height)) == TCL_ERROR) { if (interp != NULL) { | | | > | 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 | if (height <= masterPtr->height) { height = masterPtr->height; } if ((width != masterPtr->width) || (height != masterPtr->height)) { if (ImgPhotoSetSize(masterPtr, MAX(width, masterPtr->width), MAX(height, masterPtr->height)) == TCL_ERROR) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); } return TCL_ERROR; } Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, masterPtr->width, masterPtr->height); } return TCL_OK; |
︙ | ︙ | |||
3505 3506 3507 3508 3509 3510 3511 | PhotoMaster *masterPtr = (PhotoMaster *) handle; masterPtr->userWidth = width; masterPtr->userHeight = height; if (ImgPhotoSetSize(masterPtr, ((width > 0) ? width: masterPtr->width), ((height > 0) ? height: masterPtr->height)) == TCL_ERROR) { if (interp != NULL) { | | | > | 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 | PhotoMaster *masterPtr = (PhotoMaster *) handle; masterPtr->userWidth = width; masterPtr->userHeight = height; if (ImgPhotoSetSize(masterPtr, ((width > 0) ? width: masterPtr->width), ((height > 0) ? height: masterPtr->height)) == TCL_ERROR) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); } return TCL_ERROR; } Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, masterPtr->width, masterPtr->height); return TCL_OK; } |
︙ | ︙ |
Changes to generic/tkInt.h.
︙ | ︙ | |||
1166 1167 1168 1169 1170 1171 1172 | ClientData clientData); MODULE_SCOPE Tcl_ExitProc TkFinalize; MODULE_SCOPE Tcl_ExitProc TkFinalizeThread; MODULE_SCOPE void TkpBuildRegionFromAlphaData(TkRegion region, unsigned x, unsigned y, unsigned width, unsigned height, unsigned char *dataPtr, unsigned pixelStride, unsigned lineStride); | | | 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 | ClientData clientData); MODULE_SCOPE Tcl_ExitProc TkFinalize; MODULE_SCOPE Tcl_ExitProc TkFinalizeThread; MODULE_SCOPE void TkpBuildRegionFromAlphaData(TkRegion region, unsigned x, unsigned y, unsigned width, unsigned height, unsigned char *dataPtr, unsigned pixelStride, unsigned lineStride); MODULE_SCOPE void TkAppendPadAmount(Tcl_Obj *bufferObj, const char *buffer, int pad1, int pad2); MODULE_SCOPE int TkParsePadAmount(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, int *pad1Ptr, int *pad2Ptr); MODULE_SCOPE void TkFocusSplit(TkWindow *winPtr); MODULE_SCOPE void TkFocusJoin(TkWindow *winPtr); MODULE_SCOPE int TkpAlwaysShowSelection(Tk_Window tkwin); |
︙ | ︙ |
Changes to generic/tkListbox.c.
︙ | ︙ | |||
163 164 165 166 167 168 169 170 171 172 173 174 175 176 | * to issue. Malloc'ed. */ int state; /* Listbox state. */ Pixmap gray; /* Pixmap for displaying disabled text. */ int flags; /* Various flag bits: see below for * definitions. */ } Listbox; /* * ItemAttr structures are used to store item configuration information for * the items in a listbox */ typedef struct { Tk_3DBorder border; /* Used for drawing background around text */ | > > > > > > > | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | * to issue. Malloc'ed. */ int state; /* Listbox state. */ Pixmap gray; /* Pixmap for displaying disabled text. */ int flags; /* Various flag bits: see below for * definitions. */ } Listbox; /* * How to encode the keys for the hash tables used to store what items are * selected and what the attributes are. */ #define KEY(i) ((char *) INT2PTR(i)) /* * ItemAttr structures are used to store item configuration information for * the items in a listbox */ typedef struct { Tk_3DBorder border; /* Used for drawing background around text */ |
︙ | ︙ | |||
433 434 435 436 437 438 439 | * The structure below defines button class behavior by means of procedures * that can be invoked from generic window code. */ static const Tk_ClassProcs listboxClass = { sizeof(Tk_ClassProcs), /* size */ ListboxWorldChanged, /* worldChangedProc */ | | | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | * The structure below defines button class behavior by means of procedures * that can be invoked from generic window code. */ static const Tk_ClassProcs listboxClass = { sizeof(Tk_ClassProcs), /* size */ ListboxWorldChanged, /* worldChangedProc */ NULL, /* createProc */ NULL /* modalProc */ }; /* *-------------------------------------------------------------- * * Tk_ListboxObjCmd -- * |
︙ | ︙ | |||
476 477 478 479 480 481 482 | tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), Tcl_GetString(objv[1]), NULL); if (tkwin == NULL) { return TCL_ERROR; } | < | | 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), Tcl_GetString(objv[1]), NULL); if (tkwin == NULL) { return TCL_ERROR; } optionTables = Tcl_GetAssocData(interp, "ListboxOptionTables", NULL); if (optionTables == NULL) { /* * We haven't created the option tables for this widget class yet. Do * it now and save the a pointer to them as the ClientData for the * command, so future invocations will have access to it. */ |
︙ | ︙ | |||
511 512 513 514 515 516 517 | /* * Initialize the fields of the structure that won't be initialized by * ConfigureListbox, or that ConfigureListbox requires to be initialized * already (e.g. resource pointers). */ listPtr = ckalloc(sizeof(Listbox)); | | | 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 | /* * Initialize the fields of the structure that won't be initialized by * ConfigureListbox, or that ConfigureListbox requires to be initialized * already (e.g. resource pointers). */ listPtr = ckalloc(sizeof(Listbox)); memset(listPtr, 0, sizeof(Listbox)); listPtr->tkwin = tkwin; listPtr->display = Tk_Display(tkwin); listPtr->interp = interp; listPtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(listPtr->tkwin), ListboxWidgetObjCmd, listPtr, ListboxCmdDeletedProc); |
︙ | ︙ | |||
593 594 595 596 597 598 599 600 601 602 603 604 605 606 | Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Arguments as Tcl_Obj's. */ { register Listbox *listPtr = clientData; int cmdIndex, index; int result = TCL_OK; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } /* | > | 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 | Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Arguments as Tcl_Obj's. */ { register Listbox *listPtr = clientData; int cmdIndex, index; int result = TCL_OK; Tcl_Obj *objPtr; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } /* |
︙ | ︙ | |||
657 658 659 660 661 662 663 | if (result != TCL_OK) { break; } result = ListboxBboxSubCmd(interp, listPtr, index); break; | | < < | < | < < | < < > | < | > | 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 | if (result != TCL_OK) { break; } result = ListboxBboxSubCmd(interp, listPtr, index); break; case COMMAND_CGET: if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "option"); result = TCL_ERROR; break; } objPtr = Tk_GetOptionValue(interp, (char *) listPtr, listPtr->optionTable, objv[2], listPtr->tkwin); if (objPtr == NULL) { result = TCL_ERROR; break; } Tcl_SetObjResult(interp, objPtr); result = TCL_OK; break; case COMMAND_CONFIGURE: if (objc <= 3) { objPtr = Tk_GetOptionInfo(interp, (char *) listPtr, listPtr->optionTable, (objc == 3) ? objv[2] : NULL, listPtr->tkwin); if (objPtr == NULL) { result = TCL_ERROR; break; } Tcl_SetObjResult(interp, objPtr); result = TCL_OK; } else { result = ConfigureListbox(interp, listPtr, objc-2, objv+2, 0); } break; case COMMAND_CURSELECTION: { int i; if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, NULL); result = TCL_ERROR; break; } /* * Of course, it would be more efficient to use the Tcl_HashTable * search functions (Tcl_FirstHashEntry, Tcl_NextHashEntry), but then * the result wouldn't be in sorted order. So instead we loop through * the indices in order, adding them to the result if they are * selected. */ objPtr = Tcl_NewObj(); for (i = 0; i < listPtr->nElements; i++) { if (Tcl_FindHashEntry(listPtr->selection, KEY(i))) { Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewIntObj(i)); } } Tcl_SetObjResult(interp, objPtr); result = TCL_OK; break; } case COMMAND_DELETE: { int first, last; |
︙ | ︙ | |||
853 854 855 856 857 858 859 | break; } result = ListboxInsertSubCmd(listPtr, index, objc-3, objv+3); break; case COMMAND_ITEMCGET: { | < > | | > < | | > > < > | | < | 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 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 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 930 931 932 933 934 935 936 937 | break; } result = ListboxInsertSubCmd(listPtr, index, objc-3, objv+3); break; case COMMAND_ITEMCGET: { ItemAttr *attrPtr; if (objc != 4) { Tcl_WrongNumArgs(interp, 2, objv, "index option"); result = TCL_ERROR; break; } result = GetListboxIndex(interp, listPtr, objv[2], 0, &index); if (result != TCL_OK) { break; } if (index < 0 || index >= listPtr->nElements) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "item number \"%s\" out of range", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TK", "LISTBOX", "ITEM_INDEX", NULL); result = TCL_ERROR; break; } attrPtr = ListboxGetItemAttributes(interp, listPtr, index); objPtr = Tk_GetOptionValue(interp, (char *) attrPtr, listPtr->itemAttrOptionTable, objv[3], listPtr->tkwin); if (objPtr == NULL) { result = TCL_ERROR; break; } Tcl_SetObjResult(interp, objPtr); result = TCL_OK; break; } case COMMAND_ITEMCONFIGURE: { ItemAttr *attrPtr; if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, "index ?-option? ?value? ?-option value ...?"); result = TCL_ERROR; break; } result = GetListboxIndex(interp, listPtr, objv[2], 0, &index); if (result != TCL_OK) { break; } if (index < 0 || index >= listPtr->nElements) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "item number \"%s\" out of range", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TK", "LISTBOX", "ITEM_INDEX", NULL); result = TCL_ERROR; break; } attrPtr = ListboxGetItemAttributes(interp, listPtr, index); if (objc <= 4) { objPtr = Tk_GetOptionInfo(interp, (char *) attrPtr, listPtr->itemAttrOptionTable, (objc == 4) ? objv[3] : NULL, listPtr->tkwin); if (objPtr == NULL) { result = TCL_ERROR; break; } Tcl_SetObjResult(interp, objPtr); result = TCL_OK; } else { result = ConfigureListboxItem(interp, listPtr, attrPtr, objc-3, objv+3, index); } break; } |
︙ | ︙ | |||
1003 1004 1005 1006 1007 1008 1009 | index = listPtr->nElements - 1; } if (index < 0) { index = 0; } diff = listPtr->topIndex - index; if (diff > 0) { | | | | 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 | index = listPtr->nElements - 1; } if (index < 0) { index = 0; } diff = listPtr->topIndex - index; if (diff > 0) { if (diff <= listPtr->fullLines / 3) { ChangeListboxView(listPtr, index); } else { ChangeListboxView(listPtr, index - (listPtr->fullLines-1)/2); } } else { diff = index - (listPtr->topIndex + listPtr->fullLines - 1); if (diff > 0) { if (diff <= listPtr->fullLines / 3) { ChangeListboxView(listPtr, listPtr->topIndex + diff); } else { ChangeListboxView(listPtr, index-(listPtr->fullLines-1)/2); } } } result = TCL_OK; |
︙ | ︙ | |||
1086 1087 1088 1089 1090 1091 1092 | } /* * Only allow bbox requests for indices that are visible. */ if ((listPtr->topIndex <= index) && (index < lastVisibleIndex)) { | | > > > > | < | 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 | } /* * Only allow bbox requests for indices that are visible. */ if ((listPtr->topIndex <= index) && (index < lastVisibleIndex)) { Tcl_Obj *el, *results[4]; const char *stringRep; int pixelWidth, stringLen, x, y, result; Tk_FontMetrics fm; /* * Compute the pixel width of the requested element. */ result = Tcl_ListObjIndex(interp, listPtr->listObj, index, &el); if (result != TCL_OK) { return result; } stringRep = Tcl_GetStringFromObj(el, &stringLen); Tk_GetFontMetrics(listPtr->tkfont, &fm); pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen); x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset; y = ((index - listPtr->topIndex)*listPtr->lineHeight) + listPtr->inset + listPtr->selBorderWidth; results[0] = Tcl_NewIntObj(x); results[1] = Tcl_NewIntObj(y); results[2] = Tcl_NewIntObj(pixelWidth); results[3] = Tcl_NewIntObj(fm.linespace); Tcl_SetObjResult(interp, Tcl_NewListObj(4, results)); } return TCL_OK; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
1193 1194 1195 1196 1197 1198 1199 | result = ListboxSelect(listPtr, first, last, 0); break; case SELECTION_INCLUDES: if (objc != 4) { Tcl_WrongNumArgs(interp, 3, objv, "index"); return TCL_ERROR; } | | | < | 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 | result = ListboxSelect(listPtr, first, last, 0); break; case SELECTION_INCLUDES: if (objc != 4) { Tcl_WrongNumArgs(interp, 3, objv, "index"); return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewBooleanObj( Tcl_FindHashEntry(listPtr->selection, KEY(first)) != NULL)); result = TCL_OK; break; case SELECTION_SET: result = ListboxSelect(listPtr, first, last, 1); break; } return result; |
︙ | ︙ | |||
1228 1229 1230 1231 1232 1233 1234 | static int ListboxXviewSubCmd( Tcl_Interp *interp, /* Pointer to the calling Tcl interpreter */ Listbox *listPtr, /* Information about the listbox */ int objc, /* Number of arguments in the objv array */ Tcl_Obj *const objv[]) /* Array of arguments to the procedure */ { | < | > > | > | | | | > | < | | 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 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 | static int ListboxXviewSubCmd( Tcl_Interp *interp, /* Pointer to the calling Tcl interpreter */ Listbox *listPtr, /* Information about the listbox */ int objc, /* Number of arguments in the objv array */ Tcl_Obj *const objv[]) /* Array of arguments to the procedure */ { int index, count, windowWidth, windowUnits; int offset = 0; /* Initialized to stop gcc warnings. */ double fraction; windowWidth = Tk_Width(listPtr->tkwin) - 2*(listPtr->inset + listPtr->selBorderWidth); if (objc == 2) { Tcl_Obj *results[2]; if (listPtr->maxWidth == 0) { results[0] = Tcl_NewDoubleObj(0.0); results[1] = Tcl_NewDoubleObj(1.0); } else { double fraction2; fraction = listPtr->xOffset / (double) listPtr->maxWidth; fraction2 = (listPtr->xOffset + windowWidth) / (double) listPtr->maxWidth; if (fraction2 > 1.0) { fraction2 = 1.0; } results[0] = Tcl_NewDoubleObj(fraction); results[1] = Tcl_NewDoubleObj(fraction2); } Tcl_SetObjResult(interp, Tcl_NewListObj(2, results)); } else if (objc == 3) { if (Tcl_GetIntFromObj(interp, objv[2], &index) != TCL_OK) { return TCL_ERROR; } ChangeListboxOffset(listPtr, index*listPtr->xScrollUnit); } else { switch (Tk_GetScrollInfoObj(interp, objc, objv, &fraction, &count)) { case TK_SCROLL_ERROR: return TCL_ERROR; case TK_SCROLL_MOVETO: offset = (int) (fraction*listPtr->maxWidth + 0.5); break; case TK_SCROLL_PAGES: windowUnits = windowWidth / listPtr->xScrollUnit; if (windowUnits > 2) { offset = listPtr->xOffset + count*listPtr->xScrollUnit*(windowUnits-2); } else { offset = listPtr->xOffset + count*listPtr->xScrollUnit; } break; |
︙ | ︙ | |||
1304 1305 1306 1307 1308 1309 1310 | static int ListboxYviewSubCmd( Tcl_Interp *interp, /* Pointer to the calling Tcl interpreter */ Listbox *listPtr, /* Information about the listbox */ int objc, /* Number of arguments in the objv array */ Tcl_Obj *const objv[]) /* Array of arguments to the procedure */ { | | > > | > | | > | < | 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 | static int ListboxYviewSubCmd( Tcl_Interp *interp, /* Pointer to the calling Tcl interpreter */ Listbox *listPtr, /* Information about the listbox */ int objc, /* Number of arguments in the objv array */ Tcl_Obj *const objv[]) /* Array of arguments to the procedure */ { int index, count; double fraction; if (objc == 2) { Tcl_Obj *results[2]; if (listPtr->nElements == 0) { results[0] = Tcl_NewDoubleObj(0.0); results[1] = Tcl_NewDoubleObj(1.0); } else { double fraction2, numEls = (double) listPtr->nElements; fraction = listPtr->topIndex / numEls; fraction2 = (listPtr->topIndex+listPtr->fullLines) / numEls; if (fraction2 > 1.0) { fraction2 = 1.0; } results[0] = Tcl_NewDoubleObj(fraction); results[1] = Tcl_NewDoubleObj(fraction2); } Tcl_SetObjResult(interp, Tcl_NewListObj(2, results)); } else if (objc == 3) { if (GetListboxIndex(interp, listPtr, objv[2], 0, &index) != TCL_OK) { return TCL_ERROR; } ChangeListboxView(listPtr, index); } else { switch (Tk_GetScrollInfoObj(interp, objc, objv, &fraction, &count)) { case TK_SCROLL_MOVETO: index = (int) (listPtr->nElements*fraction + 0.5); break; case TK_SCROLL_PAGES: if (listPtr->fullLines > 2) { index = listPtr->topIndex + count*(listPtr->fullLines-2); } else { |
︙ | ︙ | |||
1379 1380 1381 1382 1383 1384 1385 | int index) /* Index of the item to retrieve attributes * for. */ { int isNew; Tcl_HashEntry *entry; ItemAttr *attrs; | | < | 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 | int index) /* Index of the item to retrieve attributes * for. */ { int isNew; Tcl_HashEntry *entry; ItemAttr *attrs; entry = Tcl_CreateHashEntry(listPtr->itemAttrTable, KEY(index), &isNew); if (isNew) { attrs = ckalloc(sizeof(ItemAttr)); attrs->border = NULL; attrs->selBorder = NULL; attrs->fgColor = NULL; attrs->selFgColor = NULL; Tk_InitOptions(interp, (char *)attrs, listPtr->itemAttrOptionTable, |
︙ | ︙ | |||
1906 1907 1908 1909 1910 1911 1912 | freeGC = 0; /* * Lookup this item in the item attributes table, to see if it has * special foreground/background colors. */ | | | | 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 | freeGC = 0; /* * Lookup this item in the item attributes table, to see if it has * special foreground/background colors. */ entry = Tcl_FindHashEntry(listPtr->itemAttrTable, KEY(i)); /* * If the listbox is enabled, items may be drawn differently; they may * be drawn selected, or they may have special foreground or * background colors. */ if (listPtr->state & STATE_NORMAL) { if (Tcl_FindHashEntry(listPtr->selection, KEY(i))) { /* * Selected items are drawn differently. */ gc = listPtr->selTextGC; width = Tk_Width(tkwin) - 2*listPtr->inset; selectedBg = listPtr->selBorder; |
︙ | ︙ | |||
1997 1998 1999 2000 2001 2002 2003 | Tk_3DHorizontalBevel(tkwin, pixmap, selectedBg, x-left, y, width+left+right, listPtr->selBorderWidth, 1, 1, 1, TK_RELIEF_RAISED); } /* Draw bottom bevel */ if (i + 1 == listPtr->nElements || | | < | 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 | Tk_3DHorizontalBevel(tkwin, pixmap, selectedBg, x-left, y, width+left+right, listPtr->selBorderWidth, 1, 1, 1, TK_RELIEF_RAISED); } /* Draw bottom bevel */ if (i + 1 == listPtr->nElements || !Tcl_FindHashEntry(listPtr->selection, KEY(i + 1))) { Tk_3DHorizontalBevel(tkwin, pixmap, selectedBg, x-left, y + listPtr->lineHeight - listPtr->selBorderWidth, width+left+right, listPtr->selBorderWidth, 0, 0, 0, TK_RELIEF_RAISED); } prevSelected = 1; } else { |
︙ | ︙ | |||
2234 2235 2236 2237 2238 2239 2240 | } Tk_GetFontMetrics(listPtr->tkfont, &fm); listPtr->lineHeight = fm.linespace + 1 + 2*listPtr->selBorderWidth; width = listPtr->width; if (width <= 0) { width = (listPtr->maxWidth + listPtr->xScrollUnit - 1) | | | 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 | } Tk_GetFontMetrics(listPtr->tkfont, &fm); listPtr->lineHeight = fm.linespace + 1 + 2*listPtr->selBorderWidth; width = listPtr->width; if (width <= 0) { width = (listPtr->maxWidth + listPtr->xScrollUnit - 1) / listPtr->xScrollUnit; if (width < 1) { width = 1; } } pixelWidth = width*listPtr->xScrollUnit + 2*listPtr->inset + 2*listPtr->selBorderWidth; height = listPtr->height; |
︙ | ︙ | |||
2435 2436 2437 2438 2439 2440 2441 | widthChanged = 0; for (i = first; i <= last; i++) { /* * Remove selection information. */ | | | | 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 | widthChanged = 0; for (i = first; i <= last; i++) { /* * Remove selection information. */ entry = Tcl_FindHashEntry(listPtr->selection, KEY(i)); if (entry != NULL) { listPtr->numSelected--; Tcl_DeleteHashEntry(entry); } entry = Tcl_FindHashEntry(listPtr->itemAttrTable, KEY(i)); if (entry != NULL) { ckfree(Tcl_GetHashValue(entry)); Tcl_DeleteHashEntry(entry); } /* * Check width of the element. We only have to check if widthChanged |
︙ | ︙ | |||
2735 2736 2737 2738 2739 2740 2741 | int y; const char *start; char *end; start = stringRep + 1; y = strtol(start, &end, 0); if ((start == end) || (*end != ',')) { | | < < < | < < < > | | | | | 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 | int y; const char *start; char *end; start = stringRep + 1; y = strtol(start, &end, 0); if ((start == end) || (*end != ',')) { goto badIndex; } start = end+1; y = strtol(start, &end, 0); if ((start == end) || (*end != '\0')) { goto badIndex; } *indexPtr = NearestListboxElement(listPtr, y); return TCL_OK; } /* * Maybe the index is just an integer. */ if (Tcl_GetIntFromObj(interp, indexObj, indexPtr) == TCL_OK) { return TCL_OK; } /* * Everything failed, nothing matched. Throw up an error message. */ badIndex: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad listbox index \"%s\": must be active, anchor, end, @x,y," " or a number", Tcl_GetString(indexObj))); Tcl_SetErrorCode(interp, "TK", "VALUE", "LISTBOX_INDEX", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * ChangeListboxView -- |
︙ | ︙ | |||
2899 2900 2901 2902 2903 2904 2905 | * mark point so that the current position continues to correspond to the * edge of the window. This means that the picture will start dragging as * soon as the mouse reverses direction (without this reset, might have to * slide mouse a long ways back before the picture starts moving again). */ newTopIndex = listPtr->scanMarkYIndex | | | 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 | * mark point so that the current position continues to correspond to the * edge of the window. This means that the picture will start dragging as * soon as the mouse reverses direction (without this reset, might have to * slide mouse a long ways back before the picture starts moving again). */ newTopIndex = listPtr->scanMarkYIndex - (10*(y - listPtr->scanMarkY)) / listPtr->lineHeight; if (newTopIndex > maxIndex) { newTopIndex = listPtr->scanMarkYIndex = maxIndex; listPtr->scanMarkY = y; } else if (newTopIndex < 0) { newTopIndex = listPtr->scanMarkYIndex = 0; listPtr->scanMarkY = y; } |
︙ | ︙ | |||
2951 2952 2953 2954 2955 2956 2957 | static int NearestListboxElement( register Listbox *listPtr, /* Information about widget. */ int y) /* Y-coordinate in listPtr's window. */ { int index; | | | 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 | static int NearestListboxElement( register Listbox *listPtr, /* Information about widget. */ int y) /* Y-coordinate in listPtr's window. */ { int index; index = (y - listPtr->inset) / listPtr->lineHeight; if (index >= (listPtr->fullLines + listPtr->partialLine)) { index = listPtr->fullLines + listPtr->partialLine - 1; } if (index < 0) { index = 0; } index += listPtr->topIndex; |
︙ | ︙ | |||
3022 3023 3024 3025 3026 3027 3028 | /* * For each index in the range, find it in our selection hash table. If * it's not there but should be, add it. If it's there but shouldn't be, * remove it. */ for (i = first; i <= last; i++) { | | | | | | 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 | /* * For each index in the range, find it in our selection hash table. If * it's not there but should be, add it. If it's there but shouldn't be, * remove it. */ for (i = first; i <= last; i++) { entry = Tcl_FindHashEntry(listPtr->selection, KEY(i)); if (entry != NULL) { if (!select) { Tcl_DeleteHashEntry(entry); listPtr->numSelected--; if (firstRedisplay < 0) { firstRedisplay = i; } } } else { if (select) { entry = Tcl_CreateHashEntry(listPtr->selection, KEY(i), &isNew); Tcl_SetHashValue(entry, NULL); listPtr->numSelected++; if (firstRedisplay < 0) { firstRedisplay = i; } } } } if (firstRedisplay >= 0) { EventuallyRedrawRange(listPtr, first, last); } if ((oldCount == 0) && (listPtr->numSelected > 0) && listPtr->exportSelection) { Tk_OwnSelection(listPtr->tkwin, XA_PRIMARY, ListboxLostSelection, listPtr); } return TCL_OK; } /* |
︙ | ︙ | |||
3105 3106 3107 3108 3109 3110 3111 | /* * Use a dynamic string to accumulate the contents of the selection. */ needNewline = 0; Tcl_DStringInit(&selection); for (i = 0; i < listPtr->nElements; i++) { | | | 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 | /* * Use a dynamic string to accumulate the contents of the selection. */ needNewline = 0; Tcl_DStringInit(&selection); for (i = 0; i < listPtr->nElements; i++) { entry = Tcl_FindHashEntry(listPtr->selection, KEY(i)); if (entry != NULL) { if (needNewline) { Tcl_DStringAppend(&selection, "\n", 1); } Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); stringRep = Tcl_GetStringFromObj(curElement, &stringLen); |
︙ | ︙ | |||
3246 3247 3248 3249 3250 3251 3252 | if (listPtr->yScrollCmd == NULL) { return; } if (listPtr->nElements == 0) { first = 0.0; last = 1.0; } else { | | | | 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 | if (listPtr->yScrollCmd == NULL) { return; } if (listPtr->nElements == 0) { first = 0.0; last = 1.0; } else { first = listPtr->topIndex / (double) listPtr->nElements; last = (listPtr->topIndex + listPtr->fullLines) / (double) listPtr->nElements; if (last > 1.0) { last = 1.0; } } Tcl_PrintDouble(NULL, first, firstStr); Tcl_PrintDouble(NULL, last, lastStr); |
︙ | ︙ | |||
3305 3306 3307 3308 3309 3310 3311 | int result, windowWidth; double first, last; Tcl_Interp *interp; if (listPtr->xScrollCmd == NULL) { return; } | > | | | | < | 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 | int result, windowWidth; double first, last; Tcl_Interp *interp; if (listPtr->xScrollCmd == NULL) { return; } windowWidth = Tk_Width(listPtr->tkwin) - 2*(listPtr->inset + listPtr->selBorderWidth); if (listPtr->maxWidth == 0) { first = 0; last = 1.0; } else { first = listPtr->xOffset / (double) listPtr->maxWidth; last = (listPtr->xOffset + windowWidth) / (double) listPtr->maxWidth; if (last > 1.0) { last = 1.0; } } Tcl_PrintDouble(NULL, first, firstStr); Tcl_PrintDouble(NULL, last, lastStr); |
︙ | ︙ | |||
3425 3426 3427 3428 3429 3430 3431 | Tcl_ListObjLength(listPtr->interp, listPtr->listObj, &listPtr->nElements); if (listPtr->nElements < oldLength) { for (i = listPtr->nElements; i < oldLength; i++) { /* * Clean up selection. */ | | | < | 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 | Tcl_ListObjLength(listPtr->interp, listPtr->listObj, &listPtr->nElements); if (listPtr->nElements < oldLength) { for (i = listPtr->nElements; i < oldLength; i++) { /* * Clean up selection. */ entry = Tcl_FindHashEntry(listPtr->selection, KEY(i)); if (entry != NULL) { listPtr->numSelected--; Tcl_DeleteHashEntry(entry); } /* * Clean up attributes. */ entry = Tcl_FindHashEntry(listPtr->itemAttrTable, KEY(i)); if (entry != NULL) { ckfree(Tcl_GetHashValue(entry)); Tcl_DeleteHashEntry(entry); } } } |
︙ | ︙ | |||
3510 3511 3512 3513 3514 3515 3516 | * It's more efficient to do one if/else and nest the for loops inside, * although we could avoid some code duplication if we nested the if/else * inside the for loops. */ if (offset > 0) { for (i = last; i >= first; i--) { | | | < | | < | 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 | * It's more efficient to do one if/else and nest the for loops inside, * although we could avoid some code duplication if we nested the if/else * inside the for loops. */ if (offset > 0) { for (i = last; i >= first; i--) { entry = Tcl_FindHashEntry(table, KEY(i)); if (entry != NULL) { clientData = Tcl_GetHashValue(entry); Tcl_DeleteHashEntry(entry); entry = Tcl_CreateHashEntry(table, KEY(i + offset), &isNew); Tcl_SetHashValue(entry, clientData); } } } else { for (i = first; i <= last; i++) { entry = Tcl_FindHashEntry(table, KEY(i)); if (entry != NULL) { clientData = Tcl_GetHashValue(entry); Tcl_DeleteHashEntry(entry); entry = Tcl_CreateHashEntry(table, KEY(i + offset), &isNew); Tcl_SetHashValue(entry, clientData); } } } return; } |
︙ | ︙ |
Changes to generic/tkMenu.c.
︙ | ︙ | |||
370 371 372 373 374 375 376 | * manager events. One of these includes a font change, which forces the * geometry proc to be called. */ static const Tk_ClassProcs menuClass = { sizeof(Tk_ClassProcs), /* size */ MenuWorldChanged, /* worldChangedProc */ | | | | 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | * manager events. One of these includes a font change, which forces the * geometry proc to be called. */ static const Tk_ClassProcs menuClass = { sizeof(Tk_ClassProcs), /* size */ MenuWorldChanged, /* worldChangedProc */ NULL, /* createProc */ NULL /* modalProc */ }; /* *-------------------------------------------------------------- * * TkCreateMenuCmd -- * |
︙ | ︙ | |||
885 886 887 888 889 890 891 | Tcl_WrongNumArgs(interp, 2, objv, "string"); goto error; } if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { goto error; } if (index < 0) { | | | 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 | Tcl_WrongNumArgs(interp, 2, objv, "string"); goto error; } if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { goto error; } if (index < 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj("none", -1)); } else { Tcl_SetObjResult(interp, Tcl_NewIntObj(index)); } break; } case MENU_INSERT: if (objc < 4) { |
︙ | ︙ | |||
962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | } else { result = TkPostSubmenu(interp, menuPtr, menuPtr->entries[index]); } break; } case MENU_TYPE: { int index; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "index"); goto error; } if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { goto error; } if (index < 0) { goto done; } if (menuPtr->entries[index]->type == TEAROFF_ENTRY) { | > | < | > | 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 991 992 993 | } else { result = TkPostSubmenu(interp, menuPtr, menuPtr->entries[index]); } break; } case MENU_TYPE: { int index; const char *typeStr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "index"); goto error; } if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { goto error; } if (index < 0) { goto done; } if (menuPtr->entries[index]->type == TEAROFF_ENTRY) { typeStr = "tearoff"; } else { typeStr = menuEntryTypeStrings[menuPtr->entries[index]->type]; } Tcl_SetObjResult(interp, Tcl_NewStringObj(typeStr, -1)); break; } case MENU_UNPOST: if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, NULL); goto error; } |
︙ | ︙ | |||
2202 2203 2204 2205 2206 2207 2208 | if ((label != NULL) && (Tcl_StringMatch(label, string))) { *indexPtr = i; goto success; } } | > | > | 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 | if ((label != NULL) && (Tcl_StringMatch(label, string))) { *indexPtr = i; goto success; } } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad menu entry index \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "MENU", "INDEX", NULL); return TCL_ERROR; success: return TCL_OK; } /* |
︙ | ︙ | |||
2386 2387 2388 2389 2390 2391 2392 | if (TkGetMenuIndex(interp, menuPtr, indexPtr, 1, &index) != TCL_OK) { return TCL_ERROR; } } else { index = menuPtr->numEntries; } if (index < 0) { | > | | < | 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 | if (TkGetMenuIndex(interp, menuPtr, indexPtr, 1, &index) != TCL_OK) { return TCL_ERROR; } } else { index = menuPtr->numEntries; } if (index < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad index \"%s\"", Tcl_GetString(indexPtr))); Tcl_SetErrorCode(interp, "TK", "MENU", "INDEX", NULL); return TCL_ERROR; } if (menuPtr->tearoff && (index == 0)) { index = 1; } /* |
︙ | ︙ | |||
3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 | CloneMenu(menuPtr, cloneMenuPtr, menubarPtr); cloneMenuRefPtr = TkFindMenuReferencesObj(interp, cloneMenuPtr); if ((cloneMenuRefPtr != NULL) && (cloneMenuRefPtr->menuPtr != NULL)) { Tcl_Obj *cursorPtr = Tcl_NewStringObj("-cursor", -1); Tcl_Obj *nullPtr = Tcl_NewObj(); cloneMenuRefPtr->menuPtr->parentTopLevelPtr = tkwin; menuBarPtr = cloneMenuRefPtr->menuPtr; newObjv[0] = cursorPtr; newObjv[1] = nullPtr; Tcl_IncrRefCount(cursorPtr); Tcl_IncrRefCount(nullPtr); ConfigureMenu(menuPtr->interp, cloneMenuRefPtr->menuPtr, | > | 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 | CloneMenu(menuPtr, cloneMenuPtr, menubarPtr); cloneMenuRefPtr = TkFindMenuReferencesObj(interp, cloneMenuPtr); if ((cloneMenuRefPtr != NULL) && (cloneMenuRefPtr->menuPtr != NULL)) { Tcl_Obj *cursorPtr = Tcl_NewStringObj("-cursor", -1); Tcl_Obj *nullPtr = Tcl_NewObj(); cloneMenuRefPtr->menuPtr->parentTopLevelPtr = tkwin; menuBarPtr = cloneMenuRefPtr->menuPtr; newObjv[0] = cursorPtr; newObjv[1] = nullPtr; Tcl_IncrRefCount(cursorPtr); Tcl_IncrRefCount(nullPtr); ConfigureMenu(menuPtr->interp, cloneMenuRefPtr->menuPtr, |
︙ | ︙ | |||
3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 | TkMenuReferences * TkFindMenuReferencesObj( Tcl_Interp *interp, /* The interp the menu is living in. */ Tcl_Obj *objPtr) /* The path of the menu widget. */ { const char *pathName = Tcl_GetString(objPtr); return TkFindMenuReferences(interp, pathName); } /* *---------------------------------------------------------------------- * * TkFreeMenuReferences -- | > | 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 | TkMenuReferences * TkFindMenuReferencesObj( Tcl_Interp *interp, /* The interp the menu is living in. */ Tcl_Obj *objPtr) /* The path of the menu widget. */ { const char *pathName = Tcl_GetString(objPtr); return TkFindMenuReferences(interp, pathName); } /* *---------------------------------------------------------------------- * * TkFreeMenuReferences -- |
︙ | ︙ |
Changes to generic/tkMenubutton.c.
︙ | ︙ | |||
19 20 21 22 23 24 25 | * The structure below defines menubutton class behavior by means of * procedures that can be invoked from generic window code. */ static const Tk_ClassProcs menubuttonClass = { sizeof(Tk_ClassProcs), /* size */ TkMenuButtonWorldChanged, /* worldChangedProc */ | | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | * The structure below defines menubutton class behavior by means of * procedures that can be invoked from generic window code. */ static const Tk_ClassProcs menubuttonClass = { sizeof(Tk_ClassProcs), /* size */ TkMenuButtonWorldChanged, /* worldChangedProc */ NULL, /* createProc */ NULL /* modalProc */ }; /* * The following table defines the legal values for the -direction option. It * is used together with the "enum direction" declaration in tkMenubutton.h. */ |
︙ | ︙ |
Changes to generic/tkMessage.c.
︙ | ︙ | |||
187 188 189 190 191 192 193 | * The structure below defines message class behavior by means of functions * that can be invoked from generic window code. */ static const Tk_ClassProcs messageClass = { sizeof(Tk_ClassProcs), /* size */ MessageWorldChanged, /* worldChangedProc */ | | | | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | * The structure below defines message class behavior by means of functions * that can be invoked from generic window code. */ static const Tk_ClassProcs messageClass = { sizeof(Tk_ClassProcs), /* size */ MessageWorldChanged, /* worldChangedProc */ NULL, /* createProc */ NULL /* modalProc */ }; /* *-------------------------------------------------------------- * * Tk_MessageObjCmd -- * |
︙ | ︙ | |||
273 274 275 276 277 278 279 | } if (ConfigureMessage(interp, msgPtr, objc-2, objv+2, 0) != TCL_OK) { Tk_DestroyWindow(msgPtr->tkwin); return TCL_ERROR; } | | | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | } if (ConfigureMessage(interp, msgPtr, objc-2, objv+2, 0) != TCL_OK) { Tk_DestroyWindow(msgPtr->tkwin); return TCL_ERROR; } Tcl_SetObjResult(interp, TkNewWindowObj(msgPtr->tkwin)); return TCL_OK; } /* *-------------------------------------------------------------- * * MessageWidgetObjCmd -- |
︙ | ︙ |
Changes to generic/tkObj.c.
︙ | ︙ | |||
502 503 504 505 506 507 508 509 510 511 512 513 514 515 | } return TCL_OK; error: if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad screen distance \"%.50s\"", string)); } return TCL_ERROR; } /* *---------------------------------------------------------------------- * | > | 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 | } return TCL_OK; error: if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad screen distance \"%.50s\"", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", NULL); } return TCL_ERROR; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
730 731 732 733 734 735 736 | if (rest == string) { /* * Must copy string before resetting the result in case a caller * is trying to convert the interpreter's result to mms. */ error: | | | > | 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 | if (rest == string) { /* * Must copy string before resetting the result in case a caller * is trying to convert the interpreter's result to mms. */ error: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad screen distance \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "DISTANCE", NULL); return TCL_ERROR; } while ((*rest != '\0') && isspace(UCHAR(*rest))) { rest++; } switch (*rest) { |
︙ | ︙ | |||
1028 1029 1030 1031 1032 1033 1034 | /* * Check for a common case where a single object would otherwise be * shimmered between a list and a pixel spec. */ if (specObj->typePtr == &pixelObjType) { if (Tk_GetPixelsFromObj(interp, tkwin, specObj, &firstInt) != TCL_OK){ | | | | | | | > | < | > > | | | | | 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 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 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 | /* * Check for a common case where a single object would otherwise be * shimmered between a list and a pixel spec. */ if (specObj->typePtr == &pixelObjType) { if (Tk_GetPixelsFromObj(interp, tkwin, specObj, &firstInt) != TCL_OK){ Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad pad value \"%s\": must be positive screen distance", Tcl_GetString(specObj))); Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "DIST", NULL); return TCL_ERROR; } secondInt = firstInt; goto done; } /* * Pad specifications are a list of one or two elements, each of which is * a pixel specification. */ if (Tcl_ListObjGetElements(interp, specObj, &objc, &objv) != TCL_OK) { return TCL_ERROR; } if (objc != 1 && objc != 2) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "wrong number of parts to pad specification", -1)); Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "PARTS", NULL); return TCL_ERROR; } /* * Parse the first part. */ if (Tk_GetPixelsFromObj(interp, tkwin, objv[0], &firstInt) != TCL_OK || (firstInt < 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad pad value \"%s\": must be positive screen distance", Tcl_GetString(objv[0]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "DIST", NULL); return TCL_ERROR; } /* * Parse the second part if it exists, otherwise it is as if it was the * same as the first part. */ if (objc == 1) { secondInt = firstInt; } else if (Tk_GetPixelsFromObj(interp, tkwin, objv[1], &secondInt) != TCL_OK || (secondInt < 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad 2nd pad value \"%s\": must be positive screen distance", Tcl_GetString(objv[1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "DIST", NULL); return TCL_ERROR; } /* * Write the parsed bits back into the receiving variables. */ |
︙ | ︙ |
Changes to generic/tkOldConfig.c.
︙ | ︙ | |||
91 92 93 94 95 96 97 | if (tkwin == NULL) { /* * Either we're not really in Tk, or the main window was destroyed and * we're on our way out of the application */ | | > | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | if (tkwin == NULL) { /* * Either we're not really in Tk, or the main window was destroyed and * we're on our way out of the application */ Tcl_SetObjResult(interp, Tcl_NewStringObj("NULL main window", -1)); Tcl_SetErrorCode(interp, "TK", "NO_MAIN_WINDOW", NULL); return TCL_ERROR; } needFlags = flags & ~(TK_CONFIG_USER_BIT - 1); if (Tk_Depth(tkwin) <= 1) { hateFlags = TK_CONFIG_COLOR_ONLY; } else { |
︙ | ︙ | |||
131 132 133 134 135 136 137 | } /* * Process the entry. */ if (argc < 2) { | | > > < | | < < | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | } /* * Process the entry. */ if (argc < 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", arg)); Tcl_SetErrorCode(interp, "TK", "VALUE_MISSING", NULL); return TCL_ERROR; } if (flags & TK_CONFIG_OBJS) { arg = Tcl_GetString((Tcl_Obj *) argv[1]); } else { arg = argv[1]; } if (DoConfig(interp, tkwin, specPtr, arg, 0, widgRec) != TCL_OK) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( "\n (processing \"%.40s\" option)",specPtr->argvName)); return TCL_ERROR; } if (!(flags & TK_CONFIG_ARGV_ONLY)) { specPtr->specFlags |= TK_CONFIG_OPTION_SPECIFIED; } } |
︙ | ︙ | |||
177 178 179 180 181 182 183 | value = NULL; if (specPtr->dbName != NULL) { value = Tk_GetOption(tkwin, specPtr->dbName, specPtr->dbClass); } if (value != NULL) { if (DoConfig(interp, tkwin, specPtr, value, 1, widgRec) != TCL_OK) { | < | | | | < < | < | | < | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | value = NULL; if (specPtr->dbName != NULL) { value = Tk_GetOption(tkwin, specPtr->dbName, specPtr->dbClass); } if (value != NULL) { if (DoConfig(interp, tkwin, specPtr, value, 1, widgRec) != TCL_OK) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( "\n (%s \"%.50s\" in widget \"%.50s\")", "database entry for", specPtr->dbName, Tk_PathName(tkwin))); return TCL_ERROR; } } else { if (specPtr->defValue != NULL) { value = Tk_GetUid(specPtr->defValue); } else { value = NULL; } if ((value != NULL) && !(specPtr->specFlags & TK_CONFIG_DONT_SET_DEFAULT)) { if (DoConfig(interp, tkwin, specPtr, value, 1, widgRec) != TCL_OK) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( "\n (%s \"%.50s\" in widget \"%.50s\")", "default value for", specPtr->dbName, Tk_PathName(tkwin))); return TCL_ERROR; } } } } } |
︙ | ︙ | |||
268 269 270 271 272 273 274 | continue; } if (specPtr->argvName[length] == 0) { matchPtr = specPtr; goto gotMatch; } if (matchPtr != NULL) { | | | > > | > > | | > > | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | continue; } if (specPtr->argvName[length] == 0) { matchPtr = specPtr; goto gotMatch; } if (matchPtr != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "ambiguous option \"%s\"", argvName)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "OPTION", argvName,NULL); return NULL; } matchPtr = specPtr; } if (matchPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown option \"%s\"", argvName)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "OPTION", argvName, NULL); return NULL; } /* * Found a matching entry. If it's a synonym, then find the entry that * it's a synonym for. */ gotMatch: specPtr = matchPtr; if (specPtr->type == TK_CONFIG_SYNONYM) { for (specPtr = specs; ; specPtr++) { if (specPtr->type == TK_CONFIG_END) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't find synonym for option \"%s\"", argvName)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "OPTION", argvName, NULL); return NULL; } if ((specPtr->dbName == matchPtr->dbName) && (specPtr->type != TK_CONFIG_SYNONYM) && ((specPtr->specFlags & needFlags) == needFlags) && !(specPtr->specFlags & hateFlags)) { break; |
︙ | ︙ | |||
542 543 544 545 546 547 548 | } case TK_CONFIG_CUSTOM: if (specPtr->customPtr->parseProc(specPtr->customPtr->clientData, interp, tkwin, value, widgRec, specPtr->offset)!=TCL_OK) { return TCL_ERROR; } break; | | < | | | < | 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | } case TK_CONFIG_CUSTOM: if (specPtr->customPtr->parseProc(specPtr->customPtr->clientData, interp, tkwin, value, widgRec, specPtr->offset)!=TCL_OK) { return TCL_ERROR; } break; default: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad config table: unknown type %d", specPtr->type)); Tcl_SetErrorCode(interp, "TK", "BAD_CONFIG", NULL); return TCL_ERROR; } specPtr++; } while ((specPtr->argvName == NULL) && (specPtr->type != TK_CONFIG_END)); return TCL_OK; } /* |
︙ | ︙ | |||
622 623 624 625 626 627 628 | /* * If information is only wanted for a single configuration spec, then * handle that one spec specially. */ Tcl_ResetResult(interp); if (argvName != NULL) { | | > | | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 | /* * If information is only wanted for a single configuration spec, then * handle that one spec specially. */ Tcl_ResetResult(interp); if (argvName != NULL) { specPtr = FindConfigSpec(interp, staticSpecs, argvName, needFlags, hateFlags); if (specPtr == NULL) { return TCL_ERROR; } list = FormatConfigInfo(interp, tkwin, specPtr, widgRec); Tcl_SetObjResult(interp, Tcl_NewStringObj(list, -1)); ckfree(list); return TCL_OK; } /* * Loop through all the specs, creating a big list with all their * information. |
︙ | ︙ | |||
932 933 934 935 936 937 938 | specPtr = FindConfigSpec(interp, specPtr, argvName, needFlags, hateFlags); if (specPtr == NULL) { return TCL_ERROR; } result = FormatConfigValue(interp, tkwin, specPtr, widgRec, buffer, &freeProc); | | | 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 | specPtr = FindConfigSpec(interp, specPtr, argvName, needFlags, hateFlags); if (specPtr == NULL) { return TCL_ERROR; } result = FormatConfigValue(interp, tkwin, specPtr, widgRec, buffer, &freeProc); Tcl_SetObjResult(interp, Tcl_NewStringObj(result, -1)); if (freeProc != NULL) { if ((freeProc == TCL_DYNAMIC) || (freeProc == (Tcl_FreeProc *) free)) { ckfree(result); } else { freeProc((char *) result); } } |
︙ | ︙ |
Changes to generic/tkOption.c.
︙ | ︙ | |||
537 538 539 540 541 542 543 | classNameLength = (unsigned) (masqName - name); masqClass = ckalloc(classNameLength + 1); strncpy(masqClass, name, classNameLength); masqClass[classNameLength] = '\0'; winClassId = Tk_GetUid(masqClass); ckfree(masqClass); | | | 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | classNameLength = (unsigned) (masqName - name); masqClass = ckalloc(classNameLength + 1); strncpy(masqClass, name, classNameLength); masqClass[classNameLength] = '\0'; winClassId = Tk_GetUid(masqClass); ckfree(masqClass); winNameId = ((TkWindow *) tkwin)->nameUid; levelPtr = &tsdPtr->levels[tsdPtr->curLevel]; for (currentPtr = searchOrder; *currentPtr != -1; currentPtr++) { currentStack = *currentPtr; nodePtr = tsdPtr->stacks[currentStack]->els; count = levelPtr->bases[currentStack]; |
︙ | ︙ | |||
615 616 617 618 619 620 621 | int objc, /* Number of Tcl_Obj arguments. */ Tcl_Obj *const objv[]) /* Tcl_Obj arguments. */ { Tk_Window tkwin = clientData; int index, result; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); | < < | 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | int objc, /* Number of Tcl_Obj arguments. */ Tcl_Obj *const objv[]) /* Tcl_Obj arguments. */ { Tk_Window tkwin = clientData; int index, result; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); static const char *const optionCmds[] = { "add", "clear", "get", "readfile", NULL }; enum optionVals { OPTION_ADD, OPTION_CLEAR, OPTION_GET, OPTION_READFILE }; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "cmd arg ?arg ...?"); return TCL_ERROR; |
︙ | ︙ | |||
659 660 661 662 663 664 665 | } Tk_AddOption(tkwin, Tcl_GetString(objv[2]), Tcl_GetString(objv[3]), priority); break; } case OPTION_CLEAR: { | | < | 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 | } Tk_AddOption(tkwin, Tcl_GetString(objv[2]), Tcl_GetString(objv[3]), priority); break; } case OPTION_CLEAR: { TkMainInfo *mainPtr = ((TkWindow *) tkwin)->mainPtr; if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, ""); return TCL_ERROR; } if (mainPtr->optionRootPtr != NULL) { ClearOptionTree(mainPtr->optionRootPtr); mainPtr->optionRootPtr = NULL; } tsdPtr->cachedWindow = NULL; break; } |
︙ | ︙ | |||
689 690 691 692 693 694 695 | window = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin); if (window == NULL) { return TCL_ERROR; } value = Tk_GetOption(window, Tcl_GetString(objv[3]), Tcl_GetString(objv[4])); if (value != NULL) { | | | 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 | window = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin); if (window == NULL) { return TCL_ERROR; } value = Tk_GetOption(window, Tcl_GetString(objv[3]), Tcl_GetString(objv[4])); if (value != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj(value, -1)); } break; } case OPTION_READFILE: { int priority; |
︙ | ︙ | |||
876 877 878 879 880 881 882 | return TK_INTERACTIVE_PRIO; } else { char *end; priority = strtoul(string, &end, 0); if ((end == string) || (*end != 0) || (priority < 0) || (priority > 100)) { | > | | | > | 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 | return TK_INTERACTIVE_PRIO; } else { char *end; priority = strtoul(string, &end, 0); if ((end == string) || (*end != 0) || (priority < 0) || (priority > 100)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad priority level \"%s\": must be " "widgetDefault, startupFile, userDefault, " "interactive, or a number between 0 and 100", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "PRIORITY", NULL); return -1; } } return priority; } /* |
︙ | ︙ | |||
960 961 962 963 964 965 966 | * Parse off the option name, collapsing out backslash-newline * sequences of course. */ dst = name = src; while (*src != ':') { if ((*src == '\0') || (*src == '\n')) { | < | | | | 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 | * Parse off the option name, collapsing out backslash-newline * sequences of course. */ dst = name = src; while (*src != ':') { if ((*src == '\0') || (*src == '\n')) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "missing colon on line %d", lineNum)); Tcl_SetErrorCode(interp, "TK", "OPTIONDB", "COLON", NULL); return TCL_ERROR; } if ((src[0] == '\\') && (src[1] == '\n')) { src += 2; lineNum++; } else { *dst = *src; |
︙ | ︙ | |||
995 996 997 998 999 1000 1001 | */ src++; while ((*src == ' ') || (*src == '\t')) { src++; } if (*src == '\0') { | < | | | < | | | | 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 1021 1022 1023 | */ src++; while ((*src == ' ') || (*src == '\t')) { src++; } if (*src == '\0') { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "missing value on line %d", lineNum)); Tcl_SetErrorCode(interp, "TK", "OPTIONDB", "VALUE", NULL); return TCL_ERROR; } /* * Parse off the value, squeezing out backslash-newline sequences * along the way. */ dst = value = src; while (*src != '\n') { if (*src == '\0') { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "missing newline on line %d", lineNum)); Tcl_SetErrorCode(interp, "TK", "OPTIONDB", "NEWLINE", NULL); return TCL_ERROR; } if ((src[0] == '\\') && (src[1] == '\n')) { src += 2; lineNum++; } else { *dst = *src; |
︙ | ︙ | |||
1062 1063 1064 1065 1066 1067 1068 | */ static int ReadOptionFile( Tcl_Interp *interp, /* Interpreter to use for reporting results. */ Tk_Window tkwin, /* Token for window: options are entered for * this window's main window. */ | | | | > | < | > | | > | | | 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 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 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 | */ static int ReadOptionFile( Tcl_Interp *interp, /* Interpreter to use for reporting results. */ Tk_Window tkwin, /* Token for window: options are entered for * this window's main window. */ const char *fileName, /* Name of file containing options. */ int priority) /* Priority level to use for options in this * file, such as TK_USER_DEFAULT_PRIO or * TK_INTERACTIVE_PRIO. Must be between 0 and * TK_MAX_PRIO. */ { const char *realName; char *buffer; int result, bufferSize; Tcl_Channel chan; Tcl_DString newName; /* * Prevent file system access in a safe interpreter. */ if (Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't read options from a file in a safe interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "OPTION_FILE", NULL); return TCL_ERROR; } realName = Tcl_TranslateFileName(interp, fileName, &newName); if (realName == NULL) { return TCL_ERROR; } chan = Tcl_OpenFileChannel(interp, realName, "r", 0); Tcl_DStringFree(&newName); if (chan == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf("couldn't open \"%s\": %s", fileName, Tcl_PosixError(interp))); return TCL_ERROR; } /* * Compute size of file by seeking to the end of the file. This will * overallocate if we are performing CRLF translation. */ bufferSize = (int) Tcl_Seek(chan, (Tcl_WideInt) 0, SEEK_END); Tcl_Seek(chan, (Tcl_WideInt) 0, SEEK_SET); if (bufferSize < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error seeking to end of file \"%s\": %s", fileName, Tcl_PosixError(interp))); Tcl_Close(NULL, chan); return TCL_ERROR; } buffer = ckalloc(bufferSize + 1); bufferSize = Tcl_Read(chan, buffer, bufferSize); if (bufferSize < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error reading file \"%s\": %s", fileName, Tcl_PosixError(interp))); Tcl_Close(NULL, chan); return TCL_ERROR; } Tcl_Close(NULL, chan); buffer[bufferSize] = 0; result = AddFromString(interp, tkwin, buffer, priority); ckfree(buffer); |
︙ | ︙ | |||
1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 | * of levels. Clear the stacks for EXACT_LEAF_NAME and EXACT_LEAF_CLASS * (anything that was there is of no use any more). */ if (tsdPtr->curLevel >= tsdPtr->numLevels) { StackLevel *newLevels = ckalloc(tsdPtr->numLevels * 2 * sizeof(StackLevel)); memcpy(newLevels, tsdPtr->levels, tsdPtr->numLevels * sizeof(StackLevel)); ckfree(tsdPtr->levels); tsdPtr->numLevels *= 2; tsdPtr->levels = newLevels; } levelPtr = &tsdPtr->levels[tsdPtr->curLevel]; | > | 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 | * of levels. Clear the stacks for EXACT_LEAF_NAME and EXACT_LEAF_CLASS * (anything that was there is of no use any more). */ if (tsdPtr->curLevel >= tsdPtr->numLevels) { StackLevel *newLevels = ckalloc(tsdPtr->numLevels * 2 * sizeof(StackLevel)); memcpy(newLevels, tsdPtr->levels, tsdPtr->numLevels * sizeof(StackLevel)); ckfree(tsdPtr->levels); tsdPtr->numLevels *= 2; tsdPtr->levels = newLevels; } levelPtr = &tsdPtr->levels[tsdPtr->curLevel]; |
︙ | ︙ |
Changes to generic/tkPack.c.
︙ | ︙ | |||
129 130 131 132 133 134 135 | static void Unlink(Packer *packPtr); static int XExpansion(Packer *slavePtr, int cavityWidth); static int YExpansion(Packer *slavePtr, int cavityHeight); /* *------------------------------------------------------------------------ * | | | | | | > > | > | | | > > < | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 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 | static void Unlink(Packer *packPtr); static int XExpansion(Packer *slavePtr, int cavityWidth); static int YExpansion(Packer *slavePtr, int cavityHeight); /* *------------------------------------------------------------------------ * * TkAppendPadAmount -- * * This function generates a text value that describes one of the -padx, * -pady, -ipadx, or -ipady configuration options. The text value * generated is appended to the given Tcl_Obj. * * Results: * None. * * Side effects: * None. * *------------------------------------------------------------------------ */ void TkAppendPadAmount( Tcl_Obj *bufferObj, /* The interpreter into which the result is * written. */ const char *switchName, /* One of "padx", "pady", "ipadx" or * "ipady" */ int halfSpace, /* The left or top padding amount */ int allSpace) /* The total amount of padding */ { Tcl_Obj *padding[2]; if (halfSpace*2 == allSpace) { Tcl_DictObjPut(NULL, bufferObj, Tcl_NewStringObj(switchName, -1), Tcl_NewIntObj(halfSpace)); } else { padding[0] = Tcl_NewIntObj(halfSpace); padding[1] = Tcl_NewIntObj(allSpace - halfSpace); Tcl_DictObjPut(NULL, bufferObj, Tcl_NewStringObj(switchName, -1), Tcl_NewListObj(2, padding)); } } /* *------------------------------------------------------------------------ * * Tk_PackCmd -- * |
︙ | ︙ | |||
234 235 236 237 238 239 240 | Tk_Window tkwin2; if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) { return TCL_ERROR; } prevPtr = GetPacker(tkwin2); if (prevPtr->masterPtr == NULL) { | | | > | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | Tk_Window tkwin2; if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) { return TCL_ERROR; } prevPtr = GetPacker(tkwin2); if (prevPtr->masterPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't packed", argv2)); Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL); return TCL_ERROR; } return PackAfter(interp, prevPtr, prevPtr->masterPtr, objc-3, objv+3); } case PACK_APPEND: { Packer *masterPtr; register Packer *prevPtr; |
︙ | ︙ | |||
267 268 269 270 271 272 273 | Tk_Window tkwin2; if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) { return TCL_ERROR; } packPtr = GetPacker(tkwin2); if (packPtr->masterPtr == NULL) { | | | > | | > | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | Tk_Window tkwin2; if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) { return TCL_ERROR; } packPtr = GetPacker(tkwin2); if (packPtr->masterPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't packed", argv2)); Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL); return TCL_ERROR; } masterPtr = packPtr->masterPtr; prevPtr = masterPtr->slavePtr; if (prevPtr == packPtr) { prevPtr = NULL; } else { for ( ; ; prevPtr = prevPtr->nextPtr) { if (prevPtr == NULL) { Tcl_Panic("\"pack before\" couldn't find predecessor"); } if (prevPtr->nextPtr == packPtr) { break; } } } return PackAfter(interp, prevPtr, masterPtr, objc-3, objv+3); } case PACK_CONFIGURE: if (argv2[0] != '.') { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad argument \"%s\": must be name of window", argv2)); Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW_PATH", NULL); return TCL_ERROR; } return ConfigureSlaves(interp, tkwin, objc-2, objv+2); case PACK_FORGET: { Tk_Window slave; Packer *slavePtr; int i; |
︙ | ︙ | |||
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | } } break; } case PACK_INFO: { register Packer *slavePtr; Tk_Window slave; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (TkGetWindowFromObj(interp, tkwin, objv[2], &slave) != TCL_OK) { return TCL_ERROR; } slavePtr = GetPacker(slave); if (slavePtr->masterPtr == NULL) { | > | | > | > > | | | | | > | > | > | > | | | | | > | > | 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 | } } break; } case PACK_INFO: { register Packer *slavePtr; Tk_Window slave; Tcl_Obj *infoObj; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (TkGetWindowFromObj(interp, tkwin, objv[2], &slave) != TCL_OK) { return TCL_ERROR; } slavePtr = GetPacker(slave); if (slavePtr->masterPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't packed", argv2)); Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL); return TCL_ERROR; } infoObj = Tcl_NewObj(); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-in", -1), TkNewWindowObj(slavePtr->masterPtr->tkwin)); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-anchor", -1), Tcl_NewStringObj(Tk_NameOfAnchor(slavePtr->anchor), -1)); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-expand", -1), Tcl_NewBooleanObj(slavePtr->flags & EXPAND)); switch (slavePtr->flags & (FILLX|FILLY)) { case 0: Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-fill", -1), Tcl_NewStringObj("none", -1)); break; case FILLX: Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-fill", -1), Tcl_NewStringObj("x", -1)); break; case FILLY: Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-fill", -1), Tcl_NewStringObj("y", -1)); break; case FILLX|FILLY: Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-fill", -1), Tcl_NewStringObj("both", -1)); break; } TkAppendPadAmount(infoObj, "-ipadx", slavePtr->iPadX/2, slavePtr->iPadX); TkAppendPadAmount(infoObj, "-ipady", slavePtr->iPadY/2, slavePtr->iPadY); TkAppendPadAmount(infoObj, "-padx", slavePtr->padLeft,slavePtr->padX); TkAppendPadAmount(infoObj, "-pady", slavePtr->padTop, slavePtr->padY); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-side", -1), Tcl_NewStringObj(sideNames[slavePtr->side], -1)); Tcl_SetObjResult(interp, infoObj); break; } case PACK_PROPAGATE: { Tk_Window master; Packer *masterPtr; int propagate; |
︙ | ︙ | |||
1092 1093 1094 1095 1096 1097 1098 | * Iterate over all of the window specifiers, each consisting of two * arguments. The first argument contains the window name and the * additional arguments contain options such as "top" or "padx 20". */ for ( ; objc > 0; objc -= 2, objv += 2, prevPtr = packPtr) { if (objc < 2) { | > | | | | 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 | * Iterate over all of the window specifiers, each consisting of two * arguments. The first argument contains the window name and the * additional arguments contain options such as "top" or "padx 20". */ for ( ; objc > 0; objc -= 2, objv += 2, prevPtr = packPtr) { if (objc < 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: window \"%s\" should be followed by options", Tcl_GetString(objv[0]))); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); return TCL_ERROR; } /* * Find the packer for the window to be packed, and make sure that the * window in which it will be packed is either its or a descendant of * its parent. |
︙ | ︙ | |||
1116 1117 1118 1119 1120 1121 1122 | parent = Tk_Parent(tkwin); for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_HIERARCHY) { badWindow: | > | | > | 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 | parent = Tk_Parent(tkwin); for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_HIERARCHY) { badWindow: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't pack %s inside %s", Tcl_GetString(objv[0]), Tk_PathName(masterPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); return TCL_ERROR; } } if (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_HIERARCHY) { goto badWindow; } if (tkwin == masterPtr->tkwin) { |
︙ | ︙ | |||
1175 1176 1177 1178 1179 1180 1181 | } else if ((length == 5) && (strcmp(curOpt, "fillx")) == 0) { packPtr->flags |= FILLX; } else if ((length == 5) && (strcmp(curOpt, "filly")) == 0) { packPtr->flags |= FILLY; } else if ((c == 'p') && (strcmp(curOpt, "padx")) == 0) { if (optionCount < (index+2)) { missingPad: | > | | > | 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 | } else if ((length == 5) && (strcmp(curOpt, "fillx")) == 0) { packPtr->flags |= FILLX; } else if ((length == 5) && (strcmp(curOpt, "filly")) == 0) { packPtr->flags |= FILLY; } else if ((c == 'p') && (strcmp(curOpt, "padx")) == 0) { if (optionCount < (index+2)) { missingPad: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: \"%s\" option must be" " followed by screen distance", curOpt)); Tcl_SetErrorCode(interp, "TK", "OLDPACK", "BAD_PARAMETER", NULL); return TCL_ERROR; } if (TkParsePadAmount(interp, tkwin, options[index+1], &packPtr->padLeft, &packPtr->padX) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
1203 1204 1205 1206 1207 1208 1209 | packPtr->padY /= 2; packPtr->padTop /= 2; packPtr->iPadY = 0; index++; } else if ((c == 'f') && (length > 1) && (strncmp(curOpt, "frame", (size_t) length) == 0)) { if (optionCount < (index+2)) { | > | | > > | | | > > > < | 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 | packPtr->padY /= 2; packPtr->padTop /= 2; packPtr->iPadY = 0; index++; } else if ((c == 'f') && (length > 1) && (strncmp(curOpt, "frame", (size_t) length) == 0)) { if (optionCount < (index+2)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "wrong # args: \"frame\"" " option must be followed by anchor point", -1)); Tcl_SetErrorCode(interp, "TK", "OLDPACK", "BAD_PARAMETER", NULL); return TCL_ERROR; } if (Tk_GetAnchorFromObj(interp, options[index+1], &packPtr->anchor) != TCL_OK) { return TCL_ERROR; } index++; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad option \"%s\": should be top, bottom, left," " right, expand, fill, fillx, filly, padx, pady, or" " frame", curOpt)); Tcl_SetErrorCode(interp, "TK", "OLDPACK", "BAD_PARAMETER", NULL); return TCL_ERROR; } } if (packPtr != prevPtr) { /* * Unpack this window if it's currently packed. */ if (packPtr->masterPtr != NULL) { if ((packPtr->masterPtr != masterPtr) && (packPtr->masterPtr->tkwin |
︙ | ︙ | |||
1530 1531 1532 1533 1534 1535 1536 | prevPtr = NULL; positionGiven = 0; for (j = 0; j < numWindows; j++) { if (TkGetWindowFromObj(interp, tkwin, objv[j], &slave) != TCL_OK) { return TCL_ERROR; } if (Tk_TopWinHierarchy(slave)) { | | | > > | 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 | prevPtr = NULL; positionGiven = 0; for (j = 0; j < numWindows; j++) { if (TkGetWindowFromObj(interp, tkwin, objv[j], &slave) != TCL_OK) { return TCL_ERROR; } if (Tk_TopWinHierarchy(slave)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't pack \"%s\": it's a top-level window", Tcl_GetString(objv[j]))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL); return TCL_ERROR; } slavePtr = GetPacker(slave); slavePtr->flags &= ~OLD_STYLE; /* * If the slave isn't currently packed, reset all of its configuration |
︙ | ︙ | |||
1554 1555 1556 1557 1558 1559 1560 | slavePtr->padLeft = slavePtr->padTop = 0; slavePtr->iPadX = slavePtr->iPadY = 0; slavePtr->flags &= ~(FILLX|FILLY|EXPAND); } for (i = numWindows; i < objc; i+=2) { if ((i+2) > objc) { | | > | | | > | > | 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 | slavePtr->padLeft = slavePtr->padTop = 0; slavePtr->iPadX = slavePtr->iPadY = 0; slavePtr->flags &= ~(FILLX|FILLY|EXPAND); } for (i = numWindows; i < objc; i+=2) { if ((i+2) > objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "extra option \"%s\" (option with no value?)", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "PACK", "BAD_PARAMETER", NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option", 0, &index) != TCL_OK) { return TCL_ERROR; } switch ((enum options) index) { case CONF_AFTER: if (j == 0) { if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other) != TCL_OK) { return TCL_ERROR; } prevPtr = GetPacker(other); if (prevPtr->masterPtr == NULL) { notPacked: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't packed", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL); return TCL_ERROR; } masterPtr = prevPtr->masterPtr; positionGiven = 1; } break; |
︙ | ︙ | |||
1631 1632 1633 1634 1635 1636 1637 | } else if (strcmp(string, "x") == 0) { slavePtr->flags = (slavePtr->flags & ~FILLY) | FILLX; } else if (strcmp(string, "y") == 0) { slavePtr->flags = (slavePtr->flags & ~FILLX) | FILLY; } else if (strcmp(string, "both") == 0) { slavePtr->flags |= FILLX|FILLY; } else { | > | | > | 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 | } else if (strcmp(string, "x") == 0) { slavePtr->flags = (slavePtr->flags & ~FILLY) | FILLX; } else if (strcmp(string, "y") == 0) { slavePtr->flags = (slavePtr->flags & ~FILLX) | FILLY; } else if (strcmp(string, "both") == 0) { slavePtr->flags |= FILLX|FILLY; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad fill style \"%s\": must be " "none, x, y, or both", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "FILL", NULL); return TCL_ERROR; } break; case CONF_IN: if (j == 0) { if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other) != TCL_OK) { |
︙ | ︙ | |||
1654 1655 1656 1657 1658 1659 1660 | } } positionGiven = 1; } break; case CONF_IPADX: if ((Tk_GetPixelsFromObj(interp, slave, objv[i+1], &tmp) | | < | | | < > | < | | | < > | 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 | } } positionGiven = 1; } break; case CONF_IPADX: if ((Tk_GetPixelsFromObj(interp, slave, objv[i+1], &tmp) != TCL_OK) || (tmp < 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad ipadx value \"%s\": must be positive screen" " distance", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL); return TCL_ERROR; } slavePtr->iPadX = tmp * 2; break; case CONF_IPADY: if ((Tk_GetPixelsFromObj(interp, slave, objv[i+1], &tmp) != TCL_OK) || (tmp < 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad ipady value \"%s\": must be positive screen" " distance", Tcl_GetString(objv[i+1]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL); return TCL_ERROR; } slavePtr->iPadY = tmp * 2; break; case CONF_PADX: if (TkParsePadAmount(interp, slave, objv[i+1], &slavePtr->padLeft, &slavePtr->padX) != TCL_OK) { |
︙ | ︙ | |||
1748 1749 1750 1751 1752 1753 1754 | parent = Tk_Parent(slave); for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (Tk_TopWinHierarchy(ancestor)) { | > | | > | | > | 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 | parent = Tk_Parent(slave); for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (Tk_TopWinHierarchy(ancestor)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't pack %s inside %s", Tcl_GetString(objv[j]), Tk_PathName(masterPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); return TCL_ERROR; } } if (slave == masterPtr->tkwin) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't pack %s inside itself", Tcl_GetString(objv[j]))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL); return TCL_ERROR; } /* * Unpack the slave if it's currently packed, then position it after * prevPtr. */ |
︙ | ︙ |
Changes to generic/tkPanedWindow.c.
︙ | ︙ | |||
654 655 656 657 658 659 660 | for (i = 0; i < pwPtr->numSlaves; i++) { if (pwPtr->slaves[i]->tkwin == tkwin) { resultObj = Tk_GetOptionValue(interp, (char *) pwPtr->slaves[i], pwPtr->slaveOpts, objv[3], tkwin); } } | > | > | > > | < | 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | for (i = 0; i < pwPtr->numSlaves; i++) { if (pwPtr->slaves[i]->tkwin == tkwin) { resultObj = Tk_GetOptionValue(interp, (char *) pwPtr->slaves[i], pwPtr->slaveOpts, objv[3], tkwin); } } if (resultObj == NULL) { if (i == pwPtr->numSlaves) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "not managed by this window", -1)); Tcl_SetErrorCode(interp, "TK", "PANEDWINDOW", "UNMANAGED", NULL); } result = TCL_ERROR; } else { Tcl_SetObjResult(interp, resultObj); } break; case PW_PANECONFIGURE: |
︙ | ︙ | |||
696 697 698 699 700 701 702 | } else { result = ConfigureSlaves(pwPtr, interp, objc, objv); } break; case PW_PANES: resultObj = Tcl_NewObj(); | < < < | | < | 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 | } else { result = ConfigureSlaves(pwPtr, interp, objc, objv); } break; case PW_PANES: resultObj = Tcl_NewObj(); for (i = 0; i < pwPtr->numSlaves; i++) { Tcl_ListObjAppendElement(NULL, resultObj, TkNewWindowObj(pwPtr->slaves[i]->tkwin)); } Tcl_SetObjResult(interp, resultObj); break; case PW_PROXY: result = PanedWindowProxyCommand(pwPtr, interp, objc, objv); break; case PW_SASH: |
︙ | ︙ | |||
774 775 776 777 778 779 780 | return TCL_ERROR; } else if (tkwin == pwPtr->tkwin) { /* * A panedwindow cannot manage itself. */ | | | | | | | > | | | > > | 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 | return TCL_ERROR; } else if (tkwin == pwPtr->tkwin) { /* * A panedwindow cannot manage itself. */ Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't add %s to itself", arg)); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL); return TCL_ERROR; } else if (Tk_IsTopLevel(tkwin)) { /* * A panedwindow cannot manage a toplevel. */ Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't add toplevel %s to %s", arg, Tk_PathName(pwPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL); return TCL_ERROR; } else { /* * Make sure the panedwindow is the parent of the slave, * or a descendant of the slave's parent. */ parent = Tk_Parent(tkwin); for (ancestor = pwPtr->tkwin;;ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (Tk_IsTopLevel(ancestor)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't add %s to %s", arg, Tk_PathName(pwPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); return TCL_ERROR; } } } } } firstOptionArg = i; |
︙ | ︙ | |||
858 859 860 861 862 863 864 | /* * If a window was given for -after/-before, but it's not a window managed * by the panedwindow, throw an error */ if (haveLoc && index == -1) { | | | | > | 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 | /* * If a window was given for -after/-before, but it's not a window managed * by the panedwindow, throw an error */ if (haveLoc && index == -1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" is not managed by %s", Tk_PathName(tkwin), Tk_PathName(pwPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "PANEDWINDOW", "UNMANAGED", NULL); Tk_FreeConfigOptions((char *) &options, pwPtr->slaveOpts, pwPtr->tkwin); return TCL_ERROR; } /* * Allocate an array to hold, in order, the pointers to the slave |
︙ | ︙ | |||
1082 1083 1084 1085 1086 1087 1088 | } if (Tcl_GetIndexFromObj(interp, objv[2], sashOptionStrings, "option", 0, &index) != TCL_OK) { return TCL_ERROR; } | < | | > | | > | 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 | } if (Tcl_GetIndexFromObj(interp, objv[2], sashOptionStrings, "option", 0, &index) != TCL_OK) { return TCL_ERROR; } switch ((enum sashOptions) index) { case SASH_COORD: if (objc != 4) { Tcl_WrongNumArgs(interp, 3, objv, "index"); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[3], &sash) != TCL_OK) { return TCL_ERROR; } if (!ValidSashIndex(pwPtr, sash)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid sash index", -1)); Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL); return TCL_ERROR; } slavePtr = pwPtr->slaves[sash]; coords[0] = Tcl_NewIntObj(slavePtr->sashx); coords[1] = Tcl_NewIntObj(slavePtr->sashy); Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords)); break; case SASH_MARK: if (objc != 6 && objc != 4) { Tcl_WrongNumArgs(interp, 3, objv, "index ?x y?"); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[3], &sash) != TCL_OK) { return TCL_ERROR; } if (!ValidSashIndex(pwPtr, sash)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid sash index", -1)); Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL); return TCL_ERROR; } if (objc == 6) { if (Tcl_GetIntFromObj(interp, objv[4], &x) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
1152 1153 1154 1155 1156 1157 1158 | } if (Tcl_GetIntFromObj(interp, objv[3], &sash) != TCL_OK) { return TCL_ERROR; } if (!ValidSashIndex(pwPtr, sash)) { | | | > | 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 | } if (Tcl_GetIntFromObj(interp, objv[3], &sash) != TCL_OK) { return TCL_ERROR; } if (!ValidSashIndex(pwPtr, sash)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid sash index", -1)); Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[4], &x) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
2394 2395 2396 2397 2398 2399 2400 | break; case 'w': case 'W': sticky |= STICK_WEST; break; case ' ': case ',': case '\t': case '\r': case '\n': break; default: | | | > | | | 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 | break; case 'w': case 'W': sticky |= STICK_WEST; break; case ' ': case ',': case '\t': case '\r': case '\n': break; default: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad stickyness value \"%s\": must be a string" " containing zero or more of n, e, s, and w", Tcl_GetString(*value))); Tcl_SetErrorCode(interp, "TK", "VALUE", "STICKY", NULL); return TCL_ERROR; } } } if (internalPtr != NULL) { *((int *) oldInternalPtr) = *((int *) internalPtr); |
︙ | ︙ | |||
2650 2651 2652 2653 2654 2655 2656 | * This function is invoked by the Tk dispatcher for various events on * paned window proxy windows. * * Results: * None. * * Side effects: | | | 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 | * This function is invoked by the Tk dispatcher for various events on * paned window proxy windows. * * Results: * None. * * Side effects: * When the window gets deleted, internal structures get cleaned up. When * it gets exposed, it is redisplayed. * *-------------------------------------------------------------- */ static void ProxyWindowEventProc( |
︙ | ︙ | |||
2954 2955 2956 2957 2958 2959 2960 | static int PanedWindowIdentifyCoords( PanedWindow *pwPtr, /* Information about the widget. */ Tcl_Interp *interp, /* Interpreter in which to store result. */ int x, int y) /* Coordinates of the point to identify. */ { | < < | 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 | static int PanedWindowIdentifyCoords( PanedWindow *pwPtr, /* Information about the widget. */ Tcl_Interp *interp, /* Interpreter in which to store result. */ int x, int y) /* Coordinates of the point to identify. */ { int i, sashHeight, sashWidth, thisx, thisy; int found, isHandle, lpad, rpad, tpad, bpad; if (pwPtr->orient == ORIENT_HORIZONTAL) { if (Tk_IsMapped(pwPtr->tkwin)) { sashHeight = Tk_Height(pwPtr->tkwin); } else { sashHeight = Tk_ReqHeight(pwPtr->tkwin); } |
︙ | ︙ | |||
3032 3033 3034 3035 3036 3037 3038 | } } break; } } /* | | > < | < | | > | > | 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 | } } break; } } /* * Set results. Note that the empty string is the default (this function * is called inside the implementation of a command). */ if (found != -1) { Tcl_Obj *list[2]; list[0] = Tcl_NewIntObj(found); list[1] = Tcl_NewStringObj((isHandle ? "handle" : "sash"), -1); Tcl_SetObjResult(interp, Tcl_NewListObj(2, list)); } return TCL_OK; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkPlace.c.
︙ | ︙ | |||
339 340 341 342 343 344 345 | } masterPtr = FindMaster(tkwin); if (masterPtr != NULL) { Tcl_Obj *listPtr = Tcl_NewObj(); for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; slavePtr = slavePtr->nextPtr) { | | | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | } masterPtr = FindMaster(tkwin); if (masterPtr != NULL) { Tcl_Obj *listPtr = Tcl_NewObj(); for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; slavePtr = slavePtr->nextPtr) { Tcl_ListObjAppendElement(NULL, listPtr, TkNewWindowObj(slavePtr->tkwin)); } Tcl_SetObjResult(interp, listPtr); } break; } } |
︙ | ︙ | |||
615 616 617 618 619 620 621 | register Master *masterPtr; Tk_SavedOptions savedOptions; int mask; Slave *slavePtr; Tk_Window masterWin = (Tk_Window) NULL; if (Tk_TopWinHierarchy(tkwin)) { | > | | > | 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | register Master *masterPtr; Tk_SavedOptions savedOptions; int mask; Slave *slavePtr; Tk_Window masterWin = (Tk_Window) NULL; if (Tk_TopWinHierarchy(tkwin)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't use placer on top-level window \"%s\"; use " "wm command instead", Tk_PathName(tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL); return TCL_ERROR; } slavePtr = CreateSlave(tkwin, table); if (Tk_SetOptions(interp, (char *) slavePtr, table, objc, objv, slavePtr->tkwin, &savedOptions, &mask) != TCL_OK) { |
︙ | ︙ | |||
648 649 650 651 652 653 654 | slavePtr->flags |= CHILD_REL_WIDTH; } if (slavePtr->widthPtr) { slavePtr->flags |= CHILD_WIDTH; } | | | 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | slavePtr->flags |= CHILD_REL_WIDTH; } if (slavePtr->widthPtr) { slavePtr->flags |= CHILD_WIDTH; } if (!(mask & IN_MASK) && (slavePtr->masterPtr != NULL)) { /* * If no -in option was passed and the slave is already placed then * just recompute the placement. */ masterPtr = slavePtr->masterPtr; goto scheduleLayout; |
︙ | ︙ | |||
674 675 676 677 678 679 680 | */ for (ancestor = tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == Tk_Parent(slavePtr->tkwin)) { break; } if (Tk_TopWinHierarchy(ancestor)) { | | > | | | > | | | 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 | */ for (ancestor = tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == Tk_Parent(slavePtr->tkwin)) { break; } if (Tk_TopWinHierarchy(ancestor)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't place %s relative to %s", Tk_PathName(slavePtr->tkwin), Tk_PathName(tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); goto error; } } if (slavePtr->tkwin == tkwin) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't place %s relative to itself", Tk_PathName(slavePtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL); goto error; } if ((slavePtr->masterPtr != NULL) && (slavePtr->masterPtr->tkwin == tkwin)) { /* * Re-using same old master. Nothing to do. */ |
︙ | ︙ | |||
767 768 769 770 771 772 773 | */ static int PlaceInfoCommand( Tcl_Interp *interp, /* Interp into which to place result. */ Tk_Window tkwin) /* Token for the window to get info on. */ { | < > > > | | > < | | < < < | < | < | > | < | | < | > | < | | | < | > | 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 | */ static int PlaceInfoCommand( Tcl_Interp *interp, /* Interp into which to place result. */ Tk_Window tkwin) /* Token for the window to get info on. */ { Slave *slavePtr; Tcl_Obj *infoObj; slavePtr = FindSlave(tkwin); if (slavePtr == NULL) { return TCL_OK; } infoObj = Tcl_NewObj(); if (slavePtr->masterPtr != NULL) { Tcl_AppendToObj(infoObj, "-in", -1); Tcl_ListObjAppendElement(NULL, infoObj, TkNewWindowObj(slavePtr->masterPtr->tkwin)); Tcl_AppendToObj(infoObj, " ", -1); } Tcl_AppendPrintfToObj(infoObj, "-x %d -relx %.4g -y %d -rely %.4g", slavePtr->x, slavePtr->relX, slavePtr->y, slavePtr->relY); if (slavePtr->flags & CHILD_WIDTH) { Tcl_AppendPrintfToObj(infoObj, " -width %d", slavePtr->width); } else { Tcl_AppendToObj(infoObj, " -width {}", -1); } if (slavePtr->flags & CHILD_REL_WIDTH) { Tcl_AppendPrintfToObj(infoObj, " -relwidth %.4g", slavePtr->relWidth); } else { Tcl_AppendToObj(infoObj, " -relwidth {}", -1); } if (slavePtr->flags & CHILD_HEIGHT) { Tcl_AppendPrintfToObj(infoObj, " -height %d", slavePtr->height); } else { Tcl_AppendToObj(infoObj, " -height {}", -1); } if (slavePtr->flags & CHILD_REL_HEIGHT) { Tcl_AppendPrintfToObj(infoObj, " -relheight %.4g", slavePtr->relHeight); } else { Tcl_AppendToObj(infoObj, " -relheight {}", -1); } Tcl_AppendPrintfToObj(infoObj, " -anchor %s -bordermode %s", Tk_NameOfAnchor(slavePtr->anchor), borderModeStrings[slavePtr->borderMode]); Tcl_SetObjResult(interp, infoObj); return TCL_OK; } /* *---------------------------------------------------------------------- * * RecomputePlacement -- |
︙ | ︙ | |||
1179 1180 1181 1182 1183 1184 1185 | PlaceRequestProc( ClientData clientData, /* Pointer to our record for slave. */ Tk_Window tkwin) /* Window that changed its desired size. */ { Slave *slavePtr = clientData; Master *masterPtr; | | | | 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 | PlaceRequestProc( ClientData clientData, /* Pointer to our record for slave. */ Tk_Window tkwin) /* Window that changed its desired size. */ { Slave *slavePtr = clientData; Master *masterPtr; if ((slavePtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH)) && (slavePtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT))) { return; } masterPtr = slavePtr->masterPtr; if (masterPtr == NULL) { return; } if (!(masterPtr->flags & PARENT_RECONFIG_PENDING)) { |
︙ | ︙ |
Changes to generic/tkPointer.c.
︙ | ︙ | |||
282 283 284 285 286 287 288 | /* * Mouse is not grabbed, so set a button grab. */ tsdPtr->restrictWinPtr = winPtr; TkpSetCapture(tsdPtr->restrictWinPtr); | | | 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | /* * Mouse is not grabbed, so set a button grab. */ tsdPtr->restrictWinPtr = winPtr; TkpSetCapture(tsdPtr->restrictWinPtr); } else if (!(tsdPtr->lastState & ALL_BUTTONS)) { /* * Mouse is in a non-button grab, so ensure the button * grab is inside the grab tree. */ if (TkPositionInTree(winPtr, tsdPtr->grabWinPtr) == TK_GRAB_IN_TREE) { |
︙ | ︙ |
Changes to generic/tkRectOval.c.
︙ | ︙ | |||
314 315 316 317 318 319 320 | RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; /* * If no coordinates, return the current coordinates (i.e. bounding box). */ if (objc == 0) { | | < | < | < | < | | < | | | > > | 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 | RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; /* * If no coordinates, return the current coordinates (i.e. bounding box). */ if (objc == 0) { Tcl_Obj *bbox[4]; bbox[0] = Tcl_NewDoubleObj(rectOvalPtr->bbox[0]); bbox[1] = Tcl_NewDoubleObj(rectOvalPtr->bbox[1]); bbox[2] = Tcl_NewDoubleObj(rectOvalPtr->bbox[2]); bbox[3] = Tcl_NewDoubleObj(rectOvalPtr->bbox[3]); Tcl_SetObjResult(interp, Tcl_NewListObj(4, bbox)); return TCL_OK; } /* * If one "coordinate", treat as list of coordinates. */ if (objc == 1) { if (Tcl_ListObjGetElements(interp, objv[0], &objc, (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; } } /* * Better have four coordinates now. Spit out an error message otherwise. */ if (objc != 4) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # coordinates: expected 0 or 4, got %d", objc)); Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", (rectOvalPtr->header.typePtr == &tkRectangleType ? "RECTANGLE" : "OVAL"), NULL); return TCL_ERROR; } /* * Parse the coordinates and update our bounding box. */ |
︙ | ︙ | |||
511 512 513 514 515 516 517 | gcValues.fill_style = FillStippled; mask = GCForeground|GCStipple|GCFillStyle; } else { mask = GCForeground; } #ifdef MAC_OSX_TK /* | | | > | 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | gcValues.fill_style = FillStippled; mask = GCForeground|GCStipple|GCFillStyle; } else { mask = GCForeground; } #ifdef MAC_OSX_TK /* * Mac OS X CG drawing needs access to the outline linewidth even for * fills (as linewidth controls antialiasing). */ gcValues.line_width = rectOvalPtr->outline.gc != None ? rectOvalPtr->outline.gc->line_width : 0; mask |= GCLineWidth; #endif newGC = Tk_GetGC(tkwin, mask, &gcValues); } if (rectOvalPtr->fillGC != None) { |
︙ | ︙ | |||
673 674 675 676 677 678 679 | * correct place to solve it, but it works. */ #ifdef __WIN32__ bloat = 1; #else bloat = 0; | | | | 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 | * correct place to solve it, but it works. */ #ifdef __WIN32__ bloat = 1; #else bloat = 0; #endif /* __WIN32__ */ } else { #ifdef MAC_OSX_TK /* * Mac OS X CoreGraphics needs correct rounding here otherwise it will * draw outside the bounding box. Probably correct on other platforms * as well? */ bloat = (int) (width+1.5)/2; #else bloat = (int) (width+1)/2; #endif /* MAC_OSX_TK */ } /* * Special note: the rectangle is always drawn at least 1x1 in size, so * round up the upper coordinates to be at least 1 unit greater than the * lower ones. */ |
︙ | ︙ | |||
753 754 755 756 757 758 759 | /* * Compute the screen coordinates of the bounding box for the item. Make * sure that the bbox is at least one pixel large, since some X servers * will die if it isn't. */ | | | | 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 | /* * Compute the screen coordinates of the bounding box for the item. Make * sure that the bbox is at least one pixel large, since some X servers * will die if it isn't. */ Tk_CanvasDrawableCoords(canvas, rectOvalPtr->bbox[0],rectOvalPtr->bbox[1], &x1, &y1); Tk_CanvasDrawableCoords(canvas, rectOvalPtr->bbox[2],rectOvalPtr->bbox[3], &x2, &y2); if (x2 <= x1) { x2 = x1+1; } if (y2 <= y1) { y2 = y1+1; } |
︙ | ︙ | |||
1289 1290 1291 1292 1293 1294 1295 | Tcl_Interp *interp, /* Interpreter for error reporting. */ Tk_Canvas canvas, /* Information about overall canvas. */ Tk_Item *itemPtr, /* Item for which Postscript is wanted. */ int prepass) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ { | | > > | > > > > | > > > > > | > | 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 | Tcl_Interp *interp, /* Interpreter for error reporting. */ Tk_Canvas canvas, /* Information about overall canvas. */ Tk_Item *itemPtr, /* Item for which Postscript is wanted. */ int prepass) /* 1 means this is a prepass to collect font * information; 0 means final Postscript is * being created. */ { Tcl_Obj *pathObj, *psObj; RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; double y1, y2; XColor *color; XColor *fillColor; Pixmap fillStipple; Tk_State state = itemPtr->state; Tcl_InterpState interpState; y1 = Tk_CanvasPsY(canvas, rectOvalPtr->bbox[1]); y2 = Tk_CanvasPsY(canvas, rectOvalPtr->bbox[3]); /* * Generate a string that creates a path for the rectangle or oval. This * is the only part of the function's code that is type-specific. */ if (rectOvalPtr->header.typePtr == &tkRectangleType) { pathObj = Tcl_ObjPrintf( "%.15g %.15g moveto " "%.15g 0 rlineto " "0 %.15g rlineto " "%.15g 0 rlineto " "closepath\n", rectOvalPtr->bbox[0], y1, rectOvalPtr->bbox[2]-rectOvalPtr->bbox[0], y2-y1, rectOvalPtr->bbox[0]-rectOvalPtr->bbox[2]); } else { pathObj = Tcl_ObjPrintf( "matrix currentmatrix\n" "%.15g %.15g translate " "%.15g %.15g scale " "1 0 moveto 0 0 1 0 360 arc\n" "setmatrix\n", (rectOvalPtr->bbox[0] + rectOvalPtr->bbox[2])/2, (y1 + y2)/2, (rectOvalPtr->bbox[2] - rectOvalPtr->bbox[0])/2, (y1 - y2)/2); } if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } |
︙ | ︙ | |||
1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 | fillColor = rectOvalPtr->disabledFillColor; } if (rectOvalPtr->disabledFillStipple!=None) { fillStipple = rectOvalPtr->disabledFillStipple; } } /* * First draw the filled area of the rectangle. */ if (fillColor != NULL) { | > > > > > > > > | > < > > > > | > < > > | | > | | > > > > > | > > > | > > > > > | > > > > | | 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 | fillColor = rectOvalPtr->disabledFillColor; } if (rectOvalPtr->disabledFillStipple!=None) { fillStipple = rectOvalPtr->disabledFillStipple; } } /* * Make our working space. */ psObj = Tcl_NewObj(); interpState = Tcl_SaveInterpState(interp, TCL_OK); /* * First draw the filled area of the rectangle. */ if (fillColor != NULL) { Tcl_AppendObjToObj(psObj, pathObj); Tcl_ResetResult(interp); if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (fillStipple != None) { Tcl_AppendToObj(psObj, "clip ", -1); Tcl_ResetResult(interp); if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); if (color != NULL) { Tcl_AppendToObj(psObj, "grestore gsave\n", -1); } } else { Tcl_AppendToObj(psObj, "fill\n", -1); } } /* * Now draw the outline, if there is one. */ if (color != NULL) { Tcl_AppendObjToObj(psObj, pathObj); Tcl_AppendToObj(psObj, "0 setlinejoin 2 setlinecap\n", -1); Tcl_ResetResult(interp); if (Tk_CanvasPsOutline(canvas, itemPtr, &rectOvalPtr->outline)!= TCL_OK) { goto error; } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); } /* * Plug the accumulated postscript back into the result. */ (void) Tcl_RestoreInterpState(interp, interpState); Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj); Tcl_DecrRefCount(psObj); Tcl_DecrRefCount(pathObj); return TCL_OK; error: Tcl_DiscardInterpState(interpState); Tcl_DecrRefCount(psObj); Tcl_DecrRefCount(pathObj); return TCL_ERROR; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkScale.c.
︙ | ︙ | |||
372 373 374 375 376 377 378 379 380 381 382 383 384 385 | } else { result = ConfigureScale(interp, scalePtr, objc-2, objv+2); } break; case COMMAND_COORDS: { int x, y; double value; if ((objc != 2) && (objc != 3)) { Tcl_WrongNumArgs(interp, 1, objv, "coords ?value?"); goto error; } if (objc == 3) { if (Tcl_GetDoubleFromObj(interp, objv[2], &value) != TCL_OK) { | > | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | } else { result = ConfigureScale(interp, scalePtr, objc-2, objv+2); } break; case COMMAND_COORDS: { int x, y; double value; Tcl_Obj *coords[2]; if ((objc != 2) && (objc != 3)) { Tcl_WrongNumArgs(interp, 1, objv, "coords ?value?"); goto error; } if (objc == 3) { if (Tcl_GetDoubleFromObj(interp, objv[2], &value) != TCL_OK) { |
︙ | ︙ | |||
393 394 395 396 397 398 399 | + scalePtr->borderWidth; y = TkScaleValueToPixel(scalePtr, value); } else { x = TkScaleValueToPixel(scalePtr, value); y = scalePtr->horizTroughY + scalePtr->width/2 + scalePtr->borderWidth; } | > > | | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | + scalePtr->borderWidth; y = TkScaleValueToPixel(scalePtr, value); } else { x = TkScaleValueToPixel(scalePtr, value); y = scalePtr->horizTroughY + scalePtr->width/2 + scalePtr->borderWidth; } coords[0] = Tcl_NewIntObj(x); coords[1] = Tcl_NewIntObj(y); Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords)); break; } case COMMAND_GET: { double value; int x, y; if ((objc != 2) && (objc != 4)) { |
︙ | ︙ | |||
417 418 419 420 421 422 423 | } value = TkScalePixelToValue(scalePtr, x, y); } Tcl_SetObjResult(interp, Tcl_ObjPrintf(scalePtr->format, value)); break; } case COMMAND_IDENTIFY: { | | > | < | < < | < < | < < > | 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 | } value = TkScalePixelToValue(scalePtr, x, y); } Tcl_SetObjResult(interp, Tcl_ObjPrintf(scalePtr->format, value)); break; } case COMMAND_IDENTIFY: { int x, y; const char *zone = ""; if (objc != 4) { Tcl_WrongNumArgs(interp, 1, objv, "identify x y"); goto error; } if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK)) { goto error; } switch (TkpScaleElement(scalePtr, x, y)) { case TROUGH1: zone = "trough1"; break; case SLIDER: zone = "slider"; break; case TROUGH2: zone = "trough2"; break; } Tcl_SetObjResult(interp, Tcl_NewStringObj(zone, -1)); break; } case COMMAND_SET: { double value; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "set value"); |
︙ | ︙ |
Changes to generic/tkScrollbar.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 21 | * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * * 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 "tkScrollbar.h" #include "default.h" /* * Custom option for handling "-orient" */ | > > > > | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * TODO: Convert scrollbars to the Tcl_Obj API. */ #include "tkInt.h" #include "tkScrollbar.h" #include "default.h" /* * Custom option for handling "-orient" */ |
︙ | ︙ | |||
128 129 130 131 132 133 134 | const char **argv) /* Argument strings. */ { Tk_Window tkwin = clientData; register TkScrollbar *scrollPtr; Tk_Window newWin; if (argc < 2) { | | | > > | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | const char **argv) /* Argument strings. */ { Tk_Window tkwin = clientData; register TkScrollbar *scrollPtr; Tk_Window newWin; if (argc < 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: should be \"%s pathName ?-option value ...?\"", argv[0])); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); return TCL_ERROR; } newWin = Tk_CreateWindowFromPath(interp, tkwin, argv[1], NULL); if (newWin == NULL) { return TCL_ERROR; } |
︙ | ︙ | |||
226 227 228 229 230 231 232 | { register TkScrollbar *scrollPtr = clientData; int result = TCL_OK; size_t length; int c; if (argc < 2) { | | | > > > > | < < | < < | < < > > | | > | | | | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | { register TkScrollbar *scrollPtr = clientData; int result = TCL_OK; size_t length; int c; if (argc < 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: should be \"%s option ?arg ...?\"", argv[0])); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); return TCL_ERROR; } Tcl_Preserve(scrollPtr); c = argv[1][0]; length = strlen(argv[1]); if ((c == 'a') && (strncmp(argv[1], "activate", length) == 0)) { int oldActiveField; if (argc == 2) { const char *zone = ""; switch (scrollPtr->activeField) { case TOP_ARROW: zone = "arrow1"; break; case SLIDER: zone = "slider"; break; case BOTTOM_ARROW: zone = "arrow2"; break; } Tcl_SetObjResult(interp, Tcl_NewStringObj(zone, -1)); goto done; } if (argc != 3) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: should be \"%s activate element\"", argv[0])); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); goto error; } c = argv[2][0]; length = strlen(argv[2]); oldActiveField = scrollPtr->activeField; if ((c == 'a') && (strcmp(argv[2], "arrow1") == 0)) { scrollPtr->activeField = TOP_ARROW; } else if ((c == 'a') && (strcmp(argv[2], "arrow2") == 0)) { scrollPtr->activeField = BOTTOM_ARROW; } else if ((c == 's') && (strncmp(argv[2], "slider", length) == 0)) { scrollPtr->activeField = SLIDER; } else { scrollPtr->activeField = OUTSIDE; } if (oldActiveField != scrollPtr->activeField) { TkScrollbarEventuallyRedraw(scrollPtr); } } else if ((c == 'c') && (strncmp(argv[1], "cget", length) == 0) && (length >= 2)) { if (argc != 3) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: should be \"%s cget option\"", argv[0])); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); goto error; } result = Tk_ConfigureValue(interp, scrollPtr->tkwin, configSpecs, (char *) scrollPtr, argv[2], 0); } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0) && (length >= 2)) { if (argc == 2) { |
︙ | ︙ | |||
296 297 298 299 300 301 302 | TK_CONFIG_ARGV_ONLY); } } else if ((c == 'd') && (strncmp(argv[1], "delta", length) == 0)) { int xDelta, yDelta, pixels, length; double fraction; if (argc != 4) { | > | | > | 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | TK_CONFIG_ARGV_ONLY); } } else if ((c == 'd') && (strncmp(argv[1], "delta", length) == 0)) { int xDelta, yDelta, pixels, length; double fraction; if (argc != 4) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: should be \"%s delta xDelta yDelta\"", argv[0])); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); goto error; } if ((Tcl_GetInt(interp, argv[2], &xDelta) != TCL_OK) || (Tcl_GetInt(interp, argv[3], &yDelta) != TCL_OK)) { goto error; } if (scrollPtr->vertical) { |
︙ | ︙ | |||
324 325 326 327 328 329 330 | } Tcl_SetObjResult(interp, Tcl_NewDoubleObj(fraction)); } else if ((c == 'f') && (strncmp(argv[1], "fraction", length) == 0)) { int x, y, pos, length; double fraction; if (argc != 4) { | | | > | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | } Tcl_SetObjResult(interp, Tcl_NewDoubleObj(fraction)); } else if ((c == 'f') && (strncmp(argv[1], "fraction", length) == 0)) { int x, y, pos, length; double fraction; if (argc != 4) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: should be \"%s fraction x y\"", argv[0])); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); goto error; } if ((Tcl_GetInt(interp, argv[2], &x) != TCL_OK) || (Tcl_GetInt(interp, argv[3], &y) != TCL_OK)) { goto error; } if (scrollPtr->vertical) { |
︙ | ︙ | |||
353 354 355 356 357 358 359 360 | if (fraction < 0) { fraction = 0; } else if (fraction > 1.0) { fraction = 1.0; } Tcl_SetObjResult(interp, Tcl_NewDoubleObj(fraction)); } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) { if (argc != 2) { | > > > | | < < < < | > | | > | < | < < | < < | < < | < < | < < > | 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 | if (fraction < 0) { fraction = 0; } else if (fraction > 1.0) { fraction = 1.0; } Tcl_SetObjResult(interp, Tcl_NewDoubleObj(fraction)); } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) { Tcl_Obj *resObjs[4]; if (argc != 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: should be \"%s get\"", argv[0])); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); goto error; } if (scrollPtr->flags & NEW_STYLE_COMMANDS) { resObjs[0] = Tcl_NewDoubleObj(scrollPtr->firstFraction); resObjs[1] = Tcl_NewDoubleObj(scrollPtr->lastFraction); Tcl_SetObjResult(interp, Tcl_NewListObj(2, resObjs)); } else { resObjs[0] = Tcl_NewIntObj(scrollPtr->totalUnits); resObjs[1] = Tcl_NewIntObj(scrollPtr->windowUnits); resObjs[2] = Tcl_NewIntObj(scrollPtr->firstUnit); resObjs[3] = Tcl_NewIntObj(scrollPtr->lastUnit); Tcl_SetObjResult(interp, Tcl_NewListObj(4, resObjs)); } } else if ((c == 'i') && (strncmp(argv[1], "identify", length) == 0)) { int x, y; const char *zone = ""; if (argc != 4) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: should be \"%s identify x y\"", argv[0])); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); goto error; } if ((Tcl_GetInt(interp, argv[2], &x) != TCL_OK) || (Tcl_GetInt(interp, argv[3], &y) != TCL_OK)) { goto error; } switch (TkpScrollbarPosition(scrollPtr, x, y)) { case TOP_ARROW: zone = "arrow1"; break; case TOP_GAP: zone = "trough1"; break; case SLIDER: zone = "slider"; break; case BOTTOM_GAP: zone = "trough2"; break; case BOTTOM_ARROW: zone = "arrow2"; break; } Tcl_SetObjResult(interp, Tcl_NewStringObj(zone, -1)); } else if ((c == 's') && (strncmp(argv[1], "set", length) == 0)) { int totalUnits, windowUnits, firstUnit, lastUnit; if (argc == 4) { double first, last; if (Tcl_GetDouble(interp, argv[2], &first) != TCL_OK) { |
︙ | ︙ | |||
469 470 471 472 473 474 475 | scrollPtr->lastFraction = 1.0; } else { scrollPtr->firstFraction = ((double) firstUnit)/totalUnits; scrollPtr->lastFraction = ((double) (lastUnit+1))/totalUnits; } scrollPtr->flags &= ~NEW_STYLE_COMMANDS; } else { | > | | > | | | | | > > | 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 | scrollPtr->lastFraction = 1.0; } else { scrollPtr->firstFraction = ((double) firstUnit)/totalUnits; scrollPtr->lastFraction = ((double) (lastUnit+1))/totalUnits; } scrollPtr->flags &= ~NEW_STYLE_COMMANDS; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: should be " "\"%s set firstFraction lastFraction\" or " "\"%s set totalUnits windowUnits firstUnit lastUnit\"", argv[0], argv[0])); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); goto error; } TkpComputeScrollbarGeometry(scrollPtr); TkScrollbarEventuallyRedraw(scrollPtr); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad option \"%s\": must be activate, cget, configure," " delta, fraction, get, identify, or set", argv[1])); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "option", argv[1], NULL); goto error; } done: Tcl_Release(scrollPtr); return result; |
︙ | ︙ | |||
534 535 536 537 538 539 540 | /* * A few options need special processing, such as setting the background * from a 3-D border. */ if (scrollPtr->command != NULL) { | | | 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | /* * A few options need special processing, such as setting the background * from a 3-D border. */ if (scrollPtr->command != NULL) { scrollPtr->commandSize = (int) strlen(scrollPtr->command); } else { scrollPtr->commandSize = 0; } /* * Configure platform specific options. */ |
︙ | ︙ | |||
598 599 600 601 602 603 604 | Tcl_CancelIdleCall(TkpDisplayScrollbar, scrollPtr); } /* * Free up all the stuff that requires special handling, then let * Tk_FreeOptions handle all the standard option-related stuff. */ | | < | 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 | Tcl_CancelIdleCall(TkpDisplayScrollbar, scrollPtr); } /* * Free up all the stuff that requires special handling, then let * Tk_FreeOptions handle all the standard option-related stuff. */ Tk_FreeOptions(configSpecs, (char*) scrollPtr, scrollPtr->display, 0); Tcl_EventuallyFree(scrollPtr, TCL_DYNAMIC); } else if (eventPtr->type == ConfigureNotify) { TkpComputeScrollbarGeometry(scrollPtr); TkScrollbarEventuallyRedraw(scrollPtr); } else if (eventPtr->type == FocusIn) { if (eventPtr->xfocus.detail != NotifyInferior) { scrollPtr->flags |= GOT_FOCUS; |
︙ | ︙ | |||
679 680 681 682 683 684 685 | *-------------------------------------------------------------- */ void TkScrollbarEventuallyRedraw( TkScrollbar *scrollPtr) /* Information about widget. */ { | | | | 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | *-------------------------------------------------------------- */ void TkScrollbarEventuallyRedraw( TkScrollbar *scrollPtr) /* Information about widget. */ { if ((scrollPtr->tkwin == NULL) || !Tk_IsMapped(scrollPtr->tkwin)) { return; } if (!(scrollPtr->flags & REDRAW_PENDING)) { Tcl_DoWhenIdle(TkpDisplayScrollbar, scrollPtr); scrollPtr->flags |= REDRAW_PENDING; } } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkSelect.c.
︙ | ︙ | |||
634 635 636 637 638 639 640 | * The selection is owned by some other process. */ return TkSelGetSelection(interp, tkwin, selection, target, proc, clientData); cantget: | | | > | | 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | * The selection is owned by some other process. */ return TkSelGetSelection(interp, tkwin, selection, target, proc, clientData); cantget: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s selection doesn't exist or form \"%s\" not defined", Tk_GetAtomName(tkwin, selection), Tk_GetAtomName(tkwin, target))); return TCL_ERROR; } /* *-------------------------------------------------------------- * * Tk_SelectionObjCmd -- |
︙ | ︙ | |||
704 705 706 707 708 709 710 | for (count = objc-2, objs = ((Tcl_Obj **)objv)+2; count > 0; count-=2, objs+=2) { string = Tcl_GetString(objs[0]); if (string[0] != '-') { break; } if (count < 2) { | | | > | 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | for (count = objc-2, objs = ((Tcl_Obj **)objv)+2; count > 0; count-=2, objs+=2) { string = Tcl_GetString(objs[0]); if (string[0] != '-') { break; } if (count < 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", string)); Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objs[0], clearOptionStrings, "option", 0, &clearIndex) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
763 764 765 766 767 768 769 | for (count = objc-2, objs = ((Tcl_Obj **)objv)+2; count>0; count-=2, objs+=2) { string = Tcl_GetString(objs[0]); if (string[0] != '-') { break; } if (count < 2) { | | | > | 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 | for (count = objc-2, objs = ((Tcl_Obj **)objv)+2; count>0; count-=2, objs+=2) { string = Tcl_GetString(objs[0]); if (string[0] != '-') { break; } if (count < 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", string)); Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objs[0], getOptionStrings, "option", 0, &getIndex) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
840 841 842 843 844 845 846 | for (count = objc-2, objs = ((Tcl_Obj **)objv)+2; count > 0; count-=2, objs+=2) { string = Tcl_GetString(objs[0]); if (string[0] != '-') { break; } if (count < 2) { | | | > | 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 | for (count = objc-2, objs = ((Tcl_Obj **)objv)+2; count > 0; count-=2, objs+=2) { string = Tcl_GetString(objs[0]); if (string[0] != '-') { break; } if (count < 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", string)); Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objs[0],handleOptionStrings, "option", 0, &handleIndex) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
864 865 866 867 868 869 870 | case HANDLE_TYPE: targetName = Tcl_GetString(objs[1]); break; } } if ((count < 2) || (count > 4)) { | | > | 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 | case HANDLE_TYPE: targetName = Tcl_GetString(objs[1]); break; } } if ((count < 2) || (count > 4)) { Tcl_WrongNumArgs(interp, 2, objv, "?-option value ...? window command"); return TCL_ERROR; } tkwin = Tk_NameToWindow(interp, Tcl_GetString(objs[0]), tkwin); if (tkwin == NULL) { return TCL_ERROR; } if (selName != NULL) { |
︙ | ︙ | |||
925 926 927 928 929 930 931 | for (count = objc-2, objs = ((Tcl_Obj **)objv)+2; count > 0; count-=2, objs+=2) { string = Tcl_GetString(objs[0]); if (string[0] != '-') { break; } if (count < 2) { | | | > | 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 | for (count = objc-2, objs = ((Tcl_Obj **)objv)+2; count > 0; count-=2, objs+=2) { string = Tcl_GetString(objs[0]); if (string[0] != '-') { break; } if (count < 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", string)); Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objs[0], ownOptionStrings, "option", 0, &ownIndex) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
968 969 970 971 972 973 974 | if (path != NULL) { tkwin = Tk_NameToWindow(interp, path, tkwin); } if (tkwin == NULL) { return TCL_ERROR; } | | | | 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 | if (path != NULL) { tkwin = Tk_NameToWindow(interp, path, tkwin); } if (tkwin == NULL) { return TCL_ERROR; } winPtr = (TkWindow *) tkwin; for (infoPtr = winPtr->dispPtr->selectionInfoPtr; infoPtr != NULL; infoPtr = infoPtr->nextPtr) { if (infoPtr->selection == selection) { break; } } /* * Ignore the internal clipboard window. */ if ((infoPtr != NULL) && (infoPtr->owner != winPtr->dispPtr->clipWindow)) { Tcl_SetObjResult(interp, TkNewWindowObj(infoPtr->owner)); } return TCL_OK; } tkwin = Tk_NameToWindow(interp, Tcl_GetString(objs[0]), tkwin); if (tkwin == NULL) { return TCL_ERROR; |
︙ | ︙ | |||
1281 1282 1283 1284 1285 1286 1287 | /* ARGSUSED */ static int SelGetProc( ClientData clientData, /* Dynamic string holding partially assembled * selection. */ Tcl_Interp *interp, /* Interpreter used for error reporting (not * used). */ | | | 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 | /* ARGSUSED */ static int SelGetProc( ClientData clientData, /* Dynamic string holding partially assembled * selection. */ Tcl_Interp *interp, /* Interpreter used for error reporting (not * used). */ const char *portion) /* New information to be appended. */ { Tcl_DStringAppend(clientData, portion, -1); return TCL_OK; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
1316 1317 1318 1319 1320 1321 1322 | ClientData clientData, /* Information about command to execute. */ int offset, /* Return selection bytes starting at this * offset. */ char *buffer, /* Place to store converted selection. */ int maxBytes) /* Maximum # of bytes to store at buffer. */ { CommandInfo *cmdInfoPtr = clientData; | | < < | | | 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 | ClientData clientData, /* Information about command to execute. */ int offset, /* Return selection bytes starting at this * offset. */ char *buffer, /* Place to store converted selection. */ int maxBytes) /* Maximum # of bytes to store at buffer. */ { CommandInfo *cmdInfoPtr = clientData; int length; Tcl_Obj *command; const char *string; Tcl_Interp *interp = cmdInfoPtr->interp; Tcl_InterpState savedState; int extraBytes, charOffset, count, numChars, code; const char *p; /* * We must also protect the interpreter and the command from being deleted * too soon. */ |
︙ | ︙ | |||
1359 1360 1361 1362 1363 1364 1365 | } /* * First, generate a command by taking the command string and appending * the offset and maximum # of bytes. */ | < < | < < < | > < | | > > > > > | 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 | } /* * First, generate a command by taking the command string and appending * the offset and maximum # of bytes. */ command = Tcl_ObjPrintf("%s %d %d", cmdInfoPtr->command, charOffset, maxBytes); Tcl_IncrRefCount(command); /* * Execute the command. Be sure to restore the state of the interpreter * after executing the command. */ savedState = Tcl_SaveInterpState(interp, TCL_OK); code = Tcl_EvalObjEx(interp, command, TCL_EVAL_GLOBAL); Tcl_DecrRefCount(command); if (code == TCL_OK) { /* * TODO: This assumes that bytes are characters; that's not true! */ string = Tcl_GetStringFromObj(Tcl_GetObjResult(interp), &length); count = (length > maxBytes) ? maxBytes : length; memcpy(buffer, string, (size_t) count); buffer[count] = '\0'; /* * Update the partial character information for the next retrieval if |
︙ | ︙ | |||
1420 1421 1422 1423 1424 1425 1426 | if (code == TCL_ERROR) { Tcl_AddErrorInfo(interp, "\n (command handling selection)"); Tcl_BackgroundException(interp, code); } count = -1; } | < | < < < | 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 | if (code == TCL_ERROR) { Tcl_AddErrorInfo(interp, "\n (command handling selection)"); Tcl_BackgroundException(interp, code); } count = -1; } (void) Tcl_RestoreInterpState(interp, savedState); Tcl_Release(clientData); Tcl_Release(interp); return count; } /* |
︙ | ︙ | |||
1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 | for (selPtr = winPtr->selHandlerList; selPtr != NULL; selPtr = selPtr->nextPtr) { if ((selPtr->selection == infoPtr->selection) && (selPtr->target != dispPtr->applicationAtom) && (selPtr->target != dispPtr->windowAtom)) { const char *atomString = Tk_GetAtomName((Tk_Window) winPtr, selPtr->target); Tcl_DStringAppendElement(&ds, atomString); } } length = Tcl_DStringLength(&ds); if (length >= maxBytes) { Tcl_DStringFree(&ds); return -1; | > | 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 | for (selPtr = winPtr->selHandlerList; selPtr != NULL; selPtr = selPtr->nextPtr) { if ((selPtr->selection == infoPtr->selection) && (selPtr->target != dispPtr->applicationAtom) && (selPtr->target != dispPtr->windowAtom)) { const char *atomString = Tk_GetAtomName((Tk_Window) winPtr, selPtr->target); Tcl_DStringAppendElement(&ds, atomString); } } length = Tcl_DStringLength(&ds); if (length >= maxBytes) { Tcl_DStringFree(&ds); return -1; |
︙ | ︙ | |||
1560 1561 1562 1563 1564 1565 1566 | */ static void LostSelection( ClientData clientData) /* Pointer to LostCommand structure. */ { LostCommand *lostPtr = clientData; | < | > < | < < | < < < < > | 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 | */ static void LostSelection( ClientData clientData) /* Pointer to LostCommand structure. */ { LostCommand *lostPtr = clientData; Tcl_Interp *interp = lostPtr->interp; Tcl_InterpState savedState; int code; Tcl_Preserve(interp); /* * Execute the command. Save the interpreter's result, if any, and restore * it after executing the command. */ savedState = Tcl_SaveInterpState(interp, TCL_OK); Tcl_ResetResult(interp); code = Tcl_EvalObjEx(interp, lostPtr->cmdObj, TCL_EVAL_GLOBAL); if (code != TCL_OK) { Tcl_BackgroundException(interp, code); } (void) Tcl_RestoreInterpState(interp, savedState); /* * Free the storage for the command, since we're done with it now. */ Tcl_DecrRefCount(lostPtr->cmdObj); ckfree(lostPtr); Tcl_Release(interp); } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkStubInit.c.
︙ | ︙ | |||
51 52 53 54 55 56 57 | { /* dummy implementation, no need to do anything */ } void TkCreateXEventSource(void) { | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | { /* dummy implementation, no need to do anything */ } void TkCreateXEventSource(void) { TkWinXInit(Tk_GetHINSTANCE()); } # define TkUnixContainerId 0 # define TkUnixDoOneXEvent 0 # define TkUnixSetMenubar 0 # define TkWmCleanup (void (*)(TkDisplay *)) TkpSync # define TkSendCleanup (void (*)(TkDisplay *)) TkpSync |
︙ | ︙ | |||
101 102 103 104 105 106 107 | void TkpPrintWindowId( char *buf, /* Pointer to string large enough to hold * the hex representation of a pointer. */ Window window) /* Window to be printed into buffer. */ { | | | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | void TkpPrintWindowId( char *buf, /* Pointer to string large enough to hold * the hex representation of a pointer. */ Window window) /* Window to be printed into buffer. */ { sprintf(buf, "%#08lx", (unsigned long) (window)); } int TkPutImage( unsigned long *colors, /* Array of pixel values used by this image. * May be NULL. */ int ncolors, /* Number of colors used, or 0. */ |
︙ | ︙ |
Changes to generic/tkStubLib.c.
︙ | ︙ | |||
120 121 122 123 124 125 126 | if (actualVersion == NULL) { return NULL; } } } if (!stubsPtr) { | | | < | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | if (actualVersion == NULL) { return NULL; } } } if (!stubsPtr) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "this implementation of Tk does not support stubs", -1)); return NULL; } tkPlatStubsPtr = stubsPtr->hooks->tkPlatStubs; tkIntStubsPtr = stubsPtr->hooks->tkIntStubs; tkIntPlatStubsPtr = stubsPtr->hooks->tkIntPlatStubs; tkIntXlibStubsPtr = stubsPtr->hooks->tkIntXlibStubs; |
︙ | ︙ |
Changes to generic/tkStyle.c.
︙ | ︙ | |||
1352 1353 1354 1355 1356 1357 1358 | /* * Search for a corresponding entry in the style table. */ entryPtr = Tcl_FindHashEntry(&tsdPtr->styleTable, (name!=NULL?name:"")); if (entryPtr == NULL) { if (interp != NULL) { | > | | | 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 | /* * Search for a corresponding entry in the style table. */ entryPtr = Tcl_FindHashEntry(&tsdPtr->styleTable, (name!=NULL?name:"")); if (entryPtr == NULL) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "style \"%s\" doesn't exist", name)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "STYLE", name, NULL); } return (Tk_Style) NULL; } stylePtr = Tcl_GetHashValue(entryPtr); return (Tk_Style) stylePtr; } |
︙ | ︙ |
Changes to generic/tkText.c.
︙ | ︙ | |||
756 757 758 759 760 761 762 763 764 765 | if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "option"); result = TCL_ERROR; goto done; } else { Tcl_Obj *objPtr = Tk_GetOptionValue(interp, (char *) textPtr, textPtr->optionTable, objv[2], textPtr->tkwin); if (objPtr == NULL) { result = TCL_ERROR; goto done; | > < > | | < | 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 | if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "option"); result = TCL_ERROR; goto done; } else { Tcl_Obj *objPtr = Tk_GetOptionValue(interp, (char *) textPtr, textPtr->optionTable, objv[2], textPtr->tkwin); if (objPtr == NULL) { result = TCL_ERROR; goto done; } Tcl_SetObjResult(interp, objPtr); result = TCL_OK; } break; case TEXT_COMPARE: { int relation, value; const char *p; const TkTextIndex *index1Ptr, *index2Ptr; |
︙ | ︙ | |||
788 789 790 791 792 793 794 | relation = TkTextIndexCmp(index1Ptr, index2Ptr); p = Tcl_GetString(objv[3]); if (p[0] == '<') { value = (relation < 0); if ((p[1] == '=') && (p[2] == 0)) { value = (relation <= 0); } else if (p[1] != 0) { | | < < < < < > > > > > > > > > < < > | > | 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 | relation = TkTextIndexCmp(index1Ptr, index2Ptr); p = Tcl_GetString(objv[3]); if (p[0] == '<') { value = (relation < 0); if ((p[1] == '=') && (p[2] == 0)) { value = (relation <= 0); } else if (p[1] != 0) { goto compareError; } } else if (p[0] == '>') { value = (relation > 0); if ((p[1] == '=') && (p[2] == 0)) { value = (relation >= 0); } else if (p[1] != 0) { goto compareError; } } else if ((p[0] == '=') && (p[1] == '=') && (p[2] == 0)) { value = (relation == 0); } else if ((p[0] == '!') && (p[1] == '=') && (p[2] == 0)) { value = (relation != 0); } else { goto compareError; } Tcl_SetObjResult(interp, Tcl_NewBooleanObj(value)); break; compareError: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad comparison operator \"%s\": must be" " <, <=, ==, >=, >, or !=", Tcl_GetString(objv[3]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "COMPARISON", NULL); result = TCL_ERROR; goto done; } case TEXT_CONFIGURE: if (objc <= 3) { Tcl_Obj *objPtr = Tk_GetOptionInfo(interp, (char *) textPtr, textPtr->optionTable, ((objc == 3) ? objv[2] : NULL), textPtr->tkwin); if (objPtr == NULL) { result = TCL_ERROR; goto done; } Tcl_SetObjResult(interp, objPtr); } else { result = ConfigureText(interp, textPtr, objc-2, objv+2); } break; case TEXT_COUNT: { const TkTextIndex *indexFromPtr, *indexToPtr; int i, found = 0, update = 0; Tcl_Obj *objPtr = NULL; if (objc < 4) { Tcl_WrongNumArgs(interp, 2, objv, "?-option value ...? index1 index2"); result = TCL_ERROR; goto done; } indexFromPtr = TkTextGetIndexFromObj(interp, textPtr, objv[objc-2]); if (indexFromPtr == NULL) { result = TCL_ERROR; |
︙ | ︙ | |||
855 856 857 858 859 860 861 | for (i = 2; i < objc-2; i++) { int value, length; const char *option = Tcl_GetStringFromObj(objv[i], &length); char c; if (length < 2 || option[0] != '-') { | | < < < < < < < < | 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 | for (i = 2; i < objc-2; i++) { int value, 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, (unsigned) length)) { value = CountIndices(textPtr, indexFromPtr, indexToPtr, COUNT_CHARS); } else if (c == 'd' && (length > 8) && !strncmp("-displaychars", option, (unsigned) length)) { |
︙ | ︙ | |||
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 | COUNT_INDICES); Tcl_SetObjResult(interp, Tcl_NewIntObj(value)); } else if (found > 1) { Tcl_SetObjResult(interp, objPtr); } break; } case TEXT_DEBUG: if (objc > 3) { Tcl_WrongNumArgs(interp, 2, objv, "boolean"); result = TCL_ERROR; goto done; } | > > > > > > > > > | 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 | COUNT_INDICES); Tcl_SetObjResult(interp, Tcl_NewIntObj(value)); } else if (found > 1) { Tcl_SetObjResult(interp, objPtr); } break; badOption: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad option \"%s\" must be -chars, -displaychars, " "-displayindices, -displaylines, -indices, -lines, -update, " "-xpixels, or -ypixels", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "TEXT", "INDEX_OPTION", NULL); result = TCL_ERROR; goto done; } case TEXT_DEBUG: if (objc > 3) { Tcl_WrongNumArgs(interp, 2, objv, "boolean"); result = TCL_ERROR; goto done; } |
︙ | ︙ | |||
1253 1254 1255 1256 1257 1258 1259 | * -displaychars (or any unique prefix). */ i = 2; if (objc > 3) { name = Tcl_GetStringFromObj(objv[i], &length); if (length > 1 && name[0] == '-') { | | | 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 | * -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, (unsigned) length) == 0) { i++; visible = 1; name = Tcl_GetStringFromObj(objv[i], &length); } if ((i < objc-1) && (length == 2) && !strcmp("--", name)) { i++; } |
︙ | ︙ | |||
1391 1392 1393 1394 1395 1396 1397 | } indexToPtr = TkTextGetIndexFromObj(interp, textPtr, objv[3]); if (indexToPtr == NULL) { result = TCL_ERROR; goto done; } if (TkTextIndexCmp(indexFromPtr, indexToPtr) > 0) { | | > | | | 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 | } indexToPtr = TkTextGetIndexFromObj(interp, textPtr, objv[3]); if (indexToPtr == NULL) { result = TCL_ERROR; goto done; } if (TkTextIndexCmp(indexFromPtr, indexToPtr) > 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "index \"%s\" before \"%s\" in the text", Tcl_GetString(objv[3]), Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TK", "TEXT", "INDEX_ORDER", NULL); result = TCL_ERROR; goto done; } if (textPtr->state == TK_TEXT_STATE_NORMAL) { int lineNum, byteIndex; TkTextIndex index; |
︙ | ︙ | |||
1659 1660 1661 1662 1663 1664 1665 | } if (Tcl_GetIndexFromObj(interp, objv[2], peerOptionStrings, "peer option", 0, &index) != TCL_OK) { return TCL_ERROR; } | | > > > | > | 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 | } if (Tcl_GetIndexFromObj(interp, objv[2], peerOptionStrings, "peer option", 0, &index) != TCL_OK) { return TCL_ERROR; } switch ((enum peerOptions) index) { case PEER_CREATE: if (objc < 4) { Tcl_WrongNumArgs(interp, 3, objv, "pathName ?-option value ...?"); return TCL_ERROR; } return CreateWidget(textPtr->sharedTextPtr, tkwin, interp, textPtr, objc-2, objv+2); case PEER_NAMES: { TkText *tPtr = textPtr->sharedTextPtr->peers; Tcl_Obj *peersObj; if (objc > 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } peersObj = Tcl_NewObj(); while (tPtr != NULL) { if (tPtr != textPtr) { Tcl_ListObjAppendElement(NULL, peersObj, TkNewWindowObj(tPtr->tkwin)); } tPtr = tPtr->next; } Tcl_SetObjResult(interp, peersObj); } } return TCL_OK; } /* |
︙ | ︙ | |||
2050 2051 2052 2053 2054 2055 2056 | } if (textPtr->end != NULL) { end = TkBTreeLinesTo(NULL, textPtr->end); } else { end = TkBTreeNumLines(textPtr->sharedTextPtr->tree, NULL); } if (start > end) { | | | | | 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 | } if (textPtr->end != NULL) { end = TkBTreeLinesTo(NULL, textPtr->end); } else { end = TkBTreeNumLines(textPtr->sharedTextPtr->tree, NULL); } if (start > end) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "-startline must be less than or equal to -endline", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "INDEX_ORDER", NULL); Tk_RestoreSavedOptions(&savedOptions); return TCL_ERROR; } current = TkBTreeLinesTo(NULL, textPtr->topIndex.linePtr); TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, start, 0, &index1); TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, end, 0, |
︙ | ︙ | |||
2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 | 0, &last); TkBTreeStartSearch(&first, &last, textPtr->selTagPtr, &search); if (!TkBTreeCharTagged(&first, textPtr->selTagPtr) && !TkBTreeNextTag(&search)) { /* Nothing tagged with "sel" */ } else { int line = TkBTreeLinesTo(NULL, search.curIndex.linePtr); if (line < start) { selChanged = 1; } else { TkTextLine *linePtr = search.curIndex.linePtr; while (TkBTreeNextTag(&search)) { linePtr = search.curIndex.linePtr; | > | 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 | 0, &last); TkBTreeStartSearch(&first, &last, textPtr->selTagPtr, &search); if (!TkBTreeCharTagged(&first, textPtr->selTagPtr) && !TkBTreeNextTag(&search)) { /* Nothing tagged with "sel" */ } else { int line = TkBTreeLinesTo(NULL, search.curIndex.linePtr); if (line < start) { selChanged = 1; } else { TkTextLine *linePtr = search.curIndex.linePtr; while (TkBTreeNextTag(&search)) { linePtr = search.curIndex.linePtr; |
︙ | ︙ | |||
3653 3654 3655 3656 3657 3658 3659 3660 | int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { int i, argsLeft, code; SearchSpec searchSpec; static const char *const switchStrings[] = { "--", "-all", "-backwards", "-count", "-elide", "-exact", "-forwards", | > | < > | | 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 | int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { int i, argsLeft, code; SearchSpec searchSpec; static const char *const switchStrings[] = { "-hidden", "--", "-all", "-backwards", "-count", "-elide", "-exact", "-forwards", "-nocase", "-nolinestop", "-overlap", "-regexp", "-strictlimits", NULL }; enum SearchSwitches { SEARCH_HIDDEN, SEARCH_END, SEARCH_ALL, SEARCH_BACK, SEARCH_COUNT, SEARCH_ELIDE, SEARCH_EXACT, SEARCH_FWD, SEARCH_NOCASE, SEARCH_NOLINESTOP, SEARCH_OVERLAP, SEARCH_REGEXP, SEARCH_STRICTLIMITS }; /* * Set up the search specification, including the last 4 fields which are * text widget specific. */ |
︙ | ︙ | |||
3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 | /* * Parse switches and other arguments. */ for (i=2 ; i<objc ; i++) { int index; if (Tcl_GetString(objv[i])[0] != '-') { break; } | > | | > | | < < < > | < > | 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 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 3743 3744 3745 3746 3747 3748 3749 | /* * Parse switches and other arguments. */ for (i=2 ; i<objc ; i++) { int index; if (Tcl_GetString(objv[i])[0] != '-') { break; } if (Tcl_GetIndexFromObj(NULL, objv[i], switchStrings, "switch", 0, &index) != TCL_OK) { /* * Hide the -hidden option, generating the error description with * the side effects of T_GIFO. */ (void) Tcl_GetIndexFromObj(interp, objv[i], switchStrings+1, "switch", 0, &index); return TCL_ERROR; } switch ((enum SearchSwitches) index) { case SEARCH_END: i++; goto endOfSwitchProcessing; case SEARCH_ALL: searchSpec.all = 1; break; case SEARCH_BACK: searchSpec.backwards = 1; break; case SEARCH_COUNT: if (i >= objc-1) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "no value given for \"-count\" option", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "VALUE", NULL); return TCL_ERROR; } i++; /* * Assumption objv[i] isn't going to disappear on us during this * function, which is fair. |
︙ | ︙ | |||
3774 3775 3776 3777 3778 3779 3780 | if ((argsLeft != 0) && (argsLeft != 1)) { Tcl_WrongNumArgs(interp, 2, objv, "?switches? pattern index ?stopIndex?"); return TCL_ERROR; } if (searchSpec.noLineStop && searchSpec.exact) { | > | | > > | | > | 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 | if ((argsLeft != 0) && (argsLeft != 1)) { Tcl_WrongNumArgs(interp, 2, objv, "?switches? pattern index ?stopIndex?"); return TCL_ERROR; } if (searchSpec.noLineStop && searchSpec.exact) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "the \"-nolinestop\" option requires the \"-regexp\" option" " to be present", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "SEARCH_USAGE", NULL); return TCL_ERROR; } if (searchSpec.overlap && !searchSpec.all) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "the \"-overlap\" option requires the \"-all\" option" " to be present", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "SEARCH_USAGE", NULL); return TCL_ERROR; } /* * Scan through all of the lines of the text circularly, starting at the * given index. 'objv[i]' is the pattern which may be an exact string or a * regexp pattern depending on the flags set above. |
︙ | ︙ | |||
4398 4399 4400 4401 4402 4403 4404 | if (Tk_GetPixelsFromObj(interp, textPtr->tkwin, objv[i], &tabPtr->location) != TCL_OK) { goto error; } if (tabPtr->location <= 0) { | | | > > | 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 | if (Tk_GetPixelsFromObj(interp, textPtr->tkwin, objv[i], &tabPtr->location) != TCL_OK) { goto error; } if (tabPtr->location <= 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "tab stop \"%s\" is not at a positive distance", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "TAB_STOP", NULL); goto error; } prevStop = lastStop; if (Tk_GetDoublePixelsFromObj(interp, textPtr->tkwin, objv[i], &lastStop) != TCL_OK) { goto error; |
︙ | ︙ | |||
4429 4430 4431 4432 4433 4434 4435 | if (textPtr->charWidth > 0) { tabPtr->location = (tabPtr-1)->location + textPtr->charWidth; } else { tabPtr->location = (tabPtr-1)->location + 8; } lastStop = tabPtr->location; #else | | | > | < | | 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 | if (textPtr->charWidth > 0) { tabPtr->location = (tabPtr-1)->location + textPtr->charWidth; } else { tabPtr->location = (tabPtr-1)->location + 8; } lastStop = tabPtr->location; #else Tcl_SetObjResult(interp, Tcl_ObjPrintf( "tabs must be monotonically increasing, but \"%s\" is " "smaller than or equal to the previous tab", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "TAB_STOP", NULL); goto error; #endif /* _TK_ALLOW_DECREASING_TABS */ } tabArrayPtr->numTabs++; /* |
︙ | ︙ | |||
4564 4565 4566 4567 4568 4569 4570 | break; case DUMP_WIN: what |= TK_DUMP_WIN; break; case DUMP_CMD: arg++; if (arg >= objc) { | | < < < > | | | > | | 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 | break; case DUMP_WIN: what |= TK_DUMP_WIN; break; case DUMP_CMD: arg++; if (arg >= objc) { goto wrongArgs; } command = objv[arg]; break; default: Tcl_Panic("unexpected switch fallthrough"); } } if (arg >= objc || arg+2 < objc) { wrongArgs: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Usage: %s dump ?-all -image -text -mark -tag -window? " "?-command script? index ?index2?", Tcl_GetString(objv[0]))); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); return TCL_ERROR; } if (what == 0) { what = TK_DUMP_ALL; } if (TkTextGetObjIndex(interp, textPtr, objv[arg], &index1) != TCL_OK) { 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", (unsigned) length) == 0) { atEnd = 1; } } if (TkTextIndexCmp(&index1, &index2) >= 0) { return TCL_OK; } lineno = TkBTreeLinesTo(textPtr, index1.linePtr); |
︙ | ︙ | |||
4744 4745 4746 4747 4748 4749 4750 | * text, we could not confidently revert the modification * here. */ int length = last - first; char *range = ckalloc(length + 1); | | < | 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 | * text, we could not confidently revert the modification * here. */ int length = last - first; char *range = 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, command, &index, what); ckfree(range); |
︙ | ︙ | |||
4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 | } TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr, lineno, offset, &index); lineChanged = DumpSegment(textPtr, interp, "window", pathname, command, &index, what); } } offset += currentSize; if (lineChanged) { TkTextSegment *newSegPtr; int newOffset = 0; textChanged = 1; /* * Our indices are no longer valid. */ if (textPtr->flags & DESTROYED) { return textChanged; } linePtr = TkBTreeFindLine(textPtr->sharedTextPtr->tree, textPtr, lineno); newSegPtr = linePtr->segPtr; | > | < < | 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 | } TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr, lineno, offset, &index); lineChanged = DumpSegment(textPtr, interp, "window", pathname, command, &index, what); } } offset += currentSize; if (lineChanged) { TkTextSegment *newSegPtr; int newOffset = 0; textChanged = 1; /* * Our indices are no longer valid. */ if (textPtr->flags & DESTROYED) { return textChanged; } linePtr = TkBTreeFindLine(textPtr->sharedTextPtr->tree, textPtr, lineno); newSegPtr = linePtr->segPtr; if (segPtr != newSegPtr) { while ((newOffset < endByte) && (newOffset < offset) && (newSegPtr != NULL)) { newOffset += currentSize; newSegPtr = newSegPtr->nextPtr; if (segPtr == newSegPtr) { break; } |
︙ | ︙ | |||
4863 4864 4865 4866 4867 4868 4869 | newSegPtr = searchPtr; break; } searchPtr = searchPtr->nextPtr; } } segPtr = newSegPtr; | < < | | | | 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 | newSegPtr = searchPtr; break; } searchPtr = searchPtr->nextPtr; } } segPtr = newSegPtr; } } if (segPtr != NULL) { segPtr = segPtr->nextPtr; } } return textChanged; } /* |
︙ | ︙ | |||
4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 | 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. */ int what) /* Look for TK_DUMP_INDEX bit. */ { char buffer[TK_POS_CHARS]; TkTextPrintIndex(textPtr, index, buffer); if (command == NULL) { | > > > > > | | < < < < < < < < | | > | | < < < < | 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 | 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. */ int what) /* 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); values[2] = Tcl_NewStringObj(buffer, -1); tuple = Tcl_NewListObj(3, values); if (command == NULL) { Tcl_ListObjAppendList(NULL, Tcl_GetObjResult(interp), tuple); Tcl_DecrRefCount(tuple); return 0; } else { int oldStateEpoch = TkBTreeEpoch(textPtr->sharedTextPtr->tree); Tcl_VarEval(interp, Tcl_GetString(command), " ", Tcl_GetString(tuple), NULL); Tcl_DecrRefCount(tuple); return ((textPtr->flags & DESTROYED) || TkBTreeEpoch(textPtr->sharedTextPtr->tree) != oldStateEpoch); } } /* *---------------------------------------------------------------------- * * TextEditUndo -- |
︙ | ︙ | |||
5053 5054 5055 5056 5057 5058 5059 | static int TextEditCmd( TkText *textPtr, /* Information about text widget. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { | | < | 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 | static int TextEditCmd( TkText *textPtr, /* Information about text widget. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { int index, setModified, oldModified; static const char *const editOptionStrings[] = { "modified", "redo", "reset", "separator", "undo", NULL }; enum editOptions { EDIT_MODIFIED, EDIT_REDO, EDIT_RESET, EDIT_SEPARATOR, EDIT_UNDO }; |
︙ | ︙ | |||
5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 | } switch ((enum editOptions) index) { case EDIT_MODIFIED: if (objc == 3) { Tcl_SetObjResult(interp, Tcl_NewBooleanObj(textPtr->sharedTextPtr->isDirty)); } else if (objc != 4) { Tcl_WrongNumArgs(interp, 3, objv, "?boolean?"); return TCL_ERROR; | > < < < | | | | | | | | | | | | | | | | | | | | | < | > | 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 | } switch ((enum editOptions) index) { case EDIT_MODIFIED: if (objc == 3) { Tcl_SetObjResult(interp, Tcl_NewBooleanObj(textPtr->sharedTextPtr->isDirty)); return TCL_OK; } else if (objc != 4) { Tcl_WrongNumArgs(interp, 3, objv, "?boolean?"); return TCL_ERROR; } else if (Tcl_GetBooleanFromObj(interp, objv[3], &setModified) != TCL_OK) { return TCL_ERROR; } /* * Set or reset the dirty info, and trigger a Modified event. */ setModified = setModified ? 1 : 0; oldModified = textPtr->sharedTextPtr->isDirty; textPtr->sharedTextPtr->isDirty = setModified; if (setModified) { textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_FIXED; } else { textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_NORMAL; } /* * Only issue the <<Modified>> event if the flag actually changed. * However, degree of modified-ness doesn't matter. [Bug 1799782] */ if ((!oldModified) != (!setModified)) { GenerateModifiedEvent(textPtr); } break; case EDIT_REDO: if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } if (TextEditRedo(textPtr)) { Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to redo", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_REDO", NULL); return TCL_ERROR; } break; case EDIT_RESET: if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; |
︙ | ︙ | |||
5142 5143 5144 5145 5146 5147 5148 | break; case EDIT_UNDO: if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } if (TextEditUndo(textPtr)) { | | > | 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 | break; case EDIT_UNDO: if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } if (TextEditUndo(textPtr)) { Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to undo", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_UNDO", NULL); return TCL_ERROR; } break; } return TCL_OK; } |
︙ | ︙ | |||
5202 5203 5204 5205 5206 5207 5208 | TkTextMakeByteIndex(indexPtr1->tree, textPtr, TkBTreeLinesTo(textPtr, indexPtr1->linePtr), indexPtr1->byteIndex, &tmpIndex); if (TkTextIndexCmp(indexPtr1, indexPtr2) < 0) { while (1) { | | | > < < < < < | > | | | | < | | | | < | 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 | TkTextMakeByteIndex(indexPtr1->tree, textPtr, TkBTreeLinesTo(textPtr, indexPtr1->linePtr), indexPtr1->byteIndex, &tmpIndex); if (TkTextIndexCmp(indexPtr1, indexPtr2) < 0) { while (1) { int offset; TkTextSegment *segPtr = TkTextIndexToSeg(&tmpIndex, &offset); int last = segPtr->size, last2; if (tmpIndex.linePtr == indexPtr2->linePtr) { /* * The last line that was requested must be handled carefully, * because we may need to break out of this loop in the middle * of the line. */ if (indexPtr2->byteIndex == tmpIndex.byteIndex) { break; } last2 = indexPtr2->byteIndex - tmpIndex.byteIndex + offset; if (last2 < last) { last = last2; } } if (segPtr->typePtr == &tkTextCharType && !(visibleOnly && TkTextIsElided(textPtr,&tmpIndex,NULL))){ Tcl_AppendToObj(resultPtr, segPtr->body.chars + offset, last - offset); } TkTextIndexForwBytes(textPtr, &tmpIndex, last-offset, &tmpIndex); } } return resultPtr; } |
︙ | ︙ | |||
5258 5259 5260 5261 5262 5263 5264 | *---------------------------------------------------------------------- */ static void GenerateModifiedEvent( TkText *textPtr) /* Information about text widget. */ { | > > | > | 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 | *---------------------------------------------------------------------- */ static void GenerateModifiedEvent( TkText *textPtr) /* Information about text widget. */ { union { XEvent general; XVirtualEvent virtual; } event; Tk_MakeWindowExist(textPtr->tkwin); memset(&event, 0, sizeof(event)); event.general.xany.type = VirtualEvent; event.general.xany.serial = NextRequest(Tk_Display(textPtr->tkwin)); event.general.xany.send_event = False; |
︙ | ︙ | |||
5394 5395 5396 5397 5398 5399 5400 | /* * Check for any empty search range here. It might be better in the * future to embed that in SearchCore (whose default behaviour is to * wrap when given a negative search range). */ | < | > | < < < < < | 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 | /* * Check for any empty search range here. It might be better in the * future to embed that in SearchCore (whose default behaviour is to * wrap when given a negative search range). */ if (TkTextIndexCmp(indexFromPtr, indexToPtr) == (searchSpecPtr->backwards ? -1 : 1)) { return TCL_OK; } if (searchSpecPtr->lineIndexProc(interp, toPtr, searchSpecPtr, &searchSpecPtr->stopLine, &searchSpecPtr->stopOffset) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
5708 5709 5710 5711 5712 5713 5714 | p = startOfLine + alreadySearchOffset; alreadySearchOffset = -1; } else { p = startOfLine + lastOffset -1; } while (p >= startOfLine + firstOffset) { if (p[0] == c && !strncmp(p, pattern, | | | 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 | p = startOfLine + alreadySearchOffset; alreadySearchOffset = -1; } else { p = startOfLine + lastOffset -1; } while (p >= startOfLine + firstOffset) { if (p[0] == c && !strncmp(p, pattern, (unsigned) matchLength)) { goto backwardsMatch; } p--; } break; } else { p = strstr(startOfLine + firstOffset, pattern); |
︙ | ︙ | |||
5737 5738 5739 5740 5741 5742 5743 | } else { /* * Multi-line match has only one possible match position, * because we know where the '\n' is. */ p = startOfLine + lastOffset - firstNewLine - 1; | | | 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 | } 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, (unsigned) firstNewLine + 1)) { /* * No match. */ break; } else { int extraLines = 1; |
︙ | ︙ | |||
6697 6698 6699 6700 6701 6702 6703 | TkTextIndexBackBytes(textPtr, &index, byteOffset, &index); } else { return TCL_ERROR; } TkTextSetMark(textPtr, "insert", &index); TkTextPrintIndex(textPtr, &index, buf); | < < | | 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 | TkTextIndexBackBytes(textPtr, &index, byteOffset, &index); } else { return TCL_ERROR; } TkTextSetMark(textPtr, "insert", &index); TkTextPrintIndex(textPtr, &index, buf); Tcl_SetObjResult(interp, Tcl_ObjPrintf("%s %d", buf, index.byteIndex)); return TCL_OK; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkTextDisp.c.
︙ | ︙ | |||
5983 5984 5985 5986 5987 5988 5989 | } } else if (c=='m' && strncmp(Tcl_GetString(objv[2]), "mark", length)==0) { dInfoPtr->scanMarkXPixel = dInfoPtr->newXPixelOffset; dInfoPtr->scanMarkX = x; dInfoPtr->scanTotalYScroll = 0; dInfoPtr->scanMarkY = y; } else { | | | > > > | 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 | } } else if (c=='m' && strncmp(Tcl_GetString(objv[2]), "mark", length)==0) { dInfoPtr->scanMarkXPixel = dInfoPtr->newXPixelOffset; dInfoPtr->scanMarkX = x; dInfoPtr->scanTotalYScroll = 0; dInfoPtr->scanMarkY = y; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad scan option \"%s\": must be mark or dragto", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "scan option", Tcl_GetString(objv[2]), NULL); return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
7295 7296 7297 7298 7299 7300 7301 | } if (end == -1) { end = charsLen; } return MeasureChars(tkfont, chars, charsLen, start, end-start, startX, maxX, flags, nextXPtr); | | | 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 | } if (end == -1) { end = charsLen; } return MeasureChars(tkfont, chars, charsLen, start, end-start, startX, maxX, flags, nextXPtr); #else /* TK_LAYOUT_WITH_BASE_CHUNKS */ { int xDisplacement; int fit, bstart = start, bend = end; if (chars == NULL) { Tcl_DString *baseChars = &((BaseCharInfo *) ciPtr->baseChunkPtr->clientData)->baseChars; |
︙ | ︙ | |||
7335 7336 7337 7338 7339 7340 7341 | if (fit < bstart) { return 0; } else { return fit - bstart; } } | | | 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 | if (fit < bstart) { return 0; } else { return fit - bstart; } } #endif /* TK_LAYOUT_WITH_BASE_CHUNKS */ } /* *-------------------------------------------------------------- * * CharDisplayProc -- * |
︙ | ︙ |
Changes to generic/tkTextImage.c.
︙ | ︙ | |||
151 152 153 154 155 156 157 | return TCL_ERROR; } if (TkTextGetObjIndex(interp, textPtr, objv[3], &index) != TCL_OK) { return TCL_ERROR; } eiPtr = TkTextIndexToSeg(&index, NULL); if (eiPtr->typePtr != &tkTextEmbImageType) { | > | | > | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | return TCL_ERROR; } if (TkTextGetObjIndex(interp, textPtr, objv[3], &index) != TCL_OK) { return TCL_ERROR; } eiPtr = TkTextIndexToSeg(&index, NULL); if (eiPtr->typePtr != &tkTextEmbImageType) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "no embedded image at index \"%s\"", Tcl_GetString(objv[3]))); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_IMAGE", NULL); return TCL_ERROR; } objPtr = Tk_GetOptionValue(interp, (char *) &eiPtr->body.ei, eiPtr->body.ei.optionTable, objv[4], textPtr->tkwin); if (objPtr == NULL) { return TCL_ERROR; } else { |
︙ | ︙ | |||
174 175 176 177 178 179 180 | return TCL_ERROR; } if (TkTextGetObjIndex(interp, textPtr, objv[3], &index) != TCL_OK) { return TCL_ERROR; } eiPtr = TkTextIndexToSeg(&index, NULL); if (eiPtr->typePtr != &tkTextEmbImageType) { | > | | > > | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | return TCL_ERROR; } if (TkTextGetObjIndex(interp, textPtr, objv[3], &index) != TCL_OK) { return TCL_ERROR; } eiPtr = TkTextIndexToSeg(&index, NULL); if (eiPtr->typePtr != &tkTextEmbImageType) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "no embedded image at index \"%s\"", Tcl_GetString(objv[3]))); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_IMAGE", NULL); return TCL_ERROR; } if (objc <= 5) { Tcl_Obj *objPtr = Tk_GetOptionInfo(interp, (char *) &eiPtr->body.ei, eiPtr->body.ei.optionTable, (objc == 5) ? objv[4] : NULL, textPtr->tkwin); if (objPtr == NULL) { return TCL_ERROR; } else { Tcl_SetObjResult(interp, objPtr); return TCL_OK; } } else { |
︙ | ︙ | |||
268 269 270 271 272 273 274 275 276 277 278 279 280 281 | TkTextInvalidateLineMetrics(textPtr->sharedTextPtr, NULL, index.linePtr, 0, TK_TEXT_INVALIDATE_ONLY); return TCL_OK; } case CMD_NAMES: { Tcl_HashSearch search; Tcl_HashEntry *hPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->imageTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { | > > | | > > | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | TkTextInvalidateLineMetrics(textPtr->sharedTextPtr, NULL, index.linePtr, 0, TK_TEXT_INVALIDATE_ONLY); return TCL_OK; } case CMD_NAMES: { Tcl_HashSearch search; Tcl_HashEntry *hPtr; Tcl_Obj *resultObj; if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } resultObj = Tcl_NewObj(); for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->imageTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr), -1)); } Tcl_SetObjResult(interp, resultObj); return TCL_OK; } default: Tcl_Panic("unexpected switch fallthrough"); } return TCL_ERROR; } |
︙ | ︙ | |||
319 320 321 322 323 324 325 326 327 | * options. */ { Tk_Image image; Tcl_DString newName; Tcl_HashEntry *hPtr; Tcl_HashSearch search; char *name; int count = 0; /* The counter for picking a unique name */ int conflict = 0; /* True if we have a name conflict */ | > | | | 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | * options. */ { Tk_Image image; Tcl_DString newName; Tcl_HashEntry *hPtr; Tcl_HashSearch search; char *name; int dummy; int count = 0; /* The counter for picking a unique name */ int conflict = 0; /* True if we have a name conflict */ size_t len; /* length of image name */ if (Tk_SetOptions(textPtr->interp, (char *) &eiPtr->body.ei, eiPtr->body.ei.optionTable, objc, objv, textPtr->tkwin, NULL, NULL) != TCL_OK) { return TCL_ERROR; } /* * Create the image. Save the old image around and don't free it until |
︙ | ︙ | |||
365 366 367 368 369 370 371 | */ name = eiPtr->body.ei.imageName; if (name == NULL) { name = eiPtr->body.ei.imageString; } if (name == NULL) { | | | | > > | 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | */ name = eiPtr->body.ei.imageName; if (name == NULL) { name = eiPtr->body.ei.imageString; } if (name == NULL) { Tcl_SetObjResult(textPtr->interp, Tcl_NewStringObj( "Either a \"-name\" or a \"-image\" argument must be" " provided to the \"image create\" subcommand", -1)); Tcl_SetErrorCode(textPtr->interp, "TK", "TEXT", "IMAGE_CREATE_USAGE", NULL); return TCL_ERROR; } len = strlen(name); for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->imageTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { char *haveName = Tcl_GetHashKey(&textPtr->sharedTextPtr->imageTable, hPtr); |
︙ | ︙ | |||
399 400 401 402 403 404 405 | if (conflict) { char buf[4 + TCL_INTEGER_SPACE]; sprintf(buf, "#%d", count+1); Tcl_DStringAppend(&newName, buf, -1); } name = Tcl_DStringValue(&newName); | < < < | | < | | 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | if (conflict) { char buf[4 + TCL_INTEGER_SPACE]; sprintf(buf, "#%d", count+1); Tcl_DStringAppend(&newName, buf, -1); } name = Tcl_DStringValue(&newName); hPtr = Tcl_CreateHashEntry(&textPtr->sharedTextPtr->imageTable, name, &dummy); Tcl_SetHashValue(hPtr, eiPtr); Tcl_SetObjResult(textPtr->interp, Tcl_NewStringObj(name, -1)); eiPtr->body.ei.name = ckalloc(Tcl_DStringLength(&newName) + 1); strcpy(eiPtr->body.ei.name, name); Tcl_DStringFree(&newName); return TCL_OK; } |
︙ | ︙ |
Changes to generic/tkTextIndex.c.
︙ | ︙ | |||
80 81 82 83 84 85 86 87 88 89 90 91 92 93 | static void FreeTextIndexInternalRep( Tcl_Obj *indexObjPtr) /* TextIndex object with internal rep to * free. */ { TkTextIndex *indexPtr = GET_TEXTINDEX(indexObjPtr); if (indexPtr->textPtr != NULL) { if (--indexPtr->textPtr->refCount == 0) { /* * The text widget has been deleted and we need to free it now. */ ckfree(indexPtr->textPtr); | > | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | static void FreeTextIndexInternalRep( Tcl_Obj *indexObjPtr) /* TextIndex object with internal rep to * free. */ { TkTextIndex *indexPtr = GET_TEXTINDEX(indexObjPtr); if (indexPtr->textPtr != NULL) { if (--indexPtr->textPtr->refCount == 0) { /* * The text widget has been deleted and we need to free it now. */ ckfree(indexPtr->textPtr); |
︙ | ︙ | |||
129 130 131 132 133 134 135 | static void UpdateStringOfTextIndex( Tcl_Obj *objPtr) { char buffer[TK_POS_CHARS]; register int len; | < > | | > | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | static void UpdateStringOfTextIndex( Tcl_Obj *objPtr) { char buffer[TK_POS_CHARS]; register int len; const TkTextIndex *indexPtr = GET_TEXTINDEX(objPtr); len = TkTextPrintIndex(indexPtr->textPtr, indexPtr, buffer); objPtr->bytes = ckalloc(len + 1); strcpy(objPtr->bytes, buffer); objPtr->length = len; } static int SetTextIndexFromAny( Tcl_Interp *interp, /* Used for error reporting if not NULL. */ Tcl_Obj *objPtr) /* The object to convert. */ { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't convert value to textindex except via" " TkTextGetIndexFromObj API", -1)); Tcl_SetErrorCode(interp, "TK", "API_ABUSE", NULL); return TCL_ERROR; } /* *--------------------------------------------------------------------------- * * MakeObjIndex -- |
︙ | ︙ | |||
826 827 828 829 830 831 832 | TkTextMakeByteIndex(sharedPtr->tree, textPtr, 0, 0, &first); TkTextMakeByteIndex(sharedPtr->tree, textPtr, TkBTreeNumLines(sharedPtr->tree, textPtr), 0, &last); TkBTreeStartSearch(&first, &last, tagPtr, &search); if (!TkBTreeCharTagged(&first, tagPtr) && !TkBTreeNextTag(&search)) { if (tagPtr == textPtr->selTagPtr) { tagName = "sel"; | < | | | < < | | | > > | 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 | TkTextMakeByteIndex(sharedPtr->tree, textPtr, 0, 0, &first); TkTextMakeByteIndex(sharedPtr->tree, textPtr, TkBTreeNumLines(sharedPtr->tree, textPtr), 0, &last); TkBTreeStartSearch(&first, &last, tagPtr, &search); if (!TkBTreeCharTagged(&first, tagPtr) && !TkBTreeNextTag(&search)) { if (tagPtr == textPtr->selTagPtr) { tagName = "sel"; } else if (hPtr != NULL) { tagName = Tcl_GetHashKey(&sharedPtr->tagTable, hPtr); } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "text doesn't contain any characters tagged with \"%s\"", tagName)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TEXT_INDEX", tagName, NULL); Tcl_DStringFree(©); return TCL_ERROR; } *indexPtr = search.curIndex; if (wantLast) { while (TkBTreeNextTag(&search)) { *indexPtr = search.curIndex; |
︙ | ︙ | |||
997 998 999 1000 1001 1002 1003 | if (indexPtr->linePtr == NULL) { Tcl_Panic("Bad index created"); } return TCL_OK; error: Tcl_DStringFree(©); | | | | 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 | if (indexPtr->linePtr == NULL) { Tcl_Panic("Bad index created"); } return TCL_OK; error: Tcl_DStringFree(©); Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad text index \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "TEXT", "BAD_INDEX", NULL); return TCL_ERROR; } /* *--------------------------------------------------------------------------- * * TkTextPrintIndex -- |
︙ | ︙ |
Changes to generic/tkTextMark.c.
︙ | ︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #define MSEG_SIZE ((unsigned) (Tk_Offset(TkTextSegment, body) \ + sizeof(TkTextMark))) /* * Forward references for functions defined in this file: */ static void InsertUndisplayProc(TkText *textPtr, TkTextDispChunk *chunkPtr); static int MarkDeleteProc(TkTextSegment *segPtr, TkTextLine *linePtr, int treeGone); static TkTextSegment * MarkCleanupProc(TkTextSegment *segPtr, TkTextLine *linePtr); static void MarkCheckProc(TkTextSegment *segPtr, | > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #define MSEG_SIZE ((unsigned) (Tk_Offset(TkTextSegment, body) \ + sizeof(TkTextMark))) /* * Forward references for functions defined in this file: */ static Tcl_Obj * GetMarkName(TkText *textPtr, TkTextSegment *segPtr); static void InsertUndisplayProc(TkText *textPtr, TkTextDispChunk *chunkPtr); static int MarkDeleteProc(TkTextSegment *segPtr, TkTextLine *linePtr, int treeGone); static TkTextSegment * MarkCleanupProc(TkTextSegment *segPtr, TkTextLine *linePtr); static void MarkCheckProc(TkTextSegment *segPtr, |
︙ | ︙ | |||
128 129 130 131 132 133 134 | int length; const char *str; if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 3, objv, "markName ?gravity?"); return TCL_ERROR; } | | > | > | > > | | > | | > | > > > > | > | | | > > > | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 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 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | int length; const char *str; if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 3, objv, "markName ?gravity?"); return TCL_ERROR; } str = Tcl_GetStringFromObj(objv[3], &length); if (length == 6 && !strcmp(str, "insert")) { markPtr = textPtr->insertMarkPtr; } else if (length == 7 && !strcmp(str, "current")) { markPtr = textPtr->currentMarkPtr; } else { hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->markTable, str); if (hPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "there is no mark named \"%s\"", str)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TEXT_MARK", str, NULL); return TCL_ERROR; } markPtr = Tcl_GetHashValue(hPtr); } if (objc == 4) { const char *typeStr; if (markPtr->typePtr == &tkTextRightMarkType) { typeStr = "right"; } else { typeStr = "left"; } Tcl_SetObjResult(interp, Tcl_NewStringObj(typeStr, -1)); return TCL_OK; } str = Tcl_GetStringFromObj(objv[4],&length); c = str[0]; if ((c == 'l') && (strncmp(str, "left", (unsigned) length) == 0)) { newTypePtr = &tkTextLeftMarkType; } else if ((c == 'r') && (strncmp(str, "right", (unsigned) length) == 0)) { newTypePtr = &tkTextRightMarkType; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad mark gravity \"%s\": must be left or right", str)); Tcl_SetErrorCode(interp, "TK", "VALUE", "MARK_GRAVITY", NULL); return TCL_ERROR; } TkTextMarkSegToIndex(textPtr, markPtr, &index); TkBTreeUnlinkSegment(markPtr, markPtr->body.mark.linePtr); markPtr->typePtr = newTypePtr; TkBTreeLinkSegment(markPtr, &index); break; } case MARK_NAMES: { Tcl_Obj *resultObj; if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } resultObj = Tcl_NewObj(); Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( "insert", -1)); Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( "current", -1)); for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->markTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr), -1)); } Tcl_SetObjResult(interp, resultObj); break; } case MARK_NEXT: if (objc != 4) { Tcl_WrongNumArgs(interp, 3, objv, "index"); return TCL_ERROR; } return MarkFindNext(interp, textPtr, Tcl_GetString(objv[3])); case MARK_PREVIOUS: |
︙ | ︙ | |||
839 840 841 842 843 844 845 | * segPtr points at the first possible candidate, or NULL if we ran * off the end of the line. */ for ( ; segPtr != NULL ; segPtr = segPtr->nextPtr) { if (segPtr->typePtr == &tkTextRightMarkType || segPtr->typePtr == &tkTextLeftMarkType) { | | | < < | < < < < < < < < < < < < | < | < | 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 | * segPtr points at the first possible candidate, or NULL if we ran * off the end of the line. */ for ( ; segPtr != NULL ; segPtr = segPtr->nextPtr) { if (segPtr->typePtr == &tkTextRightMarkType || segPtr->typePtr == &tkTextLeftMarkType) { Tcl_Obj *markName = GetMarkName(textPtr, segPtr); if (markName != NULL) { Tcl_SetObjResult(interp, markName); return TCL_OK; } } } index.linePtr = TkBTreeNextLine(textPtr, index.linePtr); if (index.linePtr == NULL) { return TCL_OK; } index.byteIndex = 0; |
︙ | ︙ | |||
958 959 960 961 962 963 964 | continue; } } prevPtr = seg2Ptr; } } if (prevPtr != NULL) { | | | < < < < | < < < < < < < < < < < | < < | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 1021 1022 1023 1024 1025 | continue; } } prevPtr = seg2Ptr; } } if (prevPtr != NULL) { Tcl_Obj *markName = GetMarkName(textPtr, prevPtr); if (markName != NULL) { Tcl_SetObjResult(interp, markName); return TCL_OK; } } index.linePtr = TkBTreePreviousLine(textPtr, index.linePtr); if (index.linePtr == NULL) { return TCL_OK; } segPtr = NULL; } } /* * ------------------------------------------------------------------------ * * GetMarkName -- * Returns the name of the mark that is the given text segment, or NULL * if it is unnamed (i.e., a widget-specific mark that isn't "current" or * "insert"). * * ------------------------------------------------------------------------ */ static Tcl_Obj * GetMarkName( TkText *textPtr, TkTextSegment *segPtr) { const char *markName; if (segPtr == textPtr->currentMarkPtr) { markName = "current"; } else if (segPtr == textPtr->insertMarkPtr) { markName = "insert"; } else if (segPtr->body.mark.hPtr == NULL) { /* * Ignore widget-specific marks for the other widgets. This is either * an insert or a current mark (markPtr->body.mark.hPtr actually * receives NULL for these marks in TkTextSetMark). The insert and * current marks for textPtr having already been tested above, the * current segment is an insert or current mark from a peer of * textPtr, which we don't want to return. */ return NULL; } else { markName = Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, segPtr->body.mark.hPtr); } return Tcl_NewStringObj(markName, -1); } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkTextTag.c.
︙ | ︙ | |||
96 97 98 99 100 101 102 | static void ChangeTagPriority(TkText *textPtr, TkTextTag *tagPtr, int prio); static TkTextTag * FindTag(Tcl_Interp *interp, TkText *textPtr, Tcl_Obj *tagName); static void SortTags(int numTags, TkTextTag **tagArrayPtr); static int TagSortProc(const void *first, const void *second); | | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | static void ChangeTagPriority(TkText *textPtr, TkTextTag *tagPtr, int prio); static TkTextTag * FindTag(Tcl_Interp *interp, TkText *textPtr, Tcl_Obj *tagName); static void SortTags(int numTags, TkTextTag **tagArrayPtr); static int TagSortProc(const void *first, const void *second); static void TagBindEvent(TkText *textPtr, XEvent *eventPtr, int numTags, TkTextTag **tagArrayPtr); /* *-------------------------------------------------------------- * * TkTextTagCmd -- * |
︙ | ︙ | |||
209 210 211 212 213 214 215 | * textPtr (not for other peer widget's "sel" tags) because we * cannot reach this code path with a different widget's "sel" * tag. */ if (tagPtr == textPtr->selTagPtr) { /* | | | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | * textPtr (not for other peer widget's "sel" tags) because we * cannot reach this code path with a different widget's "sel" * tag. */ if (tagPtr == textPtr->selTagPtr) { /* * Send an event that the selection changed. This is * equivalent to: * event generate $textWidget <<Selection>> */ TkTextSelectionEvent(textPtr); if (addTag && textPtr->exportSelection |
︙ | ︙ | |||
272 273 274 275 276 277 278 | if (mask & (unsigned) ~(ButtonMotionMask|Button1MotionMask |Button2MotionMask|Button3MotionMask|Button4MotionMask |Button5MotionMask|ButtonPressMask|ButtonReleaseMask |EnterWindowMask|LeaveWindowMask|KeyPressMask |KeyReleaseMask|PointerMotionMask|VirtualEventMask)) { Tk_DeleteBinding(interp, textPtr->sharedTextPtr->bindingTable, (ClientData) tagPtr->name, Tcl_GetString(objv[4])); | | | | | | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | if (mask & (unsigned) ~(ButtonMotionMask|Button1MotionMask |Button2MotionMask|Button3MotionMask|Button4MotionMask |Button5MotionMask|ButtonPressMask|ButtonReleaseMask |EnterWindowMask|LeaveWindowMask|KeyPressMask |KeyReleaseMask|PointerMotionMask|VirtualEventMask)) { Tk_DeleteBinding(interp, textPtr->sharedTextPtr->bindingTable, (ClientData) tagPtr->name, Tcl_GetString(objv[4])); Tcl_SetObjResult(interp, Tcl_NewStringObj( "requested illegal events; only key, button, motion," " enter, leave, and virtual events may be used", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "TAG_BIND_EVENT",NULL); return TCL_ERROR; } } else if (objc == 5) { const char *command; command = Tk_GetBinding(interp, textPtr->sharedTextPtr->bindingTable, |
︙ | ︙ | |||
298 299 300 301 302 303 304 | */ if (string[0] != '\0') { return TCL_ERROR; } Tcl_ResetResult(interp); } else { | | | 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | */ if (string[0] != '\0') { return TCL_ERROR; } Tcl_ResetResult(interp); } else { Tcl_SetObjResult(interp, Tcl_NewStringObj(command, -1)); } } else { Tk_GetAllBindings(interp, textPtr->sharedTextPtr->bindingTable, (ClientData) tagPtr->name); } break; case TAG_CGET: |
︙ | ︙ | |||
453 454 455 456 457 458 459 | } } if (tagPtr->elideString != NULL) { if (Tcl_GetBoolean(interp, tagPtr->elideString, &tagPtr->elide) != TCL_OK) { return TCL_ERROR; } | > > | | | | > | | 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | } } if (tagPtr->elideString != NULL) { if (Tcl_GetBoolean(interp, tagPtr->elideString, &tagPtr->elide) != TCL_OK) { return TCL_ERROR; } /* * Indices are potentially obsolete after changing -elide, * especially those computed with "display" or "any" * submodifier, therefore increase the epoch. */ textPtr->sharedTextPtr->stateEpoch++; } /* * If the "sel" tag was changed, be sure to mirror information * from the tag back into the text widget record. NOTE: we don't * have to free up information in the widget record before * overwriting it, because it was mirrored in the tag and hence |
︙ | ︙ | |||
642 643 644 645 646 647 648 649 650 651 652 653 654 655 | ckfree(arrayPtr); break; } case TAG_NEXTRANGE: { TkTextIndex last; TkTextSearch tSearch; char position[TK_POS_CHARS]; if ((objc != 5) && (objc != 6)) { Tcl_WrongNumArgs(interp, 3, objv, "tagName index1 ?index2?"); return TCL_ERROR; } tagPtr = FindTag(NULL, textPtr, objv[3]); if (tagPtr == NULL) { | > | 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 | ckfree(arrayPtr); break; } case TAG_NEXTRANGE: { TkTextIndex last; TkTextSearch tSearch; char position[TK_POS_CHARS]; Tcl_Obj *resultObj; if ((objc != 5) && (objc != 6)) { Tcl_WrongNumArgs(interp, 3, objv, "tagName index1 ?index2?"); return TCL_ERROR; } tagPtr = FindTag(NULL, textPtr, objv[3]); if (tagPtr == NULL) { |
︙ | ︙ | |||
710 711 712 713 714 715 716 717 | return TCL_OK; } gotStart: if (TkTextIndexCmp(&tSearch.curIndex, &index2) >= 0) { return TCL_OK; } TkTextPrintIndex(textPtr, &tSearch.curIndex, position); | > | > | > > > | 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 | return TCL_OK; } gotStart: if (TkTextIndexCmp(&tSearch.curIndex, &index2) >= 0) { return TCL_OK; } resultObj = Tcl_NewObj(); TkTextPrintIndex(textPtr, &tSearch.curIndex, position); Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(position, -1)); TkBTreeNextTag(&tSearch); TkTextPrintIndex(textPtr, &tSearch.curIndex, position); Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(position, -1)); Tcl_SetObjResult(interp, resultObj); break; } case TAG_PREVRANGE: { TkTextIndex last; TkTextSearch tSearch; char position1[TK_POS_CHARS]; char position2[TK_POS_CHARS]; Tcl_Obj *resultObj; if ((objc != 5) && (objc != 6)) { Tcl_WrongNumArgs(interp, 3, objv, "tagName index1 ?index2?"); return TCL_ERROR; } tagPtr = FindTag(NULL, textPtr, objv[3]); if (tagPtr == NULL) { |
︙ | ︙ | |||
769 770 771 772 773 774 775 | /* * The first character is tagged, so just add the range from * the first char to the start of the range. */ TkTextPrintIndex(textPtr, &index2, position1); TkTextPrintIndex(textPtr, &index1, position2); | | < | 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 | /* * The first character is tagged, so just add the range from * the first char to the start of the range. */ TkTextPrintIndex(textPtr, &index2, position1); TkTextPrintIndex(textPtr, &index1, position2); goto gotPrevIndexPair; } return TCL_OK; } if (tSearch.segPtr->typePtr == &tkTextToggleOnType) { TkTextPrintIndex(textPtr, &tSearch.curIndex, position1); if (textPtr->start != NULL) { |
︙ | ︙ | |||
820 821 822 823 824 825 826 | /* It's ok */ TkTextPrintIndex(textPtr, &index2, position1); } else { return TCL_OK; } } } | > > > | > | > > | 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 | /* It's ok */ TkTextPrintIndex(textPtr, &index2, position1); } else { return TCL_OK; } } } gotPrevIndexPair: resultObj = Tcl_NewObj(); Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(position1, -1)); Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(position2, -1)); Tcl_SetObjResult(interp, resultObj); break; } case TAG_RAISE: { TkTextTag *tagPtr2; int prio; if ((objc != 4) && (objc != 5)) { |
︙ | ︙ | |||
880 881 882 883 884 885 886 | TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr, 0, 0, &first); TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr, TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr), 0, &last); TkBTreeStartSearch(&first, &last, tagPtr, &tSearch); if (TkBTreeCharTagged(&first, tagPtr)) { | | | | | 894 895 896 897 898 899 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 | TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr, 0, 0, &first); TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr, TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr), 0, &last); TkBTreeStartSearch(&first, &last, tagPtr, &tSearch); if (TkBTreeCharTagged(&first, tagPtr)) { Tcl_ListObjAppendElement(NULL, listObj, TkTextNewIndexObj(textPtr, &first)); count++; } while (TkBTreeNextTag(&tSearch)) { Tcl_ListObjAppendElement(NULL, listObj, TkTextNewIndexObj(textPtr, &tSearch.curIndex)); count++; } if (count % 2 == 1) { /* * If a text widget uses '-end', it won't necessarily run to the * end of the B-tree, and therefore the tag range might not be * closed. In this case we add the end of the range. */ Tcl_ListObjAppendElement(NULL, listObj, TkTextNewIndexObj(textPtr, &last)); } Tcl_SetObjResult(interp, listObj); break; } } return TCL_OK; |
︙ | ︙ | |||
937 938 939 940 941 942 943 | { register TkTextTag *tagPtr; Tcl_HashEntry *hPtr = NULL; int isNew; const char *name; if (!strcmp(tagName, "sel")) { | | | | | | | 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 | { register TkTextTag *tagPtr; Tcl_HashEntry *hPtr = NULL; int isNew; const char *name; if (!strcmp(tagName, "sel")) { if (textPtr->selTagPtr != NULL) { if (newTag != NULL) { *newTag = 0; } return textPtr->selTagPtr; } if (newTag != NULL) { *newTag = 1; } name = "sel"; } else { hPtr = Tcl_CreateHashEntry(&textPtr->sharedTextPtr->tagTable, tagName, &isNew); if (newTag != NULL) { *newTag = isNew; } |
︙ | ︙ | |||
1044 1045 1046 1047 1048 1049 1050 | static TkTextTag * FindTag( Tcl_Interp *interp, /* Interpreter to use for error message; if * NULL, then don't record an error * message. */ TkText *textPtr, /* Widget in which tag is being used. */ | | | | | | > > > | 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 | static TkTextTag * FindTag( Tcl_Interp *interp, /* Interpreter to use for error message; if * NULL, then don't record an error * message. */ TkText *textPtr, /* Widget in which tag is being used. */ Tcl_Obj *tagName) /* Name of desired tag. */ { Tcl_HashEntry *hPtr; int len; const char *str; str = Tcl_GetStringFromObj(tagName, &len); if (len == 3 && !strcmp(str, "sel")) { return textPtr->selTagPtr; } hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->tagTable, Tcl_GetString(tagName)); if (hPtr != NULL) { return Tcl_GetHashValue(hPtr); } if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "tag \"%s\" isn't defined in text widget", Tcl_GetString(tagName))); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TEXT_TAG", Tcl_GetString(tagName), NULL); } return NULL; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
1381 1382 1383 1384 1385 1386 1387 | void TkTextBindProc( ClientData clientData, /* Pointer to canvas structure. */ XEvent *eventPtr) /* Pointer to X event that just happened. */ { TkText *textPtr = clientData; | | | 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 | void TkTextBindProc( ClientData clientData, /* Pointer to canvas structure. */ XEvent *eventPtr) /* Pointer to X event that just happened. */ { TkText *textPtr = clientData; int repick = 0; # define AnyButtonMask \ (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask) textPtr->refCount++; /* |
︙ | ︙ | |||
1425 1426 1427 1428 1429 1430 1431 | } if ((eventPtr->xbutton.state & AnyButtonMask) == (unsigned) mask) { textPtr->flags &= ~BUTTON_DOWN; repick = 1; } } else if ((eventPtr->type == EnterNotify) || (eventPtr->type == LeaveNotify)) { | | | | 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 | } if ((eventPtr->xbutton.state & AnyButtonMask) == (unsigned) mask) { textPtr->flags &= ~BUTTON_DOWN; repick = 1; } } else if ((eventPtr->type == EnterNotify) || (eventPtr->type == LeaveNotify)) { if (eventPtr->xcrossing.state & AnyButtonMask) { textPtr->flags |= BUTTON_DOWN; } else { textPtr->flags &= ~BUTTON_DOWN; } TkTextPickCurrent(textPtr, eventPtr); goto done; } else if (eventPtr->type == MotionNotify) { if (eventPtr->xmotion.state & AnyButtonMask) { textPtr->flags |= BUTTON_DOWN; } else { textPtr->flags &= ~BUTTON_DOWN; } TkTextPickCurrent(textPtr, eventPtr); } if ((textPtr->numCurTags > 0) |
︙ | ︙ | |||
1557 1558 1559 1560 1561 1562 1563 | textPtr->pickEvent.xcrossing.y_root = eventPtr->xmotion.y_root; textPtr->pickEvent.xcrossing.mode = NotifyNormal; textPtr->pickEvent.xcrossing.detail = NotifyNonlinear; textPtr->pickEvent.xcrossing.same_screen = eventPtr->xmotion.same_screen; textPtr->pickEvent.xcrossing.focus = False; textPtr->pickEvent.xcrossing.state = eventPtr->xmotion.state; | | | 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 | textPtr->pickEvent.xcrossing.y_root = eventPtr->xmotion.y_root; textPtr->pickEvent.xcrossing.mode = NotifyNormal; textPtr->pickEvent.xcrossing.detail = NotifyNonlinear; textPtr->pickEvent.xcrossing.same_screen = eventPtr->xmotion.same_screen; textPtr->pickEvent.xcrossing.focus = False; textPtr->pickEvent.xcrossing.state = eventPtr->xmotion.state; } else { textPtr->pickEvent = *eventPtr; } } /* * Find the new current character, then find and sort all of the tags * associated with it. |
︙ | ︙ |
Changes to generic/tkTextWind.c.
︙ | ︙ | |||
169 170 171 172 173 174 175 | return TCL_ERROR; } if (TkTextGetObjIndex(interp, textPtr, objv[3], &index) != TCL_OK) { return TCL_ERROR; } ewPtr = TkTextIndexToSeg(&index, NULL); if (ewPtr->typePtr != &tkTextEmbWindowType) { | > | | > | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | return TCL_ERROR; } if (TkTextGetObjIndex(interp, textPtr, objv[3], &index) != TCL_OK) { return TCL_ERROR; } ewPtr = TkTextIndexToSeg(&index, NULL); if (ewPtr->typePtr != &tkTextEmbWindowType) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "no embedded window at index \"%s\"", Tcl_GetString(objv[3]))); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_WINDOW", NULL); return TCL_ERROR; } /* * Copy over client specific value before querying. */ |
︙ | ︙ | |||
206 207 208 209 210 211 212 | return TCL_ERROR; } if (TkTextGetObjIndex(interp, textPtr, objv[3], &index) != TCL_OK) { return TCL_ERROR; } ewPtr = TkTextIndexToSeg(&index, NULL); if (ewPtr->typePtr != &tkTextEmbWindowType) { | > | | > | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | return TCL_ERROR; } if (TkTextGetObjIndex(interp, textPtr, objv[3], &index) != TCL_OK) { return TCL_ERROR; } ewPtr = TkTextIndexToSeg(&index, NULL); if (ewPtr->typePtr != &tkTextEmbWindowType) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "no embedded window at index \"%s\"", Tcl_GetString(objv[3]))); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_WINDOW", NULL); return TCL_ERROR; } if (objc <= 5) { TkTextEmbWindowClient *client; Tcl_Obj *objPtr; /* |
︙ | ︙ | |||
327 328 329 330 331 332 333 334 335 336 337 338 339 340 | TkTextInvalidateLineMetrics(textPtr->sharedTextPtr, NULL, index.linePtr, 0, TK_TEXT_INVALIDATE_ONLY); break; } case WIND_NAMES: { Tcl_HashSearch search; Tcl_HashEntry *hPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->windowTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { | > > | | > > | 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 | TkTextInvalidateLineMetrics(textPtr->sharedTextPtr, NULL, index.linePtr, 0, TK_TEXT_INVALIDATE_ONLY); break; } case WIND_NAMES: { Tcl_HashSearch search; Tcl_HashEntry *hPtr; Tcl_Obj *resultObj; if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } resultObj = Tcl_NewObj(); for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->windowTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr), -1)); } Tcl_SetObjResult(interp, resultObj); break; } } return TCL_OK; } /* |
︙ | ︙ | |||
432 433 434 435 436 437 438 | parent = Tk_Parent(ewPtr->body.ew.tkwin); for (ancestor = textPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (Tk_TopWinHierarchy(ancestor)) { badMaster: | | > | | > > | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | parent = Tk_Parent(ewPtr->body.ew.tkwin); for (ancestor = textPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (Tk_TopWinHierarchy(ancestor)) { badMaster: Tcl_SetObjResult(textPtr->interp, Tcl_ObjPrintf( "can't embed %s in %s", Tk_PathName(ewPtr->body.ew.tkwin), Tk_PathName(textPtr->tkwin))); Tcl_SetErrorCode(textPtr->interp, "TK", "GEOMETRY", "HIERARCHY", NULL); ewPtr->body.ew.tkwin = NULL; if (client != NULL) { client->tkwin = NULL; } return TCL_ERROR; } } |
︙ | ︙ | |||
842 843 844 845 846 847 848 | } if ((ewPtr->body.ew.tkwin == NULL) && (ewPtr->body.ew.create != NULL)) { int code, isNew; Tk_Window ancestor; Tcl_HashEntry *hPtr; const char *before, *string; | | > | 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 | } if ((ewPtr->body.ew.tkwin == NULL) && (ewPtr->body.ew.create != NULL)) { int code, isNew; Tk_Window ancestor; Tcl_HashEntry *hPtr; const char *before, *string; Tcl_DString buf, *dsPtr = NULL; Tcl_Obj *nameObj; before = ewPtr->body.ew.create; /* * Find everything up to the next % character and append it to the * result string. */ |
︙ | ︙ | |||
901 902 903 904 905 906 907 | Tcl_DStringAppend(dsPtr, before, (int) (string-before)); code = Tcl_GlobalEval(textPtr->interp, Tcl_DStringValue(dsPtr)); Tcl_DStringFree(dsPtr); } else { code = Tcl_GlobalEval(textPtr->interp, ewPtr->body.ew.create); } if (code != TCL_OK) { | < < | > | | > | > | < < < < < < | > > > > > > > > > | 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 956 957 958 959 960 | Tcl_DStringAppend(dsPtr, before, (int) (string-before)); code = Tcl_GlobalEval(textPtr->interp, Tcl_DStringValue(dsPtr)); Tcl_DStringFree(dsPtr); } else { code = Tcl_GlobalEval(textPtr->interp, ewPtr->body.ew.create); } if (code != TCL_OK) { Tcl_BackgroundException(textPtr->interp, code); goto gotWindow; } nameObj = Tcl_GetObjResult(textPtr->interp); Tcl_IncrRefCount(nameObj); Tcl_ResetResult(textPtr->interp); ewPtr->body.ew.tkwin = Tk_NameToWindow(textPtr->interp, Tcl_GetString(nameObj), textPtr->tkwin); Tcl_DecrRefCount(nameObj); if (ewPtr->body.ew.tkwin == NULL) { Tcl_BackgroundError(textPtr->interp); goto gotWindow; } for (ancestor = textPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == Tk_Parent(ewPtr->body.ew.tkwin)) { break; } if (Tk_TopWinHierarchy(ancestor)) { goto badMaster; } } if (Tk_TopWinHierarchy(ewPtr->body.ew.tkwin) || (textPtr->tkwin == ewPtr->body.ew.tkwin)) { badMaster: Tcl_SetObjResult(textPtr->interp, Tcl_ObjPrintf( "can't embed %s relative to %s", Tk_PathName(ewPtr->body.ew.tkwin), Tk_PathName(textPtr->tkwin))); Tcl_SetErrorCode(textPtr->interp, "TK", "GEOMETRY", "HIERARCHY", NULL); Tcl_BackgroundError(textPtr->interp); ewPtr->body.ew.tkwin = NULL; goto gotWindow; } if (client == NULL) { /* * We just used a '-create' script to make a new window, which we * now need to add to our client list. */ |
︙ | ︙ |
Changes to generic/tkTrig.c.
︙ | ︙ | |||
1371 1372 1373 1374 1375 1376 1377 | double *pointPtr, /* Array of input coordinates: x0, y0, x1, y1, * etc.. */ int numPoints) /* Number of points at pointPtr. */ { int closed, i; int numCoords = numPoints*2; double control[8]; | | > > | | < | 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 | double *pointPtr, /* Array of input coordinates: x0, y0, x1, y1, * etc.. */ int numPoints) /* Number of points at pointPtr. */ { int closed, i; int numCoords = numPoints*2; double control[8]; Tcl_Obj *psObj; /* * If the curve is a closed one then generate a special spline that spans * the last points and the first ones. Otherwise just put the first point * into the path. */ if ((pointPtr[0] == pointPtr[numCoords-2]) && (pointPtr[1] == pointPtr[numCoords-1])) { closed = 1; control[0] = 0.5*pointPtr[numCoords-4] + 0.5*pointPtr[0]; control[1] = 0.5*pointPtr[numCoords-3] + 0.5*pointPtr[1]; control[2] = 0.167*pointPtr[numCoords-4] + 0.833*pointPtr[0]; control[3] = 0.167*pointPtr[numCoords-3] + 0.833*pointPtr[1]; control[4] = 0.833*pointPtr[0] + 0.167*pointPtr[2]; control[5] = 0.833*pointPtr[1] + 0.167*pointPtr[3]; control[6] = 0.5*pointPtr[0] + 0.5*pointPtr[2]; control[7] = 0.5*pointPtr[1] + 0.5*pointPtr[3]; psObj = Tcl_ObjPrintf( "%.15g %.15g moveto\n" "%.15g %.15g %.15g %.15g %.15g %.15g curveto\n", control[0], Tk_CanvasPsY(canvas, control[1]), control[2], Tk_CanvasPsY(canvas, control[3]), control[4], Tk_CanvasPsY(canvas, control[5]), control[6], Tk_CanvasPsY(canvas, control[7])); } else { closed = 0; control[6] = pointPtr[0]; control[7] = pointPtr[1]; psObj = Tcl_ObjPrintf("%.15g %.15g moveto\n", control[6], Tk_CanvasPsY(canvas, control[7])); } /* * Cycle through all the remaining points in the curve, generating a curve * section for each vertex in the linear path. */ for (i = numPoints-2, pointPtr += 2; i > 0; i--, pointPtr += 2) { |
︙ | ︙ | |||
1428 1429 1430 1431 1432 1433 1434 | } else { control[6] = 0.5*pointPtr[0] + 0.5*pointPtr[2]; control[7] = 0.5*pointPtr[1] + 0.5*pointPtr[3]; } control[4] = 0.333*control[6] + 0.667*pointPtr[0]; control[5] = 0.333*control[7] + 0.667*pointPtr[1]; | > | < > > > | 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 | } else { control[6] = 0.5*pointPtr[0] + 0.5*pointPtr[2]; control[7] = 0.5*pointPtr[1] + 0.5*pointPtr[3]; } control[4] = 0.333*control[6] + 0.667*pointPtr[0]; control[5] = 0.333*control[7] + 0.667*pointPtr[1]; Tcl_AppendPrintfToObj(psObj, "%.15g %.15g %.15g %.15g %.15g %.15g curveto\n", control[2], Tk_CanvasPsY(canvas, control[3]), control[4], Tk_CanvasPsY(canvas, control[5]), control[6], Tk_CanvasPsY(canvas, control[7])); } Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj); Tcl_DecrRefCount(psObj); } /* *-------------------------------------------------------------- * * TkMakeRawCurvePostscript -- * |
︙ | ︙ | |||
1468 1469 1470 1471 1472 1473 1474 | * being generated. */ double *pointPtr, /* Array of input coordinates: x0, y0, x1, y1, * etc.. */ int numPoints) /* Number of points at pointPtr. */ { int i; double *segPtr; | | | < | > | < | 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 | * being generated. */ double *pointPtr, /* Array of input coordinates: x0, y0, x1, y1, * etc.. */ int numPoints) /* Number of points at pointPtr. */ { int i; double *segPtr; Tcl_Obj *psObj; /* * Put the first point into the path. */ psObj = Tcl_ObjPrintf("%.15g %.15g moveto\n", pointPtr[0], Tk_CanvasPsY(canvas, pointPtr[1])); /* * Loop through all the remaining points in the curve, generating a * straight line or curve section for every three of them. */ for (i=numPoints-1,segPtr=pointPtr ; i>=3 ; i-=3,segPtr+=6) { if (segPtr[0]==segPtr[2] && segPtr[1]==segPtr[3] && segPtr[4]==segPtr[6] && segPtr[5]==segPtr[7]) { /* * The control points on this segment are equal to their * neighbouring knots, so this segment is just a straight line. */ Tcl_AppendPrintfToObj(psObj, "%.15g %.15g lineto\n", segPtr[6], Tk_CanvasPsY(canvas, segPtr[7])); } else { /* * This is a generic Bezier curve segment. */ Tcl_AppendPrintfToObj(psObj, "%.15g %.15g %.15g %.15g %.15g %.15g curveto\n", segPtr[2], Tk_CanvasPsY(canvas, segPtr[3]), segPtr[4], Tk_CanvasPsY(canvas, segPtr[5]), segPtr[6], Tk_CanvasPsY(canvas, segPtr[7])); } } /* * If there are any points left that haven't been used, then build the * last segment and generate Postscript in the same way for that. */ |
︙ | ︙ | |||
1528 1529 1530 1531 1532 1533 1534 | if (control[0]==control[2] && control[1]==control[3] && control[4]==control[6] && control[5]==control[7]) { /* * Straight line. */ | | > | < > > > | 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 | if (control[0]==control[2] && control[1]==control[3] && control[4]==control[6] && control[5]==control[7]) { /* * Straight line. */ Tcl_AppendPrintfToObj(psObj, "%.15g %.15g lineto\n", control[6], Tk_CanvasPsY(canvas, control[7])); } else { /* * Bezier curve segment. */ Tcl_AppendPrintfToObj(psObj, "%.15g %.15g %.15g %.15g %.15g %.15g curveto\n", control[2], Tk_CanvasPsY(canvas, control[3]), control[4], Tk_CanvasPsY(canvas, control[5]), control[6], Tk_CanvasPsY(canvas, control[7])); } } Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj); Tcl_DecrRefCount(psObj); } /* *-------------------------------------------------------------- * * TkGetMiterPoints -- * |
︙ | ︙ |
Changes to generic/tkUtil.c.
︙ | ︙ | |||
52 53 54 55 56 57 58 59 60 61 62 63 64 65 | const char *value, /* Value of option. */ char *widgRec, /* Pointer to record for item. */ int offset) /* Offset into item. */ { int c; int flags = PTR2INT(clientData); size_t length; register Tk_State *statePtr = (Tk_State *) (widgRec + offset); if (value == NULL || *value == 0) { *statePtr = TK_STATE_NULL; return TCL_OK; } | > | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | const char *value, /* Value of option. */ char *widgRec, /* Pointer to record for item. */ int offset) /* Offset into item. */ { int c; int flags = PTR2INT(clientData); size_t length; Tcl_Obj *msgObj; register Tk_State *statePtr = (Tk_State *) (widgRec + offset); if (value == NULL || *value == 0) { *statePtr = TK_STATE_NULL; return TCL_OK; } |
︙ | ︙ | |||
80 81 82 83 84 85 86 | return TCL_OK; } if ((c == 'h') && (flags&2) && (strncmp(value, "hidden", length) == 0)) { *statePtr = TK_STATE_HIDDEN; return TCL_OK; } | > | < | | | | | | | > > | 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 | return TCL_OK; } if ((c == 'h') && (flags&2) && (strncmp(value, "hidden", length) == 0)) { *statePtr = TK_STATE_HIDDEN; return TCL_OK; } msgObj = Tcl_ObjPrintf("bad %s value \"%s\": must be normal", ((flags & 4) ? "-default" : "state"), value); if (flags & 1) { Tcl_AppendToObj(msgObj, ", active", -1); } if (flags & 2) { Tcl_AppendToObj(msgObj, ", hidden", -1); } if (flags & 3) { Tcl_AppendToObj(msgObj, ",", -1); } Tcl_AppendToObj(msgObj, " or disabled", -1); Tcl_SetObjResult(interp, msgObj); Tcl_SetErrorCode(interp, "TK", "VALUE", "STATE", NULL); *statePtr = TK_STATE_NORMAL; return TCL_ERROR; } /* *-------------------------------------------------------------- * |
︙ | ︙ | |||
191 192 193 194 195 196 197 | *orientPtr = 0; return TCL_OK; } if ((c == 'v') && (strncmp(value, "vertical", length) == 0)) { *orientPtr = 1; return TCL_OK; } | | | > > | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | *orientPtr = 0; return TCL_OK; } if ((c == 'v') && (strncmp(value, "vertical", length) == 0)) { *orientPtr = 1; return TCL_OK; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad orientation \"%s\": must be vertical or horizontal", value)); Tcl_SetErrorCode(interp, "TK", "VALUE", "ORIENTATION", NULL); *orientPtr = 0; return TCL_ERROR; } /* *-------------------------------------------------------------- * |
︙ | ︙ | |||
261 262 263 264 265 266 267 268 269 270 271 272 273 274 | char *widgRec, /* Widget structure record */ int offset) /* Offset of tile in record */ { Tk_TSOffset *offsetPtr = (Tk_TSOffset *) (widgRec + offset); Tk_TSOffset tsoffset; const char *q, *p; int result; if ((value == NULL) || (*value == 0)) { tsoffset.flags = TK_OFFSET_CENTER|TK_OFFSET_MIDDLE; goto goodTSOffset; } tsoffset.flags = 0; p = value; | > | 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | char *widgRec, /* Widget structure record */ int offset) /* Offset of tile in record */ { Tk_TSOffset *offsetPtr = (Tk_TSOffset *) (widgRec + offset); Tk_TSOffset tsoffset; const char *q, *p; int result; Tcl_Obj *msgObj; if ((value == NULL) || (*value == 0)) { tsoffset.flags = TK_OFFSET_CENTER|TK_OFFSET_MIDDLE; goto goodTSOffset; } tsoffset.flags = 0; p = value; |
︙ | ︙ | |||
372 373 374 375 376 377 378 | */ goodTSOffset: memcpy(offsetPtr, &tsoffset, sizeof(Tk_TSOffset)); return TCL_OK; badTSOffset: | < | | | | > > | 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | */ goodTSOffset: memcpy(offsetPtr, &tsoffset, sizeof(Tk_TSOffset)); return TCL_OK; badTSOffset: msgObj = Tcl_ObjPrintf("bad offset \"%s\": expected \"x,y\"", value); if (PTR2INT(clientData) & TK_OFFSET_RELATIVE) { Tcl_AppendToObj(msgObj, ", \"#x,y\"", -1); } if (PTR2INT(clientData) & TK_OFFSET_INDEX) { Tcl_AppendToObj(msgObj, ", <index>", -1); } Tcl_AppendToObj(msgObj, ", n, ne, e, se, s, sw, w, nw, or center", -1); Tcl_SetObjResult(interp, msgObj); Tcl_SetErrorCode(interp, "TK", "VALUE", "OFFSET", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * TkOffsetPrintProc -- |
︙ | ︙ | |||
477 478 479 480 481 482 483 | { double *doublePtr = (double *) (widgRec + offset); int result; result = TkGetDoublePixels(interp, tkwin, value, doublePtr); if ((result == TCL_OK) && (clientData == NULL) && (*doublePtr < 0.0)) { | > | > | 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | { double *doublePtr = (double *) (widgRec + offset); int result; result = TkGetDoublePixels(interp, tkwin, value, doublePtr); if ((result == TCL_OK) && (clientData == NULL) && (*doublePtr < 0.0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad screen distance \"%s\"", value)); Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", NULL); return TCL_ERROR; } return result; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
640 641 642 643 644 645 646 | * scroll, if any. */ { int c = argv[2][0]; size_t length = strlen(argv[2]); if ((c == 'm') && (strncmp(argv[2], "moveto", length) == 0)) { if (argc != 4) { | > | | > > | | > | | > | | > > | 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 | * scroll, if any. */ { int c = argv[2][0]; size_t length = strlen(argv[2]); if ((c == 'm') && (strncmp(argv[2], "moveto", length) == 0)) { if (argc != 4) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: should be \"%s %s %s\"", argv[0], argv[1], "moveto fraction")); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); return TK_SCROLL_ERROR; } if (Tcl_GetDouble(interp, argv[3], dblPtr) != TCL_OK) { return TK_SCROLL_ERROR; } return TK_SCROLL_MOVETO; } else if ((c == 's') && (strncmp(argv[2], "scroll", length) == 0)) { if (argc != 5) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: should be \"%s %s %s\"", argv[0], argv[1], "scroll number units|pages")); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); return TK_SCROLL_ERROR; } if (Tcl_GetInt(interp, argv[3], intPtr) != TCL_OK) { return TK_SCROLL_ERROR; } length = strlen(argv[4]); c = argv[4][0]; if ((c == 'p') && (strncmp(argv[4], "pages", length) == 0)) { return TK_SCROLL_PAGES; } else if ((c == 'u') && (strncmp(argv[4], "units", length) == 0)) { return TK_SCROLL_UNITS; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad argument \"%s\": must be units or pages", argv[4])); Tcl_SetErrorCode(interp, "TK", "VALUE", "SCROLL_UNITS", NULL); return TK_SCROLL_ERROR; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown option \"%s\": must be moveto or scroll", argv[2])); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "option", argv[2], NULL); return TK_SCROLL_ERROR; } /* *---------------------------------------------------------------------- * * Tk_GetScrollInfoObj -- |
︙ | ︙ | |||
740 741 742 743 744 745 746 | arg = Tcl_GetStringFromObj(objv[4], &length); if (ArgPfxEq("pages")) { return TK_SCROLL_PAGES; } else if (ArgPfxEq("units")) { return TK_SCROLL_UNITS; } | | | > | | > | 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 | arg = Tcl_GetStringFromObj(objv[4], &length); if (ArgPfxEq("pages")) { return TK_SCROLL_PAGES; } else if (ArgPfxEq("units")) { return TK_SCROLL_UNITS; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad argument \"%s\": must be units or pages", arg)); Tcl_SetErrorCode(interp, "TK", "VALUE", "SCROLL_UNITS", NULL); return TK_SCROLL_ERROR; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown option \"%s\": must be moveto or scroll", arg)); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "option", arg, NULL); return TK_SCROLL_ERROR; } /* *--------------------------------------------------------------------------- * * TkComputeAnchor -- |
︙ | ︙ | |||
909 910 911 912 913 914 915 916 | /* * Not there. Generate an error message (if we can) and return the * default. */ if (interp != NULL) { mPtr = mapPtr; | > > | | | | < > > | 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 | /* * Not there. Generate an error message (if we can) and return the * default. */ if (interp != NULL) { Tcl_Obj *msgObj; mPtr = mapPtr; msgObj = Tcl_ObjPrintf("bad %s value \"%s\": must be %s", option, strKey, mPtr->strKey); for (mPtr++; mPtr->strKey != NULL; mPtr++) { Tcl_AppendPrintfToObj(msgObj, ",%s %s", ((mPtr[1].strKey != NULL) ? "" : "or "), mPtr->strKey); } Tcl_SetObjResult(interp, msgObj); Tcl_SetErrorCode(interp, "TK", "LOOKUP", option, strKey, NULL); } return mPtr->numKey; } int TkFindStateNumObj( Tcl_Interp *interp, /* Interp for error reporting. */ |
︙ | ︙ | |||
965 966 967 968 969 970 971 972 | /* * Not there either. Generate an error message (if we can) and return the * default. */ if (interp != NULL) { mPtr = mapPtr; | > > > > | < | | < > > > | 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 | /* * Not there either. Generate an error message (if we can) and return the * default. */ if (interp != NULL) { Tcl_Obj *msgObj; mPtr = mapPtr; msgObj = Tcl_ObjPrintf( "bad %s value \"%s\": must be %s", Tcl_GetString(optionPtr), key, mPtr->strKey); for (mPtr++; mPtr->strKey != NULL; mPtr++) { Tcl_AppendPrintfToObj(msgObj, ",%s %s", ((mPtr[1].strKey != NULL) ? "" : " or"), mPtr->strKey); } Tcl_SetObjResult(interp, msgObj); Tcl_SetErrorCode(interp, "TK", "LOOKUP", Tcl_GetString(optionPtr), key, NULL); } return mPtr->numKey; } /* * ---------------------------------------------------------------------- * |
︙ | ︙ | |||
1003 1004 1005 1006 1007 1008 1009 | int TkBackgroundEvalObjv( Tcl_Interp *interp, int objc, Tcl_Obj *const *objv, int flags) { | < | < < < < < | | < | < < < < | < < < < < | < < < | < < | 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 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 1067 1068 1069 1070 1071 1072 1073 1074 | int TkBackgroundEvalObjv( Tcl_Interp *interp, int objc, Tcl_Obj *const *objv, int flags) { Tcl_InterpState state; int n, r = TCL_OK; /* * Record the state of the interpreter. */ Tcl_Preserve(interp); state = Tcl_SaveInterpState(interp, TCL_OK); /* * Evaluate the command and handle any error. */ for (n = 0; n < objc; ++n) { Tcl_IncrRefCount(objv[n]); } r = Tcl_EvalObjv(interp, objc, objv, flags); for (n = 0; n < objc; ++n) { Tcl_DecrRefCount(objv[n]); } if (r == TCL_ERROR) { Tcl_AddErrorInfo(interp, "\n (background event handler)"); Tcl_BackgroundException(interp, r); } /* * Restore the state of the interpreter. */ (void) Tcl_RestoreInterpState(interp, state); Tcl_Release(interp); return r; } /* *---------------------------------------------------------------------- * |
︙ | ︙ |
Changes to generic/tkVisual.c.
︙ | ︙ | |||
16 17 18 19 20 21 22 | /* * The table below maps from symbolic names for visual classes to the * associated X class symbols. */ typedef struct VisualDictionary { | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /* * The table below maps from symbolic names for visual classes to the * associated X class symbols. */ typedef struct VisualDictionary { const char *name; /* Textual name of class. */ int minLength; /* Minimum # characters that must be specified * for an unambiguous match. */ int class; /* X symbol for class. */ } VisualDictionary; static const VisualDictionary visualNames[] = { {"best", 1, 0}, {"directcolor", 2, DirectColor}, |
︙ | ︙ | |||
169 170 171 172 173 174 175 | int visualId; /* * This is a visual ID. */ if (Tcl_GetInt(interp, string, &visualId) == TCL_ERROR) { | | | | | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | int visualId; /* * This is a visual ID. */ if (Tcl_GetInt(interp, string, &visualId) == TCL_ERROR) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad X identifier for visual: \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "VISUALID", NULL); return NULL; } template.visualid = visualId; mask = VisualIDMask; } else { /* * Parse the string into a class name (or "best") optionally followed |
︙ | ︙ | |||
198 199 200 201 202 203 204 | && (strncmp(string, dictPtr->name, (size_t) length) == 0)) { template.class = dictPtr->class; break; } } if (template.class == -1) { | > | | > | > | > < | | < > | < > | 198 199 200 201 202 203 204 205 206 207 208 209 210 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 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | && (strncmp(string, dictPtr->name, (size_t) length) == 0)) { template.class = dictPtr->class; break; } } if (template.class == -1) { Tcl_Obj *msgObj = Tcl_ObjPrintf( "unknown or ambiguous visual name \"%s\": class must be ", string); for (dictPtr = visualNames; dictPtr->name != NULL; dictPtr++) { Tcl_AppendPrintfToObj(msgObj, "%s, ", dictPtr->name); } Tcl_AppendToObj(msgObj, "or default", -1); Tcl_SetObjResult(interp, msgObj); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "VISUAL", string, NULL); return NULL; } while (isspace(UCHAR(*p))) { p++; } if (*p == 0) { template.depth = 10000; } else if (Tcl_GetInt(interp, p, &template.depth) != TCL_OK) { return NULL; } if (c == 'b') { mask = 0; } else { mask = VisualClassMask; } } /* * Find all visuals that match the template we've just created, and return * an error if there are none that match. */ template.screen = Tk_ScreenNumber(tkwin); mask |= VisualScreenMask; visInfoList = XGetVisualInfo(Tk_Display(tkwin), mask, &template, &numVisuals); if (visInfoList == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "couldn't find an appropriate visual", -1)); Tcl_SetErrorCode(interp, "TK", "VISUAL", "INAPPROPRIATE", NULL); return NULL; } /* * Search through the visuals that were returned to find the best one. * The choice is based on the following criteria, in decreasing order of * importance: |
︙ | ︙ | |||
399 400 401 402 403 404 405 | */ other = Tk_NameToWindow(interp, string, tkwin); if (other == NULL) { return None; } if (Tk_Screen(other) != Tk_Screen(tkwin)) { | | | > | | > | 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | */ other = Tk_NameToWindow(interp, string, tkwin); if (other == NULL) { return None; } if (Tk_Screen(other) != Tk_Screen(tkwin)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't use colormap for %s: not on same screen", string)); Tcl_SetErrorCode(interp, "TK", "COLORMAP", "SCREEN", NULL); return None; } if (Tk_Visual(other) != Tk_Visual(tkwin)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't use colormap for %s: incompatible visuals", string)); Tcl_SetErrorCode(interp, "TK", "COLORMAP", "INCOMPATIBLE", NULL); return None; } colormap = Tk_Colormap(other); /* * If the colormap was a special one allocated by code in this file, * increment its reference count. |
︙ | ︙ |
Changes to generic/tkWindow.c.
︙ | ︙ | |||
99 100 101 102 103 104 105 | #define PASSMAINWINDOW 2 #define NOOBJPROC 4 #define WINMACONLY 8 #define USEINITPROC 16 typedef int (TkInitProc)(Tcl_Interp *interp, ClientData clientData); typedef struct { | | | > | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | #define PASSMAINWINDOW 2 #define NOOBJPROC 4 #define WINMACONLY 8 #define USEINITPROC 16 typedef int (TkInitProc)(Tcl_Interp *interp, ClientData clientData); typedef struct { const char *name; /* Name of command. */ Tcl_ObjCmdProc *objProc; /* Command's object- (or string-) based * function, or initProc. */ int flags; } TkCmd; static const TkCmd commands[] = { /* * Commands that are part of the intrinsics: */ |
︙ | ︙ | |||
149 150 151 152 153 154 155 | {"labelframe", Tk_LabelframeObjCmd, ISSAFE}, {"listbox", Tk_ListboxObjCmd, ISSAFE}, {"menubutton", Tk_MenubuttonObjCmd, ISSAFE}, {"message", Tk_MessageObjCmd, ISSAFE}, {"panedwindow", Tk_PanedWindowObjCmd, ISSAFE}, {"radiobutton", Tk_RadiobuttonObjCmd, ISSAFE}, {"scale", Tk_ScaleObjCmd, ISSAFE}, | | > | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | {"labelframe", Tk_LabelframeObjCmd, ISSAFE}, {"listbox", Tk_ListboxObjCmd, ISSAFE}, {"menubutton", Tk_MenubuttonObjCmd, ISSAFE}, {"message", Tk_MessageObjCmd, ISSAFE}, {"panedwindow", Tk_PanedWindowObjCmd, ISSAFE}, {"radiobutton", Tk_RadiobuttonObjCmd, ISSAFE}, {"scale", Tk_ScaleObjCmd, ISSAFE}, {"scrollbar", (Tcl_ObjCmdProc *) Tk_ScrollbarCmd, NOOBJPROC|PASSMAINWINDOW|ISSAFE}, {"spinbox", Tk_SpinboxObjCmd, ISSAFE}, {"text", Tk_TextObjCmd, PASSMAINWINDOW|ISSAFE}, {"toplevel", Tk_ToplevelObjCmd, 0}, /* * Classic widget class commands. */ |
︙ | ︙ | |||
171 172 173 174 175 176 177 | {"::tk::labelframe",Tk_LabelframeObjCmd, ISSAFE}, {"::tk::listbox", Tk_ListboxObjCmd, ISSAFE}, {"::tk::menubutton",Tk_MenubuttonObjCmd, ISSAFE}, {"::tk::message", Tk_MessageObjCmd, ISSAFE}, {"::tk::panedwindow",Tk_PanedWindowObjCmd, ISSAFE}, {"::tk::radiobutton",Tk_RadiobuttonObjCmd, ISSAFE}, {"::tk::scale", Tk_ScaleObjCmd, ISSAFE}, | | > | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | {"::tk::labelframe",Tk_LabelframeObjCmd, ISSAFE}, {"::tk::listbox", Tk_ListboxObjCmd, ISSAFE}, {"::tk::menubutton",Tk_MenubuttonObjCmd, ISSAFE}, {"::tk::message", Tk_MessageObjCmd, ISSAFE}, {"::tk::panedwindow",Tk_PanedWindowObjCmd, ISSAFE}, {"::tk::radiobutton",Tk_RadiobuttonObjCmd, ISSAFE}, {"::tk::scale", Tk_ScaleObjCmd, ISSAFE}, {"::tk::scrollbar", (Tcl_ObjCmdProc *) Tk_ScrollbarCmd, NOOBJPROC|PASSMAINWINDOW|ISSAFE}, {"::tk::spinbox", Tk_SpinboxObjCmd, ISSAFE}, {"::tk::text", Tk_TextObjCmd, PASSMAINWINDOW|ISSAFE}, {"::tk::toplevel", Tk_ToplevelObjCmd, 0}, /* * Standard dialog support. Note that the Unix/X11 platform implements * these commands differently (via the script library). |
︙ | ︙ | |||
193 194 195 196 197 198 199 | {"tk_messageBox", Tk_MessageBoxObjCmd, PASSMAINWINDOW}, #endif /* * Misc. */ | | | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | {"tk_messageBox", Tk_MessageBoxObjCmd, PASSMAINWINDOW}, #endif /* * Misc. */ #ifdef MAC_OSX_TK {"::tk::unsupported::MacWindowStyle", TkUnsupported1ObjCmd, PASSMAINWINDOW|ISSAFE}, #endif {NULL, NULL, 0} }; /* |
︙ | ︙ | |||
286 287 288 289 290 291 292 293 294 295 296 297 298 299 | Tcl_DeleteHashTable(&dispPtr->nameTable); Tcl_DeleteHashTable(&dispPtr->atomTable); dispPtr->atomInit = 0; } if (dispPtr->errorPtr != NULL) { TkErrorHandler *errorPtr; for (errorPtr = dispPtr->errorPtr; errorPtr != NULL; errorPtr = dispPtr->errorPtr) { dispPtr->errorPtr = errorPtr->nextPtr; ckfree(errorPtr); } } | > | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | Tcl_DeleteHashTable(&dispPtr->nameTable); Tcl_DeleteHashTable(&dispPtr->atomTable); dispPtr->atomInit = 0; } if (dispPtr->errorPtr != NULL) { TkErrorHandler *errorPtr; for (errorPtr = dispPtr->errorPtr; errorPtr != NULL; errorPtr = dispPtr->errorPtr) { dispPtr->errorPtr = errorPtr->nextPtr; ckfree(errorPtr); } } |
︙ | ︙ | |||
379 380 381 382 383 384 385 | if ((parent != NULL) && (screenName != NULL) && (screenName[0] == '\0')) { dispPtr = ((TkWindow *) parent)->dispPtr; screenId = Tk_ScreenNumber(parent); } else { dispPtr = GetScreen(interp, screenName, &screenId); if (dispPtr == NULL) { | | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | if ((parent != NULL) && (screenName != NULL) && (screenName[0] == '\0')) { dispPtr = ((TkWindow *) parent)->dispPtr; screenId = Tk_ScreenNumber(parent); } else { dispPtr = GetScreen(interp, screenName, &screenId); if (dispPtr == NULL) { return NULL; } } winPtr = TkAllocWindow(dispPtr, screenId, (TkWindow *) parent); /* * Set the flags specified in the call. |
︙ | ︙ | |||
412 413 414 415 416 417 418 | winPtr->flags |= TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED; if (parent != NULL) { if (NameWindow(interp, winPtr, (TkWindow *) parent, name) != TCL_OK) { Tk_DestroyWindow((Tk_Window) winPtr); | | | 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | winPtr->flags |= TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED; if (parent != NULL) { if (NameWindow(interp, winPtr, (TkWindow *) parent, name) != TCL_OK) { Tk_DestroyWindow((Tk_Window) winPtr); return NULL; } } TkWmNewWindow(winPtr); return (Tk_Window) winPtr; } |
︙ | ︙ | |||
463 464 465 466 467 468 469 | * Separate the screen number from the rest of the display name. * ScreenName is assumed to have the syntax <display>.<screen> with the * dot and the screen being optional. */ screenName = TkGetDefaultScreenName(interp, screenName); if (screenName == NULL) { | | | | | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | * Separate the screen number from the rest of the display name. * ScreenName is assumed to have the syntax <display>.<screen> with the * dot and the screen being optional. */ screenName = TkGetDefaultScreenName(interp, screenName); if (screenName == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "no display name and no $DISPLAY environment variable", -1)); Tcl_SetErrorCode(interp, "TK", "NO_DISPLAY", NULL); return NULL; } length = strlen(screenName); screenId = 0; p = screenName+length-1; while (isdigit(UCHAR(*p)) && (p != screenName)) { p--; |
︙ | ︙ | |||
493 494 495 496 497 498 499 | /* * The private function zeros out dispPtr when it is created, so * we only need to initialize the non-zero items. */ dispPtr = TkpOpenDisplay(screenName); if (dispPtr == NULL) { | | | | | 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 | /* * The private function zeros out dispPtr when it is created, so * we only need to initialize the non-zero items. */ dispPtr = TkpOpenDisplay(screenName); if (dispPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't connect to display \"%s\"", screenName)); Tcl_SetErrorCode(interp, "TK", "DISPLAY", "CONNECT", NULL); return NULL; } dispPtr->nextPtr = tsdPtr->displayList; /* TkGetDisplayList(); */ tsdPtr->displayList = dispPtr; dispPtr->lastEventTime = CurrentTime; dispPtr->bindInfoStale = 1; |
︙ | ︙ | |||
527 528 529 530 531 532 533 | } if ((strncmp(dispPtr->name, screenName, length) == 0) && (dispPtr->name[length] == '\0')) { break; } } if (screenId >= ScreenCount(dispPtr->display)) { | < | | | | 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | } if ((strncmp(dispPtr->name, screenName, length) == 0) && (dispPtr->name[length] == '\0')) { break; } } if (screenId >= ScreenCount(dispPtr->display)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad screen number \"%d\"", screenId)); Tcl_SetErrorCode(interp, "TK", "DISPLAY", "SCREEN_NUMBER", NULL); return NULL; } *screenPtr = screenId; return dispPtr; } /* |
︙ | ︙ | |||
769 770 771 772 773 774 775 | * now. */ if (winPtr->flags & TK_ANONYMOUS_WINDOW) { return TCL_OK; } | < < < < < < | | | > > > > > > > | | | > | 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 | * now. */ if (winPtr->flags & TK_ANONYMOUS_WINDOW) { return TCL_OK; } /* * Don't permit names that start with an upper-case letter: this will just * cause confusion with class names in the option database. */ if (isupper(UCHAR(name[0]))) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window name starts with an upper-case letter: \"%s\"", name)); Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW", "NOTCLASS", NULL); return TCL_ERROR; } /* * For non-anonymous windows, set up the window name. */ winPtr->nameUid = Tk_GetUid(name); /* * To permit names of arbitrary length, must be prepared to malloc a * buffer to hold the new path name. To run fast in the common case where * names are short, use a fixed-size buffer on the stack. */ length1 = strlen(parentPtr->pathName); length2 = strlen(name); if ((length1 + length2 + 2) <= FIXED_SIZE) { pathName = staticSpace; } else { pathName = ckalloc(length1 + length2 + 2); } if (length1 == 1) { pathName[0] = '.'; strcpy(pathName+1, name); } else { strcpy(pathName, parentPtr->pathName); pathName[length1] = '.'; strcpy(pathName+length1+1, name); } hPtr = Tcl_CreateHashEntry(&parentPtr->mainPtr->nameTable, pathName, &isNew); if (pathName != staticSpace) { ckfree(pathName); } if (!isNew) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window name \"%s\" already exists in parent", name)); Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW", "EXISTS", NULL); return TCL_ERROR; } Tcl_SetHashValue(hPtr, winPtr); winPtr->pathName = Tcl_GetHashKey(&parentPtr->mainPtr->nameTable, hPtr); return TCL_OK; } |
︙ | ︙ | |||
852 853 854 855 856 857 858 | Tk_Window TkCreateMainWindow( Tcl_Interp *interp, /* Interpreter to use for error reporting. */ const char *screenName, /* Name of screen on which to create window. * Empty or NULL string means use DISPLAY * environment variable. */ | | | 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 | Tk_Window TkCreateMainWindow( Tcl_Interp *interp, /* Interpreter to use for error reporting. */ const char *screenName, /* Name of screen on which to create window. * Empty or NULL string means use DISPLAY * environment variable. */ const char *baseName) /* Base name for application; usually of the * form "prog instance". */ { Tk_Window tkwin; int dummy, isSafe; Tcl_HashEntry *hPtr; register TkMainInfo *mainPtr; register TkWindow *winPtr; |
︙ | ︙ | |||
945 946 947 948 949 950 951 | /* * Bind in Tk's commands. */ isSafe = Tcl_IsSafe(interp); for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) { | | > > | > > | > | < | | < | 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 991 992 993 | /* * Bind in Tk's commands. */ isSafe = Tcl_IsSafe(interp); for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) { if (cmdPtr->objProc == NULL) { Tcl_Panic("TkCreateMainWindow: builtin command with NULL string and object procs"); } #if defined(__WIN32__) && !defined(STATIC_BUILD) if ((cmdPtr->flags & WINMACONLY) && tclStubsPtr->reserved9) { /* * We are running on Cygwin, so don't use the win32 dialogs. */ continue; } #endif /* __WIN32__ && !STATIC_BUILD */ if (cmdPtr->flags & PASSMAINWINDOW) { clientData = tkwin; } else { clientData = NULL; } if (cmdPtr->flags & USEINITPROC) { ((TkInitProc *) cmdPtr->objProc)(interp, clientData); } else if (cmdPtr->flags & NOOBJPROC) { Tcl_CreateCommand(interp, cmdPtr->name, (Tcl_CmdProc *) cmdPtr->objProc, clientData, NULL); } else { Tcl_CreateObjCommand(interp, cmdPtr->name, cmdPtr->objProc, clientData, NULL); } if (isSafe && !(cmdPtr->flags & ISSAFE)) { Tcl_HideCommand(interp, cmdPtr->name, cmdPtr->name); } } TkCreateMenuCmd(interp); /* * Set variables for the intepreter. |
︙ | ︙ | |||
1028 1029 1030 1031 1032 1033 1034 | * window; window will be a top-level * window. */ { TkWindow *parentPtr = (TkWindow *) parent; if (parentPtr) { if (parentPtr->flags & TK_ALREADY_DEAD) { | | | > | | > | 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 | * window; window will be a top-level * window. */ { TkWindow *parentPtr = (TkWindow *) parent; if (parentPtr) { if (parentPtr->flags & TK_ALREADY_DEAD) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't create window: parent has been destroyed", -1)); Tcl_SetErrorCode(interp, "TK", "CREATE", "DEAD_PARENT", NULL); return NULL; } else if (parentPtr->flags & TK_CONTAINER) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't create window: its parent has -container = yes", -1)); Tcl_SetErrorCode(interp, "TK", "CREATE", "CONTAINER", NULL); return NULL; } else if (screenName == NULL) { TkWindow *winPtr = TkAllocWindow(parentPtr->dispPtr, parentPtr->screenNum, parentPtr); if (NameWindow(interp, winPtr, parentPtr, name) != TCL_OK) { Tk_DestroyWindow((Tk_Window) winPtr); |
︙ | ︙ | |||
1090 1091 1092 1093 1094 1095 1096 | * window; window will be a top-level * window. */ { TkWindow *parentPtr = (TkWindow *) parent; if (parentPtr) { if (parentPtr->flags & TK_ALREADY_DEAD) { | | | > | | > | 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 | * window; window will be a top-level * window. */ { TkWindow *parentPtr = (TkWindow *) parent; if (parentPtr) { if (parentPtr->flags & TK_ALREADY_DEAD) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't create window: parent has been destroyed", -1)); Tcl_SetErrorCode(interp, "TK", "CREATE", "DEAD_PARENT", NULL); return NULL; } else if (parentPtr->flags & TK_CONTAINER) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't create window: its parent has -container = yes", -1)); Tcl_SetErrorCode(interp, "TK", "CREATE", "CONTAINER", NULL); return NULL; } else if (screenName == NULL) { TkWindow *winPtr = TkAllocWindow(parentPtr->dispPtr, parentPtr->screenNum, parentPtr); /* * Add the anonymous window flag now, so that NameWindow will * behave correctly. |
︙ | ︙ | |||
1172 1173 1174 1175 1176 1177 1178 | * somewhere else to avoid modifying the pathName string (for large names, * space for the copy will have to be malloc'ed); (b) must special-case * the situation where the parent is ".". */ p = strrchr(pathName, '.'); if (p == NULL) { | | | > | 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 | * somewhere else to avoid modifying the pathName string (for large names, * space for the copy will have to be malloc'ed); (b) must special-case * the situation where the parent is ".". */ p = strrchr(pathName, '.'); if (p == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad window path name \"%s\"", pathName)); Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW_PATH", NULL); return NULL; } numChars = (int) (p-pathName); if (numChars > FIXED_SPACE) { p = ckalloc(numChars + 1); } else { p = fixedSpace; |
︙ | ︙ | |||
1202 1203 1204 1205 1206 1207 1208 | if (p != fixedSpace) { ckfree(p); } if (parent == NULL) { return NULL; } if (((TkWindow *) parent)->flags & TK_ALREADY_DEAD) { | | | > < | | | > | 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 | if (p != fixedSpace) { ckfree(p); } if (parent == NULL) { return NULL; } if (((TkWindow *) parent)->flags & TK_ALREADY_DEAD) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't create window: parent has been destroyed", -1)); Tcl_SetErrorCode(interp, "TK", "CREATE", "DEAD_PARENT", NULL); return NULL; } else if (((TkWindow *) parent)->flags & TK_CONTAINER) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't create window: its parent has -container = yes", -1)); Tcl_SetErrorCode(interp, "TK", "CREATE", "CONTAINER", NULL); return NULL; } /* * Create the window. */ |
︙ | ︙ | |||
1350 1351 1352 1353 1354 1355 1356 | */ if (!(halfdeadPtr->flags & HD_DESTROY_COUNT)) { halfdeadPtr->flags |= HD_DESTROY_COUNT; } while (winPtr->childList != NULL) { | | | | 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 | */ if (!(halfdeadPtr->flags & HD_DESTROY_COUNT)) { halfdeadPtr->flags |= HD_DESTROY_COUNT; } while (winPtr->childList != NULL) { TkWindow *childPtr = winPtr->childList; childPtr->flags |= TK_DONT_DESTROY_WINDOW; Tk_DestroyWindow((Tk_Window) childPtr); if (winPtr->childList == childPtr) { /* * The child didn't remove itself from the child list, so let's * remove it here. This can happen in some strange conditions, * such as when a Destroy event handler for a window destroys the |
︙ | ︙ | |||
1378 1379 1380 1381 1382 1383 1384 | * in-line here, for the same reasons we delete children in-line * (otherwise, for example, the Tk window may appear to exist even * though its X window is gone; this could cause errors). Special * note: it's possible that the embedded window has already been * deleted, in which case TkpGetOtherWindow will return NULL. */ | | | | 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 | * in-line here, for the same reasons we delete children in-line * (otherwise, for example, the Tk window may appear to exist even * though its X window is gone; this could cause errors). Special * note: it's possible that the embedded window has already been * deleted, in which case TkpGetOtherWindow will return NULL. */ TkWindow *childPtr = TkpGetOtherWindow(winPtr); if (childPtr != NULL) { childPtr->flags |= TK_DONT_DESTROY_WINDOW; Tk_DestroyWindow((Tk_Window) childPtr); } } /* |
︙ | ︙ | |||
1524 1525 1526 1527 1528 1529 1530 | * * NOTE: Only replace the commands it if the interpreter is not * being deleted. If it *is*, the interpreter cleanup will do all * the needed work. */ if ((winPtr->mainPtr->interp != NULL) && | | | 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 | * * NOTE: Only replace the commands it if the interpreter is not * being deleted. If it *is*, the interpreter cleanup will do all * the needed work. */ if ((winPtr->mainPtr->interp != NULL) && !Tcl_InterpDeleted(winPtr->mainPtr->interp)) { for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) { Tcl_CreateCommand(winPtr->mainPtr->interp, cmdPtr->name, TkDeadAppCmd, NULL, NULL); } Tcl_CreateCommand(winPtr->mainPtr->interp, "send", TkDeadAppCmd, NULL, NULL); Tcl_UnlinkVar(winPtr->mainPtr->interp, "tk_strictMotif"); |
︙ | ︙ | |||
1609 1610 1611 1612 1613 1614 1615 | /* * Found and spliced it out, now actually do the cleanup. */ TkCloseDisplay(dispPtr); } | | | 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 | /* * Found and spliced it out, now actually do the cleanup. */ TkCloseDisplay(dispPtr); } #endif /* !WIN32 && NOT_YET */ } } Tcl_EventuallyFree(winPtr, TCL_DYNAMIC); } /* *-------------------------------------------------------------- |
︙ | ︙ | |||
1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 | */ for (winPtr2 = winPtr->nextPtr; winPtr2 != NULL; winPtr2 = winPtr2->nextPtr) { if ((winPtr2->window != None) && !(winPtr2->flags & (TK_TOP_HIERARCHY|TK_REPARENTED))) { XWindowChanges changes; changes.sibling = winPtr2->window; changes.stack_mode = Below; XConfigureWindow(winPtr->display, winPtr->window, CWSibling|CWStackMode, &changes); break; } } | > | 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 | */ for (winPtr2 = winPtr->nextPtr; winPtr2 != NULL; winPtr2 = winPtr2->nextPtr) { if ((winPtr2->window != None) && !(winPtr2->flags & (TK_TOP_HIERARCHY|TK_REPARENTED))) { XWindowChanges changes; changes.sibling = winPtr2->window; changes.stack_mode = Below; XConfigureWindow(winPtr->display, winPtr->window, CWSibling|CWStackMode, &changes); break; } } |
︙ | ︙ | |||
2324 2325 2326 2327 2328 2329 2330 | if (tkwin == NULL) { /* * Either we're not really in Tk, or the main window was destroyed and * we're on our way out of the application. */ if (interp != NULL) { | | > > | > | | 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 | if (tkwin == NULL) { /* * Either we're not really in Tk, or the main window was destroyed and * we're on our way out of the application. */ if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj("NULL main window",-1)); Tcl_SetErrorCode(interp, "TK", "NO_MAIN_WINDOW", NULL); } return NULL; } hPtr = Tcl_FindHashEntry(&((TkWindow *) tkwin)->mainPtr->nameTable, pathName); if (hPtr == NULL) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad window path name \"%s\"", pathName)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW", pathName, NULL); } return NULL; } return Tcl_GetHashValue(hPtr); } /* |
︙ | ︙ | |||
2428 2429 2430 2431 2432 2433 2434 | *---------------------------------------------------------------------- */ Tcl_Interp * Tk_Interp( Tk_Window tkwin) { | | | | 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 | *---------------------------------------------------------------------- */ Tcl_Interp * Tk_Interp( Tk_Window tkwin) { if (tkwin != NULL && ((TkWindow *) tkwin)->mainPtr != NULL) { return ((TkWindow *) tkwin)->mainPtr->interp; } return NULL; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
2587 2588 2589 2590 2591 2592 2593 | * Notify the X server of the change. If winPtr hasn't yet been created * then there's no need to tell the X server now, since the stacking order * will be handled properly when the window is finally created. */ if (winPtr->window != None) { XWindowChanges changes; | | < | 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 | * Notify the X server of the change. If winPtr hasn't yet been created * then there's no need to tell the X server now, since the stacking order * will be handled properly when the window is finally created. */ if (winPtr->window != None) { XWindowChanges changes; unsigned int mask = CWStackMode; changes.stack_mode = Above; for (otherPtr = winPtr->nextPtr; otherPtr != NULL; otherPtr = otherPtr->nextPtr) { if ((otherPtr->window != None) && !(otherPtr->flags & (TK_TOP_HIERARCHY|TK_REPARENTED))){ changes.sibling = otherPtr->window; changes.stack_mode = Below; |
︙ | ︙ | |||
2648 2649 2650 2651 2652 2653 2654 | for (mainPtr = tsdPtr->mainWindowList; mainPtr != NULL; mainPtr = mainPtr->nextPtr) { if (mainPtr->interp == interp) { return (Tk_Window) mainPtr->winPtr; } } | > | > | 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 | for (mainPtr = tsdPtr->mainWindowList; mainPtr != NULL; mainPtr = mainPtr->nextPtr) { if (mainPtr->interp == interp) { return (Tk_Window) mainPtr->winPtr; } } Tcl_SetObjResult(interp, Tcl_NewStringObj( "this isn't a Tk application", -1)); Tcl_SetErrorCode(interp, "TK", "NO_MAIN_WINDOW", NULL); return NULL; } /* *---------------------------------------------------------------------- * * Tk_StrictMotif -- |
︙ | ︙ | |||
2836 2837 2838 2839 2840 2841 2842 | #if defined(__WIN32__) && !defined(__WIN64__) static HMODULE tkcygwindll = NULL; /* * Run Tk_MainEx from libtk8.?.dll * | | | | > | | | | > | < | | | | | | | | | | | | | | > | | | | | > | 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 | #if defined(__WIN32__) && !defined(__WIN64__) static HMODULE tkcygwindll = NULL; /* * Run Tk_MainEx from libtk8.?.dll * * This function is only ever called from wish8.4.exe, the cygwin port of Tcl. * This means that the system encoding is utf-8, so we don't have to do any * encoding conversions. */ int TkCygwinMainEx( int argc, /* Number of arguments. */ char **argv, /* Array of argument strings. */ Tcl_AppInitProc *appInitProc, /* Application-specific initialization * procedure to call after most initialization * but before starting to execute commands. */ Tcl_Interp *interp) { TCHAR name[MAX_PATH]; int len; void (*tkmainex)(int, char **, Tcl_AppInitProc *, Tcl_Interp *); /* construct "<path>/libtk8.?.dll", from "<path>/tk8?.dll" */ len = GetModuleFileNameW(Tk_GetHINSTANCE(), name, MAX_PATH); name[len-2] = TEXT('.'); name[len-1] = name[len-5]; _tcscpy(name+len, TEXT(".dll")); memcpy(name+len-8, TEXT("libtk8"), 6 * sizeof(TCHAR)); tkcygwindll = LoadLibrary(name); if (!tkcygwindll) { /* dll is not present */ return 0; } tkmainex = (void (*)(int, char **, Tcl_AppInitProc *, Tcl_Interp *)) GetProcAddress(tkcygwindll, "Tk_MainEx"); if (!tkmainex) { return 0; } tkmainex(argc, argv, appInitProc, interp); return 1; } #endif /* __WIN32__ && !__WIN64__ */ /* *---------------------------------------------------------------------- * * Tk_Init -- * * This function is invoked to add Tk to an interpreter. It incorporates * all of Tk's commands into the interpreter and creates the main window |
︙ | ︙ | |||
2903 2904 2905 2906 2907 2908 2909 | int Tk_Init( Tcl_Interp *interp) /* Interpreter to initialize. */ { #if defined(__WIN32__) && !defined(__WIN64__) if (tkcygwindll) { | | | | | | | 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 | int Tk_Init( Tcl_Interp *interp) /* Interpreter to initialize. */ { #if defined(__WIN32__) && !defined(__WIN64__) if (tkcygwindll) { int (*tkinit)(Tcl_Interp *); tkinit = (int(*)(Tcl_Interp *)) GetProcAddress(tkcygwindll,"Tk_Init"); if (tkinit) { return tkinit(interp); } } #endif /* __WIN32__ && !__WIN64__ */ return Initialize(interp); } /* *---------------------------------------------------------------------- * * Tk_SafeInit -- |
︙ | ︙ | |||
2976 2977 2978 2979 2980 2981 2982 | * * The actual code called is the same as Tk_Init but Tcl_IsSafe() is * checked at several places to differentiate the two initialisations. */ #if defined(__WIN32__) && !defined(__WIN64__) if (tkcygwindll) { | | > | | | | > | | 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 | * * The actual code called is the same as Tk_Init but Tcl_IsSafe() is * checked at several places to differentiate the two initialisations. */ #if defined(__WIN32__) && !defined(__WIN64__) if (tkcygwindll) { int (*tksafeinit)(Tcl_Interp *); tksafeinit = (int (*)(Tcl_Interp *)) GetProcAddress(tkcygwindll, "Tk_SafeInit"); if (tksafeinit) { return tksafeinit(interp); } } #endif /* __WIN32__ && !__WIN64__ */ return Initialize(interp); } MODULE_SCOPE const TkStubs tkStubs; /* *---------------------------------------------------------------------- * * Initialize -- * * The core of the initialization code for Tk, called from Tk_Init and * Tk_SafeInit. * * Results: * A standard Tcl result. Also leaves an error message in the interp's * result if there was an error. * * Side effects: * Depends on the initialization scripts that are invoked. |
︙ | ︙ | |||
3078 3079 3080 3081 3082 3083 3084 | */ Tcl_Interp *master = interp; while (1) { master = Tcl_GetMaster(master); if (master == NULL) { | | > > > | > | 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 | */ Tcl_Interp *master = interp; while (1) { master = Tcl_GetMaster(master); if (master == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "no controlling master interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "NO_MASTER", NULL); code = TCL_ERROR; goto done; } if (!Tcl_IsSafe(master)) { /* Found the trusted master. */ break; } } /* * Construct the name (rewalk...) */ code = Tcl_GetInterpPath(master, interp); if (code != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "error in Tcl_GetInterpPath", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "FAILED", NULL); goto done; } /* * Build the string to eval. */ |
︙ | ︙ | |||
3119 3120 3121 3122 3123 3124 3125 | if (code != TCL_OK) { /* * We might want to transfer the error message or not. We don't. * (No API to do it and maybe security reasons). */ Tcl_DStringFree(&ds); | | | > | 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 | if (code != TCL_OK) { /* * We might want to transfer the error message or not. We don't. * (No API to do it and maybe security reasons). */ Tcl_DStringFree(&ds); Tcl_SetObjResult(interp, Tcl_NewStringObj( "not allowed to start Tk by master's safe::TkInit", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "FAILED", NULL); goto done; } Tcl_DStringFree(&ds); /* * Use the master's result as argv. Note: We don't use the Obj * interfaces to avoid dealing with cross interp refcounting and |
︙ | ︙ | |||
3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 | } } else { return Tcl_PkgPresent(interp, "Tk", version, 1); } } return actualVersion; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ | > | 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 | } } else { return Tcl_PkgPresent(interp, "Tk", version, 1); } } return actualVersion; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/ttk/ttkEntry.c.
︙ | ︙ | |||
1173 1174 1175 1176 1177 1178 1179 | TkRegion clipRegion; XRectangle rect; EntryInitStyleData(entryPtr, &es); textarea = Ttk_ClientRegion(entryPtr->core.layout, "textarea"); showCursor = | | | | 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 | TkRegion clipRegion; XRectangle rect; EntryInitStyleData(entryPtr, &es); textarea = Ttk_ClientRegion(entryPtr->core.layout, "textarea"); showCursor = (entryPtr->core.flags & CURSOR_ON) && EntryEditable(entryPtr) && entryPtr->entry.insertPos >= leftIndex && entryPtr->entry.insertPos <= rightIndex ; showSelection = !(entryPtr->core.state & TTK_STATE_DISABLED) && selFirst > -1 && selLast > leftIndex && selFirst <= rightIndex ; /* Adjust selection range to keep in display bounds. */ |
︙ | ︙ | |||
1318 1319 1320 1321 1322 1323 1324 | *indexPtr = entryPtr->entry.insertPos; } else if (strncmp(string, "left", length) == 0) { /* for debugging */ *indexPtr = entryPtr->entry.xscroll.first; } else if (strncmp(string, "right", length) == 0) { /* for debugging */ *indexPtr = entryPtr->entry.xscroll.last; } else if (strncmp(string, "sel.", 4) == 0) { if (entryPtr->entry.selectFirst < 0) { | | | | > | 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 | *indexPtr = entryPtr->entry.insertPos; } else if (strncmp(string, "left", length) == 0) { /* for debugging */ *indexPtr = entryPtr->entry.xscroll.first; } else if (strncmp(string, "right", length) == 0) { /* for debugging */ *indexPtr = entryPtr->entry.xscroll.last; } else if (strncmp(string, "sel.", 4) == 0) { if (entryPtr->entry.selectFirst < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "selection isn't in widget %s", Tk_PathName(entryPtr->core.tkwin))); Tcl_SetErrorCode(interp, "TTK", "ENTRY", "NO_SELECTION", NULL); return TCL_ERROR; } if (strncmp(string, "sel.first", length) == 0) { *indexPtr = entryPtr->entry.selectFirst; } else if (strncmp(string, "sel.last", length) == 0) { *indexPtr = entryPtr->entry.selectLast; } else { |
︙ | ︙ | |||
1372 1373 1374 1375 1376 1377 1378 | } else if (*indexPtr > entryPtr->entry.numChars) { *indexPtr = entryPtr->entry.numChars; } } return TCL_OK; badIndex: | | | > | 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 | } else if (*indexPtr > entryPtr->entry.numChars) { *indexPtr = entryPtr->entry.numChars; } } return TCL_OK; badIndex: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad entry index \"%s\"", string)); Tcl_SetErrorCode(interp, "TTK", "ENTRY", "INDEX", NULL); return TCL_ERROR; } /* $entry bbox $index -- * Return the bounding box of the character at the specified index. */ static int |
︙ | ︙ | |||
1448 1449 1450 1451 1452 1453 1454 | void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Entry *entryPtr = recordPtr; if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, NULL); return TCL_ERROR; } | | | 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 | void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Entry *entryPtr = recordPtr; if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, NULL); return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewStringObj(entryPtr->entry.string, -1)); return TCL_OK; } /* $entry icursor $index -- * Set the insert cursor position. */ static int |
︙ | ︙ | |||
1778 1779 1780 1781 1782 1783 1784 | Tcl_SetObjResult(interp, Tcl_NewIntObj(currentIndex)); return TCL_OK; } else if (objc == 3) { if (Tcl_GetIntFromObj(interp, objv[2], ¤tIndex) != TCL_OK) { return TCL_ERROR; } if (currentIndex < 0 || currentIndex >= nValues) { | | | | | 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 | Tcl_SetObjResult(interp, Tcl_NewIntObj(currentIndex)); return TCL_OK; } else if (objc == 3) { if (Tcl_GetIntFromObj(interp, objv[2], ¤tIndex) != TCL_OK) { return TCL_ERROR; } if (currentIndex < 0 || currentIndex >= nValues) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Index %s out of range", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_RANGE", NULL); return TCL_ERROR; } cbPtr->combobox.currentIndex = currentIndex; return EntrySetValue(recordPtr, Tcl_GetString(values[currentIndex])); } else { |
︙ | ︙ |
Changes to generic/ttk/ttkFrame.c.
︙ | ︙ | |||
202 203 204 205 206 207 208 | } *anchorPtr = flags; return TCL_OK; error: if (interp) { | < | | | | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | } *anchorPtr = flags; return TCL_OK; error: if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Bad label anchor specification %s", Tcl_GetString(objPtr))); Tcl_SetErrorCode(interp, "TTK", "LABEL", "ANCHOR", NULL); } return TCL_ERROR; } /* LabelAnchorSide -- * Returns the side corresponding to a LabelAnchor value. */ |
︙ | ︙ |
Changes to generic/ttk/ttkImage.c.
︙ | ︙ | |||
55 56 57 58 59 60 61 | if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) { goto error; } if ((objc % 2) != 1) { if (interp) { | | | > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) { goto error; } if ((objc % 2) != 1) { if (interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "image specification must contain an odd number of elements", -1)); Tcl_SetErrorCode(interp, "TTK", "IMAGE", "SPEC", NULL); } goto error; } n = (objc - 1) / 2; imageSpec->states = ckalloc(n * sizeof(Ttk_StateSpec)); imageSpec->images = ckalloc(n * sizeof(Tk_Image *)); |
︙ | ︙ | |||
320 321 322 323 324 325 326 | Ttk_ImageSpec *imageSpec = 0; ImageData *imageData = 0; int padding_specified = 0; int i; if (objc <= 0) { | > | > | 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | Ttk_ImageSpec *imageSpec = 0; ImageData *imageData = 0; int padding_specified = 0; int i; if (objc <= 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Must supply a base image", -1)); Tcl_SetErrorCode(interp, "TTK", "IMAGE", "BASE", NULL); return TCL_ERROR; } imageSpec = TtkGetImageSpec(interp, Tk_MainWindow(interp), objv[0]); if (!imageSpec) { return TCL_ERROR; } |
︙ | ︙ | |||
343 344 345 346 347 348 349 | imageData->imageMap = 0; #endif for (i = 1; i < objc; i += 2) { int option; if (i == objc - 1) { | | | | | > > | > > | 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 | imageData->imageMap = 0; #endif for (i = 1; i < objc; i += 2) { int option; if (i == objc - 1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Value for %s missing", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TTK", "IMAGE", "VALUE", NULL); goto error; } #if TILE_07_COMPAT if (!strcmp("-map", Tcl_GetString(objv[i]))) { imageData->imageMap = objv[i+1]; Tcl_IncrRefCount(imageData->imageMap); continue; } #endif if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option", 0, &option) != TCL_OK) { goto error; } switch (option) { case O_BORDER: if (Ttk_GetBorderFromObj(interp, objv[i+1], &imageData->border) != TCL_OK) { goto error; } if (!padding_specified) { imageData->padding = imageData->border; } break; case O_PADDING: if (Ttk_GetBorderFromObj(interp, objv[i+1], &imageData->padding) != TCL_OK) { goto error; } |
︙ | ︙ |
Changes to generic/ttk/ttkLayout.c.
︙ | ︙ | |||
322 323 324 325 326 327 328 | if (TCL_OK != Tcl_ListObjGetElements(interp, objPtr, &padc, &padv)) { goto error; } if (padc > 4) { if (interp) { | | | > | 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | if (TCL_OK != Tcl_ListObjGetElements(interp, objPtr, &padc, &padv)) { goto error; } if (padc > 4) { if (interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Wrong #elements in padding spec", -1)); Tcl_SetErrorCode(interp, "TTK", "VALUE", "PADDING", NULL); } goto error; } for (i=0; i < padc; ++i) { if (Tk_GetPixelsFromObj(interp, tkwin, padv[i], &pixels[i]) != TCL_OK) { goto error; |
︙ | ︙ | |||
359 360 361 362 363 364 365 | if (TCL_OK != Tcl_ListObjGetElements(interp, objPtr, &padc, &padv)) { goto error; } if (padc > 4) { if (interp) { | | | > | 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | if (TCL_OK != Tcl_ListObjGetElements(interp, objPtr, &padc, &padv)) { goto error; } if (padc > 4) { if (interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Wrong #elements in padding spec", -1)); Tcl_SetErrorCode(interp, "TTK", "VALUE", "BORDER", NULL); } goto error; } for (i=0; i < padc; ++i) { if (Tcl_GetIntFromObj(interp, padv[i], &pixels[i]) != TCL_OK) { goto error; |
︙ | ︙ | |||
472 473 474 475 476 477 478 | switch (c) { case 'w': case 'W': sticky |= TTK_STICK_W; break; case 'e': case 'E': sticky |= TTK_STICK_E; break; case 'n': case 'N': sticky |= TTK_STICK_N; break; case 's': case 'S': sticky |= TTK_STICK_S; break; default: if (interp) { | < | | | | | 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | switch (c) { case 'w': case 'W': sticky |= TTK_STICK_W; break; case 'e': case 'E': sticky |= TTK_STICK_E; break; case 'n': case 'N': sticky |= TTK_STICK_N; break; case 's': case 'S': sticky |= TTK_STICK_S; break; default: if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Bad -sticky specification %s", Tcl_GetString(objPtr))); Tcl_SetErrorCode(interp, "TTK", "VALUE", "STICKY", NULL); } return TCL_ERROR; } } *result = sticky; return TCL_OK; |
︙ | ︙ | |||
639 640 641 642 643 644 645 | interp, objv[i], optStrings, "option", 0, &option) != TCL_OK) { goto error; } if (++i >= objc) { | < | | > | | 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 | interp, objv[i], optStrings, "option", 0, &option) != TCL_OK) { goto error; } if (++i >= objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Missing value for option %s", Tcl_GetString(objv[i-1]))); Tcl_SetErrorCode(interp, "TTK", "VALUE", "LAYOUT", NULL); goto error; } switch (option) { case OP_SIDE: /* <<NOTE-PACKSIDE>> */ if (Tcl_GetIndexFromObj(interp, objv[i], packSideStrings, "side", 0, &value) != TCL_OK) |
︙ | ︙ | |||
786 787 788 789 790 791 792 | APPENDSTR("-expand"); APPENDSTR("1"); } else { if (flags & _TTK_MASK_PACK) { int side = 0; unsigned sideFlags = flags & _TTK_MASK_PACK; | | > | | > | 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 | APPENDSTR("-expand"); APPENDSTR("1"); } else { if (flags & _TTK_MASK_PACK) { int side = 0; unsigned sideFlags = flags & _TTK_MASK_PACK; while (!(sideFlags & TTK_PACK_LEFT)) { ++side; sideFlags >>= 1; } APPENDSTR("-side"); APPENDSTR(packSideStrings[side]); } } /* * In Ttk_ParseLayoutTemplate, default -sticky is "nsew", so always * include this even if no sticky bits are set. */ APPENDSTR("-sticky"); APPENDOBJ(Ttk_NewStickyObj(flags & _TTK_MASK_STICK)); /* @@@ Check again: are these necessary? */ if (flags & TTK_BORDER) { APPENDSTR("-border"); APPENDSTR("1"); } if (flags & TTK_UNIT) { APPENDSTR("-unit"); APPENDSTR("1"); } |
︙ | ︙ | |||
871 872 873 874 875 876 877 | Ttk_Style style = Ttk_GetStyle(themePtr, styleName); Ttk_LayoutTemplate layoutTemplate = Ttk_FindLayoutTemplate(themePtr,styleName); Ttk_ElementClass *bgelement = Ttk_GetElement(themePtr, "background"); Ttk_LayoutNode *bgnode; if (!layoutTemplate) { | | | > | 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 | Ttk_Style style = Ttk_GetStyle(themePtr, styleName); Ttk_LayoutTemplate layoutTemplate = Ttk_FindLayoutTemplate(themePtr,styleName); Ttk_ElementClass *bgelement = Ttk_GetElement(themePtr, "background"); Ttk_LayoutNode *bgnode; if (!layoutTemplate) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Layout %s not found", styleName)); Tcl_SetErrorCode(interp, "TTK", "LOOKUP", "LAYOUT", styleName, NULL); return 0; } bgnode = Ttk_NewLayoutNode(TTK_FILL_BOTH, bgelement); bgnode->next = Ttk_InstantiateLayout(themePtr, layoutTemplate); return TTKNewLayout(style, recordPtr, optionTable, tkwin, bgnode); |
︙ | ︙ | |||
911 912 913 914 915 916 917 | Tcl_DStringAppend(&buf, baseName, -1); styleName = Tcl_DStringValue(&buf); style = Ttk_GetStyle(themePtr, styleName); layoutTemplate = Ttk_FindLayoutTemplate(themePtr, styleName); if (!layoutTemplate) { | | | > | 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 | Tcl_DStringAppend(&buf, baseName, -1); styleName = Tcl_DStringValue(&buf); style = Ttk_GetStyle(themePtr, styleName); layoutTemplate = Ttk_FindLayoutTemplate(themePtr, styleName); if (!layoutTemplate) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Layout %s not found", styleName)); Tcl_SetErrorCode(interp, "TTK", "LOOKUP", "LAYOUT", styleName, NULL); return 0; } Tcl_DStringFree(&buf); return TTKNewLayout( style, 0, optionTable, parentLayout->tkwin, |
︙ | ︙ |
Changes to generic/ttk/ttkManager.c.
︙ | ︙ | |||
451 452 453 454 455 456 457 | int slaveIndex = 0; Tk_Window tkwin; /* Try interpreting as an integer first: */ if (Tcl_GetIntFromObj(NULL, objPtr, &slaveIndex) == TCL_OK) { if (slaveIndex < 0 || slaveIndex >= mgr->nSlaves) { | < | | | | | < < | > | | | | > | 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 | int slaveIndex = 0; Tk_Window tkwin; /* Try interpreting as an integer first: */ if (Tcl_GetIntFromObj(NULL, objPtr, &slaveIndex) == TCL_OK) { if (slaveIndex < 0 || slaveIndex >= mgr->nSlaves) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Slave index %d out of bounds", slaveIndex)); Tcl_SetErrorCode(interp, "TTK", "SLAVE", "INDEX", NULL); return TCL_ERROR; } *indexPtr = slaveIndex; return TCL_OK; } /* Try interpreting as a slave window name; */ if ((*string == '.') && (tkwin = Tk_NameToWindow(interp, string, mgr->masterWindow))) { slaveIndex = Ttk_SlaveIndex(mgr, tkwin); if (slaveIndex < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s is not managed by %s", string, Tk_PathName(mgr->masterWindow))); Tcl_SetErrorCode(interp, "TTK", "SLAVE", "MANAGER", NULL); return TCL_ERROR; } *indexPtr = slaveIndex; return TCL_OK; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Invalid slave specification %s", string)); Tcl_SetErrorCode(interp, "TTK", "SLAVE", "SPEC", NULL); return TCL_ERROR; } /* ++ Ttk_ReorderSlave(mgr, fromIndex, toIndex) -- * Change slave order. */ void Ttk_ReorderSlave(Ttk_Manager *mgr, int fromIndex, int toIndex) |
︙ | ︙ | |||
538 539 540 541 542 543 544 | } ancestor = Tk_Parent(ancestor); } return 1; badWindow: | | < | | | 537 538 539 540 541 542 543 544 545 546 547 548 549 | } ancestor = Tk_Parent(ancestor); } return 1; badWindow: Tcl_SetObjResult(interp, Tcl_ObjPrintf("can't add %s as slave of %s", Tk_PathName(slave), Tk_PathName(master))); Tcl_SetErrorCode(interp, "TTK", "GEOMETRY", "MAINTAINABLE", NULL); return 0; } |
Changes to generic/ttk/ttkNotebook.c.
︙ | ︙ | |||
723 724 725 726 727 728 729 | { Tab *tab; if (!Ttk_Maintainable(interp, slaveWindow, nb->core.tkwin)) { return TCL_ERROR; } #if 0 /* can't happen */ if (Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow) >= 0) { | | | | | 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 | { Tab *tab; if (!Ttk_Maintainable(interp, slaveWindow, nb->core.tkwin)) { return TCL_ERROR; } #if 0 /* can't happen */ if (Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow) >= 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf("%s already added", Tk_PathName(slaveWindow))); Tcl_SetErrorCode(interp, "TTK", "NOTEBOOK", "PRESENT", NULL); return TCL_ERROR; } #endif /* Create and insert tab. */ tab = CreateTab(interp, nb, slaveWindow); |
︙ | ︙ | |||
855 856 857 858 859 860 861 | */ static int GetTabIndex( Tcl_Interp *interp, Notebook *nb, Tcl_Obj *objPtr, int *index_rtn) { int status = FindTabIndex(interp, nb, objPtr, index_rtn); if (status == TCL_OK && *index_rtn < 0) { | < | | | | 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 | */ static int GetTabIndex( Tcl_Interp *interp, Notebook *nb, Tcl_Obj *objPtr, int *index_rtn) { int status = FindTabIndex(interp, nb, objPtr, index_rtn); if (status == TCL_OK && *index_rtn < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "tab '%s' not found", Tcl_GetString(objPtr))); Tcl_SetErrorCode(interp, "TTK", "NOTEBOOK", "TAB", NULL); status = TCL_ERROR; } return status; } /*------------------------------------------------------------------------ * +++ Widget command routines. |
︙ | ︙ | |||
1078 1079 1080 1081 1082 1083 1084 | element = Ttk_IdentifyElement(tabLayout, x, y); } switch (what) { case IDENTIFY_ELEMENT: if (element) { const char *elementName = Ttk_ElementName(element); | > | | 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 | element = Ttk_IdentifyElement(tabLayout, x, y); } switch (what) { case IDENTIFY_ELEMENT: if (element) { const char *elementName = Ttk_ElementName(element); Tcl_SetObjResult(interp, Tcl_NewStringObj(elementName, -1)); } break; case IDENTIFY_TAB: if (tabIndex >= 0) { Tcl_SetObjResult(interp, Tcl_NewIntObj(tabIndex)); } break; |
︙ | ︙ | |||
1169 1170 1171 1172 1173 1174 1175 | Tcl_WrongNumArgs(interp, 2, objv, ""); return TCL_ERROR; } result = Tcl_NewListObj(0, NULL); for (i = 0; i < Ttk_NumberSlaves(mgr); ++i) { const char *pathName = Tk_PathName(Ttk_SlaveWindow(mgr,i)); | > | < | 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 | Tcl_WrongNumArgs(interp, 2, objv, ""); return TCL_ERROR; } result = Tcl_NewListObj(0, NULL); for (i = 0; i < Ttk_NumberSlaves(mgr); ++i) { const char *pathName = Tk_PathName(Ttk_SlaveWindow(mgr,i)); Tcl_ListObjAppendElement(NULL, result, Tcl_NewStringObj(pathName,-1)); } Tcl_SetObjResult(interp, result); return TCL_OK; } /* $nb tab $tab ?-option ?value -option value...?? */ static int NotebookTabCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) |
︙ | ︙ |
Changes to generic/ttk/ttkPanedwindow.c.
︙ | ︙ | |||
153 154 155 156 157 158 159 | { return TCL_ERROR; } /* Sanity-check: */ if (pane->weight < 0) { | > | > | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | { return TCL_ERROR; } /* Sanity-check: */ if (pane->weight < 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "-weight must be nonnegative", -1)); Tcl_SetErrorCode(interp, "TTK", "PANE", "WEIGHT", NULL); goto error; } /* Done. */ Tk_FreeSavedOptions(&savedOptions); Ttk_ManagerSizeChanged(mgr); |
︙ | ︙ | |||
415 416 417 418 419 420 421 | int objc, Tcl_Obj *const objv[]) { Pane *pane; if (!Ttk_Maintainable(interp, slaveWindow, pw->core.tkwin)) { return TCL_ERROR; } if (Ttk_SlaveIndex(pw->paned.mgr, slaveWindow) >= 0) { | | | | | 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | int objc, Tcl_Obj *const objv[]) { Pane *pane; if (!Ttk_Maintainable(interp, slaveWindow, pw->core.tkwin)) { return TCL_ERROR; } if (Ttk_SlaveIndex(pw->paned.mgr, slaveWindow) >= 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s already added", Tk_PathName(slaveWindow))); Tcl_SetErrorCode(interp, "TTK", "PANE", "PRESENT", NULL); return TCL_ERROR; } pane = CreatePane(interp, pw, slaveWindow); if (!pane) { return TCL_ERROR; } |
︙ | ︙ | |||
840 841 842 843 844 845 846 | Tcl_WrongNumArgs(interp, 2,objv, "index ?newpos?"); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[2], &sashIndex) != TCL_OK) { return TCL_ERROR; } if (sashIndex < 0 || sashIndex >= Ttk_NumberSlaves(pw->paned.mgr) - 1) { | | | | | 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 | Tcl_WrongNumArgs(interp, 2,objv, "index ?newpos?"); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[2], &sashIndex) != TCL_OK) { return TCL_ERROR; } if (sashIndex < 0 || sashIndex >= Ttk_NumberSlaves(pw->paned.mgr) - 1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "sash index %d out of range", sashIndex)); Tcl_SetErrorCode(interp, "TTK", "PANE", "SASH_INDEX", NULL); return TCL_ERROR; } pane = Ttk_SlaveData(pw->paned.mgr, sashIndex); if (objc == 3) { Tcl_SetObjResult(interp, Tcl_NewIntObj(pane->sashPos)); |
︙ | ︙ |
Changes to generic/ttk/ttkState.c.
︙ | ︙ | |||
94 95 96 97 98 99 100 | for (j = 0; stateNames[j] != 0; ++j) { if (strcmp(stateName, stateNames[j]) == 0) break; } if (stateNames[j] == 0) { if (interp) { | | | > | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | for (j = 0; stateNames[j] != 0; ++j) { if (strcmp(stateName, stateNames[j]) == 0) break; } if (stateNames[j] == 0) { if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Invalid state name %s", stateName)); Tcl_SetErrorCode(interp, "TTK", "VALUE", "STATE", NULL); } return TCL_ERROR; } if (on) { onbits |= (1<<j); } else { |
︙ | ︙ | |||
212 213 214 215 216 217 218 | status = Ttk_GetStateSpecFromObj(interp, specs[j], &spec); if (status != TCL_OK) return NULL; if (Ttk_StateMatches(state, &spec)) return specs[j+1]; } if (interp) { | | | | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | status = Ttk_GetStateSpecFromObj(interp, specs[j], &spec); if (status != TCL_OK) return NULL; if (Ttk_StateMatches(state, &spec)) return specs[j+1]; } if (interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj("No match in state map", -1)); Tcl_SetErrorCode(interp, "TTK", "STATE", "UNMATCHED", NULL); } return NULL; } /* Ttk_GetStateMapFromObj -- * Returns a Ttk_StateMap from a Tcl_Obj*. * Since a Ttk_StateMap is just a specially-formatted Tcl_Obj, |
︙ | ︙ | |||
236 237 238 239 240 241 242 | int j, status; status = Tcl_ListObjGetElements(interp, mapObj, &nSpecs, &specs); if (status != TCL_OK) return NULL; if (nSpecs % 2 != 0) { | | | | | > | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | int j, status; status = Tcl_ListObjGetElements(interp, mapObj, &nSpecs, &specs); if (status != TCL_OK) return NULL; if (nSpecs % 2 != 0) { if (interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "State map must have an even number of elements", -1)); Tcl_SetErrorCode(interp, "TTK", "VALUE", "STATEMAP", NULL); } return 0; } for (j = 0; j < nSpecs; j += 2) { Ttk_StateSpec spec; if (Ttk_GetStateSpecFromObj(interp, specs[j], &spec) != TCL_OK) return NULL; |
︙ | ︙ |
Changes to generic/ttk/ttkTheme.c.
︙ | ︙ | |||
544 545 546 547 548 549 550 | StylePackageData *pkgPtr = GetStylePackageData(interp); Tcl_HashEntry *entryPtr; int newEntry; Theme *themePtr; entryPtr = Tcl_CreateHashEntry(&pkgPtr->themeTable, name, &newEntry); if (!newEntry) { | | | > | 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 | StylePackageData *pkgPtr = GetStylePackageData(interp); Tcl_HashEntry *entryPtr; int newEntry; Theme *themePtr; entryPtr = Tcl_CreateHashEntry(&pkgPtr->themeTable, name, &newEntry); if (!newEntry) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Theme %s already exists", name)); Tcl_SetErrorCode(interp, "TTK", "THEME", "EXISTS", NULL); return NULL; } /* * Initialize new theme: */ if (!parent) parent = pkgPtr->defaultTheme; |
︙ | ︙ | |||
587 588 589 590 591 592 593 | StylePackageData *pkgPtr, /* style package master record */ const char *name) /* theme name */ { Tcl_HashEntry *entryPtr; entryPtr = Tcl_FindHashEntry(&pkgPtr->themeTable, name); if (!entryPtr) { | | | > | 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 | StylePackageData *pkgPtr, /* style package master record */ const char *name) /* theme name */ { Tcl_HashEntry *entryPtr; entryPtr = Tcl_FindHashEntry(&pkgPtr->themeTable, name); if (!entryPtr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "theme \"%s\" doesn't exist", name)); Tcl_SetErrorCode(interp, "TTK", "LOOKUP", "THEME", name, NULL); return NULL; } return Tcl_GetHashValue(entryPtr); } /* |
︙ | ︙ | |||
871 872 873 874 875 876 877 | Ttk_ElementClass *elementClass; Tcl_HashEntry *entryPtr; int newEntry; if (specPtr->version != TK_STYLE_VERSION_2) { /* Version mismatch */ if (interp) { | | | | > > | > | 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 | Ttk_ElementClass *elementClass; Tcl_HashEntry *entryPtr; int newEntry; if (specPtr->version != TK_STYLE_VERSION_2) { /* Version mismatch */ if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Internal error: Ttk_RegisterElement (%s): invalid version", name)); Tcl_SetErrorCode(interp, "TTK", "REGISTER_ELEMENT", "VERSION", NULL); } return 0; } entryPtr = Tcl_CreateHashEntry(&theme->elementTable, name, &newEntry); if (!newEntry) { if (interp) { Tcl_ResetResult(interp); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Duplicate element %s", name)); Tcl_SetErrorCode(interp, "TTK", "REGISTER_ELEMENT", "DUPE", NULL); } return 0; } name = Tcl_GetHashKey(&theme->elementTable, entryPtr); elementClass = NewElementClass(name, specPtr, clientData); Tcl_SetHashValue(entryPtr, elementClass); |
︙ | ︙ | |||
1351 1352 1353 1354 1355 1356 1357 | name = Tcl_GetHashKey(&pkgPtr->themeTable, entryPtr); break; } entryPtr = Tcl_NextHashEntry(&search); } if (name == NULL) { | | | > | 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 | name = Tcl_GetHashKey(&pkgPtr->themeTable, entryPtr); break; } entryPtr = Tcl_NextHashEntry(&search); } if (name == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "error: failed to get theme name", -1)); Tcl_SetErrorCode(interp, "TTK", "THEME", "NAMELESS", NULL); return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewStringObj(name, -1)); return TCL_OK; } |
︙ | ︙ | |||
1487 1488 1489 1490 1491 1492 1493 | } elementName = Tcl_GetString(objv[3]); factoryName = Tcl_GetString(objv[4]); entryPtr = Tcl_FindHashEntry(&pkgPtr->factoryTable, factoryName); if (!entryPtr) { | > | > > | 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 | } elementName = Tcl_GetString(objv[3]); factoryName = Tcl_GetString(objv[4]); entryPtr = Tcl_FindHashEntry(&pkgPtr->factoryTable, factoryName); if (!entryPtr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "No such element type %s", factoryName)); Tcl_SetErrorCode(interp, "TTK", "LOOKUP", "ELEMENT_TYPE", factoryName, NULL); return TCL_ERROR; } recPtr = Tcl_GetHashValue(entryPtr); return recPtr->factory(interp, recPtr->clientData, theme, elementName, objc - 5, objv + 5); |
︙ | ︙ | |||
1546 1547 1548 1549 1550 1551 1552 | ++option; } Tcl_SetObjResult(interp, result); return TCL_OK; } | | > > | 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 | ++option; } Tcl_SetObjResult(interp, result); return TCL_OK; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "element %s not found", elementName)); Tcl_SetErrorCode(interp, "TTK", "LOOKUP", "ELEMENT", elementName, NULL); return TCL_ERROR; } /* + style layout name ?spec? */ static int StyleLayoutCmd( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) |
︙ | ︙ | |||
1570 1571 1572 1573 1574 1575 1576 | } layoutName = Tcl_GetString(objv[2]); if (objc == 3) { layoutTemplate = Ttk_FindLayoutTemplate(theme, layoutName); if (!layoutTemplate) { | | > > > | 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 | } layoutName = Tcl_GetString(objv[2]); if (objc == 3) { layoutTemplate = Ttk_FindLayoutTemplate(theme, layoutName); if (!layoutTemplate) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Layout %s not found", layoutName)); Tcl_SetErrorCode(interp, "TTK", "LOOKUP", "LAYOUT", layoutName, NULL); return TCL_ERROR; } Tcl_SetObjResult(interp, Ttk_UnparseLayoutTemplate(layoutTemplate)); } else { layoutTemplate = Ttk_ParseLayoutTemplate(interp, objv[3]); if (!layoutTemplate) { return TCL_ERROR; |
︙ | ︙ |
Changes to generic/ttk/ttkTreeview.c.
︙ | ︙ | |||
530 531 532 533 534 535 536 | return Tcl_GetHashValue(entryPtr); } /* Check for number: */ if (Tcl_GetIntFromObj(NULL, columnIDObj, &columnIndex) == TCL_OK) { if (columnIndex < 0 || columnIndex >= tv->tree.nColumns) { | < | | | < | < | | | < | | | | | > | 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 | return Tcl_GetHashValue(entryPtr); } /* Check for number: */ if (Tcl_GetIntFromObj(NULL, columnIDObj, &columnIndex) == TCL_OK) { if (columnIndex < 0 || columnIndex >= tv->tree.nColumns) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Column index %s out of bounds", Tcl_GetString(columnIDObj))); Tcl_SetErrorCode(interp, "TTK", "TREE", "COLBOUND", NULL); return NULL; } return tv->tree.columns + columnIndex; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Invalid column index %s", Tcl_GetString(columnIDObj))); Tcl_SetErrorCode(interp, "TTK", "TREE", "COLUMN", NULL); return NULL; } /* + FindColumn -- * Look up column by name, number, or display index. */ static TreeColumn *FindColumn( Tcl_Interp *interp, Treeview *tv, Tcl_Obj *columnIDObj) { int colno; if (sscanf(Tcl_GetString(columnIDObj), "#%d", &colno) == 1) { /* Display column specification, #n */ if (colno >= 0 && colno < tv->tree.nDisplayColumns) { return tv->tree.displayColumns[colno]; } /* else */ Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Column %s out of range", Tcl_GetString(columnIDObj))); Tcl_SetErrorCode(interp, "TTK", "TREE", "COLUMN", NULL); return NULL; } return GetColumn(interp, tv, columnIDObj); } /* + FindItem -- * Locates the item with the specified identifier in the tree. * If there is no such item, leaves an error message in interp. */ static TreeItem *FindItem( Tcl_Interp *interp, Treeview *tv, Tcl_Obj *itemNameObj) { const char *itemName = Tcl_GetString(itemNameObj); Tcl_HashEntry *entryPtr = Tcl_FindHashEntry(&tv->tree.items, itemName); if (!entryPtr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Item %s not found", itemName)); Tcl_SetErrorCode(interp, "TTK", "TREE", "ITEM", NULL); return 0; } return Tcl_GetHashValue(entryPtr); } /* + GetItemListFromObj -- * Parse a Tcl_Obj * as a list of items. |
︙ | ︙ | |||
1218 1219 1220 1221 1222 1223 1224 | tv->tree.columnOptionTable, objc, objv, tv->core.tkwin, &savedOptions,&mask) != TCL_OK) { return TCL_ERROR; } if (mask & READONLY_OPTION) { | | | > | 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 | tv->tree.columnOptionTable, objc, objv, tv->core.tkwin, &savedOptions,&mask) != TCL_OK) { return TCL_ERROR; } if (mask & READONLY_OPTION) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Attempt to change read-only option", -1)); Tcl_SetErrorCode(interp, "TTK", "TREE", "READONLY", NULL); goto error; } /* Propagate column width changes to overall widget request width, * but only if the widget is currently unmapped, in order to prevent * geometry jumping during interactive column resize. */ |
︙ | ︙ | |||
1908 1909 1910 1911 1912 1913 1914 | */ static int AncestryCheck( Tcl_Interp *interp, Treeview *tv, TreeItem *item, TreeItem *parent) { TreeItem *p = parent; while (p) { if (p == item) { | < | | | | | 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 | */ static int AncestryCheck( Tcl_Interp *interp, Treeview *tv, TreeItem *item, TreeItem *parent) { TreeItem *p = parent; while (p) { if (p == item) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Cannot insert %s as descendant of %s", ItemName(tv, item), ItemName(tv, parent))); Tcl_SetErrorCode(interp, "TTK", "TREE", "ANCESTRY", NULL); return 0; } p = p->parent; } return 1; } |
︙ | ︙ | |||
2314 2315 2316 2317 2318 2319 2320 | if (item) { Tcl_SetObjResult(interp, ItemID(tv, item)); } break; case I_COLUMN : if (colno >= 0) { | < < | | 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 | if (item) { Tcl_SetObjResult(interp, ItemID(tv, item)); } break; case I_COLUMN : if (colno >= 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf("#%d", colno)); } break; case I_ELEMENT : { Ttk_Layout layout = 0; DisplayItem displayItem; |
︙ | ︙ | |||
2484 2485 2486 2487 2488 2489 2490 | /* Return dictionary: */ Tcl_Obj *result = Tcl_NewListObj(0,0); Tcl_Obj *value; for (columnNumber=0; columnNumber<tv->tree.nColumns; ++columnNumber) { Tcl_ListObjIndex(interp, item->valuesObj, columnNumber, &value); if (value) { | | | > | > | 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 | /* Return dictionary: */ Tcl_Obj *result = Tcl_NewListObj(0,0); Tcl_Obj *value; for (columnNumber=0; columnNumber<tv->tree.nColumns; ++columnNumber) { Tcl_ListObjIndex(interp, item->valuesObj, columnNumber, &value); if (value) { Tcl_ListObjAppendElement(NULL, result, tv->tree.columns[columnNumber].idObj); Tcl_ListObjAppendElement(NULL, result, value); } } Tcl_SetObjResult(interp, result); return TCL_OK; } /* else -- get or set column */ if (!(column = FindColumn(interp, tv, objv[3]))) return TCL_ERROR; if (column == &tv->tree.column0) { /* @@@ Maybe set -text here instead? */ Tcl_SetObjResult(interp, Tcl_NewStringObj( "Display column #0 cannot be set", -1)); Tcl_SetErrorCode(interp, "TTK", "TREE", "COLUMN_0", NULL); return TCL_ERROR; } /* Note: we don't do any error checking in the list operations, * since item->valuesObj is guaranteed to be a list. */ columnNumber = column - tv->tree.columns; |
︙ | ︙ | |||
2583 2584 2585 2586 2587 2588 2589 2590 2591 | /* Get node name: * If -id supplied and does not already exist, use that; * Otherwise autogenerate new one. */ objc -= 4; objv += 4; if (objc >= 2 && !strcmp("-id", Tcl_GetString(objv[0]))) { const char *itemName = Tcl_GetString(objv[1]); entryPtr = Tcl_CreateHashEntry(&tv->tree.items, itemName, &isNew); if (!isNew) { | > > | > | 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 | /* Get node name: * If -id supplied and does not already exist, use that; * Otherwise autogenerate new one. */ objc -= 4; objv += 4; if (objc >= 2 && !strcmp("-id", Tcl_GetString(objv[0]))) { const char *itemName = Tcl_GetString(objv[1]); entryPtr = Tcl_CreateHashEntry(&tv->tree.items, itemName, &isNew); if (!isNew) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Item %s already exists", itemName)); Tcl_SetErrorCode(interp, "TTK", "TREE", "ITEM_EXISTS", NULL); return TCL_ERROR; } objc -= 2; objv += 2; } else { char idbuf[16]; do { ++tv->tree.serial; |
︙ | ︙ | |||
2642 2643 2644 2645 2646 2647 2648 | if (!(items = GetItemListFromObj(interp, tv, objv[2]))) { return TCL_ERROR; } /* Sanity-check */ for (i = 0; items[i]; ++i) { if (items[i] == tv->tree.root) { | > | > | 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 | if (!(items = GetItemListFromObj(interp, tv, objv[2]))) { return TCL_ERROR; } /* Sanity-check */ for (i = 0; items[i]; ++i) { if (items[i] == tv->tree.root) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Cannot detach root item", -1)); Tcl_SetErrorCode(interp, "TTK", "TREE", "ROOT", NULL); ckfree(items); return TCL_ERROR; } } for (i = 0; items[i]; ++i) { DetachItem(items[i]); |
︙ | ︙ | |||
2690 2691 2692 2693 2694 2695 2696 | } /* Sanity-check: */ for (i=0; items[i]; ++i) { if (items[i] == tv->tree.root) { ckfree(items); | > | > | 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 | } /* Sanity-check: */ for (i=0; items[i]; ++i) { if (items[i] == tv->tree.root) { ckfree(items); Tcl_SetObjResult(interp, Tcl_NewStringObj( "Cannot delete root item", -1)); Tcl_SetErrorCode(interp, "TTK", "TREE", "ROOT", NULL); return TCL_ERROR; } } /* Remove items from hash table. */ delq = 0; |
︙ | ︙ | |||
2881 2882 2883 2884 2885 2886 2887 | /* ASSERT: SLACKINVARIANT */ TtkRedisplayWidget(&tv->core); return TCL_OK; } left = right; } | < | | | | 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 | /* ASSERT: SLACKINVARIANT */ TtkRedisplayWidget(&tv->core); return TCL_OK; } left = right; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "column %s is not displayed", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TTK", "TREE", "COLUMN_INVISIBLE", NULL); return TCL_ERROR; } /*------------------------------------------------------------------------ * +++ Widget commands -- focus and selection */ |
︙ | ︙ | |||
2949 2950 2951 2952 2953 2954 2955 | if (objc != 4) { Tcl_WrongNumArgs(interp, 2, objv, "?add|remove|set|toggle items?"); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[2], selopStrings, | | < | 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 | if (objc != 4) { Tcl_WrongNumArgs(interp, 2, objv, "?add|remove|set|toggle items?"); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[2], selopStrings, "selection operation", 0, &selop) != TCL_OK) { return TCL_ERROR; } items = GetItemListFromObj(interp, tv, objv[3]); if (!items) { return TCL_ERROR; } |
︙ | ︙ | |||
3036 3037 3038 3039 3040 3041 3042 | unsigned long mask = Tk_CreateBinding(interp, bindingTable, tag, sequence, script, 0); /* Test mask to make sure event is supported: */ if (mask & (~TreeviewBindEventMask)) { Tk_DeleteBinding(interp, bindingTable, tag, sequence); | | | | | | 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 | unsigned long mask = Tk_CreateBinding(interp, bindingTable, tag, sequence, script, 0); /* Test mask to make sure event is supported: */ if (mask & (~TreeviewBindEventMask)) { Tk_DeleteBinding(interp, bindingTable, tag, sequence); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unsupported event %s\nonly key, button, motion, and" " virtual events supported", sequence)); Tcl_SetErrorCode(interp, "TTK", "TREE", "BIND_EVENTS", NULL); return TCL_ERROR; } } } return TCL_OK; } |
︙ | ︙ |
Changes to generic/ttk/ttkWidget.c.
︙ | ︙ | |||
436 437 438 439 440 441 442 | Tk_MakeWindowExist(tkwin); Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(tkwin), -1)); return TCL_OK; error: if (WidgetDestroyed(corePtr)) { | > | | 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | Tk_MakeWindowExist(tkwin); Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(tkwin), -1)); return TCL_OK; error: if (WidgetDestroyed(corePtr)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "widget has been destroyed", -1)); } else { Tk_DestroyWindow(tkwin); } Tcl_Release(corePtr); return TCL_ERROR; } |
︙ | ︙ | |||
630 631 632 633 634 635 636 | status = Tk_SetOptions(interp, recordPtr, corePtr->optionTable, objc - 2, objv + 2, corePtr->tkwin, &savedOptions, &mask); if (status != TCL_OK) return status; if (mask & READONLY_OPTION) { | | | > | | 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 | status = Tk_SetOptions(interp, recordPtr, corePtr->optionTable, objc - 2, objv + 2, corePtr->tkwin, &savedOptions, &mask); if (status != TCL_OK) return status; if (mask & READONLY_OPTION) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "attempt to change read-only option", -1)); Tk_RestoreSavedOptions(&savedOptions); return TCL_ERROR; } status = corePtr->widgetSpec->configureProc(interp, recordPtr, mask); if (status != TCL_OK) { Tk_RestoreSavedOptions(&savedOptions); return status; } Tk_FreeSavedOptions(&savedOptions); status = corePtr->widgetSpec->postConfigureProc(interp,recordPtr,mask); if (WidgetDestroyed(corePtr)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "widget has been destroyed", -1)); status = TCL_ERROR; } if (status != TCL_OK) { return status; } if (mask & (STYLE_CHANGED | GEOMETRY_CHANGED)) { |
︙ | ︙ |
Changes to library/choosedir.tcl.
︙ | ︙ | |||
182 183 184 185 186 187 188 | cd $old } else { set data(selectPath) [pwd] } } if {![winfo exists $data(-parent)]} { | > | | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | cd $old } else { set data(selectPath) [pwd] } } if {![winfo exists $data(-parent)]} { return -code error -errorcode [list TK LOOKUP WINDOW $data(-parent)] \ "bad window path name \"$data(-parent)\"" } } # Gets called when user presses Return in the "Selection" entry or presses OK. # proc ::tk::dialog::file::chooseDir::OkCmd {w} { upvar ::tk::dialog::file::[winfo name $w] data |
︙ | ︙ |
Changes to library/clrpick.tcl.
︙ | ︙ | |||
186 187 188 189 190 191 192 | # tclParseConfigSpec ::tk::dialog::color::$dataName $specs "" $argList if {$data(-title) eq ""} { set data(-title) " " } if {[catch {winfo rgb . $data(-initialcolor)} err]} { | > | > | | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | # tclParseConfigSpec ::tk::dialog::color::$dataName $specs "" $argList if {$data(-title) eq ""} { set data(-title) " " } if {[catch {winfo rgb . $data(-initialcolor)} err]} { return -code error -errorcode [list TK LOOKUP COLOR $data(-initialcolor)] \ $err } if {![winfo exists $data(-parent)]} { return -code error -errorcode [list TK LOOKUP WINDOW $data(-parent)] \ "bad window path name \"$data(-parent)\"" } } # ::tk::dialog::color::BuildDialog -- # # Build the dialog. # |
︙ | ︙ |
Changes to library/comdlg.tcl.
︙ | ︙ | |||
36 37 38 39 40 41 42 | proc tclParseConfigSpec {w specs flags argList} { upvar #0 $w data # 1: Put the specs in associative arrays for faster access # foreach spec $specs { if {[llength $spec] < 4} { | > | > | > | > | | 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 76 77 78 79 80 81 82 | proc tclParseConfigSpec {w specs flags argList} { upvar #0 $w data # 1: Put the specs in associative arrays for faster access # foreach spec $specs { if {[llength $spec] < 4} { return -code error -errorcode {TK VALUE CONFIG_SPEC} \ "\"spec\" should contain 5 or 4 elements" } set cmdsw [lindex $spec 0] set cmd($cmdsw) "" set rname($cmdsw) [lindex $spec 1] set rclass($cmdsw) [lindex $spec 2] set def($cmdsw) [lindex $spec 3] set verproc($cmdsw) [lindex $spec 4] } if {[llength $argList] & 1} { set cmdsw [lindex $argList end] if {![info exists cmd($cmdsw)]} { return -code error -errorcode [list TK LOOKUP OPTION $cmdsw] \ "bad option \"$cmdsw\": must be [tclListValidFlags cmd]" } return -code error -errorcode {TK VALUE_MISSING} \ "value for \"$cmdsw\" missing" } # 2: set the default values # foreach cmdsw [array names cmd] { set data($cmdsw) $def($cmdsw) } # 3: parse the argument list # foreach {cmdsw value} $argList { if {![info exists cmd($cmdsw)]} { return -code error -errorcode [list TK LOOKUP OPTION $cmdsw] \ "bad option \"$cmdsw\": must be [tclListValidFlags cmd]" } set data($cmdsw) $value } # Done! } |
︙ | ︙ | |||
116 117 118 119 120 121 122 | # within the same focus toplevel. Each toplevel can have only # one focus group, which is identified by the name of the # toplevel widget. # proc ::tk::FocusGroup_Create {t} { variable ::tk::Priv if {[winfo toplevel $t] ne $t} { | > | > | > | | 120 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 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | # within the same focus toplevel. Each toplevel can have only # one focus group, which is identified by the name of the # toplevel widget. # proc ::tk::FocusGroup_Create {t} { variable ::tk::Priv if {[winfo toplevel $t] ne $t} { return -code error -errorcode [list TK LOOKUP TOPLEVEL $t] \ "$t is not a toplevel window" } if {![info exists Priv(fg,$t)]} { set Priv(fg,$t) 1 set Priv(focus,$t) "" bind $t <FocusIn> [list tk::FocusGroup_In $t %W %d] bind $t <FocusOut> [list tk::FocusGroup_Out $t %W %d] bind $t <Destroy> [list tk::FocusGroup_Destroy $t %W] } } # ::tk::FocusGroup_BindIn -- # # Add a widget into the "FocusIn" list of the focus group. The $cmd will be # called when the widget is focused on by the user. # proc ::tk::FocusGroup_BindIn {t w cmd} { variable FocusIn variable ::tk::Priv if {![info exists Priv(fg,$t)]} { return -code error -errorcode [list TK LOOKUP FOCUS_GROUP $t] \ "focus group \"$t\" doesn't exist" } set FocusIn($t,$w) $cmd } # ::tk::FocusGroup_BindOut -- # # Add a widget into the "FocusOut" list of the focus group. The # $cmd will be called when the widget loses the focus (User # types Tab or click on another widget). # proc ::tk::FocusGroup_BindOut {t w cmd} { variable FocusOut variable ::tk::Priv if {![info exists Priv(fg,$t)]} { return -code error -errorcode [list TK LOOKUP FOCUS_GROUP $t] \ "focus group \"$t\" doesn't exist" } set FocusOut($t,$w) $cmd } # ::tk::FocusGroup_Destroy -- # # Cleans up when members of the focus group is deleted, or when the |
︙ | ︙ | |||
251 252 253 254 255 256 257 | # Process the string given by the -filetypes option of the file # dialogs. Similar to the C function TkGetFileFilters() on the Mac # and Windows platform. # proc ::tk::FDGetFileTypes {string} { foreach t $string { if {[llength $t] < 2 || [llength $t] > 3} { | > | > | | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | # Process the string given by the -filetypes option of the file # dialogs. Similar to the C function TkGetFileFilters() on the Mac # and Windows platform. # proc ::tk::FDGetFileTypes {string} { foreach t $string { if {[llength $t] < 2 || [llength $t] > 3} { return -code error -errorcode {TK VALUE FILE_TYPE} \ "bad file type \"$t\", should be \"typeName {extension ?extensions ...?} ?{macType ?macTypes ...?}?\"" } lappend fileTypes([lindex $t 0]) {*}[lindex $t 1] } set types {} foreach t $string { set label [lindex $t 0] set exts {} if {[info exists hasDoneType($label)]} { continue } # Validate each macType. This is to agree with the # behaviour of TkGetFileFilters(). This list may be # empty. foreach macType [lindex $t 2] { if {[string length $macType] != 4} { return -code error -errorcode {TK VALUE MAC_TYPE} \ "bad Macintosh file type \"$macType\"" } } set name "$label \(" set sep "" set doAppend 1 foreach ext $fileTypes($label) { |
︙ | ︙ |
Changes to library/console.tcl.
︙ | ︙ | |||
972 973 974 975 976 977 978 | # Calls: ::tk::console::ExpandBestMatch # # Returns: list containing longest unique match followed by all the # possible further matches proc ::tk::console::ExpandPathname str { set pwd [EvalAttached pwd] | | | | 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 | # Calls: ::tk::console::ExpandBestMatch # # Returns: list containing longest unique match followed by all the # possible further matches proc ::tk::console::ExpandPathname str { set pwd [EvalAttached pwd] if {[catch {EvalAttached [list cd [file dirname $str]]} err opt]} { return -options $opt $err } set dir [file tail $str] ## Check to see if it was known to be a directory and keep the trailing ## slash if so (file tail cuts it off) if {[string match */ $str]} { append dir / } |
︙ | ︙ |
Changes to library/dialog.tcl.
︙ | ︙ | |||
30 31 32 33 34 35 36 | proc ::tk_dialog {w title text bitmap default args} { global tcl_platform variable ::tk::Priv # Check that $default was properly given if {[string is integer -strict $default]} { if {$default >= [llength $args]} { | > | | | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | proc ::tk_dialog {w title text bitmap default args} { global tcl_platform variable ::tk::Priv # Check that $default was properly given if {[string is integer -strict $default]} { if {$default >= [llength $args]} { return -code error -errorcode {TK DIALOG BAD_DEFAULT} \ "default button index greater than number of buttons\ specified for tk_dialog" } } elseif {"" eq $default} { set default -1 } else { set default [lsearch -exact $args $default] } |
︙ | ︙ |
Changes to library/fontchooser.tcl.
︙ | ︙ | |||
92 93 94 95 96 97 98 | if {[llength $args] == 1} { set option [lindex $args 0] if {[string equal $option "-visible"]} { return [expr {[winfo exists $S(W)] && [winfo ismapped $S(W)]}] } elseif {[info exists S($option)]} { return $S($option) } | > | > | | 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 118 | if {[llength $args] == 1} { set option [lindex $args 0] if {[string equal $option "-visible"]} { return [expr {[winfo exists $S(W)] && [winfo ismapped $S(W)]}] } elseif {[info exists S($option)]} { return $S($option) } return -code error -errorcode [list TK LOOKUP OPTION $option] \ "bad option \"$option\": must be\ -command, -font, -parent, -title or -visible" } set cache [dict create -parent $S(-parent) -title $S(-title) \ -font $S(-font) -command $S(-command)] set r [tclParseConfigSpec [namespace which -variable S] $specs "" $args] if {![winfo exists $S(-parent)]} { set code [list TK LOOKUP WINDOW $S(-parent)] set err "bad window path name \"$S(-parent)\"" array set S $cache return -code error -errorcode $code $err } if {[string trim $S(-title)] eq ""} { set S(-title) [::msgcat::mc "Font"] } if {[winfo exists $S(W)] && [lsearch $args -font] != -1} { Init $S(-font) event generate $S(-parent) <<TkFontchooserFontChanged>> |
︙ | ︙ | |||
430 431 432 433 434 435 436 | ttk::scrollbar $f.vs -command [list $f.list yview] $f.list configure -yscrollcommand [list $f.vs set] grid $f.list $f.vs -sticky news grid rowconfigure $f 0 -weight 1 grid columnconfigure $f 0 -weight 1 interp hide {} $w interp alias {} $w {} $f.list | | | | 432 433 434 435 436 437 438 439 440 441 442 443 444 | ttk::scrollbar $f.vs -command [list $f.list yview] $f.list configure -yscrollcommand [list $f.vs set] grid $f.list $f.vs -sticky news grid rowconfigure $f 0 -weight 1 grid columnconfigure $f 0 -weight 1 interp hide {} $w interp alias {} $w {} $f.list } err opt]} { destroy $f return -options $opt $err } return $w } |
Changes to library/iconlist.tcl.
︙ | ︙ | |||
94 95 96 97 98 99 100 | 2 { lassign $args first last } 1 { set first [set last [lindex $args 0]] } default { | > | | | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | 2 { lassign $args first last } 1 { set first [set last [lindex $args 0]] } default { return -code error -errorcode {TCL WRONGARGS} \ "wrong # args: should be\ \"[lrange [info level 0] 0 1] first ?last?\"" } } set first [$w index $first] set last [$w index $last] if {$first > $last} { set tmp $first |
︙ | ︙ | |||
145 146 147 148 149 150 151 | 2 { lassign $args first last } 1 { set first [set last [lindex $args 0]] } default { | > | | | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | 2 { lassign $args first last } 1 { set first [set last [lindex $args 0]] } default { return -code error -errorcode {TCL WRONGARGS} \ "wrong # args: should be\ \"[lrange [info level 0] 0 1] first ?last?\"" } } set first [$w index $first] set last [$w index $last] if {$first > $last} { set tmp $first |
︙ | ︙ |
Changes to library/megawidget.tcl.
︙ | ︙ | |||
72 73 74 75 76 77 78 | method GetSpecs {} { return { {-takefocus takeFocus TakeFocus {}} } } | | > > > | > > > | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | method GetSpecs {} { return { {-takefocus takeFocus TakeFocus {}} } } method CreateHull {} { return -code error -errorcode {TCL OO ABSTRACT_METHOD} \ "method must be overridden" } method Create {} { return -code error -errorcode {TCL OO ABSTRACT_METHOD} \ "method must be overridden" } method WhenIdle {method args} { if {![info exists IdleCallbacks($method)]} { set IdleCallbacks($method) [after idle [list \ [namespace which my] DoWhenIdle $method $args]] } } |
︙ | ︙ |
Changes to library/menu.tcl.
︙ | ︙ | |||
249 250 251 252 253 254 255 | set menu [$w cget -menu] if {$menu eq ""} { return } set tearoff [expr {[tk windowingsystem] eq "x11" \ || [$menu cget -type] eq "tearoff"}] if {[string first $w $menu] != 0} { | > | | 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | set menu [$w cget -menu] if {$menu eq ""} { return } set tearoff [expr {[tk windowingsystem] eq "x11" \ || [$menu cget -type] eq "tearoff"}] if {[string first $w $menu] != 0} { return -code error -errorcode {TK MENUBUTTON POST_NONCHILD} \ "can't post $menu: it isn't a descendant of $w" } set cur $Priv(postedMb) if {$cur ne ""} { MenuUnpost {} } if {$::tk_strictMotif} { set Priv(cursor) [$w cget -cursor] |
︙ | ︙ | |||
316 317 318 319 320 321 322 | } PostOverPoint $menu $x $y if {$entry ne "" \ && [$menu entrycget $entry -state] ne "disabled"} { $menu activate $entry GenerateMenuSelect $menu } | | | 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | } PostOverPoint $menu $x $y if {$entry ne "" \ && [$menu entrycget $entry -state] ne "disabled"} { $menu activate $entry GenerateMenuSelect $menu } } right { set x [expr {[winfo rootx $w] + [winfo width $w]}] set y [expr {(2 * [winfo rooty $w] + [winfo height $w]) / 2}] set entry [MenuFindName $menu [$w cget -text]] if {[$w cget -indicatoron]} { if {$entry == [$menu index last]} { incr y [expr {-([$menu yposition $entry] \ |
︙ | ︙ | |||
349 350 351 352 353 354 355 | } PostOverPoint $menu $x $y [MenuFindName $menu [$w cget -text]] } else { PostOverPoint $menu [winfo rootx $w] [expr {[winfo rooty $w]+[winfo height $w]}] } } } | | < < | | 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | } PostOverPoint $menu $x $y [MenuFindName $menu [$w cget -text]] } else { PostOverPoint $menu [winfo rootx $w] [expr {[winfo rooty $w]+[winfo height $w]}] } } } } msg opt]} { # Error posting menu (e.g. bogus -postcommand). Unpost it and # reflect the error. MenuUnpost {} return -options $opt $msg } set Priv(tearoff) $tearoff if {$tearoff != 0} { focus $menu if {[winfo viewable $w]} { SaveGrabInfo $w |
︙ | ︙ |
Changes to library/msgbox.tcl.
︙ | ︙ | |||
107 108 109 110 111 112 113 | 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};" | | | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};" # ::tk::MessageBox -- # # Pops up a messagebox with an application-supplied message with # an icon and a list of buttons. This procedure will be called # by tk_messageBox if the platform does not have native # messagebox support, or if the particular type of messagebox is # not supported natively. |
︙ | ︙ | |||
149 150 151 152 153 154 155 | {-parent "" "" .} {-title "" "" " "} {-type "" "" "ok"} } tclParseConfigSpec $w $specs "" $args | | > | > | | 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 | {-parent "" "" .} {-title "" "" " "} {-type "" "" "ok"} } tclParseConfigSpec $w $specs "" $args if {$data(-icon) ni {info warning error question}} { return -code error -errorcode [list TK LOOKUP ICON $data(-icon)] \ "bad -icon value \"$data(-icon)\": must be error, info, question, or warning" } set windowingsystem [tk windowingsystem] if {$windowingsystem eq "aqua"} { switch -- $data(-icon) { "error" {set data(-icon) "stop"} "warning" {set data(-icon) "caution"} "info" {set data(-icon) "note"} } option add *Dialog*background systemDialogBackgroundActive widgetDefault option add *Dialog*Button.highlightBackground \ systemDialogBackgroundActive widgetDefault } if {![winfo exists $data(-parent)]} { return -code error -errorcode [list TK LOOKUP WINDOW $data(-parent)] \ "bad window path name \"$data(-parent)\"" } switch -- $data(-type) { abortretryignore { set names [list abort retry ignore] set labels [list &Abort &Retry &Ignore] set cancel abort |
︙ | ︙ | |||
200 201 202 203 204 205 206 | } yesnocancel { set names [list yes no cancel] set labels [list &Yes &No &Cancel] set cancel cancel } default { | > | | | | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | } yesnocancel { set names [list yes no cancel] set labels [list &Yes &No &Cancel] set cancel cancel } default { return -code error -errorcode [list TK LOOKUP DLG_TYPE $data(-type)] \ "bad -type value \"$data(-type)\": must be\ abortretryignore, ok, okcancel, retrycancel,\ yesno, or yesnocancel" } } set buttons {} foreach name $names lab $labels { lappend buttons [list $name -text [mc $lab]] } |
︙ | ︙ | |||
226 227 228 229 230 231 232 | foreach btn $buttons { if {[lindex $btn 0] eq $data(-default)} { set valid 1 break } } if {!$valid} { | > | | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | foreach btn $buttons { if {[lindex $btn 0] eq $data(-default)} { set valid 1 break } } if {!$valid} { return -code error -errorcode {TK MSGBOX DEFAULT} \ "invalid default button \"$data(-default)\"" } # 2. Set the dialog to be a child window of $parent # # if {$data(-parent) ne "."} { set w $data(-parent).__tk__messagebox |
︙ | ︙ |
Changes to library/palette.tcl.
︙ | ︙ | |||
32 33 34 35 36 37 38 | if {[llength $args] == 1} { set new(background) [lindex $args 0] } else { array set new $args } if {![info exists new(background)]} { | > | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | if {[llength $args] == 1} { set new(background) [lindex $args 0] } else { array set new $args } if {![info exists new(background)]} { return -code error -errorcode {TK SET_PALETTE BACKGROUND} \ "must specify a background color" } set bg [winfo rgb . $new(background)] if {![info exists new(foreground)]} { # Note that the range of each value in the triple returned by # [winfo rgb] is 0-65535, and your eyes are more sensitive to # green than to red, and more to red than to blue. foreach {r g b} $bg {break} |
︙ | ︙ |
Changes to library/safetk.tcl.
︙ | ︙ | |||
110 111 112 113 114 115 116 | } else { # Can't have a better one set nDisplay $display } } if {$nDisplay ne $display} { if {$displayGiven} { | > | < | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | } else { # Can't have a better one set nDisplay $display } } if {$nDisplay ne $display} { if {$displayGiven} { return -code error -errorcode {TK DISPLAY SAFE} \ "conflicting -display $display and -use $use -> $nDisplay" } else { set display $nDisplay } } } # Prepares the slave for tk with those parameters |
︙ | ︙ | |||
135 136 137 138 139 140 141 | if {[info exists tkInit($interpPath)]} { set value $tkInit($interpPath) Log $interpPath "TkInit called, returning \"$value\"" NOTICE return $value } else { Log $interpPath "TkInit called for interp with clearance:\ preventing Tk init" ERROR | | | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | if {[info exists tkInit($interpPath)]} { set value $tkInit($interpPath) Log $interpPath "TkInit called, returning \"$value\"" NOTICE return $value } else { Log $interpPath "TkInit called for interp with clearance:\ preventing Tk init" ERROR return -code error -errorcode {TK SAFE PERMISSION} "not allowed" } } # safe::allowTk -- # # Set tkInit(interpPath) to allow Tk to be initialized in # safe::TkInit. |
︙ | ︙ | |||
215 216 217 218 219 220 221 | } proc ::safe::tkTopLevel {slave display} { variable tkSafeId incr tkSafeId set w ".safe$tkSafeId" if {[catch {toplevel $w -screen $display -class SafeTk} msg]} { | | | | 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | } proc ::safe::tkTopLevel {slave display} { variable tkSafeId incr tkSafeId set w ".safe$tkSafeId" if {[catch {toplevel $w -screen $display -class SafeTk} msg]} { return -code error -errorcode {TK TOPLEVEL SAFE} \ "Unable to create toplevel for safe slave \"$slave\" ($msg)" } Log $slave "New toplevel $w" NOTICE set msg "Untrusted Tcl applet ($slave)" wm title $w $msg # Control frame (we must create a style for it) |
︙ | ︙ |
Changes to library/spinbox.tcl.
︙ | ︙ | |||
372 373 374 375 376 377 378 | set Priv(pressX) $x $w icursor [::tk::spinbox::ClosestGap $w $x] $w selection from insert if {"disabled" ne [$w cget -state]} {focus $w} $w selection clear } default { | > | | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | set Priv(pressX) $x $w icursor [::tk::spinbox::ClosestGap $w $x] $w selection from insert if {"disabled" ne [$w cget -state]} {focus $w} $w selection clear } default { return -code error -errorcode {TK SPINBOX UNKNOWN_ELEMENT} \ "unknown spinbox element \"$Priv(element)\"" } } } # ::tk::spinbox::ButtonUp -- # This procedure is invoked to handle button-1 releases in spinbox # widgets. |
︙ | ︙ |
Changes to library/tk.tcl.
︙ | ︙ | |||
209 210 211 212 213 214 215 | if {[tk windowingsystem] ne "win32"} { proc ::tk::GetSelection {w {sel PRIMARY}} { if {[catch { selection get -displayof $w -selection $sel -type UTF8_STRING } txt] && [catch { selection get -displayof $w -selection $sel } txt]} then { | > | > | | 209 210 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 | if {[tk windowingsystem] ne "win32"} { proc ::tk::GetSelection {w {sel PRIMARY}} { if {[catch { selection get -displayof $w -selection $sel -type UTF8_STRING } txt] && [catch { selection get -displayof $w -selection $sel } txt]} then { return -code error -errorcode {TK SELECTION NONE} \ "could not find default selection" } else { return $txt } } } else { proc ::tk::GetSelection {w {sel PRIMARY}} { if {[catch { selection get -displayof $w -selection $sel } txt]} then { return -code error -errorcode {TK SELECTION NONE} \ "could not find default selection" } else { return $txt } } } # ::tk::ScreenChanged -- |
︙ | ︙ |
Changes to library/tkfbox.tcl.
︙ | ︙ | |||
309 310 311 312 313 314 315 | set data(selectFile) $data(-initialfile) # 5. Parse the -filetypes option # set data(-filetypes) [::tk::FDGetFileTypes $data(-filetypes)] if {![winfo exists $data(-parent)]} { | > | | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | set data(selectFile) $data(-initialfile) # 5. Parse the -filetypes option # set data(-filetypes) [::tk::FDGetFileTypes $data(-filetypes)] if {![winfo exists $data(-parent)]} { return -code error -errorcode [list TK LOOKUP WINDOW $data(-parent)] \ "bad window path name \"$data(-parent)\"" } # Set -multiple to a one or zero value (not other boolean types like # "yes") so we can use it in tests more easily. if {$type eq "save"} { set data(-multiple) 0 } elseif {$data(-multiple)} { |
︙ | ︙ |
Changes to library/unsupported.tcl.
︙ | ︙ | |||
227 228 229 230 231 232 233 | # The old command name in the global namespace is aliased to the # new private name. proc ::tk::unsupported::ExposePrivateCommand {cmd} { variable PrivateCommands set cmds [array get PrivateCommands $cmd] if {[llength $cmds] == 0} { | > | | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | # The old command name in the global namespace is aliased to the # new private name. proc ::tk::unsupported::ExposePrivateCommand {cmd} { variable PrivateCommands set cmds [array get PrivateCommands $cmd] if {[llength $cmds] == 0} { return -code error -errorcode {TK EXPOSE_PRIVATE_COMMAND} \ "No compatibility support for \[$cmd]" } foreach {old new} $cmds { namespace eval :: [list interp alias {} $old {}] $new } } # ::tk::unsupported::ExposePrivateVariable -- |
︙ | ︙ | |||
254 255 256 257 258 259 260 | # The old variable name in the global namespace is aliased to the # new private name. proc ::tk::unsupported::ExposePrivateVariable {var} { variable PrivateVariables set vars [array get PrivateVariables $var] if {[llength $vars] == 0} { | > | | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | # The old variable name in the global namespace is aliased to the # new private name. proc ::tk::unsupported::ExposePrivateVariable {var} { variable PrivateVariables set vars [array get PrivateVariables $var] if {[llength $vars] == 0} { return -code error -errorcode {TK EXPOSE_PRIVATE_VARIABLE} \ "No compatibility support for \$$var" } namespace eval ::tk::mac {} foreach {old new} $vars { namespace eval :: [list upvar "#0" $new $old] } } |
Changes to library/xmfbox.tcl.
︙ | ︙ | |||
301 302 303 304 305 306 307 | # set data(-filetypes) [::tk::FDGetFileTypes $data(-filetypes)] if {![info exists data(filter)]} { set data(filter) * } if {![winfo exists $data(-parent)]} { | > | | 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | # set data(-filetypes) [::tk::FDGetFileTypes $data(-filetypes)] if {![info exists data(filter)]} { set data(filter) * } if {![winfo exists $data(-parent)]} { return -code error -errorcode [list TK LOOKUP WINDOW $data(-parent)] \ "bad window path name \"$data(-parent)\"" } } # ::tk::MotifFDialog_BuildUI -- # # Builds the UI components of the Motif file dialog. # |
︙ | ︙ |
Changes to macosx/tkMacOSXBitmap.c.
︙ | ︙ | |||
390 391 392 393 394 395 396 | Tcl_WrongNumArgs(interp, 1, objv, "name width height " "-file|-fileType|-osType|-systemType|-namedImage|-imageFile " "value"); goto end; } name = Tcl_GetStringFromObj(objv[i++], &len); if (!len) { | | > | > > > | > | | 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 | Tcl_WrongNumArgs(interp, 1, objv, "name width height " "-file|-fileType|-osType|-systemType|-namedImage|-imageFile " "value"); goto end; } name = Tcl_GetStringFromObj(objv[i++], &len); if (!len) { Tcl_SetObjResult(interp, Tcl_NewStringObj("empty bitmap name", -1)); Tcl_SetErrorCode(interp, "TK", "MACBITMAP", "BAD", NULL); goto end; } if (Tcl_GetIntFromObj(interp, objv[i++], &ib.width) != TCL_OK) { goto end; } if (Tcl_GetIntFromObj(interp, objv[i++], &ib.height) != TCL_OK) { goto end; } if (Tcl_GetIndexFromObj(interp, objv[i++], iconBitmapOptionStrings, "kind", TCL_EXACT, &ib.kind) != TCL_OK) { goto end; } value = Tcl_GetStringFromObj(objv[i++], &len); if (!len) { Tcl_SetObjResult(interp, Tcl_NewStringObj("empty bitmap value", -1)); Tcl_SetErrorCode(interp, "TK", "MACBITMAP", "EMPTY", NULL); goto end; } #if 0 if ((kind == ICON_TYPE || kind == ICON_SYSTEM)) { Tcl_DString ds; Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman"); Tcl_UtfToExternalDString(encoding, value, -1, &ds); len = Tcl_DStringLength(&ds); Tcl_DStringFree(&ds); Tcl_FreeEncoding(encoding); if (len > 4) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid bitmap value", -1)); Tcl_SetErrorCode(interp, "TK", "MACBITMAP", "INVALID", NULL); goto end; } } #endif ib.value = ckalloc(len + 1); strcpy(ib.value, value); if (!iconBitmapTable.buckets) { Tcl_InitHashTable(&iconBitmapTable, TCL_STRING_KEYS); } hPtr = Tcl_CreateHashEntry(&iconBitmapTable, name, &isNew); if (!isNew) { iconBitmap = Tcl_GetHashValue(hPtr); ckfree(iconBitmap->value); } else { iconBitmap = ckalloc(sizeof(IconBitmap)); Tcl_SetHashValue(hPtr, iconBitmap); } *iconBitmap = ib; result = TCL_OK; end: return result; } /* * Local Variables: * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXClipboard.c.
︙ | ︙ | |||
133 134 135 136 137 138 139 | NSStringPboardType]]; if (type) { string = [pb stringForType:type]; } result = proc(clientData, interp, string ? [string UTF8String] : ""); } else { | | | > | > | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | NSStringPboardType]]; if (type) { string = [pb stringForType:type]; } result = proc(clientData, interp, string ? [string UTF8String] : ""); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s selection doesn't exist or form \"%s\" not defined", Tk_GetAtomName(tkwin, selection), Tk_GetAtomName(tkwin, target))); Tcl_SetErrorCode(interp, "TK", "SELECTION", "EXISTS", NULL); } return result; } /* *---------------------------------------------------------------------- * |
︙ | ︙ |
Changes to macosx/tkMacOSXCursor.c.
︙ | ︙ | |||
387 388 389 390 391 392 393 | macCursorPtr->type = 0; FindCursorByName(macCursorPtr, argv[0]); } ckfree(argv); } if (!macCursorPtr || (!macCursorPtr->macCursor && macCursorPtr->type != NONE)) { | > | > | 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | macCursorPtr->type = 0; FindCursorByName(macCursorPtr, argv[0]); } ckfree(argv); } if (!macCursorPtr || (!macCursorPtr->macCursor && macCursorPtr->type != NONE)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad cursor spec \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "CURSOR", NULL); if (macCursorPtr) { ckfree(macCursorPtr); macCursorPtr = NULL; } } return (TkCursor *) macCursorPtr; } |
︙ | ︙ |
Changes to macosx/tkMacOSXDialog.c.
︙ | ︙ | |||
253 254 255 256 257 258 259 | int i; NSColor *color = nil, *initialColor = nil; NSColorPanel *colorPanel; NSInteger returnCode, numberOfComponents = 0; for (i = 1; i < objc; i += 2) { int index; | | > | < | | 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | int i; NSColor *color = nil, *initialColor = nil; NSColorPanel *colorPanel; NSInteger returnCode, numberOfComponents = 0; for (i = 1; i < objc; i += 2) { int index; const char *value; if (Tcl_GetIndexFromObj(interp, objv[i], colorOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "COLORDIALOG", "VALUE", NULL); goto end; } value = Tcl_GetString(objv[i + 1]); switch (index) { case COLOR_INITIAL: { XColor *colorPtr; |
︙ | ︙ | |||
374 375 376 377 378 379 380 | TkInitFileFilters(&fl); for (i = 1; i < objc; i += 2) { if (Tcl_GetIndexFromObj(interp, objv[i], openOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { | > | | | 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | TkInitFileFilters(&fl); for (i = 1; i < objc; i += 2) { if (Tcl_GetIndexFromObj(interp, objv[i], openOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL); goto end; } switch (index) { case OPEN_DEFAULT: break; case OPEN_FILETYPES: if (TkGetFileFilters(interp, &fl, objv[i + 1], 0) != TCL_OK) { |
︙ | ︙ | |||
552 553 554 555 556 557 558 | TkInitFileFilters(&fl); for (i = 1; i < objc; i += 2) { if (Tcl_GetIndexFromObj(interp, objv[i], saveOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { | > | < | | 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | TkInitFileFilters(&fl); for (i = 1; i < objc; i += 2) { if (Tcl_GetIndexFromObj(interp, objv[i], saveOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL); goto end; } switch (index) { case SAVE_DEFAULT: str = Tcl_GetStringFromObj(objv[i + 1], &len); while (*str && (*str == '*' || *str == '.')) { str++; |
︙ | ︙ | |||
722 723 724 725 726 727 728 | for (i = 1; i < objc; i += 2) { if (Tcl_GetIndexFromObj(interp, objv[i], chooseOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { | > | | | 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 | for (i = 1; i < objc; i += 2) { if (Tcl_GetIndexFromObj(interp, objv[i], chooseOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "DIRDIALOG", "VALUE", NULL); goto end; } switch (index) { case CHOOSE_INITDIR: str = Tcl_GetStringFromObj(objv[i + 1], &len); if (len) { directory = [[[NSString alloc] initWithUTF8String:str] |
︙ | ︙ | |||
938 939 940 941 942 943 944 | typeIndex = TYPE_OK; for (i = 1; i < objc; i += 2) { if (Tcl_GetIndexFromObj(interp, objv[i], alertOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { | > | | | 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 | typeIndex = TYPE_OK; for (i = 1; i < objc; i += 2) { if (Tcl_GetIndexFromObj(interp, objv[i], alertOptionStrings, "option", TCL_EXACT, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "MSGBOX", "VALUE", NULL); goto end; } switch (index) { case ALERT_DEFAULT: /* * Need to postpone processing of this option until we are sure to * know the '-type' as well. |
︙ | ︙ | |||
1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 | */ defaultNativeButtonIndex = alertButtonIndexAndTypeToNativeButtonIndex[typeIndex][index]; if (!defaultNativeButtonIndex) { Tcl_SetObjResult(interp, Tcl_NewStringObj("Illegal default option", -1)); goto end; } } [alert setIcon:[NSApp applicationIconImage]]; [alert setAlertStyle:alertStyles[iconIndex]]; i = 0; while (i < 3 && alertButtonNames[typeIndex][i]) { | > | 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 | */ defaultNativeButtonIndex = alertButtonIndexAndTypeToNativeButtonIndex[typeIndex][index]; if (!defaultNativeButtonIndex) { Tcl_SetObjResult(interp, Tcl_NewStringObj("Illegal default option", -1)); Tcl_SetErrorCode(interp, "TK", "MSGBOX", "DEFAULT", NULL); goto end; } } [alert setIcon:[NSApp applicationIconImage]]; [alert setAlertStyle:alertStyles[iconIndex]]; i = 0; while (i < 3 && alertButtonNames[typeIndex][i]) { |
︙ | ︙ | |||
1362 1363 1364 1365 1366 1367 1368 | * With one option and no arg, return the current value. */ Tcl_SetObjResult(interp, FontchooserCget(fcdPtr, optionIndex)); return TCL_OK; } if (i + 1 == objc) { | | | > | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | | 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 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 1465 1466 1467 1468 1469 1470 1471 1472 | * With one option and no arg, return the current value. */ Tcl_SetObjResult(interp, FontchooserCget(fcdPtr, optionIndex)); return TCL_OK; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "FONTDIALOG", "VALUE", NULL); return TCL_ERROR; } switch (optionIndex) { case FontchooserVisible: { const char *msg = "cannot change read-only option " "\"-visible\": use the show or hide command"; Tcl_SetObjResult(interp, Tcl_NewStringObj(msg, -1)); Tcl_SetErrorCode(interp, "TK", "FONTDIALOG", "READONLY", NULL); return TCL_ERROR; } case FontchooserParent: { Tk_Window parent = Tk_NameToWindow(interp, Tcl_GetString(objv[i+1]), tkwin); if (parent == None) { return TCL_ERROR; } if (fcdPtr->parent) { Tk_DeleteEventHandler(fcdPtr->parent, StructureNotifyMask, FontchooserParentEventHandler, fcdPtr); } fcdPtr->parent = parent; Tk_CreateEventHandler(fcdPtr->parent, StructureNotifyMask, FontchooserParentEventHandler, fcdPtr); break; } case FontchooserTitle: if (fcdPtr->titleObj) { Tcl_DecrRefCount(fcdPtr->titleObj); } Tcl_GetStringFromObj(objv[i+1], &len); if (len) { fcdPtr->titleObj = objv[i+1]; if (Tcl_IsShared(fcdPtr->titleObj)) { fcdPtr->titleObj = Tcl_DuplicateObj(fcdPtr->titleObj); } Tcl_IncrRefCount(fcdPtr->titleObj); } else { fcdPtr->titleObj = NULL; } break; case FontchooserFont: Tcl_GetStringFromObj(objv[i+1], &len); if (len) { Tk_Font f = Tk_AllocFontFromObj(interp, tkwin, objv[i+1]); if (!f) { return TCL_ERROR; } [fontPanelFont autorelease]; fontPanelFont = [TkMacOSXNSFontForFont(f) retain]; [fontPanelFontAttributes setDictionary: TkMacOSXNSFontAttributesForFont(f)]; [fontPanelFontAttributes removeObjectsForKeys:[NSArray arrayWithObjects:NSFontAttributeName, NSLigatureAttributeName, NSKernAttributeName, nil]]; Tk_FreeFont(f); } else { [fontPanelFont release]; fontPanelFont = nil; [fontPanelFontAttributes removeAllObjects]; } NSFontManager *fm = [NSFontManager sharedFontManager]; NSFontPanel *fp = [fm fontPanel:NO]; [fp setPanelFont:fontPanelFont isMultiple:NO]; [fm setSelectedFont:fontPanelFont isMultiple:NO]; [fm setSelectedAttributes:fontPanelFontAttributes isMultiple:NO]; if ([fp isVisible]) { TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged"); } break; case FontchooserCmd: if (fcdPtr->cmdObj) { Tcl_DecrRefCount(fcdPtr->cmdObj); } Tcl_GetStringFromObj(objv[i+1], &len); if (len) { fcdPtr->cmdObj = objv[i+1]; if (Tcl_IsShared(fcdPtr->cmdObj)) { fcdPtr->cmdObj = Tcl_DuplicateObj(fcdPtr->cmdObj); } Tcl_IncrRefCount(fcdPtr->cmdObj); } else { fcdPtr->cmdObj = NULL; } break; } } return TCL_OK; } /* * ---------------------------------------------------------------------- |
︙ | ︙ |
Changes to macosx/tkMacOSXEmbed.c.
︙ | ︙ | |||
204 205 206 207 208 209 210 | { TkWindow *winPtr = (TkWindow *) tkwin; TkWindow *usePtr; MacDrawable *parent, *macWin; Container *containerPtr; if (winPtr->window != None) { | > | | | < | | > > | < | 204 205 206 207 208 209 210 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 237 238 239 240 241 242 243 | { TkWindow *winPtr = (TkWindow *) tkwin; TkWindow *usePtr; MacDrawable *parent, *macWin; Container *containerPtr; if (winPtr->window != None) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't modify container after widget is created", -1)); Tcl_SetErrorCode(interp, "TK", "EMBED", "POST_CREATE", NULL); return TCL_ERROR; } /* * Decode the container pointer, and look for it among the list of * available containers. * * N.B. For now, we are limiting the containers to be in the same Tk * application as tkwin, since otherwise they would not be in our list of * containers. */ if (Tcl_GetInt(interp, string, (int*) &parent) != TCL_OK) { return TCL_ERROR; } usePtr = (TkWindow *) Tk_IdToWindow(winPtr->display, (Window) parent); if (usePtr != NULL && !(usePtr->flags & TK_CONTAINER)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" doesn't have -container option set", usePtr->pathName)); Tcl_SetErrorCode(interp, "TK", "EMBED", "CONTAINER", NULL); return TCL_ERROR; } /* * The code below can probably be simplified given we have already * discovered 'usePtr' above. */ |
︙ | ︙ | |||
301 302 303 304 305 306 307 | * Now check whether it is embedded in another Tk widget. If not (the * first case below) we see if there is an in-process embedding handler * registered, and if so, let that fill in the rest of the macWin. */ if (containerPtr == NULL) { /* | | | | > > | 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 | * Now check whether it is embedded in another Tk widget. If not (the * first case below) we see if there is an in-process embedding handler * registered, and if so, let that fill in the rest of the macWin. */ if (containerPtr == NULL) { /* * If someone has registered an in-process embedding handler, then * see if it can handle this window... */ if (tkMacOSXEmbedHandler == NULL || tkMacOSXEmbedHandler->registerWinProc((long) parent, (Tk_Window) winPtr) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "The window ID %s does not correspond to a valid Tk Window", string)); Tcl_SetErrorCode(interp, "TK", "EMBED", "HANDLE", NULL); return TCL_ERROR; } containerPtr = ckalloc(sizeof(Container)); containerPtr->parentPtr = NULL; containerPtr->embedded = (Window) macWin; |
︙ | ︙ |
Changes to macosx/tkMacOSXWindowEvent.c.
︙ | ︙ | |||
699 700 701 702 703 704 705 | protPtr = protPtr->nextPtr) { if (protocol == protPtr->protocol) { Tcl_Preserve(protPtr); interp = protPtr->interp; Tcl_Preserve(interp); result = Tcl_GlobalEval(interp, protPtr->command); if (result != TCL_OK) { | < | > | < | 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 | protPtr = protPtr->nextPtr) { if (protocol == protPtr->protocol) { Tcl_Preserve(protPtr); interp = protPtr->interp; Tcl_Preserve(interp); result = Tcl_GlobalEval(interp, protPtr->command); if (result != TCL_OK) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( "\n (command for \"%s\" window manager protocol)", Tk_GetAtomName((Tk_Window) winPtr, protocol))); Tcl_BackgroundError(interp); } Tcl_Release(interp); Tcl_Release(protPtr); return; } } |
︙ | ︙ |
Changes to macosx/tkMacOSXWm.c.
︙ | ︙ | |||
47 48 49 50 51 52 53 | | kWindowHideOnFullScreenAttribute | kWindowNoConstrainAttribute \ | kWindowNoShadowAttribute | kWindowLiveResizeAttribute \ | kWindowOpaqueForEventsAttribute | kWindowIgnoreClicksAttribute \ | kWindowDoesNotCycleAttribute | tkWindowDoesNotHideAttribute \ | tkCanJoinAllSpacesAttribute | tkMoveToActiveSpaceAttribute \ | tkNonactivatingPanelAttribute | tkHUDWindowAttribute) | < | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | | kWindowHideOnFullScreenAttribute | kWindowNoConstrainAttribute \ | kWindowNoShadowAttribute | kWindowLiveResizeAttribute \ | kWindowOpaqueForEventsAttribute | kWindowIgnoreClicksAttribute \ | kWindowDoesNotCycleAttribute | tkWindowDoesNotHideAttribute \ | tkCanJoinAllSpacesAttribute | tkMoveToActiveSpaceAttribute \ | tkNonactivatingPanelAttribute | tkHUDWindowAttribute) /*Objects for use in setting background color and opacity of window.*/ NSColor *colorName = NULL; NSString *opaqueTag = NULL; static const struct { const UInt64 validAttrs, defaultAttrs, forceOnAttrs, forceOffAttrs; int flags; NSUInteger styleMask; |
︙ | ︙ | |||
403 404 405 406 407 408 409 410 411 412 413 414 415 416 | if (wmPtr->gridWin) { [macWindow setResizeIncrements:NSMakeSize(wmPtr->widthInc, wmPtr->heightInc)]; } else if (wmPtr->sizeHintsFlags & PAspect && wmPtr->minAspect.x == wmPtr->maxAspect.x && wmPtr->minAspect.y == wmPtr->maxAspect.y) { NSSize aspect = NSMakeSize(wmPtr->minAspect.x, wmPtr->minAspect.y); CGFloat ratio = aspect.width/aspect.height; [macWindow setContentAspectRatio:aspect]; if ((CGFloat)minWidth/(CGFloat)minHeight > ratio) { minHeight = lround(minWidth / ratio); } else { minWidth = lround(minHeight * ratio); } if ((CGFloat)maxWidth/(CGFloat)maxHeight > ratio) { | > | 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | if (wmPtr->gridWin) { [macWindow setResizeIncrements:NSMakeSize(wmPtr->widthInc, wmPtr->heightInc)]; } else if (wmPtr->sizeHintsFlags & PAspect && wmPtr->minAspect.x == wmPtr->maxAspect.x && wmPtr->minAspect.y == wmPtr->maxAspect.y) { NSSize aspect = NSMakeSize(wmPtr->minAspect.x, wmPtr->minAspect.y); CGFloat ratio = aspect.width/aspect.height; [macWindow setContentAspectRatio:aspect]; if ((CGFloat)minWidth/(CGFloat)minHeight > ratio) { minHeight = lround(minWidth / ratio); } else { minWidth = lround(minHeight * ratio); } if ((CGFloat)maxWidth/(CGFloat)maxHeight > ratio) { |
︙ | ︙ | |||
454 455 456 457 458 459 460 | *---------------------------------------------------------------------- */ static TkWindow* FrontWindowAtPoint( int x, int y) { | < > < | 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 | *---------------------------------------------------------------------- */ static TkWindow* FrontWindowAtPoint( int x, int y) { NSPoint p = NSMakePoint(x, tkMacOSXZeroScreenHeight - y); NSWindow *win = nil; NSInteger windowCount; NSInteger *windowNumbers; NSCountWindows(&windowCount); if (windowCount) { windowNumbers = ckalloc(windowCount * sizeof(NSInteger)); NSWindowList(windowCount, windowNumbers); for (NSInteger index = 0; index < windowCount; index++) { NSWindow *w = [NSApp windowWithWindowNumber:windowNumbers[index]]; if (w && NSMouseInRect(p, [w frame], NO)) { win = w; break; } } ckfree(windowNumbers); } return (win ? TkMacOSXGetTkWindow(win) : NULL); } /* *---------------------------------------------------------------------- * * TkWmNewWindow -- * * This procedure is invoked whenever a new top-level window is created. |
︙ | ︙ | |||
545 546 547 548 549 550 551 | wmPtr->cmapCount = 0; wmPtr->configX = 0; wmPtr->configY = 0; wmPtr->configWidth = -1; wmPtr->configHeight = -1; wmPtr->vRoot = None; wmPtr->protPtr = NULL; | | < | 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 | wmPtr->cmapCount = 0; wmPtr->configX = 0; wmPtr->configY = 0; wmPtr->configWidth = -1; wmPtr->configHeight = -1; wmPtr->vRoot = None; wmPtr->protPtr = NULL; wmPtr->commandObj = NULL; wmPtr->clientMachine = NULL; wmPtr->flags = WM_NEVER_MAPPED; wmPtr->macClass = kDocumentWindowClass; wmPtr->attributes = macClassAttrs[kDocumentWindowClass].defaultAttrs; wmPtr->scrollWinPtr = NULL; wmPtr->menuPtr = NULL; wmPtr->window = nil; winPtr->wmInfoPtr = wmPtr; UpdateVRootGeometry(wmPtr); /* * Tk must monitor structure events for top-level windows, in order to * detect size and position changes caused by window managers. */ Tk_CreateEventHandler((Tk_Window) winPtr, StructureNotifyMask, |
︙ | ︙ | |||
749 750 751 752 753 754 755 | } if (wmPtr->iconFor != NULL) { wmPtr2 = ((TkWindow *) wmPtr->iconFor)->wmInfoPtr; wmPtr2->icon = NULL; wmPtr2->hints.flags &= ~IconWindowHint; } while (wmPtr->protPtr != NULL) { | | < | | > | | 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 781 782 783 784 785 786 787 788 789 790 | } if (wmPtr->iconFor != NULL) { wmPtr2 = ((TkWindow *) wmPtr->iconFor)->wmInfoPtr; wmPtr2->icon = NULL; wmPtr2->hints.flags &= ~IconWindowHint; } while (wmPtr->protPtr != NULL) { ProtocolHandler *protPtr = wmPtr->protPtr; wmPtr->protPtr = protPtr->nextPtr; Tcl_EventuallyFree(protPtr, TCL_DYNAMIC); } if (wmPtr->commandObj != NULL) { Tcl_DecrRefCount(wmPtr->commandObj); } if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); } if (wmPtr->flags & WM_UPDATE_PENDING) { Tk_CancelIdleCall(UpdateGeometryInfo, winPtr); } /* * Delete the Mac window and remove it from the windowTable. The window * could be nil if the window was never mapped. However, we don't do this * for embedded windows, they don't go in the window list, and they do not * own their portPtr's. */ NSWindow *window = wmPtr->window; if (window && !Tk_IsEmbedded(winPtr) ) { [[window parentWindow] removeChildWindow:window]; [window close]; TkMacOSXUnregisterMacWindow(window); if (winPtr->window) { ((MacDrawable *) winPtr->window)->view = nil; } TkMacOSXMakeCollectableAndRelease(wmPtr->window); } ckfree(wmPtr); winPtr->wmInfoPtr = NULL; } |
︙ | ︙ | |||
871 872 873 874 875 876 877 | wrongNumArgs: Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg ...?"); return TCL_ERROR; } argv1 = Tcl_GetStringFromObj(objv[1], &length); if ((argv1[0] == 't') && (strncmp(argv1, "tracing", length) == 0) | | | | | > > | 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 | wrongNumArgs: Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg ...?"); return TCL_ERROR; } argv1 = Tcl_GetStringFromObj(objv[1], &length); if ((argv1[0] == 't') && (strncmp(argv1, "tracing", length) == 0) && (length >= 3)) { if ((objc != 2) && (objc != 3)) { Tcl_WrongNumArgs(interp, 2, objv, "?boolean?"); return TCL_ERROR; } if (objc == 2) { Tcl_SetObjResult(interp, Tcl_NewBooleanObj(wmTracing)); return TCL_OK; } return Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing); } if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, &index) != TCL_OK) { return TCL_ERROR; } if (objc < 3) { goto wrongNumArgs; } if (TkGetWindowFromObj(interp, tkwin, objv[2], (Tk_Window *) &winPtr) != TCL_OK) { return TCL_ERROR; } if (!Tk_IsTopLevel(winPtr) && (index != WMOPT_MANAGE) && (index != WMOPT_FORGET)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't a top-level window", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TOPLEVEL", winPtr->pathName, NULL); return TCL_ERROR; } switch ((enum options) index) { case WMOPT_ASPECT: return WmAspectCmd(tkwin, winPtr, interp, objc, objv); case WMOPT_ATTRIBUTES: |
︙ | ︙ | |||
1009 1010 1011 1012 1013 1014 1015 | if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?minNumer minDenom maxNumer maxDenom?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & PAspect) { | | | | > | | > | > | 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 | if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?minNumer minDenom maxNumer maxDenom?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & PAspect) { Tcl_Obj *results[4]; results[0] = Tcl_NewIntObj(wmPtr->minAspect.x); results[1] = Tcl_NewIntObj(wmPtr->minAspect.y); results[2] = Tcl_NewIntObj(wmPtr->maxAspect.x); results[3] = Tcl_NewIntObj(wmPtr->maxAspect.y); Tcl_SetObjResult(interp, Tcl_NewListObj(4, results)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->sizeHintsFlags &= ~PAspect; } else { if ((Tcl_GetIntFromObj(interp, objv[3], &numer1) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &denom1) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[5], &numer2) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[6], &denom2) != TCL_OK)) { return TCL_ERROR; } if ((numer1 <= 0) || (denom1 <= 0) || (numer2 <= 0) || (denom2 <= 0)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "aspect number can't be <= 0", -1)); Tcl_SetErrorCode(interp, "TK", "WM", "ASPECT", NULL); return TCL_ERROR; } wmPtr->minAspect.x = numer1; wmPtr->minAspect.y = denom1; wmPtr->maxAspect.x = numer2; wmPtr->maxAspect.y = denom2; wmPtr->sizeHintsFlags |= PAspect; |
︙ | ︙ | |||
1269 1270 1271 1272 1273 1274 1275 | } if (!TkMacOSXHostToplevelExists(winPtr)) { TkMacOSXMakeRealWindowExist(winPtr); } macWindow = TkMacOSXDrawableWindow(winPtr->window); if (objc == 3) { /* wm attributes $win */ | | | | | | | 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 | } if (!TkMacOSXHostToplevelExists(winPtr)) { TkMacOSXMakeRealWindowExist(winPtr); } macWindow = TkMacOSXDrawableWindow(winPtr->window); if (objc == 3) { /* wm attributes $win */ Tcl_Obj *result = Tcl_NewObj(); for (attribute = 0; attribute < _WMATT_LAST_ATTRIBUTE; ++attribute) { Tcl_ListObjAppendElement(NULL, result, Tcl_NewStringObj(WmAttributeNames[attribute], -1)); Tcl_ListObjAppendElement(NULL, result, WmGetAttribute(winPtr, macWindow, attribute)); } Tcl_SetObjResult(interp, result); } else if (objc == 4) { /* wm attributes $win -attribute */ if (Tcl_GetIndexFromObj(interp, objv[3], WmAttributeNames, "attribute", 0, &attribute) != TCL_OK) { return TCL_ERROR; } Tcl_SetObjResult(interp, WmGetAttribute(winPtr, macWindow, attribute)); } else if ((objc - 3) % 2 == 0) { /* wm attributes $win -att value... */ int i; for (i = 3; i < objc; i += 2) { if (Tcl_GetIndexFromObj(interp, objv[i], WmAttributeNames, "attribute", 0, &attribute) != TCL_OK) { return TCL_ERROR; } if (WmSetAttribute(winPtr, macWindow, interp, attribute, objv[i+1]) != TCL_OK) { return TCL_ERROR; } } |
︙ | ︙ | |||
1339 1340 1341 1342 1343 1344 1345 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->clientMachine != NULL) { | > | | 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->clientMachine != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->clientMachine, -1)); } return TCL_OK; } argv3 = Tcl_GetStringFromObj(objv[3], &length); if (argv3[0] == 0) { if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); |
︙ | ︙ | |||
1385 1386 1387 1388 1389 1390 1391 | 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; | | < | > | > | > | | 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 | 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 **cmapList, *winPtr2; int i, windowObjc, gotToplevel = 0; Tcl_Obj **windowObjv, *resultObj; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?windowList?"); return TCL_ERROR; } if (objc == 3) { Tk_MakeWindowExist((Tk_Window) winPtr); resultObj = Tcl_NewObj(); for (i = 0; i < wmPtr->cmapCount; i++) { if ((i == (wmPtr->cmapCount-1)) && (wmPtr->flags & WM_ADDED_TOPLEVEL_COLORMAP)) { break; } Tcl_ListObjAppendElement(NULL, resultObj, TkNewWindowObj((Tk_Window) wmPtr->cmapList[i])); } Tcl_SetObjResult(interp, resultObj); return TCL_OK; } if (Tcl_ListObjGetElements(interp, objv[3], &windowObjc, &windowObjv) != TCL_OK) { return TCL_ERROR; } cmapList = ckalloc((windowObjc+1) * sizeof(TkWindow*)); for (i = 0; i < windowObjc; i++) { if (TkGetWindowFromObj(interp, tkwin, windowObjv[i], (Tk_Window *) &winPtr2) != TCL_OK) { ckfree(cmapList); |
︙ | ︙ | |||
1472 1473 1474 1475 1476 1477 1478 | 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; | < | < | < | < | < | | | | | | > | | | 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 | 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; int len; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?value?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->commandObj != NULL) { Tcl_SetObjResult(interp, wmPtr->commandObj); } return TCL_OK; } if (Tcl_GetString(objv[3])[0] == 0) { if (wmPtr->commandObj != NULL) { Tcl_DecrRefCount(wmPtr->commandObj); wmPtr->commandObj = NULL; } return TCL_OK; } if (Tcl_ListObjLength(interp, objv[3], &len) != TCL_OK) { return TCL_ERROR; } if (wmPtr->commandObj != NULL) { Tcl_DecrRefCount(wmPtr->commandObj); } wmPtr->commandObj = Tcl_DuplicateObj(objv[3]); Tcl_IncrRefCount(wmPtr->commandObj); Tcl_InvalidateStringRep(wmPtr->commandObj); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmDeiconifyCmd -- |
︙ | ︙ | |||
1538 1539 1540 1541 1542 1543 1544 1545 | { register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { | > > | | > < | | | > > > | 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 | { register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't deiconify %s: it is an icon for %s", Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "DEICONIFY", "ICON", NULL); return TCL_ERROR; } else if (winPtr->flags & TK_EMBEDDED) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't deiconify %s: it is an embedded window", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "DEICONIFY", "EMBEDDED", NULL); return TCL_ERROR; } TkpWmSetState(winPtr, TkMacOSXIsWindowZoomed(winPtr) ? ZoomState : NormalState); return TCL_OK; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
1590 1591 1592 1593 1594 1595 1596 | int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?"); return TCL_ERROR; } if (objc == 3) { | > | < | 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 | int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?"); return TCL_ERROR; } if (objc == 3) { Tcl_SetObjResult(interp, Tcl_NewStringObj( wmPtr->hints.input ? "passive" : "active", -1)); return TCL_OK; } if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
1632 1633 1634 1635 1636 1637 1638 | WmForgetCmd( Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { | < | < > | | > | > | 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 | WmForgetCmd( Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register Tk_Window frameWin = (Tk_Window) winPtr; if (Tk_IsTopLevel(frameWin)) { MacDrawable *macWin = (MacDrawable *) winPtr->parentPtr->window; TkFocusJoin(winPtr); Tk_UnmapWindow(frameWin); TkWmDeadWindow((TkWindow *) macWin); RemapWindows(winPtr, macWin); winPtr->flags &= ~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED); /* * Flags (above) must be cleared before calling TkMapTopFrame (below). */ TkMapTopFrame(frameWin); } else { /* * Already not managed by wm - ignore it. */ } return TCL_OK; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
1683 1684 1685 1686 1687 1688 1689 | 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; Window window; | < | < | 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 | 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; Window window; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } window = wmPtr->reparent; if (window == None) { window = Tk_WindowId((Tk_Window) winPtr); } Tcl_SetObjResult(interp, Tcl_ObjPrintf("0x%x", (unsigned) window)); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmGeometryCmd -- |
︙ | ︙ | |||
1733 1734 1735 1736 1737 1738 1739 | char *argv3; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newGeometry?"); return TCL_ERROR; } if (objc == 3) { | < < | | < | 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 | char *argv3; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newGeometry?"); return TCL_ERROR; } if (objc == 3) { xSign = (wmPtr->flags & WM_NEGATIVE_X) ? '-' : '+'; ySign = (wmPtr->flags & WM_NEGATIVE_Y) ? '-' : '+'; if (wmPtr->gridWin != NULL) { width = wmPtr->reqGridWidth + (winPtr->changes.width - winPtr->reqWidth)/wmPtr->widthInc; height = wmPtr->reqGridHeight + (winPtr->changes.height - winPtr->reqHeight)/wmPtr->heightInc; } else { width = winPtr->changes.width; height = winPtr->changes.height; } Tcl_SetObjResult(interp, Tcl_ObjPrintf("%dx%d%c%d%c%d", width, height, xSign, wmPtr->x, ySign, wmPtr->y)); return TCL_OK; } argv3 = Tcl_GetString(objv[3]); if (*argv3 == '\0') { wmPtr->width = -1; wmPtr->height = -1; WmUpdateGeom(wmPtr, winPtr); |
︙ | ︙ | |||
1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 | 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; int reqWidth, reqHeight, widthInc, heightInc; if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?baseWidth baseHeight widthInc heightInc?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & PBaseSize) { | > | | | > | | | 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 | 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; int reqWidth, reqHeight, widthInc, heightInc; char *errorMsg; if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?baseWidth baseHeight widthInc heightInc?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & PBaseSize) { Tcl_Obj *results[4]; results[0] = Tcl_NewIntObj(wmPtr->reqGridWidth); results[1] = Tcl_NewIntObj(wmPtr->reqGridHeight); results[2] = Tcl_NewIntObj(wmPtr->widthInc); results[3] = Tcl_NewIntObj(wmPtr->heightInc); Tcl_SetObjResult(interp, Tcl_NewListObj(4, results)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { /* * Turn off gridding and reset the width and height to make sense as * ungridded numbers. |
︙ | ︙ | |||
1828 1829 1830 1831 1832 1833 1834 | if ((Tcl_GetIntFromObj(interp, objv[3], &reqWidth) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &reqHeight) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[5], &widthInc) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[6], &heightInc)!=TCL_OK)) { return TCL_ERROR; } if (reqWidth < 0) { | | | < | | < < > | | < < > | | < > > > > > > | 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 | if ((Tcl_GetIntFromObj(interp, objv[3], &reqWidth) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &reqHeight) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[5], &widthInc) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[6], &heightInc)!=TCL_OK)) { return TCL_ERROR; } if (reqWidth < 0) { errorMsg = "baseWidth can't be < 0"; goto error; } else if (reqHeight < 0) { errorMsg = "baseHeight can't be < 0"; goto error; } else if (widthInc <= 0) { errorMsg = "widthInc can't be <= 0"; goto error; } else if (heightInc <= 0) { errorMsg = "heightInc can't be <= 0"; goto error; } Tk_SetGrid((Tk_Window) winPtr, reqWidth, reqHeight, widthInc, heightInc); } wmPtr->flags |= WM_UPDATE_SIZE_HINTS; WmUpdateGeom(wmPtr, winPtr); return TCL_OK; error: Tcl_SetObjResult(interp, Tcl_NewStringObj(errorMsg, -1)); Tcl_SetErrorCode(interp, "TK", "WM", "GRID", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * WmGroupCmd -- * |
︙ | ︙ | |||
1887 1888 1889 1890 1891 1892 1893 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & WindowGroupHint) { | | > | 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & WindowGroupHint) { Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->leaderName, -1)); } return TCL_OK; } argv3 = Tcl_GetStringFromObj(objv[3], &length); if (*argv3 == '\0') { wmPtr->hints.flags &= ~WindowGroupHint; if (wmPtr->leaderName != NULL) { ckfree(wmPtr->leaderName); } wmPtr->leaderName = NULL; |
︙ | ︙ | |||
1950 1951 1952 1953 1954 1955 1956 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconPixmapHint) { | | | > | 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconPixmapHint) { Tcl_SetObjResult(interp, Tcl_NewStringObj( Tk_NameOfBitmap(winPtr->display,wmPtr->hints.icon_pixmap), -1)); } return TCL_OK; } str = Tcl_GetStringFromObj(objv[3], &len); if (winPtr->window == None) { Tk_MakeWindowExist((Tk_Window) winPtr); } |
︙ | ︙ | |||
2012 2013 2014 2015 2016 2017 2018 2019 | Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) { | > | | > > > < | | | > < | | > | > < | | | > > > | 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 | Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } 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->master != None) { 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", winPtr->pathName, Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "ICON", NULL); return TCL_ERROR; } else if (winPtr->flags & TK_EMBEDDED) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify %s: it is an embedded window", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "EMBEDDED", NULL); return TCL_ERROR; } TkpWmSetState(winPtr, IconicState); return TCL_OK; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
2069 2070 2071 2072 2073 2074 2075 2076 2077 | Pixmap pixmap; char *argv3; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconMaskHint) { | > | | > > | 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 | Pixmap pixmap; char *argv3; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconMaskHint) { Tcl_SetObjResult(interp, Tcl_NewStringObj( Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_mask), -1)); } return TCL_OK; } argv3 = Tcl_GetString(objv[3]); if (*argv3 == '\0') { if (wmPtr->hints.icon_mask != None) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_mask); } wmPtr->hints.flags &= ~IconMaskHint; } else { |
︙ | ︙ | |||
2196 2197 2198 2199 2200 2201 2202 | * Iterate over all images to retrieve their sizes, in order to allocate a * buffer large enough to hold all images. */ for (i = 3 + isDefault; i < objc; i++) { photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i])); if (photo == NULL) { | | | > > | 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 | * Iterate over all images to retrieve their sizes, in order to allocate a * buffer large enough to hold all images. */ for (i = 3 + isDefault; i < objc; i++) { photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i])); if (photo == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't use \"%s\" as iconphoto: not a photo image", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL); return TCL_ERROR; } Tk_PhotoGetSize(photo, &width, &height); } /* * TODO: This requires implementation for OS X, but we silently return for |
︙ | ︙ | |||
2243 2244 2245 2246 2247 2248 2249 2250 2251 | register WmInfo *wmPtr = winPtr->wmInfoPtr; int x, y; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconPositionHint) { | > < > | | | > | 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 | register WmInfo *wmPtr = winPtr->wmInfoPtr; int x, y; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconPositionHint) { Tcl_Obj *results[2]; results[0] = Tcl_NewIntObj(wmPtr->hints.icon_x); results[1] = Tcl_NewIntObj(wmPtr->hints.icon_y); Tcl_SetObjResult(interp, Tcl_NewListObj(2, results)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->hints.flags &= ~IconPositionHint; } else { if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)){ return TCL_ERROR; } |
︙ | ︙ | |||
2300 2301 2302 2303 2304 2305 2306 2307 2308 | Tk_Window tkwin2; WmInfo *wmPtr2; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->icon != NULL) { | > | > | | > > > | | | > > | 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 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 | Tk_Window tkwin2; WmInfo *wmPtr2; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->icon != NULL) { Tcl_SetObjResult(interp, TkNewWindowObj(wmPtr->icon)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->hints.flags &= ~IconWindowHint; if (wmPtr->icon != NULL) { wmPtr2 = ((TkWindow *) wmPtr->icon)->wmInfoPtr; wmPtr2->iconFor = NULL; wmPtr2->hints.initial_state = WithdrawnState; } wmPtr->icon = NULL; } else { if (TkGetWindowFromObj(interp, tkwin, objv[3], &tkwin2) != TCL_OK) { return TCL_ERROR; } if (!Tk_IsTopLevel(tkwin2)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't use %s as icon window: not at top level", Tk_PathName(tkwin2))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONWINDOW", "TOPLEVEL", NULL); return TCL_ERROR; } wmPtr2 = ((TkWindow *) tkwin2)->wmInfoPtr; if (wmPtr2->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s is already an icon for %s", Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONWINDOW", "ICON", NULL); return TCL_ERROR; } if (wmPtr->icon != NULL) { WmInfo *wmPtr3 = ((TkWindow *) wmPtr->icon)->wmInfoPtr; wmPtr3->iconFor = NULL; } Tk_MakeWindowExist(tkwin2); wmPtr->hints.icon_window = Tk_WindowId(tkwin2); wmPtr->hints.flags |= IconWindowHint; wmPtr->icon = tkwin2; wmPtr2->iconFor = (Tk_Window) winPtr; |
︙ | ︙ | |||
2375 2376 2377 2378 2379 2380 2381 | WmManageCmd( Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { | < | < | | | > > | 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 | WmManageCmd( Tk_Window tkwin, /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register Tk_Window frameWin = (Tk_Window) winPtr; register WmInfo *wmPtr = winPtr->wmInfoPtr; if (!Tk_IsTopLevel(frameWin)) { MacDrawable *macWin = (MacDrawable *) winPtr->window; if (!Tk_IsManageable(frameWin)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" is not manageable: must be a" " frame, labelframe or toplevel", Tk_PathName(frameWin))); Tcl_SetErrorCode(interp, "TK", "WM", "MANAGE", NULL); return TCL_ERROR; } TkFocusSplit(winPtr); Tk_UnmapWindow(frameWin); if (wmPtr == NULL) { TkWmNewWindow(winPtr); if (winPtr->window == None) { |
︙ | ︙ | |||
2445 2446 2447 2448 2449 2450 2451 2452 | register WmInfo *wmPtr = winPtr->wmInfoPtr; int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { | > < > > | | > | | 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 | register WmInfo *wmPtr = winPtr->wmInfoPtr; int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { Tcl_Obj *results[2]; GetMaxSize(winPtr, &width, &height); results[0] = Tcl_NewIntObj(width); results[1] = Tcl_NewIntObj(height); Tcl_SetObjResult(interp, Tcl_NewListObj(2, results)); return TCL_OK; } if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &height) != TCL_OK)) { return TCL_ERROR; } wmPtr->maxWidth = width; wmPtr->maxHeight = height; wmPtr->flags |= WM_UPDATE_SIZE_HINTS; WmUpdateGeom(wmPtr, winPtr); return TCL_OK; |
︙ | ︙ | |||
2496 2497 2498 2499 2500 2501 2502 2503 | register WmInfo *wmPtr = winPtr->wmInfoPtr; int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { | > < > > | | > | 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 | register WmInfo *wmPtr = winPtr->wmInfoPtr; int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { Tcl_Obj *results[2]; GetMinSize(winPtr, &width, &height); results[0] = Tcl_NewIntObj(width); results[1] = Tcl_NewIntObj(height); Tcl_SetObjResult(interp, Tcl_NewListObj(2, results)); return TCL_OK; } if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &height) != TCL_OK)) { return TCL_ERROR; } wmPtr->minWidth = width; wmPtr->minHeight = height; wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
︙ | ︙ | |||
2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 | int boolean; XSetWindowAttributes atts; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); return TCL_ERROR; } if (objc == 3) { Tcl_SetObjResult(interp, Tcl_NewBooleanObj( Tk_Attributes((Tk_Window) winPtr)->override_redirect)); return TCL_OK; } if (Tcl_GetBooleanFromObj(interp, objv[3], &boolean) != TCL_OK) { return TCL_ERROR; } atts.override_redirect = (boolean) ? True : False; Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect, &atts); ApplyMasterOverrideChanges(winPtr, NULL); return TCL_OK; | > > | 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 | int boolean; XSetWindowAttributes atts; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); return TCL_ERROR; } if (objc == 3) { Tcl_SetObjResult(interp, Tcl_NewBooleanObj( Tk_Attributes((Tk_Window) winPtr)->override_redirect)); return TCL_OK; } if (Tcl_GetBooleanFromObj(interp, objv[3], &boolean) != TCL_OK) { return TCL_ERROR; } atts.override_redirect = (boolean) ? True : False; Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect, &atts); ApplyMasterOverrideChanges(winPtr, NULL); return TCL_OK; |
︙ | ︙ | |||
2597 2598 2599 2600 2601 2602 2603 2604 2605 | OPT_PROGRAM, OPT_USER }; int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & USPosition) { | > | | > | 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 | OPT_PROGRAM, OPT_USER }; int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & USPosition) { Tcl_SetObjResult(interp, Tcl_NewStringObj("user", -1)); } else if (wmPtr->sizeHintsFlags & PPosition) { Tcl_SetObjResult(interp, Tcl_NewStringObj("program", -1)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->sizeHintsFlags &= ~(USPosition|PPosition); } else { if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 | Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; register ProtocolHandler *protPtr, *prevPtr; Atom protocol; char *cmd; int cmdLength; if ((objc < 3) || (objc > 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?"); return TCL_ERROR; } if (objc == 3) { /* * Return a list of all defined protocols for the window. */ for (protPtr = wmPtr->protPtr; protPtr != NULL; protPtr = protPtr->nextPtr) { | > > > | | > > > | | 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 | Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; register ProtocolHandler *protPtr, *prevPtr; Atom protocol; char *cmd; int cmdLength; Tcl_Obj *resultObj; if ((objc < 3) || (objc > 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?"); return TCL_ERROR; } if (objc == 3) { /* * Return a list of all defined protocols for the window. */ resultObj = Tcl_NewObj(); for (protPtr = wmPtr->protPtr; protPtr != NULL; protPtr = protPtr->nextPtr) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( Tk_GetAtomName((Tk_Window)winPtr, protPtr->protocol),-1)); } Tcl_SetObjResult(interp, resultObj); return TCL_OK; } protocol = Tk_InternAtom((Tk_Window) winPtr, Tcl_GetString(objv[3])); if (objc == 4) { /* * Return the command to handle a given protocol. */ for (protPtr = wmPtr->protPtr; protPtr != NULL; protPtr = protPtr->nextPtr) { if (protPtr->protocol == protocol) { Tcl_SetObjResult(interp, Tcl_NewStringObj(protPtr->command, -1)); return TCL_OK; } } return TCL_OK; } /* |
︙ | ︙ | |||
2751 2752 2753 2754 2755 2756 2757 2758 | UInt64 oldAttributes = wmPtr->attributes; int oldFlags = wmPtr->flags; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { | > < > < | | | > | | 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 | UInt64 oldAttributes = wmPtr->attributes; int oldFlags = wmPtr->flags; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { Tcl_Obj *results[2]; results[0] = Tcl_NewBooleanObj(!(wmPtr->flags & WM_WIDTH_NOT_RESIZABLE)); results[1] = Tcl_NewBooleanObj(!(wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE)); Tcl_SetObjResult(interp, Tcl_NewListObj(2, results)); return TCL_OK; } if ((Tcl_GetBooleanFromObj(interp, objv[3], &width) != TCL_OK) || (Tcl_GetBooleanFromObj(interp, objv[4], &height) != TCL_OK)) { return TCL_ERROR; } if (width) { wmPtr->flags &= ~WM_WIDTH_NOT_RESIZABLE; wmPtr->attributes |= kWindowHorizontalZoomAttribute; } else { wmPtr->flags |= WM_WIDTH_NOT_RESIZABLE; |
︙ | ︙ | |||
2829 2830 2831 2832 2833 2834 2835 2836 2837 | OPT_PROGRAM, OPT_USER }; int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & USSize) { | > | | | 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 | OPT_PROGRAM, OPT_USER }; int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & USSize) { Tcl_SetObjResult(interp, Tcl_NewStringObj("user", -1)); } else if (wmPtr->sizeHintsFlags & PSize) { Tcl_SetObjResult(interp, Tcl_NewStringObj("program", -1)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->sizeHintsFlags &= ~(USSize|PSize); } else { |
︙ | ︙ | |||
2883 2884 2885 2886 2887 2888 2889 | WmStackorderCmd( 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. */ { | | | > | > > > | | > > | | | | > > | | > < < | | | > > | > | | | | | < | < | 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 | WmStackorderCmd( 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. */ { TkWindow **windows, **windowPtr; static const char *const optionStrings[] = { "isabove", "isbelow", NULL }; enum options { OPT_ISABOVE, OPT_ISBELOW }; Tcl_Obj *resultObj; int index; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?isabove|isbelow window?"); return TCL_ERROR; } if (objc == 3) { windows = TkWmStackorderToplevel(winPtr); if (windows == NULL) { Tcl_Panic("TkWmStackorderToplevel failed"); } resultObj = Tcl_NewObj(); for (windowPtr = windows; *windowPtr ; windowPtr++) { Tcl_ListObjAppendElement(NULL, resultObj, TkNewWindowObj((Tk_Window) *windowPtr)); } Tcl_SetObjResult(interp, resultObj); ckfree(windows); return TCL_OK; } else { TkWindow *winPtr2; int index1 = -1, index2 = -1, result; if (TkGetWindowFromObj(interp, tkwin, objv[4], (Tk_Window *) &winPtr2) != TCL_OK) { return TCL_ERROR; } if (!Tk_IsTopLevel(winPtr2)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't a top-level window", winPtr2->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "TOPLEVEL", NULL); return TCL_ERROR; } if (!Tk_IsMapped(winPtr)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't mapped", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", NULL); return TCL_ERROR; } else if (!Tk_IsMapped(winPtr2)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't mapped", winPtr2->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", NULL); return TCL_ERROR; } /* * Lookup stacking order of all toplevels that are children of "." and * find the position of winPtr and winPtr2 in the stacking order. */ windows = TkWmStackorderToplevel(winPtr->mainPtr->winPtr); if (windows == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "TkWmStackorderToplevel failed", -1)); Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "FAIL", NULL); return TCL_ERROR; } for (windowPtr = windows; *windowPtr ; windowPtr++) { if (*windowPtr == winPtr) { index1 = windowPtr - windows; } if (*windowPtr == winPtr2) { index2 = windowPtr - windows; } } if (index1 == -1) { Tcl_Panic("winPtr window not found"); } else if (index2 == -1) { Tcl_Panic("winPtr2 window not found"); } ckfree(windows); if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } if (index == OPT_ISABOVE) { result = index1 > index2; } else { /* OPT_ISBELOW */ result = index1 < index2; } Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result)); return TCL_OK; } } /* *---------------------------------------------------------------------- * * WmStateCmd -- * |
︙ | ︙ | |||
3012 3013 3014 3015 3016 3017 3018 3019 3020 | OPT_NORMAL, OPT_ICONIC, OPT_WITHDRAWN, OPT_ZOOMED }; int index; if ((objc < 3) || (objc > 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?state?"); return TCL_ERROR; } if (objc == 4) { if (wmPtr->iconFor != NULL) { | > | | | > > | | > | | | > > > | | > > > | | | | | | 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 | OPT_NORMAL, OPT_ICONIC, OPT_WITHDRAWN, OPT_ZOOMED }; int index; if ((objc < 3) || (objc > 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?state?"); return TCL_ERROR; } if (objc == 4) { if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't change state of %s: it is an icon for %s", Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "ICON", NULL); return TCL_ERROR; } if (winPtr->flags & TK_EMBEDDED) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't change state of %s: it is an embedded window", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "EMBEDDED", NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } if (index == OPT_NORMAL) { TkpWmSetState(winPtr, NormalState); /* * This varies from 'wm deiconify' because it does not force the * window to be raised and receive focus */ } else if (index == OPT_ICONIC) { 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", "STATE", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } if (wmPtr->master != None) { 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; } TkpWmSetState(winPtr, IconicState); } else if (index == OPT_WITHDRAWN) { TkpWmSetState(winPtr, WithdrawnState); } else { /* OPT_ZOOMED */ TkpWmSetState(winPtr, ZoomState); } } else if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj("icon", -1)); } else { if (wmPtr->hints.initial_state == NormalState || wmPtr->hints.initial_state == ZoomState) { wmPtr->hints.initial_state = (TkMacOSXIsWindowZoomed(winPtr) ? ZoomState : NormalState); } switch (wmPtr->hints.initial_state) { case NormalState: Tcl_SetObjResult(interp, Tcl_NewStringObj("normal", -1)); break; case IconicState: Tcl_SetObjResult(interp, Tcl_NewStringObj("iconic", -1)); break; case WithdrawnState: Tcl_SetObjResult(interp, Tcl_NewStringObj("withdrawn", -1)); break; case ZoomState: Tcl_SetObjResult(interp, Tcl_NewStringObj("zoomed", -1)); break; } } return TCL_OK; } /* |
︙ | ︙ | |||
3113 3114 3115 3116 3117 3118 3119 3120 | char *argv3; int length; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?"); return TCL_ERROR; } if (objc == 3) { | > | | > | 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 | char *argv3; int length; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?"); return TCL_ERROR; } if (objc == 3) { Tcl_SetObjResult(interp, Tcl_NewStringObj( wmPtr->titleUid ? wmPtr->titleUid : winPtr->nameUid, -1)); return TCL_OK; } argv3 = Tcl_GetStringFromObj(objv[3], &length); wmPtr->titleUid = Tk_GetUid(argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED) && !Tk_IsEmbedded(winPtr)) { TkSetWMName(winPtr, wmPtr->titleUid); } return TCL_OK; } |
︙ | ︙ | |||
3163 3164 3165 3166 3167 3168 3169 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?master?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->master != None) { | > | | | | > | | | > | | > | 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?master?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->master != None) { Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->masterWindowName, -1)); } return TCL_OK; } if (Tcl_GetString(objv[3])[0] == '\0') { wmPtr->master = None; if (wmPtr->masterWindowName != NULL) { ckfree(wmPtr->masterWindowName); } wmPtr->masterWindowName = NULL; } else { if (TkGetWindowFromObj(interp, tkwin, objv[3], &master) != TCL_OK) { return TCL_ERROR; } Tk_MakeWindowExist(master); 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 = ((TkWindow *) master)->wmInfoPtr; /* Under some circumstances, wmPtr2 is NULL here */ if (wmPtr2 != NULL && 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; } if ((TkWindow *) master == winPtr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't make \"%s\" its own master", Tk_PathName(winPtr))); Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL); return TCL_ERROR; } wmPtr->master = Tk_WindowId(master); masterWindowName = Tcl_GetStringFromObj(objv[3], &length); if (wmPtr->masterWindowName != NULL) { ckfree(wmPtr->masterWindowName); |
︙ | ︙ | |||
3245 3246 3247 3248 3249 3250 3251 3252 | { register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { | > > | | > | 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 | { register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't withdraw %s: it is an icon for %s", Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "WITHDRAW", "ICON", NULL); return TCL_ERROR; } TkpWmSetState(winPtr, WithdrawnState); return TCL_OK; } /* |
︙ | ︙ | |||
3663 3664 3665 3666 3667 3668 3669 | * There may also be a size-hint-update request pending from somewhere * else, too. */ if (((width != winPtr->changes.width) || (height != winPtr->changes.height)) && (wmPtr->gridWin == NULL) | | | 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 | * There may also be a size-hint-update request pending from somewhere * else, too. */ if (((width != winPtr->changes.width) || (height != winPtr->changes.height)) && (wmPtr->gridWin == NULL) && !(wmPtr->sizeHintsFlags & (PMinSize|PMaxSize))) { wmPtr->flags |= WM_UPDATE_SIZE_HINTS; } if (wmPtr->flags & WM_UPDATE_SIZE_HINTS) { UpdateSizeHints(winPtr); } /* |
︙ | ︙ | |||
3867 3868 3869 3870 3871 3872 3873 | /* * Assume that the geometry information came from the user, unless an * explicit source has been specified. Otherwise most window managers * assume that the size hints were program-specified and they ignore * them. */ | | | 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 | /* * Assume that the geometry information came from the user, unless an * explicit source has been specified. Otherwise most window managers * assume that the size hints were program-specified and they ignore * them. */ if (!(wmPtr->sizeHintsFlags & (USPosition|PPosition))) { wmPtr->sizeHintsFlags |= USPosition; flags |= WM_UPDATE_SIZE_HINTS; } } /* * Everything was parsed OK. Update the fields of *wmPtr and arrange for |
︙ | ︙ | |||
3902 3903 3904 3905 3906 3907 3908 | if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } return TCL_OK; error: | > | > | 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 | if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } return TCL_OK; error: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad geometry specifier \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "GEOMETRY", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * Tk_GetRootCoords -- |
︙ | ︙ | |||
4239 4240 4241 4242 4243 4244 4245 | /* * If this isn't a virtual-root window manager, just return information * about the screen. */ wmPtr->flags &= ~WM_VROOT_OFFSET_STALE; if (wmPtr->vRoot == None) { | | | 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 | /* * If this isn't a virtual-root window manager, just return information * about the screen. */ wmPtr->flags &= ~WM_VROOT_OFFSET_STALE; if (wmPtr->vRoot == None) { noVRoot: wmPtr->vRootX = wmPtr->vRootY = 0; wmPtr->vRootWidth = DisplayWidth(winPtr->display, winPtr->screenNum); wmPtr->vRootHeight = DisplayHeight(winPtr->display, winPtr->screenNum); return; } /* |
︙ | ︙ | |||
4362 4363 4364 4365 4366 4367 4368 | if (!(winPtr->flags & TK_TOP_LEVEL)) { Tcl_Panic("Tk_MoveToplevelWindow called with non-toplevel window"); } wmPtr->x = x; wmPtr->y = y; wmPtr->flags |= WM_MOVE_PENDING; wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y); | | | 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 | if (!(winPtr->flags & TK_TOP_LEVEL)) { Tcl_Panic("Tk_MoveToplevelWindow called with non-toplevel window"); } wmPtr->x = x; wmPtr->y = y; wmPtr->flags |= WM_MOVE_PENDING; wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y); if (!(wmPtr->sizeHintsFlags & (USPosition|PPosition))) { wmPtr->sizeHintsFlags |= USPosition; wmPtr->flags |= WM_UPDATE_SIZE_HINTS; } /* * If the window has already been mapped, must bring its geometry * up-to-date immediately, otherwise an event might arrive from the server |
︙ | ︙ | |||
4970 4971 4972 4973 4974 4975 4976 | "style", NULL }; enum SubCmds { TKMWS_STYLE }; Tk_Window tkwin = clientData; TkWindow *winPtr; | | | | > > | < | | < | < | < | | < | | < | | < | | < | | > > > > > > > > > > > > > > | < < < < < < < < < < < < < < < < < < < < < | < | < | > | 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 | "style", NULL }; enum SubCmds { TKMWS_STYLE }; Tk_Window tkwin = clientData; TkWindow *winPtr; int index, i; if (objc < 3) { Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg ...?"); return TCL_ERROR; } /* * Iterate through objc/objv to set correct background color and toggle * opacity of window. */ for (i= 0; i < objc; i++) { if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*black*")) { colorName = [NSColor blackColor]; // use #000000 in Tk scripts to match } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*dark*")) { colorName = [NSColor darkGrayColor]; //use #545454 in Tk scripts to match } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*light*")) { colorName = [NSColor lightGrayColor]; //use #ababab in Tk scripts to match } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*white*")) { colorName = [NSColor whiteColor]; //use #ffffff in Tk scripts to match } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "gray*")) { colorName = [NSColor grayColor]; //use #7f7f7f in Tk scripts to match } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*red*")) { colorName = [NSColor redColor]; //use #ff0000 in Tk scripts to match } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*green*")) { colorName = [NSColor greenColor]; //use #00ff00 in Tk scripts to match } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*blue*")) { colorName = [NSColor blueColor]; //use #0000ff in Tk scripts to match } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*cyan*")) { colorName = [NSColor cyanColor]; //use #00ffff in Tk scripts to match } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*yellow*")) { colorName = [NSColor yellowColor]; //use #ffff00 in Tk scripts to match } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*magenta*")) { colorName = [NSColor magentaColor]; //use #ff00ff in Tk scripts to match } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*orange*")) { colorName = [NSColor orangeColor]; //use #ff8000 in Tk scripts to match } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*purple*")) { colorName = [NSColor purpleColor]; //use #800080 in Tk scripts to match } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*brown*")){ colorName = [NSColor brownColor]; //use #996633 in Tk scripts to match } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*clear*")) { colorName = [NSColor clearColor]; //use systemTransparent in Tk scripts to match } if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*opacity*")) { opaqueTag = @"YES"; } } winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin); if (winPtr == NULL) { return TCL_ERROR; } if (!(winPtr->flags & TK_TOP_LEVEL)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't a top-level window", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WINDOWSTYLE", "TOPLEVEL", NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[1], subcmds, "option", 0, &index) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
5116 5117 5118 5119 5120 5121 5122 | { "none", kWindowNoAttributes }, { "standardDocument", kWindowStandardDocumentAttributes }, { "standardFloating", kWindowStandardFloatingAttributes }, { "fullZoom", kWindowFullZoomAttribute }, { NULL } }; | > | > > | 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 | { "none", kWindowNoAttributes }, { "standardDocument", kWindowStandardDocumentAttributes }, { "standardFloating", kWindowStandardFloatingAttributes }, { "fullZoom", kWindowFullZoomAttribute }, { NULL } }; /* * Map window attributes. Color and opacity are mapped to NULL; these are * parsed from the objv in TkUnsupported1ObjCmd. */ static const struct StrIntMap attrMap[] = { { "closeBox", kWindowCloseBoxAttribute }, { "horizontalZoom", kWindowHorizontalZoomAttribute }, { "verticalZoom", kWindowVerticalZoomAttribute }, { "collapseBox", kWindowCollapseBoxAttribute }, { "resizable", kWindowResizableAttribute }, |
︙ | ︙ | |||
5147 5148 5149 5150 5151 5152 5153 | { "ignoreClicks", kWindowIgnoreClicksAttribute }, { "noConstrain", kWindowNoConstrainAttribute }, { "doesNotHide", tkWindowDoesNotHideAttribute }, { "canJoinAllSpaces", tkCanJoinAllSpacesAttribute }, { "moveToActiveSpace", tkMoveToActiveSpaceAttribute }, { "nonActivating", tkNonactivatingPanelAttribute }, { "hud", tkHUDWindowAttribute }, | | | | | | | | | | | | | | | | < | | | | 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 | { "ignoreClicks", kWindowIgnoreClicksAttribute }, { "noConstrain", kWindowNoConstrainAttribute }, { "doesNotHide", tkWindowDoesNotHideAttribute }, { "canJoinAllSpaces", tkCanJoinAllSpacesAttribute }, { "moveToActiveSpace", tkMoveToActiveSpaceAttribute }, { "nonActivating", tkNonactivatingPanelAttribute }, { "hud", tkHUDWindowAttribute }, { "black", 0 }, { "dark", 0 }, { "light", 0 }, { "gray", 0 }, { "red", 0 }, { "green", 0 }, { "blue", 0 }, { "cyan", 0 }, { "yellow", 0 }, { "magenta", 0 }, { "orange", 0 }, { "purple", 0 }, { "brown", 0 }, { "clear", 0 }, { "opacity", 0 }, { NULL } }; int index, i; WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc == 3) { Tcl_Obj *attributeList, *newResult = NULL; UInt64 attributes; for (i = 0; classMap[i].strValue != NULL; i++) { if (wmPtr->macClass == classMap[i].intValue) { newResult = Tcl_NewStringObj(classMap[i].strValue, -1); break; } } if (newResult == NULL) { Tcl_Panic("invalid class"); } attributeList = Tcl_NewListObj(0, NULL); attributes = wmPtr->attributes; for (i = 0; compositeAttrMap[i].strValue != NULL; i++) { UInt64 intValue = compositeAttrMap[i].intValue; if (intValue && (attributes & intValue) == intValue) { Tcl_ListObjAppendElement(NULL, attributeList, Tcl_NewStringObj(compositeAttrMap[i].strValue, -1)); attributes &= ~intValue; break; } } for (i = 0; attrMap[i].strValue != NULL; i++) { if (attributes & attrMap[i].intValue) { Tcl_ListObjAppendElement(NULL, attributeList, Tcl_NewStringObj(attrMap[i].strValue, -1)); } } Tcl_ListObjAppendElement(NULL, newResult, attributeList); Tcl_SetObjResult(interp, newResult); } else { int attrObjc; Tcl_Obj **attrObjv = NULL; WindowClass macClass; UInt64 oldAttributes = wmPtr->attributes; int oldFlags = wmPtr->flags; |
︙ | ︙ | |||
5254 5255 5256 5257 5258 5259 5260 | return TCL_OK; badClassAttrs: wmPtr->attributes = oldAttributes; return TCL_ERROR; } | < | 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 | return TCL_OK; badClassAttrs: wmPtr->attributes = oldAttributes; return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
5417 5418 5419 5420 5421 5422 5423 | [window setMovableByWindowBackground:NO]; } /* Set background color and opacity of window if those flags are set. */ if (colorName != NULL) { [window setBackgroundColor: colorName]; | | | 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 | [window setMovableByWindowBackground:NO]; } /* Set background color and opacity of window if those flags are set. */ if (colorName != NULL) { [window setBackgroundColor: colorName]; } if (opaqueTag != NULL) { [window setOpaque: opaqueTag]; } [window setDocumentEdited:NO]; wmPtr->window = window; |
︙ | ︙ | |||
5907 5908 5909 5910 5911 5912 5913 | *---------------------------------------------------------------------- */ TkWindow ** TkWmStackorderToplevel( TkWindow *parentPtr) /* Parent toplevel window. */ { | | | 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 | *---------------------------------------------------------------------- */ TkWindow ** TkWmStackorderToplevel( TkWindow *parentPtr) /* Parent toplevel window. */ { TkWindow *childWinPtr, **windows, **windowPtr; Tcl_HashTable table; Tcl_HashEntry *hPtr; Tcl_HashSearch search; NSInteger windowCount; NSInteger *windowNumbers; /* |
︙ | ︙ | |||
5944 5945 5946 5947 5948 5949 5950 | } NSCountWindows(&windowCount); if (!windowCount) { ckfree(windows); windows = NULL; } else { | | | | | | 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 | } NSCountWindows(&windowCount); if (!windowCount) { ckfree(windows); windows = NULL; } else { windowPtr = windows + table.numEntries; *windowPtr-- = NULL; windowNumbers = ckalloc(windowCount * sizeof(NSInteger)); NSWindowList(windowCount, windowNumbers); for (NSInteger index = 0; index < windowCount; index++) { NSWindow *w = [NSApp windowWithWindowNumber:windowNumbers[index]]; if (w) { hPtr = Tcl_FindHashEntry(&table, (char*) w); if (hPtr != NULL) { childWinPtr = Tcl_GetHashValue(hPtr); *windowPtr-- = childWinPtr; } } } if (windowPtr != windows-1) { Tcl_Panic("num matched toplevel windows does not equal num " "children"); } ckfree(windowNumbers); } done: |
︙ | ︙ | |||
6277 6278 6279 6280 6281 6282 6283 | /* * Check max width and height if set by the user. */ if ((wmPtr->maxWidth > 0 && wmPtr->maxWidth < screenWidth) || (wmPtr->maxHeight > 0 && wmPtr->maxHeight < screenHeight)) { if (interp) { | | | | > | | 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 | /* * Check max width and height if set by the user. */ if ((wmPtr->maxWidth > 0 && wmPtr->maxWidth < screenWidth) || (wmPtr->maxHeight > 0 && wmPtr->maxHeight < screenHeight)) { if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't set fullscreen attribute for \"%s\": max" " width/height is too small", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "FULLSCREEN", "CONSTRAINT_FAILURE", NULL); } result = TCL_ERROR; wmPtr->flags &= ~WM_FULLSCREEN; } else { NSRect bounds = [window contentRectForFrameRect:[window frame]]; NSRect screenBounds = NSMakeRect(0, 0, screenWidth, screenHeight); |
︙ | ︙ | |||
6531 6532 6533 6534 6535 6536 6537 | /* Repeat for all the children */ for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { RemapWindows(childPtr, (MacDrawable *) winPtr->window); } } | < < | 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 | /* Repeat for all the children */ for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { RemapWindows(childPtr, (MacDrawable *) winPtr->window); } } /* * Local Variables: * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXWm.h.
1 2 3 4 5 6 7 8 | /* * tkMacOSXWm.h -- * * Declarations of Macintosh specific window manager structures. * * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * | | | | | < | | | | | | | | | < | | | | | | | | | | | | | | | | | | < | | | | | | | < | | | | | | | | | | | < | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | > < | | | | | | | | | | | | | < | | | | | < | < | | > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 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 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 76 77 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 118 119 120 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 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 188 189 190 191 192 193 194 195 196 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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | /* * tkMacOSXWm.h -- * * Declarations of Macintosh specific window manager structures. * * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef _TKMACWM #define _TKMACWM #include "tkMacOSXInt.h" #include "tkMenu.h" /* * A data structure of the following type holds information for each window * manager protocol (such as WM_DELETE_WINDOW) for which a handler (i.e. a Tcl * command) has been defined for a particular top-level window. */ 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[4]; /* 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; #define HANDLER_SIZE(cmdLength) \ ((unsigned) (sizeof(ProtocolHandler) - 3 + cmdLength)) /* * A data structure of the following type holds window-manager-related * information for each top-level window in an application. */ typedef struct TkWmInfo { TkWindow *winPtr; /* Pointer to main Tk information for this * window. */ Window reparent; /* If the window has been reparented, this * gives the ID of the ancestor of the window * 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. */ Window master; /* Master 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. */ char *masterWindowName; /* Path name of window specified as master in * "wm transient" command, or NULL. Malloc-ed. * Note: this field doesn't get updated if * masterWindowName is destroyed. */ 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. */ /* * Information used to construct an XSizeHints structure for the window * manager: */ int sizeHintsFlags; /* Flags word for XSizeHints structure. If the * PBaseSize flag is set then the window is * gridded; otherwise it isn't gridded. */ int minWidth, minHeight; /* Minimum dimensions of window, in grid units, * not pixels. */ int maxWidth, maxHeight; /* Maximum dimensions of window, in grid units, * not pixels. */ Tk_Window gridWin; /* Identifies the window that controls gridding * for this top-level, or NULL if the top-level * isn't currently gridded. */ int widthInc, heightInc; /* Increments for size changes (# pixels per * step). */ struct { int x; /* numerator */ int y; /* denominator */ } minAspect, maxAspect; /* Min/max aspect ratios for window. */ int reqGridWidth, reqGridHeight; /* The dimensions of the window (in grid units) * requested through the geometry manager. */ int gravity; /* Desired window gravity. */ /* * Information used to manage the size and location of a window. */ int width, height; /* Desired dimensions of window, specified in * grid units. These values are set by the "wm * geometry" command and by ConfigureNotify * events (for when wm resizes window). -1 * means user hasn't requested dimensions. */ int x, y; /* Desired X and Y coordinates for window. * These values are set by "wm geometry", plus * by ConfigureNotify events (when wm moves * window). These numbers are different than * the numbers stored in winPtr->changes * because (a) they could be measured from the * right or bottom edge of the screen (see * WM_NEGATIVE_X and WM_NEGATIVE_Y flags) and * (b) if the window has been reparented then * they refer to the parent rather than the * window itself. */ int parentWidth, parentHeight; /* Width and height of reparent, in pixels * *including border*. If window hasn't been * reparented then these will be the outer * dimensions of the window, including * border. */ int xInParent, yInParent; /* Offset of window within reparent, measured * from upper-left outer corner of parent's * border to upper-left outer corner of child's * border. If not reparented then these are * zero. */ int configX, configY; /* x,y position of toplevel when window is * switched into fullscreen state, */ int configWidth, configHeight; /* Dimensions passed to last request that we * issued to change geometry of window. Used to * eliminate redundant resize operations. */ /* * Information about the virtual root window for this top-level, if there * is one. */ Window vRoot; /* Virtual root window for this top-level, or * None if there is no virtual root window * (i.e. just use the screen's root). */ int vRootX, vRootY; /* Position of the virtual root inside the root * window. If the WM_VROOT_OFFSET_STALE flag is * set then this information may be incorrect * and needs to be refreshed from the OS. If * vRoot is None then these values are both * 0. */ unsigned int vRootWidth, vRootHeight; /* Dimensions of the virtual root window. If * vRoot is None, gives the dimensions of the * containing screen. This information is never * stale, even though vRootX and vRootY can * be. */ /* * List of children of the toplevel which have private colormaps. */ TkWindow **cmapList; /* Array of window with private colormaps. */ int cmapCount; /* Number of windows in array. */ /* * Miscellaneous information. */ ProtocolHandler *protPtr; /* First in list of protocol handlers for this * window (NULL means none). */ Tcl_Obj *commandObj; /* The command (guaranteed to be a list) for * the WM_COMMAND property. NULL means nothing * available. */ char *clientMachine; /* String to store in WM_CLIENT_MACHINE * property, or NULL. */ int flags; /* Miscellaneous flags, defined below. */ /* * Macintosh information. */ WindowClass macClass; UInt64 attributes, configAttributes; TkWindow *scrollWinPtr; /* Ptr to scrollbar handling grow widget. */ TkMenu *menuPtr; NSWindow *window; } WmInfo; /* * Flag values for WmInfo structures: * * WM_NEVER_MAPPED - non-zero means window has never been mapped; * need to update all info when window is first * mapped. * WM_UPDATE_PENDING - non-zero means a call to UpdateGeometryInfo * has already been scheduled for this window; no * need to schedule another one. * WM_NEGATIVE_X - non-zero means x-coordinate is measured in * pixels from right edge of screen, rather than * from left edge. * WM_NEGATIVE_Y - non-zero means y-coordinate is measured in * pixels up from bottom of screen, rather than * down from top. * WM_UPDATE_SIZE_HINTS - non-zero means that new size hints need to be * propagated to window manager. * WM_SYNC_PENDING - set to non-zero while waiting for the window * manager to respond to some state change. * WM_VROOT_OFFSET_STALE - non-zero means that (x,y) offset information * about the virtual root window is stale and * needs to be fetched fresh from the X server. * WM_ABOUT_TO_MAP - non-zero means that the window is about to be * mapped by TkWmMapWindow. This is used by * UpdateGeometryInfo to modify its behavior. * WM_MOVE_PENDING - non-zero means the application has requested a * new position for the window, but it hasn't * been reflected through the window manager yet. * WM_COLORMAPS_EXPLICIT - non-zero means the colormap windows were set * explicitly via "wm colormapwindows". * WM_ADDED_TOPLEVEL_COLORMAP - non-zero means that when "wm colormapwindows" * was called the top-level itself wasn't * specified, so we added it implicitly at the * end of the list. * WM_WIDTH_NOT_RESIZABLE - non-zero means that we're not supposed to * 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). */ #define WM_NEVER_MAPPED 0x0001 #define WM_UPDATE_PENDING 0x0002 #define WM_NEGATIVE_X 0x0004 #define WM_NEGATIVE_Y 0x0008 #define WM_UPDATE_SIZE_HINTS 0x0010 #define WM_SYNC_PENDING 0x0020 #define WM_VROOT_OFFSET_STALE 0x0040 #define WM_ABOUT_TO_MAP 0x0080 #define WM_MOVE_PENDING 0x0100 #define WM_COLORMAPS_EXPLICIT 0x0200 #define WM_ADDED_TOPLEVEL_COLORMAP 0x0400 #define WM_WIDTH_NOT_RESIZABLE 0x0800 #define WM_HEIGHT_NOT_RESIZABLE 0x1000 #define WM_TOPMOST 0x2000 #define WM_FULLSCREEN 0x4000 #define WM_TRANSPARENT 0x8000 #endif /* _TKMACWM */ /* * Local Variables: * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to tests/canvas.test.
︙ | ︙ | |||
402 403 404 405 406 407 408 | test canvas-10.2 {check errors from tag expressions} -setup { catch {destroy .c} canvas .c .c create oval 20 20 40 40 -fill red -tag [list a b c d] .c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"] } -body { .c find withtag {&&c} | | | | | | | | | | | 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 | test canvas-10.2 {check errors from tag expressions} -setup { catch {destroy .c} canvas .c .c create oval 20 20 40 40 -fill red -tag [list a b c d] .c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"] } -body { .c find withtag {&&c} } -returnCodes error -result {unexpected operator in tag search expression} test canvas-10.3 {check errors from tag expressions} -setup { catch {destroy .c} canvas .c .c create oval 20 20 40 40 -fill red -tag [list a b c d] .c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"] } -body { .c find withtag {!!c} } -returnCodes error -result {too many '!' in tag search expression} test canvas-10.4 {check errors from tag expressions} -setup { catch {destroy .c} canvas .c .c create oval 20 20 40 40 -fill red -tag [list a b c d] .c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"] } -body { .c find withtag {b||} } -returnCodes error -result {missing tag in tag search expression} test canvas-10.5 {check errors from tag expressions} -setup { catch {destroy .c} canvas .c .c create oval 20 20 40 40 -fill red -tag [list a b c d] .c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"] } -body { .c find withtag {b&&(c||)} } -returnCodes error -result {unexpected operator in tag search expression} test canvas-10.6 {check errors from tag expressions} -setup { catch {destroy .c} canvas .c .c create oval 20 20 40 40 -fill red -tag [list a b c d] .c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"] } -body { .c find withtag {d&&""} } -returnCodes error -result {null quoted tag string in tag search expression} test canvas-10.7 {check errors from tag expressions} -setup { catch {destroy .c} canvas .c .c create oval 20 20 40 40 -fill red -tag [list a b c d] .c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"] } -body { .c find withtag "d&&\"tag with spaces" } -returnCodes error -result {missing endquote in tag search expression} test canvas-10.8 {check errors from tag expressions} -setup { catch {destroy .c} canvas .c .c create oval 20 20 40 40 -fill red -tag [list a b c d] .c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"] } -returnCodes error -body { .c find withtag {a&&"tag with spaces"z} } -result {invalid boolean operator in tag search expression} test canvas-10.9 {check errors from tag expressions} -setup { catch {destroy .c} canvas .c .c create oval 20 20 40 40 -fill red -tag [list a b c d] .c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"] } -body { .c find withtag {a&&b&c} } -returnCodes error -result {singleton '&' in tag search expression} test canvas-10.10 {check errors from tag expressions} -setup { catch {destroy .c} canvas .c .c create oval 20 20 40 40 -fill red -tag [list a b c d] .c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"] } -body { .c find withtag {a||b|c} } -returnCodes error -result {singleton '|' in tag search expression} test canvas-10.11 {backward compatility - strange tags that are not expressions} -setup { catch {destroy .c} canvas .c .c create oval 20 20 40 40 -fill red \ -tag [list { strange tag(xxx&yyy|zzz) " && \" || ! ^ " }] } -body { .c find withtag { strange tag(xxx&yyy|zzz) " && \" || ! ^ " } |
︙ | ︙ |
Changes to tests/embed.test.
︙ | ︙ | |||
29 30 31 32 33 34 35 | test embed-1.3 {CreateFrame procedure, both -use and -container is invalid} -setup { deleteWindows } -body { toplevel .container -container 1 toplevel .t -use [winfo id .container] -container 1 } -cleanup { deleteWindows | | | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | test embed-1.3 {CreateFrame procedure, both -use and -container is invalid} -setup { deleteWindows } -body { toplevel .container -container 1 toplevel .t -use [winfo id .container] -container 1 } -cleanup { deleteWindows } -returnCodes error -result {windows cannot have both the -use and the -container option set} # testing window embedding for win platforms test embed-1.4.win {TkpUseWindow procedure, -container must be set} -constraints { win } -setup { deleteWindows } -body { |
︙ | ︙ |
Changes to tests/font.test.
︙ | ︙ | |||
72 73 74 75 76 77 78 | .b config -font wiggles font config wiggles -size 24 destroy . } lappend x [foo eval {catch {font families} msg; set msg}] } -cleanup { interp delete foo | | | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | .b config -font wiggles font config wiggles -size 24 destroy . } lappend x [foo eval {catch {font families} msg; set msg}] } -cleanup { interp delete foo } -result {{named font "wiggles" doesn't exist} {can't invoke "font" command: application has been destroyed}} test font-3.1 {font command: general} -body { font } -returnCodes error -result {wrong # args: should be "font option ?arg?"} test font-3.2 {font command: general} -body { font xyz |
︙ | ︙ |
Changes to tests/frame.test.
︙ | ︙ | |||
464 465 466 467 468 469 470 | deleteWindows } -body { toplevel .t -container 1 -width 300 -height 120 wm geometry .t +0+0 toplevel .x -container 1 -use [winfo id .t] } -cleanup { deleteWindows | | | 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 | deleteWindows } -body { toplevel .t -container 1 -width 300 -height 120 wm geometry .t +0+0 toplevel .x -container 1 -use [winfo id .t] } -cleanup { deleteWindows } -returnCodes error -result {windows cannot have both the -use and the -container option set} test frame-2.19 {toplevel configuration options} -setup { deleteWindows set opts {} } -body { # Make sure all options can be set to the default value toplevel .f foreach opt [.f configure] { |
︙ | ︙ |
Changes to tests/grid.test.
|
| | | < | | | | | | | | | | | < | | | | | | | | < | | < | | | | | | | | | | | | | < | < < < < < < < < < | < < < < | < < < | | | | | | < | < | < | < | | | | | | | | < < < < < < | | < < < < | < | < | 1 2 3 4 5 6 7 8 9 10 11 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 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 76 77 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 118 119 120 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 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 188 189 190 191 192 193 194 195 196 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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 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 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 | # This file is a Tcl script to test out the *NEW* "grid" command of Tk. It is # (almost) organized in the standard fashion for Tcl tests. # # Copyright (c) 1996 Sun Microsystems, Inc. # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. package require tcltest 2.2 eval tcltest::configure $argv tcltest::loadTestedCommands namespace import -force tcltest::test # helper routine to return "." to a sane state after a test. # The variable GRID_VERBOSE can be used to "look" at the result of one or all # of the tests proc grid_reset {{test ?} {top .}} { global GRID_VERBOSE if {[info exists GRID_VERBOSE]} { if {$GRID_VERBOSE eq "" || $GRID_VERBOSE eq $test} { puts -nonewline "grid test $test: " flush stdout gets stdin } } eval destroy [winfo children $top] update foreach {cols rows} [grid size .] {} for {set i 0} {$i <= $cols} {incr i} { grid columnconfigure . $i -weight 0 -minsize 0 -pad 0 -uniform "" } for {set i 0} {$i <= $rows} {incr i} { grid rowconfigure . $i -weight 0 -minsize 0 -pad 0 -uniform "" } grid propagate . 1 grid anchor . nw update } grid_reset 0.0 wm geometry . {} test grid-1.1 {basic argument checking} -body { grid } -returnCodes error -result {wrong # args: should be "grid option arg ?arg ...?"} test grid-1.2 {basic argument checking} -body { grid foo bar } -returnCodes error -result {bad option "foo": must be anchor, bbox, columnconfigure, configure, forget, info, location, propagate, remove, rowconfigure, size, or slaves} test grid-1.3 {basic argument checking} -body { button .b grid .b -row 0 -column } -cleanup { grid_reset 1.3 } -returnCodes error -result {extra option or option with no value} test grid-1.4 {basic argument checking} -body { button .b grid configure .b - foo } -cleanup { grid_reset 1.4 } -returnCodes error -result {unexpected parameter "foo" in configure list: should be window name or option} test grid-1.5 {basic argument checking} -body { grid . } -returnCodes error -result {can't manage ".": it's a top-level window} test grid-1.6 {basic argument checking} -body { grid x } -returnCodes error -result {can't determine master window} test grid-1.7 {basic argument checking} -body { grid configure x } -returnCodes error -result {can't determine master window} test grid-1.8 {basic argument checking} -body { button .b grid x .b } -cleanup { grid_reset 1.8 } -returnCodes ok -result {} test grid-1.9 {basic argument checking} -body { button .b grid configure x .b } -cleanup { grid_reset 1.9 } -returnCodes ok -result {} test grid-2.1 {bbox} -body { grid bbox . } -result {0 0 0 0} test grid-2.2 {bbox} -body { button .b grid .b destroy .b update grid bbox . } -result {0 0 0 0} test grid-2.3 {bbox: argument checking} -body { grid bbox . 0 0 5 } -returnCodes error -result {wrong # args: should be "grid bbox master ?column row ?column row??"} test grid-2.4 {bbox} -body { grid bbox .bad 0 0 } -returnCodes error -result {bad window path name ".bad"} test grid-2.5 {bbox} -body { grid bbox . x 0 } -returnCodes error -result {expected integer but got "x"} test grid-2.6 {bbox} -body { grid bbox . 0 x } -returnCodes error -result {expected integer but got "x"} test grid-2.7 {bbox} -body { grid bbox . 0 0 x 0 } -returnCodes error -result {expected integer but got "x"} test grid-2.8 {bbox} -body { grid bbox . 0 0 0 x } -returnCodes error -result {expected integer but got "x"} test grid-2.9 {bbox} -body { frame .1 -width 75 -height 75 -bg red frame .2 -width 90 -height 90 -bg red grid .1 -row 0 -column 0 grid .2 -row 1 -column 1 update set a "" lappend a [grid bbox .] lappend a [grid bbox . 0 0] lappend a [grid bbox . 0 0 1 1] lappend a [grid bbox . 1 1] return $a } -cleanup { grid_reset 2.9 } -result {{0 0 165 165} {0 0 75 75} {0 0 165 165} {75 75 90 90}} test grid-2.10 {bbox} -body { frame .1 -width 75 -height 75 -bg red frame .2 -width 90 -height 90 -bg red grid .1 -row 0 -column 0 grid .2 -row 1 -column 1 update set a "" lappend a [grid bbox . 10 10 0 0] lappend a [grid bbox . -2 -2 -1 -1] lappend a [grid bbox . 10 10 12 12] return $a } -cleanup { grid_reset 2.10 } -result {{0 0 165 165} {0 0 0 0} {165 165 0 0}} test grid-3.1 {configure: basic argument checking} -body { grid configure foo } -returnCodes error -result {bad argument "foo": must be name of window} test grid-3.2 {configure: basic argument checking} -body { button .b grid configure .b grid slaves . } -cleanup { grid_reset 3.2 } -result {.b} test grid-3.3 {configure: basic argument checking} -body { button .b grid .b -row -1 } -cleanup { grid_reset 3.3 } -returnCodes error -result {bad row value "-1": must be a non-negative integer} test grid-3.4 {configure: basic argument checking} -body { button .b grid .b -column -1 } -cleanup { grid_reset 3.4 } -returnCodes error -result {bad column value "-1": must be a non-negative integer} test grid-3.5 {configure: basic argument checking} -body { button .b grid .b -rowspan 0 } -cleanup { grid_reset 3.5 } -returnCodes error -result {bad rowspan value "0": must be a positive integer} test grid-3.6 {configure: basic argument checking} -body { button .b grid .b -columnspan 0 } -cleanup { grid_reset 3.6 } -returnCodes error -result {bad columnspan value "0": must be a positive integer} test grid-3.7 {configure: basic argument checking} -body { frame .f button .f.b grid .f .f.b } -cleanup { grid_reset 3.7 } -returnCodes error -result {can't put .f.b inside .} test grid-3.8 {configure: basic argument checking} -body { button .b grid configure x .b grid slaves . } -cleanup { grid_reset 3.8 } -result {.b} test grid-3.9 {configure: basic argument checking} -body { button .b grid configure y .b } -cleanup { grid_reset 3.9 } -returnCodes error -result {invalid window shortcut, "y" should be '-', 'x', or '^'} test grid-4.1 {forget: basic argument checking} -body { grid forget foo } -returnCodes error -result {bad window path name "foo"} test grid-4.2 {forget} -body { button .c grid [button .b] set a [grid slaves .] grid forget .b .c lappend a [grid slaves .] return $a } -cleanup { grid_reset 4.2 } -result {.b {}} test grid-4.3 {forget} -body { button .c grid .c -row 2 -column 2 -rowspan 2 -columnspan 2 -padx 3 -pady 4 -sticky ns grid forget .c grid .c -row 0 -column 0 grid info .c } -cleanup { grid_reset 4.3 } -result {-in . -column 0 -row 0 -columnspan 1 -rowspan 1 -ipadx 0 -ipady 0 -padx 0 -pady 0 -sticky {}} test grid-4.4 {forget} -body { button .c grid .c -row 2 -column 2 -rowspan 2 -columnspan 2 -padx {3 5} -pady {4 7} -sticky ns grid forget .c grid .c -row 0 -column 0 grid info .c } -cleanup { grid_reset 4.3.1 } -result {-in . -column 0 -row 0 -columnspan 1 -rowspan 1 -ipadx 0 -ipady 0 -padx 0 -pady 0 -sticky {}} test grid-4.5 {forget, calling Tk_UnmaintainGeometry} -body { frame .f -bd 2 -relief raised place .f -x 10 -y 20 -width 200 -height 100 frame .f2 -width 50 -height 30 -bg red grid .f2 -in .f update set x [winfo ismapped .f2] grid forget .f2 place .f -x 30 update lappend x [winfo ismapped .f2] } -cleanup { grid_reset 4.4 } -result {1 0} test grid-5.1 {info: basic argument checking} -body { grid info a b } -returnCodes error -result {wrong # args: should be "grid info window"} test grid-5.2 {info} -body { frame .1 -width 75 -height 75 -bg red grid .1 -row 0 -column 0 update grid info .x } -cleanup { grid_reset 5.2 } -returnCodes error -result {bad window path name ".x"} test grid-5.3 {info} -body { frame .1 -width 75 -height 75 -bg red grid .1 -row 0 -column 0 update grid info .1 } -cleanup { grid_reset 5.3 } -result {-in . -column 0 -row 0 -columnspan 1 -rowspan 1 -ipadx 0 -ipady 0 -padx 0 -pady 0 -sticky {}} test grid-5.4 {info} -body { frame .1 -width 75 -height 75 -bg red update grid info .1 } -cleanup { grid_reset 5.4 } -returnCodes ok -result {} test grid-6.1 {location: basic argument checking} -body { grid location . } -returnCodes error -result {wrong # args: should be "grid location master x y"} test grid-6.2 {location: basic argument checking} -body { grid location .bad 0 0 } -returnCodes error -result {bad window path name ".bad"} test grid-6.3 {location: basic argument checking} -body { grid location . x y } -returnCodes error -result {bad screen distance "x"} test grid-6.4 {location: basic argument checking} -body { grid location . 1c y } -returnCodes error -result {bad screen distance "y"} test grid-6.5 {location: basic argument checking} -body { frame .f grid location .f 10 10 } -cleanup { grid_reset 6.5 } -result {-1 -1} test grid-6.6 {location (x)} -body { frame .f -width 200 -height 100 -highlightthickness 0 -bg red grid .f update set got "" set result "" for {set x -10} { $x < 220} { incr x} { set a [grid location . $x 0] if {$a != $got} { lappend result $x->$a set got $a } } return $result } -cleanup { grid_reset 6.6 } -result {{-10->-1 0} {0->0 0} {201->1 0}} test grid-6.7 {location (y)} -body { frame .f -width 200 -height 100 -highlightthickness 0 -bg red grid .f update set got "" set result "" for {set y -10} { $y < 110} { incr y} { set a [grid location . 0 $y] if {$a != $got} { lappend result $y->$a set got $a } } return $result } -cleanup { grid_reset 6.7 } -result {{-10->0 -1} {0->0 0} {101->0 1}} test grid-6.8 {location (weights)} -body { frame .f -width 300 -height 100 -highlightthickness 0 -bg red frame .a grid .a grid .f -in .a grid rowconfigure .f 0 -weight 1 grid columnconfigure .f 0 -weight 1 grid propagate .a 0 .a configure -width 200 -height 15 update set got "" set result "" for {set y -10} { $y < 210} { incr y} { set a [grid location . $y $y] if {$a != $got} { lappend result $y->$a set got $a } } return $result } -cleanup { grid_reset 6.8 } -result {{-10->-1 -1} {0->0 0} {16->0 1} {201->1 1}} test grid-6.9 {location: check updates pending} -constraints { nonPortable } -body { set a "" foreach i {0 1 2} { frame .$i -width 120 -height 75 -bg red lappend a [grid location . 150 90] grid .$i -row $i -column $i } return $a } -cleanup { grid_reset 6.9 } -result {{0 0} {1 1} {1 1}} test grid-7.1 {propagate} -body { grid propagate . 1 xxx } -cleanup { grid_reset 7.1 } -returnCodes error -result {wrong # args: should be "grid propagate window ?boolean?"} test grid-7.2 {propagate} -body { grid propagate . } -cleanup { grid_reset 7.2 } -result {1} test grid-7.3 {propagate} -body { grid propagate . 0;grid propagate . } -cleanup { grid_reset 7.3 } -result {0} test grid-7.4 {propagate} -body { grid propagate .x } -cleanup { grid_reset 7.4 } -returnCodes error -result {bad window path name ".x"} test grid-7.5 {propagate} -body { grid propagate . x } -cleanup { grid_reset 7.5 } -returnCodes error -result {expected boolean value but got "x"} test grid-7.6 {propagate} -body { frame .f -width 100 -height 100 -bg red grid .f -row 0 -column 0 update set a [winfo width .f]x[winfo height .f] grid propagate .f 0 frame .g -width 75 -height 85 -bg green grid .g -in .f -row 0 -column 0 update lappend a [winfo width .f]x[winfo height .f] grid propagate .f 1 update lappend a [winfo width .f]x[winfo height .f] return $a } -cleanup { grid_reset 7.6 } -result {100x100 100x100 75x85} test grid-7.7 {propagate} -body { grid propagate . 1 set res [list [grid propagate .]] grid propagate . 0 lappend res [grid propagate .] grid propagate . 0 lappend res [grid propagate .] return $res } -cleanup { grid_reset 7.7 } -result [list 1 0 0] test grid-8.1 {size} -body { grid size . foo } -cleanup { grid_reset 8.1 } -returnCodes error -result {wrong # args: should be "grid size window"} test grid-8.2 {size} -body { grid size .x } -cleanup { grid_reset 8.2 } -returnCodes error -result {bad window path name ".x"} test grid-8.3 {size} -body { frame .f grid size .f } -cleanup { grid_reset 8.3 } -result {0 0} test grid-8.4 {size} -body { catch {unset a} scale .f grid .f -row 0 -column 0 update lappend a [grid size .] grid .f -row 4 -column 5 update lappend a [grid size .] grid .f -row 947 -column 663 update lappend a [grid size .] grid .f -row 0 -column 0 update lappend a [grid size .] return $a } -cleanup { grid_reset 8.4 } -result {{1 1} {6 5} {664 948} {1 1}} test grid-8.5 {size} -body { catch {unset a} scale .f grid .f -row 0 -column 0 update lappend a [grid size .] grid rowconfigure . 17 -weight 1 update lappend a [grid size .] grid columnconfigure . 63 -weight 1 update lappend a [grid size .] grid columnconfigure . 63 -weight 0 grid rowconfigure . 17 -weight 0 update lappend a [grid size .] return $a } -cleanup { grid_reset 8.5 } -result {{1 1} {1 18} {64 18} {1 1}} test grid-8.6 {size} -body { catch {unset a} scale .f grid .f -row 10 -column 50 update lappend a [grid size .] grid columnconfigure . 15 -weight 1 |
︙ | ︙ | |||
519 520 521 522 523 524 525 | lappend a [grid size .] grid .f -row 0 -column 0 update lappend a [grid size .] grid columnconfigure . 15 -weight 0 update lappend a [grid size .] | | < | | | | | | | | | | | | | | | < | < | < | < | < | | < | < | < | < | < | < | | < | < | < | | < | < | < | | < | | | | | | | | | | | | < | | | | | | | | < | | < | | < | < | < | < | < | < < | | | < | < < | | | | | | | < | | | | | < | < | | | < | | < | | < | | | < | < | < | < | < | | < | | | | | < | | | | | | | < | | < | < | < < < < < < | < < < | < | < < < < < < < < < < < < < < < < < | | | < | < | < < | < < | 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 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 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 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 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 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 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 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 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 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 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 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 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 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 | lappend a [grid size .] grid .f -row 0 -column 0 update lappend a [grid size .] grid columnconfigure . 15 -weight 0 update lappend a [grid size .] return $a } -cleanup { grid_reset 8.6 } -result {{51 11} {51 11} {31 11} {21 11} {16 1} {1 1}} test grid-9.1 {slaves} -body { grid slaves . } -returnCodes ok -result {} test grid-9.2 {slaves} -body { grid slaves .foo } -returnCodes error -result {bad window path name ".foo"} test grid-9.3 {slaves} -body { grid slaves a b } -returnCodes error -result {wrong # args: should be "grid slaves window ?-option value ...?"} test grid-9.4 {slaves} -body { grid slaves . a b } -returnCodes error -result {bad option "a": must be -column or -row} test grid-9.5 {slaves} -body { grid slaves . -column x } -returnCodes error -result {expected integer but got "x"} test grid-9.6 {slaves} -body { grid slaves . -row -3 } -returnCodes error -result {-3 is an invalid value: should NOT be < 0} test grid-9.7 {slaves} -body { grid slaves . -foo 3 } -returnCodes error -result {bad option "-foo": must be -column or -row} test grid-9.8 {slaves} -body { grid slaves .x -row 3 } -returnCodes error -result {bad window path name ".x"} test grid-9.9 {slaves} -body { grid slaves . -row 3 } -returnCodes ok -result {} test grid-9.10 {slaves} -body { foreach i {0 1 2} { label .$i -text $i grid .$i -row $i -column $i } grid slaves . } -cleanup { grid_reset 9.10 } -result {.2 .1 .0} test grid-9.11 {slaves} -body { catch {unset a} foreach i {0 1 2} { label .$i -text $i label .$i-x -text $i-x grid .$i -row $i -column $i grid .$i-x -row $i -column [incr i] } foreach row {0 1 2 3} { lappend a $row{[grid slaves . -row $row]} } foreach col {0 1 2 3} { lappend a $col{[grid slaves . -column $col]} } return $a } -cleanup { grid_reset 9.11 } -result {{0{.0-x .0}} {1{.1-x .1}} {2{.2-x .2}} 3{} 0{.0} {1{.1 .0-x}} {2{.2 .1-x}} 3{.2-x}} # column/row configure test grid-10.1 {column/row configure} -body { grid columnconfigure . } -cleanup { grid_reset 10.1 } -returnCodes error -result {wrong # args: should be "grid columnconfigure master index ?-option value ...?"} test grid-10.2 {column/row configure} -body { grid columnconfigure . 0 -weight 0 -pad } -cleanup { grid_reset 10.2 } -returnCodes error -result {wrong # args: should be "grid columnconfigure master index ?-option value ...?"} test grid-10.3 {column/row configure} -body { grid columnconfigure .f 0 -weight } -cleanup { grid_reset 10.3 } -returnCodes error -result {bad window path name ".f"} test grid-10.4 {column/row configure} -body { grid columnconfigure . nine -weight } -cleanup { grid_reset 10.4 } -returnCodes error -result {expected integer but got "nine" (when retrieving options only integer indices are allowed)} test grid-10.5 {column/row configure} -body { grid columnconfigure . 265 -weight } -cleanup { grid_reset 10.5 } -result {0} test grid-10.6 {column/row configure} -body { grid columnconfigure . 0 } -cleanup { grid_reset 10.6 } -result {-minsize 0 -pad 0 -uniform {} -weight 0} test grid-10.7 {column/row configure} -body { grid columnconfigure . 0 -foo } -cleanup { grid_reset 10.7 } -returnCodes error -result {bad option "-foo": must be -minsize, -pad, -uniform, or -weight} test grid-10.8 {column/row configure} -body { grid columnconfigure . 0 -minsize foo } -cleanup { grid_reset 10.8 } -returnCodes error -result {bad screen distance "foo"} test grid-10.9 {column/row configure} -body { grid columnconfigure . 0 -minsize foo } -cleanup { grid_reset 10.9 } -returnCodes error -result {bad screen distance "foo"} test grid-10.10 {column/row configure} -body { grid columnconfigure . 0 -minsize 10 grid columnconfigure . 0 -minsize } -cleanup { grid_reset 10.10 } -result {10} test grid-10.11 {column/row configure} -body { grid columnconfigure . 0 -weight bad } -cleanup { grid_reset 10.11 } -returnCodes error -result {expected integer but got "bad"} test grid-10.12 {column/row configure} -body { grid columnconfigure . 0 -weight -3 } -cleanup { grid_reset 10.12 } -returnCodes error -result {invalid arg "-weight": should be non-negative} test grid-10.13 {column/row configure} -body { grid columnconfigure . 0 -weight 3 grid columnconfigure . 0 -weight } -cleanup { grid_reset 10.13 } -result {3} test grid-10.14 {column/row configure} -body { grid columnconfigure . 0 -pad foo } -cleanup { grid_reset 10.14 } -returnCodes error -result {bad screen distance "foo"} test grid-10.15 {column/row configure} -body { grid columnconfigure . 0 -pad -3 } -cleanup { grid_reset 10.15 } -returnCodes error -result {invalid arg "-pad": should be non-negative} test grid-10.16 {column/row configure} -body { grid columnconfigure . 0 -pad 3 grid columnconfigure . 0 -pad } -cleanup { grid_reset 10.16 } -result {3} test grid-10.17 {column/row configure} -body { frame .f set a "" grid columnconfigure .f 0 -weight 0 lappend a [grid columnconfigure .f 0 -weight] grid columnconfigure .f 0 -weight 1 lappend a [grid columnconfigure .f 0 -weight] grid rowconfigure .f 0 -weight 0 lappend a [grid rowconfigure .f 0 -weight] grid rowconfigure .f 0 -weight 1 lappend a [grid columnconfigure .f 0 -weight] grid columnconfigure .f 0 -weight 0 return $a } -cleanup { grid_reset 10.17 } -result {0 1 0 1} test grid-10.18 {column/row configure} -body { frame .f grid columnconfigure .f {0 2} -minsize 10 -weight 1 list [grid columnconfigure .f 0 -minsize] \ [grid columnconfigure .f 1 -minsize] \ [grid columnconfigure .f 2 -minsize] \ [grid columnconfigure .f 0 -weight] \ [grid columnconfigure .f 1 -weight] \ [grid columnconfigure .f 2 -weight] } -cleanup { grid_reset 10.18 } -result {10 0 10 1 0 1} test grid-10.19 {column/row configure} -body { grid columnconfigure . {0 -1 2} -weight 1 } -cleanup { grid_reset 10.19 } -returnCodes error -result {"-1" is out of range} test grid-10.20 {column/row configure} -body { grid columnconfigure . 0 -uniform foo grid columnconfigure . 0 -uniform } -cleanup { grid_reset 10.20 } -result {foo} test grid-10.21 {column/row configure} -body { grid columnconfigure . .b -weight 1 } -cleanup { grid_reset 10.21 } -returnCodes error -result {illegal index ".b"} test grid-10.22 {column/row configure} -body { button .b grid columnconfigure . .b -weight 1 } -cleanup { grid_reset 10.22 } -returnCodes error -result {the window ".b" is not managed by "."} test grid-10.23 {column/row configure} -body { button .b grid .b -column 1 -columnspan 2 grid columnconfigure . .b -weight 1 set res {} foreach i {0 1 2 3} { lappend res [grid columnconfigure . $i -weight] } return $res } -cleanup { grid_reset 10.23 } -result {0 1 1 0} test grid-10.24 {column/row configure} -body { button .b button .c button .d grid .b -column 1 -columnspan 2 grid .c -column 2 -columnspan 3 grid .d -column 4 -columnspan 2 grid columnconfigure . {.b .d} -weight 1 grid columnconfigure . .c -weight 2 set res {} foreach i {0 1 2 3 4 5 6} { lappend res [grid columnconfigure . $i -weight] } return $res } -cleanup { grid_reset 10.24 } -result {0 1 2 2 2 1 0} test grid-10.25 {column/row configure} -body { button .b button .c button .d grid .b -row 1 -rowspan 2 grid .c -row 2 -rowspan 3 grid .d -row 4 -rowspan 2 grid rowconfigure . {7 all} -weight 1 grid rowconfigure . {1 .d} -weight 2 set res {} foreach i {0 1 2 3 4 5 6 7} { lappend res [grid rowconfigure . $i -weight] } return $res } -cleanup { grid_reset 10.25 } -result {0 2 1 1 2 2 0 1} test grid-10.26 {column/row configure} -body { button .b grid columnconfigure .b 0 } -cleanup { grid_reset 10.26 } -result {-minsize 0 -pad 0 -uniform {} -weight 0} test grid-10.27 {column/row configure - no indices} -body { # Bug 1422430 set t [toplevel .test] grid columnconfigure $t "" -weight 1 } -cleanup { destroy $t } -returnCodes error -result {no column indices specified} test grid-10.28 {column/row configure - no indices} -body { set t [toplevel .test] grid rowconfigure $t "" -weight 1 } -cleanup { destroy $t } -returnCodes error -result {no row indices specified} test grid-10.29 {column/row configure - invalid indices} -body { grid columnconfigure . {0 1 2} -weight } -returnCodes error -result {must specify a single element on retrieval} test grid-10.30 {column/row configure - invalid indices} -body { grid rowconfigure . {0 1 2} -weight } -returnCodes error -result {must specify a single element on retrieval} test grid-10.31 {column/row configure - empty 'all' configure} -body { # Bug 1422430 set t [toplevel .test] grid rowconfigure $t all -weight 1 destroy $t } -result {} test grid-10.32 {column/row configure} -body { # Test that no lingering message is there frame .f set res [grid columnconfigure .f all -weight 1] append res [grid columnconfigure .f {0 all} -weight 1] frame .f.f grid .f.f append res [grid columnconfigure .f {.f.f} -weight 1] append res [grid columnconfigure .f {.f.f 1} -weight 1] append res [grid columnconfigure .f {2 .f.f} -weight 1] destroy .f return $res } -cleanup { grid_reset 10.35 } -result {} test grid-10.33 {column/row configure} -body { grid columnconfigure . all } -cleanup { grid_reset 10.36 } -returnCodes error -result {expected integer but got "all" (when retrieving options only integer indices are allowed)} test grid-10.34 {column/row configure} -body { grid columnconfigure . 100000 } -cleanup { grid_reset 10.37 } -result {-minsize 0 -pad 0 -uniform {} -weight 0} test grid-10.35 {column/row configure} -body { # This is a test for bug 1423666 where a column >= 10000 caused # a crash in layout. The update is needed to reach the layout stage. # Test different combinations of row/column overflow frame .f set res {} lappend res [catch {grid .f -row 10 -column 9999} msg] $msg ; update lappend res [catch {grid .f -row 9999 -column 10} msg] $msg ; update lappend res [catch {grid .f -columnspan 2 -column 9998} msg] $msg ; update lappend res [catch {grid .f -rowspan 2 -row 9998} msg] $msg ; update lappend res [catch {grid .f -column 9998 -columnspan 2} msg] $msg ; update lappend res [catch {grid .f -row 9998 -rowspan 2} msg] $msg ; update return $res } -cleanup {destroy .f} -result [lrange { 1 {column out of bounds} 1 {row out of bounds} 1 {column out of bounds} 1 {row out of bounds} 1 {column out of bounds} 1 {row out of bounds} } 0 end] grid_reset 10.38 test grid-10.36 {column/row configure} -body { # Additional tests for row/column overflow frame .f frame .g set res {} grid .f -row 9998 -column 0 lappend res [catch {grid ^ -in .} msg] $msg ; update lappend res [catch {grid .g} msg] $msg ; update grid forget .f .g lappend res [catch {grid .f - -column 9998} msg] $msg ; update grid forget .f .g lappend res [catch {eval grid [string repeat " x " 9999] .f} msg] $msg update return $res } -cleanup {destroy .f .g} -result [lrange { 1 {row out of bounds} 1 {row out of bounds} 1 {column out of bounds} 1 {column out of bounds} } 0 end] grid_reset 10.39 # auto-placement tests test grid-11.1 {default widget placement} -body { grid ^ } -cleanup { grid_reset 11.1 } -returnCodes error -result {can't use '^', cant find master} test grid-11.2 {default widget placement} -body { button .b grid .b ^ } -cleanup { grid_reset 11.2 } -returnCodes error -result {can't find slave to extend with "^"} test grid-11.3 {default widget placement} -body { button .b grid .b - - .c } -cleanup { grid_reset 11.3 } -returnCodes error -result {bad window path name ".c"} test grid-11.4 {default widget placement} -body { button .b grid .b - - = - } -cleanup { grid_reset 11.4 } -returnCodes error -result {invalid window shortcut, "=" should be '-', 'x', or '^'} test grid-11.5 {default widget placement} -body { button .b grid .b - x - } -cleanup { grid_reset 11.5 } -returnCodes error -result {must specify window before shortcut '-'} test grid-11.6 {default widget placement} -body { foreach i {1 2 3 4 5 6} { frame .f$i -width 50 -height 50 -highlightthickness 0 -bg red } grid .f1 .f2 .f3 .f4 grid .f5 - x .f6 -sticky nsew update set a "" foreach i {5 6} { lappend a "[winfo x .f$i],[winfo y .f$i] \ [winfo width .f$i],[winfo height .f$i]" } return $a } -cleanup { grid_reset 11.6 } -result {{0,50 100,50} {150,50 50,50}} test grid-11.7 {default widget placement} -body { frame .f -width 20 -height 20 -highlightthickness 0 -bg red grid .f -row 5 -column 5 grid .f x - } -cleanup { grid_reset 11.7 } -returnCodes error -result {must specify window before shortcut '-'} test grid-11.8 {default widget placement} -body { frame .f -width 20 -height 20 -highlightthickness 0 -bg red grid .f -row 5 -column 5 grid .f ^ - } -cleanup { grid_reset 11.8 } -returnCodes error -result {must specify window before shortcut '-'} test grid-11.9 {default widget placement} -body { frame .f -width 20 -height 20 -highlightthickness 0 -bg red grid .f -row 5 -column 5 grid .f x ^ } -cleanup { grid_reset 11.9 } -returnCodes error -result {can't find slave to extend with "^"} test grid-11.10 {default widget placement} -body { foreach i {1 2 3} { frame .f$i -width 100 -height 50 -highlightthickness 0 -bg red } grid .f1 .f2 -sticky nsew grid .f3 ^ -sticky nsew update set a "" foreach i {1 2 3} { lappend a "[winfo x .f$i],[winfo y .f$i] \ [winfo width .f$i],[winfo height .f$i]" } return $a } -cleanup { grid_reset 11.10 } -result {{0,0 100,50} {100,0 100,100} {0,50 100,50}} test grid-11.11 {default widget placement} -body { foreach i {1 2 3 4 5 6 7 8 9 10 11 12} { frame .f$i -width 50 -height 50 -highlightthickness 1 -highlightbackground black } grid .f1 .f2 .f3 .f4 -sticky nsew grid .f5 .f6 - .f7 -sticky nsew grid .f8 ^ ^ .f9 -sticky nsew grid .f10 ^ ^ .f11 -sticky nsew grid .f12 - - - -sticky nsew update set a "" foreach i {5 6 7 8 9 10 11 12 } { lappend a "[winfo x .f$i],[winfo y .f$i] \ [winfo width .f$i],[winfo height .f$i]" } return $a } -cleanup { grid_reset 11.11 } -result {{0,50 50,50} {50,50 100,150} {150,50 50,50} {0,100 50,50} {150,100 50,50} {0,150 50,50} {150,150 50,50} {0,200 200,50}} test grid-11.12 {default widget placement} -body { foreach i {1 2 3 4} { frame .f$i -width 75 -height 50 -highlightthickness 1 -highlightbackground black } grid .f1 .f2 .f3 -sticky nsew grid .f4 ^ -sticky nsew update set a "" foreach i {1 2 3 4} { lappend a "[winfo x .f$i],[winfo y .f$i] \ [winfo width .f$i],[winfo height .f$i]" } grid .f4 ^ -column 1 update foreach i {1 2 3 4} { lappend a "[winfo x .f$i],[winfo y .f$i] \ [winfo width .f$i],[winfo height .f$i]" } return $a } -cleanup { grid_reset 11.12 } -result {{0,0 75,50} {75,0 75,100} {150,0 75,50} {0,50 75,50} {0,0 75,50} {75,0 75,100} {150,0 75,100} {75,50 75,50}} test grid-11.13 {default widget placement} -body { foreach i {1 2 3 4 5 6 7} { frame .f$i -width 40 -height 50 -highlightthickness 1 -highlightbackground black } grid .f1 .f2 .f3 .f4 .f5 -sticky nsew grid .f6 - .f7 -sticky nsew -columnspan 2 update set a "" foreach i {6 7} { lappend a "[winfo x .f$i],[winfo y .f$i] \ [winfo width .f$i],[winfo height .f$i]" } return $a } -cleanup { grid_reset 11.13 } -result {{0,50 120,50} {120,50 80,50}} test grid-11.14 {default widget placement} -body { foreach i {1 2 3} { frame .f$i -width 60 -height 60 -highlightthickness 0 -bg red } grid .f1 .f2 grid ^ .f3 update set a "" foreach i {1 2 3} { lappend a "[winfo x .f$i],[winfo y .f$i] \ [winfo width .f$i],[winfo height .f$i]" } return $a } -cleanup { grid_reset 11.14 } -result {{0,30 60,60} {60,0 60,60} {60,60 60,60}} test grid-11.15 {^ ^ test with multiple windows} -body { foreach i {1 2 3 4} { frame .f$i -width 50 -height 50 -bd 1 -relief solid } grid .f1 .f2 .f3 -sticky ns grid .f4 ^ ^ update set a "" foreach i {1 2 3 4} { lappend a "[winfo x .f$i],[winfo y .f$i]\ [winfo width .f$i],[winfo height .f$i]" } return $a } -cleanup { grid_reset 11.15 } -result {{0,0 50,50} {50,0 50,100} {100,0 50,100} {0,50 50,50}} test grid-11.16 {default widget placement} -body { foreach l {a b c d e} { frame .$l -width 50 -height 50 } grid .a .b .c .d -sticky news grid x ^ x .e -sticky news update set res "" lappend res [winfo height .a] lappend res [winfo height .b] lappend res [winfo height .c] } -cleanup { grid_reset 11.16 } -result {50 100 50} test grid-11.17 {default widget placement} -body { foreach l {a b c d e} { frame .$l -width 50 -height 50 } grid .a .b .c .d -sticky news grid ^ x ^ .e -sticky news update set res "" lappend res [winfo height .a] lappend res [winfo height .b] lappend res [winfo height .c] } -cleanup { grid_reset 11.17 } -result {100 50 100} test grid-11.18 {default widget placement} -body { foreach l {a b c d e} { frame .$l -width 50 -height 50 } grid .a .b .c .d -sticky news grid ^ ^ ^ x -in . ;# ^ and no child should work with -in. grid rowconfigure . {0 1} -uniform a update set res "" lappend res [winfo height .a] lappend res [winfo height .b] lappend res [winfo height .c] lappend res [winfo height .d] } -cleanup { grid_reset 11.18 } -result {100 100 100 50} test grid-11.19 {default widget placement} -body { foreach l {a b c d e} { frame .$l -width 50 -height 50 } grid .a .b -sticky news grid .c .d -sticky news grid ^ -in . -row 2 grid x ^ -in . -row 1 grid rowconfigure . {0 1 2} -uniform a update set res "" lappend res [winfo height .a] lappend res [winfo height .b] lappend res [winfo height .c] lappend res [winfo height .d] } -cleanup { grid_reset 11.19 } -result {50 100 100 50} test grid-12.1 {-sticky} -body { catch {unset data} frame .f -width 200 -height 100 -highlightthickness 0 -bg red set a "" grid .f grid rowconfigure . 0 -weight 1 grid columnconfigure . 0 -weight 1 grid propagate . 0 . configure -width 250 -height 150 foreach i { {} n s e w ns ew nw ne se sw nse nsw sew new nsew} { grid .f -sticky $i update array set data [grid info .f] append a "($data(-sticky)) [winfo x .f] [winfo y .f] [winfo width .f] [winfo height .f]\n" } return $a } -cleanup { grid_reset 12.1 } -result {() 25 25 200 100 (n) 25 0 200 100 (s) 25 50 200 100 (e) 50 25 200 100 (w) 0 25 200 100 (ns) 25 0 200 150 (ew) 0 25 250 100 (nw) 0 0 200 100 (ne) 50 0 200 100 (es) 50 50 200 100 (sw) 0 50 200 100 (nes) 50 0 200 150 (nsw) 0 0 200 150 (esw) 0 50 250 100 (new) 0 0 250 100 (nesw) 0 0 250 150 } test grid-12.2 {-sticky} -body { frame .f -bg red grid .f -sticky glue } -cleanup { grid_reset 12.2 } -returnCodes error -result {bad stickyness value "glue": must be a string containing n, e, s, and/or w} test grid-12.3 {-sticky} -body { frame .f -bg red grid .f -sticky {n,s,e,w} array set A [grid info .f] set A(-sticky) } -cleanup { grid_reset 12.3 } -result {nesw} test grid-13.1 {-in} -body { frame .f -bg red grid .f -in .f } -cleanup { grid_reset 13.1 } -returnCodes error -result {window can't be managed in itself} test grid-13.2 {-in} -body { frame .f -bg red list [winfo manager .f] \ [catch {grid .f -in .f} err] $err \ [winfo manager .f] } -cleanup { grid_reset 13.1.1 } -result {{} 1 {window can't be managed in itself} {}} test grid-13.3 {-in} -body { frame .f -bg red grid .f -in .bad } -cleanup { grid_reset 13.2 } -returnCodes error -result {bad window path name ".bad"} test grid-13.4 {-in} -body { frame .f -bg red toplevel .top grid .f -in .top } -cleanup { grid_reset 13.3 } -returnCodes error -result {can't put .f inside .top} destroy .top test grid-13.5 {-ipadx} -body { frame .f -width 20 -height 20 -highlightthickness 0 -bg red grid .f -ipadx x } -cleanup { grid_reset 13.4 } -returnCodes error -result {bad ipadx value "x": must be positive screen distance} test grid-13.6 {-ipadx} -body { frame .f -width 20 -height 20 -highlightthickness 0 -bg red grid .f -ipadx {5 5} } -cleanup { grid_reset 13.4.1 } -returnCodes error -result {bad ipadx value "5 5": must be positive screen distance} test grid-13.7 {-ipadx} -body { frame .f -width 200 -height 100 -highlightthickness 0 -bg red grid .f update set a [winfo width .f] grid .f -ipadx 1 update list $a [winfo width .f] } -cleanup { grid_reset 13.5 } -result {200 202} test grid-13.8 {-ipady} -body { frame .f -width 20 -height 20 -highlightthickness 0 -bg red grid .f -ipady x } -cleanup { grid_reset 13.6 } -returnCodes error -result {bad ipady value "x": must be positive screen distance} test grid-13.9 {-ipady} -body { frame .f -width 20 -height 20 -highlightthickness 0 -bg red grid .f -ipady {5 5} } -cleanup { grid_reset 13.6.1 } -returnCodes error -result {bad ipady value "5 5": must be positive screen distance} test grid-13.10 {-ipady} -body { frame .f -width 200 -height 100 -highlightthickness 0 -bg red grid .f update set a [winfo height .f] grid .f -ipady 1 update list $a [winfo height .f] } -cleanup { grid_reset 13.7 } -result {100 102} test grid-13.11 {-padx} -body { frame .f -width 20 -height 20 -highlightthickness 0 -bg red grid .f -padx x } -cleanup { grid_reset 13.8 } -returnCodes error -result {bad pad value "x": must be positive screen distance} test grid-13.12 {-padx} -body { frame .f -width 20 -height 20 -highlightthickness 0 -bg red grid .f -padx {10 x} } -cleanup { grid_reset 13.8.1 } -returnCodes error -result {bad 2nd pad value "x": must be positive screen distance} test grid-13.13 {-padx} -body { frame .f -width 200 -height 100 -highlightthickness 0 -bg red grid .f update set a "[winfo width .f] [winfo width .]" grid .f -padx 1 update list $a "[winfo width .f] [winfo width .] [winfo x .f]" } -cleanup { grid_reset 13.9 } -result {{200 200} {200 202 1}} test grid-13.14 {-padx} -body { frame .f -width 200 -height 100 -highlightthickness 0 -bg red grid .f update set a "[winfo width .f] [winfo width .]" grid .f -padx {10 5} update list $a "[winfo width .f] [winfo width .] [winfo x .f]" } -cleanup { grid_reset 13.9.1 } -result {{200 200} {200 215 10}} test grid-13.15 {-pady} -body { frame .f -width 20 -height 20 -highlightthickness 0 -bg red grid .f -pady x } -cleanup { grid_reset 13.10 } -returnCodes error -result {bad pad value "x": must be positive screen distance} test grid-13.16 {-pady} -body { frame .f -width 20 -height 20 -highlightthickness 0 -bg red grid .f -pady {10 x} } -cleanup { grid_reset 13.10.1 } -returnCodes error -result {bad 2nd pad value "x": must be positive screen distance} test grid-13.17 {-pady} -body { frame .f -width 200 -height 100 -highlightthickness 0 -bg red grid .f update set a "[winfo height .f] [winfo height .]" grid .f -pady 1 update list $a "[winfo height .f] [winfo height .] [winfo y .f]" } -cleanup { grid_reset 13.11 } -result {{100 100} {100 102 1}} test grid-13.18 {-pady} -body { frame .f -width 200 -height 100 -highlightthickness 0 -bg red grid .f update set a "[winfo height .f] [winfo height .]" grid .f -pady {4 16} update list $a "[winfo height .f] [winfo height .] [winfo y .f]" } -cleanup { grid_reset 13.11.1 } -result {{100 100} {100 120 4}} test grid-13.19 {-ipad x and y} -body { frame .f -width 20 -height 20 -highlightthickness 0 -bg red grid columnconfigure . 0 -minsize 150 grid rowconfigure . 0 -minsize 100 set a "" foreach x {0 5} { foreach y {0 5} { grid .f -ipadx $x -ipady $y update append a " $x,$y:" foreach prop {x y width height} { append a ,[winfo $prop .f] } } } return $a } -cleanup { grid_reset 13.12 } -result { 0,0:,65,40,20,20 0,5:,65,35,20,30 5,0:,60,40,30,20 5,5:,60,35,30,30} test grid-13.20 {reparenting} -body { frame .1 frame .2 button .b grid .1 .2 grid .b -in .1 set a "" catch {unset info}; array set info [grid info .b] lappend a [grid slaves .1],[grid slaves .2],$info(-in) grid .b -in .2 catch {unset info}; array set info [grid info .b] lappend a [grid slaves .1],[grid slaves .2],$info(-in) unset info return $a } -cleanup { grid_reset 13.13 } -result {.b,,.1 ,.b,.2} test grid-14.1 {structure notify} -body { frame .f -width 200 -height 100 -highlightthickness 0 -bg red frame .g -width 200 -height 100 -highlightthickness 0 -bg red grid .f grid .g -in .f update set a "" lappend a "[winfo x .g],[winfo y .g] \ [winfo width .g],[winfo height .g]" .f configure -bd 5 -relief raised update lappend a "[winfo x .g],[winfo y .g] \ [winfo width .g],[winfo height .g]" return $a } -cleanup { grid_reset 14.1 } -result {{0,0 200,100} {5,5 200,100}} test grid-14.2 {structure notify} -body { frame .f -width 200 -height 100 frame .f.g -width 200 -height 100 grid .f grid .f.g update set a "" lappend a [grid bbox .],[grid bbox .f] .f config -bd 20 update lappend a [grid bbox .],[grid bbox .f] } -cleanup { grid_reset 14.2 } -result {{0 0 200 100,0 0 200 100} {0 0 240 140,20 20 200 100}} test grid-14.3 {map notify: bug 1648} -constraints {nonPortable} -body { # This test is nonPortable because the number of times # A(.) will be incremented is unspecified--the behavior # is different accross window managers. global A catch {unset A} bind . <Configure> {incr A(%W)} set A(.) 0 |
︙ | ︙ | |||
1458 1459 1460 1461 1462 1463 1464 | update bind . <Configure> {} array get A } -cleanup { grid_reset 14.3 } -result {.2 2 .0 1 . 2 .1 1} | < < < | | < | | | | | < | | | | > > > > > > > > > > > > > > > > > > < < < < | < < < < < < < < < < < < < < < < | | | | | < < | | | | | < | | | < | | | | | | | < < < < < < < < < | < < < | < < < | < < < | < | | | < < < | < < < | < < < | 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 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 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 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 | update bind . <Configure> {} array get A } -cleanup { grid_reset 14.3 } -result {.2 2 .0 1 . 2 .1 1} test grid-15.1 {lost slave} -body { button .b grid .b set a [grid slaves .] pack .b lappend a [grid slaves .] grid .b lappend a [grid slaves .] } -cleanup { grid_reset 15.1 } -result {.b {} .b} test grid-15.2 {lost slave} -body { frame .f grid .f button .b grid .b -in .f set a [grid slaves .f] pack .b -in .f lappend a [grid slaves .f] grid .b -in .f lappend a [grid slaves .f] } -cleanup { grid_reset 15.2 } -result {.b {} .b} test grid-16.1 {layout centering} -body { foreach i {0 1 2} { frame .$i -bg gray -width 75 -height 50 -bd 2 -relief ridge grid .$i -row $i -column $i -sticky nswe } grid propagate . 0 grid anchor . center . configure -width 300 -height 250 update grid bbox . } -cleanup { grid_reset 16.1 } -result {37 50 225 150} test grid-16.2 {layout weights (expanding)} -body { foreach i {0 1 2} { frame .$i -bg gray -width 75 -height 50 -bd 2 -relief ridge grid .$i -row $i -column $i -sticky nswe grid rowconfigure . $i -weight [expr $i + 1] grid columnconfigure . $i -weight [expr $i + 1] } grid propagate . 0 . configure -width 500 -height 300 set a "" update foreach i {0 1 2} { lappend a [winfo width .$i]-[winfo height .$i] } return $a } -cleanup { grid_reset 16.2 } -result {120-75 167-100 213-125} test grid-16.3 {layout weights (shrinking)} -body { foreach i {0 1 2} { frame .$i -bg gray -width 100 -height 75 -bd 2 -relief ridge grid .$i -row $i -column $i -sticky nswe grid rowconfigure . $i -weight [expr $i + 1] grid columnconfigure . $i -weight [expr $i + 1] } grid propagate . 0 . configure -width 200 -height 150 set a "" update foreach i {0 1 2} { lappend a [winfo width .$i]-[winfo height .$i] } return $a } -cleanup { grid_reset 16.3 } -result {84-63 66-50 50-37} test grid-16.4 {layout weights (shrinking with minsize)} -body { foreach i {0 1 2} { frame .$i -bg gray -width 100 -height 75 -bd 2 -relief ridge grid .$i -row $i -column $i -sticky nswe grid rowconfigure . $i -weight [expr $i + 1] -minsize 45 grid columnconfigure . $i -weight [expr $i + 1] -minsize 65 } grid propagate . 0 . configure -width 200 -height 150 set a "" update foreach i {0 1 2} { lappend a [winfo width .$i]-[winfo height .$i] } return $a } -cleanup { grid_reset 16.4 } -result {70-60 65-45 65-45} test grid-16.5 {layout weights (shrinking at minsize)} -body { foreach i {0 1 2} { frame .$i -bg gray -width 100 -height 75 -bd 2 -relief ridge grid .$i -row $i -column $i -sticky nswe grid rowconfigure . $i -weight 0 -minsize 70 grid columnconfigure . $i -weight 0 -minsize 90 } grid propagate . 0 . configure -width 100 -height 75 set a "" update foreach i {0 1 2} { lappend a [winfo width .$i]-[winfo height .$i] } return $a } -cleanup { grid_reset 16.5 } -result {100-75 100-75 100-75} test grid-16.6 {layout weights (shrinking at minsize)} -body { foreach i {0 1 2} { frame .$i -bg gray -width 100 -height 75 -bd 2 -relief ridge grid .$i -row $i -column $i -sticky nswe grid rowconfigure . $i -weight [expr $i + 1] -minsize 52 grid columnconfigure . $i -weight [expr $i + 1] -minsize 69 } grid propagate . 0 . configure -width 200 -height 150 set a "" update foreach i {0 1 2} { lappend a [winfo width .$i]-[winfo height .$i] } return $a } -cleanup { grid_reset 16.6 } -result {69-52 69-52 69-52} # test fails when run alone # reason (I think): -minsize 0 causes both: # [winfo ismapped .$i] => 0 and # not responding for width ang height settings, so that # [winfo width .$i] [winfo height .$i] take different values # That doesn't happen if previous tests run test grid-16.7 {layout weights (shrinking at minsize)} -body { foreach i {0 1 2} { frame .$i -bg gray -width 100 -height 75 -bd 2 -relief ridge grid .$i -row $i -column $i -sticky nswe } grid propagate . 0 grid columnconfigure . 1 -weight 1 -minsize 0 grid rowconfigure . 1 -weight 1 -minsize 0 . configure -width 100 -height 1 set a "" update foreach i {0 1 2} { lappend a [winfo width .$i]-[winfo height .$i]-[winfo ismapped .$i] } return $a } -cleanup { grid_reset 16.7 } -result {100-75-1 1-1-0 100-75-1} test grid-16.8 {layout internal constraints} -body { foreach i {0 1 2 3 4} { frame .$i -bg gray -width 30 -height 25 -bd 2 -relief ridge grid .$i -row $i -column $i -sticky nswe } frame .f -bg red -width 250 -height 200 frame .g -bg green -width 200 -height 180 lower .f raise .g .f grid .f -row 1 -column 1 -rowspan 3 -columnspan 3 -sticky nswe grid .g -row 1 -column 1 -rowspan 2 -columnspan 2 -sticky nswe update set a "" foreach i {0 1 2 3 4} { append a "[winfo x .$i] " } append a ", " grid remove .f update foreach i {0 1 2 3 4} { append a "[winfo x .$i] " } append a ", " grid remove .g grid .f update foreach i {0 1 2 3 4} { append a "[winfo x .$i] " } append a ", " grid remove .f update foreach i {0 1 2 3 4} { append a "[winfo x .$i] " } return $a } -cleanup { grid_reset 16.8 } -result {0 30 130 230 280 , 0 30 130 230 260 , 0 30 113 196 280 , 0 30 60 90 120 } test grid-16.9 {layout uniform} -body { frame .f1 -width 75 -height 50 frame .f2 -width 60 -height 25 frame .f3 -width 95 -height 75 frame .f4 -width 135 -height 100 frame .f5 -width 80 -height 40 for {set t 1} {$t <= 5} {incr t} { grid .f$t } grid rowconfigure . {0 2} -uniform a grid rowconfigure . {1 3} -uniform b update list [grid bbox . 0 0] [grid bbox . 0 1] [grid bbox . 0 2] \ [grid bbox . 0 3] [grid bbox . 0 4] } -cleanup { grid_reset 16.9 } -result {{0 0 135 75} {0 75 135 100} {0 175 135 75} {0 250 135 100} {0 350 135 40}} test grid-16.10 {layout uniform} -body { grid [frame .f1 -width 75 -height 50] -row 0 -column 0 grid [frame .f2 -width 60 -height 30] -row 1 -column 2 grid [frame .f3 -width 95 -height 90] -row 2 -column 1 grid [frame .f4 -width 60 -height 100] -row 3 -column 4 grid [frame .f5 -width 60 -height 40] -row 4 -column 3 grid rowconfigure . {0 1} -uniform a grid rowconfigure . {2 4} -uniform b grid rowconfigure . {0 2} -weight 2 grid columnconfigure . {0 2} -uniform a grid columnconfigure . {3 4} -uniform b grid columnconfigure . {2 4} -weight 2 grid columnconfigure . 3 -minsize 70 grid columnconfigure . 4 -minsize 130 update list [grid bbox . 0 0] [grid bbox . 2 1] [grid bbox . 1 2] \ [grid bbox . 4 3] [grid bbox . 3 4] } -cleanup { grid_reset 16.10 } -result {{0 0 75 60} {170 60 150 30} {75 90 95 90} {390 180 140 100} {320 280 70 45}} test grid-16.11 {layout uniform (shrink)} -body { frame .f1 -width 75 -height 50 frame .f2 -width 100 -height 95 grid .f1 .f2 -sticky news grid columnconfigure . {0 1} -uniform a grid columnconfigure . 0 -weight 1 update set res {} lappend res [grid bbox . 0 0] [grid bbox . 1 0] grid propagate . 0 . configure -width 150 -height 95 update lappend res [grid bbox . 0 0] [grid bbox . 1 0] } -cleanup { grid_reset 16.11 } -result {{0 0 100 95} {100 0 100 95} {0 0 50 95} {50 0 100 95}} test grid-16.12 {layout uniform (grow)} -body { frame .f1 -width 40 -height 50 frame .f2 -width 50 -height 95 frame .f3 -width 60 -height 50 frame .f4 -width 70 -height 95 grid .f1 .f2 .f3 .f4 -sticky news grid columnconfigure . {0 1 2} -uniform a # Put weight 2 on the biggest in the group to see that the groups # adapt to one of the smaller. grid columnconfigure . 2 -weight 2 grid columnconfigure . {0 3} -weight 1 update set res {} lappend res [grid bbox . 0 0] [grid bbox . 1 0] lappend res [grid bbox . 2 0] [grid bbox . 3 0] grid propagate . 0 . configure -width 350 -height 95 update lappend res [grid bbox . 0 0] [grid bbox . 1 0] lappend res [grid bbox . 2 0] [grid bbox . 3 0] } -cleanup { grid_reset 16.12 } -result [list {0 0 50 95} {50 0 50 95} {100 0 100 95} {200 0 70 95} \ {0 0 70 95} {70 0 50 95} {120 0 140 95} {260 0 90 95}] test grid-16.13 {layout span} -body { frame .f1 -width 24 -height 20 frame .f2 -width 38 -height 20 frame .f3 -width 150 -height 20 grid .f1 - - .f2 grid .f3 - - - set res {} foreach w {{0 1 0 0} {0 0 1 0} {1 3 4 0} {1 2 1 2} {1 1 1 12}} { for {set c 0} {$c < 4} {incr c} { grid columnconfigure . $c -weight [lindex $w $c] } update set res2 {} for {set c 0} {$c <= 4} {incr c} { lappend res2 [lindex [grid bbox . $c 0] 2] } lappend res $res2 } return $res # The last result below should ideally be 8 8 8 126 but the current # implementation is not exact enough. } -cleanup { grid_reset 16.13 } -result [list [list 0 112 0 38 0] [list 0 0 112 38 0] [list 14 42 56 38 0] \ [list 18 38 18 76 0] [list 7 8 9 126 0]] test grid-16.14 {layout span} -body { frame .f1 -width 110 -height 20 frame .f2 -width 38 -height 20 frame .f3 -width 150 -height 20 grid .f1 - - .f2 grid .f3 - - - set res {} foreach w {{0 1 0 0} {0 0 1 0} {1 3 4 0} {1 2 1 3} {1 1 1 12}} { for {set c 0} {$c < 4} {incr c} { grid columnconfigure . $c -weight [lindex $w $c] } update set res2 {} for {set c 0} {$c <= 4} {incr c} { lappend res2 [lindex [grid bbox . $c 0] 2] } lappend res $res2 } return $res } -cleanup { grid_reset 16.14 } -result [list [list 0 112 0 38 0] [list 0 0 112 38 0] [list 14 42 56 38 0] \ [list 27 55 28 40 0] [list 36 37 37 40 0]] test grid-16.15 {layout span} -body { frame .f1 -width 24 -height 20 frame .f2 -width 38 -height 20 frame .f3 -width 150 -height 20 grid .f1 - - .f2 grid x .f3 - - set res {} foreach w {{0 1 0 0} {0 0 1 0} {1 0 1 0} {0 0 0 0} {1 0 0 6}} { for {set c 0} {$c < 4} {incr c} { grid columnconfigure . $c -weight [lindex $w $c] } update set res2 {} for {set c 0} {$c <= 4} {incr c} { lappend res2 [lindex [grid bbox . $c 0] 2] } lappend res $res2 } return $res } -cleanup { grid_reset 16.15 } -result [list [list 0 112 0 38 0] [list 0 0 112 38 0] [list 0 0 112 38 0] \ [list 0 37 37 76 0] [list 0 12 12 126 0]] test grid-16.16 {layout span} -body { frame .f1 -width 64 -height 20 frame .f2 -width 38 -height 20 frame .f3 -width 150 -height 20 frame .f4 -width 15 -height 20 frame .f5 -width 18 -height 20 frame .f6 -width 20 -height 20 grid .f1 - x .f2 grid .f3 - - - grid .f4 .f5 .f6 set res {} foreach w {{1 1 5 1} {0 0 1 0} {1 3 4 0} {1 2 1 2} {1 1 1 12}} { for {set c 0} {$c < 4} {incr c} { grid columnconfigure . $c -weight [lindex $w $c] } update set res2 {} for {set c 0} {$c <= 4} {incr c} { lappend res2 [lindex [grid bbox . $c 0] 2] } lappend res $res2 } return $res } -cleanup { grid_reset 16.16 } -result [list [list 30 34 43 43 0] [list 30 34 48 38 0] [list 22 42 48 38 0] \ [list 25 39 29 57 0] [list 30 34 22 64 0]] test grid-16.17 {layout weights (shrinking at minsize)} -body { foreach i {0 1 2 3} { frame .$i -bg gray -width 100 -height 75 -bd 2 -relief ridge grid .$i -row $i -column $i -sticky nswe } grid propagate . 0 grid columnconfigure . {0 1} -weight 1 -minsize 0 grid rowconfigure . {0 1} -weight 1 -minsize 0 set a "" . configure -width 250 -height 200 update foreach i {0 1 2 3} { lappend a [winfo width .$i]-[winfo height .$i]-[winfo ismapped .$i] } . configure -width 150 -height 100 update foreach i {0 1 2 3} { lappend a [winfo width .$i]-[winfo height .$i]-[winfo ismapped .$i] } return $a } -cleanup { grid_reset 16.17 } -result {25-25-1 25-25-1 100-75-1 100-75-1 25-25-0 25-25-0 100-75-1 100-75-1} test grid-16.18 {layout span} -body { frame .f1 -width 30 -height 20 frame .f2 -width 166 -height 20 frame .f3 -width 39 -height 20 frame .f4 -width 10 -height 20 grid .f1 .f3 - grid .f2 - .f4 grid columnconfigure . 0 -weight 1 set res {} foreach w {{1 0 0} {0 1 0} {0 0 1}} { for {set c 0} {$c < 3} {incr c} { grid columnconfigure . $c -weight [lindex $w $c] } update set res2 {} for {set c 0} {$c <= 2} {incr c} { lappend res2 [lindex [grid bbox . $c 0] 2] } lappend res $res2 } return $res } -cleanup { grid_reset 16.18 } -result [list [list 137 29 10] [list 30 136 10] [list 98 68 10]] test grid-16.19 {layout span} -constraints { knownBug } -body { # This test shows the problem in Bug 2075285 # Several overlapping multi-span widgets is a weak spot # in the current implementation. # Test present as a reminder in case a future algorithm update is made. frame .f1 -width 100 -height 20 frame .f2 -width 20 -height 20 frame .f3 -width 10 -height 20 frame .f4 -width 20 -height 20 grid .f1 - - - - - -sticky we grid .f2 - .f3 - .f4 - -sticky we grid columnconfigure . {1 5} -weight 1 set res {} update for {set c 0} {$c <= 5} {incr c} { lappend res [lindex [grid bbox . $c 0] 2] } return $res } -cleanup { grid_reset 16.19 } -result [list 0 45 5 5 0 45] test grid-17.1 {forget and pending idle handlers} -body { # This test is intended to detect a crash caused by a failure to remove # pending idle handlers when grid forget is invoked. toplevel .t wm geometry .t +0+0 frame .t.f label .t.f.l -text foobar grid .t.f.l grid .t.f update grid forget .t.f.l grid forget .t.f destroy .t toplevel .t frame .t.f label .t.f.l -text foobar grid .t.f.l destroy .t set result ok } -result ok |
︙ | ︙ | |||
1970 1971 1972 1973 1974 1975 1976 | grid rowconfigure .pack.lf 0 -weight 1 update set res [list [winfo geometry .pack.lf.f]] .pack.lf configure -labelanchor e -padx 3 -pady 5 update lappend res [winfo geometry .pack.lf.f] destroy .pack | | | < < < < < < < < < | | < | < < | | < | < | < < < < | > > > > | 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 | grid rowconfigure .pack.lf 0 -weight 1 update set res [list [winfo geometry .pack.lf.f]] .pack.lf configure -labelanchor e -padx 3 -pady 5 update lappend res [winfo geometry .pack.lf.f] destroy .pack return $res } -result {196x188+2+10 177x186+5+7} test grid-18.2 {test support for minreqsize} -body { toplevel .pack wm geometry .pack {} frame .pack.l -width 150 -height 100 labelframe .pack.lf -labelwidget .pack.l pack .pack.lf -fill both -expand 1 frame .pack.lf.f -width 20 -height 25 grid .pack.lf.f update set res [list [winfo geometry .pack.lf]] .pack.lf configure -labelanchor ws update lappend res [winfo geometry .pack.lf] destroy .pack return $res } -result {162x127+0+0 172x112+0+0} test grid-19.1 {uniform realloc} -body { # Use a lot of uniform groups to test the reallocation mechanism for {set t 0} {$t < 100} {incr t 2} { frame .fa$t -width 5 -height 20 frame .fb$t -width 6 -height 20 grid .fa$t .fb$t -row 0 -column $t -sticky news grid columnconfigure . [list $t [expr {$t + 1}]] -uniform a$t } update grid bbox . } -cleanup { grid_reset 19.1 } -result {0 0 600 20} test grid-20.1 {recalculate size after removal (destroy)} -body { label .l1 -text l1 grid .l1 -row 2 -column 2 destroy .l1 label .l2 -text l2 grid .l2 grid size . } -cleanup { grid_reset 20.1 } -result {1 1} test grid-20.2 {recalculate size after removal (forget)} -body { label .l1 -text l1 grid .l1 -row 2 -column 2 grid forget .l1 label .l2 -text l2 grid .l2 grid size . } -cleanup { grid_reset 20.2 } -result {1 1} test grid-21.1 {anchor} -body { grid anchor . 1 xxx } -cleanup { grid_reset 21.1 } -returnCodes error -result {wrong # args: should be "grid anchor window ?anchor?"} test grid-21.2 {anchor} -body { grid anchor . } -cleanup { grid_reset 21.2 } -result {nw} test grid-21.3 {anchor} -body { grid anchor . se;grid anchor . } -cleanup { grid_reset 21.3 } -result {se} test grid-21.4 {anchor} -body { grid anchor .x } -cleanup { grid_reset 21.4 } -returnCodes error -result {bad window path name ".x"} test grid-21.5 {anchor} -body { grid anchor . x } -cleanup { grid_reset 21.5 } -returnCodes error -result {bad anchor "x": must be n, ne, e, se, s, sw, w, nw, or center} test grid-21.6 {anchor} -body { foreach i {0 1 2} { frame .$i -bg gray -width 75 -height 50 -bd 2 -relief ridge grid .$i -row $i -column $i -sticky nswe } grid propagate . 0 . configure -width 300 -height 250 set res {} foreach a {n ne e se s sw w nw center} { grid anchor . $a update lappend res [grid bbox .] } return $res } -cleanup { grid_reset 21.6 } -result [list {37 0 225 150} {75 0 225 150} {75 50 225 150} {75 100 225 150} \ {37 100 225 150} {0 100 225 150} {0 50 225 150} {0 0 225 150} \ {37 50 225 150}] test grid-21.7 {anchor} -body { # Test with a non-symmetric internal border. # This only tests vertically, there is currently no way to get # it assymetric horizontally. labelframe .f -bd 0 frame .f.x -width 20 -height 20 .f configure -labelwidget .f.x pack .f -fill both -expand 1 foreach i {0 1 2} { frame .$i -bg gray -width 75 -height 50 -bd 2 -relief ridge grid .$i -in .f -row $i -column $i -sticky nswe } pack propagate . 0 grid propagate .f 0 . configure -width 300 -height 250 set res {} foreach a {n ne e se s sw w nw center} { grid anchor .f $a update lappend res [grid bbox .f] } pack propagate . 1 ; wm geometry . {} return $res } -cleanup { grid_reset 21.7 } -result [list {37 20 225 150} {75 20 225 150} {75 60 225 150} {75 100 225 150} \ {37 100 225 150} {0 100 225 150} {0 60 225 150} {0 20 225 150} \ {37 60 225 150}] test grid-22.1 {remove: basic argument checking} { list [catch {grid remove foo} msg] $msg } {1 {bad window path name "foo"}} test grid-22.2 {remove} { button .c grid [button .b] set a [grid slaves .] grid remove .b .c lappend a [grid slaves .] return $a } {.b {}} grid_reset 22.2 test grid-22.3 {remove} { button .c grid .c -row 2 -column 2 -rowspan 2 -columnspan 2 -padx 3 -pady 4 -sticky ns grid remove .c grid .c -row 0 -column 0 grid info .c } {-in . -column 0 -row 0 -columnspan 2 -rowspan 2 -ipadx 0 -ipady 0 -padx 3 -pady 4 -sticky ns} grid_reset 22.3 test grid-22.3.1 {remove} { frame .a button .c grid .c -in .a -row 2 -column 2 -rowspan 2 -columnspan 2 -padx {3 5} -pady {4 7} -sticky ns grid remove .c grid .c -row 0 -column 0 grid info .c } {-in .a -column 0 -row 0 -columnspan 2 -rowspan 2 -ipadx 0 -ipady 0 -padx {3 5} -pady {4 7} -sticky ns} grid_reset 22.3.1 test grid-22.4 {remove, calling Tk_UnmaintainGeometry} { frame .f -bd 2 -relief raised place .f -x 10 -y 20 -width 200 -height 100 frame .f2 -width 50 -height 30 -bg red grid .f2 -in .f update set x [winfo ismapped .f2] grid remove .f2 place .f -x 30 update lappend x [winfo ismapped .f2] } {1 0} grid_reset 22.4 test grid-22.5 {remove} { frame .a button .c grid .c -in .a -row 2 -column 2 -rowspan 2 -columnspan 2 -padx {3 5} -pady {4 7} -sticky ns grid remove .c # If .a was destroyed while remembered by the removed .c, make sure it # is ignored. destroy .a grid .c -row 0 -column 0 grid info .c } {-in . -column 0 -row 0 -columnspan 2 -rowspan 2 -ipadx 0 -ipady 0 -padx {3 5} -pady {4 7} -sticky ns} grid_reset 22.5 # cleanup cleanupTests return # Local Variables: # mode: tcl # End: |
Changes to tests/text.test.
︙ | ︙ | |||
1393 1394 1395 1396 1397 1398 1399 | } -body { .t insert 1.0 "Line 1 abcdefghijklm 12345" .t replace 3.1 2.3 foo } -cleanup { destroy .t | | | 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 | } -body { .t insert 1.0 "Line 1 abcdefghijklm 12345" .t replace 3.1 2.3 foo } -cleanup { destroy .t } -returnCodes {error} -result {index "2.3" before "3.1" in the text} test text-8.20 {TextWidgetCmd procedure, "replace" option} -setup { text .t } -body { .t insert 1.0 "Line 1 abcdefghijklm 12345 Line 4 |
︙ | ︙ | |||
3701 3702 3703 3704 3705 3706 3707 | test text-22.1 {TextSearchCmd procedure, argument parsing} -body { text .t .t search - } -cleanup { destroy .t | | | 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 | test text-22.1 {TextSearchCmd procedure, argument parsing} -body { text .t .t search - } -cleanup { destroy .t } -returnCodes error -result {ambiguous switch "-": must be --, -all, -backwards, -count, -elide, -exact, -forwards, -nocase, -nolinestop, -overlap, -regexp, or -strictlimits} test text-22.2 {TextSearchCmd procedure, -backwards option} -body { text .t .t insert end "xxyz xyz x. the\nfoo -forward bar xxxxx BaR foo\nxyz xxyzx" .t search -backwards xyz 1.4 } -cleanup { destroy .t } -result {1.1} |
︙ | ︙ | |||
3765 3766 3767 3768 3769 3770 3771 | } -result {2.13 2.23} test text-22.10 {TextSearchCmd procedure, -n ambiguous option} -body { text .t .t insert end "xxyz xyz x. the\nfoo -forward bar xxxxx BaR foo\nxyz xxyzx" .t search -n BaR 1.1 } -cleanup { destroy .t | | | 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 | } -result {2.13 2.23} test text-22.10 {TextSearchCmd procedure, -n ambiguous option} -body { text .t .t insert end "xxyz xyz x. the\nfoo -forward bar xxxxx BaR foo\nxyz xxyzx" .t search -n BaR 1.1 } -cleanup { destroy .t } -returnCodes error -result {ambiguous switch "-n": must be --, -all, -backwards, -count, -elide, -exact, -forwards, -nocase, -nolinestop, -overlap, -regexp, or -strictlimits} test text-22.11 {TextSearchCmd procedure, -nocase option} -body { text .t .t insert end "xxyz xyz x. the\nfoo -forward bar xxxxx BaR foo\nxyz xxyzx" .t search -noc BaR 1.1 } -cleanup { destroy .t } -result {2.13} |
︙ | ︙ |
Changes to tests/ttk/treeview.test.
︙ | ︙ | |||
401 402 403 404 405 406 407 | .tv move d3 d 0 consistencyCheck .tv .tv children d } -result [list d3 d1 d2] test treeview-7.2 "illegal move" -body { .tv move d d2 end | | | | 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 | .tv move d3 d 0 consistencyCheck .tv .tv children d } -result [list d3 d1 d2] test treeview-7.2 "illegal move" -body { .tv move d d2 end } -returnCodes 1 -result "Cannot insert d as descendant of d2" test treeview-7.3 "illegal move has no effect" -body { consistencyCheck .tv .tv children d } -result [list d3 d1 d2] test treeview-7.4 "Replace children" -body { .tv children d [list d3 d2 d1] consistencyCheck .tv .tv children d } -result [list d3 d2 d1] test treeview-7.5 "replace children - precondition" -body { # Just check to make sure the test suite so far has left # us in the state we expect to be in: list [.tv parent newnode] [.tv children newnode] } -result [list {} [list newnode.n1 newnode.n2 newnode.n3]] test treeview-7.6 "Replace children - illegal move" -body { .tv children newnode.n1 [list newnode.n1 newnode.n2 newnode.n3] } -returnCodes 1 -result "Cannot insert newnode.n1 as descendant of newnode.n1" consistencyCheck .tv test treeview-8.0 "Selection set" -body { .tv selection set [list newnode.n1 newnode.n3 newnode.n2] .tv selection } -result [list newnode.n1 newnode.n2 newnode.n3] |
︙ | ︙ |
Changes to tests/ttk/ttk.test.
︙ | ︙ | |||
44 45 46 47 48 49 50 | proc kill.b {args} { destroy .b } } -cleanup { unset OUCH } -body { pack [ttk::checkbutton .b] set rc [catch { .b configure -variable OUCH } msg] list $rc $msg [winfo exists .b] [info commands .b] | | | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | proc kill.b {args} { destroy .b } } -cleanup { unset OUCH } -body { pack [ttk::checkbutton .b] set rc [catch { .b configure -variable OUCH } msg] list $rc $msg [winfo exists .b] [info commands .b] } -result [list 1 "widget has been destroyed" 0 {}] test ttk-6.5 "Clean up -textvariable traces" -body { foreach class {ttk::button ttk::checkbutton ttk::radiobutton} { $class .b1 -textvariable V set V "asdf" destroy .b1 set V "" |
︙ | ︙ | |||
117 118 119 120 121 122 123 | } -body { list \ [catch { ttk::checkbutton .b -variable OUCH } msg] \ $msg \ [winfo exists .b] \ [info commands .b] \ ; | | | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | } -body { list \ [catch { ttk::checkbutton .b -variable OUCH } msg] \ $msg \ [winfo exists .b] \ [info commands .b] \ ; } -result [list 1 "widget has been destroyed" 0 {}] test ttk-selfdestruct-ok-1 "Intentional self-destruction" -body { # see #2298720 toplevel .t ttk::button .t.b -command [list destroy .t] .t.b invoke list [winfo exists .t] [winfo exists .t.b] |
︙ | ︙ | |||
218 219 220 221 222 223 224 | destroy .b unset -nocomplain ttk28 aid } -result 1 foreach wc $widgetClasses { test ttk-coreoptions-$wc "$wc has all core options" -body { ttk::$wc .w | | < < < < < > | | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | destroy .b unset -nocomplain ttk28 aid } -result 1 foreach wc $widgetClasses { test ttk-coreoptions-$wc "$wc has all core options" -body { ttk::$wc .w foreach option {-class -style -cursor -takefocus} { .w cget $option } } -cleanup { catch {destroy .w} } } # misc. error detection test ttk-3.0 "Bad option" -body { ttk::button .bad -badoption foo } -returnCodes 1 -result {unknown option "-badoption"} -match glob |
︙ | ︙ |
Changes to unix/tkUnix.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkInt.h" #ifdef HAVE_XSS | | > > > > > > > | < < | | | | | < | 9 10 11 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkInt.h" #ifdef HAVE_XSS # include <X11/extensions/scrnsaver.h> # ifdef __APPLE__ /* Support for weak-linked libXss. */ # define HaveXSSLibrary() (XScreenSaverQueryInfo != NULL) # else /* Other platforms always link libXss. */ # define HaveXSSLibrary() (1) # endif #endif /* *---------------------------------------------------------------------- * * TkGetServerInfo -- * * Given a window, this procedure returns information about the window * server for that window. This procedure provides the guts of the "winfo * server" command. * * Results: * Sets the interpreter result. * * Side effects: * None. * *---------------------------------------------------------------------- */ void TkGetServerInfo( Tcl_Interp *interp, /* The server information is returned in this * interpreter's result. */ Tk_Window tkwin) /* Token for window; this selects a particular * display and server. */ { Tcl_SetObjResult(interp, Tcl_ObjPrintf("X%dR%d %s %d", ProtocolVersion(Tk_Display(tkwin)), ProtocolRevision(Tk_Display(tkwin)), ServerVendor(Tk_Display(tkwin)), VendorRelease(Tk_Display(tkwin)))); } /* *---------------------------------------------------------------------- * * TkGetDefaultScreenName -- * |
︙ | ︙ | |||
203 204 205 206 207 208 209 | int eventBase, errorBase, major, minor; /* * Calling XScreenSaverQueryVersion seems to be needed to prevent a crash * on some buggy versions of XFree86. */ | | < < < | | < | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | int eventBase, errorBase, major, minor; /* * Calling XScreenSaverQueryVersion seems to be needed to prevent a crash * on some buggy versions of XFree86. */ if (HaveXSSLibrary() && XScreenSaverQueryExtension(dpy, &eventBase, &errorBase) && XScreenSaverQueryVersion(dpy, &major, &minor)) { XScreenSaverInfo *info = XScreenSaverAllocInfo(); if (info == NULL) { /* * We are out of memory. */ |
︙ | ︙ |
Changes to unix/tkUnixCursor.c.
︙ | ︙ | |||
178 179 180 181 182 183 184 | #ifndef CURSORFONT #define CURSORFONT "cursor" #endif static Cursor CreateCursorFromTableOrFile(Tcl_Interp *interp, Tk_Window tkwin, int argc, const char **argv, const struct TkCursorName *tkCursorPtr); | | | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | #ifndef CURSORFONT #define CURSORFONT "cursor" #endif static Cursor CreateCursorFromTableOrFile(Tcl_Interp *interp, Tk_Window tkwin, int argc, const char **argv, const struct TkCursorName *tkCursorPtr); /* *---------------------------------------------------------------------- * * TkGetCursorByName -- * * Retrieve a cursor by name. Parse the cursor name into fields and * create a cursor, either from the standard cursor font or from bitmap |
︙ | ︙ | |||
271 272 273 274 275 276 277 | maskIndex = namePtr->shape + 1; if (argc == 1) { fg.red = fg.green = fg.blue = 0; bg.red = bg.green = bg.blue = 65535; } else { if (TkParseColor(display, Tk_Colormap(tkwin), argv[1], &fg) == 0) { | > | | > | | > | > > | > | | 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 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 | maskIndex = namePtr->shape + 1; if (argc == 1) { fg.red = fg.green = fg.blue = 0; bg.red = bg.green = bg.blue = 65535; } else { if (TkParseColor(display, Tk_Colormap(tkwin), argv[1], &fg) == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid color name \"%s\"", argv[1])); Tcl_SetErrorCode(interp, "TK", "CURSOR", "COLOR", NULL); goto cleanup; } if (argc == 2) { bg.red = bg.green = bg.blue = 0; maskIndex = namePtr->shape; } else if (TkParseColor(display, Tk_Colormap(tkwin), argv[2], &bg) == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid color name \"%s\"", argv[2])); Tcl_SetErrorCode(interp, "TK", "CURSOR", "COLOR", NULL); goto cleanup; } } dispPtr = ((TkWindow *) tkwin)->dispPtr; if (dispPtr->cursorFont == None) { dispPtr->cursorFont = XLoadFont(display, CURSORFONT); if (dispPtr->cursorFont == None) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "couldn't load cursor font", -1)); Tcl_SetErrorCode(interp, "TK", "CURSOR", "FONT", NULL); goto cleanup; } } cursor = XCreateGlyphCursor(display, dispPtr->cursorFont, dispPtr->cursorFont, namePtr->shape, maskIndex, &fg, &bg); } else { /* * Prevent file system access in safe interpreters. */ if (!inTkTable && Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't get cursor from a file in a safe interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "CURSOR_FILE", NULL); cursorPtr = NULL; goto cleanup; } /* * If the cursor is to be created from bitmap files, then there should * be either two elements in the list (source, color) or four (source |
︙ | ︙ | |||
343 344 345 346 347 348 349 | } return (TkCursor *) cursorPtr; badString: if (argv) { ckfree(argv); } | | > | | 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | } return (TkCursor *) cursorPtr; badString: if (argv) { ckfree(argv); } Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad cursor spec \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "CURSOR", NULL); return NULL; } /* *---------------------------------------------------------------------- * * CreateCursorFromTableOrFile -- * * Create a cursor defined in a file or the Tk static cursor table. A * cursor defined in a file starts with the '@' character. This method |
︙ | ︙ | |||
415 416 417 418 419 420 421 | */ char *data; data = TkGetBitmapData(NULL, tkCursorPtr->data, NULL, &width, &height, &xHot, &yHot); if (data == NULL) { | > | | > | | > | < | | > > | | > | | > | | | 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 | */ char *data; data = TkGetBitmapData(NULL, tkCursorPtr->data, NULL, &width, &height, &xHot, &yHot); if (data == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error reading bitmap data for \"%s\"", argv[0])); Tcl_SetErrorCode(interp, "TK", "CURSOR", "BITMAP_DATA", NULL); goto cleanup; } source = XCreateBitmapFromData(display, drawable, data, width,height); ckfree(data); } else { if (TkReadBitmapFile(display, drawable, &argv[0][1], (unsigned *) &width, (unsigned *) &height, &source, &xHot, &yHot) != BitmapSuccess) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "cleanup reading bitmap file \"%s\"", &argv[0][1])); Tcl_SetErrorCode(interp, "TK", "CURSOR", "BITMAP_FILE", NULL); goto cleanup; } } if ((xHot < 0) || (yHot < 0) || (xHot >= width) || (yHot >= height)) { if (inTkTable) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad hot spot in bitmap data for \"%s\"", argv[0])); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad hot spot in bitmap file \"%s\"", &argv[0][1])); } Tcl_SetErrorCode(interp, "TK", "CURSOR", "HOTSPOT", NULL); goto cleanup; } /* * Parse color names from optional fg and bg arguments */ if (argc == 1) { fg.red = fg.green = fg.blue = 0; bg.red = bg.green = bg.blue = 65535; } else if (argc == 2) { fgColor = argv[1]; if (TkParseColor(display, Tk_Colormap(tkwin), fgColor, &fg) == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid color name \"%s\"", fgColor)); Tcl_SetErrorCode(interp, "TK", "CURSOR", "COLOR", NULL); goto cleanup; } if (inTkTable) { bg.red = bg.green = bg.blue = 0; } else { bg = fg; } } else { /* 3 or 4 arguments */ if (inTkTable) { fgColor = argv[1]; bgColor = argv[2]; } else { fgColor = argv[2]; bgColor = argv[3]; } if (TkParseColor(display, Tk_Colormap(tkwin), fgColor, &fg) == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid color name \"%s\"", fgColor)); Tcl_SetErrorCode(interp, "TK", "CURSOR", "COLOR", NULL); goto cleanup; } if (TkParseColor(display, Tk_Colormap(tkwin), bgColor, &bg) == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid color name \"%s\"", bgColor)); Tcl_SetErrorCode(interp, "TK", "CURSOR", "COLOR", NULL); goto cleanup; } } /* * If there is no mask data, then create the cursor now. */ |
︙ | ︙ | |||
507 508 509 510 511 512 513 | */ char *data; data = TkGetBitmapData(NULL, tkCursorPtr->mask, NULL, &maskWidth, &maskHeight, &dummy1, &dummy2); if (data == NULL) { | > | | > | | > | < > | | 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 | */ char *data; data = TkGetBitmapData(NULL, tkCursorPtr->mask, NULL, &maskWidth, &maskHeight, &dummy1, &dummy2); if (data == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error reading bitmap mask data for \"%s\"", argv[0])); Tcl_SetErrorCode(interp, "TK", "CURSOR", "MASK_DATA", NULL); goto cleanup; } mask = XCreateBitmapFromData(display, drawable, data, maskWidth, maskHeight); ckfree(data); } else { if (TkReadBitmapFile(display, drawable, argv[1], (unsigned int *) &maskWidth, (unsigned int *) &maskHeight, &mask, &dummy1, &dummy2) != BitmapSuccess) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "cleanup reading bitmap file \"%s\"", argv[1])); Tcl_SetErrorCode(interp, "TK", "CURSOR", "MASK_FILE", NULL); goto cleanup; } } if ((maskWidth != width) || (maskHeight != height)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "source and mask bitmaps have different sizes", -1)); Tcl_SetErrorCode(interp, "TK", "CURSOR", "SIZE_MATCH", NULL); goto cleanup; } cursor = XCreatePixmapCursor(display, source, mask, &fg, &bg, (unsigned) xHot, (unsigned) yHot); cleanup: if (source != None) { Tk_FreePixmap(display, source); } if (mask != None) { Tk_FreePixmap(display, mask); } return cursor; } /* *---------------------------------------------------------------------- * * TkCreateCursorFromData -- * * Creates a cursor from the source and mask bits. * |
︙ | ︙ | |||
594 595 596 597 598 599 600 | if (cursor != None) { cursorPtr = ckalloc(sizeof(TkUnixCursor)); cursorPtr->info.cursor = (Tk_Cursor) cursor; cursorPtr->display = display; } return (TkCursor *) cursorPtr; } | | | 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 | if (cursor != None) { cursorPtr = ckalloc(sizeof(TkUnixCursor)); cursorPtr->info.cursor = (Tk_Cursor) cursor; cursorPtr->display = display; } return (TkCursor *) cursorPtr; } /* *---------------------------------------------------------------------- * * TkpFreeCursor -- * * This function is called to release a cursor allocated by * TkGetCursorByName. |
︙ | ︙ | |||
621 622 623 624 625 626 627 | TkCursor *cursorPtr) { TkUnixCursor *unixCursorPtr = (TkUnixCursor *) cursorPtr; XFreeCursor(unixCursorPtr->display, (Cursor) unixCursorPtr->info.cursor); Tk_FreeXId(unixCursorPtr->display, (XID) unixCursorPtr->info.cursor); } | | | 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | TkCursor *cursorPtr) { TkUnixCursor *unixCursorPtr = (TkUnixCursor *) cursorPtr; XFreeCursor(unixCursorPtr->display, (Cursor) unixCursorPtr->info.cursor); Tk_FreeXId(unixCursorPtr->display, (XID) unixCursorPtr->info.cursor); } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to unix/tkUnixEmbed.c.
︙ | ︙ | |||
102 103 104 105 106 107 108 | TkWindow *winPtr = (TkWindow *) tkwin; TkWindow *usePtr; int id, anyError; Window parent; Tk_ErrorHandler handler; Container *containerPtr; XWindowAttributes parentAtts; | | | | > | < | | > > | < > | | | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 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 150 151 152 153 154 155 156 157 158 | TkWindow *winPtr = (TkWindow *) tkwin; TkWindow *usePtr; int id, anyError; Window parent; Tk_ErrorHandler handler; Container *containerPtr; XWindowAttributes parentAtts; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (winPtr->window != None) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't modify container after widget is created", -1)); Tcl_SetErrorCode(interp, "TK", "EMBED", "POST_CREATE", NULL); return TCL_ERROR; } if (Tcl_GetInt(interp, string, &id) != TCL_OK) { return TCL_ERROR; } parent = (Window) id; usePtr = (TkWindow *) Tk_IdToWindow(winPtr->display, parent); if (usePtr != NULL && !(usePtr->flags & TK_CONTAINER)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" doesn't have -container option set", usePtr->pathName)); Tcl_SetErrorCode(interp, "TK", "EMBED", "CONTAINER", NULL); return TCL_ERROR; } /* * Tk sets the window colormap to the screen default colormap in * tkWindow.c:AllocWindow. This doesn't work well for embedded windows. So * we override the colormap and visual settings to be the same as the * parent window (which is in the container app). */ anyError = 0; handler = Tk_CreateErrorHandler(winPtr->display, -1, -1, -1, EmbedErrorProc, &anyError); if (!XGetWindowAttributes(winPtr->display, parent, &parentAtts)) { anyError = 1; } XSync(winPtr->display, False); Tk_DeleteErrorHandler(handler); if (anyError) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't create child of window \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "EMBED", "NO_TARGET", NULL); } return TCL_ERROR; } Tk_SetWindowVisual(tkwin, parentAtts.visual, parentAtts.depth, parentAtts.colormap); /* |
︙ | ︙ | |||
211 212 213 214 215 216 217 | TkpMakeWindow( TkWindow *winPtr, /* Tk's information about the window that is * to be instantiated. */ Window parent) /* Window system token for the parent in which * the window is to be created. */ { Container *containerPtr; | | | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | TkpMakeWindow( TkWindow *winPtr, /* Tk's information about the window that is * to be instantiated. */ Window parent) /* Window system token for the parent in which * the window is to be created. */ { Container *containerPtr; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (winPtr->flags & TK_EMBEDDED) { /* * This window is embedded. Don't create the new window in the given * parent; instead, create it as a child of the root window of the * container's screen. The window will get reparented into a wrapper |
︙ | ︙ | |||
267 268 269 270 271 272 273 | void TkpMakeContainer( Tk_Window tkwin) /* Token for a window that is about to become * a container. */ { TkWindow *winPtr = (TkWindow *) tkwin; Container *containerPtr; | | | 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | void TkpMakeContainer( Tk_Window tkwin) /* Token for a window that is about to become * a container. */ { TkWindow *winPtr = (TkWindow *) tkwin; Container *containerPtr; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * Register the window as a container so that, for example, we can find * out later if the embedded app. is in the same process. */ |
︙ | ︙ | |||
327 328 329 330 331 332 333 | static int EmbedErrorProc( ClientData clientData, /* Points to integer to set. */ XErrorEvent *errEventPtr) /* Points to information about error (not * used). */ { | | | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | static int EmbedErrorProc( ClientData clientData, /* Points to integer to set. */ XErrorEvent *errEventPtr) /* Points to information about error (not * used). */ { int *iPtr = clientData; *iPtr = 1; return 0; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
357 358 359 360 361 362 363 | */ static void EmbeddedEventProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { | | | 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | */ static void EmbeddedEventProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { TkWindow *winPtr = clientData; if (eventPtr->type == DestroyNotify) { EmbedWindowDeleted(winPtr); } } /* |
︙ | ︙ | |||
389 390 391 392 393 394 395 | */ static void ContainerEventProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { | | | | 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | */ static void ContainerEventProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { TkWindow *winPtr = clientData; Container *containerPtr; Tk_ErrorHandler errHandler; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * Ignore any X protocol errors that happen in this function (almost any * operation could fail, for example, if the embedded application has * deleted its window). */ |
︙ | ︙ | |||
494 495 496 497 498 499 500 | */ static void EmbedStructureProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { | | | 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | */ static void EmbedStructureProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { Container *containerPtr = clientData; Tk_ErrorHandler errHandler; if (eventPtr->type == ConfigureNotify) { if (containerPtr->wrapper != None) { /* * Ignore errors, since the embedded application could have * deleted its window. |
︙ | ︙ | |||
541 542 543 544 545 546 547 | */ static void EmbedFocusProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { | | | 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | */ static void EmbedFocusProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { Container *containerPtr = clientData; Tk_ErrorHandler errHandler; Display *display; display = Tk_Display(containerPtr->parentPtr); if (eventPtr->type == FocusIn) { /* * The focus just arrived at the container. Change the X focus to move |
︙ | ︙ | |||
699 700 701 702 703 704 705 | TkWindow * TkpGetOtherWindow( TkWindow *winPtr) /* Tk's structure for a container or embedded * window. */ { Container *containerPtr; | | | 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 | TkWindow * TkpGetOtherWindow( TkWindow *winPtr) /* Tk's structure for a container or embedded * window. */ { Container *containerPtr; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); for (containerPtr = tsdPtr->firstContainerPtr; containerPtr != NULL; containerPtr = containerPtr->nextPtr) { if (containerPtr->embeddedPtr == winPtr) { return containerPtr->parentPtr; |
︙ | ︙ | |||
745 746 747 748 749 750 751 | TkWindow *winPtr, /* Window to which the event was originally * reported. */ XEvent *eventPtr) /* X event to redirect (should be KeyPress or * KeyRelease). */ { Container *containerPtr; Window saved; | | | 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 | TkWindow *winPtr, /* Window to which the event was originally * reported. */ XEvent *eventPtr) /* X event to redirect (should be KeyPress or * KeyRelease). */ { Container *containerPtr; Window saved; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * First, find the top-level window corresponding to winPtr. */ while (1) { |
︙ | ︙ | |||
817 818 819 820 821 822 823 | * window; should be embedded. */ int force) /* One means that the container should claim * the focus if it doesn't currently have * it. */ { XEvent event; Container *containerPtr; | | | 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 | * window; should be embedded. */ int force) /* One means that the container should claim * the focus if it doesn't currently have * it. */ { XEvent event; Container *containerPtr; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!(topLevelPtr->flags & TK_EMBEDDED)) { return; } for (containerPtr = tsdPtr->firstContainerPtr; |
︙ | ︙ | |||
868 869 870 871 872 873 874 | int argc, /* Number of arguments. */ const char **argv) /* Argument strings. */ { int all; Container *containerPtr; Tcl_DString dString; char buffer[50]; | | | 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 | int argc, /* Number of arguments. */ const char **argv) /* Argument strings. */ { int all; Container *containerPtr; Tcl_DString dString; char buffer[50]; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if ((argc > 1) && (strcmp(argv[1], "all") == 0)) { all = 1; } else { all = 0; } |
︙ | ︙ | |||
938 939 940 941 942 943 944 | static void EmbedWindowDeleted( TkWindow *winPtr) /* Tk's information about window that was * deleted. */ { Container *containerPtr, *prevPtr; | | | 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 | static void EmbedWindowDeleted( TkWindow *winPtr) /* Tk's information about window that was * deleted. */ { Container *containerPtr, *prevPtr; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * Find the Container structure for this window work. Delete the * information about the embedded application and free the container's * record. */ |
︙ | ︙ | |||
996 997 998 999 1000 1001 1002 | */ Window TkUnixContainerId( TkWindow *winPtr) /* Tk's structure for an embedded window. */ { Container *containerPtr; | | | 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 | */ Window TkUnixContainerId( TkWindow *winPtr) /* Tk's structure for an embedded window. */ { Container *containerPtr; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); for (containerPtr = tsdPtr->firstContainerPtr; containerPtr != NULL; containerPtr = containerPtr->nextPtr) { if (containerPtr->embeddedPtr == winPtr) { return containerPtr->parent; } |
︙ | ︙ | |||
1128 1129 1130 1131 1132 1133 1134 | /* *---------------------------------------------------------------------- * * TkpCreateBusy -- * * Construct the platform-specific parts of a busy window. Note that this | | < < < < < < < < < < < < < < < < < > > > | > > > > > > | 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 | /* *---------------------------------------------------------------------- * * TkpCreateBusy -- * * Construct the platform-specific parts of a busy window. Note that this * postpones the actual creation of the window resource until later. * * Results: * None. * * Side effects: * Sets up part of the busy window structure. * *---------------------------------------------------------------------- */ void TkpCreateBusy( Tk_FakeWin *winPtr, Tk_Window tkRef, Window *parentPtr, Tk_Window tkParent, TkBusy busy) { Window root, parent, *dummy; unsigned int count; if (winPtr->flags & TK_REPARENTED) { /* * This works around a bug in the implementation of menubars for * non-MacIntosh window systems (Win32 and X11). Tk doesn't reset the * pointers to the parent window when the menu is reparented (since * winPtr->parentPtr points to the wrong window). We get around this * by determining the parent via the native API calls. */ if (XQueryTree(Tk_Display(tkRef), Tk_WindowId(tkRef), &root, &parent, &dummy, &count) > 0) { XFree(dummy); *parentPtr = parent; } else { *parentPtr = None; } } else { *parentPtr = Tk_WindowId(tkParent); } } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to unix/tkUnixFont.c.
︙ | ︙ | |||
583 584 585 586 587 588 589 | const char *srcStart, *srcEnd, *srcClose, *dstStart, *dstEnd; int result, numChars; Tcl_UniChar ch; srcStart = src; srcEnd = src + srcLen; srcClose = srcEnd; | | | 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 | const char *srcStart, *srcEnd, *srcClose, *dstStart, *dstEnd; int result, numChars; Tcl_UniChar ch; srcStart = src; srcEnd = src + srcLen; srcClose = srcEnd; if (!(flags & TCL_ENCODING_END)) { srcClose -= TCL_UTF_MAX; } dstStart = dst; dstEnd = dst + dstLen - 2 /* sizeof(UCS-2) */; result = TCL_OK; |
︙ | ︙ | |||
1644 1645 1646 1647 1648 1649 1650 | controlPtr->fontStructPtr = subFontPtr->fontStructPtr; controlPtr->familyPtr = &tsdPtr->controlFamily; controlPtr->fontMap = tsdPtr->controlFamily.fontMap; pageMap = fontPtr->subFontArray[0].fontMap[0]; for (i = 0; i < 256; i++) { if ((minHi > 0) || (i < minLo) || (i > maxLo) | | | 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 | controlPtr->fontStructPtr = subFontPtr->fontStructPtr; controlPtr->familyPtr = &tsdPtr->controlFamily; controlPtr->fontMap = tsdPtr->controlFamily.fontMap; pageMap = fontPtr->subFontArray[0].fontMap[0]; for (i = 0; i < 256; i++) { if ((minHi > 0) || (i < minLo) || (i > maxLo) || !((pageMap[i>>3] >> (i&7)) & 1)) { n = 0; } else if (fontStructPtr->per_char == NULL) { n = fontStructPtr->max_bounds.width; } else { n = fontStructPtr->per_char[i - minLo].width; } fontPtr->widths[i] = n; |
︙ | ︙ |
Changes to unix/tkUnixSelect.c.
︙ | ︙ | |||
239 240 241 242 243 244 245 | register TkSelHandler *selPtr; int length, numItems; unsigned long i; Atom target, formatType; long buffer[TK_SEL_WORDS_AT_ONCE]; TkDisplay *dispPtr = TkGetDisplay(eventPtr->xany.display); Tk_ErrorHandler errorHandler; | | | 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | register TkSelHandler *selPtr; int length, numItems; unsigned long i; Atom target, formatType; long buffer[TK_SEL_WORDS_AT_ONCE]; TkDisplay *dispPtr = TkGetDisplay(eventPtr->xany.display); Tk_ErrorHandler errorHandler; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * See if this event announces the deletion of a property being used for * an INCR transfer. If so, then add the next chunk of data to the * property. */ |
︙ | ︙ | |||
548 549 550 551 552 553 554 | && (retrPtr->selection == eventPtr->xselection.selection) && (retrPtr->target == eventPtr->xselection.target) && (retrPtr->result == -1)) { if (retrPtr->property == eventPtr->xselection.property) { break; } if (eventPtr->xselection.property == None) { | < | > < | > | > | < > > < | < | | > | 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 | && (retrPtr->selection == eventPtr->xselection.selection) && (retrPtr->target == eventPtr->xselection.target) && (retrPtr->result == -1)) { if (retrPtr->property == eventPtr->xselection.property) { break; } if (eventPtr->xselection.property == None) { Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf( "%s selection doesn't exist or form \"%s\" not defined", Tk_GetAtomName(tkwin, retrPtr->selection), Tk_GetAtomName(tkwin, retrPtr->target))); Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "NONE", NULL); retrPtr->result = TCL_ERROR; return; } } } propInfo = NULL; result = XGetWindowProperty(eventPtr->xselection.display, eventPtr->xselection.requestor, retrPtr->property, 0, MAX_PROP_WORDS, False, (Atom) AnyPropertyType, &type, &format, &numItems, &bytesAfter, (unsigned char **) propInfoPtr); if ((result != Success) || (type == None)) { return; } if (bytesAfter != 0) { Tcl_SetObjResult(retrPtr->interp, Tcl_NewStringObj( "selection property too large", -1)); Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "SIZE",NULL); retrPtr->result = TCL_ERROR; XFree(propInfo); return; } if ((type == XA_STRING) || (type == dispPtr->textAtom) || (type == dispPtr->compoundTextAtom)) { Tcl_Encoding encoding; if (format != 8) { Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf( "bad format for string selection: wanted \"8\", got \"%d\"", format)); Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "FORMAT", NULL); retrPtr->result = TCL_ERROR; return; } interp = retrPtr->interp; Tcl_Preserve(interp); /* |
︙ | ︙ | |||
627 628 629 630 631 632 633 | * guarantee that propInfo is NULL-terminated, so we might have to * copy the string. */ char *propData = propInfo; if (format != 8) { | < | < | | > | 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | * guarantee that propInfo is NULL-terminated, so we might have to * copy the string. */ char *propData = propInfo; if (format != 8) { Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf( "bad format for string selection: wanted \"8\", got \"%d\"", format)); Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "FORMAT", NULL); retrPtr->result = TCL_ERROR; return; } if (propInfo[numItems] != '\0') { propData = ckalloc(numItems + 1); strcpy(propData, propInfo); |
︙ | ︙ | |||
669 670 671 672 673 674 675 | } Tk_DeleteEventHandler(tkwin, PropertyChangeMask, SelRcvIncrProc, retrPtr); } else { Tcl_DString ds; if (format != 32 && format != 8) { | < | | | | > | 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 | } Tk_DeleteEventHandler(tkwin, PropertyChangeMask, SelRcvIncrProc, retrPtr); } else { Tcl_DString ds; if (format != 32 && format != 8) { Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf( "bad format for selection: wanted \"32\" or " "\"8\", got \"%d\"", format)); Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "FORMAT", NULL); retrPtr->result = TCL_ERROR; return; } Tcl_DStringInit(&ds); if (format == 32) { SelCvtFromX32((long *) propInfo, (int) numItems, type, (Tk_Window) winPtr, &ds); |
︙ | ︙ | |||
731 732 733 734 735 736 737 | *---------------------------------------------------------------------- */ static void SelTimeoutProc( ClientData clientData) /* Information about retrieval in progress. */ { | | > | < > | 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 | *---------------------------------------------------------------------- */ static void SelTimeoutProc( ClientData clientData) /* Information about retrieval in progress. */ { register TkSelRetrievalInfo *retrPtr = clientData; /* * Make sure that the retrieval is still in progress. Then see how long * it's been since any sort of response was received from the other side. */ if (retrPtr->result != -1) { return; } retrPtr->idleTime++; if (retrPtr->idleTime >= 5) { /* * Use a careful function to store the error message, because the * result could already be partially filled in with a partial * selection return. */ Tcl_SetObjResult(retrPtr->interp, Tcl_NewStringObj( "selection owner didn't respond", -1)); Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "IGNORED", NULL); retrPtr->result = TCL_ERROR; } else { retrPtr->timeout = Tcl_CreateTimerHandler(1000, SelTimeoutProc, (ClientData) retrPtr); } } |
︙ | ︙ | |||
801 802 803 804 805 806 807 | IncrInfo incr; /* State of selection conversion. */ Atom singleInfo[2]; /* incr.multAtoms points here except for * multiple conversions. */ unsigned long i; Tk_ErrorHandler errorHandler; TkSelectionInfo *infoPtr; TkSelInProgress ip; | | | 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 | IncrInfo incr; /* State of selection conversion. */ Atom singleInfo[2]; /* incr.multAtoms points here except for * multiple conversions. */ unsigned long i; Tk_ErrorHandler errorHandler; TkSelectionInfo *infoPtr; TkSelInProgress ip; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); errorHandler = Tk_CreateErrorHandler(eventPtr->display, -1, -1,-1, (int (*)()) NULL, NULL); /* * Initialize the reply event. |
︙ | ︙ | |||
870 871 872 873 874 875 876 | if ((result != Success) || (bytesAfter != 0) || (format != 32) || (type == None)) { if (incr.multAtoms != NULL) { XFree((char *) incr.multAtoms); } goto refuse; } | | | 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 | if ((result != Success) || (bytesAfter != 0) || (format != 32) || (type == None)) { if (incr.multAtoms != NULL) { XFree((char *) incr.multAtoms); } goto refuse; } incr.numConversions /= 2; /* Two atoms per conversion. */ } /* * Loop through all of the requested conversions, and either return the * entire converted selection, if it can be returned in a single bunch, or * return INCR information only (the actual selection will be returned * below). |
︙ | ︙ | |||
963 964 965 966 967 968 969 | (unsigned char *) propPtr, numItems); } else if (type == winPtr->dispPtr->utf8Atom) { /* * This matches selection requests of type UTF8_STRING, which * allows us to pass our utf-8 information untouched. */ | | > | | > | | | | | > | | | 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 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 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 | (unsigned char *) propPtr, numItems); } else if (type == winPtr->dispPtr->utf8Atom) { /* * This matches selection requests of type UTF8_STRING, which * allows us to pass our utf-8 information untouched. */ XChangeProperty(reply.xsel.display, reply.xsel.requestor, property, type, 8, PropModeReplace, (unsigned char *) buffer, numItems); } else if ((type == XA_STRING) || (type == winPtr->dispPtr->compoundTextAtom)) { Tcl_DString ds; Tcl_Encoding encoding; /* * STRING is Latin-1, COMPOUND_TEXT is an iso2022 variant. We need * to convert the selection text into these external forms before * modifying the property. */ if (type == XA_STRING) { encoding = Tcl_GetEncoding(NULL, "iso8859-1"); } else { encoding = Tcl_GetEncoding(NULL, "iso2022"); } Tcl_UtfToExternalDString(encoding, (char *) buffer, -1, &ds); XChangeProperty(reply.xsel.display, reply.xsel.requestor, property, type, 8, PropModeReplace, (unsigned char *) Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); if (encoding) { Tcl_FreeEncoding(encoding); } Tcl_DStringFree(&ds); } else { propPtr = (char *) SelCvtToX((char *) buffer, type, (Tk_Window) winPtr, &numItems); if (propPtr == NULL) { goto refuse; } format = 32; XChangeProperty(reply.xsel.display, reply.xsel.requestor, property, type, format, PropModeReplace, (unsigned char *) propPtr, numItems); ckfree(propPtr); } } /* * Send an event back to the requestor to indicate that the first stage of * conversion is complete (everything is done except for long conversions * that have to be done in INCR mode). */ if (incr.numIncrs > 0) { XSelectInput(reply.xsel.display, reply.xsel.requestor, PropertyChangeMask); incr.timeout = Tcl_CreateTimerHandler(1000, IncrTimeoutProc, &incr); incr.idleTime = 0; incr.reqWindow = reply.xsel.requestor; incr.time = infoPtr->time; incr.nextPtr = tsdPtr->pendingIncrs; tsdPtr->pendingIncrs = &incr; } if (multiple) { XChangeProperty(reply.xsel.display, reply.xsel.requestor, reply.xsel.property, XA_ATOM, 32, PropModeReplace, (unsigned char *) incr.multAtoms, (int) incr.numConversions*2); } else { /* * Not a MULTIPLE request. The first property in "multAtoms" got set * to None if there was an error in conversion. */ |
︙ | ︙ | |||
1048 1049 1050 1051 1052 1053 1054 | IncrInfo *incrPtr2; while (incr.numIncrs > 0) { Tcl_DoOneEvent(0); } Tcl_DeleteTimerHandler(incr.timeout); errorHandler = Tk_CreateErrorHandler(winPtr->display, | | | 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 | IncrInfo *incrPtr2; while (incr.numIncrs > 0) { Tcl_DoOneEvent(0); } Tcl_DeleteTimerHandler(incr.timeout); errorHandler = Tk_CreateErrorHandler(winPtr->display, -1, -1, -1, (int (*)()) NULL, NULL); XSelectInput(reply.xsel.display, reply.xsel.requestor, 0L); Tk_DeleteErrorHandler(errorHandler); if (tsdPtr->pendingIncrs == &incr) { tsdPtr->pendingIncrs = incr.nextPtr; } else { for (incrPtr2 = tsdPtr->pendingIncrs; incrPtr2 != NULL; incrPtr2 = incrPtr2->nextPtr) { |
︙ | ︙ | |||
1110 1111 1112 1113 1114 1115 1116 | */ static void SelRcvIncrProc( ClientData clientData, /* Information about retrieval. */ register XEvent *eventPtr) /* X PropertyChange event. */ { | | > | < > < | < | | > | 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 | */ static void SelRcvIncrProc( ClientData clientData, /* Information about retrieval. */ register XEvent *eventPtr) /* X PropertyChange event. */ { register TkSelRetrievalInfo *retrPtr = clientData; char *propInfo, **propInfoPtr = &propInfo; Atom type; int format, result; unsigned long numItems, bytesAfter; Tcl_Interp *interp; if ((eventPtr->xproperty.atom != retrPtr->property) || (eventPtr->xproperty.state != PropertyNewValue) || (retrPtr->result != -1)) { return; } propInfo = NULL; result = XGetWindowProperty(eventPtr->xproperty.display, eventPtr->xproperty.window, retrPtr->property, 0, MAX_PROP_WORDS, True, (Atom) AnyPropertyType, &type, &format, &numItems, &bytesAfter, (unsigned char **) propInfoPtr); if ((result != Success) || (type == None)) { return; } if (bytesAfter != 0) { Tcl_SetObjResult(retrPtr->interp, Tcl_NewStringObj( "selection property too large", -1)); Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "SIZE", NULL); retrPtr->result = TCL_ERROR; goto done; } if ((type == XA_STRING) || (type == retrPtr->winPtr->dispPtr->textAtom) || (type == retrPtr->winPtr->dispPtr->utf8Atom) || (type == retrPtr->winPtr->dispPtr->compoundTextAtom)) { char *dst, *src; int srcLen, dstLen, srcRead, dstWrote, soFar; Tcl_Encoding encoding; Tcl_DString *dstPtr, temp; if (format != 8) { Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf( "bad format for string selection: wanted \"8\", got \"%d\"", format)); Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "FORMAT", NULL); retrPtr->result = TCL_ERROR; goto done; } interp = retrPtr->interp; Tcl_Preserve(interp); if (type == retrPtr->winPtr->dispPtr->compoundTextAtom) { |
︙ | ︙ | |||
1253 1254 1255 1256 1257 1258 1259 | } } else if (numItems == 0) { retrPtr->result = TCL_OK; } else { Tcl_DString ds; if (format != 32 && format != 8) { | < | | | | > | 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 | } } else if (numItems == 0) { retrPtr->result = TCL_OK; } else { Tcl_DString ds; if (format != 32 && format != 8) { Tcl_SetObjResult(retrPtr->interp, Tcl_ObjPrintf( "bad format for selection: wanted \"32\" or " "\"8\", got \"%d\"", format)); Tcl_SetErrorCode(retrPtr->interp, "TK", "SELECTION", "FORMAT", NULL); retrPtr->result = TCL_ERROR; goto done; } Tcl_DStringInit(&ds); if (format == 32) { SelCvtFromX32((long *) propInfo, (int) numItems, type, (Tk_Window) retrPtr->winPtr, &ds); |
︙ | ︙ | |||
1358 1359 1360 1361 1362 1363 1364 | static void IncrTimeoutProc( ClientData clientData) /* Information about INCR-mode selection * retrieval for which we are selection * owner. */ { | | | 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 | static void IncrTimeoutProc( ClientData clientData) /* Information about INCR-mode selection * retrieval for which we are selection * owner. */ { register IncrInfo *incrPtr = clientData; incrPtr->idleTime++; if (incrPtr->idleTime >= 5) { incrPtr->numIncrs = 0; } else { incrPtr->timeout = Tcl_CreateTimerHandler(1000, IncrTimeoutProc, incrPtr); |
︙ | ︙ |
Changes to unix/tkUnixSend.c.
︙ | ︙ | |||
980 981 982 983 984 985 986 | return TCL_ERROR; } i += 2; } else if (strcmp(argv[i], "--") == 0) { i++; break; } else { | | | > > | | > > | 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 | return TCL_ERROR; } i += 2; } else if (strcmp(argv[i], "--") == 0) { i++; break; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad option \"%s\": must be -async, -displayof, or --", argv[i])); Tcl_SetErrorCode(interp, "TK", "SEND", "OPTION", NULL); return TCL_ERROR; } } if (argc < (i+2)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf("wrong # args: should be " "\"%s ?-option value ...? interpName arg ?arg ...?\"", argv[0])); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); return TCL_ERROR; } destName = argv[i]; firstArg = i+1; dispPtr = winPtr->dispPtr; if (dispPtr->commTkwin == NULL) { |
︙ | ︙ | |||
1063 1064 1065 1066 1067 1068 1069 | * Bind the interpreter name to a communication window. */ regPtr = RegOpen(interp, winPtr->dispPtr, 0); commWindow = RegFindName(regPtr, destName); RegClose(regPtr); if (commWindow == None) { | > | > > | 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 | * Bind the interpreter name to a communication window. */ regPtr = RegOpen(interp, winPtr->dispPtr, 0); commWindow = RegFindName(regPtr, destName); RegClose(regPtr); if (commWindow == None) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "no application named \"%s\"", destName)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "APPLICATION", destName, NULL); return TCL_ERROR; } /* * Send the command to the target interpreter by appending it to the comm * window in the communication window. */ |
︙ | ︙ | |||
1186 1187 1188 1189 1190 1191 1192 | */ Tcl_ResetResult(interp); Tcl_AddErrorInfo(interp, pending.errorInfo); ckfree(pending.errorInfo); } if (pending.errorCode != NULL) { | < < | | | 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 | */ Tcl_ResetResult(interp); Tcl_AddErrorInfo(interp, pending.errorInfo); ckfree(pending.errorInfo); } if (pending.errorCode != NULL) { Tcl_SetObjErrorCode(interp, Tcl_NewStringObj(pending.errorCode, -1)); ckfree(pending.errorCode); } Tcl_SetObjResult(interp, Tcl_NewStringObj(pending.result, -1)); ckfree(pending.result); return pending.code; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 | TkGetInterpNames( Tcl_Interp *interp, /* Interpreter for returning a result. */ Tk_Window tkwin) /* Window whose display is to be used for the * lookup. */ { TkWindow *winPtr = (TkWindow *) tkwin; NameRegistry *regPtr; char *p; /* * Read the registry property, then scan through all of its entries. * Validate each entry to be sure that its application still exists. */ | > | 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 | TkGetInterpNames( Tcl_Interp *interp, /* Interpreter for returning a result. */ Tk_Window tkwin) /* Window whose display is to be used for the * lookup. */ { TkWindow *winPtr = (TkWindow *) tkwin; NameRegistry *regPtr; Tcl_Obj *resultObj = Tcl_NewObj(); char *p; /* * Read the registry property, then scan through all of its entries. * Validate each entry to be sure that its application still exists. */ |
︙ | ︙ | |||
1258 1259 1260 1261 1262 1263 1264 | } p++; if (ValidateName(winPtr->dispPtr, entryName, commWindow, 1)) { /* * The application still exists; add its name to the result. */ | | > | 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 | } p++; if (ValidateName(winPtr->dispPtr, entryName, commWindow, 1)) { /* * The application still exists; add its name to the result. */ Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(entryName, -1)); } else { int count; /* * This name is bogus (perhaps the application died without * cleaning up its entry in the registry?). Delete the name. */ |
︙ | ︙ | |||
1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 | } regPtr->propLength -= p - entry; regPtr->modified = 1; p = entry; } } RegClose(regPtr); return TCL_OK; } /* *-------------------------------------------------------------- * * TkSendCleanup -- | > | 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 | } regPtr->propLength -= p - entry; regPtr->modified = 1; p = entry; } } RegClose(regPtr); Tcl_SetObjResult(interp, resultObj); return TCL_OK; } /* *-------------------------------------------------------------- * * TkSendCleanup -- |
︙ | ︙ | |||
1982 1983 1984 1985 1986 1987 1988 | if ((result == Success) && (actualType != None) && (actualFormat == 8) && (actualType == XA_STRING)) { for (p = property; (unsigned long)(p-property) < length; p++) { if (*p == 0) { *p = '\n'; } } | | | 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 | if ((result == Success) && (actualType != None) && (actualFormat == 8) && (actualType == XA_STRING)) { for (p = property; (unsigned long)(p-property) < length; p++) { if (*p == 0) { *p = '\n'; } } Tcl_SetObjResult(interp, Tcl_NewStringObj(property, -1)); } if (property != NULL) { XFree(property); } } else if (argv[4][0] == 0) { XDeleteProperty(winPtr->dispPtr->display, w, propName); } else { |
︙ | ︙ | |||
2006 2007 2008 2009 2010 2011 2012 | XChangeProperty(winPtr->dispPtr->display, w, propName, XA_STRING, 8, PropModeReplace, (unsigned char*)Tcl_DStringValue(&tmp), p-Tcl_DStringValue(&tmp)); Tcl_DStringFree(&tmp); } } else if (strcmp(argv[1], "serial") == 0) { | < < | < | 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 | XChangeProperty(winPtr->dispPtr->display, w, propName, XA_STRING, 8, PropModeReplace, (unsigned char*)Tcl_DStringValue(&tmp), p-Tcl_DStringValue(&tmp)); Tcl_DStringFree(&tmp); } } else if (strcmp(argv[1], "serial") == 0) { Tcl_SetObjResult(interp, Tcl_NewIntObj(localData.sendSerial+1)); } else { Tcl_AppendResult(interp, "bad option \"", argv[1], "\": must be bogus, prop, or serial", NULL); return TCL_ERROR; } return TCL_OK; } |
︙ | ︙ |
Changes to unix/tkUnixWm.c.
︙ | ︙ | |||
37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #define HANDLER_SIZE(cmdLength) \ ((unsigned) ((Tk_Offset(ProtocolHandler, command) + 1) + cmdLength)) /* * Data for [wm attributes] command: */ typedef struct { double alpha; /* Transparency; 0.0=transparent, 1.0=opaque */ int topmost; /* Flag: true=>stay-on-top */ int zoomed; /* Flag: true=>maximized */ int fullscreen; /* Flag: true=>fullscreen */ } WmAttributes; | > | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #define HANDLER_SIZE(cmdLength) \ ((unsigned) ((Tk_Offset(ProtocolHandler, command) + 1) + cmdLength)) /* * Data for [wm attributes] command: */ typedef struct { double alpha; /* Transparency; 0.0=transparent, 1.0=opaque */ int topmost; /* Flag: true=>stay-on-top */ int zoomed; /* Flag: true=>maximized */ int fullscreen; /* Flag: true=>fullscreen */ } WmAttributes; |
︙ | ︙ | |||
272 273 274 275 276 277 278 279 280 281 282 283 284 285 | #define WM_MOVE_PENDING 0x200 #define WM_COLORMAPS_EXPLICIT 0x400 #define WM_ADDED_TOPLEVEL_COLORMAP 0x800 #define WM_WIDTH_NOT_RESIZABLE 0x1000 #define WM_HEIGHT_NOT_RESIZABLE 0x2000 #define WM_WITHDRAWN 0x4000 /* * This module keeps a list of all top-level windows, primarily to simplify * the job of Tk_CoordsToWindow. The list is called firstWmPtr and is stored * in the TkDisplay structure. */ /* | > > > > > > > > > > > > > > > > | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | #define WM_MOVE_PENDING 0x200 #define WM_COLORMAPS_EXPLICIT 0x400 #define WM_ADDED_TOPLEVEL_COLORMAP 0x800 #define WM_WIDTH_NOT_RESIZABLE 0x1000 #define WM_HEIGHT_NOT_RESIZABLE 0x2000 #define WM_WITHDRAWN 0x4000 /* * Wrapper for XGetWindowProperty and XChangeProperty to make them a *bit* * less verbose. */ #define GetWindowProperty(wrapperPtr, atom, length, type, typePtr, formatPtr, numItemsPtr, bytesAfterPtr, itemsPtr) \ (XGetWindowProperty((wrapperPtr)->display, (wrapperPtr)->window, \ (atom), 0, (long) (length), False, (type), \ (typePtr), (formatPtr), (numItemsPtr), (bytesAfterPtr), \ (unsigned char **) (itemsPtr)) == Success) #define SetWindowProperty(wrapperPtr, atomName, type, width, data, length) \ XChangeProperty((wrapperPtr)->display, (wrapperPtr)->window, \ Tk_InternAtom((Tk_Window) wrapperPtr, (atomName)), \ (type), (width), PropModeReplace, (unsigned char *) (data), \ (int) (length)) /* * This module keeps a list of all top-level windows, primarily to simplify * the job of Tk_CoordsToWindow. The list is called firstWmPtr and is stored * in the TkDisplay structure. */ /* |
︙ | ︙ | |||
693 694 695 696 697 698 699 | UpdateCommand(winPtr); } if (wmPtr->clientMachine != NULL) { Tcl_UtfToExternalDString(NULL, wmPtr->clientMachine, -1, &ds); if (XStringListToTextProperty(&(Tcl_DStringValue(&ds)), 1, &textProp) != 0) { unsigned long pid = (unsigned long) getpid(); | < < | | < | 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 | UpdateCommand(winPtr); } if (wmPtr->clientMachine != NULL) { Tcl_UtfToExternalDString(NULL, wmPtr->clientMachine, -1, &ds); if (XStringListToTextProperty(&(Tcl_DStringValue(&ds)), 1, &textProp) != 0) { unsigned long pid = (unsigned long) getpid(); XSetWMClientMachine(winPtr->display, wmPtr->wrapperPtr->window, &textProp); XFree((char *) textProp.value); /* * Inform the server (and more particularly any session * manager) what our process ID is. We only do this when the * CLIENT_MACHINE property is set since the spec for * _NET_WM_PID requires that to be set too. */ SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_PID", XA_CARDINAL, 32, &pid, 1); } Tcl_DStringFree(&ds); } } if (wmPtr->hints.initial_state == WithdrawnState) { return; } |
︙ | ︙ | |||
1037 1038 1039 1040 1041 1042 1043 | int wmTracing; if ((objc != 2) && (objc != 3)) { Tcl_WrongNumArgs(interp, 2, objv, "?boolean?"); return TCL_ERROR; } if (objc == 2) { | | | < | 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 | int wmTracing; if ((objc != 2) && (objc != 3)) { Tcl_WrongNumArgs(interp, 2, objv, "?boolean?"); return TCL_ERROR; } if (objc == 2) { Tcl_SetObjResult(interp, Tcl_NewBooleanObj( dispPtr->flags & TK_DISPLAY_WM_TRACING)); return TCL_OK; } if (Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing) != TCL_OK) { return TCL_ERROR; } if (wmTracing) { dispPtr->flags |= TK_DISPLAY_WM_TRACING; |
︙ | ︙ | |||
1068 1069 1070 1071 1072 1073 1074 | if (TkGetWindowFromObj(interp, tkwin, objv[2], &targetWin) != TCL_OK) { return TCL_ERROR; } winPtr = (TkWindow *) targetWin; if (!Tk_IsTopLevel(winPtr) && (index != WMOPT_MANAGE) && (index != WMOPT_FORGET)) { | | | > > | 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 | if (TkGetWindowFromObj(interp, tkwin, objv[2], &targetWin) != TCL_OK) { return TCL_ERROR; } winPtr = (TkWindow *) targetWin; if (!Tk_IsTopLevel(winPtr) && (index != WMOPT_MANAGE) && (index != WMOPT_FORGET)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't a top-level window", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TOPLEVEL", winPtr->pathName, NULL); return TCL_ERROR; } switch ((enum options) index) { case WMOPT_ASPECT: return WmAspectCmd(tkwin, winPtr, interp, objc, objv); case WMOPT_ATTRIBUTES: |
︙ | ︙ | |||
1179 1180 1181 1182 1183 1184 1185 | if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?minNumer minDenom maxNumer maxDenom?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & PAspect) { | | | | > | | > | < > | 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 | if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?minNumer minDenom maxNumer maxDenom?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & PAspect) { Tcl_Obj *results[4]; results[0] = Tcl_NewIntObj(wmPtr->minAspect.x); results[1] = Tcl_NewIntObj(wmPtr->minAspect.y); results[2] = Tcl_NewIntObj(wmPtr->maxAspect.x); results[3] = Tcl_NewIntObj(wmPtr->maxAspect.y); Tcl_SetObjResult(interp, Tcl_NewListObj(4, results)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->sizeHintsFlags &= ~PAspect; } else { if ((Tcl_GetIntFromObj(interp, objv[3], &numer1) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &denom1) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[5], &numer2) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[6], &denom2) != TCL_OK)) { return TCL_ERROR; } if ((numer1 <= 0) || (denom1 <= 0) || (numer2 <= 0) || (denom2 <= 0)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "aspect number can't be <= 0", -1)); Tcl_SetErrorCode(interp, "TK", "VALUE", "ASPECT", NULL); return TCL_ERROR; } wmPtr->minAspect.x = numer1; wmPtr->minAspect.y = denom1; wmPtr->maxAspect.x = numer2; wmPtr->maxAspect.y = denom2; wmPtr->sizeHintsFlags |= PAspect; |
︙ | ︙ | |||
1259 1260 1261 1262 1263 1264 1265 | } if (!wmPtr->wrapperPtr) { break; } opacity = 0xFFFFFFFFul * wmPtr->reqState.alpha; | < | | < | 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 | } if (!wmPtr->wrapperPtr) { break; } opacity = 0xFFFFFFFFul * wmPtr->reqState.alpha; SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_WINDOW_OPACITY", XA_CARDINAL, 32, &opacity, 1L); wmPtr->attributes.alpha = wmPtr->reqState.alpha; break; } case WMATT_TOPMOST: if (Tcl_GetBooleanFromObj(interp, value, &wmPtr->reqState.topmost) != TCL_OK) { |
︙ | ︙ | |||
1446 1447 1448 1449 1450 1451 1452 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->clientMachine != NULL) { | > | | 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->clientMachine != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->clientMachine, -1)); } return TCL_OK; } argv3 = Tcl_GetStringFromObj(objv[3], &length); if (argv3[0] == 0) { if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); |
︙ | ︙ | |||
1488 1489 1490 1491 1492 1493 1494 | /* * Inform the server (and more particularly any session manager) * what our process ID is. We only do this when the CLIENT_MACHINE * property is set since the spec for _NET_WM_PID requires that to * be set too. */ | < | | | 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 | /* * Inform the server (and more particularly any session manager) * what our process ID is. We only do this when the CLIENT_MACHINE * property is set since the spec for _NET_WM_PID requires that to * be set too. */ SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_PID", XA_CARDINAL, 32, &pid, 1); } Tcl_DStringFree(&ds); } return TCL_OK; } /* |
︙ | ︙ | |||
1526 1527 1528 1529 1530 1531 1532 | int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; Window *cmapList; TkWindow *winPtr2; int count, i, windowObjc, gotToplevel; | | < > > | < | > > | 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 | int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; Window *cmapList; TkWindow *winPtr2; int count, i, windowObjc, gotToplevel; Tcl_Obj **windowObjv, *resultObj; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?windowList?"); return TCL_ERROR; } Tk_MakeWindowExist((Tk_Window) winPtr); if (wmPtr->wrapperPtr == NULL) { CreateWrapper(wmPtr); } if (objc == 3) { if (XGetWMColormapWindows(winPtr->display, wmPtr->wrapperPtr->window, &cmapList, &count) == 0) { return TCL_OK; } resultObj = Tcl_NewObj(); for (i = 0; i < count; i++) { if ((i == (count-1)) && (wmPtr->flags & WM_ADDED_TOPLEVEL_COLORMAP)) { break; } winPtr2 = (TkWindow *) Tk_IdToWindow(winPtr->display, cmapList[i]); if (winPtr2 == NULL) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_ObjPrintf("0x%lx", cmapList[i])); } else { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(winPtr2->pathName, -1)); } } XFree((char *) cmapList); Tcl_SetObjResult(interp, resultObj); return TCL_OK; } if (Tcl_ListObjGetElements(interp, objv[3], &windowObjc, &windowObjv) != TCL_OK) { return TCL_ERROR; } cmapList = ckalloc((windowObjc+1) * sizeof(Window)); |
︙ | ︙ | |||
1634 1635 1636 1637 1638 1639 1640 | Tcl_WrongNumArgs(interp, 2, objv, "window ?value?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->cmdArgv != NULL) { char *arg = Tcl_Merge(wmPtr->cmdArgc, wmPtr->cmdArgv); | | > | 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 | Tcl_WrongNumArgs(interp, 2, objv, "window ?value?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->cmdArgv != NULL) { char *arg = Tcl_Merge(wmPtr->cmdArgc, wmPtr->cmdArgv); Tcl_SetObjResult(interp, Tcl_NewStringObj(arg, -1)); ckfree(arg); } return TCL_OK; } argv3 = Tcl_GetString(objv[3]); if (argv3[0] == 0) { if (wmPtr->cmdArgv != NULL) { ckfree(wmPtr->cmdArgv); |
︙ | ︙ | |||
1696 1697 1698 1699 1700 1701 1702 | register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { | > | | > | | > > | 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 | register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't deiconify %s: it is an icon for %s", Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "DEICONIFY", "ICON", NULL); return TCL_ERROR; } if (winPtr->flags & TK_EMBEDDED) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't deiconify %s: it is an embedded window", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "DEICONIFY", "EMBEDDED", NULL); return TCL_ERROR; } wmPtr->flags &= ~WM_WITHDRAWN; TkpWmSetState(winPtr, NormalState); return TCL_OK; } |
︙ | ︙ | |||
1747 1748 1749 1750 1751 1752 1753 | int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?"); return TCL_ERROR; } if (objc == 3) { | > | < | 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 | int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?"); return TCL_ERROR; } if (objc == 3) { Tcl_SetObjResult(interp, Tcl_NewStringObj( wmPtr->hints.input ? "passive" : "active", -1)); return TCL_OK; } if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
1840 1841 1842 1843 1844 1845 1846 | 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; Window window; | < | < | 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 | 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; Window window; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } window = wmPtr->reparent; if (window == None) { window = Tk_WindowId((Tk_Window) winPtr); } Tcl_SetObjResult(interp, Tcl_ObjPrintf("0x%x", (unsigned) window)); return TCL_OK; } /* *---------------------------------------------------------------------- * * WmGeometryCmd -- |
︙ | ︙ | |||
1890 1891 1892 1893 1894 1895 1896 | const char *argv3; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newGeometry?"); return TCL_ERROR; } if (objc == 3) { | < < | | < | 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 | const char *argv3; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newGeometry?"); return TCL_ERROR; } if (objc == 3) { xSign = (wmPtr->flags & WM_NEGATIVE_X) ? '-' : '+'; ySign = (wmPtr->flags & WM_NEGATIVE_Y) ? '-' : '+'; if (wmPtr->gridWin != NULL) { width = wmPtr->reqGridWidth + (winPtr->changes.width - winPtr->reqWidth)/wmPtr->widthInc; height = wmPtr->reqGridHeight + (winPtr->changes.height - winPtr->reqHeight)/wmPtr->heightInc; } else { width = winPtr->changes.width; height = winPtr->changes.height; } Tcl_SetObjResult(interp, Tcl_ObjPrintf("%dx%d%c%d%c%d", width, height, xSign, wmPtr->x, ySign, wmPtr->y)); return TCL_OK; } argv3 = Tcl_GetString(objv[3]); if (*argv3 == '\0') { wmPtr->width = -1; wmPtr->height = -1; WmUpdateGeom(wmPtr, winPtr); |
︙ | ︙ | |||
1953 1954 1955 1956 1957 1958 1959 | if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?baseWidth baseHeight widthInc heightInc?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & PBaseSize) { | | | | > | | | 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 | if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?baseWidth baseHeight widthInc heightInc?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & PBaseSize) { Tcl_Obj *results[4]; results[0] = Tcl_NewIntObj(wmPtr->reqGridWidth); results[1] = Tcl_NewIntObj(wmPtr->reqGridHeight); results[2] = Tcl_NewIntObj(wmPtr->widthInc); results[3] = Tcl_NewIntObj(wmPtr->heightInc); Tcl_SetObjResult(interp, Tcl_NewListObj(4, results)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { /* * Turn off gridding and reset the width and height to make sense as * ungridded numbers. |
︙ | ︙ | |||
1985 1986 1987 1988 1989 1990 1991 | if ((Tcl_GetIntFromObj(interp, objv[3], &reqWidth) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &reqHeight) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[5], &widthInc) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[6], &heightInc) !=TCL_OK)) { return TCL_ERROR; } if (reqWidth < 0) { | > | > > | > > | > > | > | 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 | if ((Tcl_GetIntFromObj(interp, objv[3], &reqWidth) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &reqHeight) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[5], &widthInc) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[6], &heightInc) !=TCL_OK)) { return TCL_ERROR; } if (reqWidth < 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "baseWidth can't be < 0", -1)); Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL); return TCL_ERROR; } if (reqHeight < 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "baseHeight can't be < 0", -1)); Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL); return TCL_ERROR; } if (widthInc <= 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "widthInc can't be <= 0", -1)); Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL); return TCL_ERROR; } if (heightInc <= 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "heightInc can't be <= 0", -1)); Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL); return TCL_ERROR; } Tk_SetGrid((Tk_Window) winPtr, reqWidth, reqHeight, widthInc, heightInc); } wmPtr->flags |= WM_UPDATE_SIZE_HINTS; WmUpdateGeom(wmPtr, winPtr); |
︙ | ︙ | |||
2045 2046 2047 2048 2049 2050 2051 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & WindowGroupHint) { | | | 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & WindowGroupHint) { Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->leaderName, -1)); } return TCL_OK; } argv3 = Tcl_GetStringFromObj(objv[3], &length); if (*argv3 == '\0') { wmPtr->hints.flags &= ~WindowGroupHint; if (wmPtr->leaderName != NULL) { |
︙ | ︙ | |||
2119 2120 2121 2122 2123 2124 2125 | if ((objc < 3) || (objc > 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconPixmapHint) { | | | < | 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 | if ((objc < 3) || (objc > 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconPixmapHint) { Tcl_SetObjResult(interp, Tcl_NewStringObj( Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_pixmap), -1)); } return TCL_OK; } argv3 = Tcl_GetString(objv[3]); if (*argv3 == '\0') { if (wmPtr->hints.icon_pixmap != None) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap); |
︙ | ︙ | |||
2177 2178 2179 2180 2181 2182 2183 | register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) { | | | > > > | | > > | > | > | | > > | | | | 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 | register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } 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; } if (wmPtr->masterPtr != 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) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify %s: it is an icon for %s", winPtr->pathName, Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "ICON", NULL); return TCL_ERROR; } if (winPtr->flags & TK_EMBEDDED) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify %s: it is an embedded window", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "EMBEDDED", NULL); return TCL_ERROR; } if (TkpWmSetState(winPtr, IconicState) == 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "couldn't send iconify message to window manager", -1)); Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL); return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
2240 2241 2242 2243 2244 2245 2246 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconMaskHint) { | | | | 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconMaskHint) { Tcl_SetObjResult(interp, Tcl_NewStringObj( Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_mask), -1)); } return TCL_OK; } argv3 = Tcl_GetString(objv[3]); if (*argv3 == '\0') { if (wmPtr->hints.icon_mask != None) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_mask); |
︙ | ︙ | |||
2298 2299 2300 2301 2302 2303 2304 | int length; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?"); return TCL_ERROR; } if (objc == 3) { | < | < > > | 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 | int length; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->iconName != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->iconName, -1)); } return TCL_OK; } else { if (wmPtr->iconName != NULL) { ckfree(wmPtr->iconName); } argv3 = Tcl_GetStringFromObj(objv[3], &length); wmPtr->iconName = ckalloc(length + 1); |
︙ | ︙ | |||
2369 2370 2371 2372 2373 2374 2375 | * Iterate over all images to retrieve their sizes, in order to allocate a * buffer large enough to hold all images. */ for (i = 3 + isDefault; i < objc; i++) { photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i])); if (photo == NULL) { | | | > > | 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 | * Iterate over all images to retrieve their sizes, in order to allocate a * buffer large enough to hold all images. */ for (i = 3 + isDefault; i < objc; i++) { photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i])); if (photo == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't use \"%s\" as iconphoto: not a photo image", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL); return TCL_ERROR; } Tk_PhotoGetSize(photo, &width, &height); /* * We need to cardinals for width & height and one cardinal for each * image pixel. |
︙ | ︙ | |||
2494 2495 2496 2497 2498 2499 2500 | if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconPositionHint) { | | | | | | 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 | if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconPositionHint) { Tcl_Obj *results[2]; results[0] = Tcl_NewIntObj(wmPtr->hints.icon_x); results[1] = Tcl_NewIntObj(wmPtr->hints.icon_y); Tcl_SetObjResult(interp, Tcl_NewListObj(2, results)); } return TCL_OK; } if (Tcl_GetString(objv[3])[0] == '\0') { wmPtr->hints.flags &= ~IconPositionHint; } else { if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK) |
︙ | ︙ | |||
2580 2581 2582 2583 2584 2585 2586 | } wmPtr->icon = NULL; } else { if (TkGetWindowFromObj(interp, tkwin, objv[3], &tkwin2) != TCL_OK) { return TCL_ERROR; } if (!Tk_IsTopLevel(tkwin2)) { | | | > > | | > | | 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 | } wmPtr->icon = NULL; } else { if (TkGetWindowFromObj(interp, tkwin, objv[3], &tkwin2) != TCL_OK) { return TCL_ERROR; } if (!Tk_IsTopLevel(tkwin2)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't use %s as icon window: not at top level", Tcl_GetString(objv[3]))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONWINDOW", "INNER", NULL); return TCL_ERROR; } wmPtr2 = ((TkWindow *) tkwin2)->wmInfoPtr; if (wmPtr2->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s is already an icon for %s", Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONWINDOW", "ICON", NULL); return TCL_ERROR; } if (wmPtr->icon != NULL) { WmInfo *wmPtr3 = ((TkWindow *) wmPtr->icon)->wmInfoPtr; wmPtr3->iconFor = NULL; wmPtr3->withdrawn = 1; |
︙ | ︙ | |||
2621 2622 2623 2624 2625 2626 2627 | wmPtr->icon = tkwin2; wmPtr2->iconFor = (Tk_Window) winPtr; if (!wmPtr2->withdrawn && !(wmPtr2->flags & WM_NEVER_MAPPED)) { wmPtr2->withdrawn = 0; if (XWithdrawWindow(Tk_Display(tkwin2), Tk_WindowId(wmPtr2->wrapperPtr), Tk_ScreenNumber(tkwin2)) == 0) { | | | > | 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 | wmPtr->icon = tkwin2; wmPtr2->iconFor = (Tk_Window) winPtr; if (!wmPtr2->withdrawn && !(wmPtr2->flags & WM_NEVER_MAPPED)) { wmPtr2->withdrawn = 0; if (XWithdrawWindow(Tk_Display(tkwin2), Tk_WindowId(wmPtr2->wrapperPtr), Tk_ScreenNumber(tkwin2)) == 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; } WaitForMapNotify((TkWindow *) tkwin2, 0); } } UpdateHints(winPtr); return TCL_OK; |
︙ | ︙ | |||
2663 2664 2665 2666 2667 2668 2669 | Tcl_Obj *const objv[]) /* Argument objects. */ { register Tk_Window frameWin = (Tk_Window) winPtr; register WmInfo *wmPtr = winPtr->wmInfoPtr; if (!Tk_IsTopLevel(frameWin)) { if (!Tk_IsManageable(frameWin)) { | | | | > | 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 | Tcl_Obj *const objv[]) /* Argument objects. */ { register Tk_Window frameWin = (Tk_Window) winPtr; register WmInfo *wmPtr = winPtr->wmInfoPtr; if (!Tk_IsTopLevel(frameWin)) { if (!Tk_IsManageable(frameWin)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" is not manageable: must be a frame," " labelframe or toplevel", Tk_PathName(frameWin))); Tcl_SetErrorCode(interp, "TK", "WM", "MANAGE", NULL); return TCL_ERROR; } TkFocusSplit(winPtr); Tk_UnmapWindow(frameWin); winPtr->flags |= TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED; if (wmPtr == NULL) { |
︙ | ︙ | |||
2727 2728 2729 2730 2731 2732 2733 | int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { | | > | | | 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 | int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { Tcl_Obj *results[2]; GetMaxSize(wmPtr, &width, &height); results[0] = Tcl_NewIntObj(width); results[1] = Tcl_NewIntObj(height); Tcl_SetObjResult(interp, Tcl_NewListObj(2, results)); return TCL_OK; } if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &height) != TCL_OK)) { return TCL_ERROR; } wmPtr->maxWidth = width; |
︙ | ︙ | |||
2785 2786 2787 2788 2789 2790 2791 | int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { | | > | | | 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 | int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { Tcl_Obj *results[2]; results[0] = Tcl_NewIntObj(wmPtr->minWidth); results[1] = Tcl_NewIntObj(wmPtr->minHeight); Tcl_SetObjResult(interp, Tcl_NewListObj(2, results)); return TCL_OK; } if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &height) != TCL_OK)) { return TCL_ERROR; } wmPtr->minWidth = width; |
︙ | ︙ | |||
2897 2898 2899 2900 2901 2902 2903 2904 | int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & USPosition) { | > > | | > | 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 | int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?"); return TCL_ERROR; } if (objc == 3) { const char *sourceStr = ""; if (wmPtr->sizeHintsFlags & USPosition) { sourceStr = "user"; } else if (wmPtr->sizeHintsFlags & PPosition) { sourceStr = "program"; } Tcl_SetObjResult(interp, Tcl_NewStringObj(sourceStr, -1)); return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->sizeHintsFlags &= ~(USPosition|PPosition); } else { if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { |
︙ | ︙ | |||
2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 | Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?"); return TCL_ERROR; } if (objc == 3) { /* * Return a list of all defined protocols for the window. */ for (protPtr = wmPtr->protPtr; protPtr != NULL; protPtr = protPtr->nextPtr) { | > > | | > > | > | < > | 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 | Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?"); return TCL_ERROR; } if (objc == 3) { /* * Return a list of all defined protocols for the window. */ Tcl_Obj *resultObj = Tcl_NewObj(); for (protPtr = wmPtr->protPtr; protPtr != NULL; protPtr = protPtr->nextPtr) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( Tk_GetAtomName((Tk_Window)winPtr, protPtr->protocol),-1)); } Tcl_SetObjResult(interp, resultObj); return TCL_OK; } protocol = Tk_InternAtom((Tk_Window) winPtr, Tcl_GetString(objv[3])); if (objc == 4) { /* * Return the command to handle a given protocol. */ for (protPtr = wmPtr->protPtr; protPtr != NULL; protPtr = protPtr->nextPtr) { if (protPtr->protocol == protocol) { Tcl_SetObjResult(interp, Tcl_NewStringObj(protPtr->command, -1)); return TCL_OK; } } return TCL_OK; } /* * Special case for _NET_WM_PING: that's always handled directly. */ if (strcmp(Tcl_GetString(objv[3]), "_NET_WM_PING") == 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "may not alter handling of that protocol", -1)); Tcl_SetErrorCode(interp, "TK", "WM", "PROTOCOL", "RESERVED", NULL); return TCL_ERROR; } /* * Delete any current protocol handler, then create a new one with the * specified command, unless the command is empty. */ |
︙ | ︙ | |||
3062 3063 3064 3065 3066 3067 3068 | int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { | | < | | | | 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 | int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { Tcl_Obj *results[2]; results[0] = Tcl_NewBooleanObj(!(wmPtr->flags&WM_WIDTH_NOT_RESIZABLE)); results[1] = Tcl_NewBooleanObj(!(wmPtr->flags&WM_HEIGHT_NOT_RESIZABLE)); Tcl_SetObjResult(interp, Tcl_NewListObj(2, results)); return TCL_OK; } if ((Tcl_GetBooleanFromObj(interp, objv[3], &width) != TCL_OK) || (Tcl_GetBooleanFromObj(interp, objv[4], &height) != TCL_OK)) { return TCL_ERROR; } if (width) { |
︙ | ︙ | |||
3126 3127 3128 3129 3130 3131 3132 3133 | int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & USSize) { | > > | | > | 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 | int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?"); return TCL_ERROR; } if (objc == 3) { const char *sourceStr = ""; if (wmPtr->sizeHintsFlags & USSize) { sourceStr = "user"; } else if (wmPtr->sizeHintsFlags & PSize) { sourceStr = "program"; } Tcl_SetObjResult(interp, Tcl_NewStringObj(sourceStr, -1)); return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->sizeHintsFlags &= ~(USSize|PSize); } else { if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, |
︙ | ︙ | |||
3194 3195 3196 3197 3198 3199 3200 3201 3202 | Tcl_WrongNumArgs(interp, 2, objv, "window ?isabove|isbelow window?"); return TCL_ERROR; } if (objc == 3) { windows = TkWmStackorderToplevel(winPtr); if (windows != NULL) { /* ASSERT: true [Bug 1789819]*/ for (window_ptr = windows; *window_ptr ; window_ptr++) { | > > > | > | | > > | | > | | > < > | > | 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 | Tcl_WrongNumArgs(interp, 2, objv, "window ?isabove|isbelow window?"); return TCL_ERROR; } if (objc == 3) { windows = TkWmStackorderToplevel(winPtr); if (windows != NULL) { Tcl_Obj *resultObj = Tcl_NewObj(); /* ASSERT: true [Bug 1789819]*/ for (window_ptr = windows; *window_ptr ; window_ptr++) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj((*window_ptr)->pathName, -1)); } ckfree(windows); Tcl_SetObjResult(interp, resultObj); return TCL_OK; } } else { Tk_Window relWin; TkWindow *winPtr2; int index1=-1, index2=-1, result; if (TkGetWindowFromObj(interp, tkwin, objv[4], &relWin) != TCL_OK) { return TCL_ERROR; } winPtr2 = (TkWindow *) relWin; if (!Tk_IsTopLevel(winPtr2)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't a top-level window", winPtr2->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "TOPLEVEL", NULL); return TCL_ERROR; } if (!Tk_IsMapped(winPtr)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't mapped", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", NULL); return TCL_ERROR; } if (!Tk_IsMapped(winPtr2)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't mapped", winPtr2->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", NULL); return TCL_ERROR; } /* * Lookup stacking order of all toplevels that are children of "." and * find the position of winPtr and winPtr2 in the stacking order. */ windows = TkWmStackorderToplevel(winPtr->mainPtr->winPtr); if (windows == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "TkWmStackorderToplevel failed", -1)); Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL); return TCL_ERROR; } for (window_ptr = windows; *window_ptr ; window_ptr++) { if (*window_ptr == winPtr) { index1 = (window_ptr - windows); } |
︙ | ︙ | |||
3305 3306 3307 3308 3309 3310 3311 | if ((objc < 3) || (objc > 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?state?"); return TCL_ERROR; } if (objc == 4) { if (wmPtr->iconFor != NULL) { | | | | > | | > > > | | > > > | | > | | > > > | | | | > | 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 | if ((objc < 3) || (objc > 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?state?"); return TCL_ERROR; } if (objc == 4) { if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't change state of %s: it is an icon for %s", Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "ICON", NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } if (index == OPT_NORMAL) { wmPtr->flags &= ~WM_WITHDRAWN; (void) TkpWmSetState(winPtr, NormalState); } else if (index == OPT_ICONIC) { 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", "STATE", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } if (wmPtr->masterPtr != 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; } if (TkpWmSetState(winPtr, IconicState) == 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "couldn't send iconify message to window manager", -1)); Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL); return TCL_ERROR; } } else { /* OPT_WITHDRAWN */ wmPtr->flags |= WM_WITHDRAWN; 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 { const char *state; if (wmPtr->iconFor != NULL) { state = "icon"; } else if (wmPtr->withdrawn) { state = "withdrawn"; } else if (Tk_IsMapped((Tk_Window) winPtr) || ((wmPtr->flags & WM_NEVER_MAPPED) && (wmPtr->hints.initial_state == NormalState))) { state = "normal"; } else { state = "iconic"; } Tcl_SetObjResult(interp, Tcl_NewStringObj(state, -1)); } return TCL_OK; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
3395 3396 3397 3398 3399 3400 3401 | int length; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?"); return TCL_ERROR; } if (objc == 3) { | > | > | < < > | 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 | int length; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->title) { Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->title, -1)); } else { Tcl_SetObjResult(interp, Tcl_NewStringObj(winPtr->nameUid, -1)); } } else { if (wmPtr->title != NULL) { ckfree(wmPtr->title); } argv3 = Tcl_GetStringFromObj(objv[3], &length); wmPtr->title = ckalloc(length + 1); strcpy(wmPtr->title, argv3); |
︙ | ︙ | |||
3489 3490 3491 3492 3493 3494 3495 | */ masterPtr = masterPtr->parentPtr; } Tk_MakeWindowExist((Tk_Window) masterPtr); if (wmPtr->iconFor != NULL) { | | | | > | | | > | | > | 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 | */ masterPtr = masterPtr->parentPtr; } Tk_MakeWindowExist((Tk_Window) masterPtr); 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 = masterPtr->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; } if (masterPtr == winPtr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't make \"%s\" its own master", Tk_PathName(winPtr))); Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL); return TCL_ERROR; } else if (masterPtr != wmPtr->masterPtr) { /* * Remove old master map/unmap binding before setting the new * master. The event handler will ensure that transient states * reflect the state of the master. */ |
︙ | ︙ | |||
3534 3535 3536 3537 3538 3539 3540 | wmPtr->masterPtr = masterPtr; } } if (!(wmPtr->flags & WM_NEVER_MAPPED)) { if (wmPtr->masterPtr != NULL && !Tk_IsMapped(wmPtr->masterPtr)) { if (TkpWmSetState(winPtr, WithdrawnState) == 0) { | | | > | 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 | wmPtr->masterPtr = masterPtr; } } if (!(wmPtr->flags & WM_NEVER_MAPPED)) { if (wmPtr->masterPtr != NULL && !Tk_IsMapped(wmPtr->masterPtr)) { 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->masterPtr != NULL) { XSetTransientForHint(winPtr->display, wmPtr->wrapperPtr->window, wmPtr->masterPtr->wmInfoPtr->wrapperPtr->window); |
︙ | ︙ | |||
3585 3586 3587 3588 3589 3590 3591 | register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { | > | | > | | | | 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 | register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't withdraw %s: it is an icon for %s", Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "WITHDRAW", "ICON", NULL); return TCL_ERROR; } wmPtr->flags |= WM_WITHDRAWN; 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; } return TCL_OK; } /* * Invoked by those wm subcommands that affect geometry. Schedules a geometry |
︙ | ︙ | |||
4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 | Window vRoot, ancestor, *children, dummy2, *virtualRootPtr, **vrPtrPtr; Atom actualType; int actualFormat; unsigned long numItems, bytesAfter; unsigned dummy; Tk_ErrorHandler handler; TkDisplay *dispPtr = wmPtr->winPtr->dispPtr; /* * Identify the root window for wrapperPtr. This is tricky because of * virtual root window managers like tvtwm. If the window has a property * named __SWM_ROOT or __WM_ROOT then this property gives the id for a * virtual root window that should be used instead of the root window of * the screen. */ vRoot = RootWindow(wrapperPtr->display, wrapperPtr->screenNum); wmPtr->vRoot = None; handler = Tk_CreateErrorHandler(wrapperPtr->display, -1,-1,-1, NULL,NULL); vrPtrPtr = &virtualRootPtr; /* Silence GCC warning */ | > > | < | < | < | < | 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 | Window vRoot, ancestor, *children, dummy2, *virtualRootPtr, **vrPtrPtr; Atom actualType; int actualFormat; unsigned long numItems, bytesAfter; unsigned dummy; Tk_ErrorHandler handler; TkDisplay *dispPtr = wmPtr->winPtr->dispPtr; Atom WM_ROOT = Tk_InternAtom((Tk_Window) wrapperPtr, "__WM_ROOT"); Atom SWM_ROOT = Tk_InternAtom((Tk_Window) wrapperPtr, "__SWM_ROOT"); /* * Identify the root window for wrapperPtr. This is tricky because of * virtual root window managers like tvtwm. If the window has a property * named __SWM_ROOT or __WM_ROOT then this property gives the id for a * virtual root window that should be used instead of the root window of * the screen. */ vRoot = RootWindow(wrapperPtr->display, wrapperPtr->screenNum); wmPtr->vRoot = None; handler = Tk_CreateErrorHandler(wrapperPtr->display, -1,-1,-1, NULL,NULL); vrPtrPtr = &virtualRootPtr; /* Silence GCC warning */ if ((GetWindowProperty(wrapperPtr, WM_ROOT, 1, XA_WINDOW, &actualType, &actualFormat, &numItems, &bytesAfter, vrPtrPtr) && (actualType == XA_WINDOW)) || (GetWindowProperty(wrapperPtr, SWM_ROOT, 1, XA_WINDOW, &actualType, &actualFormat, &numItems, &bytesAfter, vrPtrPtr) && (actualType == XA_WINDOW))) { if ((actualFormat == 32) && (numItems == 1)) { vRoot = wmPtr->vRoot = *virtualRootPtr; } else if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { printf("%s format %d numItems %ld\n", "ReparentEvent got bogus VROOT property:", actualFormat, numItems); |
︙ | ︙ | |||
4281 4282 4283 4284 4285 4286 4287 | if (eventPtr->atom == _NET_WM_STATE) { Atom actualType; int actualFormat; unsigned long numItems, bytesAfter; unsigned char *propertyValue = 0; long maxLength = 1024; | | < < | | 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 | if (eventPtr->atom == _NET_WM_STATE) { Atom actualType; int actualFormat; unsigned long numItems, bytesAfter; unsigned char *propertyValue = 0; long maxLength = 1024; if (GetWindowProperty(wrapperPtr, _NET_WM_STATE, maxLength, XA_ATOM, &actualType, &actualFormat, &numItems, &bytesAfter, &propertyValue)) { CheckNetWmState(wmPtr, (Atom *) propertyValue, (int) numItems); XFree(propertyValue); } } } /* |
︙ | ︙ | |||
4586 4587 4588 4589 4590 4591 4592 | * There may also be a size-hint-update request pending from somewhere * else, too. */ if (((width != winPtr->changes.width) || (height != winPtr->changes.height)) && (wmPtr->gridWin == NULL) | | | 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 | * There may also be a size-hint-update request pending from somewhere * else, too. */ if (((width != winPtr->changes.width) || (height != winPtr->changes.height)) && (wmPtr->gridWin == NULL) && !(wmPtr->sizeHintsFlags & (PMinSize|PMaxSize))) { wmPtr->flags |= WM_UPDATE_SIZE_HINTS; } if (wmPtr->flags & WM_UPDATE_SIZE_HINTS) { UpdateSizeHints(winPtr, width, height); } /* |
︙ | ︙ | |||
4844 4845 4846 4847 4848 4849 4850 | string = (wmPtr->title != NULL) ? wmPtr->title : winPtr->nameUid; Tcl_UtfToExternalDString(NULL, string, -1, &ds); XStoreName(winPtr->display, wmPtr->wrapperPtr->window, Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); | < < | | < | | < < | 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 | string = (wmPtr->title != NULL) ? wmPtr->title : winPtr->nameUid; Tcl_UtfToExternalDString(NULL, string, -1, &ds); XStoreName(winPtr->display, wmPtr->wrapperPtr->window, Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_NAME", XA_UTF8_STRING, 8, string, strlen(string)); /* * Set icon name: */ if (wmPtr->iconName != NULL) { Tcl_UtfToExternalDString(NULL, wmPtr->iconName, -1, &ds); XSetIconName(winPtr->display, wmPtr->wrapperPtr->window, Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_ICON_NAME", XA_UTF8_STRING, 8, wmPtr->iconName, strlen(wmPtr->iconName)); } } /* *-------------------------------------------------------------- * * UpdatePhotoIcon -- |
︙ | ︙ | |||
4894 4895 4896 4897 4898 4899 4900 | int size = wmPtr->iconDataSize; if (data == NULL) { data = winPtr->dispPtr->iconDataPtr; size = winPtr->dispPtr->iconDataSize; } if (data != NULL) { | < < < | < < < | | 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 | int size = wmPtr->iconDataSize; if (data == NULL) { data = winPtr->dispPtr->iconDataPtr; size = winPtr->dispPtr->iconDataSize; } if (data != NULL) { SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_ICON", XA_CARDINAL, 32, data, size); } } /* *---------------------------------------------------------------------- * * SetNetWmState -- |
︙ | ︙ | |||
5042 5043 5044 5045 5046 5047 5048 | atoms[numAtoms++] = Tk_InternAtom(tkwin,"_NET_WM_STATE_MAXIMIZED_VERT"); atoms[numAtoms++] = Tk_InternAtom(tkwin,"_NET_WM_STATE_MAXIMIZED_HORZ"); } if (wmPtr->reqState.fullscreen) { atoms[numAtoms++] = Tk_InternAtom(tkwin, "_NET_WM_STATE_FULLSCREEN"); } | < | | | | 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 | atoms[numAtoms++] = Tk_InternAtom(tkwin,"_NET_WM_STATE_MAXIMIZED_VERT"); atoms[numAtoms++] = Tk_InternAtom(tkwin,"_NET_WM_STATE_MAXIMIZED_HORZ"); } if (wmPtr->reqState.fullscreen) { atoms[numAtoms++] = Tk_InternAtom(tkwin, "_NET_WM_STATE_FULLSCREEN"); } SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_STATE", XA_ATOM, 32, atoms, numAtoms); } /* *---------------------------------------------------------------------- * * WaitForConfigureNotify -- * * This function is invoked in order to synchronize with the window * manager. It waits for a ConfigureNotify event to arrive, signalling |
︙ | ︙ | |||
5344 5345 5346 5347 5348 5349 5350 | } /* *---------------------------------------------------------------------- * * SetNetWmType -- * | | | | | | | | > > | < | | 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 | } /* *---------------------------------------------------------------------- * * SetNetWmType -- * * Set the extended window manager hints for a toplevel window to the * types provided. The specification states that this may be a list of * window types in preferred order. To permit for future type * definitions, the set of names is unconstrained and names are converted * to upper-case and appended to "_NET_WM_WINDOW_TYPE_" before being * converted to an Atom. * *---------------------------------------------------------------------- */ static int SetNetWmType( TkWindow *winPtr, Tcl_Obj *typePtr) { Atom *atoms = NULL; WmInfo *wmPtr; Tcl_Obj **objv; int objc, n; Tk_Window tkwin = (Tk_Window) winPtr; Tcl_Interp *interp = Tk_Interp(tkwin); if (TCL_OK != Tcl_ListObjGetElements(interp, typePtr, &objc, &objv)) { return TCL_ERROR; } if (!Tk_HasWrapper(tkwin)) { |
︙ | ︙ | |||
5397 5398 5399 5400 5401 5402 5403 | Tcl_DStringFree(&ds); } wmPtr = winPtr->wmInfoPtr; if (wmPtr->wrapperPtr == NULL) { CreateWrapper(wmPtr); } | < | < | | | < | > | | < | < | > | 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 | Tcl_DStringFree(&ds); } wmPtr = winPtr->wmInfoPtr; if (wmPtr->wrapperPtr == NULL) { CreateWrapper(wmPtr); } SetWindowProperty(wmPtr->wrapperPtr, "_NET_WM_WINDOW_TYPE", XA_ATOM, 32, atoms, objc); ckfree(atoms); return TCL_OK; } /* *---------------------------------------------------------------------- * * GetNetWmType -- * * Read the extended window manager type hint from a window and return as * a list of names suitable for use with SetNetWmType. * *---------------------------------------------------------------------- */ static Tcl_Obj * GetNetWmType( TkWindow *winPtr) { Atom typeAtom, actualType, *atoms; int actualFormat; unsigned long n, count, bytesAfter; unsigned char *propertyValue = NULL; long maxLength = 1024; Tk_Window tkwin = (Tk_Window) winPtr; TkWindow *wrapperPtr; Tcl_Obj *typePtr; Tcl_Interp *interp; Tcl_DString ds; interp = Tk_Interp(tkwin); typePtr = Tcl_NewListObj(0, NULL); if (winPtr->wmInfoPtr->wrapperPtr == NULL) { CreateWrapper(winPtr->wmInfoPtr); } wrapperPtr = winPtr->wmInfoPtr->wrapperPtr; typeAtom = Tk_InternAtom(tkwin, "_NET_WM_WINDOW_TYPE"); if (GetWindowProperty(wrapperPtr, typeAtom, maxLength, XA_ATOM, &actualType, &actualFormat, &count, &bytesAfter, &propertyValue)){ atoms = (Atom *) propertyValue; for (n = 0; n < count; ++n) { const char *name = Tk_GetAtomName(tkwin, atoms[n]); if (strncmp("_NET_WM_WINDOW_TYPE_", name, 20) == 0) { Tcl_ExternalToUtfDString(NULL, name+20, -1, &ds); Tcl_UtfToLower(Tcl_DStringValue(&ds)); Tcl_ListObjAppendElement(interp, typePtr, Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds))); Tcl_DStringFree(&ds); |
︙ | ︙ | |||
5566 5567 5568 5569 5570 5571 5572 | /* * Assume that the geometry information came from the user, unless an * explicit source has been specified. Otherwise most window managers * assume that the size hints were program-specified and they ignore * them. */ | | | 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 | /* * Assume that the geometry information came from the user, unless an * explicit source has been specified. Otherwise most window managers * assume that the size hints were program-specified and they ignore * them. */ if (!(wmPtr->sizeHintsFlags & (USPosition|PPosition))) { wmPtr->sizeHintsFlags |= USPosition; flags |= WM_UPDATE_SIZE_HINTS; } } /* * Everything was parsed OK. Update the fields of *wmPtr and arrange for |
︙ | ︙ | |||
5592 5593 5594 5595 5596 5597 5598 | if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } return TCL_OK; error: | > | > | 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 | if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } return TCL_OK; error: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad geometry specifier \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "GEOMETRY", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * Tk_GetRootCoords -- |
︙ | ︙ | |||
6063 6064 6065 6066 6067 6068 6069 | if (!(winPtr->flags & TK_TOP_LEVEL)) { Tcl_Panic("Tk_MoveToplevelWindow called with non-toplevel window"); } wmPtr->x = x; wmPtr->y = y; wmPtr->flags |= WM_MOVE_PENDING; wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y); | | | 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 | if (!(winPtr->flags & TK_TOP_LEVEL)) { Tcl_Panic("Tk_MoveToplevelWindow called with non-toplevel window"); } wmPtr->x = x; wmPtr->y = y; wmPtr->flags |= WM_MOVE_PENDING; wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y); if (!(wmPtr->sizeHintsFlags & (USPosition|PPosition))) { wmPtr->sizeHintsFlags |= USPosition; wmPtr->flags |= WM_UPDATE_SIZE_HINTS; } /* * If the window has already been mapped, must bring its geometry * up-to-date immediately, otherwise an event might arrive from the server |
︙ | ︙ | |||
6134 6135 6136 6137 6138 6139 6140 | for (protPtr = wmPtr->protPtr, atomPtr = &arrayPtr[1]; protPtr != NULL; protPtr = protPtr->nextPtr) { if (protPtr->protocol != deleteWindowAtom && protPtr->protocol != pingAtom) { *(atomPtr++) = protPtr->protocol; } } | | < < | | 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 | for (protPtr = wmPtr->protPtr, atomPtr = &arrayPtr[1]; protPtr != NULL; protPtr = protPtr->nextPtr) { if (protPtr->protocol != deleteWindowAtom && protPtr->protocol != pingAtom) { *(atomPtr++) = protPtr->protocol; } } SetWindowProperty(wmPtr->wrapperPtr, "WM_PROTOCOLS", XA_ATOM, 32, arrayPtr, atomPtr-arrayPtr); ckfree(arrayPtr); } /* *---------------------------------------------------------------------- * * TkWmProtocolEventProc -- |
︙ | ︙ | |||
6327 6328 6329 6330 6331 6332 6333 | switch (table.numEntries) { case 0: windows[0] = NULL; goto done; case 1: hPtr = Tcl_FirstHashEntry(&table, &search); | | | > > | > | 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 | switch (table.numEntries) { case 0: windows[0] = NULL; goto done; case 1: hPtr = Tcl_FirstHashEntry(&table, &search); windows[0] = Tcl_GetHashValue(hPtr); windows[1] = NULL; goto done; } vRoot = parentPtr->wmInfoPtr->vRoot; if (vRoot == None) { vRoot = RootWindowOfScreen(Tk_Screen((Tk_Window) parentPtr)); } if (XQueryTree(parentPtr->display, vRoot, &dummy1, &dummy2, &children, &numChildren) == 0) { ckfree(windows); windows = NULL; } else { for (i = 0; i < numChildren; i++) { hPtr = Tcl_FindHashEntry(&table, (char *) children[i]); if (hPtr != NULL) { childWinPtr = Tcl_GetHashValue(hPtr); *window_ptr++ = childWinPtr; } } /* * ASSERT: window_ptr - windows == table.numEntries * (#matched toplevel windows == #children) [Bug 1789819] */ *window_ptr = NULL; if (numChildren) { XFree((char *) children); } } done: |
︙ | ︙ | |||
7305 7306 7307 7308 7309 7310 7311 | } /* *---------------------------------------------------------------------- * * RemapWindows * | | < | | | 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 | } /* *---------------------------------------------------------------------- * * RemapWindows * * Adjust parent/child relationships of the given window hierarchy. * * Results: * None * * Side effects: * Keeps windowing system (X11) happy * *---------------------------------------------------------------------- */ static void RemapWindows( TkWindow *winPtr, |
︙ | ︙ |
Changes to win/tkWinClipboard.c.
︙ | ︙ | |||
158 159 160 161 162 163 164 | result = proc(clientData, interp, Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); CloseClipboard(); return result; error: | | | | > | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | result = proc(clientData, interp, Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); CloseClipboard(); return result; error: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s selection doesn't exist or form \"%s\" not defined", Tk_GetAtomName(tkwin, selection), Tk_GetAtomName(tkwin, target))); Tcl_SetErrorCode(interp, "TK", "SELECTION", "EXISTS", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * TkSetSelectionOwner -- |
︙ | ︙ |
Changes to win/tkWinCursor.c.
︙ | ︙ | |||
68 69 70 71 72 73 74 | }; /* * The default cursor is used whenever no other cursor has been specified. */ #define TK_DEFAULT_CURSOR IDC_ARROW | | < | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | }; /* * The default cursor is used whenever no other cursor has been specified. */ #define TK_DEFAULT_CURSOR IDC_ARROW /* *---------------------------------------------------------------------- * * TkGetCursorByName -- * * Retrieve a system cursor by name. * |
︙ | ︙ | |||
127 128 129 130 131 132 133 | * -cursor @C:/Winnt/cursors/E_arrow.cur * -cursor {@C:/Program\ Files/Cursors/bart.ani} * -cursor {{@C:/Program Files/Cursors/bart.ani}} * -cursor [list @[file join "C:/Program Files" Cursors bart.ani]] */ if (Tcl_IsSafe(interp)) { | > | | | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | * -cursor @C:/Winnt/cursors/E_arrow.cur * -cursor {@C:/Program\ Files/Cursors/bart.ani} * -cursor {{@C:/Program Files/Cursors/bart.ani}} * -cursor [list @[file join "C:/Program Files" Cursors bart.ani]] */ if (Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't get cursor from a file in a safe interpreter",-1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "CURSOR_FILE", NULL); ckfree(argv); ckfree(cursorPtr); return NULL; } cursorPtr->winCursor = LoadCursorFromFileA(&(argv[0][1])); } else { /* |
︙ | ︙ | |||
162 163 164 165 166 167 168 | } } if (cursorPtr->winCursor == NULL) { ckfree(cursorPtr); badCursorSpec: ckfree(argv); | > | > | | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | } } if (cursorPtr->winCursor == NULL) { ckfree(cursorPtr); badCursorSpec: ckfree(argv); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad cursor spec \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "CURSOR", NULL); return NULL; } ckfree(argv); return (TkCursor *) cursorPtr; } /* *---------------------------------------------------------------------- * * TkCreateCursorFromData -- * * Creates a cursor from the source and mask bits. * |
︙ | ︙ | |||
197 198 199 200 201 202 203 | int width, int height, /* Dimensions of cursor. */ int xHot, int yHot, /* Location of hot-spot in cursor. */ XColor fgColor, /* Foreground color for cursor. */ XColor bgColor) /* Background color for cursor. */ { return NULL; } | | | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | int width, int height, /* Dimensions of cursor. */ int xHot, int yHot, /* Location of hot-spot in cursor. */ XColor fgColor, /* Foreground color for cursor. */ XColor bgColor) /* Background color for cursor. */ { return NULL; } /* *---------------------------------------------------------------------- * * TkpFreeCursor -- * * This procedure is called to release a cursor allocated by * TkGetCursorByName. |
︙ | ︙ | |||
221 222 223 224 225 226 227 | void TkpFreeCursor( TkCursor *cursorPtr) { /* TkWinCursor *winCursorPtr = (TkWinCursor *) cursorPtr; */ } | | | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | void TkpFreeCursor( TkCursor *cursorPtr) { /* TkWinCursor *winCursorPtr = (TkWinCursor *) cursorPtr; */ } /* *---------------------------------------------------------------------- * * TkpSetCursor -- * * Set the global cursor. If the cursor is None, then use the default Tk * cursor. |
︙ | ︙ | |||
256 257 258 259 260 261 262 | hcursor = winCursor->winCursor; } if (hcursor != NULL) { SetCursor(hcursor); } } | | | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | hcursor = winCursor->winCursor; } if (hcursor != NULL) { SetCursor(hcursor); } } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to win/tkWinDialog.c.
︙ | ︙ | |||
357 358 359 360 361 362 363 | valuePtr = objv[i + 1]; if (Tcl_GetIndexFromObj(interp, optionPtr, optionStrings, "option", TCL_EXACT, &index) != TCL_OK) { return TCL_ERROR; } if (i + 1 == objc) { | > | < | | 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | valuePtr = objv[i + 1]; if (Tcl_GetIndexFromObj(interp, optionPtr, optionStrings, "option", TCL_EXACT, &index) != TCL_OK) { return TCL_ERROR; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(optionPtr))); Tcl_SetErrorCode(interp, "TK", "COLORDIALOG", "VALUE", NULL); return TCL_ERROR; } string = Tcl_GetString(valuePtr); switch ((enum options) index) { case COLOR_INITIAL: { XColor *colorPtr; |
︙ | ︙ | |||
420 421 422 423 424 425 426 | * 3. Process the result of the dialog */ if (winCode) { /* * User has selected a color */ | < | | < | 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | * 3. Process the result of the dialog */ if (winCode) { /* * User has selected a color */ Tcl_SetObjResult(interp, Tcl_ObjPrintf("#%02x%02x%02x", GetRValue(chooseColor.rgbResult), GetGValue(chooseColor.rgbResult), GetBValue(chooseColor.rgbResult))); oldColor = chooseColor.rgbResult; result = TCL_OK; } return result; } |
︙ | ︙ | |||
579 580 581 582 583 584 585 | int confirmOverwrite = 1; const char *extension = NULL, *title = NULL; Tk_Window tkwin = clientData; HWND hWnd; Tcl_Obj *filterObj = NULL, *initialTypeObj = NULL, *typeVariableObj = NULL; Tcl_DString utfFilterString, utfDirString, ds; Tcl_DString extString, filterString, dirString, titleString; | | | | | 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 | int confirmOverwrite = 1; const char *extension = NULL, *title = NULL; Tk_Window tkwin = clientData; HWND hWnd; Tcl_Obj *filterObj = NULL, *initialTypeObj = NULL, *typeVariableObj = NULL; Tcl_DString utfFilterString, utfDirString, ds; Tcl_DString extString, filterString, dirString, titleString; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); static const char *const saveOptionStrings[] = { "-confirmoverwrite", "-defaultextension", "-filetypes", "-initialdir", "-initialfile", "", "-parent", "-title", "-typevariable", NULL }; static const char *const openOptionStrings[] = { "", "-defaultextension", "-filetypes", "-initialdir", "-initialfile", "-multiple", "-parent", "-title", "-typevariable", NULL }; enum options { FILE_CONFIRMOW, FILE_DEFAULT, FILE_TYPES, FILE_INITDIR, FILE_INITFILE, FILE_MULTIPLE, FILE_PARENT, FILE_TITLE, FILE_TYPEVARIABLE }; file[0] = '\0'; ZeroMemory(&ofnData, sizeof(OFNData)); Tcl_DStringInit(&utfFilterString); Tcl_DStringInit(&utfDirString); |
︙ | ︙ | |||
615 616 617 618 619 620 621 | if (Tcl_GetIndexFromObj(interp, objv[i], open ? openOptionStrings : saveOptionStrings, "option", 0, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { | > | < | | 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 | if (Tcl_GetIndexFromObj(interp, objv[i], open ? openOptionStrings : saveOptionStrings, "option", 0, &index) != TCL_OK) { goto end; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL); goto end; } string = Tcl_GetString(valuePtr); switch ((enum options) index) { case FILE_DEFAULT: if (string[0] == '.') { |
︙ | ︙ | |||
643 644 645 646 647 648 649 | goto end; } break; case FILE_INITFILE: if (Tcl_TranslateFileName(interp, string, &ds) == NULL) { goto end; } | | | | | 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 | goto end; } break; case FILE_INITFILE: if (Tcl_TranslateFileName(interp, string, &ds) == NULL) { goto end; } Tcl_UtfToExternal(NULL, TkWinGetUnicodeEncoding(), Tcl_DStringValue(&ds), Tcl_DStringLength(&ds), 0, NULL, (char *) file, sizeof(file), NULL, NULL, NULL); Tcl_DStringFree(&ds); break; case FILE_PARENT: tkwin = Tk_NameToWindow(interp, string, tkwin); if (tkwin == NULL) { goto end; } |
︙ | ︙ | |||
866 867 868 869 870 871 872 | Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds))); gotFilename |= (Tcl_DStringLength(&ds) > 0); } Tcl_SetObjResult(interp, returnList); Tcl_DStringFree(&ds); } else { | > | < | 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 | Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds))); gotFilename |= (Tcl_DStringLength(&ds) > 0); } Tcl_SetObjResult(interp, returnList); Tcl_DStringFree(&ds); } else { Tcl_SetObjResult(interp, Tcl_NewStringObj( ConvertExternalFilename(ofn.lpstrFile, &ds), -1)); gotFilename = (Tcl_DStringLength(&ds) > 0); Tcl_DStringFree(&ds); } result = TCL_OK; if ((ofn.nFilterIndex > 0) && gotFilename && typeVariableObj && filterObj) { int listObjc, count; |
︙ | ︙ | |||
891 892 893 894 895 896 897 | result = TCL_ERROR; } else if (Tcl_ObjSetVar2(interp, typeVariableObj, NULL, typeInfo[0], TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) { result = TCL_ERROR; } } } else if (cdlgerr == FNERR_INVALIDFILENAME) { | > | | > | | 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 | result = TCL_ERROR; } else if (Tcl_ObjSetVar2(interp, typeVariableObj, NULL, typeInfo[0], TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) { result = TCL_ERROR; } } } else if (cdlgerr == FNERR_INVALIDFILENAME) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid filename \"%s\"", ConvertExternalFilename(ofn.lpstrFile, &ds))); Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "INVALID_FILENAME", NULL); Tcl_DStringFree(&ds); } else { result = TCL_OK; } if (ofn.lpstrTitle != NULL) { Tcl_DStringFree(&titleString); |
︙ | ︙ | |||
958 959 960 961 962 963 964 | if (uMsg == WM_INITDIALOG) { TkWinSetUserData(hdlg, lParam); } else if (uMsg == WM_NOTIFY) { OFNOTIFY *notifyPtr = (OFNOTIFY *) lParam; /* | | | | | | | | > > | 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 | if (uMsg == WM_INITDIALOG) { TkWinSetUserData(hdlg, lParam); } else if (uMsg == WM_NOTIFY) { OFNOTIFY *notifyPtr = (OFNOTIFY *) lParam; /* * This is weird... or not. The CDN_FILEOK is NOT sent when the * selection exceeds declared buffer size (the nMaxFile member of the * OPENFILENAME struct passed to GetOpenFileName function). So, we * have to rely on the most recent CDN_SELCHANGE then. Unfortunately * this means, that gathering the selected filenames happens twice * when they fit into the declared buffer. Luckily, it's not frequent * operation so it should not incur any noticeable delay. See [Bug * 2987995] */ if (notifyPtr->hdr.code == CDN_FILEOK || notifyPtr->hdr.code == CDN_SELCHANGE) { int dirsize, selsize; TCHAR *buffer; int buffersize; /* |
︙ | ︙ | |||
987 988 989 990 991 992 993 | hdlg = GetParent(hdlg); selsize = SendMessage(hdlg, CDM_GETSPEC, 0, 0); dirsize = SendMessage(hdlg, CDM_GETFOLDERPATH, 0, 0); buffersize = (selsize + dirsize + 1); /* | | > > | 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 | hdlg = GetParent(hdlg); selsize = SendMessage(hdlg, CDM_GETSPEC, 0, 0); dirsize = SendMessage(hdlg, CDM_GETFOLDERPATH, 0, 0); buffersize = (selsize + dirsize + 1); /* * Just empty the buffer if dirsize indicates an error. [Bug * 3071836] */ if ((selsize > 1) && (dirsize > 0)) { if (ofnData->dynFileBufferSize < buffersize) { buffer = ckrealloc(buffer, buffersize * sizeof(TCHAR)); ofnData->dynFileBufferSize = buffersize; ofnData->dynFileBuffer = buffer; } |
︙ | ︙ | |||
1353 1354 1355 1356 1357 1358 1359 | valuePtr = objv[i + 1]; if (Tcl_GetIndexFromObj(interp, optionPtr, optionStrings, "option", 0, &index) != TCL_OK) { goto cleanup; } if (i + 1 == objc) { | > | < | | > | 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 | valuePtr = objv[i + 1]; if (Tcl_GetIndexFromObj(interp, optionPtr, optionStrings, "option", 0, &index) != TCL_OK) { goto cleanup; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(optionPtr))); Tcl_SetErrorCode(interp, "TK", "DIRDIALOG", "VALUE", NULL); goto cleanup; } string = Tcl_GetString(valuePtr); switch ((enum options) index) { case DIR_INITIAL: if (Tcl_TranslateFileName(interp,string,&initDirString) == NULL) { goto cleanup; } Tcl_WinUtfToTChar(Tcl_DStringValue(&initDirString), -1, &tempString); uniStr = (TCHAR *) Tcl_DStringValue(&tempString); /* * Convert possible relative path to full path to keep dialog * happy. */ |
︙ | ︙ | |||
1457 1458 1459 1460 1461 1462 1463 | oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); GetCurrentDirectory(MAX_PATH, saveDir); if (SHGetMalloc(&pMalloc) == NOERROR) { pidl = SHBrowseForFolder(&bInfo); /* | | | | > > | < < > > | 1462 1463 1464 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 | oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); GetCurrentDirectory(MAX_PATH, saveDir); if (SHGetMalloc(&pMalloc) == NOERROR) { pidl = SHBrowseForFolder(&bInfo); /* * This is a fix for Windows 2000, which seems to modify the folder * name buffer even when the dialog is canceled (in this case the * buffer contains garbage). See [Bug #3002230] */ path[0] = '\0'; /* * Null for cancel button or invalid dir, otherwise valid. */ if (pidl != NULL) { if (!SHGetPathFromIDList(pidl, path)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "error: not a file system folder", -1)); Tcl_SetErrorCode(interp, "TK", "DIRDIALOG", "PSEUDO", NULL); } pMalloc->lpVtbl->Free(pMalloc, (void *) pidl); } else if (_tcslen(cdCBData.retDir) > 0) { _tcscpy(path, cdCBData.retDir); } pMalloc->lpVtbl->Release(pMalloc); } SetCurrentDirectory(saveDir); |
︙ | ︙ | |||
1498 1499 1500 1501 1502 1503 1504 | * slashes are used instead of forward slashes */ Tcl_ResetResult(interp); if (*path) { Tcl_DString ds; | > | < | 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 | * slashes are used instead of forward slashes */ Tcl_ResetResult(interp); if (*path) { Tcl_DString ds; Tcl_SetObjResult(interp, Tcl_NewStringObj( ConvertExternalFilename(path, &ds), -1)); Tcl_DStringFree(&ds); } result = TCL_OK; if (utfTitle != NULL) { Tcl_DStringFree(&titleString); |
︙ | ︙ | |||
1574 1575 1576 1577 1578 1579 1580 | chooseDirSharedData->retDir[0] = '\0'; return 1; } Tcl_DStringFree(&initDirString); Tcl_WinUtfToTChar(Tcl_DStringValue(&tempString), -1, &initDirString); Tcl_DStringFree(&tempString); | | > | > > | 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 | chooseDirSharedData->retDir[0] = '\0'; return 1; } Tcl_DStringFree(&initDirString); Tcl_WinUtfToTChar(Tcl_DStringValue(&tempString), -1, &initDirString); Tcl_DStringFree(&tempString); _tcsncpy(string, (TCHAR *) Tcl_DStringValue(&initDirString), MAX_PATH); Tcl_DStringFree(&initDirString); if (SetCurrentDirectory(string) == 0) { /* * Get the full path name to the user entry, at this point it does * not exist so see if it is supposed to. Otherwise just return * it. */ GetFullPathName(string, MAX_PATH, chooseDirSharedData->retDir, NULL); if (chooseDirSharedData->mustExist) { /* * User HAS to select a valid directory. */ wsprintf(selDir, TEXT("Directory '%s' does not exist,\n" "please select or enter an existing directory."), chooseDirSharedData->retDir); MessageBox(NULL, selDir, NULL, MB_ICONEXCLAMATION|MB_OK); chooseDirSharedData->retDir[0] = '\0'; return 1; } } else { /* * Changed to new folder OK, return immediatly with the current |
︙ | ︙ | |||
1728 1729 1730 1731 1732 1733 1734 | messageObj = NULL; parent = tkwin; titleObj = NULL; type = MB_OK; for (i = 1; i < objc; i += 2) { int index; | < > | < | | 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 | messageObj = NULL; parent = tkwin; titleObj = NULL; type = MB_OK; for (i = 1; i < objc; i += 2) { int index; Tcl_Obj *optionPtr, *valuePtr; optionPtr = objv[i]; valuePtr = objv[i + 1]; if (Tcl_GetIndexFromObj(interp, optionPtr, optionStrings, "option", TCL_EXACT, &index) != TCL_OK) { return TCL_ERROR; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(optionPtr))); Tcl_SetErrorCode(interp, "TK", "MSGBOX", "VALUE", NULL); return TCL_ERROR; } switch ((enum options) index) { case MSG_DEFAULT: defaultBtn = TkFindStateNumObj(interp, optionPtr, buttonMap, valuePtr); |
︙ | ︙ | |||
1810 1811 1812 1813 1814 1815 1816 | for (j = 0; j < 3; j++) { if (allowedTypes[i].btnIds[j] == defaultBtn) { defaultBtnIdx = j; break; } } if (defaultBtnIdx < 0) { | > | | | | 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 | for (j = 0; j < 3; j++) { if (allowedTypes[i].btnIds[j] == defaultBtn) { defaultBtnIdx = j; break; } } if (defaultBtnIdx < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid default button \"%s\"", TkFindStateString(buttonMap, defaultBtn))); Tcl_SetErrorCode(interp, "TK", "MSGBOX", "DEFAULT", NULL); return TCL_ERROR; } break; } } flags = buttonFlagMap[defaultBtnIdx]; } |
︙ | ︙ | |||
1860 1861 1862 1863 1864 1865 1866 | * the wrapper of the parent, which causes us to leave this child disabled * (Windows loses sync). */ EnableWindow(hWnd, 1); Tcl_DecrRefCount(tmpObj); | < | | | 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 | * the wrapper of the parent, which causes us to leave this child disabled * (Windows loses sync). */ EnableWindow(hWnd, 1); Tcl_DecrRefCount(tmpObj); Tcl_SetObjResult(interp, Tcl_NewStringObj( TkFindStateString(buttonMap, winCode), -1)); return TCL_OK; } static LRESULT CALLBACK MsgBoxCBTProc( int nCode, WPARAM wParam, |
︙ | ︙ | |||
1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 | sprintf(buf, "0x%p", (HWND) clientData); Tcl_SetVar(tsdPtr->debugInterp, "tk_dialog", buf, TCL_GLOBAL_ONLY); } /* * Factored out a common pattern in use in this file. */ static const char * ConvertExternalFilename( TCHAR *filename, Tcl_DString *dsPtr) { char *p; | > | 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 | sprintf(buf, "0x%p", (HWND) clientData); Tcl_SetVar(tsdPtr->debugInterp, "tk_dialog", buf, TCL_GLOBAL_ONLY); } /* * Factored out a common pattern in use in this file. */ static const char * ConvertExternalFilename( TCHAR *filename, Tcl_DString *dsPtr) { char *p; |
︙ | ︙ | |||
1965 1966 1967 1968 1969 1970 1971 | * Result: * A list containing a Tk font description. * * ---------------------------------------------------------------------- */ static Tcl_Obj * | | > > | 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 | * Result: * A list containing a Tk font description. * * ---------------------------------------------------------------------- */ static Tcl_Obj * GetFontObj( HDC hdc, LOGFONT *plf) { Tcl_DString ds; Tcl_Obj *resObj; int pt = 0; resObj = Tcl_NewListObj(0, NULL); Tcl_WinTCharToUtf(plf->lfFaceName, -1, &ds); |
︙ | ︙ | |||
1997 1998 1999 2000 2001 2002 2003 | Tcl_ListObjAppendElement(NULL, resObj, Tcl_NewStringObj("overstrike", -1)); } return resObj; } static void | | > > > > | 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 | Tcl_ListObjAppendElement(NULL, resObj, Tcl_NewStringObj("overstrike", -1)); } return resObj; } static void ApplyLogfont( Tcl_Interp *interp, Tcl_Obj *cmdObj, HDC hdc, LOGFONT *logfontPtr) { int objc; Tcl_Obj **objv, **tmpv; Tcl_ListObjGetElements(NULL, cmdObj, &objc, &objv); tmpv = ckalloc(sizeof(Tcl_Obj *) * (objc + 2)); memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc); |
︙ | ︙ | |||
2032 2033 2034 2035 2036 2037 2038 | Tcl_Obj *parentObj; Tcl_Obj *fontObj; HWND hwnd; Tk_Window parent; } HookData; static UINT_PTR CALLBACK | | > > > > | | 2048 2049 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 2076 2077 2078 | Tcl_Obj *parentObj; Tcl_Obj *fontObj; HWND hwnd; Tk_Window parent; } HookData; static UINT_PTR CALLBACK HookProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { CHOOSEFONT *pcf = (CHOOSEFONT *) lParam; HWND hwndCtrl; static HookData *phd = NULL; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (WM_INITDIALOG == msg && lParam != 0) { phd = (HookData *) pcf->lCustData; phd->hwnd = hwndDlg; if (tsdPtr->debugFlag) { tsdPtr->debugInterp = phd->interp; Tcl_DoWhenIdle(SetTkDialog, hwndDlg); } if (phd->titleObj != NULL) { Tcl_DString title; Tcl_WinUtfToTChar(Tcl_GetString(phd->titleObj), -1, &title); if (Tcl_DStringLength(&title) > 0) { |
︙ | ︙ | |||
2111 2112 2113 2114 2115 2116 2117 | enum FontchooserOption { FontchooserParent, FontchooserTitle, FontchooserFont, FontchooserCmd, FontchooserVisible }; static Tcl_Obj * | | > > | 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 | enum FontchooserOption { FontchooserParent, FontchooserTitle, FontchooserFont, FontchooserCmd, FontchooserVisible }; static Tcl_Obj * FontchooserCget( HookData *hdPtr, int optionIndex) { Tcl_Obj *resObj = NULL; switch(optionIndex) { case FontchooserParent: if (hdPtr->parentObj) { resObj = hdPtr->parentObj; |
︙ | ︙ | |||
2221 2222 2223 2224 2225 2226 2227 | * If one option and no arg - return the current value. */ Tcl_SetObjResult(interp, FontchooserCget(hdPtr, optionIndex)); return TCL_OK; } if (i + 1 == objc) { | | | > | > | 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 | * If one option and no arg - return the current value. */ Tcl_SetObjResult(interp, FontchooserCget(hdPtr, optionIndex)); return TCL_OK; } if (i + 1 == objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "value for \"%s\" missing", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "FONTDIALOG", "VALUE", NULL); return TCL_ERROR; } switch (optionIndex) { case FontchooserVisible: { static const char *msg = "cannot change read-only option " "\"-visible\": use the show or hide command"; Tcl_SetObjResult(interp, Tcl_NewStringObj(msg, -1)); Tcl_SetErrorCode(interp, "TK", "FONTDIALOG", "READONLY", NULL); return TCL_ERROR; } case FontchooserParent: { Tk_Window parent = Tk_NameToWindow(interp, Tcl_GetString(objv[i+1]), tkwin); if (parent == None) { |
︙ | ︙ | |||
2363 2364 2365 2366 2367 2368 2369 | Tk_Font f = Tk_AllocFontFromObj(interp, tkwin, hdPtr->fontObj); if (f == NULL) { return TCL_ERROR; } fontPtr = (TkFont *) f; cf.Flags |= CF_INITTOLOGFONTSTRUCT; | | | > | | 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 | Tk_Font f = Tk_AllocFontFromObj(interp, tkwin, hdPtr->fontObj); if (f == NULL) { return TCL_ERROR; } fontPtr = (TkFont *) f; cf.Flags |= CF_INITTOLOGFONTSTRUCT; Tcl_WinUtfToTChar(fontPtr->fa.family, -1, &ds); _tcsncpy(lf.lfFaceName, (TCHAR *)Tcl_DStringValue(&ds), LF_FACESIZE-1); Tcl_DStringFree(&ds); lf.lfFaceName[LF_FACESIZE-1] = 0; lf.lfHeight = -MulDiv(TkFontGetPoints(tkwin, fontPtr->fa.size), GetDeviceCaps(hdc, LOGPIXELSY), 72); if (fontPtr->fa.weight == TK_FW_BOLD) { lf.lfWeight = FW_BOLD; } if (fontPtr->fa.slant != TK_FS_ROMAN) { |
︙ | ︙ |
Changes to win/tkWinEmbed.c.
︙ | ︙ | |||
130 131 132 133 134 135 136 | BOOL detachFlag) /* a flag of truely detaching */ { TkpWinToplevelDetachWindow(winPtr); if(detachFlag) { TkpWinToplevelOverrideRedirect(winPtr, 0); } } | | | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | BOOL detachFlag) /* a flag of truely detaching */ { TkpWinToplevelDetachWindow(winPtr); if(detachFlag) { TkpWinToplevelOverrideRedirect(winPtr, 0); } } /* *---------------------------------------------------------------------- * * Tk_MapEmbeddedWindow -- * * This function is required for mapping an embedded window during idle. * The input winPtr must be preserved using Tcl_Preserve before call this |
︙ | ︙ | |||
239 240 241 242 243 244 245 | /* ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); */ /* if (winPtr->window != None) { | | | > | 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | /* ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); */ /* if (winPtr->window != None) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't modify container after widget is created", -1)); Tcl_SetErrorCode(interp, "TK", "EMBED", "POST_CREATE", NULL); return TCL_ERROR; } */ if (strcmp(string, "") == 0) { if (winPtr->flags & TK_EMBEDDED) { Tk_DetachEmbeddedWindow(winPtr, TRUE); |
︙ | ︙ | |||
268 269 270 271 272 273 274 | * Check if the window is a valid handle. If it is invalid, return * TCL_ERROR and potentially leave an error message in the interp's * result. */ if (!IsWindow(hwnd)) { if (interp != NULL) { | | | > > | > > | | > | > | 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 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 | * Check if the window is a valid handle. If it is invalid, return * TCL_ERROR and potentially leave an error message in the interp's * result. */ if (!IsWindow(hwnd)) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" doesn't exist", string)); Tcl_SetErrorCode(interp, "TK", "EMBED", "EXIST", NULL); } return TCL_ERROR; } id = SendMessage(hwnd, TK_INFO, TK_CONTAINER_VERIFY, 0); if (id == PTR2INT(hwnd)) { if (!SendMessage(hwnd, TK_INFO, TK_CONTAINER_ISAVAILABLE, 0)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "The container is already in use", -1)); Tcl_SetErrorCode(interp, "TK", "EMBED", "IN_USE", NULL); return TCL_ERROR; } } else if (id == -PTR2INT(hwnd)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "the window to use is not a Tk container", -1)); Tcl_SetErrorCode(interp, "TK", "EMBED", "CONTAINER", NULL); return TCL_ERROR; } else { /* * Proceed if the user decide to do so because it can be a legacy * container application. However we may have to return a TCL_ERROR in * order to avoid bug 1096074 in future. */ char msg[256]; sprintf(msg, "Unable to get information of window \"%.80s\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string); if (IDCANCEL == MessageBoxA(hwnd, msg, "Tk Warning", MB_OKCANCEL | MB_ICONWARNING)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Operation has been canceled", -1)); Tcl_SetErrorCode(interp, "TK", "EMBED", "CANCEL", NULL); return TCL_ERROR; } } Tk_DetachEmbeddedWindow(winPtr, FALSE); /* |
︙ | ︙ | |||
931 932 933 934 935 936 937 | containerPtr = containerPtr->nextPtr) { if (containerPtr->parentPtr == winPtr) { return containerPtr->embeddedHWnd; } } return NULL; } | | | 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 | containerPtr = containerPtr->nextPtr) { if (containerPtr->parentPtr == winPtr) { return containerPtr->embeddedHWnd; } } return NULL; } /* *---------------------------------------------------------------------- * * Tk_GetEmbeddedMenuHWND -- * * This function returns the embedded menu window id. * |
︙ | ︙ |
Changes to win/tkWinMenu.c.
︙ | ︙ | |||
151 152 153 154 155 156 157 | Drawable d, GC gc, Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int x, int y, int width, int height); static void DrawWindowsSystemBitmap(Display *display, Drawable drawable, GC gc, const RECT *rectPtr, int bitmapID, int alignFlags); static void FreeID(WORD commandID); | | | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | Drawable d, GC gc, Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int x, int y, int width, int height); static void DrawWindowsSystemBitmap(Display *display, Drawable drawable, GC gc, const RECT *rectPtr, int bitmapID, int alignFlags); static void FreeID(WORD commandID); static char * GetEntryText(TkMenuEntry *mePtr); static void GetMenuAccelGeometry(TkMenu *menuPtr, TkMenuEntry *mePtr, Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int *widthPtr, int *heightPtr); static void GetMenuLabelGeometry(TkMenuEntry *mePtr, Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int *widthPtr, int *heightPtr); |
︙ | ︙ | |||
183 184 185 186 187 188 189 190 191 192 193 194 195 196 | static void ReconfigureWindowsMenu(ClientData clientData); static void RecursivelyClearActiveMenu(TkMenu *menuPtr); static void SetDefaults(int firstTime); static LRESULT CALLBACK TkWinMenuProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK TkWinEmbeddedMenuProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); /* *---------------------------------------------------------------------- * * GetNewID -- * * Allocates a new menu id and marks it in use. | > > > > > > > > > > > > > > > > > > > > | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | static void ReconfigureWindowsMenu(ClientData clientData); static void RecursivelyClearActiveMenu(TkMenu *menuPtr); static void SetDefaults(int firstTime); static LRESULT CALLBACK TkWinMenuProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK TkWinEmbeddedMenuProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); static inline void ScheduleMenuReconfigure( TkMenu *menuPtr) { if (!(menuPtr->menuFlags & MENU_RECONFIGURE_PENDING)) { menuPtr->menuFlags |= MENU_RECONFIGURE_PENDING; Tcl_DoWhenIdle(ReconfigureWindowsMenu, menuPtr); } } static inline void CallPendingReconfigureImmediately( TkMenu *menuPtr) { if (menuPtr->menuFlags & MENU_RECONFIGURE_PENDING) { Tcl_CancelIdleCall(ReconfigureWindowsMenu, menuPtr); ReconfigureWindowsMenu(menuPtr); } } /* *---------------------------------------------------------------------- * * GetNewID -- * * Allocates a new menu id and marks it in use. |
︙ | ︙ | |||
209 210 211 212 213 214 215 | */ static int GetNewID( TkMenuEntry *mePtr, /* The menu we are working with. */ WORD *menuIDPtr) /* The resulting id. */ { | | | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | */ static int GetNewID( TkMenuEntry *mePtr, /* The menu we are working with. */ WORD *menuIDPtr) /* The resulting id. */ { ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); WORD curID = tsdPtr->lastCommandID; while (1) { Tcl_HashEntry *commandEntryPtr; int new; |
︙ | ︙ | |||
261 262 263 264 265 266 267 | *---------------------------------------------------------------------- */ static void FreeID( WORD commandID) { | | | > | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | *---------------------------------------------------------------------- */ static void FreeID( WORD commandID) { ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * If the menuHWND is NULL, this table has been finalized already. */ if (tsdPtr->menuHWND != NULL) { Tcl_HashEntry *entryPtr = Tcl_FindHashEntry(&tsdPtr->commandTable, INT2PTR(commandID)); if (entryPtr != NULL) { Tcl_DeleteHashEntry(entryPtr); } } } /* |
︙ | ︙ | |||
303 304 305 306 307 308 309 | TkpNewMenu( TkMenu *menuPtr) /* The common structure we are making the * platform structure for. */ { HMENU winMenuHdl; Tcl_HashEntry *hashEntryPtr; int newEntry; | | < > | | | 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | TkpNewMenu( TkMenu *menuPtr) /* The common structure we are making the * platform structure for. */ { HMENU winMenuHdl; Tcl_HashEntry *hashEntryPtr; int newEntry; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); winMenuHdl = CreatePopupMenu(); if (winMenuHdl == NULL) { Tcl_SetObjResult(menuPtr->interp, Tcl_NewStringObj( "No more menus can be allocated.", -1)); Tcl_SetErrorCode(interp, "TK", "MENU", "SYSTEM_RESOURCES", NULL); return TCL_ERROR; } /* * We hash all of the HMENU's so that we can get their menu ptrs back when * dispatch messages. */ |
︙ | ︙ | |||
349 350 351 352 353 354 355 | void TkpDestroyMenu( TkMenu *menuPtr) /* The common menu structure */ { HMENU winMenuHdl = (HMENU) menuPtr->platformData; const char *searchName; | | | | 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | void TkpDestroyMenu( TkMenu *menuPtr) /* The common menu structure */ { HMENU winMenuHdl = (HMENU) menuPtr->platformData; const char *searchName; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (menuPtr->menuFlags & MENU_RECONFIGURE_PENDING) { Tcl_CancelIdleCall(ReconfigureWindowsMenu, menuPtr); } if (winMenuHdl == NULL) { return; } if (menuPtr->menuFlags & MENU_SYSTEM_MENU) { |
︙ | ︙ | |||
396 397 398 399 400 401 402 403 404 405 406 407 408 409 | * Remove the menu from the menu hash table, then destroy the handle. * If the menuHWND is NULL, this table has been finalized already. */ if (tsdPtr->menuHWND != NULL) { Tcl_HashEntry *hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, (char *) winMenuHdl); if (hashEntryPtr != NULL) { Tcl_DeleteHashEntry(hashEntryPtr); } } DestroyMenu(winMenuHdl); } menuPtr->platformData = NULL; | > | 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | * Remove the menu from the menu hash table, then destroy the handle. * If the menuHWND is NULL, this table has been finalized already. */ if (tsdPtr->menuHWND != NULL) { Tcl_HashEntry *hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, (char *) winMenuHdl); if (hashEntryPtr != NULL) { Tcl_DeleteHashEntry(hashEntryPtr); } } DestroyMenu(winMenuHdl); } menuPtr->platformData = NULL; |
︙ | ︙ | |||
433 434 435 436 437 438 439 | TkpDestroyMenuEntry( TkMenuEntry *mePtr) /* The entry to destroy */ { TkMenu *menuPtr = mePtr->menuPtr; HMENU winMenuHdl = (HMENU) menuPtr->platformData; if (NULL != winMenuHdl) { | < < | < | 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 | TkpDestroyMenuEntry( TkMenuEntry *mePtr) /* The entry to destroy */ { TkMenu *menuPtr = mePtr->menuPtr; HMENU winMenuHdl = (HMENU) menuPtr->platformData; if (NULL != winMenuHdl) { ScheduleMenuReconfigure(menuPtr); } FreeID((WORD) PTR2INT(mePtr->platformEntryData)); mePtr->platformEntryData = NULL; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
545 546 547 548 549 550 551 | *---------------------------------------------------------------------- */ static void ReconfigureWindowsMenu( ClientData clientData) /* The menu we are rebuilding */ { | | | 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 | *---------------------------------------------------------------------- */ static void ReconfigureWindowsMenu( ClientData clientData) /* The menu we are rebuilding */ { TkMenu *menuPtr = clientData; TkMenuEntry *mePtr; HMENU winMenuHdl = (HMENU) menuPtr->platformData; char *itemText = NULL; const TCHAR *lpNewItem; UINT flags; UINT itemID; int i, count, systemMenu = 0, base; |
︙ | ︙ | |||
672 673 674 675 676 677 678 | Tcl_DStringFree(&ds); if ((menuRefPtr != NULL) && (menuRefPtr->menuPtr != NULL) && (menuPtr->parentTopLevelPtr != NULL) && (systemMenuPtr->masterMenuPtr == menuRefPtr->menuPtr)) { | | < > < < < < < | < | 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 | Tcl_DStringFree(&ds); if ((menuRefPtr != NULL) && (menuRefPtr->menuPtr != NULL) && (menuPtr->parentTopLevelPtr != NULL) && (systemMenuPtr->masterMenuPtr == menuRefPtr->menuPtr)) { HMENU systemMenuHdl = (HMENU) systemMenuPtr->platformData; HWND wrapper = TkWinGetWrapperWindow(menuPtr ->parentTopLevelPtr); if (wrapper != NULL) { DestroyMenu(systemMenuHdl); systemMenuHdl = GetSystemMenu(wrapper, FALSE); systemMenuPtr->menuFlags |= MENU_SYSTEM_MENU; systemMenuPtr->platformData = (TkMenuPlatformData) systemMenuHdl; ScheduleMenuReconfigure(systemMenuPtr); } } } if (mePtr->childMenuRefPtr->menuPtr->menuFlags & MENU_SYSTEM_MENU) { systemMenu++; } |
︙ | ︙ | |||
748 749 750 751 752 753 754 | { HMENU winMenuHdl = (HMENU) menuPtr->platformData; int result, flags; RECT noGoawayRect; POINT point; Tk_Window parentWindow = Tk_Parent(menuPtr->tkwin); int oldServiceMode = Tcl_GetServiceMode(); | | < < | < | 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 | { HMENU winMenuHdl = (HMENU) menuPtr->platformData; int result, flags; RECT noGoawayRect; POINT point; Tk_Window parentWindow = Tk_Parent(menuPtr->tkwin); int oldServiceMode = Tcl_GetServiceMode(); ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); tsdPtr->inPostMenu++; CallPendingReconfigureImmediately(menuPtr); result = TkPreprocessMenu(menuPtr); if (result != TCL_OK) { tsdPtr->inPostMenu--; return result; } |
︙ | ︙ | |||
851 852 853 854 855 856 857 | { WORD commandID; TkMenu *menuPtr = mePtr->menuPtr; if (GetNewID(mePtr, &commandID) != TCL_OK) { return TCL_ERROR; } | | < < < < < | 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | { WORD commandID; TkMenu *menuPtr = mePtr->menuPtr; if (GetNewID(mePtr, &commandID) != TCL_OK) { return TCL_ERROR; } ScheduleMenuReconfigure(menuPtr); mePtr->platformEntryData = (TkMenuPlatformEntryData) INT2PTR(commandID); return TCL_OK; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
919 920 921 922 923 924 925 926 927 928 929 | static void UpdateEmbeddedMenu( ClientData clientData) { RECT rc; HWND hMenuWnd = (HWND)clientData; GetClientRect(hMenuWnd, &rc); InvalidateRect(hMenuWnd, &rc, FALSE); UpdateWindow(hMenuWnd); } | > | | 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 | static void UpdateEmbeddedMenu( ClientData clientData) { RECT rc; HWND hMenuWnd = (HWND)clientData; GetClientRect(hMenuWnd, &rc); InvalidateRect(hMenuWnd, &rc, FALSE); UpdateWindow(hMenuWnd); } /* *---------------------------------------------------------------------- * * TkWinEmbeddedMenuProc -- * * This window proc is for the embedded menu windows. It provides * message services to an embedded menu in a different process. |
︙ | ︙ | |||
950 951 952 953 954 955 956 | HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static int nIdles = 0; LRESULT lResult = 1; | | | 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 | HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static int nIdles = 0; LRESULT lResult = 1; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); switch(message) { case WM_ENTERIDLE: if ((wParam == MSGF_MENU) && (nIdles < 1) && (hwnd == tsdPtr->embeddedMenuHWND)) { Tcl_CreateTimerHandler(200, UpdateEmbeddedMenu, |
︙ | ︙ | |||
993 994 995 996 997 998 999 | default: lResult = DefWindowProcA(hwnd, message, wParam, lParam); break; } return lResult; } | | | 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 | default: lResult = DefWindowProcA(hwnd, message, wParam, lParam); break; } return lResult; } /* *---------------------------------------------------------------------- * * TkWinHandleMenuEvent -- * * Filters out menu messages from messages passed to a top-level. Will * respond appropriately to WM_COMMAND, WM_MENUSELECT, WM_MEASUREITEM, |
︙ | ︙ | |||
1026 1027 1028 1029 1030 1031 1032 | LPARAM *plParam, LRESULT *plResult) { Tcl_HashEntry *hashEntryPtr; int returnResult = 0; TkMenu *menuPtr; TkMenuEntry *mePtr; | | | | < | < < < | < | | | | | 1032 1033 1034 1035 1036 1037 1038 1039 1040 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 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 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 1105 | LPARAM *plParam, LRESULT *plResult) { Tcl_HashEntry *hashEntryPtr; int returnResult = 0; TkMenu *menuPtr; TkMenuEntry *mePtr; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); switch (*pMessage) { case WM_UNINITMENUPOPUP: hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, (char *) *pwParam); if (hashEntryPtr != NULL) { menuPtr = Tcl_GetHashValue(hashEntryPtr); if ((menuPtr->menuRefPtr != NULL) && (menuPtr->menuRefPtr->parentEntryPtr != NULL)) { TkPostSubmenu(menuPtr->interp, menuPtr->menuRefPtr->parentEntryPtr->menuPtr, NULL); } } break; case WM_INITMENU: TkMenuInit(); hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, (char *) *pwParam); if (hashEntryPtr != NULL) { tsdPtr->oldServiceMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); menuPtr = Tcl_GetHashValue(hashEntryPtr); tsdPtr->modalMenuPtr = menuPtr; CallPendingReconfigureImmediately(menuPtr); RecursivelyClearActiveMenu(menuPtr); if (!tsdPtr->inPostMenu) { Tcl_Interp *interp = menuPtr->interp; int code; Tcl_Preserve(interp); code = TkPreprocessMenu(menuPtr); if ((code != TCL_OK) && (code != TCL_CONTINUE) && (code != TCL_BREAK)) { Tcl_AddErrorInfo(interp, "\n (menu preprocess)"); Tcl_BackgroundException(interp, code); } Tcl_Release(interp); } TkActivateMenuEntry(menuPtr, -1); *plResult = 0; returnResult = 1; } else { tsdPtr->modalMenuPtr = NULL; } break; case WM_SYSCOMMAND: case WM_COMMAND: TkMenuInit(); if (HIWORD(*pwParam) != 0) { break; } hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->commandTable, INT2PTR(LOWORD(*pwParam))); if (hashEntryPtr == NULL) { break; } mePtr = Tcl_GetHashValue(hashEntryPtr); if (mePtr != NULL) { TkMenuReferences *menuRefPtr; TkMenuEntry *parentEntryPtr; Tcl_Interp *interp; int code; /* |
︙ | ︙ | |||
1122 1123 1124 1125 1126 1127 1128 | ->state != ENTRY_DISABLED) { TkActivateMenuEntry(parentEntryPtr->menuPtr, parentEntryPtr->index); } } interp = menuPtr->interp; | | | | | 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 | ->state != ENTRY_DISABLED) { TkActivateMenuEntry(parentEntryPtr->menuPtr, parentEntryPtr->index); } } interp = menuPtr->interp; Tcl_Preserve(interp); code = TkInvokeMenu(interp, menuPtr, mePtr->index); if (code != TCL_OK && code != TCL_CONTINUE && code != TCL_BREAK) { Tcl_AddErrorInfo(interp, "\n (menu invoke)"); Tcl_BackgroundException(interp, code); } Tcl_Release(interp); *plResult = 0; returnResult = 1; } break; case WM_MENUCHAR: { hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, (char *) *plParam); if (hashEntryPtr != NULL) { int i, len, underline; Tcl_Obj *labelPtr; Tcl_UniChar *wlabel, menuChar; *plResult = 0; menuPtr = Tcl_GetHashValue(hashEntryPtr); /* * Assume we have something directly convertable to Tcl_UniChar. * True at least for wide systems. */ menuChar = Tcl_UniCharToUpper((Tcl_UniChar) LOWORD(*pwParam)); for (i = 0; i < menuPtr->numEntries; i++) { |
︙ | ︙ | |||
1275 1276 1277 1278 1279 1280 1281 | } } else { menuPtr = NULL; if (*plParam != 0) { hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, (char *) *plParam); if (hashEntryPtr != NULL) { | | | < | | 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 | } } else { menuPtr = NULL; if (*plParam != 0) { hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, (char *) *plParam); if (hashEntryPtr != NULL) { menuPtr = Tcl_GetHashValue(hashEntryPtr); } } if (menuPtr != NULL) { long entryIndex = LOWORD(*pwParam); mePtr = NULL; if (flags != 0xFFFF) { if ((flags&MF_POPUP) && (entryIndex<menuPtr->numEntries)) { mePtr = menuPtr->entries[entryIndex]; } else { hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->commandTable, INT2PTR(entryIndex)); if (hashEntryPtr != NULL) { mePtr = Tcl_GetHashValue(hashEntryPtr); } } } if ((mePtr == NULL) || (mePtr->state == ENTRY_DISABLED)) { TkActivateMenuEntry(menuPtr, -1); } else { |
︙ | ︙ | |||
1380 1381 1382 1383 1384 1385 1386 | void TkpSetWindowMenuBar( Tk_Window tkwin, /* The window we are putting the menubar * into.*/ TkMenu *menuPtr) /* The menu we are inserting */ { HMENU winMenuHdl; | | < < | < | 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 | void TkpSetWindowMenuBar( Tk_Window tkwin, /* The window we are putting the menubar * into.*/ TkMenu *menuPtr) /* The menu we are inserting */ { HMENU winMenuHdl; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (menuPtr != NULL) { Tcl_HashEntry *hashEntryPtr; int newEntry; winMenuHdl = (HMENU) menuPtr->platformData; hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, (char *) winMenuHdl); Tcl_DeleteHashEntry(hashEntryPtr); DestroyMenu(winMenuHdl); winMenuHdl = CreateMenu(); hashEntryPtr = Tcl_CreateHashEntry(&tsdPtr->winMenuTable, (char *) winMenuHdl, &newEntry); Tcl_SetHashValue(hashEntryPtr, menuPtr); menuPtr->platformData = (TkMenuPlatformData) winMenuHdl; TkWinSetMenu(tkwin, winMenuHdl); ScheduleMenuReconfigure(menuPtr); } else { TkWinSetMenu(tkwin, NULL); } } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
1780 1781 1782 1783 1784 1785 1786 | if (TkWinGetPlatformTheme() == TK_THEME_WIN_CLASSIC) { if ((mePtr->state == ENTRY_DISABLED) && (menuPtr->disabledFgPtr != NULL) && (accel != NULL)) { COLORREF oldFgColor = gc->foreground; gc->foreground = GetSysColor(COLOR_3DHILIGHT); | | | 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 | if (TkWinGetPlatformTheme() == TK_THEME_WIN_CLASSIC) { if ((mePtr->state == ENTRY_DISABLED) && (menuPtr->disabledFgPtr != NULL) && (accel != NULL)) { COLORREF oldFgColor = gc->foreground; gc->foreground = GetSysColor(COLOR_3DHILIGHT); if (!(mePtr->entryFlags & ENTRY_PLATFORM_FLAG1)) { Tk_DrawChars(menuPtr->display, d, gc, tkfont, accel, mePtr->accelLength, leftEdge + 1, baseline + 1); } gc->foreground = oldFgColor; } } |
︙ | ︙ | |||
1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 | */ if (mePtr->entryFlags & ENTRY_PLATFORM_FLAG1) { XColor *activeBgColor = Tk_3DBorderColor(Tk_Get3DBorderFromObj( mePtr->menuPtr->tkwin, (mePtr->activeBorderPtr == NULL) ? mePtr->menuPtr->activeBorderPtr : mePtr->activeBorderPtr)); gc->background = activeBgColor->pixel; } gc->foreground = GetSysColor((mePtr->state == ENTRY_DISABLED) ? COLOR_GRAYTEXT : ((mePtr->state == ENTRY_ACTIVE) ? COLOR_HIGHLIGHTTEXT : COLOR_MENUTEXT)); | > | 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 | */ if (mePtr->entryFlags & ENTRY_PLATFORM_FLAG1) { XColor *activeBgColor = Tk_3DBorderColor(Tk_Get3DBorderFromObj( mePtr->menuPtr->tkwin, (mePtr->activeBorderPtr == NULL) ? mePtr->menuPtr->activeBorderPtr : mePtr->activeBorderPtr)); gc->background = activeBgColor->pixel; } gc->foreground = GetSysColor((mePtr->state == ENTRY_DISABLED) ? COLOR_GRAYTEXT : ((mePtr->state == ENTRY_ACTIVE) ? COLOR_HIGHLIGHTTEXT : COLOR_MENUTEXT)); |
︙ | ︙ | |||
2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 | */ if (mePtr->image != NULL) { Tk_SizeOfImage(mePtr->image, &imageWidth, &imageHeight); haveImage = 1; } else if (mePtr->bitmapPtr != NULL) { Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr); Tk_SizeOfBitmap(menuPtr->display, bitmap, &imageWidth, &imageHeight); haveImage = 1; } if (!haveImage || (mePtr->compound != COMPOUND_NONE)) { if (mePtr->labelLength > 0) { const char *label = Tcl_GetString(mePtr->labelPtr); | > | 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 | */ if (mePtr->image != NULL) { Tk_SizeOfImage(mePtr->image, &imageWidth, &imageHeight); haveImage = 1; } else if (mePtr->bitmapPtr != NULL) { Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr); Tk_SizeOfBitmap(menuPtr->display, bitmap, &imageWidth, &imageHeight); haveImage = 1; } if (!haveImage || (mePtr->compound != COMPOUND_NONE)) { if (mePtr->labelLength > 0) { const char *label = Tcl_GetString(mePtr->labelPtr); |
︙ | ︙ | |||
2312 2313 2314 2315 2316 2317 2318 | if (TkWinGetPlatformTheme() == TK_THEME_WIN_CLASSIC) { /* * Win 95/98 systems draw disabled menu text with a 3D * highlight, unless the menu item is highlighted, */ if ((mePtr->state == ENTRY_DISABLED) && | | > | 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 | if (TkWinGetPlatformTheme() == TK_THEME_WIN_CLASSIC) { /* * Win 95/98 systems draw disabled menu text with a 3D * highlight, unless the menu item is highlighted, */ if ((mePtr->state == ENTRY_DISABLED) && !(mePtr->entryFlags & ENTRY_PLATFORM_FLAG1)) { COLORREF oldFgColor = gc->foreground; gc->foreground = GetSysColor(COLOR_3DHILIGHT); Tk_DrawChars(menuPtr->display, d, gc, tkfont, label, mePtr->labelLength, leftEdge + textXOffset + 1, baseline + textYOffset + 1); gc->foreground = oldFgColor; } } |
︙ | ︙ | |||
2446 2447 2448 2449 2450 2451 2452 | */ int TkpConfigureMenuEntry( register TkMenuEntry *mePtr)/* Information about menu entry; may or may * not already have values for some fields. */ { | | < < < < < | 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 | */ int TkpConfigureMenuEntry( register TkMenuEntry *mePtr)/* Information about menu entry; may or may * not already have values for some fields. */ { ScheduleMenuReconfigure(mePtr->menuPtr); return TCL_OK; } /* *---------------------------------------------------------------------- * * TkpDrawMenuEntry -- |
︙ | ︙ | |||
2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 | int haveImage = 0; if (mePtr->image != NULL) { Tk_SizeOfImage(mePtr->image, widthPtr, heightPtr); haveImage = 1; } else if (mePtr->bitmapPtr != NULL) { Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr); Tk_SizeOfBitmap(menuPtr->display, bitmap, widthPtr, heightPtr); haveImage = 1; } else { *heightPtr = 0; *widthPtr = 0; } | > | 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 | int haveImage = 0; if (mePtr->image != NULL) { Tk_SizeOfImage(mePtr->image, widthPtr, heightPtr); haveImage = 1; } else if (mePtr->bitmapPtr != NULL) { Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr); Tk_SizeOfBitmap(menuPtr->display, bitmap, widthPtr, heightPtr); haveImage = 1; } else { *heightPtr = 0; *widthPtr = 0; } |
︙ | ︙ | |||
3025 3026 3027 3028 3029 3030 3031 | TkMenu *menuPtr; if ((menuName != NULL) && (menuName[0] != '\0')) { menuRefPtr = TkFindMenuReferences(interp, menuName); if ((menuRefPtr != NULL) && (menuRefPtr->menuPtr != NULL)) { for (menuPtr = menuRefPtr->menuPtr->masterMenuPtr; menuPtr != NULL; menuPtr = menuPtr->nextInstancePtr) { | | < < < | | 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 | TkMenu *menuPtr; if ((menuName != NULL) && (menuName[0] != '\0')) { menuRefPtr = TkFindMenuReferences(interp, menuName); if ((menuRefPtr != NULL) && (menuRefPtr->menuPtr != NULL)) { for (menuPtr = menuRefPtr->menuPtr->masterMenuPtr; menuPtr != NULL; menuPtr = menuPtr->nextInstancePtr) { if (menuPtr->menuType == MENUBAR) { ScheduleMenuReconfigure(menuPtr); } } } } } /* |
︙ | ︙ | |||
3059 3060 3061 3062 3063 3064 3065 | *---------------------------------------------------------------------- */ HWND Tk_GetMenuHWND( Tk_Window tkwin) { | | > | 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 | *---------------------------------------------------------------------- */ HWND Tk_GetMenuHWND( Tk_Window tkwin) { ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); TkMenuInit(); return tsdPtr->embeddedMenuHWND; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
3110 3111 3112 3113 3114 3115 3116 | *---------------------------------------------------------------------- */ static void MenuThreadExitHandler( ClientData clientData) /* Not used */ { | | | 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 | *---------------------------------------------------------------------- */ static void MenuThreadExitHandler( ClientData clientData) /* Not used */ { ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); DestroyWindow(tsdPtr->menuHWND); DestroyWindow(tsdPtr->embeddedMenuHWND); tsdPtr->menuHWND = NULL; tsdPtr->embeddedMenuHWND = NULL; |
︙ | ︙ | |||
3328 3329 3330 3331 3332 3333 3334 | wndClass.lpfnWndProc = TkWinEmbeddedMenuProc; wndClass.lpszClassName = EMBEDDED_MENU_CLASS_NAME; if (!RegisterClass(&wndClass)) { Tcl_Panic("Failed to register embedded menu window class"); } | | | 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 | wndClass.lpfnWndProc = TkWinEmbeddedMenuProc; wndClass.lpszClassName = EMBEDDED_MENU_CLASS_NAME; if (!RegisterClass(&wndClass)) { Tcl_Panic("Failed to register embedded menu window class"); } TkCreateExitHandler(MenuExitHandler, NULL); SetDefaults(1); } /* *---------------------------------------------------------------------- * * TkpMenuThreadInit -- |
︙ | ︙ | |||
3352 3353 3354 3355 3356 3357 3358 | * *---------------------------------------------------------------------- */ void TkpMenuThreadInit(void) { | | | | 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 | * *---------------------------------------------------------------------- */ void TkpMenuThreadInit(void) { ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); tsdPtr->menuHWND = CreateWindow(MENU_CLASS_NAME, TEXT("MenuWindow"), WS_POPUP, 0, 0, 10, 10, NULL, NULL, Tk_GetHINSTANCE(), NULL); if (!tsdPtr->menuHWND) { Tcl_Panic("Failed to create the menu window"); } tsdPtr->embeddedMenuHWND = CreateWindow(EMBEDDED_MENU_CLASS_NAME, TEXT("EmbeddedMenuWindow"), WS_POPUP, 0, 0, 10, 10, NULL, NULL, Tk_GetHINSTANCE(), NULL); if (!tsdPtr->embeddedMenuHWND) { Tcl_Panic("Failed to create the embedded menu window"); } Tcl_InitHashTable(&tsdPtr->winMenuTable, TCL_ONE_WORD_KEYS); Tcl_InitHashTable(&tsdPtr->commandTable, TCL_ONE_WORD_KEYS); TkCreateThreadExitHandler(MenuThreadExitHandler, NULL); } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to win/tkWinSend.c.
|
| | | 1 2 3 4 5 6 7 8 | `/* * tkWinSend.c -- * * This file provides functions that implement the "send" command, * allowing commands to be passed from interpreter to interpreter. * * Copyright (c) 1997 by Sun Microsystems, Inc. * Copyright (c) 2003 Pat Thoyts <[email protected]> |
︙ | ︙ | |||
51 52 53 54 55 56 57 | } SendEvent; #ifdef TK_SEND_ENABLED_ON_WINDOWS typedef struct { int initialized; } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; | | | | | | 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | } SendEvent; #ifdef TK_SEND_ENABLED_ON_WINDOWS typedef struct { int initialized; } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; #endif /* TK_SEND_ENABLED_ON_WINDOWS */ /* * Functions internal to this file. */ #ifdef TK_SEND_ENABLED_ON_WINDOWS static void CmdDeleteProc(ClientData clientData); static void InterpDeleteProc(ClientData clientData, Tcl_Interp *interp); static void RevokeObjectRegistration(RegisteredInterp *riPtr); #endif /* TK_SEND_ENABLED_ON_WINDOWS */ static HRESULT BuildMoniker(const char *name, LPMONIKER *pmk); #ifdef TK_SEND_ENABLED_ON_WINDOWS static HRESULT RegisterInterp(const char *name, RegisteredInterp *riPtr); #endif /* TK_SEND_ENABLED_ON_WINDOWS */ static int FindInterpreterObject(Tcl_Interp *interp, const char *name, LPDISPATCH *ppdisp); static int Send(LPDISPATCH pdispInterp, Tcl_Interp *interp, int async, ClientData clientData, int objc, Tcl_Obj *const objv[]); static Tcl_Obj * Win32ErrorObj(HRESULT hrError); static void SendTrace(const char *format, ...); static Tcl_EventProc SendEventProc; #if defined(DEBUG) || defined(_DEBUG) #define TRACE SendTrace #else #define TRACE 1 ? ((void)0) : SendTrace #endif /* DEBUG || _DEBUG */ /* *-------------------------------------------------------------- * * Tk_SetAppName -- * * This function is called to associate an ASCII name with a Tk |
︙ | ︙ | |||
132 133 134 135 136 137 138 | ThreadSpecificData *tsdPtr = NULL; TkWindow *winPtr = (TkWindow *) tkwin; RegisteredInterp *riPtr = NULL; Tcl_Interp *interp; HRESULT hr = S_OK; interp = winPtr->mainPtr->interp; | < < | | | > | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | ThreadSpecificData *tsdPtr = NULL; TkWindow *winPtr = (TkWindow *) tkwin; RegisteredInterp *riPtr = NULL; Tcl_Interp *interp; HRESULT hr = S_OK; interp = winPtr->mainPtr->interp; tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * Initialise the COM library for this interpreter just once. */ if (tsdPtr->initialized == 0) { hr = CoInitialize(0); if (FAILED(hr)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "failed to initialize the COM library", -1)); Tcl_SetErrorcode(interp, "TK", "SEND", "COM", NULL); return ""; } tsdPtr->initialized = 1; TRACE("Initialized COM library for interp 0x%08X\n", (long)interp); } /* |
︙ | ︙ | |||
359 360 361 362 363 364 365 | } /* * We don't support displayPtr. See TIP #150. */ if (displayPtr) { | > | | > | 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | } /* * We don't support displayPtr. See TIP #150. */ if (displayPtr) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "option not implemented: \"displayof\" is not available" " for this platform.", -1)); Tcl_SetErrorcode(interp, "TK", "SEND", "DISPLAYOF_WIN", NULL); result = TCL_ERROR; } /* * Send the arguments to the foreign interp. */ /* FIX ME: we need to check for local interp */ |
︙ | ︙ | |||
432 433 434 435 436 437 438 | &IID_IUnknown, (void **) ppUnkInterp); if (SUCCEEDED(hr)) { hr = pUnkInterp->lpVtbl->QueryInterface(pUnkInterp, &IID_IDispatch, (void **) ppdisp); pUnkInterp->lpVtbl->Release(pUnkInterp); } else { | < | | > > | 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | &IID_IUnknown, (void **) ppUnkInterp); if (SUCCEEDED(hr)) { hr = pUnkInterp->lpVtbl->QueryInterface(pUnkInterp, &IID_IDispatch, (void **) ppdisp); pUnkInterp->lpVtbl->Release(pUnkInterp); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "no application named \"%s\"", name)); Tcl_SetErrorcode(interp, "TK", "LOOKUP", "APPLICATION", NULL); result = TCL_ERROR; } pmk->lpVtbl->Release(pmk); } pBindCtx->lpVtbl->Release(pBindCtx); } |
︙ | ︙ | |||
549 550 551 552 553 554 555 | */ if (riPtr->name != NULL) { free(riPtr->name); riPtr->name = NULL; } } | | | 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | */ if (riPtr->name != NULL) { free(riPtr->name); riPtr->name = NULL; } } #endif /* TK_SEND_ENABLED_ON_WINDOWS */ /* * ---------------------------------------------------------------------- * * InterpDeleteProc -- * * This is called when the interpreter is deleted and used to unregister |
︙ | ︙ | |||
576 577 578 579 580 581 582 | static void InterpDeleteProc( ClientData clientData, Tcl_Interp *interp) { CoUninitialize(); } | | | 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 | static void InterpDeleteProc( ClientData clientData, Tcl_Interp *interp) { CoUninitialize(); } #endif /* TK_SEND_ENABLED_ON_WINDOWS */ /* * ---------------------------------------------------------------------- * * BuildMoniker -- * * Construct a moniker from the given name. This ensures that all our |
︙ | ︙ | |||
697 698 699 700 701 702 703 | if (SUCCEEDED(hr)) { riPtr->name = strdup(actualName); } Tcl_DStringFree(&dString); return hr; } | | | 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 | if (SUCCEEDED(hr)) { riPtr->name = strdup(actualName); } Tcl_DStringFree(&dString); return hr; } #endif /* TK_SEND_ENABLED_ON_WINDOWS */ /* * ---------------------------------------------------------------------- * * Send -- * * Perform an interface call to the server object. We convert the Tcl |
︙ | ︙ | |||
778 779 780 781 782 783 784 | /* * Errors are returned as dispatch exceptions. If an error code was * returned then we decode the exception and setup the Tcl error * variables. */ | | < < < < | | | < | < | < | 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 | /* * Errors are returned as dispatch exceptions. If an error code was * returned then we decode the exception and setup the Tcl error * variables. */ if (hr == DISP_E_EXCEPTION && ei.bstrSource != NULL) { Tcl_Obj *opError, *opErrorCode, *opErrorInfo; opError = Tcl_NewUnicodeObj(ei.bstrSource, -1); Tcl_ListObjIndex(interp, opError, 0, &opErrorCode); Tcl_SetObjErrorCode(interp, opErrorCode); Tcl_ListObjIndex(interp, opError, 1, &opErrorInfo); Tcl_AppendObjToErrorInfo(interp, opErrorInfo); } /* * Clean up any COM allocated resources. */ SysFreeString(ei.bstrDescription); |
︙ | ︙ | |||
848 849 850 851 852 853 854 | *p = TEXT('\0'); } #ifdef _UNICODE errPtr = Tcl_NewUnicodeObj(lpBuffer, (int)wcslen(lpBuffer)); #else errPtr = Tcl_NewStringObj(lpBuffer, (int)strlen(lpBuffer)); | | | | | < | | | | > > > > | | | > > > | | < | < < < | > | | > | | | > > > | | < | | < | | | | | < < | 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 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 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 930 | *p = TEXT('\0'); } #ifdef _UNICODE errPtr = Tcl_NewUnicodeObj(lpBuffer, (int)wcslen(lpBuffer)); #else errPtr = Tcl_NewStringObj(lpBuffer, (int)strlen(lpBuffer)); #endif /* _UNICODE */ if (lpBuffer != sBuffer) { LocalFree((HLOCAL)lpBuffer); } return errPtr; } /* * ---------------------------------------------------------------------- * * TkWinSend_SetExcepInfo -- * * Convert the error information from a Tcl interpreter into a COM * exception structure. This information is then registered with the COM * thread exception object so that it can be used for rich error * reporting by COM clients. * * Results: * None. * * Side effects: * The current COM thread has its error object modified. * * ---------------------------------------------------------------------- */ void TkWinSend_SetExcepInfo( Tcl_Interp *interp, EXCEPINFO *pExcepInfo) { Tcl_Obj *opError, *opErrorInfo, *opErrorCode; ICreateErrorInfo *pCEI; IErrorInfo *pEI, **ppEI = &pEI; HRESULT hr; if (!pExcepInfo) { return; } opError = Tcl_GetObjResult(interp); opErrorInfo = Tcl_GetVar2Ex(interp, "errorInfo", NULL, TCL_GLOBAL_ONLY); opErrorCode = Tcl_GetVar2Ex(interp, "errorCode", NULL, TCL_GLOBAL_ONLY); /* * Pack the trace onto the end of the Tcl exception descriptor. */ opErrorCode = Tcl_DuplicateObj(opErrorCode); Tcl_IncrRefCount(opErrorCode); Tcl_ListObjAppendElement(interp, opErrorCode, opErrorInfo); /* TODO: Handle failure to append */ pExcepInfo->bstrDescription = SysAllocString(Tcl_GetUnicode(opError)); pExcepInfo->bstrSource = SysAllocString(Tcl_GetUnicode(opErrorCode)); Tcl_DecrRefCount(opErrorCode); pExcepInfo->scode = E_FAIL; hr = CreateErrorInfo(&pCEI); if (!SUCCEEDED(hr)) { return; } hr = pCEI->lpVtbl->SetGUID(pCEI, &IID_IDispatch); hr = pCEI->lpVtbl->SetDescription(pCEI, pExcepInfo->bstrDescription); hr = pCEI->lpVtbl->SetSource(pCEI, pExcepInfo->bstrSource); hr = pCEI->lpVtbl->QueryInterface(pCEI, &IID_IErrorInfo, (void **) ppEI); if (SUCCEEDED(hr)) { SetErrorInfo(0, pEI); pEI->lpVtbl->Release(pEI); } pCEI->lpVtbl->Release(pCEI); } /* * ---------------------------------------------------------------------- * * TkWinSend_QueueCommand -- * |
︙ | ︙ |
Changes to win/tkWinSendCom.c.
︙ | ︙ | |||
96 97 98 99 100 101 102 | }; static ISupportErrorInfoVtbl vtbl2 = { ISupportErrorInfo_QueryInterface, ISupportErrorInfo_AddRef, ISupportErrorInfo_Release, ISupportErrorInfo_InterfaceSupportsErrorInfo, }; | < | > | | | | | | | | | < < < | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | }; static ISupportErrorInfoVtbl vtbl2 = { ISupportErrorInfo_QueryInterface, ISupportErrorInfo_AddRef, ISupportErrorInfo_Release, ISupportErrorInfo_InterfaceSupportsErrorInfo, }; TkWinSendCom *obj = NULL; /* * This had probably better always be globally visible memory so we shall * use the COM Task allocator. */ obj = (TkWinSendCom *) CoTaskMemAlloc(sizeof(TkWinSendCom)); if (obj == NULL) { *ppv = NULL; return E_OUTOFMEMORY; } obj->lpVtbl = &vtbl; obj->lpVtbl2 = &vtbl2; obj->refcount = 0; obj->interp = interp; /* * lock the interp? Tcl_AddRef/Retain? */ return obj->lpVtbl->QueryInterface((IDispatch *) obj, riid, ppv); } /* * ---------------------------------------------------------------------- * * TkWinSendCom_Destroy -- * |
︙ | ︙ | |||
143 144 145 146 147 148 149 | * * ---------------------------------------------------------------------- */ static void TkWinSendCom_Destroy( LPDISPATCH pdisp) { | | | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | * * ---------------------------------------------------------------------- */ static void TkWinSendCom_Destroy( LPDISPATCH pdisp) { CoTaskMemFree((void *) pdisp); } /* * ---------------------------------------------------------------------- * * IDispatch -- * |
︙ | ︙ | |||
165 166 167 168 169 170 171 | static STDMETHODIMP WinSendCom_QueryInterface( IDispatch *This, REFIID riid, void **ppvObject) { HRESULT hr = E_NOINTERFACE; | | | | | | 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 | static STDMETHODIMP WinSendCom_QueryInterface( IDispatch *This, REFIID riid, void **ppvObject) { HRESULT hr = E_NOINTERFACE; TkWinSendCom *this = (TkWinSendCom *) This; *ppvObject = NULL; if (memcmp(riid, &IID_IUnknown, sizeof(IID)) == 0 || memcmp(riid, &IID_IDispatch, sizeof(IID)) == 0) { *ppvObject = (void **) this; this->lpVtbl->AddRef(This); hr = S_OK; } else if (memcmp(riid, &IID_ISupportErrorInfo, sizeof(IID)) == 0) { *ppvObject = (void **) (this + 1); this->lpVtbl2->AddRef((ISupportErrorInfo *) (this + 1)); hr = S_OK; } return hr; } static STDMETHODIMP_(ULONG) WinSendCom_AddRef( |
︙ | ︙ | |||
312 313 314 315 316 317 318 | static STDMETHODIMP ISupportErrorInfo_QueryInterface( ISupportErrorInfo *This, REFIID riid, void **ppvObject) { | | | | | | | 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 | static STDMETHODIMP ISupportErrorInfo_QueryInterface( ISupportErrorInfo *This, REFIID riid, void **ppvObject) { TkWinSendCom *this = (TkWinSendCom *)(This - 1); return this->lpVtbl->QueryInterface((IDispatch *) this, riid, ppvObject); } static STDMETHODIMP_(ULONG) ISupportErrorInfo_AddRef( ISupportErrorInfo *This) { TkWinSendCom *this = (TkWinSendCom *)(This - 1); return InterlockedIncrement(&this->refcount); } static STDMETHODIMP_(ULONG) ISupportErrorInfo_Release( ISupportErrorInfo *This) { TkWinSendCom *this = (TkWinSendCom *)(This - 1); return this->lpVtbl->Release((IDispatch *) this); } static STDMETHODIMP ISupportErrorInfo_InterfaceSupportsErrorInfo( ISupportErrorInfo *This, REFIID riid) { |
︙ | ︙ | |||
376 377 378 379 380 381 382 | VariantInit(&vCmd); hr = VariantChangeType(&vCmd, &Cmd, 0, VT_BSTR); if (FAILED(hr)) { Tcl_SetObjResult(obj->interp, Tcl_NewStringObj( "invalid args: Async(command)", -1)); | | | < | | | < | 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | VariantInit(&vCmd); hr = VariantChangeType(&vCmd, &Cmd, 0, VT_BSTR); if (FAILED(hr)) { Tcl_SetObjResult(obj->interp, Tcl_NewStringObj( "invalid args: Async(command)", -1)); TkWinSend_SetExcepInfo(obj->interp, pExcepInfo); hr = DISP_E_EXCEPTION; } if (SUCCEEDED(hr) && obj->interp) { Tcl_Obj *scriptPtr = Tcl_NewUnicodeObj(vCmd.bstrVal, (int) SysStringLen(vCmd.bstrVal)); TkWinSend_QueueCommand(obj->interp, scriptPtr); } VariantClear(&vCmd); return hr; } /* |
︙ | ︙ | |||
423 424 425 426 427 428 429 430 431 432 | VARIANT *pvResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { HRESULT hr = S_OK; int result = TCL_OK; VARIANT v; VariantInit(&v); hr = VariantChangeType(&v, &vCmd, 0, VT_BSTR); | > > > > > | > > | | | | | | > | | | | | | | | | | < > | < | 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 | VARIANT *pvResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { HRESULT hr = S_OK; int result = TCL_OK; VARIANT v; register Tcl_Interp *interp = obj->interp; Tcl_Obj *scriptPtr; if (interp == NULL) { return S_OK; } VariantInit(&v); hr = VariantChangeType(&v, &vCmd, 0, VT_BSTR); if (!SUCCEEDED(hr)) { return hr; } scriptPtr = Tcl_NewUnicodeObj(v.bstrVal, (int) SysStringLen(v.bstrVal)); Tcl_Preserve(interp); Tcl_IncrRefCount(scriptPtr); result = Tcl_EvalObjEx(interp, scriptPtr, TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL); Tcl_DecrRefCount(scriptPtr); if (pvResult != NULL) { VariantInit(pvResult); pvResult->vt = VT_BSTR; pvResult->bstrVal = SysAllocString(Tcl_GetUnicode( Tcl_GetObjResult(interp))); } if (result == TCL_ERROR) { hr = DISP_E_EXCEPTION; TkWinSend_SetExcepInfo(interp, pExcepInfo); } Tcl_Release(interp); VariantClear(&v); return hr; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to win/tkWinSendCom.h.
︙ | ︙ | |||
41 42 43 44 45 46 47 | #define TKWINSENDCOM_DISPID_SEND 1 #define TKWINSENDCOM_DISPID_ASYNC 2 /* * TkWinSendCom public functions */ | | | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #define TKWINSENDCOM_DISPID_SEND 1 #define TKWINSENDCOM_DISPID_ASYNC 2 /* * TkWinSendCom public functions */ MODULE_SCOPE HRESULT TkWinSendCom_CreateInstance(Tcl_Interp *interp, REFIID riid, void **ppv); MODULE_SCOPE int TkWinSend_QueueCommand(Tcl_Interp *interp, Tcl_Obj *cmdPtr); MODULE_SCOPE void TkWinSend_SetExcepInfo(Tcl_Interp *interp, EXCEPINFO *pExcepInfo); #endif /* _tkWinSendCom_h_INCLUDE */ /* * Local Variables: * mode: c |
︙ | ︙ |
Changes to win/tkWinWm.c.
︙ | ︙ | |||
70 71 72 73 74 75 76 | /* * Helper type passed via lParam to TkWmStackorderToplevelEnumProc */ typedef struct TkWmStackorderToplevelPair { Tcl_HashTable *table; | | | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | /* * Helper type passed via lParam to TkWmStackorderToplevelEnumProc */ typedef struct TkWmStackorderToplevelPair { Tcl_HashTable *table; TkWindow **windowPtr; } TkWmStackorderToplevelPair; /* * This structure represents the contents of a icon, in terms of its image. * The HICON is an internal Windows format. Most of these icon-specific * structures originated with the Winico extension. We stripped out unused * parts of that code, and integrated the code more naturally with Tcl. |
︙ | ︙ | |||
968 969 970 971 972 973 974 | if (tkw == NULL) { tkw = Tk_MainWindow(interp); application = 1; } if (!(Tk_IsTopLevel(tkw))) { | | | > > | 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | if (tkw == NULL) { tkw = Tk_MainWindow(interp); application = 1; } if (!(Tk_IsTopLevel(tkw))) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't a top-level window", Tk_PathName(tkw))); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TOPLEVEL", Tk_PathName(tkw), NULL); return TCL_ERROR; } if (Tk_WindowId(tkw) == None) { Tk_MakeWindowExist(tkw); } /* |
︙ | ︙ | |||
1002 1003 1004 1005 1006 1007 1008 | * If we aren't initialised, then just initialise with the user's * icon. Otherwise our icon choice will be ignored moments later when * Tk finishes initialising. */ if (!initialized) { if (InitWindowClass(titlebaricon) != TCL_OK) { | > | > | 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 | * If we aren't initialised, then just initialise with the user's * icon. Otherwise our icon choice will be ignored moments later when * Tk finishes initialising. */ if (!initialized) { if (InitWindowClass(titlebaricon) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Unable to set icon", -1)); Tcl_SetErrorCode(interp, "TK", "WM", "ICON", "FAILED", NULL); return TCL_ERROR; } } else { ThreadSpecificData *tsdPtr; /* * Don't check return result of SetClassLong() or |
︙ | ︙ | |||
1057 1058 1059 1060 1061 1062 1063 | * should probably be placed in one proper location. */ UpdateWrapper(wmPtr->winPtr); wmPtr = ((TkWindow *) tkw)->wmInfoPtr; hwnd = wmPtr->wrapper; if (hwnd == NULL) { | | | > | 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 | * should probably be placed in one proper location. */ UpdateWrapper(wmPtr->winPtr); wmPtr = ((TkWindow *) tkw)->wmInfoPtr; hwnd = wmPtr->wrapper; if (hwnd == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Can't set icon; window has no wrapper.", -1)); Tcl_SetErrorCode(interp, "TK", "WM", "ICON", "WRAPPER", NULL); return TCL_ERROR; } } SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM) GetIcon(titlebaricon, ICON_SMALL)); SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM) GetIcon(titlebaricon, ICON_BIG)); |
︙ | ︙ | |||
1571 1572 1573 1574 1575 1576 1577 | /* * Open the file. */ channel = Tcl_FSOpenFileChannel(interp, fileName, "r", 0); if (channel == NULL) { | > | | | 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 | /* * Open the file. */ channel = Tcl_FSOpenFileChannel(interp, fileName, "r", 0); if (channel == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error opening file \"%s\" for reading: %s", Tcl_GetString(fileName), Tcl_PosixError(interp))); return NULL; } if (Tcl_SetChannelOption(interp, channel, "-translation", "binary") != TCL_OK) { Tcl_Close(NULL, channel); return NULL; } |
︙ | ︙ | |||
1598 1599 1600 1601 1602 1603 1604 | /* * Read in the header */ lpIR->nNumImages = ReadICOHeader(channel); if (lpIR->nNumImages == -1) { | | | 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 | /* * Read in the header */ lpIR->nNumImages = ReadICOHeader(channel); if (lpIR->nNumImages == -1) { Tcl_SetObjResult(interp, Tcl_NewStringObj("Invalid file header", -1)); Tcl_Close(NULL, channel); ckfree(lpIR); return NULL; } /* * Adjust the size of the struct to account for the images. |
︙ | ︙ | |||
1624 1625 1626 1627 1628 1629 1630 | /* * Read in the icon directory entries. */ dwBytesRead = Tcl_Read(channel, (char *) lpIDE, (int) (lpIR->nNumImages * sizeof(ICONDIRENTRY))); if (dwBytesRead != lpIR->nNumImages * sizeof(ICONDIRENTRY)) { | > | > | 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 | /* * Read in the icon directory entries. */ dwBytesRead = Tcl_Read(channel, (char *) lpIDE, (int) (lpIR->nNumImages * sizeof(ICONDIRENTRY))); if (dwBytesRead != lpIR->nNumImages * sizeof(ICONDIRENTRY)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error reading file: %s", Tcl_PosixError(interp))); Tcl_SetErrorCode(interp, "TK", "WM", "ICON", "READ", NULL); Tcl_Close(NULL, channel); ckfree(lpIDE); ckfree(lpIR); return NULL; } /* |
︙ | ︙ | |||
1656 1657 1658 1659 1660 1661 1662 | lpIR->IconImages[i].dwNumBytes = lpIDE[i].dwBytesInRes; /* * Seek to beginning of this image. */ if (Tcl_Seek(channel, lpIDE[i].dwImageOffset, FILE_BEGIN) == -1) { | > | > | > | | < < < < < | 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 | lpIR->IconImages[i].dwNumBytes = lpIDE[i].dwBytesInRes; /* * Seek to beginning of this image. */ if (Tcl_Seek(channel, lpIDE[i].dwImageOffset, FILE_BEGIN) == -1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error seeking in file: %s", Tcl_PosixError(interp))); goto readError; } /* * Read it in. */ dwBytesRead = Tcl_Read(channel, (char *)lpIR->IconImages[i].lpBits, (int) lpIDE[i].dwBytesInRes); if (dwBytesRead != lpIDE[i].dwBytesInRes) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error reading file: ", Tcl_PosixError(interp))); goto readError; } /* * Set the internal pointers appropriately. */ if (!AdjustIconImagePointers(&lpIR->IconImages[i])) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Error converting to internal format", -1)); Tcl_SetErrorCode(interp, "TK", "WM", "ICON", "FORMAT", NULL); goto readError; } lpIR->IconImages[i].hIcon = MakeIconOrCursorFromResource(&lpIR->IconImages[i], isIcon); } /* * Clean up */ ckfree(lpIDE); Tcl_Close(NULL, channel); return lpIR; readError: Tcl_Close(NULL, channel); for (i = 0; i < lpIR->nNumImages; i++) { if (lpIR->IconImages[i].lpBits != NULL) { ckfree(lpIR->IconImages[i].lpBits); |
︙ | ︙ | |||
2813 2814 2815 2816 2817 2818 2819 | int wmTracing; if ((objc != 2) && (objc != 3)) { Tcl_WrongNumArgs(interp, 2, objv, "?boolean?"); return TCL_ERROR; } if (objc == 2) { | | | < | 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 | int wmTracing; if ((objc != 2) && (objc != 3)) { Tcl_WrongNumArgs(interp, 2, objv, "?boolean?"); return TCL_ERROR; } if (objc == 2) { Tcl_SetObjResult(interp, Tcl_NewBooleanObj( dispPtr->flags & TK_DISPLAY_WM_TRACING)); return TCL_OK; } if (Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing) != TCL_OK) { return TCL_ERROR; } if (wmTracing) { dispPtr->flags |= TK_DISPLAY_WM_TRACING; |
︙ | ︙ | |||
2844 2845 2846 2847 2848 2849 2850 | if (TkGetWindowFromObj(interp, tkwin, objv[2], (Tk_Window *) winPtrPtr) != TCL_OK) { return TCL_ERROR; } if (!Tk_IsTopLevel(winPtr) && (index != WMOPT_MANAGE) && (index != WMOPT_FORGET)) { | | | > > | 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 | if (TkGetWindowFromObj(interp, tkwin, objv[2], (Tk_Window *) winPtrPtr) != TCL_OK) { return TCL_ERROR; } if (!Tk_IsTopLevel(winPtr) && (index != WMOPT_MANAGE) && (index != WMOPT_FORGET)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't a top-level window", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TOPLEVEL", winPtr->pathName, NULL); return TCL_ERROR; } switch ((enum options) index) { case WMOPT_ASPECT: return WmAspectCmd(tkwin, winPtr, interp, objc, objv); case WMOPT_ATTRIBUTES: |
︙ | ︙ | |||
2955 2956 2957 2958 2959 2960 2961 | if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?minNumer minDenom maxNumer maxDenom?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & PAspect) { | > | | > | > > > | > | 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 | if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?minNumer minDenom maxNumer maxDenom?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & PAspect) { Tcl_Obj *results[4]; results[0] = Tcl_NewIntObj(wmPtr->minAspect.x); results[1] = Tcl_NewIntObj(wmPtr->minAspect.y); results[2] = Tcl_NewIntObj(wmPtr->maxAspect.x); results[3] = Tcl_NewIntObj(wmPtr->maxAspect.y); Tcl_SetObjResult(interp, Tcl_NewListObj(4, results)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->sizeHintsFlags &= ~PAspect; } else { if ((Tcl_GetIntFromObj(interp, objv[3], &numer1) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &denom1) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[5], &numer2) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[6], &denom2) != TCL_OK)) { return TCL_ERROR; } if ((numer1 <= 0) || (denom1 <= 0) || (numer2 <= 0) || (denom2 <= 0)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "aspect number can't be <= 0", -1)); Tcl_SetErrorCode(interp, "TK", "VALUE", "ASPECT", NULL); return TCL_ERROR; } wmPtr->minAspect.x = numer1; wmPtr->minAspect.y = denom1; wmPtr->maxAspect.x = numer2; wmPtr->maxAspect.y = denom2; wmPtr->sizeHintsFlags |= PAspect; |
︙ | ︙ | |||
3089 3090 3091 3092 3093 3094 3095 | updatewrapper = 1; } } else if ((length > 3) && (strncmp(string, "-topmost", (unsigned) length) == 0)) { stylePtr = &exStyle; styleBit = WS_EX_TOPMOST; if ((i < objc-1) && (winPtr->flags & TK_EMBEDDED)) { | > | | > | 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 | updatewrapper = 1; } } else if ((length > 3) && (strncmp(string, "-topmost", (unsigned) length) == 0)) { stylePtr = &exStyle; styleBit = WS_EX_TOPMOST; if ((i < objc-1) && (winPtr->flags & TK_EMBEDDED)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't set topmost flag on %s: it is an embedded window", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ATTR", "TOPMOST", NULL); return TCL_ERROR; } } else { goto configArgs; } if (styleBit == WS_EX_LAYERED) { if (objc == 4) { |
︙ | ︙ | |||
3245 3246 3247 3248 3249 3250 3251 | UpdateWrapper(winPtr); } } } if (fullscreen_attr_changed) { if (fullscreen_attr) { if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) { | | | | > | | | | | | 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 | UpdateWrapper(winPtr); } } } if (fullscreen_attr_changed) { if (fullscreen_attr) { if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't set fullscreen attribute for \"%s\":" " override-redirect flag is set", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ATTR", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } /* * Check max width and height if set by the user, don't worry * about the default values since they will likely be smaller than * screen width/height. */ if (((wmPtr->maxWidth > 0) && (WidthOfScreen(Tk_Screen(winPtr)) > wmPtr->maxWidth)) || ((wmPtr->maxHeight > 0) && (HeightOfScreen(Tk_Screen(winPtr)) > wmPtr->maxHeight))) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't set fullscreen attribute for \"%s\":" " max width/height is too small", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ATTR", "SMALL_MAX", NULL); return TCL_ERROR; } } TkpWmSetFullScreen(winPtr, fullscreen_attr); } |
︙ | ︙ | |||
3311 3312 3313 3314 3315 3316 3317 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->clientMachine != NULL) { | > | | 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->clientMachine != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->clientMachine, -1)); } return TCL_OK; } argv3 = Tcl_GetStringFromObj(objv[3], &length); if (argv3[0] == 0) { if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); |
︙ | ︙ | |||
3371 3372 3373 3374 3375 3376 3377 | 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; | | < | > > | > | 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 | 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 **cmapList, *winPtr2, **winPtr2Ptr = &winPtr2; int i, windowObjc, gotToplevel; Tcl_Obj **windowObjv, *resultObj; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?windowList?"); return TCL_ERROR; } if (objc == 3) { Tk_MakeWindowExist((Tk_Window) winPtr); resultObj = Tcl_NewObj(); for (i = 0; i < wmPtr->cmapCount; i++) { if ((i == (wmPtr->cmapCount-1)) && (wmPtr->flags & WM_ADDED_TOPLEVEL_COLORMAP)) { break; } Tcl_ListObjAppendElement(NULL, resultObj, TkNewWindowObj((Tk_Window) wmPtr->cmapList[i])); } Tcl_SetObjResult(interp, resultObj); return TCL_OK; } if (Tcl_ListObjGetElements(interp, objv[3], &windowObjc, &windowObjv) != TCL_OK) { return TCL_ERROR; } cmapList = ckalloc((windowObjc + 1) * sizeof(TkWindow*)); |
︙ | ︙ | |||
3473 3474 3475 3476 3477 3478 3479 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?value?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->cmdArgv != NULL) { | | | > > | 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?value?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->cmdArgv != NULL) { char *merged = Tcl_Merge(wmPtr->cmdArgc, wmPtr->cmdArgv); Tcl_SetObjResult(interp, Tcl_NewStringObj(merged, -1)); ckfree(merged); } return TCL_OK; } argv3 = Tcl_GetString(objv[3]); if (argv3[0] == 0) { if (wmPtr->cmdArgv != NULL) { ckfree(wmPtr->cmdArgv); |
︙ | ︙ | |||
3536 3537 3538 3539 3540 3541 3542 | register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { | > | | > | | > > | 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 | register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't deiconify %s: it is an icon for %s", Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "DEICONIFY", "ICON", NULL); return TCL_ERROR; } if (winPtr->flags & TK_EMBEDDED) { if (!SendMessage(wmPtr->wrapper, TK_DEICONIFY, 0, 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't deiconify %s: the container does not support the request", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL); return TCL_ERROR; } return TCL_OK; } TkpWinToplevelDeiconify(winPtr); return TCL_OK; } |
︙ | ︙ | |||
3591 3592 3593 3594 3595 3596 3597 | int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?"); return TCL_ERROR; } if (objc == 3) { | > | < | 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 | int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?"); return TCL_ERROR; } if (objc == 3) { Tcl_SetObjResult(interp, Tcl_NewStringObj( wmPtr->hints.input ? "passive" : "active", -1)); return TCL_OK; } if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
3796 3797 3798 3799 3800 3801 3802 | if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?baseWidth baseHeight widthInc heightInc?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & PBaseSize) { | > | | > > | > | 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 | if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?baseWidth baseHeight widthInc heightInc?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & PBaseSize) { Tcl_Obj *results[4]; results[0] = Tcl_NewIntObj(wmPtr->reqGridWidth); results[1] = Tcl_NewIntObj(wmPtr->reqGridHeight); results[2] = Tcl_NewIntObj(wmPtr->widthInc); results[3] = Tcl_NewIntObj(wmPtr->heightInc); Tcl_SetObjResult(interp, Tcl_NewListObj(4, results)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { /* * Turn off gridding and reset the width and height to make sense as * ungridded numbers. |
︙ | ︙ | |||
3825 3826 3827 3828 3829 3830 3831 | if ((Tcl_GetIntFromObj(interp, objv[3], &reqWidth) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &reqHeight) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[5], &widthInc) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[6], &heightInc) != TCL_OK)) { return TCL_ERROR; } if (reqWidth < 0) { | > | > > | > > | > > | > | 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 | if ((Tcl_GetIntFromObj(interp, objv[3], &reqWidth) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &reqHeight) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[5], &widthInc) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[6], &heightInc) != TCL_OK)) { return TCL_ERROR; } if (reqWidth < 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "baseWidth can't be < 0", -1)); Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL); return TCL_ERROR; } if (reqHeight < 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "baseHeight can't be < 0", -1)); Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL); return TCL_ERROR; } if (widthInc <= 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "widthInc can't be <= 0", -1)); Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL); return TCL_ERROR; } if (heightInc <= 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "heightInc can't be <= 0", -1)); Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL); return TCL_ERROR; } Tk_SetGrid((Tk_Window) winPtr, reqWidth, reqHeight, widthInc, heightInc); } WmUpdateGeom(wmPtr, winPtr); return TCL_OK; |
︙ | ︙ | |||
3883 3884 3885 3886 3887 3888 3889 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & WindowGroupHint) { | | | 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & WindowGroupHint) { Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->leaderName, -1)); } return TCL_OK; } argv3 = Tcl_GetStringFromObj(objv[3], &length); if (*argv3 == '\0') { wmPtr->hints.flags &= ~WindowGroupHint; if (wmPtr->leaderName != NULL) { |
︙ | ︙ | |||
3950 3951 3952 3953 3954 3955 3956 | /* * If we have 5 arguments, we must have a '-default' flag. */ const char *argv3 = Tcl_GetString(objv[3]); if (strcmp(argv3, "-default")) { | | | > | | | 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 | /* * If we have 5 arguments, we must have a '-default' flag. */ const char *argv3 = Tcl_GetString(objv[3]); if (strcmp(argv3, "-default")) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "illegal option \"%s\" must be \"-default\"", argv3)); Tcl_SetErrorCode(interp, "TK", "WM", "ICONBITMAP", "OPTION",NULL); return TCL_ERROR; } useWinPtr = NULL; } else if (objc == 3) { /* * No arguments were given. */ if (wmPtr->hints.flags & IconPixmapHint) { Tcl_SetObjResult(interp, Tcl_NewStringObj( Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_pixmap), -1)); } return TCL_OK; } string = Tcl_GetString(objv[objc-1]); if (*string == '\0') { if (wmPtr->hints.icon_pixmap != None) { |
︙ | ︙ | |||
4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 | /* * We didn't manage to handle the argument as a valid icon. Try as * a bitmap. First we must clear the error message which was * placed in the interpreter. */ Pixmap pixmap; Tcl_ResetResult(interp); pixmap = Tk_GetBitmap(interp, (Tk_Window) winPtr, string); if (pixmap == None) { return TCL_ERROR; } wmPtr->hints.icon_pixmap = pixmap; wmPtr->hints.flags |= IconPixmapHint; | > | 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 | /* * We didn't manage to handle the argument as a valid icon. Try as * a bitmap. First we must clear the error message which was * placed in the interpreter. */ Pixmap pixmap; Tcl_ResetResult(interp); pixmap = Tk_GetBitmap(interp, (Tk_Window) winPtr, string); if (pixmap == None) { return TCL_ERROR; } wmPtr->hints.icon_pixmap = pixmap; wmPtr->hints.flags |= IconPixmapHint; |
︙ | ︙ | |||
4076 4077 4078 4079 4080 4081 4082 | register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (winPtr->flags & TK_EMBEDDED) { if (!SendMessage(wmPtr->wrapper, TK_ICONIFY, 0, 0)) { | | | > > | | > > > | | > > | > | > | 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 | register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (winPtr->flags & TK_EMBEDDED) { if (!SendMessage(wmPtr->wrapper, TK_ICONIFY, 0, 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify %s: the container does not support the request", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "EMBEDDED", NULL); return TCL_ERROR; } } 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; } if (wmPtr->masterPtr != 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) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify %s: it is an icon for %s", winPtr->pathName, Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "ICON", NULL); return TCL_ERROR; } TkpWmSetState(winPtr, IconicState); return TCL_OK; } /* |
︙ | ︙ | |||
4135 4136 4137 4138 4139 4140 4141 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconMaskHint) { | | | | 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconMaskHint) { Tcl_SetObjResult(interp, Tcl_NewStringObj( Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_mask), -1)); } return TCL_OK; } argv3 = Tcl_GetString(objv[3]); if (*argv3 == '\0') { if (wmPtr->hints.icon_mask != None) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_mask); |
︙ | ︙ | |||
4192 4193 4194 4195 4196 4197 4198 | int length; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?"); return TCL_ERROR; } if (objc == 3) { | | | < | 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 | int length; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?"); return TCL_ERROR; } if (objc == 3) { Tcl_SetObjResult(interp, Tcl_NewStringObj( (wmPtr->iconName ? wmPtr->iconName : ""), -1)); return TCL_OK; } else { if (wmPtr->iconName != NULL) { ckfree(wmPtr->iconName); } argv3 = Tcl_GetStringFromObj(objv[3], &length); wmPtr->iconName = ckalloc(length + 1); |
︙ | ︙ | |||
4270 4271 4272 4273 4274 4275 4276 | "window ?-default? image1 ?image2 ...?"); return TCL_ERROR; } } for (i = startObj; i < objc; i++) { photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i])); if (photo == NULL) { | | | > > | 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 | "window ?-default? image1 ?image2 ...?"); return TCL_ERROR; } } for (i = startObj; i < objc; i++) { photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i])); if (photo == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't use \"%s\" as iconphoto: not a photo image", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL); return TCL_ERROR; } } /* * We have calculated the size of the data. Try to allocate the needed * memory space. |
︙ | ︙ | |||
4321 4322 4323 4324 4325 4326 4327 | bmInfo.bmiHeader.biBitCount = 32; bmInfo.bmiHeader.biCompression = BI_RGB; iconInfo.hbmColor = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS, &bgraPixel.voidPtr, NULL, 0); if (!iconInfo.hbmColor) { ckfree(lpIR); | > | | > | 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 | bmInfo.bmiHeader.biBitCount = 32; bmInfo.bmiHeader.biCompression = BI_RGB; iconInfo.hbmColor = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS, &bgraPixel.voidPtr, NULL, 0); if (!iconInfo.hbmColor) { ckfree(lpIR); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "failed to create color bitmap for \"%s\"", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "BITMAP", NULL); return TCL_ERROR; } /* * Convert the photo image data into BGRA format (RGBQUAD). */ |
︙ | ︙ | |||
4351 4352 4353 4354 4355 4356 4357 | bmInfo.bmiHeader.biBitCount = 1; iconInfo.hbmMask = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS, &bgraMask.voidPtr, NULL, 0); if (!iconInfo.hbmMask) { DeleteObject(iconInfo.hbmColor); ckfree(lpIR); | > | | > > | | > | 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 | bmInfo.bmiHeader.biBitCount = 1; iconInfo.hbmMask = CreateDIBSection(NULL, &bmInfo, DIB_RGB_COLORS, &bgraMask.voidPtr, NULL, 0); if (!iconInfo.hbmMask) { DeleteObject(iconInfo.hbmColor); ckfree(lpIR); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "failed to create mask bitmap for \"%s\"", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "MASK", NULL); return TCL_ERROR; } ZeroMemory(bgraMask.ptr, width*height/8); /* * Create an icon from the bitmaps. */ hIcon = CreateIconIndirect(&iconInfo); DeleteObject(iconInfo.hbmColor); DeleteObject(iconInfo.hbmMask); if (hIcon == NULL) { /* * XXX should free up created icons. */ ckfree(lpIR); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "failed to create icon for \"%s\"", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "ICON", NULL); return TCL_ERROR; } lpIR->IconImages[i-startObj].Width = width; lpIR->IconImages[i-startObj].Height = height; lpIR->IconImages[i-startObj].Colors = 4; lpIR->IconImages[i-startObj].hIcon = hIcon; } |
︙ | ︙ | |||
4429 4430 4431 4432 4433 4434 4435 | if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconPositionHint) { | > > > > | < | 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 | if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->hints.flags & IconPositionHint) { Tcl_Obj *results[2]; results[0] = Tcl_NewIntObj(wmPtr->hints.icon_x); results[1] = Tcl_NewIntObj(wmPtr->hints.icon_y); Tcl_SetObjResult(interp, Tcl_NewListObj(2, results)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->hints.flags &= ~IconPositionHint; } else { if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK) |
︙ | ︙ | |||
4484 4485 4486 4487 4488 4489 4490 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->icon != NULL) { | | | 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->icon != NULL) { Tcl_SetObjResult(interp, TkNewWindowObj(wmPtr->icon)); } return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->hints.flags &= ~IconWindowHint; if (wmPtr->icon != NULL) { /* |
︙ | ︙ | |||
4509 4510 4511 4512 4513 4514 4515 | } wmPtr->icon = NULL; } else { if (TkGetWindowFromObj(interp, tkwin, objv[3], &tkwin2) != TCL_OK) { return TCL_ERROR; } if (!Tk_IsTopLevel(tkwin2)) { | | | > > | | > | | 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 | } wmPtr->icon = NULL; } else { if (TkGetWindowFromObj(interp, tkwin, objv[3], &tkwin2) != TCL_OK) { return TCL_ERROR; } if (!Tk_IsTopLevel(tkwin2)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't use %s as icon window: not at top level", Tcl_GetString(objv[3]))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONWINDOW", "INNER", NULL); return TCL_ERROR; } wmPtr2 = ((TkWindow *) tkwin2)->wmInfoPtr; if (wmPtr2->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s is already an icon for %s", Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "ICONWINDOW", "ICON", NULL); return TCL_ERROR; } if (wmPtr->icon != NULL) { WmInfo *wmPtr3 = ((TkWindow *) wmPtr->icon)->wmInfoPtr; wmPtr3->iconFor = NULL; /* |
︙ | ︙ | |||
4585 4586 4587 4588 4589 4590 4591 | Tcl_Obj *const objv[]) /* Argument objects. */ { register Tk_Window frameWin = (Tk_Window) winPtr; register WmInfo *wmPtr = winPtr->wmInfoPtr; if (!Tk_IsTopLevel(frameWin)) { if (!Tk_IsManageable(frameWin)) { | | | | > | 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 | Tcl_Obj *const objv[]) /* Argument objects. */ { register Tk_Window frameWin = (Tk_Window) winPtr; register WmInfo *wmPtr = winPtr->wmInfoPtr; if (!Tk_IsTopLevel(frameWin)) { if (!Tk_IsManageable(frameWin)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" is not manageable: must be a frame," " labelframe or toplevel", Tk_PathName(frameWin))); Tcl_SetErrorCode(interp, "TK", "WM", "MANAGE", NULL); return TCL_ERROR; } TkFocusSplit(winPtr); Tk_UnmapWindow(frameWin); winPtr->flags |= TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED; RemapWindows(winPtr, NULL); if (wmPtr == NULL) { |
︙ | ︙ | |||
4641 4642 4643 4644 4645 4646 4647 4648 | int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { GetMaxSize(wmPtr, &width, &height); | > > > > | | 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 | int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { Tcl_Obj *results[2]; GetMaxSize(wmPtr, &width, &height); results[0] = Tcl_NewIntObj(width); results[1] = Tcl_NewIntObj(height); Tcl_SetObjResult(interp, Tcl_NewListObj(2, results)); return TCL_OK; } if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &height) != TCL_OK)) { return TCL_ERROR; } wmPtr->maxWidth = width; |
︙ | ︙ | |||
4688 4689 4690 4691 4692 4693 4694 4695 | int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { GetMinSize(wmPtr, &width, &height); | > > > > | | 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 | int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { Tcl_Obj *results[2]; GetMinSize(wmPtr, &width, &height); results[0] = Tcl_NewIntObj(width); results[1] = Tcl_NewIntObj(height); Tcl_SetObjResult(interp, Tcl_NewListObj(2, results)); return TCL_OK; } if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[4], &height) != TCL_OK)) { return TCL_ERROR; } wmPtr->minWidth = width; |
︙ | ︙ | |||
4738 4739 4740 4741 4742 4743 4744 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); return TCL_ERROR; } if (winPtr->flags & TK_EMBEDDED) { curValue = SendMessage(wmPtr->wrapper, TK_OVERRIDEREDIRECT, -1, -1)-1; if (curValue < 0) { | | | > | 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); return TCL_ERROR; } if (winPtr->flags & TK_EMBEDDED) { curValue = SendMessage(wmPtr->wrapper, TK_OVERRIDEREDIRECT, -1, -1)-1; if (curValue < 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Container does not support overrideredirect", -1)); Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL); return TCL_ERROR; } } else { curValue = Tk_Attributes((Tk_Window) winPtr)->override_redirect; } if (objc == 3) { Tcl_SetObjResult(interp, Tcl_NewBooleanObj(curValue)); |
︙ | ︙ | |||
4812 4813 4814 4815 4816 4817 4818 4819 | int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & USPosition) { | > > | | > | 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 | int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?"); return TCL_ERROR; } if (objc == 3) { const char *sourceStr = ""; if (wmPtr->sizeHintsFlags & USPosition) { sourceStr = "user"; } else if (wmPtr->sizeHintsFlags & PPosition) { sourceStr = "program"; } Tcl_SetObjResult(interp, Tcl_NewStringObj(sourceStr, -1)); return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->sizeHintsFlags &= ~(USPosition|PPosition); } else { if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { |
︙ | ︙ | |||
4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 | Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; register ProtocolHandler *protPtr, *prevPtr; Atom protocol; const char *cmd; int cmdLength; if ((objc < 3) || (objc > 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?"); return TCL_ERROR; } if (objc == 3) { /* * Return a list of all defined protocols for the window. */ for (protPtr = wmPtr->protPtr; protPtr != NULL; protPtr = protPtr->nextPtr) { | > > | | > > | | 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 | Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; register ProtocolHandler *protPtr, *prevPtr; Atom protocol; const char *cmd; int cmdLength; Tcl_Obj *resultObj; if ((objc < 3) || (objc > 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?"); return TCL_ERROR; } if (objc == 3) { /* * Return a list of all defined protocols for the window. */ resultObj = Tcl_NewObj(); for (protPtr = wmPtr->protPtr; protPtr != NULL; protPtr = protPtr->nextPtr) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( Tk_GetAtomName((Tk_Window)winPtr, protPtr->protocol), -1)); } Tcl_SetObjResult(interp, resultObj); return TCL_OK; } protocol = Tk_InternAtom((Tk_Window) winPtr, Tcl_GetString(objv[3])); if (objc == 4) { /* * Return the command to handle a given protocol. */ for (protPtr = wmPtr->protPtr; protPtr != NULL; protPtr = protPtr->nextPtr) { if (protPtr->protocol == protocol) { Tcl_SetObjResult(interp, Tcl_NewStringObj(protPtr->command, -1)); return TCL_OK; } } return TCL_OK; } /* |
︙ | ︙ | |||
4963 4964 4965 4966 4967 4968 4969 | int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { | > | | | > | 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 | int width, height; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); return TCL_ERROR; } if (objc == 3) { Tcl_Obj *results[2]; results[0] = Tcl_NewBooleanObj(!(wmPtr->flags&WM_WIDTH_NOT_RESIZABLE)); results[1] = Tcl_NewBooleanObj(!(wmPtr->flags&WM_HEIGHT_NOT_RESIZABLE)); Tcl_SetObjResult(interp, Tcl_NewListObj(2, results)); return TCL_OK; } if ((Tcl_GetBooleanFromObj(interp, objv[3], &width) != TCL_OK) || (Tcl_GetBooleanFromObj(interp, objv[4], &height) != TCL_OK)) { return TCL_ERROR; } if (width) { |
︙ | ︙ | |||
5029 5030 5031 5032 5033 5034 5035 5036 | int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?"); return TCL_ERROR; } if (objc == 3) { if (wmPtr->sizeHintsFlags & USSize) { | > > | | > | 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 | int index; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?"); return TCL_ERROR; } if (objc == 3) { const char *sourceStr = ""; if (wmPtr->sizeHintsFlags & USSize) { sourceStr = "user"; } else if (wmPtr->sizeHintsFlags & PSize) { sourceStr = "program"; } Tcl_SetObjResult(interp, Tcl_NewStringObj(sourceStr, -1)); return TCL_OK; } if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->sizeHintsFlags &= ~(USSize|PSize); } else { if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, |
︙ | ︙ | |||
5081 5082 5083 5084 5085 5086 5087 | WmStackorderCmd( 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. */ { | | > > > | | > > | | | > > | | > | | > > | > | | | | | < | | 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 | WmStackorderCmd( 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. */ { TkWindow **windows, **windowPtr; static const char *const optionStrings[] = { "isabove", "isbelow", NULL }; enum options { OPT_ISABOVE, OPT_ISBELOW }; Tcl_Obj *resultObj; int index; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?isabove|isbelow window?"); return TCL_ERROR; } if (objc == 3) { windows = TkWmStackorderToplevel(winPtr); if (windows == NULL) { Tcl_Panic("TkWmStackorderToplevel failed"); } resultObj = Tcl_NewObj(); for (windowPtr = windows; *windowPtr ; windowPtr++) { Tcl_ListObjAppendElement(NULL, resultObj, TkNewWindowObj((Tk_Window) *windowPtr)); } Tcl_SetObjResult(interp, resultObj); ckfree(windows); return TCL_OK; } else { TkWindow *winPtr2, **winPtr2Ptr = &winPtr2; int index1 = -1, index2 = -1, result; if (TkGetWindowFromObj(interp, tkwin, objv[4], (Tk_Window *) winPtr2Ptr) != TCL_OK) { return TCL_ERROR; } if (!Tk_IsTopLevel(winPtr2)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't a top-level window", winPtr2->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "TOPLEVEL", NULL); return TCL_ERROR; } if (!Tk_IsMapped(winPtr)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't mapped", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", NULL); return TCL_ERROR; } if (!Tk_IsMapped(winPtr2)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't mapped", winPtr2->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", NULL); return TCL_ERROR; } /* * Lookup stacking order of all toplevels that are children of "." and * find the position of winPtr and winPtr2 in the stacking order. */ windows = TkWmStackorderToplevel(winPtr->mainPtr->winPtr); if (windows == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "TkWmStackorderToplevel failed", -1)); Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL); return TCL_ERROR; } for (windowPtr = windows; *windowPtr ; windowPtr++) { if (*windowPtr == winPtr) { index1 = (windowPtr - windows); } if (*windowPtr == winPtr2) { index2 = (windowPtr - windows); } } if (index1 == -1) { Tcl_Panic("winPtr window not found"); } else if (index2 == -1) { Tcl_Panic("winPtr2 window not found"); } ckfree(windows); if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { |
︙ | ︙ | |||
5214 5215 5216 5217 5218 5219 5220 | if ((objc < 3) || (objc > 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?state?"); return TCL_ERROR; } if (objc == 4) { if (wmPtr->iconFor != NULL) { | | | | > | 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 | if ((objc < 3) || (objc > 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?state?"); return TCL_ERROR; } if (objc == 4) { if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't change state of %s: it is an icon for %s", Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "ICON", NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } |
︙ | ︙ | |||
5250 5251 5252 5253 5254 5255 5256 | state = ZoomState; break; default: Tcl_Panic("unexpected index"); } if (state+1 != SendMessage(wmPtr->wrapper, TK_STATE, state, 0)) { | > | | | | | > > > > | | > > > > | | | < < | < < | < < | < < > | 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 | state = ZoomState; break; default: Tcl_Panic("unexpected index"); } if (state+1 != SendMessage(wmPtr->wrapper, TK_STATE, state, 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't change state of %s: the container does not support the request", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL); return TCL_ERROR; } return TCL_OK; } if (index == OPT_NORMAL) { wmPtr->flags &= ~WM_WITHDRAWN; TkpWmSetState(winPtr, NormalState); /* * This varies from 'wm deiconify' because it does not force the * window to be raised and receive focus. */ } else if (index == OPT_ICONIC) { 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", "STATE", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } if (wmPtr->masterPtr != 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; } TkpWmSetState(winPtr, IconicState); } else if (index == OPT_WITHDRAWN) { wmPtr->flags |= WM_WITHDRAWN; TkpWmSetState(winPtr, WithdrawnState); } else if (index == OPT_ZOOMED) { TkpWmSetState(winPtr, ZoomState); } else { Tcl_Panic("wm state not matched"); } } else { const char *stateStr = ""; if (wmPtr->iconFor != NULL) { stateStr = "icon"; } else { int state; if (winPtr->flags & TK_EMBEDDED) { state = SendMessage(wmPtr->wrapper, TK_STATE, -1, -1) - 1; } else { state = wmPtr->hints.initial_state; } switch (state) { case NormalState: stateStr = "normal"; break; case IconicState: stateStr = "iconic"; break; case WithdrawnState: stateStr = "withdrawn"; break; case ZoomState: stateStr = "zoomed"; break; } } Tcl_SetObjResult(interp, Tcl_NewStringObj(stateStr, -1)); } return TCL_OK; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
5364 5365 5366 5367 5368 5369 5370 | if (wrapper) { TCHAR buf[256]; Tcl_DString titleString; int size = 256; GetWindowText(wrapper, buf, size); Tcl_WinTCharToUtf(buf, -1, &titleString); | > | > | | < | 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 | if (wrapper) { TCHAR buf[256]; Tcl_DString titleString; int size = 256; GetWindowText(wrapper, buf, size); Tcl_WinTCharToUtf(buf, -1, &titleString); Tcl_SetObjResult(interp, Tcl_NewStringObj( Tcl_DStringValue(&titleString), Tcl_DStringLength(&titleString))); Tcl_DStringFree(&titleString); } else { Tcl_SetObjResult(interp, Tcl_NewStringObj( (wmPtr->title ? wmPtr->title : winPtr->nameUid), -1)); } } else { if (wmPtr->title != NULL) { ckfree(wmPtr->title); } argv3 = Tcl_GetStringFromObj(objv[3], &length); wmPtr->title = ckalloc(length + 1); |
︙ | ︙ | |||
5425 5426 5427 5428 5429 5430 5431 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?master?"); return TCL_ERROR; } if (objc == 3) { if (masterPtr != NULL) { | | | 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 | if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?master?"); return TCL_ERROR; } if (objc == 3) { if (masterPtr != NULL) { Tcl_SetObjResult(interp, TkNewWindowObj(masterPtr)); } return TCL_OK; } if (Tcl_GetString(objv[3])[0] == '\0') { if (masterPtr != NULL) { /* * If we had a master, tell them that we aren't tied to them |
︙ | ︙ | |||
5458 5459 5460 5461 5462 5463 5464 | */ masterPtr = masterPtr->parentPtr; } Tk_MakeWindowExist((Tk_Window) masterPtr); if (wmPtr->iconFor != NULL) { | | | | > | | | > | | > | 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 | */ masterPtr = masterPtr->parentPtr; } Tk_MakeWindowExist((Tk_Window) masterPtr); 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 = masterPtr->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; } if (masterPtr == winPtr) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't make \"%s\" its own master", Tk_PathName(winPtr))); Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL); return TCL_ERROR; } else if (masterPtr != wmPtr->masterPtr) { /* * Remove old master map/unmap binding before setting the new * master. The event handler will ensure that transient states * reflect the state of the master. */ |
︙ | ︙ | |||
5543 5544 5545 5546 5547 5548 5549 | register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { | > | | > | | > > | 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 | register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't withdraw %s: it is an icon for %s", Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor))); Tcl_SetErrorCode(interp, "TK", "WM", "WITHDRAW", "ICON", NULL); return TCL_ERROR; } if (winPtr->flags & TK_EMBEDDED) { if (SendMessage(wmPtr->wrapper, TK_WITHDRAW, 0, 0) < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't withdraw %s: the container does not support the request", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TK", "WM", "COMMUNICATION", NULL); return TCL_ERROR; } } else { wmPtr->flags |= WM_WITHDRAWN; TkpWmSetState(winPtr, WithdrawnState); } return TCL_OK; |
︙ | ︙ | |||
6248 6249 6250 6251 6252 6253 6254 | /* * Assume that the geometry information came from the user, unless an * explicit source has been specified. Otherwise most window managers * assume that the size hints were program-specified and they ignore * them. */ | | | 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 | /* * Assume that the geometry information came from the user, unless an * explicit source has been specified. Otherwise most window managers * assume that the size hints were program-specified and they ignore * them. */ if (!(wmPtr->sizeHintsFlags & (USPosition|PPosition))) { wmPtr->sizeHintsFlags |= USPosition; } } /* * Everything was parsed OK. Update the fields of *wmPtr and arrange for * the appropriate information to be percolated out to the window manager |
︙ | ︙ | |||
6273 6274 6275 6276 6277 6278 6279 | if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } return TCL_OK; error: | > | > | 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 | if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; } return TCL_OK; error: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad geometry specifier \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "GEOMETRY", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * Tk_GetRootCoords -- |
︙ | ︙ | |||
6440 6441 6442 6443 6444 6445 6446 | if (!(winPtr->flags & TK_TOP_LEVEL)) { Tcl_Panic("Tk_MoveToplevelWindow called with non-toplevel window"); } wmPtr->x = x; wmPtr->y = y; wmPtr->flags |= WM_MOVE_PENDING; wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y); | | | 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 | if (!(winPtr->flags & TK_TOP_LEVEL)) { Tcl_Panic("Tk_MoveToplevelWindow called with non-toplevel window"); } wmPtr->x = x; wmPtr->y = y; wmPtr->flags |= WM_MOVE_PENDING; wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y); if (!(wmPtr->sizeHintsFlags & (USPosition|PPosition))) { wmPtr->sizeHintsFlags |= USPosition; } /* * If the window has already been mapped, must bring its geometry * up-to-date immediately, otherwise an event might arrive from the server * that would overwrite wmPtr->x and wmPtr->y and lose the new position. |
︙ | ︙ | |||
6575 6576 6577 6578 6579 6580 6581 | } else { Tcl_SetHashValue(hPtr, NULL); } /* fprintf(stderr, "Found mapped HWND %d -> %x (%s)\n", hwnd, childWinPtr, childWinPtr->pathName); */ | | | 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 | } else { Tcl_SetHashValue(hPtr, NULL); } /* fprintf(stderr, "Found mapped HWND %d -> %x (%s)\n", hwnd, childWinPtr, childWinPtr->pathName); */ *(pair->windowPtr)-- = childWinPtr; } return TRUE; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
6685 6686 6687 6688 6689 6690 6691 | /* * We will be inserting into the array starting at the end and working our * way to the beginning since EnumWindows returns windows in highest to * lowest order. */ pair.table = &table; | | | | | 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 | /* * We will be inserting into the array starting at the end and working our * way to the beginning since EnumWindows returns windows in highest to * lowest order. */ pair.table = &table; pair.windowPtr = windows + table.numEntries; *pair.windowPtr-- = NULL; if (EnumWindows((WNDENUMPROC) TkWmStackorderToplevelEnumProc, (LPARAM) &pair) == 0) { ckfree(windows); windows = NULL; } else if (pair.windowPtr != (windows-1)) { Tcl_Panic("num matched toplevel windows does not equal num children"); } done: Tcl_DeleteHashTable(&table); return windows; } |
︙ | ︙ |
Changes to win/tkWinX.c.
︙ | ︙ | |||
116 117 118 119 120 121 122 | void TkGetServerInfo( Tcl_Interp *interp, /* The server information is returned in this * interpreter's result. */ Tk_Window tkwin) /* Token for window; this selects a particular * display and server. */ { | < | > | | < | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | void TkGetServerInfo( Tcl_Interp *interp, /* The server information is returned in this * interpreter's result. */ Tk_Window tkwin) /* Token for window; this selects a particular * display and server. */ { OSVERSIONINFO os; os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&os); Tcl_SetObjResult(interp, Tcl_ObjPrintf("Windows %d.%d %d %s", (int) os.dwMajorVersion, (int) os.dwMinorVersion, (int) os.dwBuildNumber, #ifdef _WIN64 "Win64" #else "Win32" #endif )); } /* *---------------------------------------------------------------------- * * Tk_GetHINSTANCE -- * |
︙ | ︙ |
Changes to win/ttkWinXPTheme.c.
︙ | ︙ | |||
1058 1059 1060 1061 1062 1063 1064 | Tcl_Obj **objv; int i, objc; if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) return TCL_ERROR; if (objc != 2) { | | > | 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 | Tcl_Obj **objv; int i, objc; if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) return TCL_ERROR; if (objc != 2) { Tcl_SetObjResult(interp, Tcl_NewStringObj("wrong # args", -1)); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); return TCL_ERROR; } for (i = 0; i < objc; ++i) { int option; if (Tcl_GetIndexFromObj(interp, objv[i], names, "system constant", 0, &option) != TCL_OK) return TCL_ERROR; |
︙ | ︙ | |||
1112 1113 1114 1115 1116 1117 1118 | static const char *optionStrings[] = { "-padding","-width","-height","-margins", "-syssize", "-halfheight", "-halfwidth", NULL }; enum { O_PADDING, O_WIDTH, O_HEIGHT, O_MARGINS, O_SYSSIZE, O_HALFHEIGHT, O_HALFWIDTH }; if (objc < 2) { | | | > > | | > | 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 | static const char *optionStrings[] = { "-padding","-width","-height","-margins", "-syssize", "-halfheight", "-halfwidth", NULL }; enum { O_PADDING, O_WIDTH, O_HEIGHT, O_MARGINS, O_SYSSIZE, O_HALFHEIGHT, O_HALFWIDTH }; if (objc < 2) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "missing required arguments 'class' and/or 'partId'", -1)); Tcl_SetErrorCode(interp, "TTK", "VSAPI", "REQUIRED", NULL); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[1], &partId) != TCL_OK) { return TCL_ERROR; } className = Tcl_GetUnicodeFromObj(objv[0], &length); /* flags or padding */ if (objc > 3) { int i = 3, option = 0; for (i = 3; i < objc; i += 2) { int tmp = 0; if (i == objc -1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Missing value for \"%s\".", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TTK", "VSAPI", "MISSING", NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option", 0, &option) != TCL_OK) return TCL_ERROR; switch (option) { case O_PADDING: |
︙ | ︙ |