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