This patch will calculate the position to draw the menu
title instead of using fixed offsets. Fixed offsets
will draw the title at the wrong location if the height
of the menu title bar somehow does not fit very well
with the font that is being used.
I copied the logic of the calculation from the NSCell
code. A better fix would probably be to rewrite
the NSMenuTitleView by being a cell. But this will
work as well.
2003-03-08 Willem Rein Oudshoorn <[EMAIL PROTECTED]>
* Source/NSMenuView.m ([NSMenuWindowTitleView -drawRect:]):
Centre drawing of title instead of using fixed offset.
Wim Oudshoorn.
Index: Source/NSMenuView.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSMenuView.m,v
retrieving revision 1.70
diff -u -r1.70 NSMenuView.m
--- Source/NSMenuView.m 7 Mar 2003 06:03:15 -0000 1.70
+++ Source/NSMenuView.m 8 Mar 2003 11:05:52 -0000
@@ -1425,6 +1425,7 @@
- (void) drawRect: (NSRect)rect
{
NSRect workRect = [self bounds];
+ NSSize titleSize;
NSRectEdge sides[] = {NSMinXEdge, NSMaxYEdge};
float grays[] = {NSDarkGray, NSDarkGray};
/* Cache the title attributes */
@@ -1454,11 +1455,10 @@
nil];
}
- // This gives the correct position
- // WO: No it doesn't!
+ titleSize = [[menu title] sizeWithAttributes: attr];
workRect.origin.x += 5;
- workRect.size.width -= 5;
- workRect.size.height -= 2;
+ workRect.origin.y = NSMidY (workRect) - titleSize.height / 2;
+ workRect.size.height = titleSize.height;
[[menu title] drawInRect: workRect withAttributes: attr];
}
_______________________________________________
Bug-gnustep mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-gnustep