From 17b3a9afdbac6f249bd15e33f5d4d30239b3d4d1 Mon Sep 17 00:00:00 2001 From: jingham Date: Wed, 16 Jun 1999 05:36:46 +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. --- 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