-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAboutWindowController.m
57 lines (42 loc) · 1.69 KB
/
AboutWindowController.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
//
// AboutWindowController.m
// USB Missile Launcher NZ
//
// Created by David Wilson on 15/06/11.
// Copyright 2011 David G. Wilson. All rights reserved.
//
#import "AboutWindowController.h"
@implementation AboutWindowController
@synthesize applicationName;
@synthesize applicationVersion;
@synthesize applicationIcon;
@synthesize applicationText;
- (id) init
{
if ( ! (self = [super initWithWindowNibName: @"AboutWindow"]) ) {
NSLog(@"init failed in AboutWindowController");
return nil;
} // end if
return self;
}
- (void)windowDidLoad
{
// Application Name
NSString * name = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
[applicationName setStringValue:name];
// Application Version
NSString * version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
[applicationVersion setStringValue:version];
// Load and display Credits.rtf
NSSize contentSize = [applicationText contentSize];
NSTextView * theTextView = [[NSTextView alloc] initWithFrame:NSMakeRect(0, 0, contentSize.width, contentSize.height)];
[theTextView setHorizontallyResizable:YES];
[theTextView setVerticallyResizable:YES];
[theTextView setAutoresizingMask:(NSViewMaxXMargin | NSViewMinXMargin | NSViewMaxYMargin | NSViewMinYMargin | NSViewWidthSizable | NSViewHeightSizable)];
NSData *theRTFData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"rtf"]];
[theTextView replaceCharactersInRange:NSMakeRange(0, [[theTextView string] length]) withRTF:theRTFData];
[applicationText setDocumentView:theTextView];
// Load and display Application Icon
[applicationIcon setImage:[NSImage imageNamed:@"NSApplicationIcon"]];
}
@end