1 #import "MTShizzleWindow.h"
2 #import "MainController.h"
4 @interface MTShizzleWindow (Private)
5 - (void)setBling:(id)bling;
10 @implementation MTShizzleWindow
12 static MTShizzleWindow *_privateSharedWindow = nil;
14 + (id)sharedWindowForSender:(id)sender
16 if( _privateSharedWindow ) {
17 [_privateSharedWindow setBling:sender];
18 return _privateSharedWindow;
20 _privateSharedWindow = [[MTShizzleWindow alloc]
21 initWithContentRect:NSMakeRect(0, 0, 385, 353)
22 styleMask:NSTitledWindowMask
23 backing:NSBackingStoreBuffered
25 [_privateSharedWindow setBling:sender];
26 return _privateSharedWindow;
30 - (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag
32 if ( (self = [super initWithContentRect:contentRect
36 [self setLevel:NSStatusWindowLevel];
42 - (void)makeKeyAndOrderFront:(id)sender {
43 if ( ( [[NSDate date] timeIntervalSinceDate:[[MainController sharedController] getBlingTime]] >= 604800 ) && ([[regLater title] isEqualToString:@"Register Later"]) ) {
44 [regLater setTitle:@"Quit"];
45 [regLater setTarget:[NSApplication sharedApplication]];
46 [regLater setAction:@selector(terminate:)];
48 [super makeKeyAndOrderFront:sender];
54 [regBenefits release];
60 [registerButton release];
63 [contentView release];
68 - (void)setBling:(id)bling
76 unichar returnChar = '\r';
78 [self setReleasedWhenClosed:NO];
79 [self setTitle:NSLocalizedString(@"registerMenuTunes", @"Register MenuTunes")];
80 contentView = [self contentView];
82 regMessage = [[NSTextField alloc] initWithFrame:NSMakeRect(20, 282, 345, 51)];
83 [regMessage setStringValue:NSLocalizedString(@"sharewareMessage", @"MenuTunes is shareware. If you find it to be a valuable tool, please click the button below to buy your copy. Your support is greatly appreciated.")];
84 [regMessage setBordered:NO];
85 [regMessage setBezeled:NO];
86 [regMessage setEditable:NO];
87 [regMessage setSelectable:NO];
88 [regMessage setDrawsBackground:NO];
89 [contentView addSubview:regMessage];
92 box = [[NSBox alloc] initWithFrame:NSMakeRect(20, 181, 345, 81)];
93 [box setTitlePosition:NSNoTitle];
94 [box setBorderType:NSBezelBorder];
95 [contentView addSubview:box];
97 //This isn't tall enough
98 registerButton = [[NSButton alloc] initWithFrame:NSMakeRect(24, 13, 115, 49)];
99 [registerButton setImage:[NSImage imageNamed:@"esellerate"]];
100 [registerButton setButtonType:NSMomentaryPushButton];
101 [registerButton setBezelStyle:NSRegularSquareBezelStyle];
102 [registerButton setTarget:_sender];
103 [registerButton setAction:@selector(goToTheStore:)];
104 [[box contentView] addSubview:registerButton];
106 regBenefits = [[NSTextField alloc] initWithFrame:NSMakeRect(152, 16, 175, 42)];
107 [regBenefits setStringValue:NSLocalizedString(@"regPoints", @"Registration Points")];
108 [regBenefits setBordered:NO];
109 [regBenefits setBezeled:NO];
110 [regBenefits setEditable:NO];
111 [regBenefits setSelectable:NO];
112 [regBenefits setDrawsBackground:NO];
113 [regBenefits setFont:[NSFont fontWithName:@"LucidaGrande" size:11]];
114 [[box contentView] addSubview:regBenefits];
116 enterInfo = [[NSTextField alloc] initWithFrame:NSMakeRect(20, 148, 345, 17)];
117 [enterInfo setStringValue:NSLocalizedString(@"regInfo", @"Please enter your registration information below.")];
118 [enterInfo setBordered:NO];
119 [enterInfo setBezeled:NO];
120 [enterInfo setEditable:NO];
121 [enterInfo setSelectable:NO];
122 [enterInfo setDrawsBackground:NO];
123 [enterInfo setFont:[NSFont fontWithName:@"Lucida Grande" size:13]];
124 [contentView addSubview:enterInfo];
126 owner = [[NSTextField alloc] initWithFrame:NSMakeRect(20, 126, 345, 14)];
127 [owner setStringValue:NSLocalizedString(@"licenseOwner", @"License Owner:")];
128 [owner setBordered:NO];
129 [owner setBezeled:NO];
130 [owner setEditable:NO];
131 [owner setSelectable:NO];
132 [owner setDrawsBackground:NO];
133 [owner setFont:[NSFont fontWithName:@"Lucida Grande" size:11]];
134 [contentView addSubview:owner];
136 key = [[NSTextField alloc] initWithFrame:NSMakeRect(20, 82, 345, 14)];
137 [key setStringValue:NSLocalizedString(@"licenseKey", @"License Key:")];
138 [key setBordered:NO];
140 [key setEditable:NO];
141 [key setSelectable:NO];
142 [key setDrawsBackground:NO];
143 [key setFont:[NSFont fontWithName:@"Lucida Grande" size:11]];
144 [contentView addSubview:key];
146 ownerEntry = [[NSTextField alloc] initWithFrame:NSMakeRect(20, 104, 345, 22)];
147 [ownerEntry setTarget:_sender];
148 [ownerEntry setAction:@selector(verifyKey:)];
149 [contentView addSubview:ownerEntry];
151 keyEntry = [[NSTextField alloc] initWithFrame:NSMakeRect(20, 60, 345, 22)];
152 [keyEntry setTarget:_sender];
153 [keyEntry setAction:@selector(verifyKey:)];
154 [contentView addSubview:keyEntry];
156 regLater = [[NSButton alloc] initWithFrame:NSMakeRect(138, 16, 116, 25)];
157 [regLater setTitle:NSLocalizedString(@"registerLater", @"Register Later")];
158 [regLater setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
159 [regLater setTarget:_sender];
160 [regLater setAction:@selector(registerLater:)];
161 [regLater setBezelStyle:NSRoundedBezelStyle];
162 [contentView addSubview:regLater];
164 verifyKey = [[NSButton alloc] initWithFrame:NSMakeRect(255, 16, 116, 25)];
165 [verifyKey setTitle:NSLocalizedString(@"verifyKey", @"Verify Key")];
166 [verifyKey setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
167 [verifyKey setTarget:_sender];
168 [verifyKey setAction:@selector(verifyKey:)];
169 [verifyKey setBezelStyle:NSRoundedBezelStyle];
170 [verifyKey setKeyEquivalent:[NSString stringWithCharacters:&returnChar length:1]];
171 [contentView addSubview:verifyKey];
176 [registerButton setTarget:_sender];
177 [ownerEntry setTarget:_sender];
178 [keyEntry setTarget:_sender];
179 [regLater setTarget:_sender];
180 [verifyKey setTarget:_sender];
185 return [ownerEntry stringValue];
190 return [keyEntry stringValue];