mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-24 03:51:22 +00:00
Removed GormResourcesManager
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@5511 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f08b53bd83
commit
01100bd4b6
9 changed files with 208 additions and 322 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Tue Dec 14 19:53:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
|
Removed GormResourcesManager - merged functionality into GormDocument
|
||||||
|
|
||||||
Tue Dec 14 17:33:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
Tue Dec 14 17:33:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* GormDocument.m: Major changes - nearly all methods implemented to
|
* GormDocument.m: Major changes - nearly all methods implemented to
|
||||||
|
|
|
@ -69,8 +69,7 @@ Gorm_OBJC_FILES = \
|
||||||
GormObjectEditor.m \
|
GormObjectEditor.m \
|
||||||
GormWindowEditor.m \
|
GormWindowEditor.m \
|
||||||
GormInspectorsManager.m \
|
GormInspectorsManager.m \
|
||||||
GormPalettesManager.m \
|
GormPalettesManager.m
|
||||||
GormResourcesManager.m
|
|
||||||
|
|
||||||
-include GNUmakefile.preamble
|
-include GNUmakefile.preamble
|
||||||
|
|
||||||
|
|
2
Gorm.h
2
Gorm.h
|
@ -143,8 +143,6 @@ extern NSString *IBDidEndTestingInterfaceNotification;
|
||||||
- (void) detachObject: (id)anObject;
|
- (void) detachObject: (id)anObject;
|
||||||
- (void) detachObjects: (NSArray*)anArray;
|
- (void) detachObjects: (NSArray*)anArray;
|
||||||
- (NSString*) documentPath;
|
- (NSString*) documentPath;
|
||||||
- (BOOL) documentShouldClose;
|
|
||||||
- (void) documentWillClose;
|
|
||||||
- (void) editor: (id<IBEditors>)anEditor didCloseForObject: (id)anObject;
|
- (void) editor: (id<IBEditors>)anEditor didCloseForObject: (id)anObject;
|
||||||
- (id<IBEditors>) editorForObject: (id)anObject
|
- (id<IBEditors>) editorForObject: (id)anObject
|
||||||
create: (BOOL)flag;
|
create: (BOOL)flag;
|
||||||
|
|
14
Gorm.m
14
Gorm.m
|
@ -35,13 +35,13 @@
|
||||||
|
|
||||||
- (BOOL) applicationShouldTerminate: (NSApplication*)sender
|
- (BOOL) applicationShouldTerminate: (NSApplication*)sender
|
||||||
{
|
{
|
||||||
NSEnumerator *enumerator = [documents objectEnumerator];
|
NSEnumerator *enumerator = [[self windows] objectEnumerator];
|
||||||
GormDocument *doc;
|
NSWindow *win;
|
||||||
BOOL edited = NO;
|
BOOL edited = NO;
|
||||||
|
|
||||||
while ((doc = [enumerator nextObject]) != nil)
|
while ((win = [enumerator nextObject]) != nil)
|
||||||
{
|
{
|
||||||
if ([[[doc resourcesManager] window] isDocumentEdited] == YES)
|
if ([win isDocumentEdited] == YES)
|
||||||
{
|
{
|
||||||
edited = YES;
|
edited = YES;
|
||||||
}
|
}
|
||||||
|
@ -58,11 +58,9 @@
|
||||||
}
|
}
|
||||||
else if (result != NSAlertOtherReturn)
|
else if (result != NSAlertOtherReturn)
|
||||||
{
|
{
|
||||||
enumerator = [documents objectEnumerator];
|
enumerator = [[self windows] objectEnumerator];
|
||||||
while ((doc = [enumerator nextObject]) != nil)
|
while ((win = [enumerator nextObject]) != nil)
|
||||||
{
|
{
|
||||||
NSWindow *win = [[doc resourcesManager] window];
|
|
||||||
|
|
||||||
if ([win isDocumentEdited] == YES)
|
if ([win isDocumentEdited] == YES)
|
||||||
{
|
{
|
||||||
[win performClose: self];
|
[win performClose: self];
|
||||||
|
|
|
@ -21,13 +21,15 @@
|
||||||
|
|
||||||
@interface GormDocument : GSNibContainer <IBDocuments>
|
@interface GormDocument : GSNibContainer <IBDocuments>
|
||||||
{
|
{
|
||||||
GormResourcesManager *resourcesManager;
|
|
||||||
GormFilesOwner *filesOwner;
|
GormFilesOwner *filesOwner;
|
||||||
GormFirstResponder *firstResponder;
|
GormFirstResponder *firstResponder;
|
||||||
GormFontManager *fontManager;
|
GormFontManager *fontManager;
|
||||||
NSString *documentPath;
|
NSString *documentPath;
|
||||||
NSMapTable *objToName;
|
NSMapTable *objToName;
|
||||||
id owner; /* Dummy object */
|
NSWindow *window;
|
||||||
|
NSMatrix *selectionView;
|
||||||
|
NSScrollView *scrollView;
|
||||||
|
id objectsView;
|
||||||
}
|
}
|
||||||
- (void) addConnector: (id<IBConnectors>)aConnector;
|
- (void) addConnector: (id<IBConnectors>)aConnector;
|
||||||
- (NSArray*) allConnectors;
|
- (NSArray*) allConnectors;
|
||||||
|
@ -50,8 +52,7 @@
|
||||||
- (void) detachObject: (id)anObject;
|
- (void) detachObject: (id)anObject;
|
||||||
- (void) detachObjects: (NSArray*)anArray;
|
- (void) detachObjects: (NSArray*)anArray;
|
||||||
- (NSString*) documentPath;
|
- (NSString*) documentPath;
|
||||||
- (BOOL) documentShouldClose;
|
- (void) handleNotification: (NSNotification*)aNotification;
|
||||||
- (void) documentWillClose;
|
|
||||||
- (NSString*) nameForObject: (id)anObject;
|
- (NSString*) nameForObject: (id)anObject;
|
||||||
- (id) objectForName: (NSString*)aString;
|
- (id) objectForName: (NSString*)aString;
|
||||||
- (NSArray*) objects;
|
- (NSArray*) objects;
|
||||||
|
@ -60,13 +61,13 @@
|
||||||
- (NSArray*) pasteType: (NSString*)aType
|
- (NSArray*) pasteType: (NSString*)aType
|
||||||
fromPasteboard: (NSPasteboard*)aPasteboard
|
fromPasteboard: (NSPasteboard*)aPasteboard
|
||||||
parent: (id)parent;
|
parent: (id)parent;
|
||||||
- (GormResourcesManager*) resourcesManager;
|
|
||||||
- (void) removeConnector: (id<IBConnectors>)aConnector;
|
- (void) removeConnector: (id<IBConnectors>)aConnector;
|
||||||
- (id) saveAsDocument: (id)sender;
|
- (id) saveAsDocument: (id)sender;
|
||||||
- (id) saveDocument: (id)sender;
|
- (id) saveDocument: (id)sender;
|
||||||
- (void) setDocumentActive: (BOOL)flag;
|
- (void) setDocumentActive: (BOOL)flag;
|
||||||
- (void) setName: (NSString*)aName forObject: (id)object;
|
- (void) setName: (NSString*)aName forObject: (id)object;
|
||||||
- (void) touch; /* Mark document as having been changed. */
|
- (void) touch; /* Mark document as having been changed. */
|
||||||
|
- (BOOL) windowShouldClose;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
226
GormDocument.m
226
GormDocument.m
|
@ -29,6 +29,8 @@ NSString *IBWillSaveDocumentNotification = @"IBWillSaveDocumentNotification";
|
||||||
NSString *IBDidSaveDocumentNotification = @"IBDidSaveDocumentNotification";
|
NSString *IBDidSaveDocumentNotification = @"IBDidSaveDocumentNotification";
|
||||||
NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
||||||
|
|
||||||
|
@class GormObjectEditor;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Each document has a GormFilesOwner object that is used as a placeholder
|
* Each document has a GormFilesOwner object that is used as a placeholder
|
||||||
* for the owner of the document.
|
* for the owner of the document.
|
||||||
|
@ -126,10 +128,39 @@ NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
||||||
|
|
||||||
@implementation GormDocument
|
@implementation GormDocument
|
||||||
|
|
||||||
|
static NSImage *objectsImage = nil;
|
||||||
|
static NSImage *imagesImage = nil;
|
||||||
|
static NSImage *soundsImage = nil;
|
||||||
|
static NSImage *classesImage = nil;
|
||||||
|
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
if (self == [GormDocument class])
|
if (self == [GormDocument class])
|
||||||
{
|
{
|
||||||
|
NSBundle *bundle;
|
||||||
|
NSString *path;
|
||||||
|
|
||||||
|
bundle = [NSBundle mainBundle];
|
||||||
|
path = [bundle pathForImageResource: @"GormObject"];
|
||||||
|
if (path != nil)
|
||||||
|
{
|
||||||
|
objectsImage = [[NSImage alloc] initWithContentsOfFile: path];
|
||||||
|
}
|
||||||
|
path = [bundle pathForImageResource: @"GormImage"];
|
||||||
|
if (path != nil)
|
||||||
|
{
|
||||||
|
imagesImage = [[NSImage alloc] initWithContentsOfFile: path];
|
||||||
|
}
|
||||||
|
path = [bundle pathForImageResource: @"GormSound"];
|
||||||
|
if (path != nil)
|
||||||
|
{
|
||||||
|
soundsImage = [[NSImage alloc] initWithContentsOfFile: path];
|
||||||
|
}
|
||||||
|
path = [bundle pathForImageResource: @"GormClass"];
|
||||||
|
if (path != nil)
|
||||||
|
{
|
||||||
|
classesImage = [[NSImage alloc] initWithContentsOfFile: path];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +208,7 @@ NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
||||||
if ([anObject isKindOfClass: [NSWindow class]] == YES
|
if ([anObject isKindOfClass: [NSWindow class]] == YES
|
||||||
|| [anObject isKindOfClass: [NSMenu class]] == YES)
|
|| [anObject isKindOfClass: [NSMenu class]] == YES)
|
||||||
{
|
{
|
||||||
[resourcesManager addObject: anObject];
|
[objectsView addObject: anObject];
|
||||||
[[self openEditorForObject: anObject] activate];
|
[[self openEditorForObject: anObject] activate];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,8 +321,9 @@ NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[[resourcesManager window] performClose: self];
|
[window setDelegate: nil];
|
||||||
RELEASE(resourcesManager);
|
[window performClose: self];
|
||||||
|
RELEASE(window);
|
||||||
RELEASE(filesOwner);
|
RELEASE(filesOwner);
|
||||||
RELEASE(firstResponder);
|
RELEASE(firstResponder);
|
||||||
RELEASE(fontManager);
|
RELEASE(fontManager);
|
||||||
|
@ -320,7 +352,7 @@ NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
||||||
if ([anObject isKindOfClass: [NSWindow class]] == YES
|
if ([anObject isKindOfClass: [NSWindow class]] == YES
|
||||||
|| [anObject isKindOfClass: [NSMenu class]] == YES)
|
|| [anObject isKindOfClass: [NSMenu class]] == YES)
|
||||||
{
|
{
|
||||||
[resourcesManager removeObject: anObject];
|
[objectsView removeObject: anObject];
|
||||||
}
|
}
|
||||||
[nameTable removeObjectForKey: name];
|
[nameTable removeObjectForKey: name];
|
||||||
}
|
}
|
||||||
|
@ -341,37 +373,10 @@ NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
||||||
return documentPath;
|
return documentPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) documentShouldClose
|
- (void) handleNotification: (NSNotification*)aNotification
|
||||||
{
|
{
|
||||||
if ([[resourcesManager window] isDocumentEdited] == YES)
|
if ([[aNotification name] isEqual: NSWindowWillCloseNotification] == YES)
|
||||||
{
|
{
|
||||||
NSString *msg;
|
|
||||||
int result;
|
|
||||||
|
|
||||||
if (documentPath == nil || [documentPath isEqualToString: @""])
|
|
||||||
{
|
|
||||||
msg = @"Document 'UNTITLED' has been modified";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg = [NSString stringWithFormat: @"Document '%@' has been modified",
|
|
||||||
[documentPath lastPathComponent]];
|
|
||||||
}
|
|
||||||
result = NSRunAlertPanel(NULL, msg, @"Save", @"Cancel", @"Don't Save");
|
|
||||||
if (result == NSAlertAlternateReturn)
|
|
||||||
{
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
else if (result != NSAlertOtherReturn)
|
|
||||||
{
|
|
||||||
[self saveDocument: self];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) documentWillClose
|
|
||||||
{
|
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
Class winClass = [NSWindow class];
|
Class winClass = [NSWindow class];
|
||||||
NSEnumerator *enumerator;
|
NSEnumerator *enumerator;
|
||||||
|
@ -392,6 +397,7 @@ NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[self setDocumentActive: NO];
|
[self setDocumentActive: NO];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) editor: (id<IBEditors>)anEditor didCloseForObject: (id)anObject
|
- (void) editor: (id<IBEditors>)anEditor didCloseForObject: (id)anObject
|
||||||
|
@ -576,19 +582,113 @@ NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self != nil)
|
if (self != nil)
|
||||||
{
|
{
|
||||||
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
NSRect winrect = NSMakeRect(100,100,340,252);
|
||||||
|
NSRect selectionRect = {{0, 188}, {240, 64}};
|
||||||
|
NSRect scrollRect = {{0, 0}, {340, 188}};
|
||||||
|
NSRect mainRect = {{20, 0}, {320, 188}};
|
||||||
|
NSImage *image;
|
||||||
|
NSButtonCell *cell;
|
||||||
|
unsigned style;
|
||||||
|
|
||||||
objToName = NSCreateMapTableWithZone(NSNonRetainedObjectMapKeyCallBacks,
|
objToName = NSCreateMapTableWithZone(NSNonRetainedObjectMapKeyCallBacks,
|
||||||
NSNonRetainedObjectMapValueCallBacks, 128, [self zone]);
|
NSNonRetainedObjectMapValueCallBacks, 128, [self zone]);
|
||||||
|
|
||||||
resourcesManager = [GormResourcesManager newManagerForDocument: self];
|
|
||||||
|
style = NSTitledWindowMask | NSClosableWindowMask
|
||||||
|
| NSResizableWindowMask | NSMiniaturizableWindowMask;
|
||||||
|
window = [[NSWindow alloc] initWithContentRect: winrect
|
||||||
|
styleMask: style
|
||||||
|
backing: NSBackingStoreRetained
|
||||||
|
defer: NO];
|
||||||
|
[window setMinSize: [window frame].size];
|
||||||
|
[window setTitle: @"UNTITLED"];
|
||||||
|
|
||||||
|
[window setDelegate: self];
|
||||||
|
[nc addObserver: self
|
||||||
|
selector: @selector(handleNotification:)
|
||||||
|
name: NSWindowWillCloseNotification
|
||||||
|
object: window];
|
||||||
|
|
||||||
|
selectionView = [[NSMatrix alloc] initWithFrame: selectionRect
|
||||||
|
mode: NSRadioModeMatrix
|
||||||
|
cellClass: [NSButtonCell class]
|
||||||
|
numberOfRows: 1
|
||||||
|
numberOfColumns: 4];
|
||||||
|
[selectionView setTarget: self];
|
||||||
|
[selectionView setAction: @selector(changeView:)];
|
||||||
|
[selectionView setAutosizesCells: NO];
|
||||||
|
[selectionView setCellSize: NSMakeSize(64,64)];
|
||||||
|
[selectionView setIntercellSpacing: NSMakeSize(28,0)];
|
||||||
|
[selectionView setAutoresizingMask: NSViewMinYMargin|NSViewWidthSizable];
|
||||||
|
|
||||||
|
if ((image = objectsImage) != nil)
|
||||||
|
{
|
||||||
|
cell = [selectionView cellAtRow: 0 column: 0];
|
||||||
|
[cell setImage: image];
|
||||||
|
[cell setTitle: @"Objects"];
|
||||||
|
[cell setBordered: NO];
|
||||||
|
[cell setAlignment: NSCenterTextAlignment];
|
||||||
|
[cell setImagePosition: NSImageAbove];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((image = imagesImage) != nil)
|
||||||
|
{
|
||||||
|
cell = [selectionView cellAtRow: 0 column: 1];
|
||||||
|
[cell setImage: image];
|
||||||
|
[cell setTitle: @"Images"];
|
||||||
|
[cell setBordered: NO];
|
||||||
|
[cell setAlignment: NSCenterTextAlignment];
|
||||||
|
[cell setImagePosition: NSImageAbove];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((image = soundsImage) != nil)
|
||||||
|
{
|
||||||
|
cell = [selectionView cellAtRow: 0 column: 2];
|
||||||
|
[cell setImage: image];
|
||||||
|
[cell setTitle: @"Sounds"];
|
||||||
|
[cell setBordered: NO];
|
||||||
|
[cell setAlignment: NSCenterTextAlignment];
|
||||||
|
[cell setImagePosition: NSImageAbove];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((image = classesImage) != nil)
|
||||||
|
{
|
||||||
|
cell = [selectionView cellAtRow: 0 column: 3];
|
||||||
|
[cell setImage: image];
|
||||||
|
[cell setTitle: @"Classes"];
|
||||||
|
[cell setBordered: NO];
|
||||||
|
[cell setAlignment: NSCenterTextAlignment];
|
||||||
|
[cell setImagePosition: NSImageAbove];
|
||||||
|
}
|
||||||
|
|
||||||
|
[[window contentView] addSubview: selectionView];
|
||||||
|
RELEASE(selectionView);
|
||||||
|
|
||||||
|
scrollView = [[NSScrollView alloc] initWithFrame: scrollRect];
|
||||||
|
[scrollView setHasVerticalScroller: YES];
|
||||||
|
[scrollView setHasHorizontalScroller: NO];
|
||||||
|
[scrollView setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
|
||||||
|
[[window contentView] addSubview: scrollView];
|
||||||
|
RELEASE(scrollView);
|
||||||
|
|
||||||
|
mainRect.origin = NSMakePoint(0,0);
|
||||||
|
objectsView = [[GormObjectEditor alloc] initWithObject: nil
|
||||||
|
inDocument: self];
|
||||||
|
[objectsView setFrame: mainRect];
|
||||||
|
[objectsView setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
|
||||||
|
[scrollView setDocumentView: objectsView];
|
||||||
|
RELEASE(objectsView);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up special-case dummy objects and add them to the resources mgr.
|
* Set up special-case dummy objects and add them to the objects view.
|
||||||
*/
|
*/
|
||||||
filesOwner = [GormFilesOwner new];
|
filesOwner = [GormFilesOwner new];
|
||||||
[self setName: @"NSOwner" forObject: filesOwner];
|
[self setName: @"NSOwner" forObject: filesOwner];
|
||||||
[resourcesManager addObject: filesOwner];
|
[objectsView addObject: filesOwner];
|
||||||
firstResponder = [GormFirstResponder new];
|
firstResponder = [GormFirstResponder new];
|
||||||
[self setName: @"NSFirst" forObject: firstResponder];
|
[self setName: @"NSFirst" forObject: firstResponder];
|
||||||
[resourcesManager addObject: firstResponder];
|
[objectsView addObject: firstResponder];
|
||||||
fontManager = [GormFontManager new];
|
fontManager = [GormFontManager new];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
|
@ -709,7 +809,7 @@ NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
||||||
if ([obj isKindOfClass: [NSWindow class]] == YES
|
if ([obj isKindOfClass: [NSWindow class]] == YES
|
||||||
|| [obj isKindOfClass: [NSMenu class]] == YES)
|
|| [obj isKindOfClass: [NSMenu class]] == YES)
|
||||||
{
|
{
|
||||||
[resourcesManager addObject: obj];
|
[objectsView addObject: obj];
|
||||||
[[self openEditorForObject: obj] activate];
|
[[self openEditorForObject: obj] activate];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -718,7 +818,7 @@ NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
||||||
* Finally, we set our new file name
|
* Finally, we set our new file name
|
||||||
*/
|
*/
|
||||||
ASSIGN(documentPath, aFile);
|
ASSIGN(documentPath, aFile);
|
||||||
[[resourcesManager window] setTitleWithRepresentedFilename: documentPath];
|
[window setTitleWithRepresentedFilename: documentPath];
|
||||||
[nc postNotificationName: IBDidOpenDocumentNotification
|
[nc postNotificationName: IBDidOpenDocumentNotification
|
||||||
object: self];
|
object: self];
|
||||||
return self;
|
return self;
|
||||||
|
@ -773,8 +873,8 @@ NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
||||||
NSPoint filePoint;
|
NSPoint filePoint;
|
||||||
NSPoint screenPoint;
|
NSPoint screenPoint;
|
||||||
|
|
||||||
filePoint = [[resourcesManager window] mouseLocationOutsideOfEventStream];
|
filePoint = [window mouseLocationOutsideOfEventStream];
|
||||||
screenPoint = [[resourcesManager window] convertBaseToScreen: filePoint];
|
screenPoint = [window convertBaseToScreen: filePoint];
|
||||||
|
|
||||||
if ([aType isEqualToString: IBWindowPboardType] == YES)
|
if ([aType isEqualToString: IBWindowPboardType] == YES)
|
||||||
{
|
{
|
||||||
|
@ -830,11 +930,6 @@ NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
||||||
[editor activate];
|
[editor activate];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (GormResourcesManager*) resourcesManager
|
|
||||||
{
|
|
||||||
return resourcesManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setName: (NSString*)aName forObject: (id)object
|
- (void) setName: (NSString*)aName forObject: (id)object
|
||||||
{
|
{
|
||||||
id oldObject;
|
id oldObject;
|
||||||
|
@ -969,8 +1064,8 @@ NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
||||||
@"OK", NULL, NULL);
|
@"OK", NULL, NULL);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
[[resourcesManager window] setDocumentEdited: NO];
|
[window setDocumentEdited: NO];
|
||||||
[[resourcesManager window] setTitleWithRepresentedFilename: documentPath];
|
[window setTitleWithRepresentedFilename: documentPath];
|
||||||
|
|
||||||
[nc postNotificationName: IBWillSaveDocumentNotification
|
[nc postNotificationName: IBWillSaveDocumentNotification
|
||||||
object: self];
|
object: self];
|
||||||
|
@ -992,7 +1087,7 @@ NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
||||||
[obj orderFront: self];
|
[obj orderFront: self];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[[resourcesManager window] orderFront: self];
|
[window orderFront: self];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1003,7 +1098,7 @@ NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
||||||
[obj orderOut: self];
|
[obj orderOut: self];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[[resourcesManager window] orderOut: self];
|
[window orderOut: self];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1017,7 +1112,36 @@ NSString *IBWillCloseDocumentNotification = @"IBWillCloseDocumentNotification";
|
||||||
|
|
||||||
- (void) touch
|
- (void) touch
|
||||||
{
|
{
|
||||||
[[resourcesManager window] setDocumentEdited: YES];
|
[window setDocumentEdited: YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) windowShouldClose
|
||||||
|
{
|
||||||
|
if ([window isDocumentEdited] == YES)
|
||||||
|
{
|
||||||
|
NSString *msg;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
if (documentPath == nil || [documentPath isEqualToString: @""])
|
||||||
|
{
|
||||||
|
msg = @"Document 'UNTITLED' has been modified";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg = [NSString stringWithFormat: @"Document '%@' has been modified",
|
||||||
|
[documentPath lastPathComponent]];
|
||||||
|
}
|
||||||
|
result = NSRunAlertPanel(NULL, msg, @"Save", @"Cancel", @"Don't Save");
|
||||||
|
if (result == NSAlertAlternateReturn)
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
else if (result != NSAlertOtherReturn)
|
||||||
|
{
|
||||||
|
[self saveDocument: self];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -4,14 +4,12 @@
|
||||||
@class GormDocument;
|
@class GormDocument;
|
||||||
@class GormInspectorsManager;
|
@class GormInspectorsManager;
|
||||||
@class GormPalettesManager;
|
@class GormPalettesManager;
|
||||||
@class GormResourcesManager;
|
|
||||||
|
|
||||||
#include "Gorm.h"
|
#include "Gorm.h"
|
||||||
|
|
||||||
#include "GormDocument.h"
|
#include "GormDocument.h"
|
||||||
#include "GormInspectorsManager.h"
|
#include "GormInspectorsManager.h"
|
||||||
#include "GormPalettesManager.h"
|
#include "GormPalettesManager.h"
|
||||||
#include "GormResourcesManager.h"
|
|
||||||
|
|
||||||
@interface Gorm : NSApplication <IB>
|
@interface Gorm : NSApplication <IB>
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
#ifndef GORMRESOURCESMANAGER_H
|
|
||||||
#define GORMRESOURCESMANAGER_H
|
|
||||||
|
|
||||||
@interface GormResourcesManager : NSObject
|
|
||||||
{
|
|
||||||
NSWindow *window;
|
|
||||||
NSMatrix *selectionView;
|
|
||||||
NSScrollView *scrollView;
|
|
||||||
id objectsView;
|
|
||||||
id<IBDocuments> document;
|
|
||||||
}
|
|
||||||
+ (GormResourcesManager*) newManagerForDocument: (id<IBDocuments>)doc;
|
|
||||||
- (void) addObject: (id)anObject;
|
|
||||||
- (id<IBDocuments>) document;
|
|
||||||
- (void) removeObject: (id)anObject;
|
|
||||||
- (NSWindow*) window;
|
|
||||||
- (BOOL) windowShouldClose: (NSWindow*)aWindow;
|
|
||||||
- (void) windowWillClose: (NSNotification*)aNotification;
|
|
||||||
@end
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,215 +0,0 @@
|
||||||
/* GormResourcesManager.m
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 Free Software Foundation, Inc.
|
|
||||||
*
|
|
||||||
* Author: Richard Frith-Macdonald <richard@brainstrom.co.uk>
|
|
||||||
* Date: 1999
|
|
||||||
*
|
|
||||||
* This file is part of GNUstep.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "GormPrivate.h"
|
|
||||||
|
|
||||||
@class GormObjectEditor;
|
|
||||||
|
|
||||||
@implementation GormResourcesManager
|
|
||||||
|
|
||||||
static NSImage *objectsImage = nil;
|
|
||||||
static NSImage *imagesImage = nil;
|
|
||||||
static NSImage *soundsImage = nil;
|
|
||||||
static NSImage *classesImage = nil;
|
|
||||||
|
|
||||||
+ (void) initialize
|
|
||||||
{
|
|
||||||
if (self == [GormResourcesManager class])
|
|
||||||
{
|
|
||||||
NSBundle *bundle;
|
|
||||||
NSString *path;
|
|
||||||
|
|
||||||
bundle = [NSBundle mainBundle];
|
|
||||||
path = [bundle pathForImageResource: @"GormObject"];
|
|
||||||
if (path != nil)
|
|
||||||
{
|
|
||||||
objectsImage = [[NSImage alloc] initWithContentsOfFile: path];
|
|
||||||
}
|
|
||||||
path = [bundle pathForImageResource: @"GormImage"];
|
|
||||||
if (path != nil)
|
|
||||||
{
|
|
||||||
imagesImage = [[NSImage alloc] initWithContentsOfFile: path];
|
|
||||||
}
|
|
||||||
path = [bundle pathForImageResource: @"GormSound"];
|
|
||||||
if (path != nil)
|
|
||||||
{
|
|
||||||
soundsImage = [[NSImage alloc] initWithContentsOfFile: path];
|
|
||||||
}
|
|
||||||
path = [bundle pathForImageResource: @"GormClass"];
|
|
||||||
if (path != nil)
|
|
||||||
{
|
|
||||||
classesImage = [[NSImage alloc] initWithContentsOfFile: path];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (GormResourcesManager*) newManagerForDocument: (id<IBDocuments>)doc
|
|
||||||
{
|
|
||||||
GormResourcesManager *mgr;
|
|
||||||
|
|
||||||
mgr = [self alloc];
|
|
||||||
mgr->document = doc;
|
|
||||||
mgr = [mgr init];
|
|
||||||
return mgr;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) addObject: (id)anObject
|
|
||||||
{
|
|
||||||
[objectsView addObject: anObject];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) dealloc
|
|
||||||
{
|
|
||||||
[window performClose: self];
|
|
||||||
RELEASE(window);
|
|
||||||
RELEASE(objectsView);
|
|
||||||
[super dealloc];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id<IBDocuments>) document
|
|
||||||
{
|
|
||||||
return document;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) init
|
|
||||||
{
|
|
||||||
self = [super init];
|
|
||||||
if (self != nil)
|
|
||||||
{
|
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
||||||
NSRect winrect = NSMakeRect(100,100,340,252);
|
|
||||||
NSRect selectionRect = {{0, 188}, {240, 64}};
|
|
||||||
NSRect scrollRect = {{0, 0}, {340, 188}};
|
|
||||||
NSRect mainRect = {{20, 0}, {320, 188}};
|
|
||||||
NSImage *image;
|
|
||||||
NSButtonCell *cell;
|
|
||||||
unsigned style = NSTitledWindowMask | NSClosableWindowMask
|
|
||||||
| NSResizableWindowMask | NSMiniaturizableWindowMask;
|
|
||||||
|
|
||||||
window = [[NSWindow alloc] initWithContentRect: winrect
|
|
||||||
styleMask: style
|
|
||||||
backing: NSBackingStoreRetained
|
|
||||||
defer: NO];
|
|
||||||
[window setDelegate: self];
|
|
||||||
[window setMinSize: [window frame].size];
|
|
||||||
[window setTitle: @"UNTITLED"];
|
|
||||||
|
|
||||||
[nc addObserver: self
|
|
||||||
selector: @selector(windowWillClose:)
|
|
||||||
name: NSWindowWillCloseNotification
|
|
||||||
object: window];
|
|
||||||
|
|
||||||
selectionView = [[NSMatrix alloc] initWithFrame: selectionRect
|
|
||||||
mode: NSRadioModeMatrix
|
|
||||||
cellClass: [NSButtonCell class]
|
|
||||||
numberOfRows: 1
|
|
||||||
numberOfColumns: 4];
|
|
||||||
[selectionView setTarget: self];
|
|
||||||
[selectionView setAction: @selector(changeView:)];
|
|
||||||
[selectionView setAutosizesCells: NO];
|
|
||||||
[selectionView setCellSize: NSMakeSize(64,64)];
|
|
||||||
[selectionView setIntercellSpacing: NSMakeSize(28,0)];
|
|
||||||
[selectionView setAutoresizingMask: NSViewMinYMargin|NSViewWidthSizable];
|
|
||||||
|
|
||||||
if ((image = objectsImage) != nil)
|
|
||||||
{
|
|
||||||
cell = [selectionView cellAtRow: 0 column: 0];
|
|
||||||
[cell setImage: image];
|
|
||||||
[cell setTitle: @"Objects"];
|
|
||||||
[cell setBordered: NO];
|
|
||||||
[cell setAlignment: NSCenterTextAlignment];
|
|
||||||
[cell setImagePosition: NSImageAbove];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((image = imagesImage) != nil)
|
|
||||||
{
|
|
||||||
cell = [selectionView cellAtRow: 0 column: 1];
|
|
||||||
[cell setImage: image];
|
|
||||||
[cell setTitle: @"Images"];
|
|
||||||
[cell setBordered: NO];
|
|
||||||
[cell setAlignment: NSCenterTextAlignment];
|
|
||||||
[cell setImagePosition: NSImageAbove];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((image = soundsImage) != nil)
|
|
||||||
{
|
|
||||||
cell = [selectionView cellAtRow: 0 column: 2];
|
|
||||||
[cell setImage: image];
|
|
||||||
[cell setTitle: @"Sounds"];
|
|
||||||
[cell setBordered: NO];
|
|
||||||
[cell setAlignment: NSCenterTextAlignment];
|
|
||||||
[cell setImagePosition: NSImageAbove];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((image = classesImage) != nil)
|
|
||||||
{
|
|
||||||
cell = [selectionView cellAtRow: 0 column: 3];
|
|
||||||
[cell setImage: image];
|
|
||||||
[cell setTitle: @"Classes"];
|
|
||||||
[cell setBordered: NO];
|
|
||||||
[cell setAlignment: NSCenterTextAlignment];
|
|
||||||
[cell setImagePosition: NSImageAbove];
|
|
||||||
}
|
|
||||||
|
|
||||||
[[window contentView] addSubview: selectionView];
|
|
||||||
RELEASE(selectionView);
|
|
||||||
|
|
||||||
scrollView = [[NSScrollView alloc] initWithFrame: scrollRect];
|
|
||||||
[scrollView setHasVerticalScroller: YES];
|
|
||||||
[scrollView setHasHorizontalScroller: NO];
|
|
||||||
[scrollView setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
|
|
||||||
[[window contentView] addSubview: scrollView];
|
|
||||||
RELEASE(scrollView);
|
|
||||||
|
|
||||||
mainRect.origin = NSMakePoint(0,0);
|
|
||||||
objectsView = [[GormObjectEditor alloc] initWithObject: nil
|
|
||||||
inDocument: document];
|
|
||||||
[objectsView setFrame: mainRect];
|
|
||||||
[objectsView setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
|
|
||||||
[scrollView setDocumentView: objectsView];
|
|
||||||
}
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) removeObject: (id)anObject
|
|
||||||
{
|
|
||||||
[objectsView removeObject: anObject];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSWindow*) window
|
|
||||||
{
|
|
||||||
return window;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL) windowShouldClose: (NSWindow*)aWindow
|
|
||||||
{
|
|
||||||
return [document documentShouldClose];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) windowWillClose: (NSNotification*)aNotification
|
|
||||||
{
|
|
||||||
[document documentWillClose];
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
|
|
Loading…
Reference in a new issue