Added a new spin effect. Silly, but looks cool :)
[ITKit.git] / ITWindowEffect.m
1 #import "ITWindowEffect.h"
2 #import "ITTransientStatusWindow.h"
3
4
5 @implementation ITWindowEffect
6
7 + (NSArray *)effectClasses
8 {
9     NSArray *classes = [NSArray arrayWithObjects:
10         NSClassFromString(@"ITCutWindowEffect"),
11         NSClassFromString(@"ITDissolveWindowEffect"),
12         NSClassFromString(@"ITSlideHorizontallyWindowEffect"),
13         NSClassFromString(@"ITSlideVerticallyWindowEffect"),
14         NSClassFromString(@"ITPivotWindowEffect"),
15         NSClassFromString(@"ITZoomWindowEffect"),
16         NSClassFromString(@"ITSpinWindowEffect"),
17         nil];
18         
19     return classes;
20 }
21
22 - (id)initWithWindow:(NSWindow *)window
23 {
24     if ( (self = [super init]) ) {
25         _window                 = [window retain];
26         _effectTime             = DEFAULT_EFFECT_TIME;
27         _effectTimer            = nil;
28         __shouldReleaseWhenIdle = NO;
29         __idle                  = YES;
30
31         if ( [window conformsToProtocol:@protocol(ITWindowPositioning)] ) {
32             _verticalPosition   = (ITVerticalWindowPosition)[(ITTransientStatusWindow *)window verticalPosition];
33             _horizontalPosition = (ITHorizontalWindowPosition)[(ITTransientStatusWindow *)window horizontalPosition];
34         } else {
35             NSLog(@"ITWindowEffect - initWithWindow: - window does not conform to ITWindowPositioning.");
36             _verticalPosition   = ITWindowPositionBottom;
37             _horizontalPosition = ITWindowPositionLeft;
38         }
39     }
40     return self;
41 }
42
43 - (NSWindow *)window
44 {
45     return _window;
46 }
47
48 - (void)setWindow:(NSWindow *)newWindow
49 {
50     [_window autorelease];
51     _window = [newWindow retain];
52 }
53
54 - (void)setWindowVisibility:(ITWindowVisibilityState)visibilityState
55 {
56     if ( [_window conformsToProtocol:@protocol(ITWindowMotility)] ) {
57        // Cast so the compiler won't gripe
58         [(ITTransientStatusWindow *)_window setVisibilityState:visibilityState];
59     } else {
60         NSLog(@"ITWindowEffect - setWindowVisibility: - window does not conform to ITWindowVisibility.");
61     }
62 }
63
64 - (float)effectTime
65 {
66     return _effectTime;
67 }
68
69 - (void)setEffectTime:(float)newTime
70 {
71     _effectTime = newTime;
72 }
73
74 + (NSString *)effectName
75 {
76     NSLog(@"ITWindowEffect does not implement +effectName.");
77     return nil;
78 }
79
80 + (NSDictionary *)supportedPositions
81 {
82     NSLog(@"ITWindowEffect does not implement +supportedPositions.");
83     
84 //  Below is an example dictionary.  Modify it appropriately when subclassing.
85     return [NSDictionary dictionaryWithObjectsAndKeys:
86         [NSDictionary dictionaryWithObjectsAndKeys:
87             [NSNumber numberWithBool:NO], @"Left",
88             [NSNumber numberWithBool:NO], @"Center",
89             [NSNumber numberWithBool:NO], @"Right", nil] , @"Top" ,
90         [NSDictionary dictionaryWithObjectsAndKeys:
91             [NSNumber numberWithBool:NO], @"Left",
92             [NSNumber numberWithBool:NO], @"Center",
93             [NSNumber numberWithBool:NO], @"Right", nil] , @"Middle" ,
94         [NSDictionary dictionaryWithObjectsAndKeys:
95             [NSNumber numberWithBool:NO], @"Left",
96             [NSNumber numberWithBool:NO], @"Center",
97             [NSNumber numberWithBool:NO], @"Right", nil] , @"Bottom" , nil];
98 }
99
100 + (unsigned int)listOrder
101 {
102     NSLog(@"ITWindowEffect does not implement +listOrder.");
103     return 0;
104 }
105
106 - (void)performAppear
107 {
108     NSLog(@"ITWindowEffect does not implement -performAppear.");
109 }
110
111 - (void)performVanish
112 {
113     NSLog(@"ITWindowEffect does not implement -performVanish.");
114 }
115
116 - (void)cancelAppear
117 {
118     NSLog(@"ITWindowEffect does not implement -cancelAppear.");
119 }
120
121 - (void)cancelVanish
122 {
123     NSLog(@"ITWindowEffect does not implement -cancelVanish.");
124 }
125
126 - (void)releaseWhenIdle;
127 {
128     if ( __idle ) {
129         [self release];
130     } else {
131         __shouldReleaseWhenIdle = YES;
132     }
133 }
134
135 - (void)dealloc
136 {
137         [_window release];
138         [super dealloc];
139 }
140
141
142 @end