From 22a86e1af594d77fde7f056cf5152478f14dafbf Mon Sep 17 00:00:00 2001 From: Matthew Judy Date: Mon, 27 Jan 2003 09:09:30 +0000 Subject: [PATCH] ITKit for Menutunes Commit Phase 2: New Classes This checkin adds the new classes to the repository. --- ITCategory-NSView.h | 8 + ITCategory-NSView.m | 10 ++ ITCoreGraphicsHacks.h | 35 ++++ ITTSWBackgroundView.h | 16 ++ ITTSWBackgroundView.m | 46 ++++++ ITTableCornerView.h | 36 +++++ ITTableCornerView.m | 39 +++++ ITTableView.h | 28 ++++ ITTableView.m | 48 ++++++ ITTextField.h | 54 +++++++ ITTextField.m | 171 ++++++++++++++++++++ ITTransientStatusWindow.h | 105 ++++++++++++ ITTransientStatusWindow.m | 332 ++++++++++++++++++++++++++++++++++++++ 13 files changed, 928 insertions(+) create mode 100755 ITCategory-NSView.h create mode 100755 ITCategory-NSView.m create mode 100755 ITCoreGraphicsHacks.h create mode 100755 ITTSWBackgroundView.h create mode 100755 ITTSWBackgroundView.m create mode 100755 ITTableCornerView.h create mode 100755 ITTableCornerView.m create mode 100755 ITTableView.h create mode 100755 ITTableView.m create mode 100755 ITTextField.h create mode 100755 ITTextField.m create mode 100755 ITTransientStatusWindow.h create mode 100755 ITTransientStatusWindow.m diff --git a/ITCategory-NSView.h b/ITCategory-NSView.h new file mode 100755 index 0000000..79d26d6 --- /dev/null +++ b/ITCategory-NSView.h @@ -0,0 +1,8 @@ +#import + + +@interface NSView (ITCategory) + +- (void)removeAllSubviews; + +@end diff --git a/ITCategory-NSView.m b/ITCategory-NSView.m new file mode 100755 index 0000000..b2c8c0c --- /dev/null +++ b/ITCategory-NSView.m @@ -0,0 +1,10 @@ +#import "ITCategory-NSView.h" + + +@implementation NSView (ITCategory) + +- (void)removeAllSubviews { + [[self subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)]; +} + +@end diff --git a/ITCoreGraphicsHacks.h b/ITCoreGraphicsHacks.h new file mode 100755 index 0000000..c9041c9 --- /dev/null +++ b/ITCoreGraphicsHacks.h @@ -0,0 +1,35 @@ + +/*************************************************************************/ +#pragma mark - +#pragma mark CoreGraphics HACKS +/*************************************************************************/ + +typedef void * CGSGenericObj; +typedef CGSGenericObj CGSValueObj; +typedef void * CGSConnectionID; +typedef void * CGSWindowID; +typedef struct CGStyle *CGStyleRef; +typedef struct CGShadowStyle { + unsigned int version; + float elevation; + float azimuth; + float ambient; + float height; + float radius; + float saturation; +} CGShadowStyle; +typedef unsigned char CGSBoolean; +enum { + kCGSFalse = 0, + kCGSTrue = 1 +}; + +extern void CGStyleRelease(CGStyleRef style); +extern void CGSReleaseObj(void *obj); +extern void CGContextSetStyle(CGContextRef c, CGStyleRef style); +extern void CGStyleRelease(CGStyleRef style); +extern CGStyleRef CGStyleCreateShadow(const CGShadowStyle *shadow); +extern CGSValueObj CGSCreateCString(const char *string); +extern CGSValueObj CGSCreateBoolean(CGSBoolean boolean); +extern CGError CGSSetWindowProperty(const CGSConnectionID cid, + CGSWindowID wid, const CGSValueObj key, const CGSValueObj value); diff --git a/ITTSWBackgroundView.h b/ITTSWBackgroundView.h new file mode 100755 index 0000000..53172e0 --- /dev/null +++ b/ITTSWBackgroundView.h @@ -0,0 +1,16 @@ +// +// ITGrayRoundedView.h +// ITKit +// +// Created by Matt L. Judy on Wed Jan 22 2003. +// Copyright (c) 2003 NibFile.com. All rights reserved. +// + +#import + + +@interface ITGrayRoundedView : NSView { + +} + +@end diff --git a/ITTSWBackgroundView.m b/ITTSWBackgroundView.m new file mode 100755 index 0000000..c978c55 --- /dev/null +++ b/ITTSWBackgroundView.m @@ -0,0 +1,46 @@ +// +// ITGrayRoundedView.m +// ITKit +// +// Created by Matt L. Judy on Wed Jan 22 2003. +// Copyright (c) 2003 NibFile.com. All rights reserved. +// + +#import "ITGrayRoundedView.h" + + +@implementation ITGrayRoundedView + +- (void)drawRect:(NSRect)theRect +{ + NSBezierPath *path = [NSBezierPath bezierPath]; + float vh = NSHeight(theRect); + float vw = NSWidth(theRect); + [path moveToPoint:NSMakePoint( 0.0, (vh - 24.0) )]; // first point + [path curveToPoint:NSMakePoint( 24.0, vh ) + controlPoint1:NSMakePoint( 0.0, (vh - 11.0) ) + controlPoint2:NSMakePoint( 11.0, vh )]; // top-left curve + [path lineToPoint:NSMakePoint( (vw - 24.0), vh )]; // top line + [path curveToPoint:NSMakePoint( vw, (vh - 24.0) ) + controlPoint1:NSMakePoint( (vw - 11.0), vh ) + controlPoint2:NSMakePoint( vw, (vh - 11.0) )]; // top-right curve + [path lineToPoint:NSMakePoint( vw, 24.0 )]; // right line + [path curveToPoint:NSMakePoint( (vw - 24.0), 0.0 ) + controlPoint1:NSMakePoint( vw, 11.0 ) + controlPoint2:NSMakePoint( (vw - 11.0), 0.0 )]; // bottom-right curve + [path lineToPoint:NSMakePoint( 24.0, 0.0 )]; // bottom line + [path curveToPoint:NSMakePoint( 0.0, 24.0 ) + controlPoint1:NSMakePoint( 11.0, 0.0 ) + controlPoint2:NSMakePoint( 0.0, 11.0 )]; // bottom-left curve + [path closePath]; // left line + + [[NSColor colorWithCalibratedWhite:0.0 alpha:0.15] set]; + [path fill]; +} + +- (BOOL)isOpaque +{ + return NO; +} + +@end diff --git a/ITTableCornerView.h b/ITTableCornerView.h new file mode 100755 index 0000000..a8b582c --- /dev/null +++ b/ITTableCornerView.h @@ -0,0 +1,36 @@ +/* + * ITKit + * ITTableCornerView + * NSPopUpButton subclass for corner views in a table view. + * + * Original Author : Joseph Spiros + * Responsibility : Matt Judy + * Responsibility : Joseph Spiros + * + * Copyright (c) 2002 - 2003 iThink Software. + * All Rights Reserved + * + */ + +/* + * This subclass does 4 things to approximate NSMenuExtra's functionality: + * + * 1. Makes the status item smarter about highlighting. + * 2. Allows you to set an alternate (inverted) image. + * 3. Eliminates the pre-Jaguar shadow behind a normal status item. + * 4. If you use an image AND title, the text will be made slightly smaller + * to resemble the visual interface of an NSMenuExtra. + * + * Note: In order to have the shadow not overlap the bottom of the + * menubar, Apple moves the image up one pixel. Since that shadow is + * no longer drawn, please adjust your images DOWN one pixel to compensate. + * + */ + +#import + +@interface ITTableCornerView : NSPopUpButton { + NSTableHeaderCell *headerCell; +} +@end + diff --git a/ITTableCornerView.m b/ITTableCornerView.m new file mode 100755 index 0000000..256c808 --- /dev/null +++ b/ITTableCornerView.m @@ -0,0 +1,39 @@ +// +// ITTableCornerView.m +// +// +// Created by Joseph Spiros on Wed Jan 22 2003. +// Copyright (c) 2003 __MyCompanyName__. All rights reserved. +// + +#import "ITTableCornerView.h" + +@implementation ITTableCornerView + +- (id)initWithFrame:(NSRect)frame { + self = [super initWithFrame:frame]; + if (self) { + headerCell = [[NSTableHeaderCell alloc] init]; + } + return self; +} + +- (void)drawRect:(NSRect)rect { + rect.origin.y = 0; + rect.size.height = 17; + rect.size.width += 1; + + [headerCell setState: ([[self cell] isHighlighted]) ? NSOnState : NSOffState]; + [headerCell drawWithFrame:rect inView:nil]; + + if ([self image]) { + [[self image] drawAtPoint:rect.origin fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; + } +} + +- (void)dealloc { + [headerCell release]; + [super dealloc]; +} + +@end \ No newline at end of file diff --git a/ITTableView.h b/ITTableView.h new file mode 100755 index 0000000..5661c74 --- /dev/null +++ b/ITTableView.h @@ -0,0 +1,28 @@ +/* + * ITKit + * ITTableView + * + * An NSTableView subclass with easy to use accessors for adding a menu (with optional image) + * to the corner view of the TableView. + * + * Original Author : Joseph Spiros + * Responsibility : Joseph Spiros + * + * Copyright (c) 2002 iThink Software. + * All Rights Reserved + * + */ + +#import +#import "ITTableCornerView.h" + +@interface ITTableView : NSTableView { + ITTableCornerView *corner; +} + +- (void)setCornerImage:(NSImage*)image; +- (NSImage*)cornerImage; +- (void)setCornerMenu:(NSMenu*)menu; +- (NSMenu*)cornerMenu; + +@end diff --git a/ITTableView.m b/ITTableView.m new file mode 100755 index 0000000..613a441 --- /dev/null +++ b/ITTableView.m @@ -0,0 +1,48 @@ +// ITTableView.m + +#import "ITTableView.h" + + +@implementation ITTableView + +- (id)initWithFrame:(NSRect)frame { + self = [super initWithFrame:frame]; + if (self) { + corner = [[ITTableCornerView alloc] initWithFrame:[[self cornerView] frame]]; + [corner setPullsDown:YES]; + [self setCornerView:corner]; + } + return self; +} + +- (id)initWithCoder:(NSCoder*)coder { + self = [super initWithCoder:coder]; + if (self) { + corner = [[ITTableCornerView alloc] initWithFrame:[[self cornerView] frame]]; + [corner setPullsDown:YES]; + [self setCornerView:corner]; + } + return self; +} + +- (void)encodeWithCoder:(NSCoder*)coder { + [super encodeWithCoder:coder]; +} + +- (void)setCornerImage:(NSImage*)image { + [corner setImage:image]; +} + +- (NSImage*)cornerImage { + return [corner image]; +} + +- (void)setCornerMenu:(NSMenu*)menu { + [corner setMenu:menu]; +} + +- (NSMenu*)cornerMenu { + return [corner menu]; +} + +@end diff --git a/ITTextField.h b/ITTextField.h new file mode 100755 index 0000000..ea3e8f3 --- /dev/null +++ b/ITTextField.h @@ -0,0 +1,54 @@ +/* + * ITKit + * ITTextField + * Allows shadows to be drawn under text. + * + * Original Author : Matt Judy + * Responsibility : Matt Judy + * Responsibility : Joseph Spiros + * + * Copyright (c) 2002 - 2003 iThink Software. + * All Rights Reserved + * + */ + + +#import + + +@interface ITTextField : NSTextField { + + BOOL castsShadow; + + float shadowElevation; + float shadowAzimuth; + float shadowAmbient; + float shadowHeight; + float shadowRadius; + float shadowSaturation; + +} + +- (BOOL)castsShadow; +- (void)setCastsShadow:(BOOL)newSetting; + +- (float)shadowElevation; /* Light source elevation in degrees. Defaults to 45.0 */ +- (void)setShadowElevation:(float)newElevation; + +- (float)shadowAzimuth; /* Light source azimuth in degrees. Defaults to 90.0 */ +- (void)setShadowAzimuth:(float)newAzimuth; + +- (float)shadowAmbient; /* Amount of ambient light. Defaults to 0.15 */ +- (void)setShadowAmbient:(float)newAmbient; + +- (float)shadowHeight; /* Height above the canvas. Defaults to 1.0 */ +- (void)setShadowHeight:(float)newHeight; + +- (float)shadowRadius; /* Blur radius. Defaults to 4.0 */ +- (void)setShadowRadius:(float)newRadius; + +- (float)shadowSaturation; /* Maximum saturation. Defaults to 1.0 */ +- (void)setShadowSaturation:(float)newSaturation; + + +@end diff --git a/ITTextField.m b/ITTextField.m new file mode 100755 index 0000000..3ab85b7 --- /dev/null +++ b/ITTextField.m @@ -0,0 +1,171 @@ +#import "ITTextField.h" +#import +#import "ITCoreGraphicsHacks.h" + + +/*************************************************************************/ +#pragma mark - +#pragma mark IMPLEMENTATION +/*************************************************************************/ + +@implementation ITTextField + +/*************************************************************************/ +#pragma mark - +#pragma mark INITIALIZATION METHODS +/*************************************************************************/ + +- (id)initWithFrame:(NSRect)frameRect +{ + if ( ( self = [super initWithFrame:frameRect] ) ) { + castsShadow = NO; + shadowElevation = 45.0; + shadowAzimuth = 90.0; + shadowAmbient = 0.15; + shadowHeight = 1.00; + shadowRadius = 4.00; + shadowSaturation = 1.0; + } + + return self; +} + +- (id)initWithCoder:(NSCoder *)coder +{ + if ( ( self = [super initWithCoder:coder] ) ) { + castsShadow = NO; + shadowElevation = 45.0; + shadowAzimuth = 90.0; + shadowAmbient = 0.15; + shadowHeight = 1.00; + shadowRadius = 4.00; + shadowSaturation = 1.0; + } + + return self; +} + + +/*************************************************************************/ +#pragma mark - +#pragma mark DRAWING METHODS +/*************************************************************************/ + +- (void)drawRect:(NSRect)rect +{ + CGSGenericObj style = nil; + CGShadowStyle shadow; + + if ( castsShadow ) { + // Create the shadow style to use for drawing the string + shadow.version = 0; + shadow.elevation = shadowElevation; + shadow.azimuth = shadowAzimuth; + shadow.ambient = shadowAmbient; + shadow.height = shadowHeight; + shadow.radius = shadowRadius; + shadow.saturation = shadowSaturation; + style = CGStyleCreateShadow(&shadow); + + // Set the context for drawing the string + [NSGraphicsContext saveGraphicsState]; + CGContextSetStyle([[NSGraphicsContext currentContext] graphicsPort], style); + } + + // Draw the string + [super drawRect:rect]; + + + if ( castsShadow ) { + // Restore the old context + [NSGraphicsContext restoreGraphicsState]; + CGStyleRelease(style); + } +} + + + +/*************************************************************************/ +#pragma mark - +#pragma mark ACCESSOR METHODS +/*************************************************************************/ + +- (BOOL)castsShadow; +{ + return castsShadow; +} + +- (void)setCastsShadow:(BOOL)newSetting; +{ + castsShadow = newSetting; + [self setNeedsDisplay:YES]; +} + +- (float)shadowElevation; +{ + return shadowElevation; +} + +- (void)setShadowElevation:(float)newElevation; +{ + shadowElevation = newElevation; + [self setNeedsDisplay:YES]; +} + +- (float)shadowAzimuth; +{ + return shadowAzimuth; +} + +- (void)setShadowAzimuth:(float)newAzimuth; +{ + shadowAzimuth = newAzimuth; + [self setNeedsDisplay:YES]; +} + +- (float)shadowAmbient; +{ + return shadowAmbient; +} + +- (void)setShadowAmbient:(float)newAmbient; +{ + shadowAmbient = newAmbient; + [self setNeedsDisplay:YES]; +} + +- (float)shadowHeight; +{ + return shadowHeight; +} + +- (void)setShadowHeight:(float)newHeight; +{ + shadowHeight = newHeight; + [self setNeedsDisplay:YES]; +} + +- (float)shadowRadius; +{ + return shadowRadius; +} + +- (void)setShadowRadius:(float)newRadius; +{ + shadowRadius = newRadius; + [self setNeedsDisplay:YES]; +} + +- (float)shadowSaturation; +{ + return shadowSaturation; +} + +- (void)setShadowSaturation:(float)newSaturation; +{ + shadowSaturation = newSaturation; + [self setNeedsDisplay:YES]; +} + + +@end diff --git a/ITTransientStatusWindow.h b/ITTransientStatusWindow.h new file mode 100755 index 0000000..af6d277 --- /dev/null +++ b/ITTransientStatusWindow.h @@ -0,0 +1,105 @@ +/* + * ITKit + * ITTransientStatusWindow + * NSWindow subclass for quick display of status information. + * Similar to volume/brightness/eject bezel key windows. + * + * Original Author : Kent Sutherland + * Original Author : Matt Judy + * Responsibility : Matt Judy + * Responsibility : Joseph Spiros + * + * Copyright (c) 2002 - 2003 iThink Software. + * All Rights Reserved + * + */ + + +#import + + +#define DEFAULT_EXIT_DELAY 3.0 + + +typedef enum { + ITTransientStatusWindowHiddenState, + ITTransientStatusWindowEnteringState, + ITTransientStatusWindowVisibleState, + ITTransientStatusWindowExitingState +} ITTransientStatusWindowVisibilityState; + +typedef enum { + ITTransientStatusWindowExitOnOrderOut, + ITTransientStatusWindowExitAfterDelay, +} ITTransientStatusWindowExitMode; + +typedef enum { + ITTransientStatusWindowNoBackground, + ITTransientStatusWindowRounded, + ITTransientStatusWindowSquare, + ITTransientStatusWindowMetal, + ITTransientStatusWindowMetalUtility, + ITTransientStatusWindowAquaUtility +} ITTransientStatusWindowBackgroundType; + +typedef enum { + ITTransientStatusWindowPositionTop, + ITTransientStatusWindowPositionMiddle, + ITTransientStatusWindowPositionBottom, + ITTransientStatusWindowPositionLeft, + ITTransientStatusWindowPositionCenter, + ITTransientStatusWindowPositionRight, + ITTransientStatusWindowOther +} ITTransientStatusWindowPosition; + +typedef enum { // Note: Entry effects described here. Exit does the reverse. + ITTransientStatusWindowEffectNone, // No effect, window just appears. + ITTransientStatusWindowEffectDissolve, // Fades in. + ITTransientStatusWindowEffectSlideVertically, // Slides vertically onto the screen from the nearest edge + ITTransientStatusWindowEffectSlideHorizontally // Slides horizontally onto the screen from the nearest edge +} ITTransientStatusWindowEffect; + + +@interface ITTransientStatusWindow : NSWindow { + + ITTransientStatusWindowVisibilityState _visibilityState; + ITTransientStatusWindowExitMode _exitMode; + float _exitDelay; + ITTransientStatusWindowBackgroundType _backgroundType; + ITTransientStatusWindowEffect _entryEffect; + ITTransientStatusWindowEffect _exitEffect; + ITTransientStatusWindowPosition _verticalPosition; + ITTransientStatusWindowPosition _horizontalPosition; + + NSTimer *_delayTimer; + NSTimer *_fadeTimer; + +// NSView *_contentSubView; +} + ++ (ITTransientStatusWindow *)sharedWindow; + +- (ITTransientStatusWindowVisibilityState)visibilityState; + +- (ITTransientStatusWindowExitMode)exitMode; +- (void)setExitMode:(ITTransientStatusWindowExitMode)newMode; + +- (float)exitDelay; +- (void)setExitDelay:(float)seconds; + +- (ITTransientStatusWindowBackgroundType)backgroundType; +- (void)setBackgroundType:(ITTransientStatusWindowBackgroundType)newType; + +- (ITTransientStatusWindowPosition)verticalPosition; +- (void)setVerticalPosition:(ITTransientStatusWindowPosition)newPosition; + +- (ITTransientStatusWindowPosition)horizontalPosition; +- (void)setHorizontalPosition:(ITTransientStatusWindowPosition)newPosition; + +- (ITTransientStatusWindowEffect)entryEffect; +- (void)setEntryEffect:(ITTransientStatusWindowEffect)newEffect; + +- (ITTransientStatusWindowEffect)exitEffect; +- (void)setExitEffect:(ITTransientStatusWindowEffect)newEffect; + +@end diff --git a/ITTransientStatusWindow.m b/ITTransientStatusWindow.m new file mode 100755 index 0000000..4182d57 --- /dev/null +++ b/ITTransientStatusWindow.m @@ -0,0 +1,332 @@ +#import "ITTransientStatusWindow.h" +#import +#import "ITCoreGraphicsHacks.h" +#import "ITTextField.h" +#import "ITGrayRoundedView.h" + + +/*************************************************************************/ +#pragma mark - +#pragma mark EVIL HACKERY +/*************************************************************************/ + +@interface NSApplication (HACKHACKHACKHACK) +- (CGSConnectionID)contextID; +@end + + +/*************************************************************************/ +#pragma mark - +#pragma mark PRIVATE METHOD DECLARATIONS +/*************************************************************************/ + +@interface ITTransientStatusWindow (Private) +- (id)initWithContentView:(NSView *)contentView + exitMode:(ITTransientStatusWindowExitMode)exitMode + backgroundType:(ITTransientStatusWindowBackgroundType)backgroundType; +- (void)rebuildWindow; +- (void)performEffect; +- (void)dissolveEffect:(BOOL)entering; +- (void)slideVerticalEffect:(BOOL)entering; +- (void)slideHorizontalEffect:(BOOL)entering; +@end + + +/*************************************************************************/ +#pragma mark - +#pragma mark IMPLEMENTATION +/*************************************************************************/ + +@implementation ITTransientStatusWindow + + +/*************************************************************************/ +#pragma mark - +#pragma mark SHARED STATIC OBJECTS +/*************************************************************************/ + +static ITTransientStatusWindow *staticWindow = nil; + + +/*************************************************************************/ +#pragma mark - +#pragma mark INITIALIZATION METHODS +/*************************************************************************/ + ++ (ITTransientStatusWindow *)sharedWindow +{ + if ( ! (staticWindow) ) { + staticWindow = [[self alloc] initWithContentView:nil + exitMode:ITTransientStatusWindowExitAfterDelay + backgroundType:ITTransientStatusWindowRounded]; + } + return staticWindow; +} + +- (id)initWithContentView:(NSView *)contentView + exitMode:(ITTransientStatusWindowExitMode)exitMode + backgroundType:(ITTransientStatusWindowBackgroundType)backgroundType +{ + NSRect contentRect; + + CGSValueObj key; + CGSValueObj ignore; + + // If no Content View was provided, use a generic NSImageView with the app icon. + if ( ! (contentView) ) { + contentView = [[[NSView alloc] initWithFrame: + NSMakeRect(100.0, 100.0, 200.0, 200.0)] autorelease]; + } + + // Set the content rect to the frame of the content view, now guaranteed to exist. + contentRect = [contentView frame]; + + if ( ( self = [super initWithContentRect:contentRect + styleMask:NSBorderlessWindowMask + backing:NSBackingStoreBuffered + defer:NO] ) ) { + + _visibilityState = ITTransientStatusWindowHiddenState; + _exitMode = exitMode; + _exitDelay = DEFAULT_EXIT_DELAY; + _backgroundType = backgroundType; + _verticalPosition = ITTransientStatusWindowPositionBottom; + _horizontalPosition = ITTransientStatusWindowPositionLeft; + _entryEffect = ITTransientStatusWindowEffectNone; + _exitEffect = ITTransientStatusWindowEffectDissolve; + + _delayTimer = nil; + _fadeTimer = nil; + +// if ( _backgroundType == ITTransientStatusWindowRounded ) { +// _contentSubView = contentView; +// } else { +// [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 setLevel:NSScreenSaverWindowLevel]; + [self setContentView:contentView]; + [self rebuildWindow]; + } + return self; +} + + +/*************************************************************************/ +#pragma mark - +#pragma mark INSTANCE METHODS +/*************************************************************************/ + +- (void)orderFront:(id)sender +{ + if ( _exitMode = ITTransientStatusWindowExitAfterDelay ) { + // set the timer, and orderOut: when it lapses. + } + + if ( _entryEffect == ITTransientStatusWindowEffectNone ) { + [super orderFront:sender]; + } else { + [self performEffect]; + } +} + +- (void)makeKeyAndOrderFront:(id)sender +{ + if ( _exitMode = ITTransientStatusWindowExitAfterDelay ) { + // set the timer, and orderOut: when it lapses. + } + + if ( _entryEffect == ITTransientStatusWindowEffectNone ) { + [super makeKeyAndOrderFront:sender]; + } else { + [self performEffect]; + [self makeKeyWindow]; + } +} + +- (void)orderOut:(id)sender +{ + if ( _entryEffect == ITTransientStatusWindowEffectNone ) { + [super orderOut:sender]; + } else { + [self performEffect]; + } +} + +/* + +- (id)contentView +{ + if ( _backgroundType == ITTransientStatusWindowRounded ) { + return _contentSubView; + } else { + return [super contentView]; + } +} + +- (void)setContentView:(NSView *)aView +{ + if ( _backgroundType == ITTransientStatusWindowRounded ) { + [_contentSubView removeFromSuperview]; + _contentSubView = aView; + [_contentSubView setFrame:[[super contentView] frame]]; + [[super contentView] addSubview:_contentSubView]; + [_contentSubView setNextResponder:self]; + } else { + [super setContentView:aView]; + } +} + +*/ + +- (ITTransientStatusWindowVisibilityState)visibilityState +{ + return _visibilityState; +} + +- (ITTransientStatusWindowExitMode)ExitMode +{ + return _exitMode; +} + +- (void)setExitMode:(ITTransientStatusWindowExitMode)newMode +{ + _exitMode = newMode; +} + +- (float)exitDelay +{ + return _exitDelay; +} + +- (void)setExitDelay:(float)seconds +{ + _exitDelay = seconds; +} + +- (ITTransientStatusWindowBackgroundType)backgroundType +{ +// return _backgroundType; + return ITTransientStatusWindowRounded; +} + +- (void)setBackgroundType:(ITTransientStatusWindowBackgroundType)newType +{ +// setBackgroundType: is currently ignored. Defaults to ITTransientStatusWindowRounded. +// _backgroundType = newType; + _backgroundType = ITTransientStatusWindowRounded; +} + +- (ITTransientStatusWindowPosition)verticalPosition; +{ + return _verticalPosition; +} + +- (void)setVerticalPosition:(ITTransientStatusWindowPosition)newPosition; +{ + _verticalPosition = newPosition; +} + +- (ITTransientStatusWindowPosition)horizontalPosition; +{ + return _horizontalPosition; +} + +- (void)setHorizontalPosition:(ITTransientStatusWindowPosition)newPosition; +{ + _horizontalPosition = newPosition; +} + +- (ITTransientStatusWindowEffect)entryEffect +{ + return _entryEffect; +} + +- (void)setEntryEffect:(ITTransientStatusWindowEffect)newEffect; +{ + _entryEffect = newEffect; +} + +- (ITTransientStatusWindowEffect)exitEffect; +{ + return _exitEffect; +} + +- (void)setExitEffect:(ITTransientStatusWindowEffect)newEffect; +{ + _exitEffect = newEffect; +} + + +/*************************************************************************/ +#pragma mark - +#pragma mark PRIVATE METHODS +/*************************************************************************/ + +- (void)rebuildWindow; +{ + if ( _backgroundType == ITTransientStatusWindowRounded ) { + ITGrayRoundedView *roundedView = [[[ITGrayRoundedView alloc] initWithFrame:[self frame]] autorelease]; + + [self setBackgroundColor:[NSColor clearColor]]; + [self setHasShadow:NO]; + [self setOpaque:NO]; + + [self setContentView:roundedView]; +// [super setContentView:roundedView]; +// [_contentSubView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; +// [self setContentView:_contentSubView]; + } else { + // YUO == CLWONBAOT + } +} + +- (void)performEffect +{ + if ( _visibilityState == ITTransientStatusWindowHiddenState ) { + if ( _entryEffect == ITTransientStatusWindowEffectDissolve ) { + [self dissolveEffect:YES]; + } else if ( _entryEffect == ITTransientStatusWindowEffectSlideVertically ) { + [self slideEffect:YES]; + } else if ( _entryEffect == ITTransientStatusWindowEffectSlideHorizontally ) { + [self slideEffect:YES]; + } + } else if ( _visibilityState == ITTransientStatusWindowVisibleState ) { + if ( _exitEffect == ITTransientStatusWindowEffectDissolve ) { + [self dissolveEffect:NO]; + } else if ( _exitEffect == ITTransientStatusWindowEffectSlideVertically ) { + [self slideEffect:NO]; + } else if ( _exitEffect == ITTransientStatusWindowEffectSlideHorizontally ) { + [self slideEffect:NO]; + } + } +} + +- (void)dissolveEffect:(BOOL)entering +{ + + [super orderFront:self]; +} + +- (void)slideVerticalEffect:(BOOL)entering +{ + [super orderFront:self]; +} + +- (void)slideHorizontalEffect:(BOOL)entering +{ + [super orderFront:self]; +} + + +@end -- 2.20.1