diff options
author | jingham <jingham> | 1999-06-16 05:36:46 (GMT) |
---|---|---|
committer | jingham <jingham> | 1999-06-16 05:36:46 (GMT) |
commit | 17b3a9afdbac6f249bd15e33f5d4d30239b3d4d1 (patch) | |
tree | 5a67bd0ae7ad96224d7b11b313736d4c9c5fd48c /mac | |
parent | 52b3b0b8d6400edb039bb91df5b0cba105ee1290 (diff) | |
download | tk-17b3a9afdbac6f249bd15e33f5d4d30239b3d4d1.zip tk-17b3a9afdbac6f249bd15e33f5d4d30239b3d4d1.tar.gz tk-17b3a9afdbac6f249bd15e33f5d4d30239b3d4d1.tar.bz2 |
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.
Diffstat (limited to 'mac')
-rw-r--r-- | mac/tkMacMenu.c | 26 |
1 files 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 <Menus.h> #include <OSUtils.h> @@ -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; } } |