From 0f1f8839500afed56199f756b95bcb0a34e17c77 Mon Sep 17 00:00:00 2001 From: Nicola Pero Date: Sun, 21 Jan 2001 01:35:36 +0000 Subject: [PATCH] Modification to allow changing menu font and size git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@8720 72102866-910b-0410-8b05-ffd578937521 --- Source/NSMenu.m | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/Source/NSMenu.m b/Source/NSMenu.m index 48528a96d..662c56a69 100644 --- a/Source/NSMenu.m +++ b/Source/NSMenu.m @@ -51,6 +51,20 @@ #include #include +@interface NSMenuWindowTitleView (height) ++ (float) titleHeight; +@end + +@implementation NSMenuWindowTitleView (height) ++ (float) titleHeight +{ + NSFont *font = [NSFont boldSystemFontOfSize: 0.0]; + + /* Should make up 23 for the default font */ + return ([font boundingRectForFont].size.height) + 8; +} +@end + static NSZone *menuZone = NULL; static NSString *NSMenuLocationsKey = @"NSMenuLocations"; @@ -158,7 +172,8 @@ static NSString *NSMenuLocationsKey = @"NSMenuLocations"; - (id) initWithTitle: (NSString*)aTitle { - NSRect winRect = {{0,0},{20,23}}; + float height = [NSMenuWindowTitleView titleHeight]; + NSRect winRect = { {0 , 0}, {20, height} }; NSView *contentView; [super init]; @@ -196,8 +211,8 @@ static NSString *NSMenuLocationsKey = @"NSMenuLocations"; bWindow = [[NSMenuWindow alloc] init]; titleView = [[NSMenuWindowTitleView alloc] init]; - [titleView setFrameOrigin: NSMakePoint(0, winRect.size.height - 23)]; - [titleView setFrameSize: NSMakeSize (winRect.size.width, 23)]; + [titleView setFrameOrigin: NSMakePoint(0, winRect.size.height - height)]; + [titleView setFrameSize: NSMakeSize (winRect.size.width, height)]; contentView = [aWindow contentView]; [contentView addSubview: menu_view]; @@ -833,7 +848,9 @@ static NSString *NSMenuLocationsKey = @"NSMenuLocations"; if (!menu_is_beholdenToPopUpButton) { - size.height += 23; + float height = [NSMenuWindowTitleView titleHeight]; + + size.height += height; [aWindow setContentSize: size]; [aWindow setFrameTopLeftPoint: NSMakePoint(NSMinX(windowFrame),NSMaxY(windowFrame))]; @@ -841,8 +858,9 @@ static NSString *NSMenuLocationsKey = @"NSMenuLocations"; [bWindow setContentSize: size]; [bWindow setFrameTopLeftPoint: NSMakePoint(NSMinX(windowFrame),NSMaxY(windowFrame))]; - [menu_view setFrameOrigin: NSMakePoint(0, 0)]; - [titleView setFrame: NSMakeRect(0,size.height-23,size.width,23)]; + [menu_view setFrameOrigin: NSMakePoint (0, 0)]; + [titleView setFrame: NSMakeRect (0, size.height - height, + size.width, height)]; } else {