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:
Fred Kiefer 2013-08-17 13:39:16 +00:00
parent ceb8720fb2
commit ef49975949
7 changed files with 397 additions and 5 deletions

View file

@ -1,3 +1,13 @@
2013-08-17 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSStatusBar.h,
* Source/NSStatusBar.m: Add new class implementation.
* Headers/AppKit/AppKit.h: Add new header for NSStatusBar.h
* Source/GNUmakefile: Add new class.
* Headers/AppKit/NSStatusItem.h,
* Source/NSStatusItem.m:
Add fill in code by Nikolaus Schaller <hns@computer.org>.
2013-08-12 Lubos Dolezel <lubos@dolezel.info>
* Headers/AppKit/NSSavePanel.h,
@ -13,12 +23,12 @@
2013-07-22 Quentin Mathe <quentin.mathe@gmail.com>
* Source/NSImage.m (+_pathForImageNamed:, +_pathForSystemImageNamed:type:,
+_pathForThemeImageNamed:type:, +_resourceNameForImageNamed:type:):
Fixed missing theme images if not listed in the theme bundle Info.plist.
Theme bundles that contain theme images named using either GNUstep or
* Source/NSImage.m (+_pathForImageNamed:, +_pathForSystemImageNamed:type:,
+_pathForThemeImageNamed:type:, +_resourceNameForImageNamed:type:):
Fixed missing theme images if not listed in the theme bundle Info.plist.
Theme bundles that contain theme images named using either GNUstep or
OPENSTEP names now work properly again (bug introduced in r36836).
Finished to clean and reduce duplication in the image searching code
Finished to clean and reduce duplication in the image searching code
related to -_pathForImageNamed:.
* Images/nsmapping.strings: Updated documentation.

View file

@ -111,6 +111,7 @@
#import <AppKit/NSSpellChecker.h>
#import <AppKit/NSSpellProtocol.h>
#import <AppKit/NSSplitView.h>
#import <AppKit/NSStatusBar.h>
#import <AppKit/NSStatusItem.h>
#import <AppKit/NSStringDrawing.h>
#import <AppKit/NSText.h>

View file

@ -0,0 +1,57 @@
/*
NSStatusBar.h
The status bar class
Copyright (C) 2013 Free Software Foundation, Inc.
Author: Dr. H. Nikolaus Schaller
Date: 2013
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _GNUstep_H_NSStatusBar
#define _GNUstep_H_NSStatusBar
#import <Foundation/Foundation.h>
@class NSStatusItem;
@interface NSStatusBar : NSObject
{
@private
NSMutableArray *_items;
}
#ifndef NSSquareStatusItemLength
// length == thickness
#define NSSquareStatusItemLength ((CGFloat) -2.0)
// variable
#define NSVariableStatusItemLength ((CGFloat) -1.0)
#endif
+ (NSStatusBar*) systemStatusBar;
- (BOOL) isVertical;
- (void) removeStatusItem: (NSStatusItem*)item;
- (NSStatusItem*) statusItemWithLength: (CGFloat)length;
- (CGFloat) thickness;
@end
#endif // _GNUstep_H_NSStatusBar

View file

@ -33,9 +33,62 @@
#ifndef _GNUstep_H_NSStatusItem
#define _GNUstep_H_NSStatusItem
#import <GNUstepBase/GSVersionMacros.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSGeometry.h>
@class NSAttributedString;
@class NSString;
@class NSStatusBar;
@class NSView;
@class NSImage;
@class NSMenu;
@class NSMenuItem;
@interface NSStatusItem : NSObject
{
@private
NSMenuItem *_menuItem;
NSStatusBar *_statusBar;
NSView *_view;
CGFloat _length;
BOOL _highlightMode;
}
- (SEL) action;
- (NSAttributedString*) attributedTitle;
- (SEL) doubleAction;
- (void) drawStatusBarBackgroundInRect: (NSRect)rect withHighlight: (BOOL)flag;
- (BOOL) highlightMode;
- (NSImage*) image;
- (BOOL) isEnabled;
- (CGFloat) length;
- (NSMenu*) menu;
- (void) popUpStatusItemMenu: (NSMenu*)menu;
- (void) sendActionOn: (NSInteger)mask;
- (void) setAction: (SEL)action;
- (void) setAttributedTitle: (NSAttributedString*)title;
- (void) setDoubleAction: (SEL)sel;
- (void) setEnabled: (BOOL)flag;
- (void) setHighlightMode: (BOOL)highlightMode;
- (void) setImage: (NSImage*)image;
- (void) setLength: (CGFloat)length;
- (void) setMenu: (NSMenu*)menu;
- (void) setTarget: (id)target;
- (void) setTitle: (NSString*)title;
- (void) setToolTip: (NSString*)toolTip;
- (void) setView: (NSView*)view;
- (NSStatusBar*) statusBar;
- (id) target;
- (NSString*) title;
- (NSString*) toolTip;
- (NSView*) view;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (NSImage*) alternateImage;
- (void) setAlternateImage: (NSImage*)img;
#endif
@end
#endif // _GNUstep_H_NSStatusItem

View file

@ -163,6 +163,7 @@ NSSplitView.m \
NSStepper.m \
NSStepperCell.m \
NSStringDrawing.m \
NSStatusBar.m \
NSStatusItem.m \
NSTabView.m \
NSTabViewItem.m \
@ -376,6 +377,7 @@ NSSplitView.h \
NSStepper.h \
NSStepperCell.h \
NSStringDrawing.h \
NSStatusBar.h \
NSStatusItem.h \
NSTabView.h \
NSTabViewItem.h \

87
Source/NSStatusBar.m Normal file
View file

@ -0,0 +1,87 @@
/*
NSStatusBar.m
The status bar class
Copyright (C) 2013 Free Software Foundation, Inc.
Author: Dr. H. Nikolaus Schaller
Date: 2013
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import <Foundation/NSArray.h>
#import <AppKit/NSStatusBar.h>
#import <AppKit/NSStatusItem.h>
@interface NSStatusItem (Private)
- (id) _initForStatusBar: (NSStatusBar*)bar
withLength: (CGFloat)len;
@end
@implementation NSStatusBar
- (id) init
{
self = [super init];
if (self)
{
_items = [[NSMutableArray alloc] init];
}
return self;
}
- (void) dealloc
{
RELEASE(_items);
[super dealloc];
}
+ (NSStatusBar*) systemStatusBar
{
return nil;
}
- (BOOL) isVertical
{
return NO;
}
- (void) removeStatusItem: (NSStatusItem*)item
{
[_items removeObjectIdenticalTo: item];
}
- (NSStatusItem*) statusItemWithLength: (CGFloat)length
{
NSStatusItem *item = [[NSStatusItem alloc] _initForStatusBar: self
withLength: length];
[_items addObject: item];
return AUTORELEASE(item);
}
- (CGFloat) thickness
{
return 22;
}
@end

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