forked from pmougin/F-Script
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathFSImageInspector.m
58 lines (47 loc) · 1.56 KB
/
FSImageInspector.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
// FSImageInspector.m Copyright (c) 2001-2009 Philippe Mougin.
// This software is open source. See the license.
#import "FSImageInspector.h"
#import "FSMiscTools.h"
static NSPoint topLeftPoint = {0,0}; // Used for cascading windows.
@implementation FSImageInspector
+(FSImageInspector *)imageInspectorWithImage:(id)object
{
return [[[self alloc] initWithImage:object] autorelease];
}
-(FSImageInspector *)initWithImage:(id)object
{
if ((self = [super init]))
{
inspectedObject = [object retain];
[NSBundle loadNibNamed:@"FSImageInspector.nib" owner:self];
[self retain]; // To balance the autorelease in windowWillClose:
NSSize imageSize = [inspectedObject size];
[imageView setImageScaling:NSScaleNone];
if (!(imageSize.width == 0 && imageSize.height == 0))
{
[imageView setFrameSize:imageSize];
[window setContentSize:NSMakeSize(MAX(imageSize.width+15, 120), MAX(imageSize.height+15, 20))];
[window setMaxSize:[window frame].size];
}
[imageView setImage:inspectedObject];
[imageView setImageAlignment:NSImageAlignCenter];
topLeftPoint = [window cascadeTopLeftFromPoint:topLeftPoint];
[window makeKeyAndOrderFront:nil];
return self;
}
return nil;
}
-(void) dealloc
{
//NSLog(@"\n FSImageInspector dealloc\n");
[inspectedObject release];
[super dealloc];
}
/////////////////// Window delegate callbacks
- (void)windowWillClose:(NSNotification *)aNotification
{
//NSLog(@"\n WindowWillClose\n");
[self autorelease];
}
//- (unsigned)imageViewRc {return [imageView retainCount];}
@end