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