Intermediary checkin for effect list... more coming.
[ITKit.git] / ITWindowEffect.m
1 #import "ITWindowEffect.h"
2 #import "ITTransientStatusWindow.h"
3
4
5 @implementation ITWindowEffect
6
7 + (NSArray *)effectsInfo
8 {
9     int ce;
10     NSMutableArray *finalArray = [[[NSMutableArray alloc] initWithCapacity:5] autorelease];
11
12     NSArray *effectKeys = [NSArray arrayWithObjects:
13         @"Name",
14         @"Class",
15         @"Positions",
16         nil];
17     
18     NSArray *effectNames = [NSArray arrayWithObjects:
19         @"Cut",
20         @"Dissolve",
21         @"Slide Horizontally",
22         @"Slide Vertically",
23         @"Pivot",
24         nil];
25         
26     NSArray *classNames = [NSArray arrayWithObjects:
27         @"ITCutWindowEffect",
28         @"ITDissolveWindowEffect",
29         @"ITSlideHorizontallyWindowEffect",
30         @"ITSlideVerticallyWindowEffect",
31         @"ITPivotWindowEffect",
32         nil];
33         
34     NSArray *positionKeys = [NSArray arrayWithObjects:
35         @"TopLeft",
36         @"TopCenter",
37         @"TopRight",
38         @"MiddleLeft",
39         @"MiddleCenter",
40         @"MiddleRight",
41         @"BottomLeft",
42         @"BottomCenter",
43         @"BottomRight",
44         nil];
45         
46     NSArray *cutPositionValues = [NSArray arrayWithObjects:
47         [NSNumber numberWithBool:YES],
48         [NSNumber numberWithBool:YES],
49         [NSNumber numberWithBool:YES],
50         [NSNumber numberWithBool:YES],
51         [NSNumber numberWithBool:YES],
52         [NSNumber numberWithBool:YES],
53         [NSNumber numberWithBool:YES],
54         [NSNumber numberWithBool:YES],
55         [NSNumber numberWithBool:YES],
56         nil];
57     
58     NSArray *dissolvePositionValues = [NSArray arrayWithObjects:
59         [NSNumber numberWithBool:YES],
60         [NSNumber numberWithBool:YES],
61         [NSNumber numberWithBool:YES],
62         [NSNumber numberWithBool:YES],
63         [NSNumber numberWithBool:YES],
64         [NSNumber numberWithBool:YES],
65         [NSNumber numberWithBool:YES],
66         [NSNumber numberWithBool:YES],
67         [NSNumber numberWithBool:YES],
68         nil];
69     
70     NSArray *slideVerticallyPositionValues = [NSArray arrayWithObjects:
71         [NSNumber numberWithBool:YES],
72         [NSNumber numberWithBool:YES],
73         [NSNumber numberWithBool:YES],
74         [NSNumber numberWithBool:NO],
75         [NSNumber numberWithBool:NO],
76         [NSNumber numberWithBool:NO],
77         [NSNumber numberWithBool:YES],
78         [NSNumber numberWithBool:YES],
79         [NSNumber numberWithBool:YES],
80         nil];
81     
82     NSArray *slideHorizontallyPositionValues = [NSArray arrayWithObjects:
83         [NSNumber numberWithBool:YES],
84         [NSNumber numberWithBool:NO],
85         [NSNumber numberWithBool:YES],
86         [NSNumber numberWithBool:YES],
87         [NSNumber numberWithBool:NO],
88         [NSNumber numberWithBool:YES],
89         [NSNumber numberWithBool:YES],
90         [NSNumber numberWithBool:NO],
91         [NSNumber numberWithBool:YES],
92         nil];
93     
94     NSArray *pivotPositionValues = [NSArray arrayWithObjects:
95         [NSNumber numberWithBool:YES],
96         [NSNumber numberWithBool:NO],
97         [NSNumber numberWithBool:YES],
98         [NSNumber numberWithBool:NO],
99         [NSNumber numberWithBool:NO],
100         [NSNumber numberWithBool:NO],
101         [NSNumber numberWithBool:YES],
102         [NSNumber numberWithBool:NO],
103         [NSNumber numberWithBool:YES],
104         nil];
105     
106     NSArray *positionDicts = [NSArray arrayWithObjects:
107         [NSDictionary dictionaryWithObjects:cutPositionValues
108                                     forKeys:positionKeys],
109         [NSDictionary dictionaryWithObjects:dissolvePositionValues
110                                     forKeys:positionKeys],
111         [NSDictionary dictionaryWithObjects:slideVerticallyPositionValues
112                                     forKeys:positionKeys],
113         [NSDictionary dictionaryWithObjects:slideHorizontallyPositionValues
114                                     forKeys:positionKeys],
115         [NSDictionary dictionaryWithObjects:pivotPositionValues
116                                     forKeys:positionKeys],
117         nil];
118         
119     for ( ce = 0 ; ce < [effectNames count] ; ce++ ) {
120         
121         NSArray *entryValues = [NSArray arrayWithObjects:
122             [effectNames   objectAtIndex:ce],
123             [classNames    objectAtIndex:ce],
124             [positionDicts objectAtIndex:ce],
125             nil];
126         
127         NSDictionary *entryDict = [NSDictionary dictionaryWithObjects:entryValues
128                                                               forKeys:effectKeys];
129         [finalArray addObject:entryDict];
130     }
131     
132     return finalArray;
133 }
134
135 - (id)initWithWindow:(NSWindow *)window
136 {
137     if ( (self = [super init]) ) {
138     
139         _window                 = [window retain];
140         _effectTime             = DEFAULT_EFFECT_TIME;
141         _effectTimer            = nil;
142         __shouldReleaseWhenIdle = NO;
143         __idle                  = YES;
144
145         if ( [window conformsToProtocol:@protocol(ITWindowPositioning)] ) {
146                                                            // Casts so the compiler won't gripe
147             _verticalPosition   = (ITVerticalWindowPosition)[(ITTransientStatusWindow *)window verticalPosition];
148             _horizontalPosition = (ITHorizontalWindowPosition)[(ITTransientStatusWindow *)window horizontalPosition];
149         } else {
150             NSLog(@"ITWindowEffect - initWithWindow: - window does not conform to ITWindowPositioning.");
151             _verticalPosition   = ITWindowPositionBottom;
152             _horizontalPosition = ITWindowPositionLeft;
153         }
154     }
155     return self;
156 }
157
158 - (NSWindow *)window
159 {
160     return _window;
161 }
162
163 - (void)setWindow:(NSWindow *)newWindow
164 {
165     [_window autorelease];
166     _window = [newWindow retain];
167 }
168
169 - (void)setWindowVisibility:(ITWindowVisibilityState)visibilityState
170 {
171     if ( [_window conformsToProtocol:@protocol(ITWindowMotility)] ) {
172        // Cast so the compiler won't gripe
173         [(ITTransientStatusWindow *)_window setVisibilityState:visibilityState];
174     } else {
175         NSLog(@"ITWindowEffect - setWindowVisibility: - window does not conform to ITWindowVisibility.");
176     }
177 }
178
179 - (float)effectTime
180 {
181     return _effectTime;
182 }
183
184 - (void)setEffectTime:(float)newTime
185 {
186     _effectTime = newTime;
187 }
188
189 - (void)performAppear
190 {
191     NSLog(@"ITWindowEffect does not implement performAppear.");
192 }
193
194 - (void)performVanish
195 {
196     NSLog(@"ITWindowEffect does not implement performVanish.");
197 }
198
199 - (void)cancelAppear
200 {
201     NSLog(@"ITWindowEffect does not implement cancelAppear.");
202 }
203
204 - (void)cancelVanish
205 {
206     NSLog(@"ITWindowEffect does not implement cancelVanish.");
207 }
208
209 - (void)releaseWhenIdle;
210 {
211     if ( __idle ) {
212         [self release];
213     } else {
214         __shouldReleaseWhenIdle = YES;
215     }
216 }
217
218 - (void)dealloc
219 {
220         [_window release];
221         [super dealloc];
222 }
223
224
225 @end