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