-
Notifications
You must be signed in to change notification settings - Fork 0
/
ITSplashView.m
93 lines (79 loc) · 2.71 KB
/
ITSplashView.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#import "ITSplashView.h"
@implementation ITSplashView
- (void)dealloc {
[_image release];
[_progress release];
[_text release];
[super dealloc];
}
- (void)drawRect:(NSRect)rect {
[_image compositeToPoint:NSZeroPoint operation:NSCompositeSourceOver];
}
- (BOOL)isOpaque {
return NO;
}
- (void)stopAnimation {
[_progress stopAnimation:nil];
}
- (NSProgressIndicator *)progressIndicator {
return _progress;
}
- (NSImage *)image {
return _image;
}
- (NSString *)string {
return [_text stringValue];
}
- (void)setImage:(NSImage *)image {
[_image autorelease];
_image = [image retain];
}
- (void)setString:(NSString *)text {
[_text setStringValue:text];
}
- (void)loadControlsFromPath:(NSString *)path {
[_progress removeFromSuperview];
[_progress release];
[_text removeFromSuperview];
[_text release];
//Reset the controls
NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:path];
int height = [[settings objectForKey:@"ProgressIndicator.thickness"] intValue];
NSControlSize size;
switch (height) {
/*case NSProgressIndicatorPreferredSmallThickness:
size = NSMiniControlSize;
break;*/
case NSProgressIndicatorPreferredAquaThickness:
size = NSSmallControlSize;
break;
case NSProgressIndicatorPreferredThickness:
default:
size = NSRegularControlSize;
break;
}
if ([[settings objectForKey:@"ProgressIndicator.style"] intValue] == 0) {
//We have a normal bar
_progress = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect([[settings objectForKey:@"ProgressIndicator.x"] intValue], [[settings objectForKey:@"ProgressIndicator.y"] intValue], [[settings objectForKey:@"ProgressIndicator.size"] intValue], height)];
[_progress setStyle:NSProgressIndicatorBarStyle];
[_progress setControlSize:size];
[_progress setIndeterminate:NO];
[_progress setMaxValue:100.0];
[_progress setMinValue:0.0];
} else {
//We have a spinner thinger
_progress = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect([[settings objectForKey:@"ProgressIndicator.x"] intValue], [[settings objectForKey:@"ProgressIndicator.y"] intValue], [[settings objectForKey:@"ProgressIndicator.size"] intValue], [[settings objectForKey:@"ProgressIndicator.size"] intValue])];
[_progress setStyle:NSProgressIndicatorSpinningStyle];
[_progress setControlSize:size];
}
[self addSubview:_progress];
[_progress startAnimation:nil];
_text = [[NSTextField alloc] initWithFrame:NSMakeRect([[settings objectForKey:@"StatusText.x"] intValue], [[settings objectForKey:@"StatusText.y"] intValue], [[settings objectForKey:@"StatusText.width"] intValue], 22)];
[_text setEditable:NO];
[_text setSelectable:NO];
[_text setBezeled:NO];
[_text setDrawsBackground:NO];
[self addSubview:_text];
[settings release];
}
@end