Intermediary checkin, just to mark my place and back up, in case Panther decides...
[ITKit.git] / ITCutWindowEffect.m
1 #import "ITCutWindowEffect.h"
2 #import "ITTransientStatusWindow.h"
3 #import "ITCoreGraphicsHacks.h"
4
5 @implementation ITCutWindowEffect
6
7
8 + (NSString *)effectName
9 {
10     return @"Cut";
11 }
12
13 + (NSDictionary *)supportedPositions
14 {
15     return [NSDictionary dictionaryWithObjectsAndKeys:
16         [NSDictionary dictionaryWithObjectsAndKeys:
17             [NSNumber numberWithBool:YES], @"Left",
18             [NSNumber numberWithBool:YES], @"Center",
19             [NSNumber numberWithBool:YES], @"Right", nil] , @"Top" ,
20         [NSDictionary dictionaryWithObjectsAndKeys:
21             [NSNumber numberWithBool:YES], @"Left",
22             [NSNumber numberWithBool:YES], @"Center",
23             [NSNumber numberWithBool:YES], @"Right", nil] , @"Middle" ,
24         [NSDictionary dictionaryWithObjectsAndKeys:
25             [NSNumber numberWithBool:YES], @"Left",
26             [NSNumber numberWithBool:YES], @"Center",
27             [NSNumber numberWithBool:YES], @"Right", nil] , @"Bottom" , nil];
28 }
29
30
31 /*************************************************************************/
32 #pragma mark -
33 #pragma mark APPEAR METHODS
34 /*************************************************************************/
35
36 - (void)performAppear
37 {
38     CGAffineTransform transform;
39     NSPoint appearPoint;
40     
41     //Set the location on the screen
42     if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionLeft ) {
43         appearPoint.x = -( 32.0 + [[_window screen] visibleFrame].origin.x );
44     } else if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionRight ) {
45         appearPoint.x = -(([[_window screen] visibleFrame].size.width + [[_window screen] visibleFrame].origin.x) - 32.0 - [_window frame].size.width);
46     } else if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionCenter ) {
47         appearPoint.x = ( [_window frame].size.width - [[_window screen] visibleFrame].size.width ) / 2;
48     }
49     
50     if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionTop ) {
51         appearPoint.y = ( 64.0 + [[_window screen] visibleFrame].origin.y - [_window frame].size.height );
52     } else if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionBottom ) {
53         appearPoint.y = -( [[_window screen] frame].size.height - ( [_window frame].size.height + 32.0 + [[_window screen] visibleFrame].origin.y) );
54     } else if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionMiddle ) {
55         appearPoint.y = ( [_window frame].size.height - [[_window screen] visibleFrame].size.height) / 2;
56     }
57     
58     transform = CGAffineTransformMakeTranslation(appearPoint.x, appearPoint.y);
59     CGSSetWindowTransform([NSApp contextID],
60                           (CGSWindowID)[_window windowNumber],
61                           transform);
62     
63     [_window orderFront:self];
64     [self setWindowVisibility:ITWindowVisibleState];
65 }
66
67 - (void)cancelAppear
68 {
69     [self performVanish];
70 }
71
72
73 /*************************************************************************/
74 #pragma mark -
75 #pragma mark VANISH METHODS
76 /*************************************************************************/
77
78 - (void)performVanish
79 {
80     [_window orderOut:self];
81     [self setWindowVisibility:ITWindowHiddenState];
82 }
83
84 - (void)cancelVanish
85 {
86     [self performAppear];
87 }
88
89
90 @end