forked from pmougin/F-Script
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathFSCollectionInspector.m
68 lines (51 loc) · 2.68 KB
/
FSCollectionInspector.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* FSCollectionInspector.m Copyright (c) 1998-2009 Philippe Mougin. */
/* This software is open source. See the license. */
#import "build_config.h"
#import "FSCollectionInspector.h"
#import "FSBlock.h" // value:
#import "FSMiscTools.h"
#import "FSInterpreter.h"
#import <AppKit/AppKit.h>
#import "FSArray.h"
#import "FSNSArray.h"
//#import "FSObjectFormatter.h"
#import "Number_fscript.h"
#import "FSNSString.h"
#import "FSCollectionInspectorView.h"
static NSPoint topLeftPoint = {0,0}; // Used for cascading windows.
@implementation FSCollectionInspector
+ (FSCollectionInspector *)collectionInspectorWithCollection:(id)theCollection interpreter:(FSInterpreter *)theInterpreter blocks:(NSArray *)blocks showExternals:(BOOL)showExternals
{
return [[[self alloc] initWithCollection:theCollection interpreter:theInterpreter blocks:blocks showExternals:showExternals] autorelease];
}
+ (FSCollectionInspector *)collectionInspectorWithCollection:(id)theCollection interpreter:(FSInterpreter *)theInterpreter blocks:(NSArray *)blocks
{
return [self collectionInspectorWithCollection:theCollection interpreter:theInterpreter blocks:blocks showExternals:YES];
}
- (void)dealloc
{
//NSLog(@"FSCollectionInspector dealloc");
[super dealloc];
}
- (FSCollectionInspector *)initWithCollection:(id)theCollection interpreter:(FSInterpreter *)theInterpreter blocks:(NSArray *)blocks showExternals:(BOOL)showExternals
{
if (self = [super init])
{
[self retain]; // we must stay alive while our window exist cause we are its delegate (and NSWindow doesn't retain its delegate).
[NSBundle loadNibNamed:@"FSCollectionInspector.nib" owner:self];
[collectionInspectorView setCollection:theCollection interpreter:theInterpreter blocks:blocks showExternals:showExternals];
topLeftPoint = [[collectionInspectorView window] cascadeTopLeftFromPoint:topLeftPoint];
if ([theCollection isKindOfClass:[NSArray class]]) [[collectionInspectorView window] setTitle:@"Array Inspector"];
else if ([theCollection isKindOfClass:[NSDictionary class]]) [[collectionInspectorView window] setTitle:@"Dictionary Inspector"];
else if ([theCollection isKindOfClass:[NSCountedSet class]]) [[collectionInspectorView window] setTitle:@"Counted Set Inspector"];
else if ([theCollection isKindOfClass:[NSSet class]]) [[collectionInspectorView window] setTitle:@"Set Inspector"];
[[collectionInspectorView window] makeKeyAndOrderFront:nil]; // We configure the interface in the background before putting the window on screen
}
return self;
}
/////////////////// Window delegate callbacks
- (void)windowWillClose:(NSNotification *)aNotification
{
[self autorelease];
}
@end