From 667bf9fcb8bf6d59f6fb9c809e2cc37c2fd0164f Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 26 Sep 2018 06:26:41 +0000 Subject: Fix [9658bc800c]: Right border calculated wrong in Tk menu if borderwidth != activeborderwidth. Patch provided by ingo_brunberg --- generic/tkMenuDraw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkMenuDraw.c b/generic/tkMenuDraw.c index 1abe1c4..14a60ca 100644 --- a/generic/tkMenuDraw.c +++ b/generic/tkMenuDraw.c @@ -673,7 +673,7 @@ DisplayMenu( } else { if (mePtr->entryFlags & ENTRY_LAST_COLUMN) { width = Tk_Width(menuPtr->tkwin) - mePtr->x - - activeBorderWidth; + - borderWidth; } else { width = mePtr->width + borderWidth; } -- cgit v0.12 From 65ba89c907a5b7c966d6ba5904daf97f4e39d199 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 28 Sep 2018 22:11:57 +0000 Subject: Fix more issues with menues drawing, that are visible when -activeborderwidth is very different from -borderwidth --- generic/tkMenuDraw.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/generic/tkMenuDraw.c b/generic/tkMenuDraw.c index 14a60ca..8a82a27 100644 --- a/generic/tkMenuDraw.c +++ b/generic/tkMenuDraw.c @@ -624,7 +624,6 @@ DisplayMenu( int width; int borderWidth; Tk_3DBorder border; - int activeBorderWidth; int relief; @@ -636,8 +635,6 @@ DisplayMenu( Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr, &borderWidth); border = Tk_Get3DBorderFromObj(menuPtr->tkwin, menuPtr->borderPtr); - Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, - menuPtr->activeBorderWidthPtr, &activeBorderWidth); if (menuPtr->menuType == MENUBAR) { Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border, borderWidth, @@ -687,9 +684,8 @@ DisplayMenu( Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border, mePtr->x, mePtr->y + mePtr->height, mePtr->width, - Tk_Height(tkwin) - mePtr->y - mePtr->height - - activeBorderWidth, 0, - TK_RELIEF_FLAT); + Tk_Height(tkwin) - mePtr->y - mePtr->height - borderWidth, + 0, TK_RELIEF_FLAT); } } @@ -698,19 +694,18 @@ DisplayMenu( if (menuPtr->numEntries == 0) { x = y = borderWidth; - width = Tk_Width(tkwin) - 2 * activeBorderWidth; - height = Tk_Height(tkwin) - 2 * activeBorderWidth; + width = Tk_Width(tkwin) - 2 * borderWidth; + height = Tk_Height(tkwin) - 2 * borderWidth; } else { mePtr = menuPtr->entries[menuPtr->numEntries - 1]; Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border, mePtr->x, mePtr->y + mePtr->height, mePtr->width, - Tk_Height(tkwin) - mePtr->y - mePtr->height - - activeBorderWidth, 0, - TK_RELIEF_FLAT); + Tk_Height(tkwin) - mePtr->y - mePtr->height - borderWidth, + 0, TK_RELIEF_FLAT); x = mePtr->x + mePtr->width; y = mePtr->y + mePtr->height; - width = Tk_Width(tkwin) - x - activeBorderWidth; - height = Tk_Height(tkwin) - y - activeBorderWidth; + width = Tk_Width(tkwin) - x - borderWidth; + height = Tk_Height(tkwin) - y - borderWidth; } Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border, x, y, width, height, 0, TK_RELIEF_FLAT); -- cgit v0.12 From ea0200f3f7bb5e9837114f2a9f674a9ef330ec2b Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 29 Sep 2018 08:00:36 +0000 Subject: Once the menu geometry is correctly computed there is no need anymore for questionable hacks in menu width calculation when displaying it --- generic/tkMenuDraw.c | 15 ++------------- macosx/tkMacOSXMenu.c | 2 +- unix/tkUnixMenu.c | 2 +- win/tkWinMenu.c | 6 +++--- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/generic/tkMenuDraw.c b/generic/tkMenuDraw.c index 8a82a27..3f492db 100644 --- a/generic/tkMenuDraw.c +++ b/generic/tkMenuDraw.c @@ -665,25 +665,14 @@ DisplayMenu( } mePtr->entryFlags &= ~ENTRY_NEEDS_REDISPLAY; - if (menuPtr->menuType == MENUBAR) { - width = mePtr->width; - } else { - if (mePtr->entryFlags & ENTRY_LAST_COLUMN) { - width = Tk_Width(menuPtr->tkwin) - mePtr->x - - borderWidth; - } else { - width = mePtr->width + borderWidth; - } - } TkpDrawMenuEntry(mePtr, Tk_WindowId(menuPtr->tkwin), tkfont, - &menuMetrics, mePtr->x, mePtr->y, width, + &menuMetrics, mePtr->x, mePtr->y, mePtr->width, mePtr->height, strictMotif, 1); if ((index > 0) && (menuPtr->menuType != MENUBAR) && mePtr->columnBreak) { mePtr = menuPtr->entries[index - 1]; Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border, - mePtr->x, mePtr->y + mePtr->height, - mePtr->width, + mePtr->x, mePtr->y + mePtr->height, mePtr->width, Tk_Height(tkwin) - mePtr->y - mePtr->height - borderWidth, 0, TK_RELIEF_FLAT); } diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 404f625..ea7a97f 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -1139,7 +1139,7 @@ TkpComputeStandardMenuGeometry( columnEntryPtr->x = x; columnEntryPtr->entryFlags &= ~ENTRY_LAST_COLUMN; } - x += maxIndicatorSpace + maxWidth + 2 * borderWidth; + x += maxIndicatorSpace + maxWidth + 2 * activeBorderWidth; maxWidth = maxIndicatorSpace = 0; lastColumnBreak = i; y = borderWidth; diff --git a/unix/tkUnixMenu.c b/unix/tkUnixMenu.c index bc1bd2e..acee61f 100644 --- a/unix/tkUnixMenu.c +++ b/unix/tkUnixMenu.c @@ -1718,7 +1718,7 @@ TkpComputeStandardMenuGeometry( menuPtr->entries[j]->entryFlags |= ENTRY_LAST_COLUMN; } windowWidth = x + indicatorSpace + labelWidth + accelWidth - + 2 * activeBorderWidth + 2 * borderWidth; + + 2 * activeBorderWidth + borderWidth; windowHeight += borderWidth; diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 5dc8f8a..99da158 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -2874,7 +2874,7 @@ TkpComputeStandardMenuGeometry( menuPtr->entries[j]->entryFlags &= ~ENTRY_LAST_COLUMN; } x += indicatorSpace + labelWidth + accelWidth - + 2 * borderWidth; + + 2 * activeBorderWidth; indicatorSpace = labelWidth = accelWidth = 0; lastColumnBreak = i; y = borderWidth; @@ -2944,8 +2944,8 @@ TkpComputeStandardMenuGeometry( menuPtr->entries[j]->x = x; menuPtr->entries[j]->entryFlags |= ENTRY_LAST_COLUMN; } - windowWidth = x + indicatorSpace + labelWidth + accelWidth + accelSpace - + 2 * activeBorderWidth + 2 * borderWidth; + windowWidth = x + indicatorSpace + labelWidth + accelWidth + + 2 * activeBorderWidth + borderWidth; windowHeight += borderWidth; -- cgit v0.12 From 396d37035ef04c028b26e8329bc454353bf94299 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 29 Sep 2018 08:27:29 +0000 Subject: Guard against negative widths for the indicator of menu entries, that could be obtained with larger -borderwidth value. This had no impact given how the geometry calculation algorithm is made, but... (belt and suspenders). --- win/tkWinMenu.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 99da158..69005e8 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -1482,6 +1482,15 @@ GetMenuIndicatorGeometry( Tk_GetPixelsFromObj(menuPtr->interp, menuPtr->tkwin, menuPtr->borderWidthPtr, &borderWidth); *widthPtr = indicatorDimensions[1] - borderWidth; + + /* + * Quite dubious about the above (why would borderWidth play a role?) + * and about how indicatorDimensions[1] is obtained in SetDefaults(). + * At least don't let the result be negative! + */ + if (*widthPtr < 0) { + *widthPtr = 0; + } } } @@ -3281,6 +3290,7 @@ SetDefaults( * * The code below was given to me by Microsoft over the phone. It is the * only way to ensure menu items line up, and is not documented. + * How strange the calculation of indicatorDimensions[1] is...! */ indicatorDimensions[0] = GetSystemMetrics(SM_CYMENUCHECK); -- cgit v0.12 From ec60445b0cc27430b44a55eb513656838f6a6064 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 29 Sep 2018 09:35:07 +0000 Subject: Fix drawing of the tearoff entry --- unix/tkUnixMenu.c | 2 +- win/tkWinMenu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unix/tkUnixMenu.c b/unix/tkUnixMenu.c index acee61f..e2bd6ad 100644 --- a/unix/tkUnixMenu.c +++ b/unix/tkUnixMenu.c @@ -1193,7 +1193,7 @@ DrawTearoffEntry( points[0].y = y + height/2; points[1].y = points[0].y; segmentWidth = 6; - maxX = width - 1; + maxX = x + width - 1; border = Tk_Get3DBorderFromObj(menuPtr->tkwin, menuPtr->borderPtr); while (points[0].x < maxX) { diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 69005e8..91bac32 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -2437,7 +2437,7 @@ DrawTearoffEntry( points[0].y = y + height/2; points[1].y = points[0].y; segmentWidth = 6; - maxX = width - 1; + maxX = x + width - 1; border = Tk_Get3DBorderFromObj(menuPtr->tkwin, menuPtr->borderPtr); while (points[0].x < maxX) { -- cgit v0.12 From 806e1a97bcd1635ec4b00fb3502c5690d5ce5a61 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 29 Sep 2018 09:54:54 +0000 Subject: Fix drawing of the menu separator on Linux (was already correct on Windows) --- unix/tkUnixMenu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/tkUnixMenu.c b/unix/tkUnixMenu.c index e2bd6ad..63f6ed7 100644 --- a/unix/tkUnixMenu.c +++ b/unix/tkUnixMenu.c @@ -638,7 +638,7 @@ DrawMenuSeparator( points[0].x = x; points[0].y = y + height/2; - points[1].x = width - 1; + points[1].x = x + width - 1; points[1].y = points[0].y; border = Tk_Get3DBorderFromObj(menuPtr->tkwin, menuPtr->borderPtr); Tk_Draw3DPolygon(menuPtr->tkwin, d, border, points, 2, 1, -- cgit v0.12