mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 17:12:24 +00:00
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:
parent
c209f41c6a
commit
6590fa6a1f
7 changed files with 397 additions and 5 deletions
20
ChangeLog
20
ChangeLog
|
@ -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>
|
2013-08-12 Lubos Dolezel <lubos@dolezel.info>
|
||||||
|
|
||||||
* Headers/AppKit/NSSavePanel.h,
|
* Headers/AppKit/NSSavePanel.h,
|
||||||
|
@ -13,12 +23,12 @@
|
||||||
|
|
||||||
2013-07-22 Quentin Mathe <quentin.mathe@gmail.com>
|
2013-07-22 Quentin Mathe <quentin.mathe@gmail.com>
|
||||||
|
|
||||||
* Source/NSImage.m (+_pathForImageNamed:, +_pathForSystemImageNamed:type:,
|
* Source/NSImage.m (+_pathForImageNamed:, +_pathForSystemImageNamed:type:,
|
||||||
+_pathForThemeImageNamed:type:, +_resourceNameForImageNamed:type:):
|
+_pathForThemeImageNamed:type:, +_resourceNameForImageNamed:type:):
|
||||||
Fixed missing theme images if not listed in the theme bundle Info.plist.
|
Fixed missing theme images if not listed in the theme bundle Info.plist.
|
||||||
Theme bundles that contain theme images named using either GNUstep or
|
Theme bundles that contain theme images named using either GNUstep or
|
||||||
OPENSTEP names now work properly again (bug introduced in r36836).
|
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:.
|
related to -_pathForImageNamed:.
|
||||||
* Images/nsmapping.strings: Updated documentation.
|
* Images/nsmapping.strings: Updated documentation.
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,7 @@
|
||||||
#import <AppKit/NSSpellChecker.h>
|
#import <AppKit/NSSpellChecker.h>
|
||||||
#import <AppKit/NSSpellProtocol.h>
|
#import <AppKit/NSSpellProtocol.h>
|
||||||
#import <AppKit/NSSplitView.h>
|
#import <AppKit/NSSplitView.h>
|
||||||
|
#import <AppKit/NSStatusBar.h>
|
||||||
#import <AppKit/NSStatusItem.h>
|
#import <AppKit/NSStatusItem.h>
|
||||||
#import <AppKit/NSStringDrawing.h>
|
#import <AppKit/NSStringDrawing.h>
|
||||||
#import <AppKit/NSText.h>
|
#import <AppKit/NSText.h>
|
||||||
|
|
57
Headers/AppKit/NSStatusBar.h
Normal file
57
Headers/AppKit/NSStatusBar.h
Normal 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
|
|
@ -33,9 +33,62 @@
|
||||||
|
|
||||||
#ifndef _GNUstep_H_NSStatusItem
|
#ifndef _GNUstep_H_NSStatusItem
|
||||||
#define _GNUstep_H_NSStatusItem
|
#define _GNUstep_H_NSStatusItem
|
||||||
|
#import <GNUstepBase/GSVersionMacros.h>
|
||||||
#import <Foundation/NSObject.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
|
@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
|
@end
|
||||||
|
|
||||||
#endif // _GNUstep_H_NSStatusItem
|
#endif // _GNUstep_H_NSStatusItem
|
||||||
|
|
|
@ -163,6 +163,7 @@ NSSplitView.m \
|
||||||
NSStepper.m \
|
NSStepper.m \
|
||||||
NSStepperCell.m \
|
NSStepperCell.m \
|
||||||
NSStringDrawing.m \
|
NSStringDrawing.m \
|
||||||
|
NSStatusBar.m \
|
||||||
NSStatusItem.m \
|
NSStatusItem.m \
|
||||||
NSTabView.m \
|
NSTabView.m \
|
||||||
NSTabViewItem.m \
|
NSTabViewItem.m \
|
||||||
|
@ -376,6 +377,7 @@ NSSplitView.h \
|
||||||
NSStepper.h \
|
NSStepper.h \
|
||||||
NSStepperCell.h \
|
NSStepperCell.h \
|
||||||
NSStringDrawing.h \
|
NSStringDrawing.h \
|
||||||
|
NSStatusBar.h \
|
||||||
NSStatusItem.h \
|
NSStatusItem.h \
|
||||||
NSTabView.h \
|
NSTabView.h \
|
||||||
NSTabViewItem.h \
|
NSTabViewItem.h \
|
||||||
|
|
87
Source/NSStatusBar.m
Normal file
87
Source/NSStatusBar.m
Normal 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
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
Author: Gregory Casamento <greg.casamento@gmail.com>
|
Author: Gregory Casamento <greg.casamento@gmail.com>
|
||||||
Date: 2013
|
Date: 2013
|
||||||
|
Author: Dr. H. Nikolaus Schaller
|
||||||
|
|
||||||
This file is part of the GNUstep GUI Library.
|
This file is part of the GNUstep GUI Library.
|
||||||
|
|
||||||
|
@ -31,7 +32,188 @@
|
||||||
// apps which require NSStatusItem. Currently there is not a clean,
|
// apps which require NSStatusItem. Currently there is not a clean,
|
||||||
// cross-platform way to implement this functionality.
|
// cross-platform way to implement this functionality.
|
||||||
|
|
||||||
|
#import <Foundation/NSAttributedString.h>
|
||||||
|
#import <Foundation/NSString.h>
|
||||||
|
|
||||||
#import <AppKit/NSStatusItem.h>
|
#import <AppKit/NSStatusItem.h>
|
||||||
|
#import <AppKit/NSMenuItem.h>
|
||||||
|
#import <AppKit/NSView.h>
|
||||||
|
|
||||||
@implementation NSStatusItem
|
@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
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue