[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Menu sizing patch (Misc. comments)
From: |
Malmberg |
Subject: |
Re: Menu sizing patch (Misc. comments) |
Date: |
Sat, 20 Jan 2001 18:59:19 +0100 |
I've attached a patch that makes NSMenu and NSMenuView use the font
sizes to size themselves (using [[NSFont someFontOfSize: 0.0]
boundingRectForFont].size). I'm no expert on GNUstep coding/class/etc.
conventions, so I'm not sure adding a new method to
NSMenuWindowTitleView is the proper way of fixing this, but it works and
could easily be changed.
- Alexander Malmberg
Index: NSMenu.m
===================================================================
RCS file: /gnustep/gnustep/core/gui/Source/NSMenu.m,v
retrieving revision 1.78
diff -u -r1.78 NSMenu.m
--- NSMenu.m 2001/01/16 12:23:17 1.78
+++ NSMenu.m 2001/01/20 15:20:47
@@ -51,6 +51,12 @@
#include <AppKit/NSPopUpButtonCell.h>
#include <AppKit/NSScreen.h>
+
+@interface NSMenuWindowTitleView (height)
++ (float) titleSize;
+@end
+
+
static NSZone *menuZone = NULL;
static NSString *NSMenuLocationsKey = @"NSMenuLocations";
@@ -158,7 +164,7 @@
- (id) initWithTitle: (NSString*)aTitle
{
- NSRect winRect = {{0,0},{20,23}};
+ NSRect winRect = {{0,0},{20,[NSMenuWindowTitleView
titleSize]}};
NSView *contentView;
[super init];
@@ -196,8 +202,8 @@
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 -
[NSMenuWindowTitleView titleSize])];
+ [titleView setFrameSize: NSMakeSize (winRect.size.width,
[NSMenuWindowTitleView titleSize])];
contentView = [aWindow contentView];
[contentView addSubview: menu_view];
@@ -833,7 +839,7 @@
if (!menu_is_beholdenToPopUpButton)
{
- size.height += 23;
+ size.height += [NSMenuWindowTitleView titleSize];
[aWindow setContentSize: size];
[aWindow setFrameTopLeftPoint:
NSMakePoint(NSMinX(windowFrame),NSMaxY(windowFrame))];
@@ -842,7 +848,8 @@
[bWindow setFrameTopLeftPoint:
NSMakePoint(NSMinX(windowFrame),NSMaxY(windowFrame))];
[menu_view setFrameOrigin: NSMakePoint(0, 0)];
- [titleView setFrame: NSMakeRect(0,size.height-23,size.width,23)];
+ [titleView setFrame: NSMakeRect(0,size.height-[NSMenuWindowTitleView
titleSize],
+ size.width,[NSMenuWindowTitleView titleSize])];
}
else
{
@@ -1327,6 +1334,11 @@
@end
@implementation NSMenuWindowTitleView
+
++ (float) titleSize
+{
+ return [[NSFont boldSystemFontOfSize: 0.0]
boundingRectForFont].size.height*1.2;
+}
- (BOOL) acceptsFirstMouse: (NSEvent *)theEvent
{
Index: NSMenuView.m
===================================================================
RCS file: /gnustep/gnustep/core/gui/Source/NSMenuView.m,v
retrieving revision 1.47
diff -u -r1.47 NSMenuView.m
--- NSMenuView.m 2000/09/02 17:13:59 1.47
+++ NSMenuView.m 2001/01/20 15:20:51
@@ -34,7 +34,7 @@
#include <AppKit/NSWindow.h>
#include <AppKit/PSOperators.h>
-static float GSMenuBarHeight = 25.0; // A wild guess.
+//static float GSMenuBarHeight = 25.0; // A wild guess.
// FIXME Check this strange comment:
// These private methods are used in NSPopUpButton. For NSPB we need to be
@@ -51,7 +51,7 @@
*/
+ (float) menuBarHeight
{
- return GSMenuBarHeight;
+ return [[NSFont menuFontOfSize: 0.0] boundingRectForFont].size.height*1.1;
}
/*
@@ -72,7 +72,8 @@
- (id) initWithFrame: (NSRect)aFrame
{
- cellSize = NSMakeSize(110,20);
+ NSRect r=[[NSFont menuFontOfSize: 0.0] boundingRectForFont];
+ cellSize = NSMakeSize(r.size.width*5.5,r.size.height*1.1);
menuv_highlightedItemIndex = -1;
menuv_horizontalEdgePad = 4.;
Re: Misc. comments, Nicola Pero, 2001/01/15