Removing the use of private CoreGraphics APIs to draw shadows, and replacing with...
[ITKit.git] / ITSplashView.m
1 #import "ITSplashView.h"
2
3 @implementation ITSplashView
4
5 - (void)dealloc {
6         [_image release];
7         [_progress release];
8         [_text release];
9         [super dealloc];
10 }
11
12 - (void)drawRect:(NSRect)rect {
13         [_image compositeToPoint:NSZeroPoint operation:NSCompositeSourceOver];
14 }
15
16 - (BOOL)isOpaque {
17         return NO;
18 }
19
20 - (void)stopAnimation {
21         [_progress stopAnimation:nil];
22 }
23
24 - (NSProgressIndicator *)progressIndicator {
25         return _progress;
26 }
27
28 - (NSImage *)image {
29         return _image;
30 }
31
32 - (NSString *)string {
33         return [_text stringValue];
34 }
35
36 - (void)setImage:(NSImage *)image {
37         [_image autorelease];
38         _image = [image retain];
39 }
40
41 - (void)setString:(NSString *)text {
42         [_text setStringValue:text];
43 }
44
45 - (void)loadControlsFromPath:(NSString *)path {
46         [_progress removeFromSuperview];
47         [_progress release];
48         [_text removeFromSuperview];
49         [_text release];
50         //Reset the controls
51         NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:path];
52         int height = [[settings objectForKey:@"ProgressIndicator.thickness"] intValue];
53         NSControlSize size;
54         switch (height) {
55                 /*case NSProgressIndicatorPreferredSmallThickness:
56                         size = NSMiniControlSize;
57                         break;*/
58                 case NSProgressIndicatorPreferredAquaThickness:
59                         size = NSSmallControlSize;
60                         break;
61                 case NSProgressIndicatorPreferredThickness:
62                 default:
63                         size = NSRegularControlSize;
64                         break;
65         }
66         if ([[settings objectForKey:@"ProgressIndicator.style"] intValue] == 0) {
67                 //We have a normal bar
68                 _progress = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect([[settings objectForKey:@"ProgressIndicator.x"] intValue], [[settings objectForKey:@"ProgressIndicator.y"] intValue], [[settings objectForKey:@"ProgressIndicator.size"] intValue], height)];
69                 [_progress setStyle:NSProgressIndicatorBarStyle];
70                 [_progress setControlSize:size];
71                 [_progress setIndeterminate:NO];
72                 [_progress setMaxValue:100.0];
73                 [_progress setMinValue:0.0];
74         } else {
75                 //We have a spinner thinger
76                 _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])];
77                 [_progress setStyle:NSProgressIndicatorSpinningStyle];
78                 [_progress setControlSize:size];
79         }
80         [self addSubview:_progress];
81         [_progress startAnimation:nil];
82         
83         _text = [[NSTextField alloc] initWithFrame:NSMakeRect([[settings objectForKey:@"StatusText.x"] intValue], [[settings objectForKey:@"StatusText.y"] intValue], [[settings objectForKey:@"StatusText.width"] intValue], 22)];
84         [_text setEditable:NO];
85         [_text setSelectable:NO];
86         [_text setBezeled:NO];
87         [_text setDrawsBackground:NO];
88         [self addSubview:_text];
89         
90         [settings release];
91 }
92
93 @end