Skip to content

Commit

Permalink
Merge 8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Dec 22, 2023
2 parents 2b5f153 + 1ad353b commit 1270239
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 78 deletions.
41 changes: 24 additions & 17 deletions generic/tk3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,7 @@ Tk_GetReliefFromObj(
*
* Results:
* A standard Tcl return value. If all goes well then *reliefPtr is
* filled in with one of the values TK_RELIEF_RAISED, TK_RELIEF_FLAT, or
* TK_RELIEF_SUNKEN.
* filled in with one of the values TK_RELIEF_*
*
* Side effects:
* None.
Expand All @@ -656,30 +655,38 @@ Tk_GetRelief(
{
char c;
size_t length;
int relief;

c = name[0];
length = strlen(name);
if ((c == 'f') && (strncmp(name, "flat", length) == 0)) {
*reliefPtr = TK_RELIEF_FLAT;
} else if ((c == 'g') && (strncmp(name, "groove", length) == 0)
&& (length >= 2)) {
*reliefPtr = TK_RELIEF_GROOVE;
relief = TK_RELIEF_FLAT;
} else if ((c == 'g') && (strncmp(name, "groove", length) == 0)) {
relief = TK_RELIEF_GROOVE;
} else if ((c == 'r') && (strncmp(name, "raised", length) == 0)
&& (length >= 2)) {
*reliefPtr = TK_RELIEF_RAISED;
} 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;
relief = TK_RELIEF_RAISED;
} else if ((c == 'r') && (strncmp(name, "ridge", length) == 0)
&& (length >= 2)) {
relief = TK_RELIEF_RIDGE;
} else if ((c == 's') && (strncmp(name, "solid", length) == 0)
&& (length >= 2)) {
relief = TK_RELIEF_SOLID;
} else if ((c == 's') && (strncmp(name, "sunken", length) == 0)
&& (length >= 2)) {
relief = 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);
if (interp) {
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;
}
if (reliefPtr) {
*reliefPtr = relief;
}
return TCL_OK;
}

Expand Down
2 changes: 1 addition & 1 deletion generic/tkMacWinMenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ PreprocessMenu(

do {
finished = 1;
for (index = 0; index < (int)menuPtr->numEntries; index++) {
for (index = 0; index < menuPtr->numEntries; index++) {
TkMenuEntry *entryPtr = menuPtr->entries[index];

if ((entryPtr->type == CASCADE_ENTRY)
Expand Down
36 changes: 19 additions & 17 deletions generic/tkMenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,11 @@ enum options {
static int CloneMenu(TkMenu *menuPtr, Tcl_Obj *newMenuName,
Tcl_Obj *newMenuTypeString);
static int ConfigureMenu(Tcl_Interp *interp, TkMenu *menuPtr,
int objc, Tcl_Obj *const objv[]);
Tcl_Size objc, Tcl_Obj *const objv[]);
static int ConfigureMenuCloneEntries(TkMenu *menuPtr, int index,
int objc, Tcl_Obj *const objv[]);
Tcl_Size objc, Tcl_Obj *const objv[]);
static int ConfigureMenuEntry(TkMenuEntry *mePtr,
int objc, Tcl_Obj *const objv[]);
Tcl_Size objc, Tcl_Obj *const objv[]);
static void DeleteMenuCloneEntries(TkMenu *menuPtr,
int first, int last);
static void DestroyMenuHashTable(void *clientData,
Expand All @@ -342,7 +342,7 @@ static int MenuDoYPosition(Tcl_Interp *interp,
static int MenuDoXPosition(Tcl_Interp *interp,
TkMenu *menuPtr, Tcl_Obj *objPtr);
static int MenuAddOrInsert(Tcl_Interp *interp,
TkMenu *menuPtr, Tcl_Obj *indexPtr, int objc,
TkMenu *menuPtr, Tcl_Obj *indexPtr, Tcl_Size objc,
Tcl_Obj *const objv[]);
static void MenuCmdDeletedProc(void *clientData);
static TkMenuEntry * MenuNewEntry(TkMenu *menuPtr, Tcl_Size index, int type);
Expand Down Expand Up @@ -401,7 +401,8 @@ Tk_MenuObjCmd(
Tk_Window newWin;
TkMenu *menuPtr;
TkMenuReferences *menuRefPtr;
int i, index, toplevel;
Tcl_Size i;
int index, toplevel;
const char *windowName;
static const char *const typeStringList[] = {"-type", NULL};
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Expand Down Expand Up @@ -1563,7 +1564,7 @@ ConfigureMenu(
Tcl_Interp *interp, /* Used for error reporting. */
TkMenu *menuPtr, /* Information about widget; may or may not
* already have values for some fields. */
int objc, /* Number of valid entries in argv. */
Tcl_Size objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[]) /* Arguments. */
{
int i;
Expand Down Expand Up @@ -1668,7 +1669,7 @@ ConfigureMenu(

Tcl_EventuallyFree(menuListPtr->entries[0], DestroyMenuEntry);

for (i = 0; i < (int)menuListPtr->numEntries - 1; i++) {
for (i = 0; i < menuListPtr->numEntries - 1; i++) {
menuListPtr->entries[i] = menuListPtr->entries[i + 1];
menuListPtr->entries[i]->index = i;
}
Expand All @@ -1687,7 +1688,7 @@ ConfigureMenu(
* parent.
*/

for (i = 0; i < (int)menuListPtr->numEntries; i++) {
for (i = 0; i < menuListPtr->numEntries; i++) {
TkMenuEntry *mePtr;

mePtr = menuListPtr->entries[i];
Expand Down Expand Up @@ -1944,7 +1945,7 @@ static int
ConfigureMenuEntry(
TkMenuEntry *mePtr,/* Information about menu entry; may or may
* not already have values for some fields. */
int objc, /* Number of valid entries in argv. */
Tcl_Size objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[]) /* Arguments. */
{
TkMenu *menuPtr = mePtr->menuPtr;
Expand Down Expand Up @@ -2007,7 +2008,7 @@ static int
ConfigureMenuCloneEntries(
TkMenu *menuPtr, /* Information about whole menu. */
int index, /* Index of mePtr within menuPtr's entries. */
int objc, /* Number of valid entries in argv. */
Tcl_Size objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[]) /* Arguments. */
{
TkMenuEntry *mePtr;
Expand Down Expand Up @@ -2154,7 +2155,7 @@ GetMenuIndex(
* *after* last entry. */
Tcl_Size *indexPtr) /* Where to store converted index. */
{
int i;
Tcl_Size i;
const char *string;
Tcl_HashEntry *entryPtr;

Expand Down Expand Up @@ -2199,7 +2200,7 @@ GetMenuIndex(
return TCL_OK;
}

for (i = 0; i < (int)menuPtr->numEntries; i++) {
for (i = 0; i < menuPtr->numEntries; i++) {
Tcl_Obj *labelPtr = menuPtr->entries[i]->labelPtr;
const char *label = (labelPtr == NULL) ? NULL : Tcl_GetString(labelPtr);

Expand Down Expand Up @@ -2379,7 +2380,7 @@ MenuAddOrInsert(
TkMenu *menuPtr, /* Widget in which to create new entry. */
Tcl_Obj *indexPtr, /* Object describing index at which to insert.
* NULL means insert at end. */
int objc, /* Number of elements in objv. */
Tcl_Size objc, /* Number of elements in objv. */
Tcl_Obj *const objv[]) /* Arguments to command: first arg is type of
* entry, others are config options. */
{
Expand Down Expand Up @@ -3025,7 +3026,8 @@ GetIndexFromCoords(
const char *string, /* The @string we are parsing. */
Tcl_Size *indexPtr) /* The index of the item that matches. */
{
int x, y, i;
int x, y;
Tcl_Size i;
const char *p;
const char *rest;
int x2, borderwidth, max;
Expand Down Expand Up @@ -3061,7 +3063,7 @@ GetIndexFromCoords(
? Tk_Width(menuPtr->tkwin) : Tk_ReqWidth(menuPtr->tkwin);
max -= borderwidth;

for (i = 0; i < (int)menuPtr->numEntries; i++) {
for (i = 0; i < menuPtr->numEntries; i++) {
if (menuPtr->entries[i]->entryFlags & ENTRY_LAST_COLUMN) {
x2 = max;
} else {
Expand Down Expand Up @@ -3600,15 +3602,15 @@ DeleteMenuCloneEntries(
int last) /* The zero-based last entry. */
{
TkMenu *menuListPtr;
int numDeleted, i, j;
Tcl_Size numDeleted, i, j;

numDeleted = last + 1 - first;
for (menuListPtr = menuPtr->mainMenuPtr; menuListPtr != NULL;
menuListPtr = menuListPtr->nextInstancePtr) {
for (i = last; i >= first; i--) {
Tcl_EventuallyFree(menuListPtr->entries[i], DestroyMenuEntry);
}
for (i = last + 1; i < (int)menuListPtr->numEntries; i++) {
for (i = last + 1; i < menuListPtr->numEntries; i++) {
j = i - numDeleted;
menuListPtr->entries[j] = menuListPtr->entries[i];
menuListPtr->entries[j]->index = j;
Expand Down
4 changes: 2 additions & 2 deletions generic/tkMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,9 @@ MODULE_SCOPE void TkpMenuInit(void);
MODULE_SCOPE int TkpMenuNewEntry(TkMenuEntry *mePtr);
MODULE_SCOPE int TkpNewMenu(TkMenu *menuPtr);
MODULE_SCOPE int TkpPostMenu(Tcl_Interp *interp, TkMenu *menuPtr,
int x, int y, int index);
int x, int y, Tcl_Size index);
MODULE_SCOPE int TkpPostTearoffMenu(Tcl_Interp *interp, TkMenu *menuPtr,
int x, int y, int index);
int x, int y, Tcl_Size index);
MODULE_SCOPE void TkpSetWindowMenuBar(Tk_Window tkwin, TkMenu *menuPtr);

#endif /* _TKMENU */
18 changes: 9 additions & 9 deletions macosx/tkMacOSXMenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ TkpPostMenu(
int x, int y, /* The screen coordinates where the top left
* corner of the menu, or of the specified
* entry, will be located. */
int index)
Tcl_Size index)
{
int result;
Tk_Window realWin = menuPtr->tkwin;
Expand Down Expand Up @@ -1029,7 +1029,7 @@ int
TkpPostTearoffMenu(
TCL_UNUSED(Tcl_Interp *), /* The interpreter this menu lives in */
TkMenu *menuPtr, /* The menu we are posting */
int x, int y, int index) /* The screen coordinates where the top left
int x, int y, Tcl_Size index) /* The screen coordinates where the top left
* corner of the menu, or of the specified
* entry, will be located. */
{
Expand Down Expand Up @@ -1057,7 +1057,7 @@ TkpPostTearoffMenu(
* at the given coordinates.
*/

if (index < 0 || (Tcl_Size)index >= menuPtr->numEntries) {
if (index < 0 || index >= menuPtr->numEntries) {
index = menuPtr->numEntries - 1;
}
if (index >= 0) {
Expand Down Expand Up @@ -1402,8 +1402,8 @@ TkpComputeStandardMenuGeometry(
Tk_FontMetrics menuMetrics, entryMetrics;
int modifierCharWidth, menuModifierCharWidth;
int x, y, modifierWidth, labelWidth, indicatorSpace;
int windowWidth, windowHeight, accelWidth;
int i, maxWidth;
int windowWidth, maxWidth, windowHeight, accelWidth;
Tcl_Size i;
int entryWidth, maxIndicatorSpace, borderWidth, activeBorderWidth;
TkMenuEntry *mePtr;
int haveAccel = 0;
Expand Down Expand Up @@ -1439,15 +1439,15 @@ TkpComputeStandardMenuGeometry(
Tk_GetFontMetrics(menuFont, &menuMetrics);
menuModifierCharWidth = ModifierCharWidth(menuFont);

for (i = 0; i < (int) menuPtr->numEntries; i++) {
for (i = 0; i < menuPtr->numEntries; i++) {
mePtr = menuPtr->entries[i];
if (mePtr->type == CASCADE_ENTRY || mePtr->accelLength > 0) {
haveAccel = 1;
break;
}
}

for (i = 0; i < (int) menuPtr->numEntries; i++) {
for (i = 0; i < menuPtr->numEntries; i++) {
mePtr = menuPtr->entries[i];
if (mePtr->type == TEAROFF_ENTRY) {
continue;
Expand Down Expand Up @@ -1671,10 +1671,10 @@ void
RecursivelyClearActiveMenu(
TkMenu *menuPtr) /* The menu to reset. */
{
int i;
Tcl_Size i;

TkActivateMenuEntry(menuPtr, TCL_INDEX_NONE);
for (i = 0; i < (int) menuPtr->numEntries; i++) {
for (i = 0; i < menuPtr->numEntries; i++) {
TkMenuEntry *mePtr = menuPtr->entries[i];

if (mePtr->type == CASCADE_ENTRY
Expand Down
6 changes: 3 additions & 3 deletions tests/canvas.test
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ test canvas-1.32 {configuration options: bad value for "insertwidth"} -body {
.c configure -insertwidth 6x
} -returnCodes error -result {bad screen distance "6x"}
test canvas-1.33 {configuration options: good value for "relief"} -body {
.c configure -relief groove
.c configure -relief g
.c cget -relief
} -result {groove}
test canvas-1.34 {configuration options: bad value for "relief"} -body {
.c configure -relief 1.5
} -returnCodes error -result {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}
.c configure -relief r
} -returnCodes error -result {bad relief "r": must be flat, groove, raised, ridge, solid, or sunken}
test canvas-1.35 {configuration options: good value for "selectbackground"} -body {
.c configure -selectbackground #110022
.c cget -selectbackground
Expand Down
22 changes: 12 additions & 10 deletions unix/tkUnixMenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ int
TkpPostMenu(
Tcl_Interp *interp,
TkMenu *menuPtr,
int x, int y, int index)
int x, int y, Tcl_Size index)
{
return TkpPostTearoffMenu(interp, menuPtr, x, y, index);
}
Expand Down Expand Up @@ -936,7 +936,7 @@ int
TkpPostTearoffMenu(
TCL_UNUSED(Tcl_Interp *), /* The interpreter of the menu */
TkMenu *menuPtr, /* The menu we are posting */
int x, int y, int index) /* The root X,Y coordinates where the
int x, int y, Tcl_Size index) /* The root X,Y coordinates where the
* specified entry will be posted */
{
int vRootX, vRootY, vRootWidth, vRootHeight;
Expand All @@ -963,7 +963,7 @@ TkpPostTearoffMenu(
* at the given coordinates.
*/

if (index >= (int)menuPtr->numEntries) {
if (index >= menuPtr->numEntries) {
index = menuPtr->numEntries - 1;
}
if (index >= 0) {
Expand Down Expand Up @@ -1098,8 +1098,9 @@ TkpComputeMenubarGeometry(
{
Tk_Font tkfont, menuFont;
Tk_FontMetrics menuMetrics, entryMetrics, *fmPtr;
int width, height, i, j, x, y, currentRowHeight, maxWidth;
int maxWindowWidth, lastRowBreak, lastEntry;
int width, height, x, y, currentRowHeight, maxWidth;
Tcl_Size i, j, lastRowBreak;
int maxWindowWidth, lastEntry;
int activeBorderWidth, helpMenuIndex = -1;
TkMenuEntry *mePtr;

Expand Down Expand Up @@ -1137,7 +1138,7 @@ TkpComputeMenubarGeometry(
menuFont = Tk_GetFontFromObj(menuPtr->tkwin, menuPtr->fontPtr);
Tk_GetFontMetrics(menuFont, &menuMetrics);

for (i = 0; i < (int)menuPtr->numEntries; i++) {
for (i = 0; i < menuPtr->numEntries; i++) {
mePtr = menuPtr->entries[i];
mePtr->entryFlags &= ~ENTRY_LAST_COLUMN;
if (mePtr->fontPtr != NULL) {
Expand Down Expand Up @@ -1214,7 +1215,7 @@ TkpComputeMenubarGeometry(
maxWidth = x + menuPtr->entries[lastEntry]->width + borderWidth;
}
x = borderWidth;
for (j = lastRowBreak; j < (int)menuPtr->numEntries; j++) {
for (j = lastRowBreak; j < menuPtr->numEntries; j++) {
if (j == helpMenuIndex) {
continue;
}
Expand Down Expand Up @@ -1685,7 +1686,8 @@ TkpComputeStandardMenuGeometry(
Tk_Font tkfont, menuFont;
Tk_FontMetrics menuMetrics, entryMetrics, *fmPtr;
int x, y, height, width, indicatorSpace, labelWidth, accelWidth;
int windowWidth, windowHeight, accelSpace, i, j, lastColumnBreak = 0;
int windowWidth, windowHeight, accelSpace;
Tcl_Size i, j, lastColumnBreak = 0;
TkMenuEntry *mePtr;
int borderWidth, activeBorderWidth;

Expand Down Expand Up @@ -1715,7 +1717,7 @@ TkpComputeStandardMenuGeometry(
Tk_GetFontMetrics(menuFont, &menuMetrics);
accelSpace = Tk_TextWidth(menuFont, "M", 1);

for (i = 0; i < (int)menuPtr->numEntries; i++) {
for (i = 0; i < menuPtr->numEntries; i++) {
mePtr = menuPtr->entries[i];
if (mePtr->fontPtr == NULL) {
tkfont = menuFont;
Expand Down Expand Up @@ -1810,7 +1812,7 @@ TkpComputeStandardMenuGeometry(
if (accelWidth != 0) {
labelWidth += accelSpace;
}
for (j = lastColumnBreak; j < (int)menuPtr->numEntries; j++) {
for (j = lastColumnBreak; j < menuPtr->numEntries; j++) {
menuPtr->entries[j]->indicatorSpace = indicatorSpace;
menuPtr->entries[j]->labelWidth = labelWidth;
menuPtr->entries[j]->width = indicatorSpace + labelWidth
Expand Down
Loading

0 comments on commit 1270239

Please sign in to comment.