mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-24 06:28:54 +00:00
Cache attribute dictionary used when drawing the menu title
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@10283 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d09426e14b
commit
6ff351d2f9
1 changed files with 19 additions and 15 deletions
|
@ -217,7 +217,7 @@ static NSString *NSMenuLocationsKey = @"NSMenuLocations";
|
|||
contentView = [aWindow contentView];
|
||||
[contentView addSubview: menu_view];
|
||||
[contentView addSubview: titleView];
|
||||
|
||||
|
||||
[titleView setMenu: self];
|
||||
|
||||
// Set up the notification to start the process of redisplaying
|
||||
|
@ -1339,7 +1339,8 @@ static NSString *NSMenuLocationsKey = @"NSMenuLocations";
|
|||
|
||||
frameRect.origin = aPoint;
|
||||
DPSplacewindow(GSCurrentContext(), frameRect.origin.x, frameRect.origin.y,
|
||||
frameRect.size.width, frameRect.size.height, [self windowNumber]);
|
||||
frameRect.size.width, frameRect.size.height,
|
||||
[self windowNumber]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -1366,15 +1367,15 @@ static NSString *NSMenuLocationsKey = @"NSMenuLocations";
|
|||
NSRect workRect = [self bounds];
|
||||
NSRectEdge sides[] = {NSMinXEdge, NSMaxYEdge};
|
||||
float grays[] = {NSDarkGray, NSDarkGray};
|
||||
NSDictionary *attr;
|
||||
/* Cache the title attributes */
|
||||
static NSDictionary *attr = nil;
|
||||
|
||||
// Draw the dark gray upper left lines.
|
||||
workRect = NSDrawTiledRects(workRect, workRect,
|
||||
sides, grays, 2);
|
||||
|
||||
workRect = NSDrawTiledRects(workRect, workRect, sides, grays, 2);
|
||||
|
||||
// Draw the title box's button.
|
||||
NSDrawButton(workRect, workRect);
|
||||
|
||||
|
||||
// Paint it Black!
|
||||
workRect.origin.x += 1;
|
||||
workRect.origin.y += 2;
|
||||
|
@ -1383,18 +1384,21 @@ static NSString *NSMenuLocationsKey = @"NSMenuLocations";
|
|||
[[NSColor windowFrameColor] set];
|
||||
NSRectFill(workRect);
|
||||
|
||||
// Draw the title.
|
||||
attr = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
[NSFont boldSystemFontOfSize: 0], NSFontAttributeName,
|
||||
[NSColor windowFrameTextColor], NSForegroundColorAttributeName,
|
||||
nil];
|
||||
// Draw the title
|
||||
if (attr == nil)
|
||||
{
|
||||
attr = [[NSDictionary alloc]
|
||||
initWithObjectsAndKeys:
|
||||
[NSFont boldSystemFontOfSize: 0], NSFontAttributeName,
|
||||
[NSColor windowFrameTextColor], NSForegroundColorAttributeName,
|
||||
nil];
|
||||
}
|
||||
|
||||
// This gives the correct position, but I don't quite understand it.
|
||||
// This gives the correct position
|
||||
workRect.origin.x += 5;
|
||||
workRect.size.width -= 5;
|
||||
workRect.size.height -= 2;
|
||||
[[menu title] drawInRect: workRect withAttributes: attr];
|
||||
RELEASE(attr);
|
||||
[[menu title] drawInRect: workRect withAttributes: attr];
|
||||
}
|
||||
|
||||
- (void) mouseDown: (NSEvent*)theEvent
|
||||
|
|
Loading…
Reference in a new issue