Indentation, and use ASSIGN in a couple of places

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@10528 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
nico 2001-07-20 09:18:31 +00:00
parent fd5216d3cb
commit 2256c67cca

View file

@ -27,29 +27,29 @@
@implementation NSWindowController @implementation NSWindowController
- (id)initWithWindowNibName:(NSString *)windowNibName - (id) initWithWindowNibName: (NSString *)windowNibName
{ {
return [self initWithWindowNibName:windowNibName owner:self]; return [self initWithWindowNibName: windowNibName owner: self];
} }
- (id)initWithWindowNibName:(NSString *)windowNibName owner:(id)owner - (id) initWithWindowNibName: (NSString *)windowNibName owner: (id)owner
{ {
[self initWithWindow:nil]; [self initWithWindow: nil];
_windowNibName = RETAIN(windowNibName); _windowNibName = RETAIN (windowNibName);
_owner = owner; _owner = owner;
return self; return self;
} }
- (id)initWithWindow:(NSWindow *)window - (id) initWithWindow: (NSWindow *)window
{ {
[super init]; [super init];
_window = RETAIN(window); ASSIGN (_window, window);
_windowFrameAutosaveName = @""; _windowFrameAutosaveName = @"";
_wcFlags.shouldCascade = YES; _wcFlags.shouldCascade = YES;
_wcFlags.shouldCloseDocument = NO; _wcFlags.shouldCloseDocument = NO;
if (_window) if (_window != nil)
{ {
[self _windowDidLoad]; [self _windowDidLoad];
} }
@ -57,90 +57,96 @@
return self; return self;
} }
- (id)init - (id) init
{ {
return [self initWithWindowNibName:nil]; return [self initWithWindowNibName: nil];
} }
- (void)dealloc - (void) dealloc
{ {
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver: self];
RELEASE(_windowNibName); RELEASE (_windowNibName);
RELEASE(_windowFrameAutosaveName); RELEASE (_windowFrameAutosaveName);
RELEASE(_topLevelObjects); RELEASE (_topLevelObjects);
AUTORELEASE(_window); AUTORELEASE (_window); /* FIXME - should be RELEASE I think */
[super dealloc]; [super dealloc];
} }
- (NSString *)windowNibName - (NSString *) windowNibName
{ {
return _windowNibName; return _windowNibName;
} }
- (id)owner - (id) owner
{ {
return _owner; return _owner;
} }
- (void)setDocument:(NSDocument *)document - (void) setDocument: (NSDocument *)document
{ {
// FIXME - this is RETAINed and never RELEASEd ... // FIXME - this is RETAINed and never RELEASEd ...
ASSIGN(_document, document); ASSIGN(_document, document);
[self _synchronizeWindowTitleWithDocumentName]; [self _synchronizeWindowTitleWithDocumentName];
} }
- (id)document - (id) document
{ {
return _document; return _document;
} }
- (void)setWindowFrameAutosaveName:(NSString *)name - (void) setWindowFrameAutosaveName:(NSString *)name
{ {
ASSIGN(_windowFrameAutosaveName, name); ASSIGN (_windowFrameAutosaveName, name);
if ([self isWindowLoaded]) if ([self isWindowLoaded])
{ {
[[self window] setFrameAutosaveName:name? name : @""]; [[self window] setFrameAutosaveName:name? name : @""];
} }
} }
- (NSString *)windowFrameAutosaveName; - (NSString *) windowFrameAutosaveName;
{ {
return _windowFrameAutosaveName; return _windowFrameAutosaveName;
} }
- (void)setShouldCloseDocument:(BOOL)flag - (void) setShouldCloseDocument: (BOOL)flag
{ {
_wcFlags.shouldCloseDocument = flag; _wcFlags.shouldCloseDocument = flag;
} }
- (BOOL)shouldCloseDocument - (BOOL) shouldCloseDocument
{ {
return _wcFlags.shouldCloseDocument; return _wcFlags.shouldCloseDocument;
} }
- (void)setShouldCascadeWindows:(BOOL)flag - (void) setShouldCascadeWindows: (BOOL)flag
{ {
_wcFlags.shouldCascade = flag; _wcFlags.shouldCascade = flag;
} }
- (BOOL)shouldCascadeWindows - (BOOL) shouldCascadeWindows
{ {
return _wcFlags.shouldCascade; return _wcFlags.shouldCascade;
} }
- (void)close - (void) close
{ {
[_window close]; [_window close];
} }
- (void)_windowWillClose:(NSNotification *)notification - (void) _windowWillClose: (NSNotification *)notification
{ {
if ([notification object] == _window) if ([notification object] == _window)
{ {
if ([_window delegate] == self) [_window setDelegate:nil]; if ([_window delegate] == self)
if ([_window windowController] == self) [_window setWindowController:nil]; {
[_window setDelegate: nil];
}
if ([_window windowController] == self)
{
[_window setWindowController: nil];
}
/* /*
* If the window is set to isReleasedWhenClosed, it will release * If the window is set to isReleasedWhenClosed, it will release
@ -155,53 +161,64 @@
{ {
_window = nil; _window = nil;
} }
[_document _removeWindowController:self]; [_document _removeWindowController: self];
} }
} }
- (NSWindow *)window - (NSWindow *) window
{ {
if (_window == nil && ![self isWindowLoaded]) if (_window == nil && ![self isWindowLoaded])
{ {
// Do all the notifications. Yes, the docs say this should // Do all the notifications. Yes, the docs say this should
// be implemented here instead of in -loadWindow itself. // be implemented here instead of in -loadWindow itself.
[self windowWillLoad]; [self windowWillLoad];
if ([_document respondsToSelector:@selector(windowControllerWillLoadNib:)]) if ([_document respondsToSelector:
[_document windowControllerWillLoadNib:self]; @selector(windowControllerWillLoadNib:)])
{
[_document windowControllerWillLoadNib:self];
}
[self loadWindow]; [self loadWindow];
[self _windowDidLoad]; [self _windowDidLoad];
if ([_document respondsToSelector:@selector(windowControllerDidLoadNib:)]) if ([_document respondsToSelector:
[_document windowControllerDidLoadNib:self]; @selector(windowControllerDidLoadNib:)])
{
[_document windowControllerDidLoadNib:self];
}
} }
return _window; return _window;
} }
// Private method; the nib loading will call this. // Private method; the nib loading will call this.
- (void)setWindow:(NSWindow *)aWindow - (void) setWindow: (NSWindow *)aWindow
{ {
ASSIGN(_window, aWindow); ASSIGN (_window, aWindow);
} }
- (IBAction)showWindow:(id)sender - (IBAction) showWindow: (id)sender
{ {
NSWindow *window = [self window]; NSWindow *window = [self window];
if ([window isKindOfClass:[NSPanel class]] && [(NSPanel*)window becomesKeyOnlyIfNeeded]) if ([window isKindOfClass: [NSPanel class]]
[window orderFront:sender]; && [(NSPanel*)window becomesKeyOnlyIfNeeded])
{
[window orderFront: sender];
}
else else
[window makeKeyAndOrderFront:sender]; {
[window makeKeyAndOrderFront: sender];
}
} }
- (NSString *)windowTitleForDocumentDisplayName:(NSString *)displayName - (NSString *) windowTitleForDocumentDisplayName:(NSString *)displayName
{ {
return displayName; return displayName;
} }
- (void)_synchronizeWindowTitleWithDocumentName - (void) _synchronizeWindowTitleWithDocumentName
{ {
if (_document) if (_document)
{ {
@ -239,21 +256,21 @@
{ {
_wcFlags.nibIsLoaded = YES; _wcFlags.nibIsLoaded = YES;
[_window setWindowController:self]; [_window setWindowController: self];
[self _synchronizeWindowTitleWithDocumentName]; [self _synchronizeWindowTitleWithDocumentName];
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
addObserver:self addObserver: self
selector:@selector(_windowWillClose:) selector: @selector(_windowWillClose:)
name:NSWindowWillCloseNotification name: NSWindowWillCloseNotification
object:_window]; object: _window];
/* Make sure window sizes itself right */ /* Make sure window sizes itself right */
if ([_windowFrameAutosaveName length] > 0) if ([_windowFrameAutosaveName length] > 0)
{ {
[_window setFrameUsingName:_windowFrameAutosaveName]; [_window setFrameUsingName: _windowFrameAutosaveName];
[_window setFrameAutosaveName:_windowFrameAutosaveName]; [_window setFrameAutosaveName: _windowFrameAutosaveName];
} }
if ([self shouldCascadeWindows]) if ([self shouldCascadeWindows])
@ -266,7 +283,8 @@
NSRect windowFrame = [_window frame]; NSRect windowFrame = [_window frame];
/* Start with the frame as set */ /* Start with the frame as set */
nextWindowLocation = NSMakePoint(NSMinX(windowFrame), NSMaxY(windowFrame)); nextWindowLocation = NSMakePoint (NSMinX (windowFrame),
NSMaxY (windowFrame));
firstWindow = NO; firstWindow = NO;
} }
else else
@ -278,7 +296,8 @@
* extreme top of the screen, and offset only a small amount * extreme top of the screen, and offset only a small amount
* from the left. * from the left.
*/ */
nextWindowLocation = [_window cascadeTopLeftFromPoint:nextWindowLocation]; nextWindowLocation = [_window
cascadeTopLeftFromPoint: nextWindowLocation];
} }
} }
@ -306,12 +325,12 @@
* There's no way I'll ever get these compatible if Apple's versions * There's no way I'll ever get these compatible if Apple's versions
* actually encode anything, sigh * actually encode anything, sigh
*/ */
- initWithCoder:(NSCoder *)coder - (id) initWithCoder: (NSCoder *)coder
{ {
return [self init]; return [self init];
} }
- (void)encodeWithCoder:(NSCoder *)coder - (void) encodeWithCoder: (NSCoder *)coder
{ {
// What are we supposed to encode? Window nib name? Or should these // What are we supposed to encode? Window nib name? Or should these
// be empty, just to conform to NSCoding, so we do an -init on // be empty, just to conform to NSCoding, so we do an -init on