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
41 - (void)makeKeyAndOrderFront:(id)sender {
42 if ( ( [[NSDate date] timeIntervalSinceDate:[[MainController sharedController] getBlingTime]] >= 604800 ) && ([[regLater title] isEqualToString:@"Register Later"]) ) {
43 [regLater setTitle:@"Quit"];
44 [regLater setTarget:[NSApplication sharedApplication]];
45 [regLater setAction:@selector(terminate:)];
47 [super makeKeyAndOrderFront:sender];
53 [regBenefits release];
59 [registerButton release];
62 [contentView release];
67 - (void)setBling:(id)bling
75 unichar returnChar = '\r';
77 [self setReleasedWhenClosed:NO];
78 [self setTitle:[NSString stringWithFormat:@"Register %@", @"MenuTunes"]];
79 contentView = [self contentView];
81 regMessage = [[NSTextField alloc] initWithFrame:NSMakeRect(20, 282, 345, 51)];
82 [regMessage setStringValue:[NSString stringWithFormat:@"%@ 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.", @"MenuTunes"]];
83 [regMessage setBordered:NO];
84 [regMessage setBezeled:NO];
85 [regMessage setEditable:NO];
86 [regMessage setSelectable:NO];
87 [regMessage setDrawsBackground:NO];
88 [contentView addSubview:regMessage];
91 box = [[NSBox alloc] initWithFrame:NSMakeRect(20, 181, 345, 81)];
92 [box setTitlePosition:NSNoTitle];
93 [box setBorderType:NSBezelBorder];
94 [contentView addSubview:box];
96 //This isn't tall enough
97 registerButton = [[NSButton alloc] initWithFrame:NSMakeRect(24, 13, 115, 49)];
98 [registerButton setImage:[NSImage imageNamed:@"esellerate"]];
99 [registerButton setButtonType:NSMomentaryPushButton];
100 [registerButton setBezelStyle:NSRegularSquareBezelStyle];
101 [registerButton setTarget:_sender];
102 [registerButton setAction:@selector(goToTheStore:)];
103 [[box contentView] addSubview:registerButton];
105 regBenefits = [[NSTextField alloc] initWithFrame:NSMakeRect(152, 16, 175, 42)];
106 [regBenefits setStringValue:[NSString stringWithUTF8String:"• Register instantly and easily.\n• Fast, secure transaction.\n• Major credit cards accepted."]];
107 [regBenefits setBordered:NO];
108 [regBenefits setBezeled:NO];
109 [regBenefits setEditable:NO];
110 [regBenefits setSelectable:NO];
111 [regBenefits setDrawsBackground:NO];
112 [regBenefits setFont:[NSFont fontWithName:@"Lucida Grande" size:11]];
113 [[box contentView] addSubview:regBenefits];
115 enterInfo = [[NSTextField alloc] initWithFrame:NSMakeRect(20, 148, 345, 17)];
116 [enterInfo setStringValue:@"Please enter your registration information below."];
117 [enterInfo setBordered:NO];
118 [enterInfo setBezeled:NO];
119 [enterInfo setEditable:NO];
120 [enterInfo setSelectable:NO];
121 [enterInfo setDrawsBackground:NO];
122 [enterInfo setFont:[NSFont fontWithName:@"Lucida Grande" size:13]];
123 [contentView addSubview:enterInfo];
125 owner = [[NSTextField alloc] initWithFrame:NSMakeRect(20, 126, 345, 14)];
126 [owner setStringValue:@"License Owner:"];
127 [owner setBordered:NO];
128 [owner setBezeled:NO];
129 [owner setEditable:NO];
130 [owner setSelectable:NO];
131 [owner setDrawsBackground:NO];
132 [owner setFont:[NSFont fontWithName:@"Lucida Grande" size:11]];
133 [contentView addSubview:owner];
135 key = [[NSTextField alloc] initWithFrame:NSMakeRect(20, 82, 345, 14)];
136 [key setStringValue:@"License Key:"];
137 [key setBordered:NO];
139 [key setEditable:NO];
140 [key setSelectable:NO];
141 [key setDrawsBackground:NO];
142 [key setFont:[NSFont fontWithName:@"Lucida Grande" size:11]];
143 [contentView addSubview:key];
145 ownerEntry = [[NSTextField alloc] initWithFrame:NSMakeRect(20, 104, 345, 22)];
146 [ownerEntry setTarget:_sender];
147 [ownerEntry setAction:@selector(verifyKey:)];
148 [contentView addSubview:ownerEntry];
150 keyEntry = [[NSTextField alloc] initWithFrame:NSMakeRect(20, 60, 345, 22)];
151 [keyEntry setTarget:_sender];
152 [keyEntry setAction:@selector(verifyKey:)];
153 [contentView addSubview:keyEntry];
155 regLater = [[NSButton alloc] initWithFrame:NSMakeRect(138, 16, 116, 25)];
156 [regLater setTitle:@"Register Later"];
157 [regLater setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
158 [regLater setTarget:_sender];
159 [regLater setAction:@selector(registerLater:)];
160 [regLater setBezelStyle:NSRoundedBezelStyle];
161 [contentView addSubview:regLater];
163 verifyKey = [[NSButton alloc] initWithFrame:NSMakeRect(255, 16, 116, 25)];
164 [verifyKey setTitle:@"Verify Key"];
165 [verifyKey setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
166 [verifyKey setTarget:_sender];
167 [verifyKey setAction:@selector(verifyKey:)];
168 [verifyKey setBezelStyle:NSRoundedBezelStyle];
169 [verifyKey setKeyEquivalent:[NSString stringWithCharacters:&returnChar length:1]];
170 [contentView addSubview:verifyKey];
175 [registerButton setTarget:_sender];
176 [ownerEntry setTarget:_sender];
177 [keyEntry setTarget:_sender];
178 [regLater setTarget:_sender];
179 [verifyKey setTarget:_sender];
184 return [ownerEntry stringValue];
189 return [keyEntry stringValue];