forked from pmougin/F-Script
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathFSAttributedStringInspector.m
57 lines (46 loc) · 1.73 KB
/
FSAttributedStringInspector.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
// FSAttributedStringInspector.m Copyright (c) 2004-2009 Philippe Mougin.
// This software is open source. See the license.
#import "FSAttributedStringInspector.h"
#import "FSMiscTools.h"
static NSPoint topLeftPoint = {0,0}; // Used for cascading windows.
@implementation FSAttributedStringInspector
+(FSAttributedStringInspector *)attributedStringInspectorWithAttributedString:(NSAttributedString *)object
{
return [[[self alloc] initWithAttributedString:object] autorelease];
}
-(FSAttributedStringInspector *)initWithAttributedString:(NSAttributedString *)object
{
if ((self = [super init]))
{
inspectedObject = [object retain];
[NSBundle loadNibNamed:@"FSAttributedStringInspector.nib" owner:self];
[self retain]; // To balance the autorelease in windowWillClose:
[self updateAction:nil];
topLeftPoint = [window cascadeTopLeftFromPoint:topLeftPoint];
[window makeKeyAndOrderFront:nil];
return self;
}
return nil;
}
-(void) dealloc
{
//NSLog(@"\n FSAttributedStringInspector dealloc\n");
[inspectedObject release];
[super dealloc];
}
- (void)updateAction:(id)sender
{
[window setTitle:[NSString stringWithFormat:@"Inspecting %@ at address %p",descriptionForFSMessage(inspectedObject), inspectedObject]];
[printStringView setFont:[NSFont userFixedPitchFontOfSize:userFixedPitchFontSize()]];
[printStringView setString:printString(inspectedObject)];
[[attributedStringView textStorage] beginEditing];
[[attributedStringView textStorage] setAttributedString:inspectedObject];
[[attributedStringView textStorage] endEditing];
}
/////////////////// Window delegate callbacks
- (void)windowWillClose:(NSNotification *)aNotification
{
//NSLog(@"\n WindowWillClose:\n");
[self autorelease];
}
@end