5 // Created by Claudio Bisegni on 11/07/07.
6 // Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
9 #import "AFSMenuExtraView.h"
10 #import "AFSPropertyManager.h"
13 @implementation AFSMenuExtraView
15 - initWithFrame:(NSRect)myRect
16 backgrounder:(AFSBackgrounderDelegate*)backgrounder
20 self = [super initWithFrame:myRect];
26 backgrounderDelegator = backgrounder;
27 statusItem = [backgrounderDelegator statusItem];
28 statusItemMenu = menu;
40 - (void)drawRect:(NSRect)rect
44 NSAttributedString *kerberosStringIndicator = nil;
46 //check if we nedd to simulate the background menu clicked
47 [statusItem drawStatusBarBackgroundInRect:[self bounds]
48 withHighlight:isMenuVisible];
50 image = [backgrounderDelegator imageToRender];
52 // Live updating even when menu is down handled by making the extra
53 // draw the background if needed.
54 [image compositeToPoint:NSMakePoint(0, 0) operation:NSCompositeSourceOver];
60 //Draw, if necessary, the kerberos indicator for aklog usage for get token
61 if([backgrounderDelegator useAklogPrefValue] == NSOnState) {
62 kerberosStringIndicator = [[self makeKerberosIndicator:&fontHeight] autorelease];
63 if(kerberosStringIndicator) [kerberosStringIndicator drawAtPoint:NSMakePoint(0, kMenuBarHeight-fontHeight)];
68 @method makeKerberosIndicator
69 @abstract Make the kerberos indicator
70 @discussion Make a letter to render in menu view to inform the user if is enable aklog use
72 - (NSAttributedString*) makeKerberosIndicator:(int*)fontHeight {
73 NSFont *font = [NSFont fontWithName:@"Palatino-Roman" size:9.0];
74 NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:font
75 forKey:NSFontAttributeName];
76 NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"K"
77 attributes:attrsDictionary];
78 *fontHeight = [attrString size].height;
82 -(void)mouseDown:(NSEvent *)event {
83 [statusItemMenu setDelegate:self];
84 [statusItem popUpStatusItemMenu:statusItemMenu];
85 [self setNeedsDisplay:YES];
88 - (void)menuWillOpen:(NSMenu *)menu {
90 [self setNeedsDisplay:YES];
93 - (void)menuDidClose:(NSMenu *)menu {
95 [statusItemMenu setDelegate:nil];
96 [self setNeedsDisplay:YES];
99 // -------------------------------------------------------------------------------
100 // - (void)menuNeedsUpdate:(NSMenu *)menu
101 // -------------------------------------------------------------------------------
102 - (void)menuNeedsUpdate:(NSMenu *)menu {
103 [backgrounderDelegator menuNeedsUpdate:menu];