mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 22:10:47 +00:00
Implemented new methods and renamed some old which are now public.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11542 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c018f02e93
commit
9d857045a2
1 changed files with 93 additions and 24 deletions
|
@ -47,7 +47,28 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
self = [self initWithWindow: nil];
|
self = [self initWithWindow: nil];
|
||||||
ASSIGN (_windowNibName, windowNibName);
|
ASSIGN(_windowNibName, windowNibName);
|
||||||
|
_owner = owner;
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithWindowNibPath: (NSString *)windowNibPath
|
||||||
|
owner: (id)owner
|
||||||
|
{
|
||||||
|
if (windowNibPath == nil)
|
||||||
|
{
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"attempt to init NSWindowController with nil windowNibPath"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (owner == nil)
|
||||||
|
{
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"attempt to init NSWindowController with nil owner"];
|
||||||
|
}
|
||||||
|
|
||||||
|
self = [self initWithWindow: nil];
|
||||||
|
ASSIGN(_windowNibPath, windowNibPath);
|
||||||
_owner = owner;
|
_owner = owner;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -78,18 +99,44 @@
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||||
RELEASE (_windowNibName);
|
RELEASE(_windowNibName);
|
||||||
RELEASE (_windowFrameAutosaveName);
|
RELEASE(_windowNibPath);
|
||||||
RELEASE (_topLevelObjects);
|
RELEASE(_windowFrameAutosaveName);
|
||||||
|
RELEASE(_topLevelObjects);
|
||||||
AUTORELEASE (_window); /* FIXME - should be RELEASE I think */
|
AUTORELEASE (_window); /* FIXME - should be RELEASE I think */
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) windowNibName
|
- (NSString *) windowNibName
|
||||||
{
|
{
|
||||||
|
if ((_windowNibName == nil) && (_windowNibPath != nil))
|
||||||
|
{
|
||||||
|
return [[_windowNibPath lastPathComponent]
|
||||||
|
stringByDeletingPathExtension];
|
||||||
|
}
|
||||||
|
|
||||||
return _windowNibName;
|
return _windowNibName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *)windowNibPath
|
||||||
|
{
|
||||||
|
if ((_windowNibName != nil) && (_windowNibPath == nil))
|
||||||
|
{
|
||||||
|
NSString *path;
|
||||||
|
|
||||||
|
// This is not fully correct as nib resources are searched different.
|
||||||
|
path = [[NSBundle bundleForClass: [_owner class]]
|
||||||
|
pathForNibResource: _windowNibName];
|
||||||
|
if (path == nil)
|
||||||
|
path = [[NSBundle mainBundle]
|
||||||
|
pathForNibResource: _windowNibName];
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _windowNibPath;
|
||||||
|
}
|
||||||
|
|
||||||
- (id) owner
|
- (id) owner
|
||||||
{
|
{
|
||||||
return _owner;
|
return _owner;
|
||||||
|
@ -99,7 +146,7 @@
|
||||||
{
|
{
|
||||||
// FIXME - this is RETAINed and never RELEASEd ...
|
// FIXME - this is RETAINed and never RELEASEd ...
|
||||||
ASSIGN (_document, document);
|
ASSIGN (_document, document);
|
||||||
[self _synchronizeWindowTitleWithDocumentName];
|
[self synchronizeWindowTitleWithDocumentName];
|
||||||
|
|
||||||
if (_document != nil)
|
if (_document != nil)
|
||||||
{
|
{
|
||||||
|
@ -122,13 +169,18 @@
|
||||||
return _document;
|
return _document;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setDocumentEdited: (BOOL)flag
|
||||||
|
{
|
||||||
|
[_window setDocumentEdited: flag];
|
||||||
|
}
|
||||||
|
|
||||||
- (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 : @""];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +214,6 @@
|
||||||
[_window close];
|
[_window close];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) _windowWillClose: (NSNotification *)notification
|
- (void) _windowWillClose: (NSNotification *)notification
|
||||||
{
|
{
|
||||||
if ([notification object] == _window)
|
if ([notification object] == _window)
|
||||||
|
@ -223,10 +274,17 @@
|
||||||
return _window;
|
return _window;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private method; the nib loading will call this.
|
|
||||||
- (void) setWindow: (NSWindow *)aWindow
|
- (void) setWindow: (NSWindow *)aWindow
|
||||||
{
|
{
|
||||||
ASSIGN (_window, aWindow);
|
ASSIGN (_window, aWindow);
|
||||||
|
if (_document != nil)
|
||||||
|
{
|
||||||
|
[_window setReleasedWhenClosed: YES];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[_window setReleasedWhenClosed: NO];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction) showWindow: (id)sender
|
- (IBAction) showWindow: (id)sender
|
||||||
|
@ -249,7 +307,7 @@
|
||||||
return displayName;
|
return displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _synchronizeWindowTitleWithDocumentName
|
- (void) synchronizeWindowTitleWithDocumentName
|
||||||
{
|
{
|
||||||
if (_document != nil)
|
if (_document != nil)
|
||||||
{
|
{
|
||||||
|
@ -264,10 +322,9 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (filename) [_window setRepresentedFilename:filename];
|
if (filename)
|
||||||
{
|
[_window setRepresentedFilename: filename];
|
||||||
[_window setTitle:title];
|
[_window setTitle: title];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,7 +348,7 @@
|
||||||
|
|
||||||
[_window setWindowController: self];
|
[_window setWindowController: self];
|
||||||
|
|
||||||
[self _synchronizeWindowTitleWithDocumentName];
|
[self synchronizeWindowTitleWithDocumentName];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
addObserver: self
|
addObserver: self
|
||||||
|
@ -344,6 +401,26 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((_windowNibName == nil) && (_windowNibPath != nil))
|
||||||
|
{
|
||||||
|
NSDictionary *table;
|
||||||
|
|
||||||
|
table = [NSDictionary dictionaryWithObject: _owner forKey: @"NSOwner"];
|
||||||
|
|
||||||
|
if ([NSBundle loadNibFile: _windowNibPath
|
||||||
|
externalNameTable: table
|
||||||
|
withZone: [_owner zone]])
|
||||||
|
{
|
||||||
|
_wcFlags.nibIsLoaded = YES;
|
||||||
|
|
||||||
|
if (_window == nil && _document != nil && _owner == _document)
|
||||||
|
{
|
||||||
|
[self setWindow: [_document _transferWindowOwnership]];
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ([NSBundle loadNibNamed: _windowNibName owner: _owner])
|
if ([NSBundle loadNibNamed: _windowNibName owner: _owner])
|
||||||
{
|
{
|
||||||
_wcFlags.nibIsLoaded = YES;
|
_wcFlags.nibIsLoaded = YES;
|
||||||
|
@ -352,18 +429,10 @@
|
||||||
{
|
{
|
||||||
[self setWindow: [_document _transferWindowOwnership]];
|
[self setWindow: [_document _transferWindowOwnership]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_document != nil)
|
|
||||||
{
|
|
||||||
[_window setReleasedWhenClosed: YES];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
[_window setReleasedWhenClosed: NO];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// FIXME: We should still try the main bundle
|
||||||
NSLog (@"%@: could not load nib named %@.nib",
|
NSLog (@"%@: could not load nib named %@.nib",
|
||||||
[self class], _windowNibName);
|
[self class], _windowNibName);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue