From 1ab597e11b964960febacdbf5d7a0e4222aa2638 Mon Sep 17 00:00:00 2001 From: jingham Date: Wed, 16 Jun 1999 05:36:45 +0000 Subject: Fix a bug in the region calculation for popup menus which would cause the popup to get posted in the wrong place if the menu was going to stick off the bottom of the screen. FossilOrigin-Name: ce98dd35444b216a6f3a9677cbe5cf392ed3a126 --- mac/tkMacMenu.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/mac/tkMacMenu.c b/mac/tkMacMenu.c index b4bcce5..4940269 100644 --- a/mac/tkMacMenu.c +++ b/mac/tkMacMenu.c @@ -8,13 +8,14 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacMenu.c,v 1.9 1999/05/22 06:33:19 jingham Exp $ + * RCS: @(#) $Id: tkMacMenu.c,v 1.10 1999/06/16 05:36:46 jingham Exp $ */ #include "tkMacInt.h" #include "tkMenuButton.h" #include "tkMenu.h" #include "tkColor.h" +#include "tkMacInt.h" #undef Status #include #include @@ -3159,12 +3160,29 @@ MenuDefProc( if (menuPtr->totalHeight > maxMenuHeight) { menuRectPtr->top = GetMBarHeight(); } else { + int delta; menuRectPtr->top = hitPt.h; if (oldItem >= 0) { menuRectPtr->top -= menuPtr->entries[oldItem]->y; } - if (menuRectPtr->top + menuPtr->totalHeight > maxMenuHeight) { - menuRectPtr->top -= maxMenuHeight - menuPtr->totalHeight; + + if (menuRectPtr->top < GetMBarHeight()) { + /* Displace downward if the menu would stick off the + * top of the screen. + */ + + menuRectPtr->top = GetMBarHeight() + SCREEN_MARGIN; + } else { + /* + * Or upward if the menu sticks off the + * bottom end... + */ + + delta = menuRectPtr->top + menuPtr->totalHeight + - maxMenuHeight; + if (delta > 0) { + menuRectPtr->top -= delta; + } } } menuRectPtr->left = hitPt.v; @@ -3177,6 +3195,8 @@ MenuDefProc( } else { *whichItem = menuRectPtr->top; } + globalsPtr->menuTop = *whichItem; + globalsPtr->menuBottom = menuRectPtr->bottom; break; } } -- cgit v0.12