Removing an NSLog
[ITKit.git] / ITTransientStatusWindow.m
index 4182d57..45ad1e3 100755 (executable)
@@ -4,6 +4,8 @@
 #import "ITTextField.h"
 #import "ITGrayRoundedView.h"
 
+@class ITTextField;
+@class ITGrayRoundedView;
 
 /*************************************************************************/
 #pragma mark -
@@ -69,10 +71,7 @@ static ITTransientStatusWindow *staticWindow = nil;
 {
     NSRect contentRect;
     
-    CGSValueObj         key;
-    CGSValueObj         ignore;
-
-    // If no Content View was provided, use a generic NSImageView with the app icon.
+    // If no Content View was provided, use a generic NSView with the app icon.
     if ( ! (contentView) ) {
         contentView = [[[NSView alloc] initWithFrame:
             NSMakeRect(100.0, 100.0, 200.0, 200.0)] autorelease];
@@ -86,15 +85,16 @@ static ITTransientStatusWindow *staticWindow = nil;
                                      backing:NSBackingStoreBuffered
                                        defer:NO] ) ) {
                                     
-        _visibilityState    = ITTransientStatusWindowHiddenState;
-        _exitMode           = exitMode;
-        _exitDelay          = DEFAULT_EXIT_DELAY;
-        _backgroundType     = backgroundType;
-        _verticalPosition   = ITTransientStatusWindowPositionBottom;
-        _horizontalPosition = ITTransientStatusWindowPositionLeft;
-        _entryEffect        = ITTransientStatusWindowEffectNone;
-        _exitEffect         = ITTransientStatusWindowEffectDissolve;
-        
+        _visibilityState     = ITTransientStatusWindowHiddenState;
+        _exitMode            = exitMode;
+        _exitDelay           = DEFAULT_EXIT_DELAY;
+        _backgroundType      = backgroundType;
+        _verticalPosition    = ITTransientStatusWindowPositionBottom;
+        _horizontalPosition  = ITTransientStatusWindowPositionLeft;
+        _entryEffect         = ITTransientStatusWindowEffectNone;
+        _exitEffect          = ITTransientStatusWindowEffectDissolve;
+        _effectTime          = DEFAULT_EFFECT_TIME;
+        _reallyIgnoresEvents = YES;
         _delayTimer = nil;
         _fadeTimer  = nil;
 
@@ -104,16 +104,7 @@ static ITTransientStatusWindow *staticWindow = nil;
 //            [self setContentView:contentView];
 //        }
 
-//      [self setIgnoresMouseEvents:YES];
-
-        key = CGSCreateCString("IgnoreForEvents");
-        ignore = CGSCreateBoolean(kCGSTrue);
-        
-        CGSSetWindowProperty([NSApp contextID], (CGSWindowID)[self windowNumber], key, ignore);
-
-        CGSReleaseObj(key);
-        CGSReleaseObj(ignore);
-        
+        [self setIgnoresMouseEvents:YES];
         [self setLevel:NSScreenSaverWindowLevel];
         [self setContentView:contentView];
         [self rebuildWindow];
@@ -127,9 +118,40 @@ static ITTransientStatusWindow *staticWindow = nil;
 #pragma mark INSTANCE METHODS
 /*************************************************************************/
 
+- (void)setRotation:(float)angle
+{
+    CGAffineTransform transform = CGAffineTransformMakeRotation(angle);
+    transform.tx = -32.0;
+    transform.ty = [self frame].size.height + 32.0;
+    CGSSetWindowTransform([NSApp contextID],
+                          (CGSWindowID)[self windowNumber],
+                          CGAffineTransformTranslate(transform,
+                                                     (([self frame].origin.x - 32.0) * -1),
+                                                     (([[self screen] frame].size.height - ([self frame].origin.y) + 32.0) * -1) ));
+}
+
+- (BOOL)ignoresMouseEvents
+{
+    return _reallyIgnoresEvents;
+}
+
+- (void)setIgnoresMouseEvents:(BOOL)flag
+{
+    CGSValueObj         key;
+    CGSValueObj         ignore;
+
+    key = CGSCreateCString("IgnoreForEvents");
+    ignore = CGSCreateBoolean( (flag ? kCGSTrue : kCGSFalse) );
+    CGSSetWindowProperty([NSApp contextID], (CGSWindowID)[self windowNumber], key, ignore);
+    CGSReleaseObj(key);
+    CGSReleaseObj(ignore);
+
+    _reallyIgnoresEvents = flag;
+}
+
 - (void)orderFront:(id)sender
 {
-    if ( _exitMode = ITTransientStatusWindowExitAfterDelay ) {
+    if ( _exitMode == ITTransientStatusWindowExitAfterDelay ) {
         // set the timer, and orderOut: when it lapses.
     }
 
@@ -142,7 +164,7 @@ static ITTransientStatusWindow *staticWindow = nil;
 
 - (void)makeKeyAndOrderFront:(id)sender
 {
-    if ( _exitMode = ITTransientStatusWindowExitAfterDelay ) {
+    if ( _exitMode == ITTransientStatusWindowExitAfterDelay ) {
         // set the timer, and orderOut: when it lapses.
     }
 
@@ -163,6 +185,11 @@ static ITTransientStatusWindow *staticWindow = nil;
     }
 }
 
+- (NSTimeInterval)animationResizeTime:(NSRect)newFrame
+{
+    return _effectTime;
+}
+
 /*
 
 - (id)contentView
@@ -194,7 +221,7 @@ static ITTransientStatusWindow *staticWindow = nil;
     return _visibilityState;
 }
 
-- (ITTransientStatusWindowExitMode)ExitMode
+- (ITTransientStatusWindowExitMode)exitMode
 {
     return _exitMode;
 }
@@ -297,35 +324,46 @@ static ITTransientStatusWindow *staticWindow = nil;
         if ( _entryEffect == ITTransientStatusWindowEffectDissolve ) {
             [self dissolveEffect:YES];
         } else if ( _entryEffect == ITTransientStatusWindowEffectSlideVertically ) {
-            [self slideEffect:YES];
+            [self slideVerticalEffect:YES];
         } else if ( _entryEffect == ITTransientStatusWindowEffectSlideHorizontally ) {
-            [self slideEffect:YES];
+            [self slideHorizontalEffect:YES];
         }
     } else if ( _visibilityState == ITTransientStatusWindowVisibleState ) {
         if ( _exitEffect == ITTransientStatusWindowEffectDissolve ) {
             [self dissolveEffect:NO];
         } else if ( _exitEffect == ITTransientStatusWindowEffectSlideVertically ) {
-            [self slideEffect:NO];
+            [self slideVerticalEffect:NO];
         } else if ( _exitEffect == ITTransientStatusWindowEffectSlideHorizontally ) {
-            [self slideEffect:NO];
+            [self slideHorizontalEffect:NO];
         }
     }
 }
 
 - (void)dissolveEffect:(BOOL)entering
 {
-    
-    [super orderFront:self];
+    if ( entering ) {
+        [super orderFront:self];
+    } else {
+        [super orderOut:self];
+    }
 }
 
 - (void)slideVerticalEffect:(BOOL)entering
 {
-    [super orderFront:self];
+    if ( entering ) {
+        [super orderFront:self];
+    } else {
+        [super orderOut:self];
+    }
 }
 
 - (void)slideHorizontalEffect:(BOOL)entering
 {
-    [super orderFront:self];
+    if ( entering ) {
+        [super orderFront:self];
+    } else {
+        [super orderOut:self];
+    }
 }