Merge from revision 35723 from main branch plus NSCell allowsUndo flag extract from xib

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@35724 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Marcian Lytwyn 2012-10-19 22:51:20 +00:00
parent b155bbdc2d
commit 36e77b95f7
40 changed files with 828 additions and 459 deletions

View file

@ -438,7 +438,6 @@ APPKIT_EXPORT NSString *NSEventTrackingRunLoopMode;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
/**
* Sender requests application to open filenames.
* <em>Not sent yet under GNUstep.</em>
*/
- (void) application: (NSApplication*)app openFiles: (NSArray*)filenames;
#endif

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;
}
//
@ -99,10 +109,6 @@ typedef enum _NSBoxType
- (NSBoxType)boxType;
- (void)setBoxType:(NSBoxType)aType;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
- (NSColor*)fillColor;
- (void)setFillColor:(NSColor*)newFillColor;
#endif
//
// Setting and Placing the Content View
@ -121,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

@ -215,10 +215,6 @@ APPKIT_EXPORT NSString *NSControlTextDidChangeNotification;
- (BOOL) control: (NSControl *)control
textShouldEndEditing: (NSText *)fieldEditor;
- (void) controlTextDidBeginEditing: (NSNotification *)aNotification;
- (void) controlTextDidEndEditing: (NSNotification *)aNotification;
- (void) controlTextDidChange: (NSNotification *)aNotification;
- (BOOL) control: (NSControl *)control
didFailToFormatString: (NSString *)string
errorDescription: (NSString *)error;

View file

@ -92,6 +92,7 @@ APPKIT_EXPORT NSString *NSDataLinkFileNameExtension;
unsigned isDirty:1;
unsigned willOpenSource:1;
unsigned willUpdate:1;
unsigned isMarker:1;
} _flags;
}

View file

@ -33,6 +33,7 @@
#import <AppKit/NSPanel.h>
#import <AppKit/NSFontManager.h>
#import <AppKit/NSTextField.h> // needed for NSTextFieldDelegate
@class NSFont;
@class NSView;
@ -40,8 +41,6 @@
@class NSBrowser;
@class NSTextField;
@protocol NSTextFieldDelegate;
enum {
NSFPPreviewButton,
NSFPRevertButton,

View file

@ -33,8 +33,13 @@
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
/* IBOutlet and IBAction are now built-in macros in recent Clang */
#if !defined(IBOutlet)
#define IBOutlet
#endif
#if !defined(IBAction)
#define IBAction void
#endif
#endif
#endif

View file

@ -102,20 +102,27 @@ typedef enum {
+ (void)clearCurrentContext;
+ (NSOpenGLContext *)currentContext;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (void *)CGLContextObj;
#endif
- (void)clearDrawable;
- (void)copyAttributesFromContext:(NSOpenGLContext *)context
withMask:(unsigned long)mask;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
- (void)createTexture:(unsigned long)target
fromView:(NSView*)view
internalFormat:(unsigned long)format;
- (int)currentVirtualScreen;
#endif
- (void)flushBuffer;
- (void)getValues:(long *)vals
forParameter:(NSOpenGLContextParameter)param;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
- (id)initWithCGLContextObj:(void *)context;
#endif
- (id)initWithFormat:(NSOpenGLPixelFormat *)format
shareContext:(NSOpenGLContext *)share;
@ -140,7 +147,6 @@ typedef enum {
- (NSView *)view;
@end

View file

@ -54,6 +54,8 @@ typedef enum {
BOOL _draws_background;
BOOL _truncated_label;
id _delegate;
NSView *_original_nextKeyView;
NSUInteger _selected_item;
}
- (void)addTabViewItem:(NSTabViewItem *)tabViewItem;
- (void)insertTabViewItem:(NSTabViewItem *)tabViewItem

View file

@ -80,9 +80,8 @@ typedef enum {
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
- (NSString *)toolTip;
- (void) setToolTip:(NSString *)newToolTip;
- (void)setToolTip:(NSString *)newToolTip;
#endif
@end
@interface NSTabViewItem (GNUstep)
@ -92,7 +91,6 @@ typedef enum {
- (void)_setTabView:(NSTabView *)tabView;
- (NSRect) _tabRect;
- (NSString*)_truncatedLabel;
@end
#endif // _GNUstep_H_NSTabViewItem

View file

@ -133,12 +133,6 @@ enum
*/
- (void) endEditing;
/*
* Attributes for string...
*/
- (NSFont*) font;
- (void) setFont: (NSFont*)font;
/*
* The delegate can use the following methods when it receives a
* notification that a change was made. The methods tell him what
@ -188,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

@ -141,7 +141,6 @@ PACKAGE_SCOPE
BOOL _is_rotated_from_base;
BOOL _is_rotated_or_scaled_from_base;
BOOL _post_frame_changes;
BOOL _posting_frame_changes;
BOOL _post_bounds_changes;
BOOL _autoresizes_subviews;
BOOL _coordinates_valid;

View file

@ -94,10 +94,6 @@ GSDisplayServer *
GSCurrentServer(void)
{
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
if ([NSThread currentThread] != [NSThread mainThread])
NSLog(@"%s:attempt to access display server on background thread: %@", __PRETTY_FUNCTION__,
[NSThread currentThread]);
return (GSDisplayServer*) [dict objectForKey: NSCurrentServerThreadKey];
}

View file

@ -1275,8 +1275,8 @@ NS_DURING
*nextGlyphIndex = curGlyph;
NS_HANDLER
NSLog(@"GSHorizontalTypesetter - %@", [localException reason]);
// [lock unlock];
//[localException raise];
[lock unlock];
[localException raise];
ret=0; /* This is never reached, but it shuts up the compiler. */
NS_ENDHANDLER
[lock unlock];

View file

@ -55,12 +55,7 @@ value_from_info_plist_for_key (NSString *key)
if ((d == nil) && (load_failed == NO))
{
NSBundle *b;
NSString *f;
b = [NSBundle mainBundle];
f = [b pathForResource: @"Info-gnustep" ofType: @"plist"];
d = [NSDictionary dictionaryWithContentsOfFile: f];
d = [[NSBundle mainBundle] localizedInfoDictionary];
if (d == nil)
load_failed = YES;

View file

@ -591,6 +591,28 @@ static NSString *disabledName = @".GNUstepDisabled";
return result;
}
- (void) application: (NSApplication*)theApp
openFiles: (NSArray*)files
{
id del = [NSApp delegate];
if ([del respondsToSelector: _cmd])
{
[del application: theApp openFiles: files];
}
else
{
NSString *filePath;
NSEnumerator *en = [files objectEnumerator];
while ((filePath = (NSString *)[en nextObject]) != nil)
{
[self application: theApp openFile: filePath];
}
}
}
- (BOOL) application: (NSApplication*)theApp
openFileWithoutUI: (NSString*)file
{

View file

@ -77,6 +77,27 @@
@end
@implementation GSTheme (Drawing)
- (void) setKeyEquivalent: (NSString *)key
forButtonCell: (NSButtonCell *)cell
{
if([cell image] == nil && ([key isEqualToString:@"\r"] ||
[key isEqualToString:@"\n"]))
{
[cell setImagePosition: NSImageRight];
[cell setImage: [NSImage imageNamed:@"common_ret"]];
[cell setAlternateImage: [NSImage imageNamed:@"common_retH"]];
}
else if([key isEqualToString:@"\r"] == NO &&
[key isEqualToString:@"\n"] == NO)
{
NSImage *cellImage = [cell image];
if(cellImage == [NSImage imageNamed:@"common_ret"])
{
[cell setImage: nil];
[cell setAlternateImage: nil];
}
}
}
- (void) drawButton: (NSRect)frame
in: (NSCell*)cell
@ -1658,10 +1679,6 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
BOOL truncate = [(NSTabView *)view allowsTruncatedLabels];
NSTabViewType type = [(NSTabView *)view tabViewType];
// Make sure some tab is selected
if (!selected && howMany > 0)
[(NSTabView *)view selectFirstTabViewItem: nil];
DPSgsave(ctxt);
switch (type)

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"])
@ -1192,8 +1195,14 @@
- (id) initForReadingWithData: (NSData*)data
{
NSXMLParser *theParser;
NSData *theData = data;
NSData *theData = [self _preProcessXib: data];
// If we are in the interface builder app, do not replace
// the existing classes with their custom subclasses.
if([NSClassSwapper isInInterfaceBuilder] == NO)
{
theData = [self _preProcessXib: data];
}
objects = [[NSMutableDictionary alloc] init];
stack = [[NSMutableArray alloc] init];

View file

@ -383,6 +383,10 @@ struct _NSModalSession {
- (NSMenu *) _dockMenu;
@end
@interface NSWindow (TitleWithRepresentedFilename)
- (BOOL) _hasTitleWithRepresentedFilename;
@end
@interface NSWindow (ApplicationPrivate)
- (void) setAttachedSheet: (id) sheet;
@end
@ -1120,12 +1124,7 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
if ((files = [self _openFiles]) != nil)
{
NSEnumerator *en = [files objectEnumerator];
while ((filePath = (NSString *)[en nextObject]) != nil)
{
[_listener application: self openFile: filePath];
}
[_listener application: self openFiles: files];
}
else if ((filePath = [defs stringForKey: @"GSFilePath"]) != nil
|| (filePath = [defs stringForKey: @"NSOpen"]) != nil)
@ -1549,18 +1548,18 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
{
IF_NO_GC(_runLoopPool = [arpClass new]);
e = [self nextEventMatchingMask: NSAnyEventMask
untilDate: distantFuture
inMode: NSDefaultRunLoopMode
dequeue: YES];
if (e != nil)
{
NSEventType type = [e type];
// Catch and report any uncaught exceptions.
NS_DURING
{
e = [self nextEventMatchingMask: NSAnyEventMask
untilDate: distantFuture
inMode: NSDefaultRunLoopMode
dequeue: YES];
if (e != nil)
{
NSEventType type = [e type];
// Catch and report any uncaught exceptions.
NS_DURING
{
[self sendEvent: e];
// update (en/disable) the services menu's items
@ -1570,13 +1569,13 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
[_main_menu update];
}
}
NS_HANDLER
{
[self _handleException: localException];
}
NS_ENDHANDLER;
}
NS_HANDLER
{
[self _handleException: localException];
}
NS_ENDHANDLER;
DESTROY (_runLoopPool);
}
@ -2262,13 +2261,13 @@ IF_NO_GC(NSAssert([event retainCount] > 0, NSInternalInconsistencyException));
modal dialog panel work.
*/
NSWindow *toolbarWindow =
[[[(NSToolbarItem *)sender toolbar] _toolbarView] window];
[[[(NSToolbarItem *)sender toolbar] _toolbarView] window];
NSWindow *keyWindow = [self keyWindow];
if (keyWindow != toolbarWindow)
keyWindow = nil;
return [self _targetForAction: theAction
keyWindow: keyWindow
mainWindow: toolbarWindow];
keyWindow: keyWindow
mainWindow: toolbarWindow];
}
else
{
@ -2287,9 +2286,18 @@ IF_NO_GC(NSAssert([event retainCount] > 0, NSInternalInconsistencyException));
*/
- (id) targetForAction: (SEL)aSelector
{
/* During a modal session actions must not be sent to the main window of
* the application, but rather to the dialog window of the modal session.
* Note that the modal session window is not necessarily the key window,
* as a panel with worksWhenModal = YES, e.g., the font panel, can still
* become key window during a modal session.
*/
NSWindow *mainWindow = [self mainWindow];
if (_session != 0)
mainWindow = _session->window;
return [self _targetForAction: aSelector
keyWindow: [self keyWindow]
mainWindow: [self mainWindow]];
keyWindow: [self keyWindow]
mainWindow: mainWindow];
}
@ -3137,15 +3145,9 @@ image.</p><p>See Also: -applicationIconImage</p>
if (found == NO)
{
NSString *t = [aWindow title];
NSString *f = [aWindow representedFilename];
f = [NSString stringWithFormat: @"%@ -- %@",
[f lastPathComponent],
[f stringByDeletingLastPathComponent]];
[self changeWindowsItem: aWindow
title: t
filename: [t isEqual: f]];
title: [aWindow title]
filename: [aWindow _hasTitleWithRepresentedFilename]];
}
}
}
@ -3197,15 +3199,9 @@ image.</p><p>See Also: -applicationIconImage</p>
if (([win isExcludedFromWindowsMenu] == NO)
&& ([win isVisible] || [win isMiniaturized]))
{
NSString *t = [win title];
NSString *f = [win representedFilename];
f = [NSString stringWithFormat: @"%@ -- %@",
[f lastPathComponent],
[f stringByDeletingLastPathComponent]];
[self changeWindowsItem: win
title: t
filename: [t isEqual: f]];
title: [win title]
filename: [win _hasTitleWithRepresentedFilename]];
}
}
}
@ -3555,6 +3551,7 @@ struct _DelegateWrapper
* <item>application:shouldTerminateAfterLastWindowClosed:</item>
* <item>application:shouldOpenUntitledFile:</item>
* <item>application:openFile:</item>
* <item>application:openFiles:</item>
* <item>application:openFileWithoutUI:</item>
* <item>application:openTempFile:</item>
* <item>application:openUntitledFile:</item>
@ -3862,75 +3859,77 @@ struct _DelegateWrapper
[_listener application: self openFile: filePath];
}
- (id) _targetForAction: (SEL)aSelector window: (NSWindow *)window
{
id resp, delegate;
NSDocumentController *sdc;
if (window == nil)
{
return nil;
}
/* traverse the responder chain including the window's delegate */
resp = [window firstResponder];
while (resp != nil && resp != self)
{
if ([resp respondsToSelector: aSelector])
{
return resp;
}
if (resp == window)
{
delegate = [window delegate];
if ([delegate respondsToSelector: aSelector])
{
return delegate;
}
}
resp = [resp nextResponder];
}
/* in a document based app try the window's document */
sdc = [NSDocumentController sharedDocumentController];
if ([[sdc documentClassNames] count] > 0)
{
resp = [sdc documentForWindow: window];
if (resp != nil && [resp respondsToSelector: aSelector])
{
return resp;
}
}
/* nothing found */
return nil;
}
- (id) _targetForAction: (SEL)aSelector
keyWindow: (NSWindow *)keyWindow
mainWindow: (NSWindow *)mainWindow
{
NSDocumentController *sdc;
id resp, delegate;
NSWindow *window;
NSDocumentController *sdc;
id resp;
if (aSelector == NULL)
return nil;
return nil;
/* if we have a key window, start looking in its responder chain, ... */
if (keyWindow != nil)
/* start looking in the key window's responder chain */
resp = [self _targetForAction: aSelector window: keyWindow];
if (resp != nil)
{
window = keyWindow;
}
/* ... otherwise in the main window's responder chain */
else
{
if (_session != 0)
return nil;
window = mainWindow;
return resp;
}
if (window != nil)
/* next check the main window's responder chain (provided it is not
* the key window) */
if (mainWindow != keyWindow)
{
NSDocumentController *sdc;
/* traverse the responder chain including the window's delegate */
resp = [window firstResponder];
while (resp != nil && resp != self)
{
if ([resp respondsToSelector: aSelector])
{
return resp;
}
if (resp == window)
{
delegate = [window delegate];
if ([delegate respondsToSelector: aSelector])
{
return delegate;
}
}
resp = [resp nextResponder];
resp = [self _targetForAction: aSelector window: mainWindow];
if (resp != nil)
{
return resp;
}
/* in a document based app try the window's document */
sdc = [NSDocumentController sharedDocumentController];
if ([[sdc documentClassNames] count] > 0)
{
resp = [sdc documentForWindow: window];
if (resp != nil && [resp respondsToSelector: aSelector])
{
return resp;
}
}
}
/* if we've found no target in the key window start over without key window */
if (keyWindow != nil)
{
if (_session != 0)
return nil;
if (mainWindow != nil && mainWindow != keyWindow)
return [self _targetForAction: aSelector
keyWindow: nil
mainWindow: mainWindow];
}
/* try the shared application imstance and its delegate */
@ -3944,26 +3943,25 @@ struct _DelegateWrapper
return _delegate;
}
/*
* Try the NSApplication's responder list to determine if any of them
/* Try the NSApplication's responder list to determine if any of them
* respond to the selector.
*/
resp = [self nextResponder];
while(resp != nil)
while (resp != nil)
{
if([resp respondsToSelector: aSelector])
if ([resp respondsToSelector: aSelector])
{
return resp;
}
resp = [resp nextResponder];
}
/* as a last resort in a document based app, try the document controller */
/* as last resort in a document based app, try the document controller */
sdc = [NSDocumentController sharedDocumentController];
if ([[sdc documentClassNames] count] > 0
&& [sdc respondsToSelector: aSelector])
{
return [NSDocumentController sharedDocumentController];
return sdc;
}
/* give up */

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;
@ -149,16 +150,6 @@
}
}
- (NSColor*) fillColor
{
return [_window backgroundColor];
}
- (void) setFillColor:(NSColor*)fillColor
{
[_window setBackgroundColor: fillColor];
}
/**<p>Sets the title cell to <var>aString</var>, resizes the content
view frame if needed and marks self for display.</p>
<p>Warning: This method does not implement the Cocoa behaviour</p>
@ -461,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);
@ -473,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];
@ -500,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;
}
//
@ -517,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
@ -558,7 +623,7 @@
}
if ([aDecoder containsValueForKey: @"NSTransparent"])
{
//Bool transparent = [aDecoder decodeBoolForKey: @"NSTransparent"];
_transparent = [aDecoder decodeBoolForKey: @"NSTransparent"];
}
if ([aDecoder containsValueForKey: @"NSOffsets"])
{

View file

@ -629,6 +629,8 @@ typedef struct _GSButtonCellFlags
*/
- (void) setKeyEquivalent: (NSString*)key
{
[[GSTheme theme] setKeyEquivalent: key
forButtonCell: self];
ASSIGNCOPY(_keyEquivalent, key);
}
@ -1914,8 +1916,11 @@ typedef struct _GSButtonCellFlags
{
BOOL tmp;
int version = [aDecoder versionForClassName: @"NSButtonCell"];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_keyEquivalent];
NSString *key = nil;
[aDecoder decodeValueOfObjCType: @encode(id) at: &key];
[self setKeyEquivalent: key]; // Set the key equivalent...
[aDecoder decodeValueOfObjCType: @encode(id) at: &_keyEquivalentFont];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_altContents];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_altImage];

View file

@ -1991,14 +1991,6 @@ static NSColor *dtxtCol;
return nil;
}
/** Although not documented, Apple XIBs allow specifying a tool tip on an NSCell
it's unclear exactly where that tooltip should be set/applied
but not responding makes XIBs unloadable */
- (void) setToolTip: (NSString *) toolTip
{
return;
}
/**<p>This method is used by subclasses to specify the control view.</p>
*/
- (void) setControlView: (NSView*)view
@ -2402,6 +2394,7 @@ static NSColor *dtxtCol;
[aCoder encodeInt: cFlags forKey: @"NSCellFlags"];
// flags part 2
cFlags2 |= (([self allowsUndo] == NO) ? 0x1000 : 0);
cFlags2 |= ([self controlTint] << 5);
cFlags2 |= ([self lineBreakMode] << 9);
cFlags2 |= ([self controlSize] << 17);
@ -2568,7 +2561,7 @@ static NSColor *dtxtCol;
cFlags2 = [aDecoder decodeIntForKey: @"NSCellFlags2"];
[self setControlTint: ((cFlags2 & 0xE0) >> 5)];
[self setLineBreakMode: ((cFlags2 & 0xE00) >> 9)];
[self setLineBreakMode: ((cFlags2 & 0xE00) >> 9)];
[self setControlSize: ((cFlags2 & 0xE0000) >> 17)];
[self setSendsActionOnEndEditing: ((cFlags2 & 0x400000) == 0x400000)];
[self setAllowsMixedState: ((cFlags2 & 0x1000000) == 0x1000000)];
@ -2576,6 +2569,9 @@ static NSColor *dtxtCol;
[self setAlignment: ((cFlags2 & 0x1C000000) >> 26)];
[self setImportsGraphics: ((cFlags2 & 0x20000000) == 0x20000000)];
[self setAllowsEditingTextAttributes: ((cFlags2 & 0x40000000) == 0x40000000)];
// These bit flags are the other way around!
[self setAllowsUndo: ((cFlags2 & 0x1000) != 0x1000)];
}
if ([aDecoder containsValueForKey: @"NSSupport"])
{

View file

@ -125,6 +125,7 @@ static inline NSRect integralRect (NSRect rect, NSView *view)
- (void) setDocumentView: (NSView*)aView
{
NSNotificationCenter *nc;
NSView *nextKV;
if (_documentView == aView)
{
@ -134,6 +135,12 @@ static inline NSRect integralRect (NSRect rect, NSView *view)
nc = [NSNotificationCenter defaultCenter];
if (_documentView)
{
nextKV = [_documentView nextKeyView];
if ([nextKV isDescendantOf: _documentView])
{
nextKV = nil;
}
[nc removeObserver: self
name: NSViewFrameDidChangeNotification
object: _documentView];
@ -152,6 +159,10 @@ static inline NSRect integralRect (NSRect rect, NSView *view)
}
[_documentView removeFromSuperview];
}
else
{
nextKV = [self nextKeyView];
}
/* Don't retain this since it's stored in our subviews. */
_documentView = aView;
@ -193,7 +204,7 @@ static inline NSRect integralRect (NSRect rect, NSView *view)
object: _documentView];
/*
* if out document view is a tableview, let it know
* if our document view is a tableview, let it know
* when we resize
*/
if ([_documentView isKindOfClass: [NSTableView class]])
@ -205,9 +216,12 @@ static inline NSRect integralRect (NSRect rect, NSView *view)
object: self];
}
[self setNextKeyView: _documentView];
if (![_documentView nextKeyView])
[_documentView setNextKeyView: nextKV];
}
/* TODO: Adjust the key view loop to include the new document view */
else
[self setNextKeyView: nextKV];
[_super_view reflectScrolledClipView: self];
}
@ -722,6 +736,14 @@ static inline NSRect integralRect (NSRect rect, NSView *view)
}
}
- (void) setNextKeyView: (NSView *)aView
{
if (_documentView && aView != _documentView)
[_documentView setNextKeyView: aView];
else
[super setNextKeyView: aView];
}
/*
* NSCoding protocol
*/

View file

@ -486,7 +486,9 @@ static NSColorList *themeColorList = nil;
if (path_is_standard && ([fm fileExistsAtPath: path] == NO))
{
if ([fm createDirectoryAtPath: path
attributes: nil])
withIntermediateDirectories: YES
attributes: nil
error: NULL])
{
NSLog (@"Created standard directory %@", path);
}

View file

@ -1255,29 +1255,29 @@ static GSComboWindow *gsWindow = nil;
{
if (_dataSource == nil)
{
NSLog(@"%@: No data source currently specified", self);
}
NSLog(@"%@: No data source currently specified", self);
}
else if ([_dataSource respondsToSelector: @selector(comboBox:completedString:)])
{
return [_dataSource comboBox: (NSComboBox *)[self controlView]
completedString: substring];
}
return [_dataSource comboBox: (NSComboBox *)[self controlView]
completedString: substring];
}
else if ([_dataSource respondsToSelector: @selector(comboBoxCell:completedString:)])
{
return [_dataSource comboBoxCell: self completedString: substring];
}
return [_dataSource comboBoxCell: self completedString: substring];
}
else
{
unsigned int i;
for (i = 0; i < [self numberOfItems]; i++)
{
NSString *str = [self _stringValueAtIndex: i];
NSString *str = [self _stringValueAtIndex: i];
if ([str length] > [substring length] && [str hasPrefix: substring])
return str;
}
}
if ([str length] > [substring length] && [str hasPrefix: substring])
return str;
}
}
}
else
{
@ -1285,10 +1285,10 @@ static GSComboWindow *gsWindow = nil;
for (i = 0; i < [_popUpList count]; i++)
{
NSString *str = [[_popUpList objectAtIndex: i] description];
NSString *str = [[_popUpList objectAtIndex: i] description];
if ([str length] > [substring length] && [str hasPrefix: substring])
return str;
if ([str length] > [substring length] && [str hasPrefix: substring])
return str;
}
}
@ -1749,14 +1749,14 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
&& _prevSelectedRange.location < selectedRange.location)
{
more = [self completedString: myString];
if (more && [more isEqualToString: myString] == NO)
if ((more != nil) && [more isEqualToString: myString] == NO)
{
[textObject setString: more];
location = myStringLength;
[textObject setString: more];
location = myStringLength;
length = [more length] - location;
[textObject setSelectedRange: NSMakeRange(location, length)];
[textObject scrollRangeToVisible: NSMakeRange(location, length)];
}
[textObject setSelectedRange: NSMakeRange(location, length)];
[textObject scrollRangeToVisible: NSMakeRange(location, length)];
}
}
RELEASE(myString);
}

View file

@ -49,6 +49,7 @@
#import "AppKit/NSTextView.h"
#import "AppKit/NSWindow.h"
#import "GSBindingHelpers.h"
#import "NSViewPrivate.h"
/*
* Class variables
@ -1120,3 +1121,14 @@ static NSNotificationCenter *nc;
}
@end
@implementation NSControl(KeyViewLoop)
- (void) _setUpKeyViewLoopWithNextKeyView: (NSView *)nextKeyView
{
// Controls are expected to have no subviews
//NSLog(@"%@@%p -_setUpKeyViewLoopWithKeyKeyView:%@@%p", [self class], self, [nextKeyView class], nextKeyView);
[self setNextKeyView: nextKeyView];
}
@end

View file

@ -63,10 +63,10 @@ static NSMutableDictionary *cursorDict = nil;
// Initialize class variables
NSCursor_class = self;
gnustep_gui_cursor_stack = [[NSMutableArray alloc] initWithCapacity: 2];
gnustep_gui_cursor_stack = [[NSMutableArray alloc] initWithCapacity: 1];
gnustep_gui_hidden_until_move = NO;
cursorDict = [NSMutableDictionary new];
[[self arrowCursor] push];
[[self arrowCursor] set];
}
}
@ -109,13 +109,14 @@ static NSMutableDictionary *cursorDict = nil;
/*
* The object we pop is the current cursor
*/
if ([gnustep_gui_cursor_stack count] > 1)
if ([gnustep_gui_cursor_stack count] > 0)
{
NSCursor *c = RETAIN([gnustep_gui_cursor_stack lastObject]);
[gnustep_gui_cursor_stack removeLastObject];
gnustep_gui_current_cursor = [gnustep_gui_cursor_stack lastObject];
NSDebugLLog(@"NSCursor", @"Cursor pop");
[gnustep_gui_current_cursor set];
[c set];
RELEASE(c);
}
}
@ -489,7 +490,7 @@ backgroundColorHint:(NSColor *)bg
*/
- (void) push
{
[gnustep_gui_cursor_stack addObject: self];
[gnustep_gui_cursor_stack addObject: gnustep_gui_current_cursor];
[self set];
NSDebugLLog(@"NSCursor", @"Cursor push %p", _cid);
}
@ -498,11 +499,25 @@ backgroundColorHint:(NSColor *)bg
*/
- (void) set
{
gnustep_gui_current_cursor = self;
ASSIGN(gnustep_gui_current_cursor, self);
if (_cid)
{
[GSCurrentServer() setcursor: _cid];
}
else
{
/*
* No image? This is odd, so we set an standard
* cursor image (GSArrowCursor).
*/
void *c = NULL;
[GSCurrentServer() standardcursor: GSArrowCursor : &c];
if (c != NULL)
{
[self _setCid: c];
[GSCurrentServer() setcursor: _cid];
}
}
}
/** <p>Sets whether if the cursor is set on -mouseEntered:.

View file

@ -80,6 +80,11 @@
{
ASSIGN(destinationSelection,dst);
}
- (void) setIsMarker: (BOOL)flag
{
_flags.isMarker = flag;
}
@end
@ -161,7 +166,7 @@
- (BOOL)addLinkAsMarker:(NSDataLink *)link
at:(NSSelection *)selection
{
// FIXME: Marker?
[link setIsMarker: YES];
return [self addLink: link at: selection];
}

View file

@ -1501,14 +1501,24 @@ static NSString *processName = nil;
if ([fm fileExistsAtPath: path isDirectory: &isDir] == NO)
{
if (![fm createDirectoryAtPath: path attributes: nil])
return nil;
if (![fm createDirectoryAtPath: path
withIntermediateDirectories: YES
attributes: nil
error: NULL])
{
return nil;
}
}
else if (isDir == NO)
{
if (![fm removeFileAtPath: path handler: nil] ||
![fm createDirectoryAtPath: path attributes: nil])
return nil;
if (![fm removeFileAtPath: path handler: nil]
|| ![fm createDirectoryAtPath: path
withIntermediateDirectories: YES
attributes: nil
error: NULL])
{
return nil;
}
}
}

View file

@ -203,7 +203,10 @@
NSEnumerator *enumerator = [_wrapperData keyEnumerator];
NSString *key;
[fm createDirectoryAtPath: path attributes: _fileAttributes];
[fm createDirectoryAtPath: path
withIntermediateDirectories: YES
attributes: _fileAttributes
error: NULL];
while ((key = (NSString*)[enumerator nextObject]))
{
NSString *newPath =

View file

@ -119,7 +119,7 @@
{
NSDictionary *traits;
traits = [_attributes objectForKey: NSFontTraitsAttribute];
traits = [self objectForKey: NSFontTraitsAttribute];
if (traits == nil)
{
traits = [NSDictionary dictionaryWithObject:
@ -219,7 +219,7 @@
return [[NSFontManager sharedFontManager] matchingFontDescriptorsFor: attributes];
}
- (NSFontDescriptor *) matchingFontDescriptorWithMandatoryKeys: (NSSet *)keys;
- (NSFontDescriptor *) matchingFontDescriptorWithMandatoryKeys: (NSSet *)keys
{
NSArray *found = [self matchingFontDescriptorsWithMandatoryKeys: keys];
@ -235,7 +235,7 @@
- (NSAffineTransform *) matrix
{
return [_attributes objectForKey: NSFontMatrixAttribute];
return [self objectForKey: NSFontMatrixAttribute];
}
- (id) objectForKey: (NSString *)attribute
@ -245,11 +245,11 @@
- (CGFloat) pointSize
{
id size = [_attributes objectForKey: NSFontSizeAttribute];
id size = [self objectForKey: NSFontSizeAttribute];
if (size)
{
return [size floatValue];
return [size doubleValue];
}
else
{
@ -277,7 +277,7 @@
{
NSDictionary *traits;
traits = [_attributes objectForKey: NSFontTraitsAttribute];
traits = [self objectForKey: NSFontTraitsAttribute];
if (traits == nil)
{
return 0;

View file

@ -1653,28 +1653,28 @@ static NSSize GSResolutionOfImageRep(NSImageRep *rep)
reps = [coder decodeObjectForKey: @"NSReps"];
reps = [reps objectAtIndex: 0];
id rep = [reps objectAtIndex: 1];
if([rep isKindOfClass:[NSImageRep class]])
if ([rep isKindOfClass: [NSImageRep class]])
{
[self addRepresentation: rep];
}
else
{
if([rep isKindOfClass:[NSURL class]])
if ([rep isKindOfClass: [NSURL class]])
{
NSURL *tmp = [[rep copy] autorelease];
rep = [NSImageRep imageRepWithContentsOfURL:rep];
NSURL *tmp = (NSURL*)rep;
rep = [NSImageRep imageRepWithContentsOfURL: rep];
// If we are unable to resolved the URL, try to get it from the
// resources folder.
if(rep == nil)
if (rep == nil)
{
NSString *fileName = [[tmp absoluteString] lastPathComponent];
NSString *path = [[NSBundle mainBundle] pathForImageResource:fileName];
rep = [NSImageRep imageRepWithContentsOfFile:path];
NSString *path = [[NSBundle mainBundle] pathForImageResource: fileName];
rep = [NSImageRep imageRepWithContentsOfFile: path];
}
// If the representation was found, add it...
if(rep != nil)
if (rep != nil)
{
[self addRepresentation: rep];
}

View file

@ -69,6 +69,12 @@
return [[self _classContext] currentContext];
}
- (void *)CGLContextObj
{
[self subclassResponsibility: _cmd];
return NULL;
}
- (void)clearDrawable
{
[self subclassResponsibility: _cmd];
@ -107,16 +113,19 @@
[self subclassResponsibility: _cmd];
}
- (id)initWithCGLContextObj:(void *)context
{
[self subclassResponsibility: _cmd];
return nil;
}
- (id)initWithFormat:(NSOpenGLPixelFormat *)format
shareContext:(NSOpenGLContext *)share
{
[self subclassResponsibility: _cmd];
return 0;
return nil;
}
- (void)makeCurrentContext
{
[self subclassResponsibility: _cmd];

View file

@ -231,8 +231,8 @@ setPath(NSBrowser *browser, NSString *path)
[_browser setAllowsMultipleSelection: NO];
[_browser setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable];
[_browser setTag: NSFileHandlingPanelBrowser];
[_browser setAction:@selector(_selectText:)];
[_browser setTarget:self];
[_browser setAction: @selector(_selectText:)];
[_browser setTarget: self];
[_browser setMinColumnWidth: 140];
[_topView addSubview: _browser];
[_browser release];
@ -1104,7 +1104,7 @@ selectCellWithString: (NSString*)title
*/
- (NSInteger) runModal
{
return [self runModalForDirectory: [self directory] file: @""];
return [self runModalForDirectory: [self directory] file: [self filename]];
}
/**<p> Initializes the panel to the directory specified by path and,
@ -1344,7 +1344,10 @@ selectCellWithString: (NSString*)title
if (result == NSAlertDefaultReturn)
{
if ([_fm createDirectoryAtPath: filename attributes: nil] == NO)
if ([_fm createDirectoryAtPath: filename
withIntermediateDirectories: YES
attributes: nil
error: NULL] == NO)
{
NSRunAlertPanel(_(@"Save"),
_(@"The directory '%@' could not be created."),

View file

@ -42,6 +42,12 @@
#import "AppKit/NSWindow.h"
#import "GNUstepGUI/GSTheme.h"
#import "GSBindingHelpers.h"
#import "NSViewPrivate.h"
@interface NSTabViewItem (KeyViewLoop)
- (void) _setUpKeyViewLoopWithNextKeyView: (NSView *)nextKeyView;
- (NSView *) _lastKeyView;
@end
@implementation NSTabView
@ -82,6 +88,9 @@
{
RELEASE(_items);
RELEASE(_font);
// Reset the _selected attribute to prevent crash when -dealloc calls
// -setNextKeyView:
_selected = nil;
[super dealloc];
}
@ -226,6 +235,7 @@
- (void) selectTabViewItem: (NSTabViewItem*)tabViewItem
{
BOOL canSelect = YES;
NSView *selectedView = nil;
if ([_delegate respondsToSelector: @selector(tabView: shouldSelectTabViewItem:)])
{
@ -246,34 +256,47 @@
/* NB: If [_selected view] is nil this does nothing, which
is fine. */
[[_selected view] removeFromSuperview];
_selected = nil;
_selected = nil;
}
if (tabViewItem)
if ([_delegate respondsToSelector:
@selector(tabView: willSelectTabViewItem:)])
{
_selected = tabViewItem;
[_selected _setTabState: NSSelectedTab];
[_delegate tabView: self willSelectTabViewItem: tabViewItem];
}
NSView *selectedView = [_selected view];
_selected = tabViewItem;
_selected_item = [_items indexOfObject: _selected];
[_selected _setTabState: NSSelectedTab];
if (selectedView == nil)
{
NSLog(@"%s:selected view is NIL\n", __PRETTY_FUNCTION__);
}
else
{
[self addSubview: selectedView];
// FIXME: We should not change this mask
[selectedView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[selectedView setFrame: [self contentRect]];
[_window makeFirstResponder: [_selected initialFirstResponder]];
}
selectedView = [_selected view];
if (selectedView != nil)
{
NSView *firstResponder;
[self addSubview: selectedView];
// FIXME: We should not change this mask
[selectedView setAutoresizingMask:
NSViewWidthSizable | NSViewHeightSizable];
[selectedView setFrame: [self contentRect]];
firstResponder = [_selected initialFirstResponder];
if (firstResponder == nil)
{
firstResponder = [_selected view];
[_selected setInitialFirstResponder: firstResponder];
[firstResponder _setUpKeyViewLoopWithNextKeyView:
_original_nextKeyView];
}
[self setNextKeyView: firstResponder];
[_window makeFirstResponder: firstResponder];
}
/* Will need to redraw tabs and content area. */
[self setNeedsDisplay: YES];
if ([_delegate respondsToSelector: @selector(tabView: didSelectTabViewItem:)])
if ([_delegate respondsToSelector:
@selector(tabView: didSelectTabViewItem:)])
{
[_delegate tabView: self didSelectTabViewItem: _selected];
}
@ -445,6 +468,12 @@
- (void) drawRect: (NSRect)rect
{
// Make sure some tab is selected
if ((_selected == nil) && ([_items count] > 0))
{
[self selectFirstTabViewItem: nil];
}
[[GSTheme theme] drawTabViewRect: rect
inView: self
withItems: _items
@ -692,3 +721,63 @@
}
}
@end
@implementation NSTabViewItem (KeyViewLoop)
- (void) _setUpKeyViewLoopWithNextKeyView: (NSView *)nextKeyView
{
[self setInitialFirstResponder: [self view]];
[[self view] _setUpKeyViewLoopWithNextKeyView: nextKeyView];
}
- (NSView *) _lastKeyView
{
NSView *keyView = [self initialFirstResponder];
NSView *itemView = [self view];
NSView *lastKeyView = nil;
NSMutableArray *views = // cycle protection
[[NSMutableArray alloc] initWithCapacity: 1 + [[itemView subviews] count]];
if (keyView == nil && itemView != nil)
{
[self _setUpKeyViewLoopWithNextKeyView: itemView];
}
while ([keyView isDescendantOf: itemView] && ![views containsObject: keyView])
{
[views addObject: keyView];
lastKeyView = keyView;
keyView = [keyView nextKeyView];
}
[views release];
return lastKeyView;
}
@end
@implementation NSTabView (KeyViewLoop)
- (void) _setUpKeyViewLoopWithNextKeyView: (NSView *)nextKeyView
{
[_items makeObjectsPerform: @selector(_setUpKeyViewLoopWithNextKeyView:)
withObject: nextKeyView];
if (_selected)
{
[super setNextKeyView: [_selected initialFirstResponder]];
}
[self setNextKeyView: nextKeyView];
}
- (void) setNextKeyView: (NSView *)nextKeyView
{
_original_nextKeyView = nextKeyView;
if (_selected)
{
[[_selected _lastKeyView] setNextKeyView: nextKeyView];
}
else
{
[super setNextKeyView: nextKeyView];
}
}
@end

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
@ -249,18 +259,6 @@
return self;
}
- (NSString *)toolTip
{
return _toolTip;
}
- (void) setToolTip:(NSString *)newToolTip
{
// FIXME: Need to find out how to link this to display
ASSIGN(_toolTip, newToolTip);
}
@end
@implementation NSTabViewItem (GNUstep)

View file

@ -87,21 +87,6 @@ static NSNotificationCenter *nc = nil;
return nil;
}
- (NSFont*) font
{
return [self attribute: NSFontAttributeName atIndex: 0 effectiveRange: NULL];
}
- (void) setFont: (NSFont*)font
{
if (font)
{
NSDictionary *attrInfo = [NSDictionary dictionaryWithObject: font forKey: NSFontAttributeName];
NSRange range = { 0, [[self string] length] };
[self setAttributes: attrInfo range: range];
}
}
/*
* Managing GSLayoutManagers
*/
@ -395,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

@ -779,7 +779,10 @@ static NSNumber *float_plus_one(NSNumber *cur)
- (void) yank: (id)sender
{
[self insertText: killBuffer];
if ([killBuffer length] > 0)
{
[self insertText: killBuffer];
}
}

View file

@ -77,6 +77,7 @@
#import "GSToolTips.h"
#import "GSBindingHelpers.h"
#import "GSGuiPrivate.h"
#import "NSViewPrivate.h"
/*
* We need a fast array that can store objects without retain/release ...
@ -359,12 +360,6 @@ GSSetDragTypes(NSView* obj, NSArray *types)
_visibleRect = _bounds;
}
}
if (_rFlags.has_tooltips != 0)
{
GSToolTips *tt = [GSToolTips tipsForView: self];
[tt rebuild];
}
}
}
@ -422,10 +417,18 @@ GSSetDragTypes(NSView* obj, NSArray *types)
if (_window != nil)
{
[GSDisplayServer removeDragTypes: t fromWindow: _window];
if ([_window autorecalculatesKeyViewLoop])
{
[_window recalculateKeyViewLoop];
}
}
if (newWindow != nil)
{
[GSDisplayServer addDragTypes: t toWindow: newWindow];
if ([newWindow autorecalculatesKeyViewLoop])
{
[newWindow recalculateKeyViewLoop];
}
}
}
@ -1223,12 +1226,10 @@ static NSSize _computeScale(NSSize fs, NSSize bs)
}
[self resetCursorRects];
[self resizeSubviewsWithOldSize: old_size];
if (_post_frame_changes && (_posting_frame_changes == NO))
if (_post_frame_changes)
{
_posting_frame_changes = YES;
[nc postNotificationName: NSViewFrameDidChangeNotification
object: self];
_posting_frame_changes = NO;
}
}
}
@ -1246,12 +1247,10 @@ static NSSize _computeScale(NSSize fs, NSSize bs)
}
[self _setFrameAndClearAutoresizingError: newFrame];
[self resetCursorRects];
if (_post_frame_changes && (_posting_frame_changes == NO))
if (_post_frame_changes)
{
_posting_frame_changes = YES;
[nc postNotificationName: NSViewFrameDidChangeNotification
object: self];
_posting_frame_changes = NO;
}
}
}
@ -1313,12 +1312,10 @@ static NSSize _computeScale(NSSize fs, NSSize bs)
}
[self resetCursorRects];
[self resizeSubviewsWithOldSize: old_size];
if (_post_frame_changes && (_posting_frame_changes == NO))
if (_post_frame_changes)
{
_posting_frame_changes = YES;
[nc postNotificationName: NSViewFrameDidChangeNotification
object: self];
_posting_frame_changes = NO;
}
}
}
@ -3527,7 +3524,6 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
}
++t;
aRect = [self convertRect: aRect toView: nil];
m = [[rectClass alloc] initWithRect: aRect
tag: t
owner: anObject
@ -5063,3 +5059,54 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
@end
@implementation NSView(KeyViewLoop)
static int
cmpFrame(id view1, id view2, void *context)
{
BOOL flippedSuperView = [(NSView *)context isFlipped];
NSRect frame1 = [view1 frame];
NSRect frame2 = [view2 frame];
if (NSMinY(frame1) < NSMinY(frame2))
return flippedSuperView ? NSOrderedAscending : NSOrderedDescending;
if (NSMaxY(frame1) > NSMaxY(frame2))
return flippedSuperView ? NSOrderedDescending : NSOrderedAscending;
// FIXME Should use NSMaxX in a Hebrew or Arabic locale
if (NSMinX(frame1) < NSMinX(frame2))
return NSOrderedAscending;
if (NSMinX(frame1) > NSMinX(frame2))
return NSOrderedDescending;
return NSOrderedSame;
}
- (void) _setUpKeyViewLoopWithNextKeyView: (NSView *)nextKeyView
{
if (_rFlags.has_subviews)
{
[self _recursiveSetUpKeyViewLoopWithNextKeyView: nextKeyView];
}
else
{
[self setNextKeyView: nextKeyView];
}
}
- (void) _recursiveSetUpKeyViewLoopWithNextKeyView: (NSView *)nextKeyView
{
NSArray *sortedViews;
NSView *aView;
NSEnumerator *e;
sortedViews = [_sub_views sortedArrayUsingFunction: cmpFrame context: self];
e = [sortedViews reverseObjectEnumerator];
while ((aView = [e nextObject]) != nil)
{
[aView _setUpKeyViewLoopWithNextKeyView: nextKeyView];
nextKeyView = aView;
}
[self setNextKeyView: nextKeyView];
}
@end

View file

@ -89,6 +89,7 @@
#import "GSToolTips.h"
#import "GSIconManager.h"
#import "NSToolbarFrameworkPrivate.h"
#import "NSViewPrivate.h"
#define GSI_ARRAY_TYPES 0
#define GSI_ARRAY_TYPE NSWindow *
@ -164,7 +165,7 @@ static GSWindowAnimationDelegate *animationDelegate;
- (void) _lossOfKeyOrMainWindow;
- (NSView *) _windowView;
- (NSScreen *) _screenForFrame:(NSRect)frame;
- (NSScreen *) _screenForFrame: (NSRect)frame;
@end
@implementation NSWindow (GNUstepPrivate)
@ -386,25 +387,26 @@ has blocked and waited for events.
method and internal requests for the correct 'screen' based on the
supplied frame request.
*/
- (NSScreen *) _screenForFrame:(NSRect)frame
- (NSScreen *) _screenForFrame: (NSRect)frame
{
NSInteger largest = 0;
NSInteger largest = -1;
NSArray *screens = [NSScreen screens];
NSInteger index = 0;
NSScreen *theScreen = nil;
for (index = 0; index < [screens count]; ++index)
{
NSScreen *screen = [screens objectAtIndex:index];
NSRect sframe = [screen frame];
NSRect iframe = NSIntersectionRect(frame, sframe);
NSInteger isize = NSWidth(iframe) * NSHeight(iframe);
if (isize > largest)
{
largest = isize;
theScreen = screen;
NSScreen *screen = [screens objectAtIndex: index];
NSRect sframe = [screen frame];
NSRect iframe = NSIntersectionRect(frame, sframe);
NSInteger isize = NSWidth(iframe) * NSHeight(iframe);
if (isize > largest)
{
largest = isize;
theScreen = screen;
}
}
}
NSDebugMLLog(@"NSWindow", @"frame: %@ screen: %@ size: %ld\n",
NSDebugLLog(@"NSWindow", @"%s: frame: %@ screen: %@ size: %ld\n", __PRETTY_FUNCTION__,
NSStringFromRect(frame), theScreen, (long)largest);
return theScreen;
@ -1272,12 +1274,25 @@ many times.
}
}
static NSString *
titleWithRepresentedFilename(NSString *representedFilename)
{
return [NSString stringWithFormat: @"%@ -- %@",
[representedFilename lastPathComponent],
[[representedFilename stringByDeletingLastPathComponent]
stringByAbbreviatingWithTildeInPath]];
}
- (BOOL) _hasTitleWithRepresentedFilename
{
NSString *aString = titleWithRepresentedFilename (_representedFilename);
return [_windowTitle isEqualToString: aString];
}
- (void) setTitleWithRepresentedFilename: (NSString*)aString
{
[self setRepresentedFilename: aString];
aString = [NSString stringWithFormat:
@"%@ -- %@", [aString lastPathComponent],
[aString stringByDeletingLastPathComponent]];
aString = titleWithRepresentedFilename(aString);
if ([_windowTitle isEqual: aString] == NO)
{
ASSIGNCOPY(_windowTitle, aString);
@ -1537,6 +1552,10 @@ many times.
if ((!_firstResponder) || (_firstResponder == self))
{
if (!_initialFirstResponder)
{
[self recalculateKeyViewLoop];
}
if (_initialFirstResponder)
{
[self makeFirstResponder: _initialFirstResponder];
@ -1750,7 +1769,6 @@ many times.
{
GSDisplayServer *srv = GSServerForWindow(self);
BOOL display = NO;
BOOL redisplay = NO;
if (YES == [[NSUserDefaults standardUserDefaults]
boolForKey: @"GSBackgroundApp"])
@ -1791,8 +1809,6 @@ many times.
[self _initBackendWindow];
display = YES;
}
else
redisplay = (_f.visible == NO);
}
/* If a hide on deactivate window is explicitly ordered in or out while
@ -1805,8 +1821,10 @@ many times.
// Draw content before backend window ordering
if (display)
[self display];
[_wv display];
else if (place != NSWindowOut)
[_wv displayIfNeeded];
/* The backend will keep us below the current key window unless we
force it not too */
if ((otherWin == 0
@ -1816,10 +1834,9 @@ many times.
otherWin = -1;
[srv orderwindow: place : otherWin : _windowNum];
if (redisplay)
if (display)
[self display];
if (place != NSWindowOut)
{
/*
@ -1837,17 +1854,9 @@ many times.
_f.has_opened = YES;
if (_f.menu_exclude == NO)
{
BOOL isFileName;
NSString *aString;
aString = [NSString stringWithFormat: @"%@ -- %@",
[_representedFilename lastPathComponent],
[_representedFilename stringByDeletingLastPathComponent]];
isFileName = [_windowTitle isEqual: aString];
[NSApp addWindowsItem: self
title: _windowTitle
filename: isFileName];
filename: [self _hasTitleWithRepresentedFilename]];
}
}
if ([self isKeyWindow] == YES)
@ -1856,7 +1865,6 @@ many times.
[srv setinputfocus: _windowNum];
}
_f.visible = YES;
[self displayIfNeeded];
}
#ifndef __MINGW32__
else if ([self isOneShot])
@ -1995,7 +2003,10 @@ many times.
- (BOOL) showsResizeIndicator
{
return ([self styleMask] & NSResizableWindowMask) ? YES : NO;
// TODO
NSLog(@"Method %s is not implemented for class %s",
"showsResizeIndicator", "NSWindow");
return YES;
}
- (void) setShowsResizeIndicator: (BOOL)show
@ -2079,37 +2090,20 @@ many times.
return (maxDiff * resizeTime) / 150;
}
- (NSRect) _centerFrame: (NSRect)frame onScreen: (NSScreen*)theScreen
{
NSRect centeredFrame = frame;
if ((NSEqualRects(frame, NSZeroRect) == NO) && theScreen)
{
NSSize screenSize = [theScreen visibleFrame].size;
centeredFrame.origin.x = (screenSize.width - centeredFrame.size.width) / 2;
centeredFrame.origin.y = (screenSize.height - centeredFrame.size.height) / 2;
}
return centeredFrame;
}
- (NSRect) _centerFrame: (NSRect)frame
{
NSScreen *screen = [self screen];
// if not visible on any screen, center on the main screen
if (!screen)
screen = [NSScreen mainScreen];
return [self _centerFrame:frame onScreen:screen];
}
- (void) center
{
NSRect newFrame = [self _centerFrame: _frame];
NSScreen *screen = [self screen];
NSSize screenSize;
NSPoint origin = _frame.origin;
[self setFrameOrigin: newFrame.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;
[self setFrameOrigin: origin];
}
/**
@ -2411,9 +2405,14 @@ many times.
- (void) displayIfNeeded
{
if (_gstate == 0 || _f.visible == NO)
return;
if (_f.views_need_display)
{
[self display];
[_wv displayIfNeeded];
[self discardCachedImage];
_f.views_need_display = NO;
}
}
@ -2610,7 +2609,18 @@ many times.
/** Returns the screen the window is on. */
- (NSScreen *) screen
{
ASSIGN(_screen, [self _screenForFrame:_frame]);
// Only recompute the screen if the current screen
// doesn't contain the whole window.
// FIXME: Containing half the window would be enough
if (_screen != nil)
{
NSRect sframe = [_screen frame];
if (NSContainsRect(sframe, _frame))
{
return _screen;
}
}
ASSIGN(_screen, [self _screenForFrame: _frame]);
return _screen;
}
@ -3454,6 +3464,7 @@ resetCursorRectsForView(NSView *theView)
return;
if (theView->_rFlags.has_trkrects)
{
BOOL isFlipped = [theView isFlipped];
NSArray *tr = theView->_tracking_rects;
unsigned count = [tr count];
@ -3464,8 +3475,11 @@ resetCursorRectsForView(NSView *theView)
{
GSTrackingRect *rects[count];
NSPoint loc = [theEvent locationInWindow];
NSPoint lastPoint = _lastPoint;
unsigned i;
lastPoint = [theView convertPoint: lastPoint fromView: nil];
loc = [theView convertPoint: loc fromView: nil];
[tr getObjects: rects];
for (i = 0; i < count; ++i)
@ -3477,9 +3491,9 @@ resetCursorRectsForView(NSView *theView)
if ([r isValid] == NO)
continue;
/* Check mouse at last point */
last = NSMouseInRect(_lastPoint, r->rectangle, NO);
last = NSMouseInRect(lastPoint, r->rectangle, isFlipped);
/* Check mouse at current point */
now = NSMouseInRect(loc, r->rectangle, NO);
now = NSMouseInRect(loc, r->rectangle, isFlipped);
if ((!last) && (now)) // Mouse entered event
{
@ -4378,7 +4392,7 @@ resetCursorRectsForView(NSView *theView)
_f.selectionDirection = NSSelectingNext;
[(id)theView selectText: self];
_f.selectionDirection = NSDirectSelection;
}
}
}
}
@ -4475,7 +4489,7 @@ resetCursorRectsForView(NSView *theView)
{
return;
}
if ([theView respondsToSelector:@selector(selectText:)])
if ([theView respondsToSelector:@selector(selectText:)])
{
_f.selectionDirection = NSSelectingPrevious;
[(id)theView selectText: self];
@ -4515,8 +4529,10 @@ current key view.<br />
- (void) recalculateKeyViewLoop
{
// FIXME
// Should be called from NSView viewWillMoveToWindow
// Should be called from NSView viewWillMoveToWindow (but only if
// -autorecalculatesKeyViewLoop returns YES)
[_contentView _setUpKeyViewLoopWithNextKeyView: _contentView];
[self setInitialFirstResponder: [_contentView nextValidKeyView]];
}
@ -4572,17 +4588,9 @@ current key view.<br />
}
else if (_f.has_opened == YES && flag == NO)
{
BOOL isFileName;
NSString *aString;
aString = [NSString stringWithFormat: @"%@ -- %@",
[_representedFilename lastPathComponent],
[_representedFilename stringByDeletingLastPathComponent]];
isFileName = [_windowTitle isEqual: aString];
[NSApp addWindowsItem: self
title: _windowTitle
filename: isFileName];
filename: [self _hasTitleWithRepresentedFilename]];
}
}
}
@ -4661,6 +4669,7 @@ current key view.<br />
NSRect sRect;
NSRect fRect;
int value;
NSScreen *screen;
/*
* Scan in the window frame (flipped coordinate system).
@ -4704,6 +4713,21 @@ current key view.<br />
}
#endif
// if toolbar is showing, adjust saved frame to add the toolbar back in
if ([_toolbar isVisible])
{
float toolbarHeight = [[_toolbar _toolbarView] frame].size.height;
fRect.size.height += toolbarHeight;
fRect.origin.y -= toolbarHeight;
}
// if window has a menu, adjust saved frame to add the menu back in
if ([_wv hasMenu])
{
float menuBarHeight = [[GSTheme theme] menuHeightForWindow: self];
fRect.size.height += menuBarHeight;
fRect.origin.y -= menuBarHeight;
}
/*
* Scan in the frame for the area the window was placed in in screen.
*/
@ -4734,62 +4758,12 @@ current key view.<br />
return;
}
sRect.size.height = value;
#if defined(__MINGW__)
// Finally, this is for handling possible frame errors due to MSWindows sending
// x/y frame position of -32000/32893 on a minimize. These are now ignored in the
// backend but since they were stored before, if the application was quit with
// minimized windows the stored frames in defaults are corrupted and windows are
// potentially never seen in subsequent application runs...
// There's only so much we can do to try to restore this information and this
// section may need to be updated as we test further...
if ((fabs(fRect.origin.x) > 32000.00) || (fabs(fRect.origin.y) > 32000.00))
{
// This additional check potentially needed if application restarted multiple
// times after the above sequence causing corrupted width/height values...
// We'll try using the minimum size set but this may not be valid...
NSSize minSize = [self minSize];
if ((minSize.width < 100) || (minSize.height < 100))
minSize = NSMakeSize(100, 100);
// Adjust if necessary...
if (fRect.size.width < minSize.width)
fRect.size.width = minSize.width;
if (fRect.size.height < minSize.height)
fRect.size.height = minSize.height;
// Center in screen...
fRect = [self _centerFrame: fRect onScreen: [NSScreen mainScreen]];
// Also - screen rectangle could be corrupted and completely meaningless...
sRect = [[NSScreen mainScreen] visibleFrame];
}
#endif
// Another error is that the saved screen rectangle could be wrong i.e. zero...
if (NSEqualRects(sRect, NSZeroRect))
sRect = [[NSScreen mainScreen] visibleFrame];
// if toolbar is showing, adjust saved frame to add the toolbar back in
if ([_toolbar isVisible])
{
float toolbarHeight = [[_toolbar _toolbarView] frame].size.height;
fRect.size.height += toolbarHeight;
fRect.origin.y -= toolbarHeight;
}
// if window has a menu, adjust saved frame to add the menu back in
if ([_wv hasMenu])
{
float menuBarHeight = [[GSTheme theme] menuHeightForWindow: self];
fRect.size.height += menuBarHeight;
fRect.origin.y -= menuBarHeight;
}
/*
* The screen rectangle gives the area of the screen in which
* the window could be placed (ie a rectangle excluding the dock).
*/
NSScreen *screen = [self _screenForFrame:fRect];
screen = [self _screenForFrame: fRect];
// Check whether a portion is showing somewhere...
if (screen == nil)
@ -4798,7 +4772,7 @@ current key view.<br />
// to move it so it can be seen and assign it to the main
// screen...
screen = [NSScreen mainScreen];
NSDebugMLLog(@"NSWindow", @"re-assigning to main screen\n");
NSDebugLLog(@"NSWindow", @"%s: re-assigning to main screen\n", __PRETTY_FUNCTION__);
}
nRect = [screen visibleFrame];
@ -4810,7 +4784,6 @@ current key view.<br />
{
fRect.origin.x += nRect.origin.x - sRect.origin.x;
fRect.origin.y += nRect.origin.y - sRect.origin.y;
NSWarnMLog(@"NSEqualPoints: %@\n", NSStringFromRect(fRect));
}
/*
@ -4821,7 +4794,7 @@ current key view.<br />
if (nRect.size.width != sRect.size.width)
{
fRect.origin.x = nRect.origin.x + (fRect.origin.x - nRect.origin.x)
* (nRect.size.width / sRect.size.width);
* (nRect.size.width / sRect.size.width);
}
if (nRect.size.height != sRect.size.height)
{
@ -4836,7 +4809,7 @@ current key view.<br />
fRect.origin.y = nRect.size.height - fRect.size.height;
}
}
// FIXME: Is this check needed?
/* If we aren't resizable (ie. if we don't have a resize bar), make sure
we don't change the size. */
@ -4891,6 +4864,7 @@ current key view.<br />
{
NSRect fRect;
NSRect sRect;
NSString *autosaveString;
fRect = _frame;
@ -4913,19 +4887,14 @@ current key view.<br />
* The screen rectangle should give the area of the screen in which
* the window could be placed (ie a rectangle excluding the dock).
*/
NSScreen *myScreen = [self screen];
// If window doesn't show up on any screen then just include main screen frame...
if (myScreen == nil)
myScreen = [NSScreen mainScreen];
sRect = [myScreen visibleFrame];
NSString *autosaveString = [NSString stringWithFormat: @"%d %d %d %d %d %d % d %d ",
sRect = [[self screen] visibleFrame];
autosaveString = [NSString stringWithFormat: @"%d %d %d %d %d %d % d %d ",
(int)fRect.origin.x, (int)fRect.origin.y,
(int)fRect.size.width, (int)fRect.size.height,
(int)sRect.origin.x, (int)sRect.origin.y,
(int)sRect.size.width, (int)sRect.size.height];
NSDebugMLLog(@"NSWindow", @"autosaveName: %@ frame string: %@", _autosaveName, autosaveString);
NSDebugLLog(@"NSWindow", @"%s:autosaveName: %@ frame string: %@", __PRETTY_FUNCTION__,
_autosaveName, autosaveString);
return autosaveString;
}
@ -5762,4 +5731,3 @@ NSWindow* GSWindowWithNumber(int num)
return (NSWindow*)NSMapGet(windowmaps, (void*)(intptr_t)num);
return nil;
}

View file

@ -246,15 +246,7 @@ static id GSLaunched(NSNotification *notification, BOOL active)
{
[file writeToFile: path atomically: YES];
}
NS_DURING
{
[lock unlock];
}
NS_HANDLER
{
NSLog(@"NSWorkspace lock: %@", localException);
}
NS_ENDHANDLER
[lock unlock];
if (active == YES)
{
@ -773,6 +765,43 @@ static NSString *_rootPath = @"/";
/*
* Opening Files
*/
- (BOOL) _openUnknown: (NSString*)fullPath
{
NSString *tool = [[NSUserDefaults standardUserDefaults] objectForKey: @"GSUnknownFileTool"];
NSString *launchPath;
if ((tool == nil) || (launchPath = [NSTask launchPathForTool: tool]) == nil)
{
#ifdef __MINGW32__
// Maybe we should rather use "Explorer.exe /e, " as the tool name
unichar *buffer = (unichar *)calloc(1, ([fullPath length] + 1) * sizeof(unichar));
[fullPath getCharacters: buffer range: NSMakeRange(0, [fullPath length])];
buffer[[fullPath length]] = 0;
BOOL success = (ShellExecuteW(GetDesktopWindow(), L"open", buffer, NULL,
NULL, SW_SHOWNORMAL) > 32);
free(buffer);
return success;
#else
// Fall back to xdg-open
launchPath = [NSTask launchPathForTool: @"xdg-open"];
#endif
}
if (launchPath)
{
NSTask * task = [NSTask launchedTaskWithLaunchPath: launchPath
arguments: [NSArray arrayWithObject: fullPath]];
if (task != nil)
{
[task waitUntilExit];
if ([task terminationStatus] == 0)
return YES;
}
}
return NO;
}
- (BOOL) openFile: (NSString*)fullPath
{
return [self openFile: fullPath withApplication: nil];
@ -828,8 +857,15 @@ static NSString *_rootPath = @"/";
if ([self _extension: ext role: nil app: &appName] == NO)
{
NSWarnLog(@"No known applications for file extension '%@'", ext);
return NO;
if ([self _openUnknown: fullPath])
{
return YES;
}
else
{
NSWarnLog(@"No known applications for file extension '%@'", ext);
return NO;
}
}
}
@ -891,8 +927,15 @@ static NSString *_rootPath = @"/";
ext = [fullPath pathExtension];
if ([self _extension: ext role: nil app: &appName] == NO)
{
NSWarnLog(@"No known applications for file extension '%@'", ext);
return NO;
if ([self _openUnknown: fullPath])
{
return YES;
}
else
{
NSWarnLog(@"No known applications for file extension '%@'", ext);
return NO;
}
}
app = [self _connectApplication: appName];
@ -936,7 +979,7 @@ static NSString *_rootPath = @"/";
appName = [self getBestAppInRole: nil forScheme: [url scheme]];
if (appName != nil)
{
id app;
id app;
/* Now try to get the application to open the URL.
*/
@ -964,7 +1007,14 @@ static NSString *_rootPath = @"/";
[pb declareTypes: [NSArray arrayWithObject: NSURLPboardType]
owner: nil];
[url writeToPasteboard: pb];
return NSPerformService(@"OpenURL", pb);
if (NSPerformService(@"OpenURL", pb))
{
return YES;
}
else
{
return [self _openUnknown: [url absoluteString]];
}
}
}