Add code by Nikolaus Schaller <hns@computer.org>, reformatted and

simplified.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36982 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2013-08-17 13:39:16 +00:00
parent c209f41c6a
commit 6590fa6a1f
7 changed files with 397 additions and 5 deletions

View file

@ -7,6 +7,7 @@
Author: Gregory Casamento <greg.casamento@gmail.com>
Date: 2013
Author: Dr. H. Nikolaus Schaller
This file is part of the GNUstep GUI Library.
@ -31,7 +32,188 @@
// apps which require NSStatusItem. Currently there is not a clean,
// cross-platform way to implement this functionality.
#import <Foundation/NSAttributedString.h>
#import <Foundation/NSString.h>
#import <AppKit/NSStatusItem.h>
#import <AppKit/NSMenuItem.h>
#import <AppKit/NSView.h>
@implementation NSStatusItem
- (id) _initForStatusBar: (NSStatusBar*)bar
withLength: (CGFloat)len
{
if ((self = [super init]))
{
_statusBar = bar;
_menuItem = [[NSMenuItem alloc] initWithTitle: @"?"
action: NULL
keyEquivalent: @""];
[_menuItem setRepresentedObject: self];
[self setLength: len];
}
return self;
}
- (void) dealloc
{
RELEASE(_menuItem);
[super dealloc];
}
- (SEL) action
{
return [_menuItem action];
}
- (NSAttributedString*) attributedTitle
{
return [_menuItem attributedTitle];
}
- (SEL) doubleAction
{
// NIMP
return NULL;
}
- (void) drawStatusBarBackgroundInRect: (NSRect)rect withHighlight: (BOOL)flag
{
// NIMP
}
- (BOOL) highlightMode
{
return _highlightMode;
}
- (NSImage*) image
{
return [_menuItem image];
}
- (BOOL) isEnabled
{
return [_menuItem isEnabled];
}
- (CGFloat) length
{
return _length;
}
- (NSMenu *) menu
{
return [_menuItem submenu];
}
- (void) popUpStatusItemMenu: (NSMenu*)menu
{
// NIMP
}
- (void) sendActionOn: (NSInteger)mask
{
//NIMP
}
- (void) setAction: (SEL)action
{
[_menuItem setAction: action];
}
- (void) setAttributedTitle: (NSAttributedString*) title
{
[_menuItem setAttributedTitle: title];
}
- (void) setDoubleAction: (SEL)sel
{
// NIMP
}
- (void) setEnabled: (BOOL)flag
{
[_menuItem setEnabled: flag];
}
- (void) setHighlightMode: (BOOL)highlightMode
{
_highlightMode = highlightMode;
}
- (void) setImage: (NSImage*)image
{
[_menuItem setImage: image];
}
- (void) setLength: (CGFloat)len
{
_length = len;
//[_menuItem _changed];
}
- (void) setMenu: (NSMenu*)menu
{
[_menuItem setSubmenu: menu];
}
- (void) setTarget: (id)target
{
[_menuItem setTarget: target];
}
- (void) setTitle: (NSString*)title
{
[_menuItem setTitle: title];
}
- (void) setToolTip: (NSString*)toolTip
{
[_menuItem setToolTip: toolTip];
}
- (void) setView: (NSView*)view
{
ASSIGN(_view, view);
}
- (NSStatusBar*) statusBar
{
return _statusBar;
}
- (id) target
{
return [_menuItem target];
}
- (NSString*) title
{
return [_menuItem title];
}
- (NSString*) toolTip
{
return [_menuItem toolTip];
}
- (NSView*) view
{
return _view;
}
- (NSImage*) alternateImage
{
//NIMP
return nil;
}
- (void) setAlternateImage: (NSImage*)img
{
//NIMP
}
@end