Merge selected changes from testplant branch.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@35681 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2012-10-13 18:43:38 +00:00
parent 4f5c219ed9
commit e85b16bc05
9 changed files with 175 additions and 20 deletions

View file

@ -1,3 +1,19 @@
2012-10-13 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSBox.h,
* Source/NSBox.m: Add 10.5 methods for custom drawn boxes.
* Source/GSXibLoader.m (IBObjectContainer nibInstantiate): Check
whether the object responds to setToolTip: before calling it.
Merge changes from testplant branch:
* Headers/AppKit/NSTabViewItem.h: Declare tooltip methods.
* Source/NSTabViewItem.m: Move tooltip methods to correct category.
* Headers/AppKit/NSTextStorage.h,
* Source/NSTextStorage.m: Add font/setFont methods to NSTextStorage
Patch by Marcian Lytwyn <marcian.lytwyn@advcsi.com>
* NSWindow.m (-center): Center on the main screen if window is off screen.
Patch by Doug Simons <doug.simons@testplant.com>
2012-10-12 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSComboBoxCell.m (-textDidChange:):

View file

@ -34,6 +34,7 @@
#import <AppKit/NSView.h>
@class NSString;
@class NSColor;
@class NSFont;
/** Title positioning of an NSBox:
@ -64,6 +65,9 @@ typedef enum _NSBoxType
NSBoxSecondary,
NSBoxSeparator,
NSBoxOldStyle
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
, NSBoxCustom
#endif
} NSBoxType;
#endif
@ -78,6 +82,12 @@ typedef enum _NSBoxType
NSBorderType _border_type;
NSTitlePosition _title_position;
NSBoxType _box_type;
// Only used when the type is NSBoxCustom
NSColor *_fill_color;
NSColor *_border_color;
CGFloat _border_width;
CGFloat _corner_radius;
BOOL _transparent;
}
//
@ -117,6 +127,19 @@ typedef enum _NSBoxType
#if OS_API_VERSION(GS_API_NONE, GS_API_NONE)
-(NSSize) minimumSize;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
- (NSColor*)fillColor;
- (void)setFillColor:(NSColor*)newFillColor;
- (NSColor*)borderColor;
- (void)setBorderColor:(NSColor*)newBorderColor;
- (CGFloat)borderWidth;
- (void)setBorderWidth:(CGFloat)borderWidth;
- (CGFloat)cornerRadius;
- (void)setCornerRadius:(CGFloat)cornerRadius;
- (BOOL)isTransparent;
- (void)setTransparent:(BOOL)transparent;
#endif
@end
#endif // _GNUstep_H_NSBox

View file

@ -77,6 +77,11 @@ typedef enum {
- (void)drawLabel:(BOOL)shouldTruncateLabel
inRect:(NSRect)tabRect;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
- (NSString *)toolTip;
- (void)setToolTip:(NSString *)newToolTip;
#endif
@end
@interface NSTabViewItem (GNUstep)

View file

@ -42,6 +42,7 @@
@class NSNotification;
@class NSString;
@class GSLayoutManager;
@class NSFont;
/*
* When edit:range:changeInLength: is called, it takes a mask saying
@ -181,6 +182,14 @@ enum
@end
@interface NSTextStorage (Scripting)
/*
* Attributes for string...
*/
- (NSFont*) font;
- (void) setFont: (NSFont*)font;
@end
/**** Notifications ****/
/* The object of the notification is the NSTextStorage itself. */

View file

@ -804,7 +804,10 @@
{
IBToolTipAttribute *tta = [(NSDictionary*)value objectForKey: @"ToolTip"];
[realObj setToolTip: [tta toolTip]];
if ([realObj respondsToSelector: @selector(setToolTip:)])
{
[realObj setToolTip: [tta toolTip]];
}
}
if ([realObj respondsToSelector: @selector(awakeFromNib)])
@ -844,7 +847,7 @@
NSMutableArray *topLevelObjects = [context objectForKey: NSNibTopLevelObjects];
id owner = [context objectForKey: NSNibOwner];
id first = nil;
id app = [(NSCustomObject*)[rootObjects objectAtIndex: 2] realObject];
id app = nil;
// Get the file's owner and NSApplication object references...
if ([[(NSCustomObject*)[rootObjects objectAtIndex: 1] className] isEqualToString: @"FirstResponder"])

View file

@ -72,7 +72,6 @@
NSView *cv;
self = [super initWithFrame: frameRect];
if (!self)
return self;
@ -80,6 +79,8 @@
[_cell setAlignment: NSCenterTextAlignment];
[_cell setBordered: NO];
[_cell setEditable: NO];
[self setTitleFont: [NSFont systemFontOfSize:
[NSFont smallSystemFontSize]]];
_offsets.width = 5;
_offsets.height = 5;
_border_rect = _bounds;
@ -451,8 +452,17 @@
//
- (void) drawRect: (NSRect)rect
{
NSColor *color = [_window backgroundColor];
NSColor *color;
rect = NSIntersectionRect(_bounds, rect);
if (_box_type == NSBoxCustom)
{
color = _fill_color;
}
else
{
color = [_window backgroundColor];
}
// Fill inside
[color set];
NSRectFill(rect);
@ -463,8 +473,16 @@
case NSNoBorder:
break;
case NSLineBorder:
[[NSColor controlDarkShadowColor] set];
NSFrameRect(_border_rect);
if (_box_type == NSBoxCustom)
{
[_border_color set];
NSFrameRectWithWidth(_border_rect, _border_width);
}
else
{
[[NSColor controlDarkShadowColor] set];
NSFrameRect(_border_rect);
}
break;
case NSBezelBorder:
[[GSTheme theme] drawDarkBezel: _border_rect withClip: rect];
@ -490,7 +508,64 @@
- (BOOL) isOpaque
{
return YES;
if (_box_type == NSBoxCustom)
{
return !_transparent;
}
else
{
return YES;
}
}
- (NSColor*) fillColor
{
return _fill_color;
}
- (void) setFillColor: (NSColor*)newFillColor
{
ASSIGN(_fill_color, newFillColor);
}
- (NSColor*) borderColor
{
return _border_color;
}
- (void) setBorderColor: (NSColor*)newBorderColor
{
ASSIGN(_border_color, newBorderColor);
}
- (CGFloat) borderWidth
{
return _border_width;
}
- (void) setBorderWidth: (CGFloat)borderWidth
{
_border_width = borderWidth;
}
- (CGFloat) cornerRadius
{
return _corner_radius;
}
- (void) setCornerRadius: (CGFloat)cornerRadius
{
_corner_radius = cornerRadius;
}
- (BOOL) isTransparent
{
return _transparent;
}
- (void) setTransparent: (BOOL)transparent
{
_transparent = transparent;
}
//
@ -507,7 +582,7 @@
[aCoder encodeInt: [self borderType] forKey: @"NSBorderType"];
[aCoder encodeInt: [self boxType] forKey: @"NSBoxType"];
[aCoder encodeInt: [self titlePosition] forKey: @"NSTitlePosition"];
[aCoder encodeBool: NO forKey: @"NSTransparent"];
[aCoder encodeBool: _transparent forKey: @"NSTransparent"];
[aCoder encodeSize: [self contentViewMargins] forKey: @"NSOffsets"];
}
else
@ -548,7 +623,7 @@
}
if ([aDecoder containsValueForKey: @"NSTransparent"])
{
//Bool transparent = [aDecoder decodeBoolForKey: @"NSTransparent"];
_transparent = [aDecoder decodeBoolForKey: @"NSTransparent"];
}
if ([aDecoder containsValueForKey: @"NSOffsets"])
{

View file

@ -198,6 +198,16 @@
RELEASE(attr);
}
- (void) setToolTip: (NSString*)toolTip
{
ASSIGN(_toolTip, toolTip);
}
- (NSString*) toolTip
{
return _toolTip;
}
// NSCoding protocol.
- (void) encodeWithCoder: (NSCoder*)aCoder
@ -276,14 +286,4 @@
return _label;
}
- (void) setToolTip: (NSString *)toolTip
{
ASSIGN(_toolTip,toolTip);
}
- (NSString *)toolTip
{
return _toolTip;
}
@end

View file

@ -380,3 +380,22 @@ static NSNotificationCenter *nc = nil;
}
@end
@implementation NSTextStorage (Scripting)
- (NSFont*) font
{
return [self attribute: NSFontAttributeName atIndex: 0 effectiveRange: NULL];
}
- (void) setFont: (NSFont*)font
{
if (font != nil)
{
[self addAttribute: NSFontAttributeName
value: font
range: NSMakeRange(0, [self length])];
}
}
@end

View file

@ -2081,9 +2081,14 @@ titleWithRepresentedFilename(NSString *representedFilename)
- (void) center
{
NSSize screenSize = [[self screen] visibleFrame].size;
NSScreen *screen = [self screen];
NSSize screenSize;
NSPoint origin = _frame.origin;
if (screen == nil) {
screen = [NSScreen mainScreen];
}
screenSize = [screen visibleFrame].size;
origin.x = (screenSize.width - _frame.size.width) / 2;
origin.y = (screenSize.height - _frame.size.height) / 2;