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 need to simulate the background
menu clicked
47 [statusItem drawStatusBarBackgroundInRect
:[self bounds
]
48 withHighlight
:isMenuVisible
];
49 image = [backgrounderDelegator imageToRender
];
51 // Live updating even when
menu is down handled by making the extra
52 // draw the background
if needed.
53 [image compositeToPoint
:NSMakePoint
(0, 0) operation
:NSCompositeSourceOver
];
55 //Draw
, if necessary
, the kerberos indicator
for aklog usage
for get token
56 if([backgrounderDelegator useAklogPrefValue
] == NSOnState
) {
57 kerberosStringIndicator
= [[self makeKerberosIndicator
:&fontHeight
] autorelease
];
58 if(kerberosStringIndicator
) [kerberosStringIndicator drawAtPoint
:NSMakePoint
(0, kMenuBarHeight
-fontHeight
)];
63 @method makeKerberosIndicator
64 @abstract Make the kerberos indicator
65 @discussion Make a letter to render in menu view to inform the user if is enable aklog use
67 - (NSAttributedString
*) makeKerberosIndicator
:(int
*)fontHeight
{
68 NSFont
*font
= [NSFont systemFontOfSize
:9.0];
69 NSDictionary
*attrsDictionary
= [NSDictionary dictionaryWithObject
:font
70 forKey
:NSFontAttributeName
];
71 NSAttributedString
*attrString
= [[NSAttributedString alloc
] initWithString
:@"K"
72 attributes
:attrsDictionary
];
73 *fontHeight
= [attrString
size].height
;
77 -(void
)mouseDown
:(NSEvent
*)event
{
78 [statusItemMenu setDelegate
:self
];
79 [statusItem popUpStatusItemMenu
:statusItemMenu
];
80 [self setNeedsDisplay
:YES
];
83 - (void
)menuWillOpen
:(NSMenu
*)menu {
85 [self setNeedsDisplay
:YES
];
88 - (void
)menuDidClose
:(NSMenu
*)menu {
90 [statusItemMenu setDelegate
:nil
];
91 [self setNeedsDisplay
:YES
];
94 // -------------------------------------------------------------------------------
95 // - (void
)menuNeedsUpdate
:(NSMenu
*)menu
96 // -------------------------------------------------------------------------------
97 - (void
)menuNeedsUpdate
:(NSMenu
*)menu {
98 [backgrounderDelegator menuNeedsUpdate
:menu];