mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
Improvements for testing etc
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@5649 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
28d89e43f6
commit
5c17f3142d
10 changed files with 472 additions and 150 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Mon Jan 3 10:50:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
Rewrote testing mechanism so that we test by creating an in-memory
|
||||
nib, and load that nib. This way, the testing process has no effect
|
||||
on the original objects in the document we are working on.
|
||||
Also changed the editor api so that we have a deactivate method.
|
||||
Editors are deactivated on archiving and reactivated afterwords -
|
||||
this means that we no longer need to destroy all editors during
|
||||
archiving in order to stop them being included in the archive.
|
||||
|
||||
Thu Dec 23 16:32:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
Added generic object inspector.
|
||||
|
|
104
Gorm.h
104
Gorm.h
|
@ -117,39 +117,141 @@ extern NSString *IBDidEndTestingInterfaceNotification;
|
|||
* objects and mark the display appropriately. Setting either source or
|
||||
* target to 'nil' will remove markup from any previous source or target.
|
||||
* NB. This method expects to be able to call the active document to ask it
|
||||
* for the window adn rectangle in which to perform markup.
|
||||
* for the window and rectangle in which to perform markup.
|
||||
*/
|
||||
- (void) displayConnectionBetween: (id)source and: (id)destination;
|
||||
@end
|
||||
|
||||
/*
|
||||
* The [-editorClassName] method is used to return the name of the editor
|
||||
* class for the object. Documents use this method to create editors for
|
||||
* objects, it shouldn't be used elsewhere.
|
||||
* If you are writing a custom editor for a particular class of object, you
|
||||
* need to override this method for objects of that class.
|
||||
*/
|
||||
@interface NSObject (IBEditorSpecification)
|
||||
- (NSString*) editorClassName;
|
||||
@end
|
||||
|
||||
/*
|
||||
* The IBSelectionOwners protocol defines the methods that a selection owner
|
||||
* must implement.
|
||||
*/
|
||||
@protocol IBSelectionOwners <NSObject>
|
||||
- (unsigned) selectionCount;
|
||||
- (NSArray*) selection;
|
||||
- (void) drawSelection;
|
||||
@end
|
||||
|
||||
/*
|
||||
* The IBEditors protocol defines API for object editors. This is probably the
|
||||
* area in which Gorm differs most from InterfaceBuilder, as I have no clear
|
||||
* idea of how InterfaceBuilder editors are meant to operate.
|
||||
*/
|
||||
@protocol IBEditors <IBSelectionOwners>
|
||||
/*
|
||||
* Decide whether an editor can accept data from the pasteboard.
|
||||
*/
|
||||
- (BOOL) acceptsTypeFromArray: (NSArray*)types;
|
||||
|
||||
/*
|
||||
* Activate an editor - inserts it into the view hierarchy or whatever is
|
||||
* needed for the editor to be able to provide its functionality.
|
||||
* This method should be called by the document when an editor is created
|
||||
* or opened. It should be safe to call repeatedly.
|
||||
*/
|
||||
- (BOOL) activate;
|
||||
|
||||
- (id) initWithObject: (id)anObject inDocument: (id/*<IBDocuments>*/)aDocument;
|
||||
|
||||
/*
|
||||
* Close an editor - this destroys the editor. In this method the editor
|
||||
* should tell its document that it has been closed, so that the document
|
||||
* can remove all its references to the editor.
|
||||
*/
|
||||
- (void) close;
|
||||
|
||||
/*
|
||||
* Close subeditors of this editor.
|
||||
*/
|
||||
- (void) closeSubeditors;
|
||||
|
||||
/*
|
||||
* This method places the current selection from the editor on the pasteboard.
|
||||
*/
|
||||
- (void) copySelection;
|
||||
|
||||
/*
|
||||
* Deactivate an editor - removes it from the view hierarchy so that objects
|
||||
* can be archived without including the editor.
|
||||
* This method should be called automatically by the 'close' method.
|
||||
* It should be safe to call repeatedly.
|
||||
*/
|
||||
- (void) deactivate;
|
||||
|
||||
/*
|
||||
* This method deletes all the objects in the current selection in the editor.
|
||||
*/
|
||||
- (void) deleteSelection;
|
||||
|
||||
/*
|
||||
* This method returns the document that owns the object that the editor edits.
|
||||
*/
|
||||
- (id /*<IBDocuments>*/) document;
|
||||
|
||||
/*
|
||||
* This method returns the object that the editor is editing.
|
||||
*/
|
||||
- (id) editedObject;
|
||||
|
||||
/*
|
||||
* This method is used to draw or remove markup that identifies selected
|
||||
* objects within the object being edited.
|
||||
*/
|
||||
- (void) makeSelectionVisible: (BOOL)flag;
|
||||
|
||||
/*
|
||||
* This method is used to open an editor for an object within the object
|
||||
* currently being edited.
|
||||
*/
|
||||
- (id<IBEditors>) openSubeditorForObject: (id)anObject;
|
||||
|
||||
/*
|
||||
* This method is used to ensure that the editor is visible on screen.
|
||||
*/
|
||||
- (void) orderFront;
|
||||
|
||||
/*
|
||||
* This method is used to add the contents of the pasteboard to the current
|
||||
* selection of objects within the editor.
|
||||
*/
|
||||
- (void) pasteInSelection;
|
||||
|
||||
/*
|
||||
* FIXME - I don't think we use this.
|
||||
*/
|
||||
- (void) resetObject: (id)anObject;
|
||||
|
||||
/*
|
||||
* This method changes the current selection to those objects in the array.
|
||||
*/
|
||||
- (void) selectObjects: (NSArray*)objects;
|
||||
|
||||
/*
|
||||
* FIXME - I don't think we use this.
|
||||
*/
|
||||
- (void) validateEditing;
|
||||
|
||||
/*
|
||||
* When an editor resigns the selection ownership, all editors are asked if
|
||||
* they want selection ownership, and the first one to return YES gets made
|
||||
* into the current selection owner.
|
||||
*/
|
||||
- (BOOL) wantsSelection;
|
||||
|
||||
/*
|
||||
* This returns the window in which the editor is drawn.
|
||||
*/
|
||||
- (NSWindow*) window;
|
||||
@end
|
||||
|
||||
|
|
100
Gorm.m
100
Gorm.m
|
@ -130,6 +130,7 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
|||
RELEASE(infoPanel);
|
||||
RELEASE(inspectorsManager);
|
||||
RELEASE(palettesManager);
|
||||
RELEASE(hiddenDuringTest);
|
||||
RELEASE(documents);
|
||||
RELEASE(classManager);
|
||||
[super dealloc];
|
||||
|
@ -240,10 +241,39 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
|||
else
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
NSEnumerator *e;
|
||||
NSWindow *w;
|
||||
id val;
|
||||
|
||||
[nc postNotificationName: IBWillEndTestingInterfaceNotification
|
||||
object: self];
|
||||
|
||||
/*
|
||||
* Make sure windows will go away when the container is destroyed.
|
||||
*/
|
||||
e = [[testContainer nameTable] objectEnumerator];
|
||||
while ((val = [e nextObject]) != nil)
|
||||
{
|
||||
if ([val isKindOfClass: [NSWindow class]] == YES)
|
||||
{
|
||||
[val setReleasedWhenClosed: YES];
|
||||
[val close];
|
||||
}
|
||||
}
|
||||
DESTROY(testContainer);
|
||||
|
||||
/*
|
||||
* Restore old windows.
|
||||
*/
|
||||
e = [hiddenDuringTest objectEnumerator];
|
||||
while ((w = [e nextObject]) != nil)
|
||||
{
|
||||
[w orderFront: self];
|
||||
}
|
||||
[hiddenDuringTest removeAllObjects];
|
||||
|
||||
isTesting = NO;
|
||||
|
||||
if ([selectionOwner conformsToProtocol: @protocol(IBEditors)] == YES)
|
||||
{
|
||||
[(id<IBEditors>)selectionOwner makeSelectionVisible: YES];
|
||||
|
@ -311,6 +341,7 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
|||
targetImage = [[NSImage alloc] initWithContentsOfFile: path];
|
||||
|
||||
documents = [NSMutableArray new];
|
||||
hiddenDuringTest = [NSMutableArray new];
|
||||
[nc addObserver: self
|
||||
selector: @selector(handleNotification:)
|
||||
name: IBSelectionChangedNotification
|
||||
|
@ -533,16 +564,85 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
|||
else
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
NSEnumerator *e;
|
||||
NSWindow *w;
|
||||
NSData *d;
|
||||
|
||||
[nc postNotificationName: IBWillBeginTestingInterfaceNotification
|
||||
object: self];
|
||||
|
||||
isTesting = YES;
|
||||
|
||||
[activeDocument beginArchiving];
|
||||
d = [NSArchiver archivedDataWithRootObject: activeDocument];
|
||||
[activeDocument endArchiving];
|
||||
|
||||
e = [[self windows] objectEnumerator];
|
||||
while ((w = [e nextObject]) != nil)
|
||||
{
|
||||
if ([w isVisible] == YES
|
||||
&& [w isKindOfClass: [NSMenuWindow class]] == NO)
|
||||
{
|
||||
[hiddenDuringTest addObject: w];
|
||||
[w orderOut: self];
|
||||
}
|
||||
}
|
||||
|
||||
if ([selectionOwner conformsToProtocol: @protocol(IBEditors)] == YES)
|
||||
{
|
||||
[(id<IBEditors>)selectionOwner makeSelectionVisible: NO];
|
||||
}
|
||||
|
||||
testContainer = [NSUnarchiver unarchiveObjectWithData: d];
|
||||
if (testContainer != nil)
|
||||
{
|
||||
NSDictionary *nameTable = [testContainer nameTable];
|
||||
NSEnumerator *enumerator;
|
||||
id<IBConnectors> connection;
|
||||
id val;
|
||||
|
||||
RETAIN(testContainer);
|
||||
/*
|
||||
* establish connections
|
||||
*/
|
||||
enumerator = [[testContainer connections] objectEnumerator];
|
||||
while ((connection = [enumerator nextObject]) != nil)
|
||||
{
|
||||
val = [nameTable objectForKey: [connection source]];
|
||||
[connection setSource: val];
|
||||
val = [nameTable objectForKey: [connection destination]];
|
||||
[connection setDestination: val];
|
||||
[connection establishConnection];
|
||||
}
|
||||
/*
|
||||
* wake loaded objects.
|
||||
*/
|
||||
enumerator = [nameTable objectEnumerator];
|
||||
while ((val = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([val respondsToSelector: @selector(awakeFromNib)])
|
||||
{
|
||||
[val awakeFromNib];
|
||||
}
|
||||
}
|
||||
/*
|
||||
* See if there are objects that should be made visible.
|
||||
*/
|
||||
val = [nameTable objectForKey: @"NSVisible"];
|
||||
if (val != nil && [val isKindOfClass: [NSArray class]] == YES)
|
||||
{
|
||||
unsigned pos = [val count];
|
||||
|
||||
while (pos-- > 0)
|
||||
{
|
||||
[[val objectAtIndex: pos] orderFront: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[nc postNotificationName: IBDidBeginTestingInterfaceNotification
|
||||
object: self];
|
||||
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,11 +33,13 @@
|
|||
BOOL hiddenDuringTest;
|
||||
NSMenu *savedMenu;
|
||||
NSMenuItem *quitItem; /* Replaced during test */
|
||||
NSMutableArray *savedEditors;
|
||||
}
|
||||
- (void) addConnector: (id<IBConnectors>)aConnector;
|
||||
- (NSArray*) allConnectors;
|
||||
- (void) attachObject: (id)anObject toParent: (id)aParent;
|
||||
- (void) attachObjects: (NSArray*)anArray toParent: (id)aParent;
|
||||
- (void) beginArchiving;
|
||||
- (NSArray*) connectorsForDestination: (id)destination;
|
||||
- (NSArray*) connectorsForDestination: (id)destination
|
||||
ofClass: (Class)aConnectorClass;
|
||||
|
@ -55,9 +57,11 @@
|
|||
- (void) detachObject: (id)anObject;
|
||||
- (void) detachObjects: (NSArray*)anArray;
|
||||
- (NSString*) documentPath;
|
||||
- (void) endArchiving;
|
||||
- (void) handleNotification: (NSNotification*)aNotification;
|
||||
- (NSString*) nameForObject: (id)anObject;
|
||||
- (id) objectForName: (NSString*)aString;
|
||||
- (BOOL) objectIsVisibleAtLaunch: (id)anObject;
|
||||
- (NSArray*) objects;
|
||||
- (id) openDocument: (id)sender;
|
||||
- (id) parentOfObject: (id)anObject;
|
||||
|
@ -69,6 +73,7 @@
|
|||
- (id) saveDocument: (id)sender;
|
||||
- (void) setDocumentActive: (BOOL)flag;
|
||||
- (void) setName: (NSString*)aName forObject: (id)object;
|
||||
- (void) setObject: (id)anObject isVisibleAtLaunch: (BOOL)flag;
|
||||
- (void) touch; /* Mark document as having been changed. */
|
||||
- (BOOL) windowShouldClose;
|
||||
@end
|
||||
|
|
262
GormDocument.m
262
GormDocument.m
|
@ -148,6 +148,14 @@ static NSImage *classesImage = nil;
|
|||
{
|
||||
NSArray *old;
|
||||
|
||||
RETAIN(anObject);
|
||||
/*
|
||||
* remove any old linkage
|
||||
*/
|
||||
if ([self containsObject: anObject] == YES)
|
||||
{
|
||||
[self detachObject: anObject];
|
||||
}
|
||||
/*
|
||||
* Create a connector that links this object to its parent.
|
||||
* A nil parent is the root of the hierarchy so we use a dummy object for it.
|
||||
|
@ -178,6 +186,7 @@ static NSImage *classesImage = nil;
|
|||
[objectsView addObject: anObject];
|
||||
[[self openEditorForObject: anObject] activate];
|
||||
}
|
||||
RELEASE(anObject);
|
||||
}
|
||||
|
||||
- (void) attachObjects: (NSArray*)anArray toParent: (id)aParent
|
||||
|
@ -191,6 +200,53 @@ static NSImage *classesImage = nil;
|
|||
}
|
||||
}
|
||||
|
||||
- (void) beginArchiving
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id<IBConnectors> con;
|
||||
id obj;
|
||||
|
||||
/*
|
||||
* Map all connector sources and destinations to their name strings.
|
||||
* Deactivate editors so they won't be archived.
|
||||
*/
|
||||
enumerator = [connections objectEnumerator];
|
||||
while ((con = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([con isKindOfClass: [GormObjectToEditor class]] == YES)
|
||||
{
|
||||
[savedEditors addObject: con];
|
||||
[[con destination] deactivate];
|
||||
}
|
||||
else if ([con isKindOfClass: [GormEditorToParent class]] == YES)
|
||||
{
|
||||
[savedEditors addObject: con];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *name;
|
||||
|
||||
obj = [con source];
|
||||
name = [self nameForObject: obj];
|
||||
[con setSource: name];
|
||||
obj = [con destination];
|
||||
name = [self nameForObject: obj];
|
||||
[con setDestination: name];
|
||||
}
|
||||
}
|
||||
[connections removeObjectsInArray: savedEditors];
|
||||
|
||||
/*
|
||||
* Remove objects and connections that shouldn't be archived.
|
||||
*/
|
||||
[nameTable removeObjectForKey: @"NSOwner"];
|
||||
[nameTable removeObjectForKey: @"NSFirst"];
|
||||
if (fontManager != nil)
|
||||
{
|
||||
[nameTable removeObjectForKey: @"NSFont"];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A Gorm document is encoded in the archive as a GSNibContainer ...
|
||||
* A class that the gnustep gui library knbows about and can unarchive.
|
||||
|
@ -297,16 +353,18 @@ static NSImage *classesImage = nil;
|
|||
RELEASE(fontManager);
|
||||
NSFreeMapTable(objToName);
|
||||
RELEASE(documentPath);
|
||||
RELEASE(savedEditors);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) detachObject: (id)anObject
|
||||
{
|
||||
NSString *name = [self nameForObject: anObject];
|
||||
unsigned count = [connections count];
|
||||
unsigned count;
|
||||
|
||||
[[self editorForObject: anObject create: NO] close];
|
||||
|
||||
count = [connections count];
|
||||
while (count-- > 0)
|
||||
{
|
||||
id<IBConnectors> con = [connections objectAtIndex: count];
|
||||
|
@ -322,6 +380,12 @@ static NSImage *classesImage = nil;
|
|||
{
|
||||
[objectsView removeObject: anObject];
|
||||
}
|
||||
/*
|
||||
* Make sure this object isn't in the list of objects to be made visible
|
||||
* on nib loading.
|
||||
*/
|
||||
[self setObject: anObject isVisibleAtLaunch: NO];
|
||||
|
||||
[nameTable removeObjectForKey: name];
|
||||
}
|
||||
|
||||
|
@ -341,6 +405,50 @@ static NSImage *classesImage = nil;
|
|||
return documentPath;
|
||||
}
|
||||
|
||||
- (void) endArchiving
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id<IBConnectors> con;
|
||||
id obj;
|
||||
|
||||
/*
|
||||
* Restore removed objects.
|
||||
*/
|
||||
[nameTable setObject: filesOwner forKey: @"NSOwner"];
|
||||
[nameTable setObject: firstResponder forKey: @"NSFirst"];
|
||||
if (fontManager != nil)
|
||||
{
|
||||
[nameTable setObject: fontManager forKey: @"NSFont"];
|
||||
}
|
||||
|
||||
/*
|
||||
* Map all connector source and destination names to their objects.
|
||||
*/
|
||||
enumerator = [connections objectEnumerator];
|
||||
while ((con = [enumerator nextObject]) != nil)
|
||||
{
|
||||
NSString *name;
|
||||
|
||||
name = (NSString*)[con source];
|
||||
obj = [self objectForName: name];
|
||||
[con setSource: obj];
|
||||
name = (NSString*)[con destination];
|
||||
obj = [self objectForName: name];
|
||||
[con setDestination: obj];
|
||||
}
|
||||
|
||||
/*
|
||||
* Restore editor links and reactivate the editors.
|
||||
*/
|
||||
[connections addObjectsFromArray: savedEditors];
|
||||
enumerator = [savedEditors objectEnumerator];
|
||||
while ((con = [enumerator nextObject]) != nil)
|
||||
{
|
||||
[[con destination] activate];
|
||||
}
|
||||
[savedEditors removeAllObjects];
|
||||
}
|
||||
|
||||
- (void) handleNotification: (NSNotification*)aNotification
|
||||
{
|
||||
NSString *name = [aNotification name];
|
||||
|
@ -470,33 +578,25 @@ static NSImage *classesImage = nil;
|
|||
- (void) editor: (id<IBEditors>)anEditor didCloseForObject: (id)anObject
|
||||
{
|
||||
NSArray *links;
|
||||
id<IBConnectors> con;
|
||||
|
||||
/*
|
||||
* If there is a link from this editor to a parent, remove it.
|
||||
*/
|
||||
links = [self connectorsForSource: anEditor
|
||||
ofClass: [GormEditorToParent class]];
|
||||
con = [links lastObject];
|
||||
if (con != nil)
|
||||
NSAssert([links count] < 2, NSInternalInconsistencyException);
|
||||
if ([links count] == 1)
|
||||
{
|
||||
[connections removeObjectIdenticalTo: con];
|
||||
[connections removeObjectIdenticalTo: [links objectAtIndex: 0]];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Remove the connection linking the object to this editor.
|
||||
*/
|
||||
links = [self connectorsForSource: anObject
|
||||
ofClass: [GormObjectToEditor class]];
|
||||
con = [links lastObject];
|
||||
if (con != nil)
|
||||
{
|
||||
[connections removeObjectIdenticalTo: con];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Strange - removing editor without link from %@", anObject);
|
||||
}
|
||||
NSAssert([links count] == 1, NSInternalInconsistencyException);
|
||||
[connections removeObjectIdenticalTo: [links objectAtIndex: 0]];
|
||||
}
|
||||
|
||||
- (id<IBEditors>) editorForObject: (id)anObject
|
||||
|
@ -568,6 +668,7 @@ static NSImage *classesImage = nil;
|
|||
objToName = NSCreateMapTableWithZone(NSNonRetainedObjectMapKeyCallBacks,
|
||||
NSNonRetainedObjectMapValueCallBacks, 128, [self zone]);
|
||||
|
||||
savedEditors = [NSMutableArray new];
|
||||
|
||||
style = NSTitledWindowMask | NSClosableWindowMask
|
||||
| NSResizableWindowMask | NSMiniaturizableWindowMask;
|
||||
|
@ -691,6 +792,11 @@ static NSImage *classesImage = nil;
|
|||
return [nameTable objectForKey: name];
|
||||
}
|
||||
|
||||
- (BOOL) objectIsVisibleAtLaunch: (id)anObject
|
||||
{
|
||||
return [[nameTable objectForKey: @"NSVisible"] containsObject: anObject];
|
||||
}
|
||||
|
||||
- (NSArray*) objects
|
||||
{
|
||||
return [nameTable allValues];
|
||||
|
@ -822,6 +928,8 @@ static NSImage *classesImage = nil;
|
|||
{
|
||||
[self openEditorForObject: [p editedObject]];
|
||||
}
|
||||
[e orderFront];
|
||||
[[e window] makeKeyAndOrderFront: self];
|
||||
return e;
|
||||
}
|
||||
|
||||
|
@ -979,6 +1087,29 @@ static NSImage *classesImage = nil;
|
|||
}
|
||||
}
|
||||
|
||||
- (void) setObject: (id)anObject isVisibleAtLaunch: (BOOL)flag
|
||||
{
|
||||
NSMutableArray *a = [nameTable objectForKey: @"NSVisible"];
|
||||
|
||||
if (flag == YES)
|
||||
{
|
||||
if (a == nil)
|
||||
{
|
||||
a = [NSMutableArray new];
|
||||
[nameTable setObject: a forKey: @"NSVisible"];
|
||||
RELEASE(a);
|
||||
}
|
||||
if ([a containsObject: anObject] == NO)
|
||||
{
|
||||
[a addObject: anObject];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[a removeObject: anObject];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) saveAsDocument: (id)sender
|
||||
{
|
||||
NSSavePanel *sp;
|
||||
|
@ -1032,10 +1163,6 @@ static NSImage *classesImage = nil;
|
|||
- (id) saveDocument: (id)sender
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
NSMutableArray *editorInfo;
|
||||
NSEnumerator *enumerator;
|
||||
id<IBConnectors> con;
|
||||
id obj;
|
||||
BOOL archiveResult;
|
||||
|
||||
if (documentPath == nil || [documentPath isEqualToString: @""])
|
||||
|
@ -1046,104 +1173,11 @@ static NSImage *classesImage = nil;
|
|||
[nc postNotificationName: IBWillSaveDocumentNotification
|
||||
object: self];
|
||||
|
||||
/*
|
||||
* Map all connector sources and destinations to their name strings.
|
||||
*/
|
||||
editorInfo = [NSMutableArray new];
|
||||
enumerator = [connections objectEnumerator];
|
||||
while ((con = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([con isKindOfClass: [GormObjectToEditor class]] == YES)
|
||||
{
|
||||
[editorInfo addObject: con];
|
||||
}
|
||||
else if ([con isKindOfClass: [GormEditorToParent class]] == YES)
|
||||
{
|
||||
[editorInfo addObject: con];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *name;
|
||||
id obj;
|
||||
|
||||
obj = [con source];
|
||||
name = [self nameForObject: obj];
|
||||
[con setSource: name];
|
||||
obj = [con destination];
|
||||
name = [self nameForObject: obj];
|
||||
[con setDestination: name];
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Remove objects and connections that shouldn't be archived.
|
||||
* All editors are closed (this removes their links).
|
||||
*/
|
||||
enumerator = [editorInfo objectEnumerator];
|
||||
while ((con = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([con isKindOfClass: [GormObjectToEditor class]] == YES)
|
||||
{
|
||||
[[con destination] close];
|
||||
}
|
||||
}
|
||||
enumerator = [editorInfo objectEnumerator];
|
||||
while ((con = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([connections indexOfObjectIdenticalTo: con] != NSNotFound)
|
||||
{
|
||||
NSLog(@"Argh - not all editor links removed");
|
||||
break;
|
||||
}
|
||||
}
|
||||
RELEASE(editorInfo);
|
||||
[nameTable removeObjectForKey: @"NSOwner"];
|
||||
[nameTable removeObjectForKey: @"NSFirst"];
|
||||
if (fontManager != nil)
|
||||
{
|
||||
[nameTable removeObjectForKey: @"NSFont"];
|
||||
}
|
||||
[self beginArchiving];
|
||||
|
||||
archiveResult = [NSArchiver archiveRootObject: self toFile: documentPath];
|
||||
|
||||
/*
|
||||
* Restore removed objects.
|
||||
*/
|
||||
[nameTable setObject: filesOwner forKey: @"NSOwner"];
|
||||
[nameTable setObject: firstResponder forKey: @"NSFirst"];
|
||||
if (fontManager != nil)
|
||||
{
|
||||
[nameTable setObject: fontManager forKey: @"NSFont"];
|
||||
}
|
||||
|
||||
/*
|
||||
* Map all connector source and destination names to their objects.
|
||||
*/
|
||||
enumerator = [connections objectEnumerator];
|
||||
while ((con = [enumerator nextObject]) != nil)
|
||||
{
|
||||
NSString *name;
|
||||
id obj;
|
||||
|
||||
name = (NSString*)[con source];
|
||||
obj = [self objectForName: name];
|
||||
[con setSource: obj];
|
||||
name = (NSString*)[con destination];
|
||||
obj = [self objectForName: name];
|
||||
[con setDestination: obj];
|
||||
}
|
||||
|
||||
/*
|
||||
* Restore basic editor information.
|
||||
*/
|
||||
enumerator = [nameTable objectEnumerator];
|
||||
while ((obj = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([obj isKindOfClass: [NSWindow class]] == YES
|
||||
|| [obj isKindOfClass: [NSMenu class]] == YES)
|
||||
{
|
||||
[[self openEditorForObject: obj] activate];
|
||||
}
|
||||
}
|
||||
[self endArchiving];
|
||||
|
||||
if (archiveResult == NO)
|
||||
{
|
||||
|
|
|
@ -123,6 +123,7 @@ static NSMapTable *docMap = 0;
|
|||
|
||||
- (void) close
|
||||
{
|
||||
[self deactivate];
|
||||
[self closeSubeditors];
|
||||
}
|
||||
|
||||
|
@ -147,6 +148,10 @@ static NSMapTable *docMap = 0;
|
|||
}
|
||||
}
|
||||
|
||||
- (void) deactivate
|
||||
{
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(objects);
|
||||
|
|
|
@ -32,6 +32,8 @@ extern NSString *GormLinkPboardType;
|
|||
NSMutableArray *documents;
|
||||
BOOL isConnecting;
|
||||
BOOL isTesting;
|
||||
NSMutableArray *hiddenDuringTest;
|
||||
id testContainer;
|
||||
NSImage *linkImage;
|
||||
NSImage *sourceImage;
|
||||
NSImage *targetImage;
|
||||
|
|
|
@ -153,6 +153,7 @@ NSRectFromPoints(NSPoint p0, NSPoint p1)
|
|||
- (void) close;
|
||||
- (void) closeSubeditors;
|
||||
- (void) copySelection;
|
||||
- (void) deactivate;
|
||||
- (void) deleteSelection;
|
||||
- (id<IBDocuments>) document;
|
||||
- (void) draggedImage: (NSImage*)i endedAt: (NSPoint)p deposited: (BOOL)f;
|
||||
|
@ -173,9 +174,10 @@ NSRectFromPoints(NSPoint p0, NSPoint p1)
|
|||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
NSLog(@"Argh - encoding window editor!");
|
||||
[super encodeWithCoder: aCoder];
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Argh - encoding window editor"];
|
||||
}
|
||||
|
||||
/*
|
||||
* Intercepting events in the view and handling them
|
||||
*/
|
||||
|
@ -748,6 +750,7 @@ NSRectFromPoints(NSPoint p0, NSPoint p1)
|
|||
|
||||
- (BOOL) activate
|
||||
{
|
||||
NSAssert(isClosed == NO, NSInternalInconsistencyException);
|
||||
if (original == nil)
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
|
@ -765,47 +768,27 @@ NSRectFromPoints(NSPoint p0, NSPoint p1)
|
|||
[self addSubview: sub];
|
||||
}
|
||||
[edited setContentView: self];
|
||||
}
|
||||
if ([edited isKeyWindow] == NO)
|
||||
{
|
||||
[window makeKeyAndOrderFront: self];
|
||||
}
|
||||
if ([selection count] == 0)
|
||||
{
|
||||
[selection addObject: edited];
|
||||
}
|
||||
if ([(id<IB>)NSApp selectionOwner] != self)
|
||||
{
|
||||
[document setSelectionFromEditor: self];
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) close
|
||||
{
|
||||
[self closeSubeditors];
|
||||
NSAssert(isClosed == NO, NSInternalInconsistencyException);
|
||||
isClosed = YES;
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
|
||||
if (original != nil)
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
NSView *sub;
|
||||
|
||||
/*
|
||||
* Swap ourselves out and the original window content view in.
|
||||
*/
|
||||
[original setFrame: [self frame]];
|
||||
enumerator = [[self subviews] objectEnumerator];
|
||||
while ((sub = [enumerator nextObject]) != nil)
|
||||
{
|
||||
[original addSubview: sub];
|
||||
}
|
||||
[edited setContentView: original];
|
||||
DESTROY(original);
|
||||
}
|
||||
[self makeSelectionVisible: NO];
|
||||
if ([(id<IB>)NSApp selectionOwner] == self)
|
||||
{
|
||||
[document resignSelectionForEditor: self];
|
||||
}
|
||||
|
||||
[self closeSubeditors];
|
||||
|
||||
[self deactivate];
|
||||
|
||||
[document editor: self didCloseForObject: edited];
|
||||
}
|
||||
|
||||
|
@ -830,10 +813,35 @@ NSRectFromPoints(NSPoint p0, NSPoint p1)
|
|||
}
|
||||
}
|
||||
|
||||
- (void) deactivate
|
||||
{
|
||||
if (original != nil)
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
NSView *sub;
|
||||
|
||||
RETAIN(self);
|
||||
/*
|
||||
* Swap ourselves out and the original window content view in.
|
||||
*/
|
||||
[original setFrame: [self frame]];
|
||||
[edited setContentView: original];
|
||||
enumerator = [[self subviews] objectEnumerator];
|
||||
while ((sub = [enumerator nextObject]) != nil)
|
||||
{
|
||||
[original addSubview: sub];
|
||||
}
|
||||
DESTROY(original);
|
||||
RELEASE(self);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
[self close];
|
||||
if (isClosed == NO)
|
||||
{
|
||||
[self close];
|
||||
}
|
||||
RELEASE(edited);
|
||||
RELEASE(selection);
|
||||
RELEASE(subeditors);
|
||||
|
|
|
@ -68,6 +68,7 @@ NSString *IBSelectionChangedNotification
|
|||
|
||||
- (void) setObject: (id)anObject
|
||||
{
|
||||
ASSIGN(object, anObject);
|
||||
}
|
||||
|
||||
- (void) textDidBeginEditing: (NSNotification*)aNotification
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <AppKit/AppKit.h>
|
||||
#include "../../Gorm.h"
|
||||
#include "../../GormPrivate.h"
|
||||
|
||||
@interface GormWindowMaker : NSObject <NSCoding>
|
||||
{
|
||||
|
@ -138,6 +138,9 @@
|
|||
|
||||
|
||||
@interface GormWindowAttributesInspector : IBInspector
|
||||
{
|
||||
NSButton *visibleAtLaunchTime;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormWindowAttributesInspector
|
||||
|
@ -160,13 +163,65 @@
|
|||
backing: NSBackingStoreRetained
|
||||
defer: NO];
|
||||
contents = [window contentView];
|
||||
|
||||
box = [[NSBox alloc] initWithFrame: NSMakeRect(10, 300, 100, 50)];
|
||||
[box setTitle: @"Backing"];
|
||||
[box setBorderType: NSGrooveBorder];
|
||||
[contents addSubview: box];
|
||||
RELEASE(box);
|
||||
|
||||
box = [[NSBox alloc] initWithFrame: NSMakeRect(10, 10, 210, 250)];
|
||||
[box setTitle: @"Options"];
|
||||
[box setBorderType: NSGrooveBorder];
|
||||
[contents addSubview: box];
|
||||
RELEASE(box);
|
||||
|
||||
visibleAtLaunchTime
|
||||
= [[NSButton alloc] initWithFrame: NSMakeRect(10, 10, 180, 20)];
|
||||
[visibleAtLaunchTime setButtonType: NSSwitchButton];
|
||||
[visibleAtLaunchTime setBordered: NO];
|
||||
[visibleAtLaunchTime setImagePosition: NSImageRight];
|
||||
[visibleAtLaunchTime setTitle: @"Visible at launch time:"];
|
||||
[visibleAtLaunchTime setTarget: self];
|
||||
[visibleAtLaunchTime setAction: @selector(ok:)];
|
||||
[box addSubview: visibleAtLaunchTime];
|
||||
RELEASE(visibleAtLaunchTime);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) ok: (id)sender
|
||||
{
|
||||
GormDocument *doc = (GormDocument*)[(id<IB>)NSApp activeDocument];
|
||||
|
||||
if (sender == visibleAtLaunchTime)
|
||||
{
|
||||
if ([sender state] == NSOnState)
|
||||
{
|
||||
[doc setObject: object isVisibleAtLaunch: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[doc setObject: object isVisibleAtLaunch: NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setObject: (id)anObject
|
||||
{
|
||||
GormDocument *doc = (GormDocument*)[(id<IB>)NSApp activeDocument];
|
||||
|
||||
[super setObject: anObject];
|
||||
|
||||
if ([doc objectIsVisibleAtLaunch: object] == YES)
|
||||
{
|
||||
[visibleAtLaunchTime setState: NSOnState];
|
||||
}
|
||||
else
|
||||
{
|
||||
[visibleAtLaunchTime setState: NSOffState];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in a new issue