From: Joseph Spiros Date: Thu, 3 Mar 2005 16:14:08 +0000 (+0000) Subject: Huge audit of ITKit, mostly everything has been updated to current coding X-Git-Tag: v1.0~6 X-Git-Url: http://git.ithinksw.org/ITKit.git/commitdiff_plain/7a218424c6a92eb4979564a7260f862edd46052d Huge audit of ITKit, mostly everything has been updated to current coding style and I've removed things that we don't need/that don't belong in ITKit anymore. The only things really left untouched are the class files for anything related to ITTSW. --- diff --git a/Deprecated/ITChasingArrow1.tiff b/Deprecated/ITChasingArrow1.tiff deleted file mode 100755 index 2c87a94..0000000 Binary files a/Deprecated/ITChasingArrow1.tiff and /dev/null differ diff --git a/Deprecated/ITChasingArrow10.tiff b/Deprecated/ITChasingArrow10.tiff deleted file mode 100755 index 0a27697..0000000 Binary files a/Deprecated/ITChasingArrow10.tiff and /dev/null differ diff --git a/Deprecated/ITChasingArrow2.tiff b/Deprecated/ITChasingArrow2.tiff deleted file mode 100755 index abda131..0000000 Binary files a/Deprecated/ITChasingArrow2.tiff and /dev/null differ diff --git a/Deprecated/ITChasingArrow3.tiff b/Deprecated/ITChasingArrow3.tiff deleted file mode 100755 index 37a3d6b..0000000 Binary files a/Deprecated/ITChasingArrow3.tiff and /dev/null differ diff --git a/Deprecated/ITChasingArrow4.tiff b/Deprecated/ITChasingArrow4.tiff deleted file mode 100755 index 5653961..0000000 Binary files a/Deprecated/ITChasingArrow4.tiff and /dev/null differ diff --git a/Deprecated/ITChasingArrow5.tiff b/Deprecated/ITChasingArrow5.tiff deleted file mode 100755 index 5e6a93d..0000000 Binary files a/Deprecated/ITChasingArrow5.tiff and /dev/null differ diff --git a/Deprecated/ITChasingArrow6.tiff b/Deprecated/ITChasingArrow6.tiff deleted file mode 100755 index 5aed596..0000000 Binary files a/Deprecated/ITChasingArrow6.tiff and /dev/null differ diff --git a/Deprecated/ITChasingArrow7.tiff b/Deprecated/ITChasingArrow7.tiff deleted file mode 100755 index f10726f..0000000 Binary files a/Deprecated/ITChasingArrow7.tiff and /dev/null differ diff --git a/Deprecated/ITChasingArrow8.tiff b/Deprecated/ITChasingArrow8.tiff deleted file mode 100755 index a1ac918..0000000 Binary files a/Deprecated/ITChasingArrow8.tiff and /dev/null differ diff --git a/Deprecated/ITChasingArrow9.tiff b/Deprecated/ITChasingArrow9.tiff deleted file mode 100755 index f00c467..0000000 Binary files a/Deprecated/ITChasingArrow9.tiff and /dev/null differ diff --git a/Deprecated/ITChasingArrowsView.h b/Deprecated/ITChasingArrowsView.h deleted file mode 100755 index 6ef2844..0000000 --- a/Deprecated/ITChasingArrowsView.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * ITKit - * ITChasingArrowsView - * Animating Asynchronous Arrows Widget - * *** DEPRECATED: NSProgressIndicator now offers an async mode. MLJ - 01/14/2003 - * - * Original Author : Doug Brown <...> - * Responsibility : Matthew Judy - * Responsibility : Joseph Spiros - * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved - * - */ - - -#import - - -@interface ITChasingArrowsView : NSView -{ - BOOL running, inForeground; - int curIndex; - NSTimer *timer; - NSArray *images; -} - -- (IBAction)stop:(id)sender; -- (IBAction)start:(id)sender; - - -@end diff --git a/Deprecated/ITChasingArrowsView.m b/Deprecated/ITChasingArrowsView.m deleted file mode 100755 index b903182..0000000 --- a/Deprecated/ITChasingArrowsView.m +++ /dev/null @@ -1,165 +0,0 @@ -#import "ITChasingArrowsView.h" - - -@implementation ITChasingArrowsView - -- (id)initWithCoder:(NSCoder *)decoder -{ - self = [super initWithCoder:decoder]; - - running = NO; - - images = [[decoder decodeObject] retain]; - - curIndex = 0; - timer = nil; - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder -{ - [super encodeWithCoder:coder]; - - [coder encodeObject:images]; -} - -- (id)initWithFrame:(NSRect)frame { - self = [super initWithFrame:frame]; - if (self) { - NSBundle *bund = [NSBundle bundleForClass:[self class]]; - running = NO; - images = [[NSArray alloc] initWithObjects: - [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow1.tiff"]] autorelease], - [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow2.tiff"]] autorelease], - [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow3.tiff"]] autorelease], - [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow4.tiff"]] autorelease], - [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow5.tiff"]] autorelease], - [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow6.tiff"]] autorelease], - [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow7.tiff"]] autorelease], - [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow8.tiff"]] autorelease], - [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow9.tiff"]] autorelease], - [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow10.tiff"]] autorelease], - nil]; - - curIndex = 0; - timer = nil; - } - return self; -} - -- (void)dealloc -{ - if (timer) - { - [timer invalidate]; - [timer release]; - timer = nil; - } - [images release]; - - [super dealloc]; -} -- (void)drawRect:(NSRect)rect { - - if (running) - { - NSImage *curImage = [images objectAtIndex:curIndex]; - float amt; - if (inForeground) - { - amt = 1.0; - } - else - { - amt = 0.5; - } - [curImage compositeToPoint:NSMakePoint(0,0) operation:NSCompositeSourceOver fraction:amt]; - } - else - { - // draw nothing. - } -} - -- (IBAction)stop:(id)sender -{ - running = NO; - - if (timer) - { - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - [nc removeObserver:self]; - [timer invalidate]; - [timer release]; - timer = nil; - } - - [self setNeedsDisplay:YES]; -} - -- (IBAction)start:(id)sender -{ - if (!timer) - { - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self selector:@selector(appWentToBackground:) name:NSApplicationWillResignActiveNotification object:nil]; - [nc addObserver:self selector:@selector(appWentToForeground:) name:NSApplicationWillBecomeActiveNotification object:nil]; - [nc addObserver:self selector:@selector(windowWentToBackground:) name:NSWindowDidResignMainNotification object:nil]; - [nc addObserver:self selector:@selector(windowWentToForeground:) name:NSWindowDidBecomeMainNotification object:nil]; - inForeground = ([NSApp isActive] && [[self window] isMainWindow]); - curIndex = 0; - running = YES; - timer = [[NSTimer scheduledTimerWithTimeInterval:0.05 - target:self - selector:@selector(showNewImage:) - userInfo:nil - repeats:YES] retain]; - [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSEventTrackingRunLoopMode]; - } -} - -- (void)showNewImage:(NSTimer *)t -{ - [self setNeedsDisplay:YES]; - - if (curIndex == 9) - { - curIndex = 0; - } - else - { - curIndex++; - } -} - -- (void)appWentToBackground:(NSNotification *)note -{ - inForeground = NO; -} - -- (void)appWentToForeground:(NSNotification *)note -{ - inForeground = YES; -} - -- (void)windowWentToBackground:(NSNotification *)note -{ - NSWindow *window = [note object]; - if (window == [self window]) - { - inForeground = NO; - } -} - -- (void)windowWentToForeground:(NSNotification *)note -{ - NSWindow *window = [note object]; - if (window == [self window]) - { - inForeground = YES; - } -} - - -@end diff --git a/Graphics/URLTextViewHand.tiff b/Graphics/URLTextViewHand.tiff deleted file mode 100755 index 37a9783..0000000 Binary files a/Graphics/URLTextViewHand.tiff and /dev/null differ diff --git a/ITBevelView.h b/ITBevelView.h old mode 100755 new mode 100644 index e582c2e..f7141d2 --- a/ITBevelView.h +++ b/ITBevelView.h @@ -1,31 +1,24 @@ /* * ITKit - * ITBevelView - * NSView subclass which draws a bevel. + * ITBevelView.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy + * NSView subclass which draws a bevel of specified thickness, and resizes its + * first subview to fill the remaining space. * - * Copyright (c) 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ -/* - * Draws a bevel of specified thickness, and resizes - * its first subview to fill the remaining space. - */ - - #import - @interface ITBevelView : NSView { - int _bevelDepth; + int _bevelDepth; } - (int)bevelDepth; - (void)setBevelDepth:(int)newDepth; - -@end +@end \ No newline at end of file diff --git a/ITBevelView.m b/ITBevelView.m old mode 100755 new mode 100644 index d5beb0d..09cb89f --- a/ITBevelView.m +++ b/ITBevelView.m @@ -1,119 +1,81 @@ #import "ITBevelView.h" - @implementation ITBevelView - -/*************************************************************************/ -#pragma mark - -#pragma mark INITIALIZATION METHODS -/*************************************************************************/ - -- (id)initWithFrame:(NSRect)frameRect -{ - if ( (self = [super initWithFrame:frameRect]) ) { - _bevelDepth = 5; - [self setAutoresizesSubviews:NO]; - } - - return self; +- (id)initWithFrame:(NSRect)frameRect { + if ((self = [super initWithFrame:frameRect])) { + _bevelDepth = 5; + [self setAutoresizesSubviews:NO]; + } + return self; } -- (id)initWithCoder:(NSCoder *)coder -{ - if ( ( self = [super initWithCoder:coder] ) ) { - _bevelDepth = 5; - [self setAutoresizesSubviews:NO]; - } - - return self; +- (id)initWithCoder:(NSCoder *)coder { + if ((self = [super initWithCoder:coder])) { + _bevelDepth = 5; + [self setAutoresizesSubviews:NO]; + } + return self; } - -/*************************************************************************/ -#pragma mark - -#pragma mark ACCESSOR METHODS -/*************************************************************************/ - -- (int)bevelDepth -{ - return _bevelDepth; +- (int)bevelDepth { + return _bevelDepth; } -- (void)setBevelDepth:(int)newDepth -{ - _bevelDepth = newDepth; - [self setNeedsDisplay:YES]; +- (void)setBevelDepth:(int)newDepth { + _bevelDepth = newDepth; + [self setNeedsDisplay:YES]; } - -/*************************************************************************/ -#pragma mark - -#pragma mark INSTANCE METHODS -/*************************************************************************/ - -- (void)drawRect:(NSRect)aRect -{ - NSRect frameRect = [self convertRect:[self frame] fromView:[self superview]]; - NSRect innerRect = NSMakeRect( (frameRect.origin.x + _bevelDepth), - (frameRect.origin.y + _bevelDepth), - (frameRect.size.width - (_bevelDepth * 2)), - (frameRect.size.height - (_bevelDepth * 2)) ); - - NSBezierPath *leftEdge = [NSBezierPath bezierPath]; - NSBezierPath *topEdge = [NSBezierPath bezierPath]; - NSBezierPath *rightEdge = [NSBezierPath bezierPath]; - NSBezierPath *bottomEdge = [NSBezierPath bezierPath]; - - [[[self subviews] objectAtIndex:0] setFrame:innerRect]; - - [leftEdge moveToPoint:frameRect.origin]; - [leftEdge lineToPoint:NSMakePoint(frameRect.origin.x, frameRect.size.height)]; - [leftEdge lineToPoint:NSMakePoint( (frameRect.origin.x + _bevelDepth), (frameRect.size.height - _bevelDepth) )]; - [leftEdge lineToPoint:NSMakePoint( (frameRect.origin.x + _bevelDepth), (frameRect.origin.y + _bevelDepth) )]; - - [topEdge moveToPoint:NSMakePoint(frameRect.origin.x, frameRect.size.height)]; - [topEdge lineToPoint:NSMakePoint(frameRect.size.width, frameRect.size.height)]; - [topEdge lineToPoint:NSMakePoint( (frameRect.size.width - _bevelDepth), (frameRect.size.height - _bevelDepth) )]; - [topEdge lineToPoint:NSMakePoint( (frameRect.origin.x + _bevelDepth), (frameRect.size.height - _bevelDepth) )]; - - [rightEdge moveToPoint:NSMakePoint(frameRect.size.width, frameRect.origin.y)]; - [rightEdge lineToPoint:NSMakePoint(frameRect.size.width, frameRect.size.height)]; - [rightEdge lineToPoint:NSMakePoint( (frameRect.size.width - _bevelDepth), (frameRect.size.height - _bevelDepth) )]; - [rightEdge lineToPoint:NSMakePoint( (frameRect.size.width - _bevelDepth), (_bevelDepth) )]; - - [bottomEdge moveToPoint:frameRect.origin]; - [bottomEdge lineToPoint:NSMakePoint(frameRect.size.width, frameRect.origin.y)]; - [bottomEdge lineToPoint:NSMakePoint( (frameRect.size.width - _bevelDepth), (_bevelDepth) )]; - [bottomEdge lineToPoint:NSMakePoint( (frameRect.origin.x + _bevelDepth), (frameRect.origin.y + _bevelDepth) )]; - - [[NSColor colorWithCalibratedWhite:0.5 alpha:0.5] set]; - [leftEdge fill]; - [[NSColor colorWithCalibratedWhite:0.0 alpha:0.5] set]; - [topEdge fill]; - [[NSColor colorWithCalibratedWhite:0.5 alpha:0.5] set]; - [rightEdge fill]; - [[NSColor colorWithCalibratedWhite:1.0 alpha:0.6] set]; - [bottomEdge fill]; - - [[[self subviews] objectAtIndex:0] setNeedsDisplay:YES]; +- (void)drawRect:(NSRect)aRect { + NSRect frameRect = [self convertRect:[self frame] fromView:[self superview]]; + NSRect innerRect = NSMakeRect((frameRect.origin.x + _bevelDepth), (frameRect.origin.y + _bevelDepth), (frameRect.size.width - (_bevelDepth * 2)), (frameRect.size.height - (_bevelDepth * 2))); + + NSBezierPath *leftEdge = [NSBezierPath bezierPath]; + NSBezierPath *topEdge = [NSBezierPath bezierPath]; + NSBezierPath *rightEdge = [NSBezierPath bezierPath]; + NSBezierPath *bottomEdge = [NSBezierPath bezierPath]; + + [[[self subviews] objectAtIndex:0] setFrame:innerRect]; + + [leftEdge moveToPoint:frameRect.origin]; + [leftEdge lineToPoint:NSMakePoint(frameRect.origin.x, frameRect.size.height)]; + [leftEdge lineToPoint:NSMakePoint((frameRect.origin.x + _bevelDepth), (frameRect.size.height - _bevelDepth))]; + [leftEdge lineToPoint:NSMakePoint((frameRect.origin.x + _bevelDepth), (frameRect.origin.y + _bevelDepth))]; + + [topEdge moveToPoint:NSMakePoint(frameRect.origin.x, frameRect.size.height)]; + [topEdge lineToPoint:NSMakePoint(frameRect.size.width, frameRect.size.height)]; + [topEdge lineToPoint:NSMakePoint((frameRect.size.width - _bevelDepth), (frameRect.size.height - _bevelDepth))]; + [topEdge lineToPoint:NSMakePoint((frameRect.origin.x + _bevelDepth), (frameRect.size.height - _bevelDepth))]; + + [rightEdge moveToPoint:NSMakePoint(frameRect.size.width, frameRect.origin.y)]; + [rightEdge lineToPoint:NSMakePoint(frameRect.size.width, frameRect.size.height)]; + [rightEdge lineToPoint:NSMakePoint((frameRect.size.width - _bevelDepth), (frameRect.size.height - _bevelDepth))]; + [rightEdge lineToPoint:NSMakePoint((frameRect.size.width - _bevelDepth), _bevelDepth)]; + + [bottomEdge moveToPoint:frameRect.origin]; + [bottomEdge lineToPoint:NSMakePoint(frameRect.size.width, frameRect.origin.y)]; + [bottomEdge lineToPoint:NSMakePoint((frameRect.size.width - _bevelDepth), _bevelDepth)]; + [bottomEdge lineToPoint:NSMakePoint((frameRect.origin.x + _bevelDepth), (frameRect.origin.y + _bevelDepth))]; + + [[NSColor colorWithCalibratedWhite:0.5 alpha:0.5] set]; + [leftEdge fill]; + [[NSColor colorWithCalibratedWhite:0.0 alpha:0.5] set]; + [topEdge fill]; + [[NSColor colorWithCalibratedWhite:0.5 alpha:0.5] set]; + [rightEdge fill]; + [[NSColor colorWithCalibratedWhite:1.0 alpha:0.6] set]; + [bottomEdge fill]; + + [[[self subviews] objectAtIndex:0] setNeedsDisplay:YES]; } -- (BOOL)mouseDownCanMoveWindow -{ - return NO; +- (BOOL)mouseDownCanMoveWindow { + return NO; } - -/*************************************************************************/ -#pragma mark - -#pragma mark DEALLOCATION METHOD -/*************************************************************************/ - -- (void)dealloc -{ +- (void)dealloc { [super dealloc]; } - -@end +@end \ No newline at end of file diff --git a/ITButton.h b/ITButton.h old mode 100755 new mode 100644 index 618437d..e97435c --- a/ITButton.h +++ b/ITButton.h @@ -1,23 +1,20 @@ /* * ITKit - * ITButton - * Stylized button for use in Status Windows. + * ITButton.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy - * Responsibility : Joseph Spiros + * Custom NSButton subclass that uses ITButtonCell. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - #import - @interface ITButton : NSButton { } -@end +@end \ No newline at end of file diff --git a/ITButton.m b/ITButton.m old mode 100755 new mode 100644 index 7a81312..276db25 --- a/ITButton.m +++ b/ITButton.m @@ -1,51 +1,40 @@ #import "ITButton.h" #import "ITButtonCell.h" - @implementation ITButton - -/*************************************************************************/ -#pragma mark - -#pragma mark INITIALIZATION METHODS -/*************************************************************************/ - -+ (void)initialize -{ - if ( self == [ITButton class] ) { - [self setCellClass:[ITButtonCell class]]; - } ++ (void)initialize { + if (self == [ITButton class]) { + [self setCellClass:[ITButtonCell class]]; + } } -+ (Class)cellClass -{ - return [ITButtonCell class]; ++ (Class)cellClass { + return [ITButtonCell class]; } - (void)displayIfNeeded { - [super displayIfNeededIgnoringOpacity]; + [super displayIfNeededIgnoringOpacity]; } - (void)displayIfNeededInRect:(NSRect)aRect { - [super displayIfNeededInRectIgnoringOpacity:aRect]; + [super displayIfNeededInRectIgnoringOpacity:aRect]; } - (void)displayRect:(NSRect)aRect { - [super displayRectIgnoringOpacity:aRect]; + [super displayRectIgnoringOpacity:aRect]; } -- (id)initWithCoder:(NSCoder *)coder -{ - if ( ( self = [super initWithCoder:coder] ) ) { - ITButtonCell *cell = [[ITButtonCell alloc] init]; - [self setCell:cell]; - } - return self; +- (id)initWithCoder:(NSCoder *)coder { + if ((self = [super initWithCoder:coder])) { + ITButtonCell *cell = [[ITButtonCell alloc] init]; + [self setCell:cell]; + } + return self; } -- (BOOL)isOpaque -{ - return NO; +- (BOOL)isOpaque { + return NO; } -@end +@end \ No newline at end of file diff --git a/ITButtonCell.h b/ITButtonCell.h old mode 100755 new mode 100644 index e99ef10..5cea59d --- a/ITButtonCell.h +++ b/ITButtonCell.h @@ -1,31 +1,25 @@ /* * ITKit - * ITButtonCell - * Cell used by the ITButton control. + * ITButtonCell.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy - * Responsibility : Joseph Spiros + * Custom NSButtonCell subclass that provides a stylized bezel style for use + * with ITStatusWindows. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - #import - typedef enum _ITBezelStyle { - ITGrayRoundedBezelStyle = 1001 + ITGrayRoundedBezelStyle = 1001 } ITBezelStyle; - @interface ITButtonCell : NSButtonCell { - - ITBezelStyle _subStyle; - + ITBezelStyle _subStyle; } - -@end +@end \ No newline at end of file diff --git a/ITButtonCell.m b/ITButtonCell.m old mode 100755 new mode 100644 index 30ac956..11e8e95 --- a/ITButtonCell.m +++ b/ITButtonCell.m @@ -1,110 +1,80 @@ #import "ITButtonCell.h" -#import "ITTextFieldCell.h" - #define GRAY_EXTRA_PAD_H 60.0 - @interface ITButtonCell (Private) - (void)drawGrayRoundedBezelWithFrame:(NSRect)rect inView:(NSView *)controlView; @end - @implementation ITButtonCell -- (id)init -{ - if ( ( self = [super init] ) ) { - _subStyle = 0; - } - - return self; +- (id)init { + if ((self = [super init])) { + _subStyle = 0; + } + return self; } - - -/*************************************************************************/ -#pragma mark - -#pragma mark INSTANCE METHODS -/*************************************************************************/ - -- (void)setBezelStyle:(NSBezelStyle)bezelStyle -{ - if ( bezelStyle == ITGrayRoundedBezelStyle ) { - _subStyle = bezelStyle; - bezelStyle = NSRegularSquareBezelStyle; - } else { - _subStyle = 0; - } - - [super setBezelStyle:bezelStyle]; +- (void)setBezelStyle:(NSBezelStyle)bezelStyle { + if (bezelStyle == ITGrayRoundedBezelStyle) { + _subStyle = bezelStyle; + bezelStyle = NSRegularSquareBezelStyle; + } else { + _subStyle = 0; + } + [super setBezelStyle:bezelStyle]; } - -/*************************************************************************/ -#pragma mark - -#pragma mark DRAWING METHODS -/*************************************************************************/ - -- (void)drawWithFrame:(NSRect)rect inView:(NSView *)controlView -{ - if ( _subStyle == ITGrayRoundedBezelStyle ) { - [self drawGrayRoundedBezelWithFrame:rect inView:controlView]; - if ( [self attributedTitle] ) { - NSPoint stringOrigin; - NSSize stringSize; - stringSize = [[self attributedTitle] size]; - stringOrigin.x = rect.origin.x + (rect.size.width - stringSize.width)/2; - stringOrigin.y = (rect.origin.y + (rect.size.height - stringSize.height)/2) - 2; - [controlView lockFocus]; - [[self attributedTitle] drawAtPoint:stringOrigin]; - [controlView unlockFocus]; - } else { - [super drawInteriorWithFrame:rect inView:controlView]; - } - [[controlView superview] setNeedsDisplay:YES]; - } else { - [super drawWithFrame:rect inView:controlView]; - } +- (void)drawWithFrame:(NSRect)rect inView:(NSView *)controlView { + if (_subStyle == ITGrayRoundedBezelStyle) { + [self drawGrayRoundedBezelWithFrame:rect inView:controlView]; + if ([self attributedTitle]) { + NSPoint stringOrigin; + NSSize stringSize; + stringSize = [[self attributedTitle] size]; + stringOrigin.x = rect.origin.x + (rect.size.width - stringSize.width) / 2; + stringOrigin.y = (rect.origin.y + (rect.size.height - stringSize.height) / 2) - 2; + [controlView lockFocus]; + [[self attributedTitle] drawAtPoint:stringOrigin]; + [controlView unlockFocus]; + } else { + [super drawInteriorWithFrame:rect inView:controlView]; + } + [[controlView superview] setNeedsDisplay:YES]; + } else { + [super drawWithFrame:rect inView:controlView]; + } } -- (void)drawGrayRoundedBezelWithFrame:(NSRect)rect inView:(NSView *)controlView -{ - NSBezierPath *path = [NSBezierPath bezierPath]; - float ch = rect.size.height; - float cw = rect.size.width; - float radius = ( ch / 2 ); - NSPoint pointA = NSMakePoint( (ch / 2) , 0.0 ); - NSPoint pointB = NSMakePoint( (cw - (ch / 2)) , 0.0 ); -// NSPoint pointC = NSMakePoint( (cw - (ch / 2)) , ch ); - NSPoint pointD = NSMakePoint( (ch / 2) , ch ); - NSPoint lCtr = NSMakePoint( (ch / 2) , (ch / 2) ); - NSPoint rCtr = NSMakePoint( (cw - (ch / 2)) , (ch / 2) ); - float alpha = 0.45; - - [path moveToPoint:pointA]; - [path lineToPoint:pointB]; - [path appendBezierPathWithArcWithCenter:rCtr - radius:radius - startAngle:270.0 - endAngle:90.0]; - [path lineToPoint:pointD]; - [path appendBezierPathWithArcWithCenter:lCtr - radius:radius - startAngle:90.0 - endAngle:270.0]; - - if ( [self isHighlighted] ) { - alpha = 0.60; - } - - [[NSColor colorWithCalibratedWhite:0.15 alpha:alpha] set]; - [path fill]; +- (void)drawGrayRoundedBezelWithFrame:(NSRect)rect inView:(NSView *)controlView { + NSBezierPath *path = [NSBezierPath bezierPath]; + float ch = rect.size.height; + float cw = rect.size.width; + float radius = (ch / 2); + NSPoint pointA = NSMakePoint((ch / 2), 0.0); + NSPoint pointB = NSMakePoint((cw - (ch / 2)), 0.0); +// NSPoint pointC = NSMakePoint((cw - (ch / 2)), ch); + NSPoint pointD = NSMakePoint((ch / 2), ch); + NSPoint lCtr = NSMakePoint((ch / 2), (ch / 2)); + NSPoint rCtr = NSMakePoint((cw - (ch / 2)), (ch / 2)); + float alpha = 0.45; + + [path moveToPoint:pointA]; + [path lineToPoint:pointB]; + [path appendBezierPathWithArcWithCenter:rCtr radius:radius startAngle:270.0 endAngle:90.0]; + [path lineToPoint:pointD]; + [path appendBezierPathWithArcWithCenter:lCtr radius:radius startAngle:90.0 endAngle:270.0]; + + if ([self isHighlighted]) { + alpha = 0.60; + } + + [[NSColor colorWithCalibratedWhite:0.15 alpha:alpha] set]; + [path fill]; } -- (BOOL)isOpaque -{ - return NO; +- (BOOL)isOpaque { + return NO; } -@end +@end \ No newline at end of file diff --git a/ITCategory-NSMenu.h b/ITCategory-NSMenu.h old mode 100755 new mode 100644 index 2a4870e..aecbe8e --- a/ITCategory-NSMenu.h +++ b/ITCategory-NSMenu.h @@ -1,21 +1,18 @@ /* * ITKit - * ITCategory-NSMenu.h - * Category which extends NSMenu + * ITCategory-NSMenu.h * - * Original Author : Joseph Spiros - * Responsibility : Joseph Spiros + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. * - * Copyright (c) 2002 - 2004 iThink Software. - * All Rights Reserved + * $Id$ * */ - #import #import -@interface NSMenu (ITCategory) +@interface NSMenu (ITKitCategory) - (void)indentItem:(id )item; - (void)indentItemAtIndex:(int)index; @@ -24,4 +21,4 @@ - (MenuRef)menuRef; - (void)removeAllItems; -@end +@end \ No newline at end of file diff --git a/ITCategory-NSMenu.m b/ITCategory-NSMenu.m old mode 100755 new mode 100644 index 80501bf..69d3c61 --- a/ITCategory-NSMenu.m +++ b/ITCategory-NSMenu.m @@ -1,13 +1,18 @@ #import "ITCategory-NSMenu.h" -@interface NSMenu (HACKHACKHACKHACK) +extern void _NSGetMenuItemForCommandKeyEvent(NSMenu *menu, void *chicken, void *taco, void *food); +extern MenuRef _NSGetCarbonMenu(NSMenu *menu); + +@interface NSMenu (ITKitCategoryHacks) - (id)_menuImpl; @end -extern void _NSGetMenuItemForCommandKeyEvent (NSMenu *menu, void *chicken, void *taco, void *food); -extern MenuRef _NSGetCarbonMenu( NSMenu *menu); +@protocol _ITKitCategoryNSMenuItemPantherCompatability +- (int)indentationLevel; +- (void)setIndentationLevel:(int)indentationLevel; +@end -@implementation NSMenu (ITCategory) +@implementation NSMenu (ITKitCategory) - (void)indentItem:(id )item { [self indentItem:item toLevel:1]; @@ -22,8 +27,9 @@ extern MenuRef _NSGetCarbonMenu( NSMenu *menu); } - (void)indentItemAtIndex:(int)index toLevel:(int)indentLevel { - if ([[self itemAtIndex:index] respondsToSelector:@selector(setIndentationLevel:)]) { - (void)[[self itemAtIndex:index] setIndentationLevel:indentLevel]; + id theItem = [self itemAtIndex:index]; + if ([theItem respondsToSelector:@selector(setIndentationLevel:)]) { + [(id <_ITKitCategoryNSMenuItemPantherCompatability>)theItem setIndentationLevel:indentLevel]; } else { MenuRef carbonMenu = [self menuRef]; if (carbonMenu) { @@ -36,7 +42,7 @@ extern MenuRef _NSGetCarbonMenu( NSMenu *menu); MenuRef carbonMenu; int w00t, m00f; - if( [self respondsToSelector:@selector(_menuImpl)] ) { + if ([self respondsToSelector:@selector(_menuImpl)]) { (void)[self _menuImpl]; } else { return nil; @@ -57,4 +63,4 @@ extern MenuRef _NSGetCarbonMenu( NSMenu *menu); } } -@end +@end \ No newline at end of file diff --git a/ITCategory-NSView.h b/ITCategory-NSView.h old mode 100755 new mode 100644 index 3f0c047..0b41f97 --- a/ITCategory-NSView.h +++ b/ITCategory-NSView.h @@ -1,23 +1,19 @@ /* * ITKit - * ITCategory-NSView.h - * Category which extends NSView + * ITCategory-NSView.h * - * Original Author : Joseph Spiros - * Responsibility : Joseph Spiros + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. * - * Copyright (c) 2002 - 2004 iThink Software. - * All Rights Reserved + * $Id$ * */ - - -#import +#import -@interface NSView (ITCategory) +@interface NSView (ITKitCategory) - (void)removeAllSubviews; - (void)removeSubview:(NSView *)subview; -@end +@end \ No newline at end of file diff --git a/ITCategory-NSView.m b/ITCategory-NSView.m old mode 100755 new mode 100644 index 8c6ed90..be4332b --- a/ITCategory-NSView.m +++ b/ITCategory-NSView.m @@ -1,7 +1,6 @@ #import "ITCategory-NSView.h" - -@implementation NSView (ITCategory) +@implementation NSView (ITKitCategory) - (void)removeAllSubviews { [[self subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)]; @@ -13,4 +12,4 @@ } } -@end +@end \ No newline at end of file diff --git a/ITCoreGraphicsHacks.h b/ITCoreGraphicsHacks.h old mode 100755 new mode 100644 index a07942b..c77185d --- a/ITCoreGraphicsHacks.h +++ b/ITCoreGraphicsHacks.h @@ -1,62 +1,48 @@ /* * ITKit - * ITCoreGraphicsHacks - * Header to import to work with private CoreGraphics API + * ITCoreGraphicsHacks.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy + * Header to import to work with private CoreGraphics API. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - -/*************************************************************************/ -#pragma mark - -#pragma mark CoreGraphics HACK HACK HACK -/*************************************************************************/ - 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; + 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 + 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 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); - +extern CGError CGSSetWindowProperty(const CGSConnectionID cid, CGSWindowID wid, const CGSValueObj key, const CGSValueObj value); + extern CGError CGSSetWindowWarp(const CGSConnectionID cid, CGSWindowID wid, int w,int h, float *mesh); extern CGError CGSSetWindowTransform(const CGSConnectionID cid, CGSWindowID wid, CGAffineTransform transform); - -/*************************************************************************/ -#pragma mark - -#pragma mark NSApplication HACK HACK HACK -/*************************************************************************/ - -@interface NSApplication (HACKHACKHACKHACK) +@interface NSApplication (ITCoreGraphicsHacks) - (CGSConnectionID)contextID; -@end - - +@end \ No newline at end of file diff --git a/ITCutWindowEffect.h b/ITCutWindowEffect.h old mode 100755 new mode 100644 index fe53fc1..ad43a4f --- a/ITCutWindowEffect.h +++ b/ITCutWindowEffect.h @@ -1,23 +1,21 @@ /* * ITKit - * ITCutWindowEffect - * Effect subclass which performs a simple cut in or out, with no transition. + * ITCutWindowEffect.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy + * Effect subclass which performs a simple cut in or out, with no transition. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - #import #import "ITWindowEffect.h" - -@interface ITCutWindowEffect : ITWindowEffect { +@interface ITCutWindowEffect : ITWindowEffect { } -@end +@end \ No newline at end of file diff --git a/ITCutWindowEffect.m b/ITCutWindowEffect.m old mode 100755 new mode 100644 diff --git a/ITDissolveWindowEffect.h b/ITDissolveWindowEffect.h old mode 100755 new mode 100644 index ebc6342..73cdfae --- a/ITDissolveWindowEffect.h +++ b/ITDissolveWindowEffect.h @@ -1,23 +1,21 @@ /* * ITKit - * ITDissolveWindowEffect - * Effect subclass which performs a dissolve fade effect on a window. + * ITDissolveWindowEffect.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy + * Effect subclass which performs a dissolve fade effect on a window. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - #import #import "ITWindowEffect.h" - -@interface ITDissolveWindowEffect : ITWindowEffect { +@interface ITDissolveWindowEffect : ITWindowEffect { } -@end +@end \ No newline at end of file diff --git a/ITDissolveWindowEffect.m b/ITDissolveWindowEffect.m old mode 100755 new mode 100644 diff --git a/ITHotKey.h b/ITHotKey.h old mode 100755 new mode 100644 index 7910081..453886a --- a/ITHotKey.h +++ b/ITHotKey.h @@ -1,42 +1,38 @@ /* * ITKit - * ITHotKey + * ITHotKey.h * - * Original Author : Quentin Carnicelli <...> - * Responsibility : Kent Sutherland - * Responsibility : Matthew Judy + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * $Id$ * */ +#import -#import -#import "ITKeyCombo.h" +@class ITKeyCombo; - -@interface ITHotKey : NSObject -{ - NSString* mName; - ITKeyCombo* mKeyCombo; - id mTarget; - SEL mAction; +@interface ITHotKey : NSObject { + NSString *mName; + ITKeyCombo *mKeyCombo; + id mTarget; + SEL mAction; } - (id)init; -- (void)setName: (NSString*)name; -- (NSString*)name; +- (void)setName:(NSString *)name; +- (NSString *)name; -- (void)setKeyCombo: (ITKeyCombo*)combo; -- (ITKeyCombo*)keyCombo; +- (void)setKeyCombo:(ITKeyCombo *)combo; +- (ITKeyCombo *)keyCombo; -- (void)setTarget: (id)target; +- (void)setTarget:(id)target; - (id)target; -- (void)setAction: (SEL)action; +- (void)setAction:(SEL)action; - (SEL)action; - (void)invoke; -@end +@end \ No newline at end of file diff --git a/ITHotKey.m b/ITHotKey.m old mode 100755 new mode 100644 index 0e2ddc3..940223d --- a/ITHotKey.m +++ b/ITHotKey.m @@ -1,91 +1,61 @@ -// -// ITHotKey.m -// -// Created by Quentin Carnicelli on Sat Aug 02 2003. -// Copyright (c) 2003 iThink Software. All rights reserved. -// - #import "ITHotKey.h" - -#import "ITHotKeyCenter.h" #import "ITKeyCombo.h" @implementation ITHotKey -- (id)init -{ - if ( (self = [super init]) ) - { - [self setKeyCombo: [ITKeyCombo clearKeyCombo]]; +- (id)init { + if ((self = [super init])) { + [self setKeyCombo:[ITKeyCombo clearKeyCombo]]; } - return self; } -- (void)dealloc -{ +- (void)dealloc { [mName release]; [mKeyCombo release]; - [super dealloc]; } -- (NSString*)description -{ - return [NSString stringWithFormat: @"<%@: %@>", - NSStringFromClass( [self class] ), - [self keyCombo]]; +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %@>", NSStringFromClass([self class]), [self keyCombo]]; } -#pragma mark - - -- (void)setKeyCombo: (ITKeyCombo*)combo -{ - [combo retain]; - [mKeyCombo release]; - mKeyCombo = combo; +- (void)setKeyCombo:(ITKeyCombo *)combo { + [mKeyCombo autorelease]; + mKeyCombo = [combo retain]; } -- (ITKeyCombo*)keyCombo -{ +- (ITKeyCombo *)keyCombo { return mKeyCombo; } -- (void)setName: (NSString*)name -{ - [name retain]; - [mName release]; - mName = name; +- (void)setName:(NSString *)name { + [mName autorelease]; + mName = [name retain]; } -- (NSString*)name -{ +- (NSString *)name { return mName; } -- (void)setTarget: (id)target -{ +- (void)setTarget:(id)target { mTarget = target; } -- (id)target -{ +- (id)target { return mTarget; } -- (void)setAction: (SEL)action -{ +- (void)setAction:(SEL)action { mAction = action; } -- (SEL)action -{ +- (SEL)action { return mAction; } -- (void)invoke -{ - [mTarget performSelector: mAction withObject: self]; +- (void)invoke { + [mTarget performSelector:mAction withObject:self]; } -@end +@end \ No newline at end of file diff --git a/ITHotKeyCenter.h b/ITHotKeyCenter.h old mode 100755 new mode 100644 index 347110f..153b2ca --- a/ITHotKeyCenter.h +++ b/ITHotKeyCenter.h @@ -1,28 +1,22 @@ /* * ITKit - * ITHotKeyCenter + * ITHotKeyCenter.h * - * Original Author : Quentin Carnicelli <...> - * Responsibility : Kent Sutherland - * Responsibility : Matthew Judy + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * $Id$ * */ - -#import - +#import @class ITHotKey; - -@interface ITHotKeyCenter : NSObject -{ - NSMutableDictionary* mHotKeys; //Keys are NSValue of EventHotKeyRef - BOOL mEventHandlerInstalled; - BOOL _enabled; +@interface ITHotKeyCenter : NSObject { + NSMutableDictionary *mHotKeys; //Keys are NSValue of EventHotKeyRef + BOOL mEventHandlerInstalled; + BOOL _enabled; } + (id)sharedCenter; @@ -30,12 +24,11 @@ - (BOOL)isEnabled; - (void)setEnabled:(BOOL)flag; -- (BOOL)registerHotKey: (ITHotKey*)hotKey; -- (void)unregisterHotKey: (ITHotKey*)hotKey; - -- (NSArray*)allHotKeys; +- (BOOL)registerHotKey:(ITHotKey *)hotKey; +- (void)unregisterHotKey:(ITHotKey *)hotKey; -- (void)sendEvent: (NSEvent*)event; +- (NSArray *)allHotKeys; +- (void)sendEvent:(NSEvent *)event; -@end +@end \ No newline at end of file diff --git a/ITHotKeyCenter.m b/ITHotKeyCenter.m old mode 100755 new mode 100644 index 2e43e56..366f15d --- a/ITHotKeyCenter.m +++ b/ITHotKeyCenter.m @@ -1,198 +1,151 @@ -// -// ITHotKeyCenter.m -// -// Created by Quentin Carnicelli on Sat Aug 02 2003. -// Copyright (c) 2003 iThink Software. All rights reserved. -// - #import "ITHotKeyCenter.h" #import "ITHotKey.h" #import "ITKeyCombo.h" #import -#if __PROTEIN__ -#import "NSObjectAdditions.h" -#endif - @interface ITHotKeyCenter (Private) - (BOOL)_hasCarbonEventSupport; -- (ITHotKey*)_hotKeyForCarbonHotKey: (EventHotKeyRef)carbonHotKey; -- (EventHotKeyRef)_carbonHotKeyForHotKey: (ITHotKey*)hotKey; +- (ITHotKey *)_hotKeyForCarbonHotKey:(EventHotKeyRef)carbonHotKey; +- (EventHotKeyRef)_carbonHotKeyForHotKey:(ITHotKey *)hotKey; - (void)_updateEventHandler; -- (void)_hotKeyDown: (ITHotKey*)hotKey; -- (void)_hotKeyUp: (ITHotKey*)hotKey; -static OSStatus hotKeyEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void* refCon ); +- (void)_hotKeyDown:(ITHotKey *)hotKey; +- (void)_hotKeyUp:(ITHotKey *)hotKey; + +static OSStatus hotKeyEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void *refCon); @end @implementation ITHotKeyCenter -static id _sharedHotKeyCenter = nil; +static ITHotKeyCenter *_sharedHotKeyCenter = nil; -+ (id)sharedCenter -{ - if( _sharedHotKeyCenter == nil ) - { ++ (id)sharedCenter { + if (!_sharedHotKeyCenter) { _sharedHotKeyCenter = [[self alloc] init]; - #if __PROTEIN__ - [_sharedHotKeyCenter releaseOnTerminate]; - #endif } - return _sharedHotKeyCenter; } -- (id)init -{ - self = [super init]; - - if( self ) - { +- (id)init { + if ((self = [super init])) { mHotKeys = [[NSMutableDictionary alloc] init]; _enabled = YES; } - return self; } -- (void)dealloc -{ +- (void)dealloc { [mHotKeys release]; [super dealloc]; } -#pragma mark - - -- (BOOL)isEnabled -{ +- (BOOL)isEnabled { return _enabled; } -- (void)setEnabled:(BOOL)flag -{ +- (void)setEnabled:(BOOL)flag { _enabled = flag; } -- (BOOL)registerHotKey: (ITHotKey*)hotKey -{ - OSStatus err; +- (BOOL)registerHotKey:(ITHotKey *)hotKey { EventHotKeyID hotKeyID; EventHotKeyRef carbonHotKey; - NSValue* key; - - if( [[self allHotKeys] containsObject: hotKey] == YES ) - [self unregisterHotKey: hotKey]; + NSValue *key; + + if ([[self allHotKeys] containsObject:hotKey]) { + [self unregisterHotKey:hotKey]; + } - if( [[hotKey keyCombo] isValidHotKeyCombo] == NO ) + if (![[hotKey keyCombo] isValidHotKeyCombo]) { return YES; + } hotKeyID.signature = 'PTHk'; hotKeyID.id = (long)hotKey; - err = RegisterEventHotKey( [[hotKey keyCombo] keyCode], - [[hotKey keyCombo] modifiers], - hotKeyID, - GetEventDispatcherTarget(), - nil, - &carbonHotKey ); - - if( err ) + if (RegisterEventHotKey([[hotKey keyCombo] keyCode], [[hotKey keyCombo] modifiers], hotKeyID, GetEventDispatcherTarget(), nil, &carbonHotKey)) { return NO; - - key = [NSValue valueWithPointer: carbonHotKey]; - [mHotKeys setObject: hotKey forKey: key]; - + } + + key = [NSValue valueWithPointer:carbonHotKey]; + [mHotKeys setObject:hotKey forKey:key]; + [self _updateEventHandler]; return YES; } -- (void)unregisterHotKey: (ITHotKey*)hotKey -{ +- (void)unregisterHotKey:(ITHotKey *)hotKey { OSStatus err; EventHotKeyRef carbonHotKey; - NSValue* key; - - if( [[self allHotKeys] containsObject: hotKey] == NO ) + NSValue *key; + + if (![[self allHotKeys] containsObject:hotKey]) { return; + } - carbonHotKey = [self _carbonHotKeyForHotKey: hotKey]; - NSAssert( carbonHotKey != nil, @"" ); - - err = UnregisterEventHotKey( carbonHotKey ); - //Watch as we ignore 'err': - - key = [NSValue valueWithPointer: carbonHotKey]; - [mHotKeys removeObjectForKey: key]; + carbonHotKey = [self _carbonHotKeyForHotKey:hotKey]; + NSAssert(carbonHotKey, @""); + + err = UnregisterEventHotKey(carbonHotKey); + + key = [NSValue valueWithPointer:carbonHotKey]; + [mHotKeys removeObjectForKey:key]; [self _updateEventHandler]; - - //See that? Completely ignored } -- (NSArray*)allHotKeys -{ +- (NSArray *)allHotKeys { return [mHotKeys allValues]; } -#pragma mark - - -- (BOOL)_hasCarbonEventSupport -{ - return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_1; +- (BOOL)_hasCarbonEventSupport { + return (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_1); } -- (ITHotKey*)_hotKeyForCarbonHotKey: (EventHotKeyRef)carbonHotKey -{ - NSValue* key = [NSValue valueWithPointer: carbonHotKey]; - return [mHotKeys objectForKey: key]; +- (ITHotKey *)_hotKeyForCarbonHotKey:(EventHotKeyRef)carbonHotKey { + NSValue *key = [NSValue valueWithPointer:carbonHotKey]; + return [mHotKeys objectForKey:key]; } -- (EventHotKeyRef)_carbonHotKeyForHotKey: (ITHotKey*)hotKey -{ - NSArray* values; - NSValue* value; +- (EventHotKeyRef)_carbonHotKeyForHotKey:(ITHotKey *)hotKey { + NSArray *values; + NSValue *value; - values = [mHotKeys allKeysForObject: hotKey]; - NSAssert( [values count] == 1, @"Failed to find Carbon Hotkey for ITHotKey" ); + values = [mHotKeys allKeysForObject:hotKey]; + NSAssert(([values count] == 1), @"Failed to find Carbon Hotkey for ITHotKey"); value = [values lastObject]; return (EventHotKeyRef)[value pointerValue]; } -- (void)_updateEventHandler -{ - if( [self _hasCarbonEventSupport] == NO ) //Don't use event handler on these systems +- (void)_updateEventHandler { + if (![self _hasCarbonEventSupport]) { return; - - if( [mHotKeys count] && mEventHandlerInstalled == NO ) - { + } + + if ([mHotKeys count] && !mEventHandlerInstalled) { EventTypeSpec eventSpec[2] = { { kEventClassKeyboard, kEventHotKeyPressed }, { kEventClassKeyboard, kEventHotKeyReleased } - }; - - InstallEventHandler( GetEventDispatcherTarget(), - (EventHandlerProcPtr)hotKeyEventHandler, - 2, eventSpec, nil, nil); - + }; + + InstallEventHandler(GetEventDispatcherTarget(), (EventHandlerProcPtr)hotKeyEventHandler, 2, eventSpec, nil, nil); + mEventHandlerInstalled = YES; } } -- (void)_hotKeyDown: (ITHotKey*)hotKey -{ +- (void)_hotKeyDown:(ITHotKey *)hotKey { [hotKey invoke]; } -- (void)_hotKeyUp: (ITHotKey*)hotKey -{ +- (void)_hotKeyUp:(ITHotKey *)hotKey { } -- (void)sendEvent: (NSEvent*)event -{ +- (void)sendEvent:(NSEvent *)event { long subType; EventHotKeyRef carbonHotKey; @@ -201,84 +154,67 @@ static id _sharedHotKeyCenter = nil; } //We only have to intercept sendEvent to do hot keys on old system versions - if( [self _hasCarbonEventSupport] ) + if ([self _hasCarbonEventSupport]) { return; + } - if( [event type] == NSSystemDefined ) - { + if ([event type] == NSSystemDefined) { subType = [event subtype]; - if( subType == 6 ) //6 is hot key down - { - carbonHotKey= (EventHotKeyRef)[event data1]; //data1 is our hot key ref - if( carbonHotKey != nil ) - { - ITHotKey* hotKey = [self _hotKeyForCarbonHotKey: carbonHotKey]; - [self _hotKeyDown: hotKey]; + if (subType == 6) { //6 is hot key down + carbonHotKey = (EventHotKeyRef)[event data1]; //data1 is our hot key ref + if (carbonHotKey) { + ITHotKey *hotKey = [self _hotKeyForCarbonHotKey:carbonHotKey]; + [self _hotKeyDown:hotKey]; } - } - else if( subType == 9 ) //9 is hot key up - { - carbonHotKey= (EventHotKeyRef)[event data1]; - if( carbonHotKey != nil ) - { - ITHotKey* hotKey = [self _hotKeyForCarbonHotKey: carbonHotKey]; - [self _hotKeyUp: hotKey]; + } else if (subType == 9) { //9 is hot key up + carbonHotKey = (EventHotKeyRef)[event data1]; + if (carbonHotKey) { + ITHotKey *hotKey = [self _hotKeyForCarbonHotKey:carbonHotKey]; + [self _hotKeyUp:hotKey]; } } } } -- (OSStatus)sendCarbonEvent: (EventRef)event -{ +- (OSStatus)sendCarbonEvent:(EventRef)event { OSStatus err; EventHotKeyID hotKeyID; - ITHotKey* hotKey; + ITHotKey *hotKey; if (!_enabled) { return -1; } - NSAssert( [self _hasCarbonEventSupport], @"" ); - NSAssert( GetEventClass( event ) == kEventClassKeyboard, @"Unknown event class" ); + NSAssert([self _hasCarbonEventSupport], @""); + NSAssert((GetEventClass(event) == kEventClassKeyboard), @"Unknown event class"); - err = GetEventParameter( event, - kEventParamDirectObject, - typeEventHotKeyID, - nil, - sizeof(EventHotKeyID), - nil, - &hotKeyID ); - if( err ) + if ((err = GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, nil, sizeof(EventHotKeyID), nil, &hotKeyID))) { return err; + } + NSAssert((hotKeyID.signature == 'PTHk'), @"Invalid hot key id"); + NSAssert((hotKeyID.id != nil), @"Invalid hot key id"); - NSAssert( hotKeyID.signature == 'PTHk', @"Invalid hot key id" ); - NSAssert( hotKeyID.id != nil, @"Invalid hot key id" ); - - hotKey = (ITHotKey*)hotKeyID.id; - - switch( GetEventKind( event ) ) - { + hotKey = (ITHotKey *)hotKeyID.id; + + switch (GetEventKind(event)) { case kEventHotKeyPressed: - [self _hotKeyDown: hotKey]; - break; - + [self _hotKeyDown:hotKey]; + break; case kEventHotKeyReleased: - [self _hotKeyUp: hotKey]; - break; - + [self _hotKeyUp:hotKey]; + break; default: - NSAssert( 0, @"Unknown event kind" ); - break; + NSAssert(NO, @"Unknown event kind"); + break; } return noErr; } -static OSStatus hotKeyEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void* refCon ) -{ - return [[ITHotKeyCenter sharedCenter] sendCarbonEvent: inEvent]; +static OSStatus hotKeyEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void *refCon) { + return [[ITHotKeyCenter sharedCenter] sendCarbonEvent:inEvent]; } @end diff --git a/ITIconAndTextStatusWindow.h b/ITIconAndTextStatusWindow.h old mode 100755 new mode 100644 index 9955f04..aa0a5d2 --- a/ITIconAndTextStatusWindow.h +++ b/ITIconAndTextStatusWindow.h @@ -1,14 +1,13 @@ /* * ITKit - * ITIconAndTextStatusWindow - * ITTransientStatusWindow subclass to show an icon and text. + * ITIconAndTextStatusWindow.h * - * Original Author : Kent Sutherland - * Responsibility : Kent Sutherland - * Responsibility : Joseph Spiros + * ITTransientStatusWindow subclass to show an icon and text. * - * Copyright (c) 2002 - 2004 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ @@ -16,10 +15,10 @@ #import "ITTransientStatusWindow.h" @interface ITIconAndTextStatusWindow : ITTransientStatusWindow { - NSImage *_image; + NSImage *_image; } - (void)setImage:(NSImage *)newImage; - (void)buildTextWindowWithString:(NSString *)text; -@end +@end \ No newline at end of file diff --git a/ITIconAndTextStatusWindow.m b/ITIconAndTextStatusWindow.m old mode 100755 new mode 100644 diff --git a/ITImageCell.h b/ITImageCell.h old mode 100755 new mode 100644 index d3a9424..61c657f --- a/ITImageCell.h +++ b/ITImageCell.h @@ -1,32 +1,30 @@ /* * ITKit - * ITImageCell - * Cell used by the ITImageView control. + * ITImageCell.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy + * Custom NSImageCell subclass that casts a shadow using CoreGraphics, + * providing support for versions of Cocoa that don't have the NSShadow + * class which was introduced in Mac OS X 10.3 (Panther), and also + * provides smooth scaling. * - * Copyright (c) 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - - -#import +#import @interface ITImageCell : NSImageCell { - - BOOL _scalesSmoothly; - - BOOL castsShadow; - - float shadowElevation; - float shadowAzimuth; - float shadowAmbient; - float shadowHeight; - float shadowRadius; - float shadowSaturation; + BOOL _scalesSmoothly; + BOOL castsShadow; + float shadowElevation; + float shadowAzimuth; + float shadowAmbient; + float shadowHeight; + float shadowRadius; + float shadowSaturation; } - (BOOL)scalesSmoothly; @@ -35,22 +33,22 @@ - (BOOL)castsShadow; - (void)setCastsShadow:(BOOL)newSetting; -- (float)shadowElevation; /* Light source elevation in degrees. Defaults to 45.0 */ +- (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 */ +- (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 */ +- (float)shadowAmbient; /* Amount of ambient light. Defaults to 0.15 */ - (void)setShadowAmbient:(float)newAmbient; -- (float)shadowHeight; /* Height above the canvas. Defaults to 1.0 */ +- (float)shadowHeight; /* Height above the canvas. Defaults to 1.0 */ - (void)setShadowHeight:(float)newHeight; -- (float)shadowRadius; /* Blur radius. Defaults to 4.0 */ +- (float)shadowRadius; /* Blur radius. Defaults to 4.0 */ - (void)setShadowRadius:(float)newRadius; -- (float)shadowSaturation; /* Maximum saturation. Defaults to 1.0 */ +- (float)shadowSaturation; /* Maximum saturation. Defaults to 1.0 */ - (void)setShadowSaturation:(float)newSaturation; -@end +@end \ No newline at end of file diff --git a/ITImageCell.m b/ITImageCell.m old mode 100755 new mode 100644 index 055435a..1ca761d --- a/ITImageCell.m +++ b/ITImageCell.m @@ -1,168 +1,145 @@ #import "ITImageCell.h" -#import #import "ITCoreGraphicsHacks.h" - +#import @implementation ITImageCell +- (id)initImageCell:(NSImage *)image { + if ((self = [super initImageCell:image])) { + _scalesSmoothly = YES; + castsShadow = NO; + shadowElevation = 45.0; + shadowAzimuth = 90.0; + shadowAmbient = 0.15; + shadowHeight = 1.00; + shadowRadius = 4.00; + shadowSaturation = 1.0; + } + return self; +} -- (id)initImageCell:(NSImage *)image -{ - if ( (self = [super initImageCell:image]) ) { - _scalesSmoothly = YES; - castsShadow = NO; - shadowElevation = 45.0; - shadowAzimuth = 90.0; - shadowAmbient = 0.15; - shadowHeight = 1.00; - shadowRadius = 4.00; - shadowSaturation = 1.0; - } - NSLog(@"foo"); - return self; -} - -- (id)init -{ - if ( (self = [super init]) ) { - _scalesSmoothly = YES; - castsShadow = NO; - shadowElevation = 45.0; - shadowAzimuth = 90.0; - shadowAmbient = 0.15; - shadowHeight = 1.00; - shadowRadius = 4.00; - shadowSaturation = 1.0; - } - return self; -} - -- (void)drawWithFrame:(NSRect)rect inView:(NSView *)controlView -{ - CGSGenericObj style = nil; - CGShadowStyle shadow; - - if ( _scalesSmoothly || castsShadow ) { - [NSGraphicsContext saveGraphicsState]; - } - - if ( _scalesSmoothly ) { - // CGContextSetInterpolationQuality([[NSGraphicsContext currentContext] graphicsPort], kCGInterpolationHigh); - [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh]; - [[NSGraphicsContext currentContext] setShouldAntialias:YES]; - } - - 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); - CGContextSetStyle([[NSGraphicsContext currentContext] graphicsPort], style); - } - - [super drawWithFrame:rect inView:controlView]; - - if ( _scalesSmoothly || castsShadow ) { - [NSGraphicsContext restoreGraphicsState]; - } - - if ( castsShadow ) { - CGStyleRelease(style); - } +- (id)init { + if ((self = [super init])) { + _scalesSmoothly = YES; + castsShadow = NO; + shadowElevation = 45.0; + shadowAzimuth = 90.0; + shadowAmbient = 0.15; + shadowHeight = 1.00; + shadowRadius = 4.00; + shadowSaturation = 1.0; + } + return self; } -- (BOOL)scalesSmoothly -{ - return _scalesSmoothly; +- (void)drawWithFrame:(NSRect)rect inView:(NSView *)controlView { + CGSGenericObj style = nil; + CGShadowStyle shadow; + + if (_scalesSmoothly || castsShadow) { + [NSGraphicsContext saveGraphicsState]; + } + + if (_scalesSmoothly) { + // CGContextSetInterpolationQuality([[NSGraphicsContext currentContext] graphicsPort], kCGInterpolationHigh); + [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh]; + [[NSGraphicsContext currentContext] setShouldAntialias:YES]; + } + + 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); + CGContextSetStyle([[NSGraphicsContext currentContext] graphicsPort], style); + } + + [super drawWithFrame:rect inView:controlView]; + + if (castsShadow) { + CGStyleRelease(style); + } + + if (_scalesSmoothly || castsShadow) { + [NSGraphicsContext restoreGraphicsState]; + } } -- (void)setScalesSmoothly:(BOOL)flag -{ - _scalesSmoothly = flag; - [[self controlView] setNeedsDisplay:YES]; +- (BOOL)scalesSmoothly { + return _scalesSmoothly; } -- (BOOL)castsShadow; -{ - return castsShadow; +- (void)setScalesSmoothly:(BOOL)flag { + _scalesSmoothly = flag; + [[self controlView] setNeedsDisplay:YES]; } -- (void)setCastsShadow:(BOOL)newSetting; -{ - castsShadow = newSetting; - [[self controlView] setNeedsDisplay:YES]; +- (BOOL)castsShadow { + return castsShadow; } -- (float)shadowElevation; -{ - return shadowElevation; +- (void)setCastsShadow:(BOOL)newSetting { + castsShadow = newSetting; + [[self controlView] setNeedsDisplay:YES]; } -- (void)setShadowElevation:(float)newElevation; -{ - shadowElevation = newElevation; - [[self controlView] setNeedsDisplay:YES]; +- (float)shadowElevation { + return shadowElevation; } -- (float)shadowAzimuth; -{ - return shadowAzimuth; +- (void)setShadowElevation:(float)newElevation { + shadowElevation = newElevation; + [[self controlView] setNeedsDisplay:YES]; } -- (void)setShadowAzimuth:(float)newAzimuth; -{ - shadowAzimuth = newAzimuth; - [[self controlView] setNeedsDisplay:YES]; +- (float)shadowAzimuth { + return shadowAzimuth; } -- (float)shadowAmbient; -{ - return shadowAmbient; +- (void)setShadowAzimuth:(float)newAzimuth { + shadowAzimuth = newAzimuth; + [[self controlView] setNeedsDisplay:YES]; } -- (void)setShadowAmbient:(float)newAmbient; -{ - shadowAmbient = newAmbient; - [[self controlView] setNeedsDisplay:YES]; +- (float)shadowAmbient { + return shadowAmbient; } -- (float)shadowHeight; -{ - return shadowHeight; +- (void)setShadowAmbient:(float)newAmbient { + shadowAmbient = newAmbient; + [[self controlView] setNeedsDisplay:YES]; } -- (void)setShadowHeight:(float)newHeight; -{ - shadowHeight = newHeight; - [[self controlView] setNeedsDisplay:YES]; +- (float)shadowHeight { + return shadowHeight; } -- (float)shadowRadius; -{ - return shadowRadius; +- (void)setShadowHeight:(float)newHeight { + shadowHeight = newHeight; + [[self controlView] setNeedsDisplay:YES]; } -- (void)setShadowRadius:(float)newRadius; -{ - shadowRadius = newRadius; - [[self controlView] setNeedsDisplay:YES]; +- (float)shadowRadius { + return shadowRadius; } -- (float)shadowSaturation; -{ - return shadowSaturation; +- (void)setShadowRadius:(float)newRadius { + shadowRadius = newRadius; + [[self controlView] setNeedsDisplay:YES]; } -- (void)setShadowSaturation:(float)newSaturation; -{ - shadowSaturation = newSaturation; - [[self controlView] setNeedsDisplay:YES]; +- (float)shadowSaturation { + return shadowSaturation; } +- (void)setShadowSaturation:(float)newSaturation { + shadowSaturation = newSaturation; + [[self controlView] setNeedsDisplay:YES]; +} -@end +@end \ No newline at end of file diff --git a/ITImageView.h b/ITImageView.h old mode 100755 new mode 100644 index 72b768d..3715a0c --- a/ITImageView.h +++ b/ITImageView.h @@ -1,20 +1,18 @@ /* * ITKit - * ITImageView - * NSImageView subclass which adds new features, such as smooth scaling. + * ITImageView.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy + * Custom NSImageView subclass that uses ITImageCell. * - * Copyright (c) 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - #import - @interface ITImageView : NSImageView { } @@ -25,23 +23,22 @@ - (BOOL)castsShadow; - (void)setCastsShadow:(BOOL)newSetting; -- (float)shadowElevation; /* Light source elevation in degrees. Defaults to 45.0 */ +- (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 */ +- (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 */ +- (float)shadowAmbient; /* Amount of ambient light. Defaults to 0.15 */ - (void)setShadowAmbient:(float)newAmbient; -- (float)shadowHeight; /* Height above the canvas. Defaults to 1.0 */ +- (float)shadowHeight; /* Height above the canvas. Defaults to 1.0 */ - (void)setShadowHeight:(float)newHeight; -- (float)shadowRadius; /* Blur radius. Defaults to 4.0 */ +- (float)shadowRadius; /* Blur radius. Defaults to 4.0 */ - (void)setShadowRadius:(float)newRadius; -- (float)shadowSaturation; /* Maximum saturation. Defaults to 1.0 */ +- (float)shadowSaturation; /* Maximum saturation. Defaults to 1.0 */ - (void)setShadowSaturation:(float)newSaturation; - -@end +@end \ No newline at end of file diff --git a/ITImageView.m b/ITImageView.m old mode 100755 new mode 100644 index 228e2f4..de903dd --- a/ITImageView.m +++ b/ITImageView.m @@ -1,110 +1,87 @@ #import "ITImageView.h" #import "ITImageCell.h" - @implementation ITImageView - -+ (void)initialize -{ - if ( self == [ITImageView class] ) { - [self setCellClass:[ITImageCell class]]; - } ++ (void)initialize { + if (self == [ITImageView class]) { + [self setCellClass:[ITImageCell class]]; + } } -+ (Class)cellClass -{ - return [ITImageCell class]; ++ (Class)cellClass { + return [ITImageCell class]; } -- (id)initWithFrame:(NSRect)rect -{ - if ( (self = [super initWithFrame:rect]) ) { - [self setScalesSmoothly:YES]; - } - - return self; +- (id)initWithFrame:(NSRect)rect { + if ((self = [super initWithFrame:rect])) { + [self setScalesSmoothly:YES]; + } + return self; } -- (BOOL)scalesSmoothly -{ - return [[self cell] scalesSmoothly]; +- (BOOL)scalesSmoothly { + return [[self cell] scalesSmoothly]; } -- (void)setScalesSmoothly:(BOOL)flag -{ - [[self cell] setScalesSmoothly:flag]; +- (void)setScalesSmoothly:(BOOL)flag { + [[self cell] setScalesSmoothly:flag]; } -- (BOOL)castsShadow; -{ - return [[self cell] castsShadow]; +- (BOOL)castsShadow { + return [[self cell] castsShadow]; } -- (void)setCastsShadow:(BOOL)newSetting; -{ - [[self cell] setCastsShadow:newSetting]; +- (void)setCastsShadow:(BOOL)newSetting { + [[self cell] setCastsShadow:newSetting]; } -- (float)shadowElevation; -{ - return [[self cell] shadowElevation]; +- (float)shadowElevation { + return [[self cell] shadowElevation]; } -- (void)setShadowElevation:(float)newElevation; -{ - [[self cell] setShadowElevation:newElevation]; +- (void)setShadowElevation:(float)newElevation { + [[self cell] setShadowElevation:newElevation]; } -- (float)shadowAzimuth; -{ - return [[self cell] shadowAzimuth]; +- (float)shadowAzimuth { + return [[self cell] shadowAzimuth]; } -- (void)setShadowAzimuth:(float)newAzimuth; -{ - [[self cell] setShadowAzimuth:newAzimuth]; +- (void)setShadowAzimuth:(float)newAzimuth { + [[self cell] setShadowAzimuth:newAzimuth]; } -- (float)shadowAmbient; -{ - return [[self cell] shadowAmbient]; +- (float)shadowAmbient { + return [[self cell] shadowAmbient]; } -- (void)setShadowAmbient:(float)newAmbient; -{ - [[self cell] setShadowAmbient:newAmbient]; +- (void)setShadowAmbient:(float)newAmbient { + [[self cell] setShadowAmbient:newAmbient]; } -- (float)shadowHeight; -{ - return [[self cell] shadowHeight]; +- (float)shadowHeight { + return [[self cell] shadowHeight]; } -- (void)setShadowHeight:(float)newHeight; -{ - [[self cell] setShadowHeight:newHeight]; +- (void)setShadowHeight:(float)newHeight { + [[self cell] setShadowHeight:newHeight]; } -- (float)shadowRadius; -{ - return [[self cell] shadowRadius]; +- (float)shadowRadius { + return [[self cell] shadowRadius]; } -- (void)setShadowRadius:(float)newRadius; -{ - [[self cell] setShadowRadius:newRadius]; +- (void)setShadowRadius:(float)newRadius { + [[self cell] setShadowRadius:newRadius]; } -- (float)shadowSaturation; -{ - return [[self cell] shadowSaturation]; +- (float)shadowSaturation { + return [[self cell] shadowSaturation]; } -- (void)setShadowSaturation:(float)newSaturation; -{ - [[self cell] setShadowSaturation:newSaturation]; +- (void)setShadowSaturation:(float)newSaturation { + [[self cell] setShadowSaturation:newSaturation]; } - -@end +@end \ No newline at end of file diff --git a/ITKeyBroadcaster.h b/ITKeyBroadcaster.h old mode 100755 new mode 100644 index 1fed89f..d94d75e --- a/ITKeyBroadcaster.h +++ b/ITKeyBroadcaster.h @@ -1,28 +1,22 @@ /* * ITKit - * ITHotKeyBroadcaster + * ITKeyBroadcaster.h * - * Original Author : Quentin Carnicelli <...> - * Responsibility : Kent Sutherland - * Responsibility : Matthew Judy + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * $Id$ * */ +#import -#import +__private_extern__ NSString *ITKeyBroadcasterKeyEvent; //keys: keyCombo as ITKeyCombo +@interface ITKeyBroadcaster : NSButton { -@interface ITKeyBroadcaster : NSButton -{ } -+ (long)cocoaModifiersAsCarbonModifiers: (long)cocoaModifiers; ++ (long)cocoaModifiersAsCarbonModifiers:(long)cocoaModifiers; - -@end - - -__private_extern__ NSString* ITKeyBroadcasterKeyEvent; //keys: keyCombo as ITKeyCombo \ No newline at end of file +@end \ No newline at end of file diff --git a/ITKeyBroadcaster.m b/ITKeyBroadcaster.m old mode 100755 new mode 100644 index b09ea9a..4411022 --- a/ITKeyBroadcaster.m +++ b/ITKeyBroadcaster.m @@ -1,73 +1,58 @@ -// -// ITKeyBroadcaster.m -// -// Created by Quentin Carnicelli on Sun Aug 03 2003. -// Copyright (c) 2003 iThink Software. All rights reserved. -// - #import "ITKeyBroadcaster.h" #import "ITKeyCombo.h" #import -NSString* ITKeyBroadcasterKeyEvent = @"ITKeyBroadcasterKeyEvent"; +NSString *ITKeyBroadcasterKeyEvent = @"ITKeyBroadcasterKeyEvent"; @implementation ITKeyBroadcaster -- (void)_bcastKeyCode: (short)keyCode modifiers: (long)modifiers -{ - ITKeyCombo* keyCombo = [ITKeyCombo keyComboWithKeyCode: keyCode modifiers: modifiers]; - NSDictionary* userInfo = [NSDictionary dictionaryWithObject: keyCombo forKey:@"keyCombo"]; - - [[NSNotificationCenter defaultCenter] - postNotificationName: ITKeyBroadcasterKeyEvent - object: self - userInfo: userInfo]; +- (void)_bcastKeyCode:(short)keyCode modifiers:(long)modifiers { + ITKeyCombo *keyCombo = [ITKeyCombo keyComboWithKeyCode:keyCode modifiers:modifiers]; + NSDictionary *userInfo = [NSDictionary dictionaryWithObject:keyCombo forKey:@"keyCombo"]; + + [[NSNotificationCenter defaultCenter] postNotificationName:ITKeyBroadcasterKeyEvent object:self userInfo:userInfo]; } -- (void)_bcastEvent: (NSEvent*)event -{ +- (void)_bcastEvent:(NSEvent *)event { short keyCode; long modifiers; keyCode = [event keyCode]; modifiers = [event modifierFlags]; - modifiers = [[self class] cocoaModifiersAsCarbonModifiers: modifiers]; - - [self _bcastKeyCode: keyCode modifiers: modifiers]; + modifiers = [[self class] cocoaModifiersAsCarbonModifiers:modifiers]; + + [self _bcastKeyCode:keyCode modifiers:modifiers]; } -- (void)keyDown: (NSEvent*)event -{ - [self _bcastEvent: event]; +- (void)keyDown:(NSEvent *)event { + [self _bcastEvent:event]; } -- (BOOL)performKeyEquivalent: (NSEvent*)event -{ - [self _bcastEvent: event]; +- (BOOL)performKeyEquivalent:(NSEvent *)event { + [self _bcastEvent:event]; return YES; } -+ (long)cocoaModifiersAsCarbonModifiers: (long)cocoaModifiers -{ - static long cocoaToCarbon[6][2] = - { - { NSCommandKeyMask, cmdKey}, - { NSAlternateKeyMask, optionKey}, - { NSControlKeyMask, controlKey}, - { NSShiftKeyMask, shiftKey}, - { NSFunctionKeyMask, rightControlKey}, ++ (long)cocoaModifiersAsCarbonModifiers:(long)cocoaModifiers { + static long cocoaToCarbon[6][2] = { + { NSCommandKeyMask, cmdKey }, + { NSAlternateKeyMask, optionKey }, + { NSControlKeyMask, controlKey }, + { NSShiftKeyMask, shiftKey }, + { NSFunctionKeyMask, rightControlKey }, //{ NSAlphaShiftKeyMask, alphaLock }, //Ignore this? }; - + long carbonModifiers = 0; int i; - for( i = 0 ; i < 6; i++ ) - if( cocoaModifiers & cocoaToCarbon[i][0] ) + for (i = 0;i < 6;i++) { + if (cocoaModifiers & cocoaToCarbon[i][0]) { carbonModifiers += cocoaToCarbon[i][1]; + } + } return carbonModifiers; } - -@end +@end \ No newline at end of file diff --git a/ITKeyCombo.h b/ITKeyCombo.h old mode 100755 new mode 100644 index d5c3d77..130d675 --- a/ITKeyCombo.h +++ b/ITKeyCombo.h @@ -1,35 +1,30 @@ /* * ITKit - * ITKeyCombo + * ITKeyCombo.h * - * Original Author : Quentin Carnicelli <...> - * Responsibility : Kent Sutherland - * Responsibility : Matthew Judy + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * $Id$ * */ +#import -#import - - -@interface ITKeyCombo : NSObject -{ - int mKeyCode; - int mModifiers; +@interface ITKeyCombo : NSObject { + int mKeyCode; + int mModifiers; } + (id)clearKeyCombo; -+ (id)keyComboWithKeyCode: (int)keyCode modifiers: (int)modifiers; -+ (id)keyComboWithPlistRepresentation: (id)plist; -- (id)initWithKeyCode: (int)keyCode modifiers: (int)modifiers; ++ (id)keyComboWithKeyCode:(int)keyCode modifiers:(int)modifiers; ++ (id)keyComboWithPlistRepresentation:(id)plist; +- (id)initWithKeyCode:(int)keyCode modifiers:(int)modifiers; -- (id)initWithPlistRepresentation: (id)plist; +- (id)initWithPlistRepresentation:(id)plist; - (id)plistRepresentation; -- (BOOL)isEqual: (ITKeyCombo*)combo; +- (BOOL)isEqual:(ITKeyCombo *)combo; - (int)keyCode; - (int)modifiers; @@ -37,12 +32,10 @@ - (BOOL)isClearCombo; - (BOOL)isValidHotKeyCombo; - @end - @interface ITKeyCombo (UserDisplayAdditions) -- (NSString*)description; +- (NSString *)description; @end \ No newline at end of file diff --git a/ITKeyCombo.m b/ITKeyCombo.m old mode 100755 new mode 100644 index c0111a1..fc43061 --- a/ITKeyCombo.m +++ b/ITKeyCombo.m @@ -1,182 +1,131 @@ -// -// ITKeyCombo.m -// -// Created by Quentin Carnicelli on Sat Aug 02 2003. -// Copyright (c) 2003 iThink Software. All rights reserved. -// - #import "ITKeyCombo.h" - #import @implementation ITKeyCombo -+ (id)clearKeyCombo -{ - return [self keyComboWithKeyCode: -1 modifiers: -1]; ++ (id)clearKeyCombo { + return [self keyComboWithKeyCode:-1 modifiers:-1]; } -+ (id)keyComboWithKeyCode: (int)keyCode modifiers: (int)modifiers -{ - return [[[self alloc] initWithKeyCode: keyCode modifiers: modifiers] autorelease]; ++ (id)keyComboWithKeyCode:(int)keyCode modifiers:(int)modifiers { + return [[[self alloc] initWithKeyCode:keyCode modifiers:modifiers] autorelease]; } -+ (id)keyComboWithPlistRepresentation: (id)plist -{ - return [[[self alloc] initWithPlistRepresentation: plist] autorelease]; ++ (id)keyComboWithPlistRepresentation:(id)plist { + return [[[self alloc] initWithPlistRepresentation:plist] autorelease]; } -- (id)initWithKeyCode: (int)keyCode modifiers: (int)modifiers -{ - self = [super init]; - - if( self ) - { +- (id)initWithKeyCode:(int)keyCode modifiers:(int)modifiers { + if ((self = [super init])) { mKeyCode = keyCode; mModifiers = modifiers; } - return self; } -- (id)initWithPlistRepresentation: (id)plist -{ +- (id)initWithPlistRepresentation:(id)plist { int keyCode, modifiers; - - keyCode = [[plist objectForKey: @"keyCode"] intValue]; - if( keyCode <= 0 ) keyCode = -1; - - modifiers = [[plist objectForKey: @"modifiers"] intValue]; - if( modifiers <= 0 ) modifiers = -1; - - return [self initWithKeyCode: keyCode modifiers: modifiers]; + + keyCode = [[plist objectForKey:@"keyCode"] intValue]; + if (keyCode <= 0) { + keyCode = -1; + } + + modifiers = [[plist objectForKey:@"modifiers"] intValue]; + if (modifiers <= 0) { + modifiers = -1; + } + + return [self initWithKeyCode:keyCode modifiers:modifiers]; } -- (id)plistRepresentation -{ - return [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithInt: [self keyCode]], @"keyCode", - [NSNumber numberWithInt: [self modifiers]], @"modifiers", - nil]; +- (id)plistRepresentation { + return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:[self keyCode]], @"keyCode", [NSNumber numberWithInt:[self modifiers]], @"modifiers", nil]; } -- (id)copyWithZone:(NSZone*)zone; -{ +- (id)copyWithZone:(NSZone *)zone { return [self retain]; } -- (BOOL)isEqual: (ITKeyCombo*)combo -{ - return [self keyCode] == [combo keyCode] && - [self modifiers] == [combo modifiers]; +- (BOOL)isEqual:(ITKeyCombo *)combo { + return (([self keyCode] == [combo keyCode]) && ([self modifiers] == [combo modifiers])); } -#pragma mark - - -- (int)keyCode -{ +- (int)keyCode { return mKeyCode; } -- (int)modifiers -{ +- (int)modifiers { return mModifiers; } -- (BOOL)isValidHotKeyCombo -{ - return mKeyCode >= 0 && mModifiers > 0; +- (BOOL)isValidHotKeyCombo { + return ((mKeyCode >= 0) && (mModifiers > 0)); } -- (BOOL)isClearCombo -{ - return mKeyCode == -1 && mModifiers == -1; +- (BOOL)isClearCombo { + return ((mKeyCode == -1) && (mModifiers == -1)); } @end -#pragma mark - - @implementation ITKeyCombo (UserDisplayAdditions) -+ (NSDictionary*)_keyCodesDictionary -{ - static NSDictionary* keyCodes = nil; ++ (NSDictionary *)_keyCodesDictionary { + static NSDictionary *keyCodes = nil; - if( keyCodes == nil ) - { - NSString* path; - NSString* contents; + if (!keyCodes) { + NSString *path; + NSString *contents; - path = [[NSBundle bundleForClass: self] pathForResource: @"ITKeyCodes" ofType: @"plist"]; - contents = [NSString stringWithContentsOfFile: path]; + path = [[NSBundle bundleForClass:self] pathForResource:@"ITKeyCodes" ofType:@"plist"]; + contents = [NSString stringWithContentsOfFile:path]; keyCodes = [[contents propertyList] retain]; } return keyCodes; } -+ (NSString*)_stringForModifiers: (long)modifiers -{ - static long modToChar[4][2] = - { - { cmdKey, 0x23180000 }, - { optionKey, 0x23250000 }, - { controlKey, 0x005E0000 }, - { shiftKey, 0x21e70000 } ++ (NSString *)_stringForModifiers:(long)modifiers { + static long modToChar[4][2] = { + { cmdKey, 0x23180000 }, + { optionKey, 0x23250000 }, + { controlKey, 0x005E0000 }, + { shiftKey, 0x21e70000 } }; - - NSString* str = nil; - NSString* charStr; + + NSString *str = @""; + NSString *charStr; long i; - - str = [NSString string]; - - for( i = 0; i < 4; i++ ) - { - if( modifiers & modToChar[i][0] ) - { - charStr = [NSString stringWithCharacters: (const unichar*)&modToChar[i][1] length: 1]; - str = [str stringByAppendingString: charStr]; + + for (i = 0;i < 4;i++) { + if (modifiers & modToChar[i][0]) { + charStr = [NSString stringWithCharacters:(const unichar *)&modToChar[i][1] length:1]; + str = [str stringByAppendingString:charStr]; } } - if( !str ) - str = @""; - return str; } -+ (NSString*)_stringForKeyCode: (short)keyCode -{ - NSDictionary* dict; - id key; - NSString* str; - - dict = [self _keyCodesDictionary]; - key = [NSString stringWithFormat: @"%d", keyCode]; - str = [dict objectForKey: key]; ++ (NSString *)_stringForKeyCode:(short)keyCode { + NSDictionary *dict = [self _keyCodesDictionary]; + NSString *key = [NSString stringWithFormat:@"%d", keyCode]; + NSString *str = [dict objectForKey:key]; - if( !str ) - str = [NSString stringWithFormat: @"%X", keyCode]; + if (!str) { + str = [NSString stringWithFormat:@"%X", keyCode]; + } return str; } -- (NSString*)description -{ - NSString* desc; - - if( [self isValidHotKeyCombo] ) //This might have to change - { - desc = [NSString stringWithFormat: @"%@%@", - [[self class] _stringForModifiers: [self modifiers]], - [[self class] _stringForKeyCode: [self keyCode]]]; +- (NSString *)description { + if ([self isValidHotKeyCombo]) { //This might have to change + return [NSString stringWithFormat:@"%@%@", [[self class] _stringForModifiers:[self modifiers]], [[self class] _stringForKeyCode:[self keyCode]]]; } - else - desc = NSLocalizedString( @"(None)", @"Hot Keys: Key Combo text for 'empty' combo" ); - - return desc; + + return NSLocalizedString(@"(None)", @"Hot Keys: Key Combo text for 'empty' combo"); } @end \ No newline at end of file diff --git a/ITKeyComboPanel.h b/ITKeyComboPanel.h old mode 100755 new mode 100644 index 3df295a..e23f6ee --- a/ITKeyComboPanel.h +++ b/ITKeyComboPanel.h @@ -1,49 +1,41 @@ /* * ITKit - * ITKeyComboPanel + * ITKeyComboPanel.h * - * Original Author : Quentin Carnicelli <...> - * Responsibility : Kent Sutherland - * Responsibility : Matthew Judy + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * $Id$ * */ - -#import - +#import @class ITKeyBroadcaster; @class ITKeyCombo; @class ITHotKey; - -@interface ITKeyComboPanel : NSWindowController -{ - IBOutlet NSTextField* mTitleField; - IBOutlet NSTextField* mComboField; - IBOutlet ITKeyBroadcaster* mKeyBcaster; - - NSString* mKeyName; - ITKeyCombo* mKeyCombo; +@interface ITKeyComboPanel : NSWindowController { + IBOutlet NSTextField *mTitleField; + IBOutlet NSTextField *mComboField; + IBOutlet ITKeyBroadcaster *mKeyBcaster; + NSString *mKeyName; + ITKeyCombo *mKeyCombo; } + (id)sharedPanel; - (int)runModal; -- (void)runModalForHotKey: (ITHotKey*)hotKey; - -- (void)setKeyCombo: (ITKeyCombo*)combo; -- (ITKeyCombo*)keyCombo; +- (void)runModalForHotKey:(ITHotKey *)hotKey; -- (void)setKeyBindingName: (NSString*)name; -- (NSString*)keyBindingName; +- (void)setKeyCombo:(ITKeyCombo *)combo; +- (ITKeyCombo *)keyCombo; -- (IBAction)ok: (id)sender; -- (IBAction)cancel: (id)sender; -- (IBAction)clear: (id)sender; +- (void)setKeyBindingName:(NSString *)name; +- (NSString *)keyBindingName; +- (IBAction)ok:(id)sender; +- (IBAction)cancel:(id)sender; +- (IBAction)clear:(id)sender; -@end +@end \ No newline at end of file diff --git a/ITKeyComboPanel.m b/ITKeyComboPanel.m old mode 100755 new mode 100644 index 3f71636..4fd3ff0 --- a/ITKeyComboPanel.m +++ b/ITKeyComboPanel.m @@ -1,154 +1,107 @@ -// -// ITKeyComboPanel.m -// -// Created by Quentin Carnicelli on Sun Aug 03 2003. -// Copyright (c) 2003 iThink Software. All rights reserved. -// - #import "ITKeyComboPanel.h" - #import "ITHotKey.h" #import "ITKeyCombo.h" #import "ITKeyBroadcaster.h" #import "ITHotKeyCenter.h" -#if __PROTEIN__ -#import "NSObjectAdditions.h" -#endif - @implementation ITKeyComboPanel static id _sharedKeyComboPanel = nil; -+ (id)sharedPanel -{ - if( _sharedKeyComboPanel == nil ) - { ++ (id)sharedPanel { + if (!_sharedKeyComboPanel) { _sharedKeyComboPanel = [[self alloc] init]; - - #if __PROTEIN__ - [_sharedKeyComboPanel releaseOnTerminate]; - #endif } - return _sharedKeyComboPanel; } -- (id)init -{ - return [self initWithWindowNibName: @"ITKeyComboPanel"]; +- (id)init { + return [self initWithWindowNibName:@"ITKeyComboPanel"]; } -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver: self]; +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; [mKeyName release]; - [super dealloc]; } -- (void)windowDidLoad -{ - [[NSNotificationCenter defaultCenter] - addObserver: self - selector: @selector( noteKeyBroadcast: ) - name: ITKeyBroadcasterKeyEvent - object: mKeyBcaster]; +- (void)windowDidLoad { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(noteKeyBroadcast:) name:ITKeyBroadcasterKeyEvent object:mKeyBcaster]; } -- (void)_refreshContents -{ - if( mComboField ) - [mComboField setStringValue: [mKeyCombo description]]; - - if( mTitleField ) +- (void)_refreshContents { + if (mComboField) { + [mComboField setStringValue:[mKeyCombo description]]; + } + if (mTitleField) { [mTitleField setStringValue:mKeyName]; + } } -- (int)runModal -{ +- (int)runModal { int resultCode; - + [self window]; //Force us to load - + [self _refreshContents]; [[self window] center]; - [self showWindow: self]; - resultCode = [[NSApplication sharedApplication] runModalForWindow: [self window]]; + [self showWindow:self]; + resultCode = [[NSApplication sharedApplication] runModalForWindow:[self window]]; [self close]; - + return resultCode; } -- (void)runModalForHotKey: (ITHotKey*)hotKey -{ +- (void)runModalForHotKey:(ITHotKey *)hotKey { int resultCode; - [self setKeyBindingName: [hotKey name]]; - [self setKeyCombo: [hotKey keyCombo]]; + [self setKeyBindingName:[hotKey name]]; + [self setKeyCombo:[hotKey keyCombo]]; resultCode = [self runModal]; - if( resultCode == NSOKButton ) - { - [hotKey setKeyCombo: [self keyCombo]]; - [[ITHotKeyCenter sharedCenter] registerHotKey: hotKey]; + if (resultCode == NSOKButton) { + [hotKey setKeyCombo:[self keyCombo]]; + [[ITHotKeyCenter sharedCenter] registerHotKey:hotKey]; } } -#pragma mark - - -- (void)setKeyCombo: (ITKeyCombo*)combo -{ - [combo retain]; - [mKeyCombo release]; - mKeyCombo = combo; +- (void)setKeyCombo:(ITKeyCombo *)combo { + [mKeyCombo autorelease]; + mKeyCombo = [combo retain]; [self _refreshContents]; } -- (ITKeyCombo*)keyCombo -{ +- (ITKeyCombo *)keyCombo { return mKeyCombo; } -- (void)setKeyBindingName: (NSString*)name -{ - [name retain]; - [mKeyName release]; - mKeyName = name; +- (void)setKeyBindingName:(NSString *)name { + [mKeyName autorelease]; + mKeyName = [name retain]; [self _refreshContents]; } -- (NSString*)keyBindingName -{ +- (NSString *)keyBindingName { return mKeyName; } -#pragma mark - - -- (IBAction)ok: (id)sender -{ - [[NSApplication sharedApplication] stopModalWithCode: NSOKButton]; +- (IBAction)ok:(id)sender { + [[NSApplication sharedApplication] stopModalWithCode:NSOKButton]; } -- (IBAction)cancel: (id)sender -{ - [[NSApplication sharedApplication] stopModalWithCode: NSCancelButton]; +- (IBAction)cancel:(id)sender { + [[NSApplication sharedApplication] stopModalWithCode:NSCancelButton]; } -- (IBAction)clear: (id)sender -{ - [self setKeyCombo: [ITKeyCombo clearKeyCombo]]; - [[NSApplication sharedApplication] stopModalWithCode: NSOKButton]; +- (IBAction)clear:(id)sender { + [self setKeyCombo:[ITKeyCombo clearKeyCombo]]; + [[NSApplication sharedApplication] stopModalWithCode:NSOKButton]; } -- (void)noteKeyBroadcast: (NSNotification*)note -{ - ITKeyCombo* keyCombo; - - keyCombo = [[note userInfo] objectForKey: @"keyCombo"]; - - [self setKeyCombo: keyCombo]; +- (void)noteKeyBroadcast:(NSNotification *)note { + ITKeyCombo *keyCombo = [[note userInfo] objectForKey:@"keyCombo"]; + [self setKeyCombo:keyCombo]; } @end diff --git a/ITKit.h b/ITKit.h old mode 100755 new mode 100644 index 60a36c9..ed6e388 --- a/ITKit.h +++ b/ITKit.h @@ -1,13 +1,13 @@ /* * ITKit - * iThink Software's custom extensions to Apple's AppKit framework + * ITKit.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy - * Responsibility : Joseph Spiros + * iThink Software's custom extensions to Apple's Cocoa framework. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ @@ -32,4 +32,4 @@ #import #import -#import +#import \ No newline at end of file diff --git a/ITKit.xcode/project.pbxproj b/ITKit.xcode/project.pbxproj old mode 100755 new mode 100644 index e8fc996..9511d2b --- a/ITKit.xcode/project.pbxproj +++ b/ITKit.xcode/project.pbxproj @@ -82,7 +82,6 @@ 7C992F8B054F539B000B93EA, 08FB77AEFE84172EC02AAC07, 7C992F90054F53D9000B93EA, - 7C992FA1054F54C3000B93EA, 32C88DFF0371C24200C91783, 089C1665FE841158C02AAC07, 7C99307F054F6982000B93EA, @@ -154,7 +153,6 @@ }; 08FB77AEFE84172EC02AAC07 = { children = ( - 7C01A1B7059B4A86003A4662, 7C992F93054F53F2000B93EA, 7C992F96054F53F7000B93EA, 7C992F9B054F547C000B93EA, @@ -698,86 +696,6 @@ //7C2 //7C3 //7C4 - 7C01A1B7059B4A86003A4662 = { - children = ( - 7C01A1BA059B4A8B003A4662, - ); - isa = PBXGroup; - name = Carbon; - refType = 4; - sourceTree = ""; - }; - 7C01A1BA059B4A8B003A4662 = { - children = ( - 7C01A1BF059B4AA1003A4662, - 7C01A1C0059B4AA1003A4662, - 7C01A1C5059B4AAC003A4662, - 7C01A1C6059B4AAC003A4662, - 7C23B320059BA4C000E08741, - ); - isa = PBXGroup; - name = Resources; - refType = 4; - sourceTree = ""; - }; - 7C01A1BF059B4AA1003A4662 = { - fileEncoding = 4; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.h; - path = ITMacResourceFile.h; - refType = 4; - sourceTree = ""; - }; - 7C01A1C0059B4AA1003A4662 = { - fileEncoding = 4; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.objc; - path = ITMacResourceFile.m; - refType = 4; - sourceTree = ""; - }; - 7C01A1C5059B4AAC003A4662 = { - fileEncoding = 4; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.h; - path = ITMacResource.h; - refType = 4; - sourceTree = ""; - }; - 7C01A1C6059B4AAC003A4662 = { - fileEncoding = 4; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.objc; - path = ITMacResource.m; - refType = 4; - sourceTree = ""; - }; - 7C23B316059BA4AA00E08741 = { - fileEncoding = 4; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.h; - path = ITStringMacResource.h; - refType = 4; - sourceTree = ""; - }; - 7C23B317059BA4AA00E08741 = { - fileEncoding = 4; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.objc; - path = ITStringMacResource.m; - refType = 4; - sourceTree = ""; - }; - 7C23B320059BA4C000E08741 = { - children = ( - 7C23B316059BA4AA00E08741, - 7C23B317059BA4AA00E08741, - ); - isa = PBXGroup; - name = "Custom Types"; - refType = 4; - sourceTree = ""; - }; 7C4BBADA05F98C9900734027 = { fileEncoding = 4; isa = PBXFileReference; @@ -1604,7 +1522,6 @@ 7C992E3E054F5246000B93EA = { children = ( 7C992E3F054F5246000B93EA, - 7C992E43054F5246000B93EA, ); isa = PBXGroup; path = Graphics; @@ -1618,25 +1535,12 @@ refType = 4; sourceTree = ""; }; - 7C992E43054F5246000B93EA = { - isa = PBXFileReference; - lastKnownFileType = image.tiff; - path = URLTextViewHand.tiff; - refType = 4; - sourceTree = ""; - }; 7C992E44054F5246000B93EA = { fileRef = 7C992E3F054F5246000B93EA; isa = PBXBuildFile; settings = { }; }; - 7C992E48054F5246000B93EA = { - fileRef = 7C992E43054F5246000B93EA; - isa = PBXBuildFile; - settings = { - }; - }; 7C992E78054F5285000B93EA = { fileEncoding = 4; isa = PBXFileReference; @@ -1828,134 +1732,6 @@ refType = 4; sourceTree = ""; }; - 7C992FA1054F54C3000B93EA = { - children = ( - 7C993015054F54F0000B93EA, - 7C993016054F54F0000B93EA, - 7C99301F054F5509000B93EA, - ); - isa = PBXGroup; - name = Deprecated; - path = ""; - refType = 4; - sourceTree = ""; - }; - 7C993015054F54F0000B93EA = { - fileEncoding = 4; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.h; - name = ITChasingArrowsView.h; - path = Deprecated/ITChasingArrowsView.h; - refType = 4; - sourceTree = ""; - }; - 7C993016054F54F0000B93EA = { - fileEncoding = 4; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.objc; - name = ITChasingArrowsView.m; - path = Deprecated/ITChasingArrowsView.m; - refType = 4; - sourceTree = ""; - }; - 7C99301F054F5509000B93EA = { - children = ( - 7C993035054F6524000B93EA, - 7C993036054F6524000B93EA, - 7C993037054F6524000B93EA, - 7C993038054F6524000B93EA, - 7C993039054F6524000B93EA, - 7C99303A054F6524000B93EA, - 7C99303B054F6524000B93EA, - 7C99303C054F6524000B93EA, - 7C99303D054F6524000B93EA, - 7C99303E054F6524000B93EA, - ); - isa = PBXGroup; - path = Graphics; - refType = 4; - sourceTree = ""; - }; - 7C993035054F6524000B93EA = { - isa = PBXFileReference; - lastKnownFileType = image.tiff; - name = ITChasingArrow1.tiff; - path = Deprecated/ITChasingArrow1.tiff; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 7C993036054F6524000B93EA = { - isa = PBXFileReference; - lastKnownFileType = image.tiff; - name = ITChasingArrow2.tiff; - path = Deprecated/ITChasingArrow2.tiff; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 7C993037054F6524000B93EA = { - isa = PBXFileReference; - lastKnownFileType = image.tiff; - name = ITChasingArrow3.tiff; - path = Deprecated/ITChasingArrow3.tiff; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 7C993038054F6524000B93EA = { - isa = PBXFileReference; - lastKnownFileType = image.tiff; - name = ITChasingArrow4.tiff; - path = Deprecated/ITChasingArrow4.tiff; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 7C993039054F6524000B93EA = { - isa = PBXFileReference; - lastKnownFileType = image.tiff; - name = ITChasingArrow5.tiff; - path = Deprecated/ITChasingArrow5.tiff; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 7C99303A054F6524000B93EA = { - isa = PBXFileReference; - lastKnownFileType = image.tiff; - name = ITChasingArrow6.tiff; - path = Deprecated/ITChasingArrow6.tiff; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 7C99303B054F6524000B93EA = { - isa = PBXFileReference; - lastKnownFileType = image.tiff; - name = ITChasingArrow7.tiff; - path = Deprecated/ITChasingArrow7.tiff; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 7C99303C054F6524000B93EA = { - isa = PBXFileReference; - lastKnownFileType = image.tiff; - name = ITChasingArrow8.tiff; - path = Deprecated/ITChasingArrow8.tiff; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 7C99303D054F6524000B93EA = { - isa = PBXFileReference; - lastKnownFileType = image.tiff; - name = ITChasingArrow9.tiff; - path = Deprecated/ITChasingArrow9.tiff; - refType = 2; - sourceTree = SOURCE_ROOT; - }; - 7C99303E054F6524000B93EA = { - isa = PBXFileReference; - lastKnownFileType = image.tiff; - name = ITChasingArrow10.tiff; - path = Deprecated/ITChasingArrow10.tiff; - refType = 2; - sourceTree = SOURCE_ROOT; - }; 7C993057054F6832000B93EA = { children = ( 7C992DF9054F5179000B93EA, @@ -2367,7 +2143,6 @@ files = ( 8DC2EF530486A6940098B216, 7C992E44054F5246000B93EA, - 7C992E48054F5246000B93EA, 2A30D88F056B3AD90087AE54, 2A30D8A3056B3BE30087AE54, 2A30D8BE056B3C5D0087AE54, diff --git a/ITMacResource.h b/ITMacResource.h deleted file mode 100755 index c05da2f..0000000 --- a/ITMacResource.h +++ /dev/null @@ -1,33 +0,0 @@ -// -// ITMacResource.h -// ITKit -// -// Created by Joseph Spiros on Thu Dec 25 2003. -// Copyright (c) 2003 __MyCompanyName__. All rights reserved. -// - -#import -#import - -typedef ResType ITMacResourceType; - -@interface ITMacResource : NSObject { - @protected - Handle _handle; -} -+ (void)_registerClass:(Class)class forType:(ITMacResourceType)type; -+ (Class)_classForType:(ITMacResourceType)type; - -+ (id)_resourceWithHandle:(Handle)handle; -- (id)_initWithHandle:(Handle)handle; - -- (Handle)_handle; - -- (NSData *)data; -- (ITMacResourceType)type; -- (NSNumber *)id; -- (NSString *)name; - -- (Class)nativeRepresentationClass; -- (id)nativeRepresentation; -@end diff --git a/ITMacResource.m b/ITMacResource.m deleted file mode 100755 index 1ae8883..0000000 --- a/ITMacResource.m +++ /dev/null @@ -1,89 +0,0 @@ -// -// ITMacResource.m -// ITKit -// -// Created by Joseph Spiros on Thu Dec 25 2003. -// Copyright (c) 2003 __MyCompanyName__. All rights reserved. -// - -#import "ITMacResource.h" - - -@implementation ITMacResource - -static NSMutableDictionary *_resourceTypeClasses = nil; - -+ (void)_registerClass:(Class)class forType:(ITMacResourceType)type { - if (!_resourceTypeClasses) { - _resourceTypeClasses = [[NSMutableDictionary dictionary] retain]; - } - [_resourceTypeClasses setObject:class forKey:[NSString stringWithCString:(char *)type]]; -} - -+ (Class)_classForType:(ITMacResourceType)type { - Class _class = [_resourceTypeClasses objectForKey:[NSString stringWithCString:(char *)type]]; - return ((_class == nil) ? [ITMacResource class] : _class); -} - -+ (id)_resourceWithHandle:(Handle)handle { // THIS *WILL* RETURN A MORE SPECIFIC INSTANCE USING THE REGISTRATION DATABASE IF SUCH A CLASS EXISTS - return [[[self alloc] _initWithHandle:handle] autorelease]; -} - -- (id)_initWithHandle:(Handle)handle { - if (self = [super init]) { - _handle = handle; - } - return self; -} - -- (Handle)_handle { - return _handle; -} - -- (NSData *)data { - NSData *_data; - HLock(_handle); - _data = [NSData dataWithBytes:(*_handle) length:GetHandleSize(_handle)]; - HUnlock(_handle); - return _data; -} - -- (ITMacResourceType)type { - short _id; - ResType _type; - Str255 _name; - GetResInfo(_handle, &_id, &_type, _name); - return (ITMacResourceType)_type; -} - -- (NSNumber *)id { - short _id; - ResType _type; - Str255 _name; - GetResInfo(_handle, &_id, &_type, _name); - return [NSNumber numberWithShort:_id]; -} - -- (NSString *)name { - short _id; - ResType _type; - Str255 _name; - GetResInfo(_handle, &_id, &_type, _name); - return [(NSString*)CFStringCreateWithPascalString(NULL, -_name, kCFStringEncodingMacRomanLatin1) autorelease]; -} - -- (Class)nativeRepresentationClass { - return nil; -} - -- (id)nativeRepresentation { - return nil; -} - -- (void)dealloc { - ReleaseResource(_handle); - [super dealloc]; -} - -@end diff --git a/ITMacResourceFile.h b/ITMacResourceFile.h deleted file mode 100755 index 4cfa271..0000000 --- a/ITMacResourceFile.h +++ /dev/null @@ -1,22 +0,0 @@ -// -// ITMacResourceFile.h -// ITKit -// -// Created by Joseph Spiros on Thu Dec 25 2003. -// Copyright (c) 2003 __MyCompanyName__. All rights reserved. -// - -#import -#import -#import "ITMacResource.h" - -@interface ITMacResourceFile : NSObject { - FSRef _fileReference; - SInt16 _referenceNumber; -} -- (id)initWithContentsOfFile:(NSString *)path; -- (id)initWithContentsOfFile:(NSString *)path fork:(HFSUniStr255)namedFork; - -- (ITMacResource *)resourceOfType:(ITMacResourceType)type withID:(NSNumber *)idNum; -- (ITMacResource *)resourceOfType:(ITMacResourceType)type withName:(NSString *)name; -@end diff --git a/ITMacResourceFile.m b/ITMacResourceFile.m deleted file mode 100755 index 6f39d53..0000000 --- a/ITMacResourceFile.m +++ /dev/null @@ -1,53 +0,0 @@ -// -// ITMacResourceFile.m -// ITKit -// -// Created by Joseph Spiros on Thu Dec 25 2003. -// Copyright (c) 2003 __MyCompanyName__. All rights reserved. -// - -#import "ITMacResourceFile.h" - - -@implementation ITMacResourceFile - -- (id)initWithContentsOfFile:(NSString *)path { - HFSUniStr255 dataForkName; - FSGetDataForkName(&dataForkName); - return [self initWithContentsOfFile:path fork:dataForkName]; -} - -- (id)initWithContentsOfFile:(NSString *)path fork:(HFSUniStr255)namedFork { - if (self = [super init]) { - if (FSPathMakeRef([path fileSystemRepresentation],&_fileReference,NULL) == noErr) { - FSOpenResourceFile(&_fileReference, namedFork.length, namedFork.unicode, fsRdPerm, &_referenceNumber); - } else { - // Raise Exception! - } - } - return self; -} - -- (ITMacResource *)resourceOfType:(ITMacResourceType)type withID:(NSNumber *)idNum { - return [[ITMacResource _classForType:type] _resourceWithHandle:GetResource((ResType)type,[idNum shortValue])]; -} - -- (ITMacResource *)resourceOfType:(ITMacResourceType)type withName:(NSString *)name { - Str255 _buffer; - StringPtr _ptr = CFStringGetPascalStringPtr((CFStringRef)name, kCFStringEncodingMacRomanLatin1); - if (_ptr == NULL) { - if (CFStringGetPascalString((CFStringRef)name, _buffer, 256, kCFStringEncodingMacRomanLatin1)) { - _ptr = _buffer; - } else { - // Raise exception! - } - } - return [[ITMacResource _classForType:type] _resourceWithHandle:GetNamedResource((ResType)type,_ptr)]; -} - -- (void)dealloc { - CloseResFile(_referenceNumber); - [super dealloc]; -} - -@end diff --git a/ITMultilineTextFieldCell.h b/ITMultilineTextFieldCell.h old mode 100755 new mode 100644 index 59ca9c0..01fc748 --- a/ITMultilineTextFieldCell.h +++ b/ITMultilineTextFieldCell.h @@ -1,15 +1,21 @@ -// -// ITMultilineTextFieldCell.h -// ITKit -// -// Created by Joseph Spiros on Fri Mar 05 2004. -// Copyright (c) 2004 __MyCompanyName__. All rights reserved. -// +/* + * ITKit + * ITMultilineTextFieldCell.h + * + * Custom NSCell subclass that draws multiple lines of text using standard + * UI guidelines for such a presentation. + * + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ + * + */ #import - @interface ITMultilineTextFieldCell : NSCell { + } -@end +@end \ No newline at end of file diff --git a/ITMultilineTextFieldCell.m b/ITMultilineTextFieldCell.m old mode 100755 new mode 100644 index b804768..3fda642 --- a/ITMultilineTextFieldCell.m +++ b/ITMultilineTextFieldCell.m @@ -1,113 +1,103 @@ -// -// ITMultilineTextFieldCell.m -// ITKit -// -// Created by Joseph Spiros on Fri Mar 05 2004. -// Copyright (c) 2004 __MyCompanyName__. All rights reserved. -// - #import "ITMultilineTextFieldCell.h" - @implementation ITMultilineTextFieldCell -- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView -{ - if ([[self objectValue] isKindOfClass:[NSArray class]]) { - - /* - Okay, here's the different possibilities for the objectValue of this cell, and how they're displayed: - - NSArray of NSStrings - Draw first line with System Font, following lines with Small System Font - NSArray of NSAttributedStrings - Draw as given - NSArray of both - Draw each line as above! - - The number of lines is determined by the contents of the array... - */ - - NSColor *defaultColor; - NSMutableParagraphStyle *paragraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease]; - [paragraphStyle setLineBreakMode:NSLineBreakByTruncatingTail]; - NSPoint cellPoint = cellFrame.origin; - NSSize cellSize = cellFrame.size; - - NSRect secondaryLineRect; - - if ([self isHighlighted] && ([self highlightColorWithFrame:cellFrame inView:controlView]!=[NSColor secondarySelectedControlColor])) { - defaultColor = [NSColor whiteColor]; - } else { - defaultColor = [NSColor blackColor]; - } - - // Process the first line... - { - NSDictionary *firstLineAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont boldSystemFontOfSize:[NSFont systemFontSize]], NSFontAttributeName, defaultColor, NSForegroundColorAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil]; - - NSRect firstLineRect = NSMakeRect(cellPoint.x+5, cellPoint.y+1, cellSize.width-5, cellSize.height); - - id firstString = [[self objectValue] objectAtIndex:0]; - NSMutableAttributedString *firstAttrString; - - if ([firstString isKindOfClass:[NSAttributedString class]]) { - firstAttrString = [[[NSMutableAttributedString alloc] initWithAttributedString:firstString] autorelease]; - [firstAttrString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0,[firstAttrString length])]; - if ([defaultColor isEqual:[NSColor whiteColor]]) { - [firstAttrString addAttribute:NSForegroundColorAttributeName value:defaultColor range:NSMakeRange(0,[firstAttrString length])]; - } - } else if ([firstString isKindOfClass:[NSString class]]) { - firstAttrString = [[[NSMutableAttributedString alloc] initWithString:firstString attributes:firstLineAttributes] autorelease]; - } else { - firstAttrString = [[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"Object (%@) is not a string", firstString] attributes:firstLineAttributes] autorelease]; - } - - [controlView lockFocus]; - - [firstAttrString drawInRect:firstLineRect]; - - [controlView unlockFocus]; - - secondaryLineRect = NSMakeRect(cellPoint.x+5, (cellPoint.y+1+[firstAttrString size].height), cellSize.width-5, cellSize.height); - } - - // Process the secondary lines - { - NSDictionary *secondaryLineAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]], NSFontAttributeName, defaultColor, NSForegroundColorAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil]; - - NSMutableArray *tMArray = [NSMutableArray arrayWithArray:[self objectValue]]; - [tMArray removeObjectAtIndex:0]; // Remove the first line string... already handled that above! - - NSEnumerator *enumerator = [tMArray objectEnumerator]; - id secondaryString; - - while (secondaryString = [enumerator nextObject]) { - - NSMutableAttributedString *secondaryAttrString; - - if ([secondaryString isKindOfClass:[NSAttributedString class]]) { - secondaryAttrString = [[[NSMutableAttributedString alloc] initWithAttributedString:secondaryString] autorelease]; - [secondaryAttrString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0,[secondaryAttrString length])]; - if ([defaultColor isEqual:[NSColor whiteColor]]) { - [secondaryAttrString addAttribute:NSForegroundColorAttributeName value:defaultColor range:NSMakeRange(0,[secondaryAttrString length])]; - } - } else if ([secondaryString isKindOfClass:[NSString class]]) { - secondaryAttrString = [[[NSMutableAttributedString alloc] initWithString:secondaryString attributes:secondaryLineAttributes] autorelease]; - } else { - secondaryAttrString = [[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"Object (%@) is not a string", secondaryString] attributes:secondaryLineAttributes] autorelease]; - } - - [controlView lockFocus]; - - [secondaryAttrString drawInRect:secondaryLineRect]; - - [controlView unlockFocus]; - - secondaryLineRect.origin.y = secondaryLineRect.origin.y+[secondaryAttrString size].height; // modify the rect for the next loop, based on the size and location of the most recently processed line. - - } - } - } else { - [super drawInteriorWithFrame:cellFrame inView:controlView]; - } +- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { + if ([(id)[self objectValue] isKindOfClass:[NSArray class]]) { + + /* + Okay, here's the different possibilities for the objectValue of this cell, and how they're displayed: + + NSArray of NSStrings - Draw first line with System Font, following lines with Small System Font + NSArray of NSAttributedStrings - Draw as given + NSArray of both - Draw each line as above! + + The number of lines is determined by the contents of the array... + */ + + NSColor *defaultColor; + NSMutableParagraphStyle *paragraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease]; + [paragraphStyle setLineBreakMode:NSLineBreakByTruncatingTail]; + NSPoint cellPoint = cellFrame.origin; + NSSize cellSize = cellFrame.size; + + NSRect secondaryLineRect; + + if ([self isHighlighted] && ([self highlightColorWithFrame:cellFrame inView:controlView]!=[NSColor secondarySelectedControlColor])) { + defaultColor = [NSColor whiteColor]; + } else { + defaultColor = [NSColor blackColor]; + } + + // Process the first line... + { + NSDictionary *firstLineAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont boldSystemFontOfSize:[NSFont systemFontSize]], NSFontAttributeName, defaultColor, NSForegroundColorAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil]; + + NSRect firstLineRect = NSMakeRect(cellPoint.x+5, cellPoint.y+1, cellSize.width-5, cellSize.height); + + id firstString = [(NSArray *)[self objectValue] objectAtIndex:0]; + NSMutableAttributedString *firstAttrString; + + if ([firstString isKindOfClass:[NSAttributedString class]]) { + firstAttrString = [[[NSMutableAttributedString alloc] initWithAttributedString:firstString] autorelease]; + [firstAttrString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0,[firstAttrString length])]; + if ([defaultColor isEqual:[NSColor whiteColor]]) { + [firstAttrString addAttribute:NSForegroundColorAttributeName value:defaultColor range:NSMakeRange(0,[firstAttrString length])]; + } + } else if ([firstString isKindOfClass:[NSString class]]) { + firstAttrString = [[[NSMutableAttributedString alloc] initWithString:firstString attributes:firstLineAttributes] autorelease]; + } else { + firstAttrString = [[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"Object (%@) is not a string", firstString] attributes:firstLineAttributes] autorelease]; + } + + [controlView lockFocus]; + + [firstAttrString drawInRect:firstLineRect]; + + [controlView unlockFocus]; + + secondaryLineRect = NSMakeRect(cellPoint.x+5, (cellPoint.y+1+[firstAttrString size].height), cellSize.width-5, cellSize.height); + } + + // Process the secondary lines + { + NSDictionary *secondaryLineAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]], NSFontAttributeName, defaultColor, NSForegroundColorAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil]; + + NSMutableArray *tMArray = [NSMutableArray arrayWithArray:(NSArray *)[self objectValue]]; + [tMArray removeObjectAtIndex:0]; // Remove the first line string... already handled that above! + + NSEnumerator *enumerator = [tMArray objectEnumerator]; + id secondaryString; + + while ((secondaryString = [enumerator nextObject])) { + + NSMutableAttributedString *secondaryAttrString; + + if ([secondaryString isKindOfClass:[NSAttributedString class]]) { + secondaryAttrString = [[[NSMutableAttributedString alloc] initWithAttributedString:secondaryString] autorelease]; + [secondaryAttrString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0,[secondaryAttrString length])]; + if ([defaultColor isEqual:[NSColor whiteColor]]) { + [secondaryAttrString addAttribute:NSForegroundColorAttributeName value:defaultColor range:NSMakeRange(0,[secondaryAttrString length])]; + } + } else if ([secondaryString isKindOfClass:[NSString class]]) { + secondaryAttrString = [[[NSMutableAttributedString alloc] initWithString:secondaryString attributes:secondaryLineAttributes] autorelease]; + } else { + secondaryAttrString = [[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"Object (%@) is not a string", secondaryString] attributes:secondaryLineAttributes] autorelease]; + } + + [controlView lockFocus]; + + [secondaryAttrString drawInRect:secondaryLineRect]; + + [controlView unlockFocus]; + + secondaryLineRect.origin.y = secondaryLineRect.origin.y+[secondaryAttrString size].height; // modify the rect for the next loop, based on the size and location of the most recently processed line. + + } + } + } else { + [super drawInteriorWithFrame:cellFrame inView:controlView]; + } } -@end +@end \ No newline at end of file diff --git a/ITPivotWindowEffect.h b/ITPivotWindowEffect.h old mode 100755 new mode 100644 index ae69b00..add7c1c --- a/ITPivotWindowEffect.h +++ b/ITPivotWindowEffect.h @@ -1,23 +1,21 @@ /* * ITKit - * ITPivotWindowEffect - * Effect subclass which pivots (rotates) a window into position on the screen. + * ITPivotWindowEffect.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy + * Effect subclass which pivots (rotates) a window into position on the screen. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - #import #import "ITWindowEffect.h" - -@interface ITPivotWindowEffect : ITWindowEffect { +@interface ITPivotWindowEffect : ITWindowEffect { } -@end +@end \ No newline at end of file diff --git a/ITPivotWindowEffect.m b/ITPivotWindowEffect.m old mode 100755 new mode 100644 diff --git a/ITSlideHorizontallyWindowEffect.h b/ITSlideHorizontallyWindowEffect.h old mode 100755 new mode 100644 index 5054912..32b042d --- a/ITSlideHorizontallyWindowEffect.h +++ b/ITSlideHorizontallyWindowEffect.h @@ -1,23 +1,21 @@ /* * ITKit - * ITSlideHorizontallyWindowEffect - * Effect subclass which slides a window in from the right or left side of the screen. + * ITSlideHorizontallyWindowEffect.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy + * Effect subclass which slides a window in from the right or left side of the screen. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - #import #import "ITWindowEffect.h" - -@interface ITSlideHorizontallyWindowEffect : ITWindowEffect { +@interface ITSlideHorizontallyWindowEffect : ITWindowEffect { } -@end +@end \ No newline at end of file diff --git a/ITSlideHorizontallyWindowEffect.m b/ITSlideHorizontallyWindowEffect.m old mode 100755 new mode 100644 diff --git a/ITSlideVerticallyWindowEffect.h b/ITSlideVerticallyWindowEffect.h old mode 100755 new mode 100644 index 58a4fe9..842c5d2 --- a/ITSlideVerticallyWindowEffect.h +++ b/ITSlideVerticallyWindowEffect.h @@ -1,23 +1,21 @@ /* * ITKit - * ITSlideVerticallyWindowEffect - * Effect subclass which slides a window in from the top or bottom of the screen. + * ITSlideVerticallyWindowEffect.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy + * Effect subclass which slides a window in from the top or bottom of the screen. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - #import #import "ITWindowEffect.h" - -@interface ITSlideVerticallyWindowEffect : ITWindowEffect { +@interface ITSlideVerticallyWindowEffect : ITWindowEffect { } -@end +@end \ No newline at end of file diff --git a/ITSlideVerticallyWindowEffect.m b/ITSlideVerticallyWindowEffect.m old mode 100755 new mode 100644 diff --git a/ITSpinAndZoomWindowEffect.h b/ITSpinAndZoomWindowEffect.h old mode 100755 new mode 100644 index 5f923ec..750331f --- a/ITSpinAndZoomWindowEffect.h +++ b/ITSpinAndZoomWindowEffect.h @@ -1,23 +1,21 @@ /* * ITKit - * ITSpinAndZoomWindowEffect - * Effect subclass which Spins (expands/shrinks) a window into position on the screen. + * ITSpinAndZoomWindowEffect.h * - * Original Author : Kent Sutherland - * Responsibility : Kent Sutherland + * Effect subclass which spins and zooms a window into position on the screen. * - * Copyright (c) 2002 - 2004 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - #import #import "ITWindowEffect.h" - -@interface ITSpinAndZoomWindowEffect : ITWindowEffect { +@interface ITSpinAndZoomWindowEffect : ITWindowEffect { } -@end +@end \ No newline at end of file diff --git a/ITSpinAndZoomWindowEffect.m b/ITSpinAndZoomWindowEffect.m old mode 100755 new mode 100644 diff --git a/ITSpinWindowEffect.h b/ITSpinWindowEffect.h old mode 100755 new mode 100644 index ee6fad8..93cf3b4 --- a/ITSpinWindowEffect.h +++ b/ITSpinWindowEffect.h @@ -1,23 +1,21 @@ /* * ITKit - * ITSpinWindowEffect - * Effect subclass which Spins (expands/shrinks) a window into position on the screen. + * ITSpinWindowEffect.h * - * Original Author : Kent Sutherland - * Responsibility : Kent Sutherland + * Effect subclass which spins a window into position on the screen. * - * Copyright (c) 2002 - 2004 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - #import #import "ITWindowEffect.h" - -@interface ITSpinWindowEffect : ITWindowEffect { +@interface ITSpinWindowEffect : ITWindowEffect { } -@end +@end \ No newline at end of file diff --git a/ITSpinWindowEffect.m b/ITSpinWindowEffect.m old mode 100755 new mode 100644 diff --git a/ITSplashScreen.h b/ITSplashScreen.h index 40ac83c..42ab05c 100644 --- a/ITSplashScreen.h +++ b/ITSplashScreen.h @@ -1,15 +1,24 @@ -/* ITSplashScreen */ +/* + * ITKit + * ITSplashScreen.h + * + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ + * + */ #import @class ITSplashWindow, ITSplashView; -@interface ITSplashScreen : NSObject -{ +@interface ITSplashScreen : NSObject { NSTimer *_fadeTimer; ITSplashWindow *_window; ITSplashView *_view; } + + (ITSplashScreen *)sharedController; - (double)progressValue; @@ -22,4 +31,5 @@ - (void)showSplashWindow; - (void)closeSplashWindow; -@end + +@end \ No newline at end of file diff --git a/ITSplashScreen.m b/ITSplashScreen.m index ce7a8cd..f41ddb6 100644 --- a/ITSplashScreen.m +++ b/ITSplashScreen.m @@ -2,21 +2,19 @@ #import "ITSplashWindow.h" #import "ITSplashView.h" -static ITSplashScreen *_sharedController; +static ITSplashScreen *_sharedScreen; @implementation ITSplashScreen -+ (ITSplashScreen *)sharedController -{ - if (!_sharedController) { - _sharedController = [[ITSplashScreen alloc] init]; ++ (ITSplashScreen *)sharedController { + if (!_sharedScreen) { + _sharedScreen = [[ITSplashScreen alloc] init]; } - return _sharedController; + return _sharedScreen; } -- (id)init -{ - if ( (self = [super init]) ) { +- (id)init { + if ((self = [super init])) { _window = [[ITSplashWindow alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; _view = [[ITSplashView alloc] initWithFrame:NSMakeRect(0, 0, 200, 200)]; [_window setLevel:NSStatusWindowLevel]; @@ -25,19 +23,16 @@ static ITSplashScreen *_sharedController; return self; } -- (void)dealloc -{ +- (void)dealloc { [_window release]; [super dealloc]; } -- (double)progressValue -{ +- (double)progressValue { return ([[_view progressIndicator] doubleValue] / 100.0); } -- (void)setProgressValue:(double)progress -{ +- (void)setProgressValue:(double)progress { if (progress >= 1.0) { [[_view progressIndicator] setIndeterminate:YES]; } else { @@ -45,13 +40,11 @@ static ITSplashScreen *_sharedController; } } -- (NSImage *)image -{ +- (NSImage *)image { return [_view image]; } -- (void)setImage:(NSImage *)image -{ +- (void)setImage:(NSImage *)image { NSRect rect = NSZeroRect, newRect = [_window frame]; rect.size = [image size]; newRect.size = rect.size; @@ -63,48 +56,41 @@ static ITSplashScreen *_sharedController; [_window center]; } -- (NSString *)string -{ +- (NSString *)string { return [_view string]; } -- (void)setString:(NSString *)string -{ +- (void)setString:(NSString *)string { [_view setString:string]; } -- (void)setSettingsPath:(NSString *)path -{ +- (void)setSettingsPath:(NSString *)path { [_view loadControlsFromPath:path]; } -- (void)showSplashWindow -{ +- (void)showSplashWindow { //[_window setAlphaValue:0.0]; [_window makeKeyAndOrderFront:nil]; //_fadeTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / 30.0) target:self selector:@selector(showStep:) userInfo:nil repeats:YES]; } -- (void)showStep:(NSTimer *)timer -{ - [_window setAlphaValue:[_window alphaValue] + 0.05]; +- (void)showStep:(NSTimer *)timer { + [_window setAlphaValue:([_window alphaValue] + 0.05)]; if ([_window alphaValue] >= 1.0) { [timer invalidate]; _fadeTimer = nil; } } -- (void)closeSplashWindow -{ +- (void)closeSplashWindow { if (_fadeTimer) { [_fadeTimer invalidate]; } _fadeTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / 30.0) target:self selector:@selector(closeStep:) userInfo:nil repeats:YES]; } -- (void)closeStep:(NSTimer *)timer -{ - [_window setAlphaValue:[_window alphaValue] - 0.05]; +- (void)closeStep:(NSTimer *)timer { + [_window setAlphaValue:([_window alphaValue] - 0.05)]; if ([_window alphaValue] <= 0.0) { [timer invalidate]; _fadeTimer = nil; diff --git a/ITSplashView.h b/ITSplashView.h index 359bd3c..03ea722 100644 --- a/ITSplashView.h +++ b/ITSplashView.h @@ -1,19 +1,22 @@ -// -// ITSplashView.h -// SplashScreen -// -// Created by Kent Sutherland on 11/22/04. -// Copyright 2004 __MyCompanyName__. All rights reserved. -// +/* + * ITKit + * ITSplashView.h + * + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ + * + */ #import -@interface ITSplashView : NSView -{ +@interface ITSplashView : NSView { NSImage *_image; NSProgressIndicator *_progress; NSTextField *_text; } + - (void)stopAnimation; - (NSProgressIndicator *)progressIndicator; - (NSImage *)image; @@ -21,4 +24,5 @@ - (void)setImage:(NSImage *)image; - (void)setString:(NSString *)text; - (void)loadControlsFromPath:(NSString *)path; -@end + +@end \ No newline at end of file diff --git a/ITSplashView.m b/ITSplashView.m index 5c90f53..d400a13 100644 --- a/ITSplashView.m +++ b/ITSplashView.m @@ -1,73 +1,48 @@ -// -// ITSplashView.m -// SplashScreen -// -// Created by Kent Sutherland on 11/22/04. -// Copyright 2004 __MyCompanyName__. All rights reserved. -// - #import "ITSplashView.h" @implementation ITSplashView -- (id)initWithFrame:(NSRect)frame -{ - if ( (self = [super initWithFrame:frame]) ) { - } - return self; -} - -- (void)dealloc -{ +- (void)dealloc { [_image release]; [_progress release]; [_text release]; [super dealloc]; } -- (void)drawRect:(NSRect)rect -{ +- (void)drawRect:(NSRect)rect { [_image compositeToPoint:NSZeroPoint operation:NSCompositeSourceOver]; } -- (BOOL)isOpaque -{ +- (BOOL)isOpaque { return NO; } -- (void)stopAnimation -{ +- (void)stopAnimation { [_progress stopAnimation:nil]; } -- (NSProgressIndicator *)progressIndicator -{ +- (NSProgressIndicator *)progressIndicator { return _progress; } -- (NSImage *)image -{ +- (NSImage *)image { return _image; } -- (NSString *)string -{ +- (NSString *)string { return [_text stringValue]; } -- (void)setImage:(NSImage *)image -{ +- (void)setImage:(NSImage *)image { [_image autorelease]; _image = [image retain]; } -- (void)setString:(NSString *)text -{ +- (void)setString:(NSString *)text { [_text setStringValue:text]; } -- (void)loadControlsFromPath:(NSString *)path -{ +- (void)loadControlsFromPath:(NSString *)path { [_progress removeFromSuperview]; [_progress release]; [_text removeFromSuperview]; @@ -79,14 +54,14 @@ switch (height) { /*case NSProgressIndicatorPreferredSmallThickness: size = NSMiniControlSize; - break;*/ + break;*/ case NSProgressIndicatorPreferredAquaThickness: size = NSSmallControlSize; - break; + break; case NSProgressIndicatorPreferredThickness: default: size = NSRegularControlSize; - break; + break; } if ([[settings objectForKey:@"ProgressIndicator.style"] intValue] == 0) { //We have a normal bar @@ -115,4 +90,4 @@ [settings release]; } -@end +@end \ No newline at end of file diff --git a/ITSplashWindow.h b/ITSplashWindow.h index 48c17e2..d959a7a 100644 --- a/ITSplashWindow.h +++ b/ITSplashWindow.h @@ -1,8 +1,18 @@ -/* ITSplashWindow */ +/* + * ITKit + * ITSplashWindow.h + * + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ + * + */ #import -@interface ITSplashWindow : NSWindow -{ +@interface ITSplashWindow : NSWindow { + } -@end + +@end \ No newline at end of file diff --git a/ITSplashWindow.m b/ITSplashWindow.m index a41d7e1..63d6923 100644 --- a/ITSplashWindow.m +++ b/ITSplashWindow.m @@ -3,9 +3,8 @@ @implementation ITSplashWindow -- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag -{ - if ( (self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]) ) { +- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag { + if ((self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO])) { [self setOpaque:NO]; [self setBackgroundColor:[NSColor clearColor]]; [self setHasShadow:YES]; @@ -13,14 +12,12 @@ return self; } -- (BOOL)canBecomeKeyWindow -{ +- (BOOL)canBecomeKeyWindow { return YES; } -- (BOOL)isKeyWindow -{ +- (BOOL)isKeyWindow { return YES; } -@end +@end \ No newline at end of file diff --git a/ITStatusItem.h b/ITStatusItem.h old mode 100755 new mode 100644 index fb381e0..f2f6070 --- a/ITStatusItem.h +++ b/ITStatusItem.h @@ -1,49 +1,26 @@ /* * ITKit - * ITStatusItem - * NSStatusItem subclass which reduces suckage + * ITStatusItem.h * - * Original Author : Joseph Spiros - * Original Author : Matthew Judy - * Responsibility : Matthew Judy - * Responsibility : Joseph Spiros + * NSStatusItem subclass which attempts to approximate NSMenuExtra's + * appearance and functionality. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by 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. + * $Id$ * */ - #import +@interface ITStatusItem : NSStatusItem { -@interface ITStatusItem : NSStatusItem -{ } -// Use this to create a new retained status item. -// It will appear in the system status bar, and -// default to YES for its highlightMode. -- (id)initWithStatusBar:(NSStatusBar*)statusBar withLength:(float)length; - -// These allow you to use an alternate (selected) image for your status item. -- (NSImage*) alternateImage; -- (void) setAlternateImage:(NSImage*)image; +- (id)initWithStatusBar:(NSStatusBar *)statusBar withLength:(float)length; +- (NSImage *)alternateImage; +- (void)setAlternateImage:(NSImage *)image; -@end +@end \ No newline at end of file diff --git a/ITStatusItem.m b/ITStatusItem.m old mode 100755 new mode 100644 index bf1d18f..b758d5c --- a/ITStatusItem.m +++ b/ITStatusItem.m @@ -1,98 +1,54 @@ #import "ITStatusItem.h" -/*************************************************************************/ -#pragma mark - -#pragma mark EVIL HACKERY -/*************************************************************************/ +@class NSStatusBarButton; -// This stuff is actually implemented by the AppKit. -// We declare it here to cancel out warnings. - -@interface NSStatusBarButton : NSButton +@interface NSStatusItem (ITStatusItemHacks) +- (id)_initInStatusBar:(NSStatusBar *)statusBar withLength:(float)length withPriority:(int)priority; +- (NSStatusBarButton *)_button; @end -@interface NSStatusItem (HACKHACKHACKHACK) -- (id)_initInStatusBar:(NSStatusBar*)statusBar - withLength:(float)length - withPriority:(int)priority; -- (NSStatusBarButton*)_button; +@protocol _ITStatusItemNSStatusItemPantherCompatability +- (void)setAlternateImage:(NSImage *)image; +- (NSImage *)alternateImage; @end +@implementation ITStatusItem -/*************************************************************************/ -#pragma mark - -#pragma mark PRIVATE METHOD DECLARATIONS -/*************************************************************************/ - -@interface ITStatusItem (Private) -- (void)setImage:(NSImage*)image; -- (NSString*) title; -- (void)setTitle:(NSString*)title; -- (void)setSmallTitle:(NSString*)title; -@end - +static BOOL _ITStatusItemShouldKillShadow = NO; -@implementation ITStatusItem ++ (void)initialize { + if ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_1) && (floor(NSAppKitVersionNumber) <= 663.6)) { + _ITStatusItemShouldKillShadow = YES; + } +} -/*************************************************************************/ -#pragma mark - -#pragma mark INITIALIZATION METHODS -/*************************************************************************/ +- (id)initWithStatusBar:(NSStatusBar *)statusBar withLength:(float)length { + return [self _initInStatusBar:statusBar withLength:length withPriority:1000]; +} -- (id)initWithStatusBar:(NSStatusBar*)statusBar withLength:(float)length -{ - if ( ( self = [super _initInStatusBar:statusBar - withLength:length - withPriority:1000] ) ) { - - //Eliminate the fucking shadow... - [[[self _button] cell] setType:NSNullCellType]; - - //Be something other than a dumbshit about highlighting... +- (id)_initInStatusBar:(NSStatusBar *)statusBar withLength:(float)length withPriority:(int)priority { + if ((self = [super _initInStatusBar:statusBar withLength:length withPriority:priority])) { + if (_ITStatusItemShouldKillShadow) { + [[(NSButton *)[self _button] cell] setType:NSNullCellType]; + } [self setHighlightMode:YES]; } return self; } - -/*************************************************************************/ -#pragma mark - -#pragma mark ACCESSOR METHODS -/*************************************************************************/ - -- (NSImage*)alternateImage { - return [[self _button] alternateImage]; +- (NSImage *)alternateImage { + if ([super respondsToSelector:@selector(alternateImage)]) { + return [(id <_ITStatusItemNSStatusItemPantherCompatability>)super alternateImage]; + } + return [(NSButton *)[self _button] alternateImage]; } - (void)setAlternateImage:(NSImage*)image { - [[self _button] setAlternateImage:image]; + if ([super respondsToSelector:@selector(setAlternateImage:)]) { + [(id <_ITStatusItemNSStatusItemPantherCompatability>)super setAlternateImage:image]; + return; + } + [(NSButton *)[self _button] setAlternateImage:image]; } -- (void)setImage:(NSImage*)image { - [super setImage:image]; - if ( [self title] ) { - [self setTitle:[self title]]; - } -} - -- (void)setTitle:(NSString*)title { - if ( [self image] && (title != nil) ) { - [self setSmallTitle:title]; - } else { - [super setTitle:title]; - } -} - - -/*************************************************************************/ -#pragma mark - -#pragma mark PRIVATE METHODS -/*************************************************************************/ - -- (void)setSmallTitle:(NSString*)title { - NSAttributedString *attrTitle = [[[NSAttributedString alloc] initWithString:title attributes:[NSDictionary dictionaryWithObject:[NSFont fontWithName:@"LucidaGrande" size:12.0] forKey:NSFontAttributeName]] autorelease]; - [self setAttributedTitle:attrTitle]; -} - - -@end +@end \ No newline at end of file diff --git a/ITStringMacResource.h b/ITStringMacResource.h deleted file mode 100755 index 096d941..0000000 --- a/ITStringMacResource.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// ITStringMacResource.h -// ITKit -// -// Created by Joseph Spiros on Thu Dec 25 2003. -// Copyright (c) 2003 __MyCompanyName__. All rights reserved. -// - -#import -#import "ITMacResource.h" - -@interface ITStringMacResource : ITMacResource { - -} - -@end diff --git a/ITStringMacResource.m b/ITStringMacResource.m deleted file mode 100755 index 3cc887b..0000000 --- a/ITStringMacResource.m +++ /dev/null @@ -1,26 +0,0 @@ -// -// ITStringMacResource.m -// ITKit -// -// Created by Joseph Spiros on Thu Dec 25 2003. -// Copyright (c) 2003 __MyCompanyName__. All rights reserved. -// - -#import "ITStringMacResource.h" - - -@implementation ITStringMacResource - -+ (void)load { - [ITMacResource _registerClass:self forType:'STR ']; -} - -- (Class)nativeRepresentationClass { - return [NSString class]; -} - -- (id)nativeRepresentation { - return @"Not Implemented Yet"; -} - -@end diff --git a/ITTSWBackgroundView.h b/ITTSWBackgroundView.h old mode 100755 new mode 100644 index 129eb03..ad1d854 --- a/ITTSWBackgroundView.h +++ b/ITTSWBackgroundView.h @@ -1,30 +1,28 @@ /* * ITKit - * ITTSWBackgroundView - * NSView subclass which draws a translucent background with rounded corners. + * ITTSWBackgroundView.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy + * NSView subclass which draws a translucent background with rounded corners. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ #import - typedef enum _ITTSWBackgroundMode { ITTSWBackgroundApple, ITTSWBackgroundReadable, ITTSWBackgroundColored } ITTSWBackgroundMode; - @interface ITTSWBackgroundView : NSView { - NSBezierPath *_path; - NSColor *_color; - ITTSWBackgroundMode _mode; + NSBezierPath *_path; + NSColor *_color; + ITTSWBackgroundMode _mode; } - (ITTSWBackgroundMode)backgroundMode; @@ -33,4 +31,4 @@ typedef enum _ITTSWBackgroundMode { - (NSColor *)backgroundColor; - (void)setBackgroundColor:(NSColor *)newColor; -@end +@end \ No newline at end of file diff --git a/ITTSWBackgroundView.m b/ITTSWBackgroundView.m old mode 100755 new mode 100644 diff --git a/ITTabView.h b/ITTabView.h old mode 100755 new mode 100644 index 89b5fef..36d1ca6 --- a/ITTabView.h +++ b/ITTabView.h @@ -1,39 +1,30 @@ /* * ITKit - * ITTabView - * NSTabView subclass which includes convenience features + * ITTabView.h * - * Original Author : Kent Sutherland - * Responsibility : Matthew Judy - * Responsibility : Kent Sutherland + * NSTabView subclass which allows dragging (reordering) of tab view items. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ -/* - * This subclass enables drag-and-drop for tab view items. - */ - - #import - -@interface ITTabView : NSTabView -{ - NSTabViewItem *_draggedTab; - bool _allowsDragging; - unsigned int _requiredModifiers; +@interface ITTabView : NSTabView { + NSTabViewItem *_draggedTab; + BOOL _allowsDragging; + unsigned int _requiredModifiers; } -- (void)setAllowsDragging:(bool)flag; -- (bool)allowsDragging; +- (void)setAllowsDragging:(BOOL)flag; +- (BOOL)allowsDragging; - (void)setRequiredModifiers:(unsigned int)modifiers; - (unsigned int)requiredModifiers; - (void)moveTab:(NSTabViewItem *)tab toIndex:(int)index; - -@end +@end \ No newline at end of file diff --git a/ITTabView.m b/ITTabView.m old mode 100755 new mode 100644 index 66f0bcc..a94825a --- a/ITTabView.m +++ b/ITTabView.m @@ -1,95 +1,79 @@ #import "ITTabView.h" -/*************************************************************************/ -#pragma mark - -#pragma mark EVIL HACKERY -/*************************************************************************/ - -@interface NSTabViewItem (HACKHACKHACKHACK) +@interface NSTabViewItem (ITTabViewHacks) - (NSRect)_tabRect; @end - @implementation ITTabView -- (id)initWithFrame:(NSRect)frame -{ - if ( (self = [super initWithFrame:frame]) ) { - _draggedTab = nil; - _allowsDragging = NO; - _requiredModifiers = NSCommandKeyMask; - } - return self; +- (id)initWithFrame:(NSRect)frame { + if ((self = [super initWithFrame:frame])) { + _draggedTab = nil; + _allowsDragging = NO; + _requiredModifiers = NSCommandKeyMask; + } + return self; } -- (void)setAllowsDragging:(bool)flag -{ - _allowsDragging = flag; - _requiredModifiers = NSCommandKeyMask; +- (void)setAllowsDragging:(BOOL)flag { + _allowsDragging = flag; } -- (bool)allowsDragging -{ - return _allowsDragging; +- (BOOL)allowsDragging { + return _allowsDragging; } -- (void)setRequiredModifiers:(unsigned int)modifiers -{ - _requiredModifiers = modifiers; +- (void)setRequiredModifiers:(unsigned int)modifiers { + _requiredModifiers = modifiers; } -- (unsigned int)requiredModifiers -{ - return _requiredModifiers; +- (unsigned int)requiredModifiers { + return _requiredModifiers; } -- (void)moveTab:(NSTabViewItem *)tab toIndex:(int)index -{ - if ([self indexOfTabViewItem:tab] != index) - { - [tab retain]; - [self removeTabViewItem:tab]; - [self insertTabViewItem:tab atIndex:index]; - [self selectTabViewItem:tab]; - } +- (void)moveTab:(NSTabViewItem *)tab toIndex:(int)index { + int oldIndex = [self indexOfTabViewItem:tab]; + if ((oldIndex != NSNotFound) && (oldIndex != index)) { + [tab retain]; + [self removeTabViewItem:tab]; + [self insertTabViewItem:tab atIndex:index]; + [self selectTabViewItem:tab]; + [tab release]; + } } -- (void)mouseDown:(NSEvent *)event -{ - if ((_requiredModifiers == 0 || ([[NSApp currentEvent] modifierFlags] & _requiredModifiers)) && [self allowsDragging]) { - NSPoint clickedPoint; - clickedPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]]; - NSTabViewItem *clickedTab = [self tabViewItemAtPoint:clickedPoint]; - _draggedTab = clickedTab; - } - [super mouseDown:event]; +- (void)mouseDown:(NSEvent *)event { + if ((_requiredModifiers == 0 || ([[NSApp currentEvent] modifierFlags] & _requiredModifiers)) && [self allowsDragging]) { + NSPoint clickedPoint; + clickedPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]]; + NSTabViewItem *clickedTab = [self tabViewItemAtPoint:clickedPoint]; + _draggedTab = clickedTab; + } + [super mouseDown:event]; } -- (void)mouseUp:(NSEvent *)event -{ - if (_draggedTab && [self allowsDragging]) { - NSPoint releasedPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]]; - NSTabViewItem *releasedTab = [self tabViewItemAtPoint:releasedPoint]; - if (releasedTab && ![releasedTab isEqualTo:_draggedTab]) { - [self moveTab:_draggedTab toIndex:[self indexOfTabViewItem:releasedTab]]; - } - _draggedTab = nil; - } - [super mouseUp:event]; +- (void)mouseUp:(NSEvent *)event { + if (_draggedTab && [self allowsDragging]) { + NSPoint releasedPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]]; + NSTabViewItem *releasedTab = [self tabViewItemAtPoint:releasedPoint]; + if (releasedTab && ![releasedTab isEqualTo:_draggedTab]) { + [self moveTab:_draggedTab toIndex:[self indexOfTabViewItem:releasedTab]]; + } + _draggedTab = nil; + } + [super mouseUp:event]; } -- (void)mouseDragged:(NSEvent *)event -{ - if (_draggedTab && [self allowsDragging]) { - NSPoint currentPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]]; - NSTabViewItem *curTab = [self tabViewItemAtPoint:currentPoint]; - if (curTab && ![curTab isEqualTo:_draggedTab]) { - [self moveTab:_draggedTab toIndex:[self indexOfTabViewItem:curTab]]; - [self selectTabViewItem:_draggedTab]; - } - } - [super mouseDragged:event]; +- (void)mouseDragged:(NSEvent *)event { + if (_draggedTab && [self allowsDragging]) { + NSPoint currentPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]]; + NSTabViewItem *curTab = [self tabViewItemAtPoint:currentPoint]; + if (curTab && ![curTab isEqualTo:_draggedTab]) { + [self moveTab:_draggedTab toIndex:[self indexOfTabViewItem:curTab]]; + [self selectTabViewItem:_draggedTab]; + } + } + [super mouseDragged:event]; } - -@end +@end \ No newline at end of file diff --git a/ITTableCornerView.h b/ITTableCornerView.h old mode 100755 new mode 100644 index b9a3577..a0a24fe --- a/ITTableCornerView.h +++ b/ITTableCornerView.h @@ -1,22 +1,21 @@ /* * ITKit - * ITTableCornerView - * NSPopUpButton subclass for corner views in a table view. + * ITTableCornerView.h * - * Original Author : Joseph Spiros - * Responsibility : Matthew Judy - * Responsibility : Joseph Spiros + * NSPopUpButton subclass for use as a cornerView in NSTableView instances. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - #import @interface ITTableCornerView : NSPopUpButton { - NSTableHeaderCell *headerCell; + NSImage *image; + NSTableHeaderCell *headerCell; } -@end +@end \ No newline at end of file diff --git a/ITTableCornerView.m b/ITTableCornerView.m old mode 100755 new mode 100644 index 4f90316..2f231d2 --- a/ITTableCornerView.m +++ b/ITTableCornerView.m @@ -1,31 +1,57 @@ #import "ITTableCornerView.h" +@interface ITTableCornerView (Private) + +- (id)initWithFrame:(NSRect)frame cellClass:(Class)cellClass; + +@end + @implementation ITTableCornerView - (id)initWithFrame:(NSRect)frame { - self = [super initWithFrame:frame]; - if (self) { - headerCell = [[NSTableHeaderCell alloc] init]; - } - return self; + return [self initWithFrame:frame cellClass:[NSTableHeaderCell class]]; +} + +- (id)initWithFrame:(NSRect)frame cellClass:(Class)cellClass { + if ((self = [super initWithFrame:frame])) { + headerCell = [[cellClass alloc] init]; + [self setPullsDown:YES]; + } + 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]; - } + NSImage *drawImage; + + 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 ((drawImage = [self image])) { + BOOL oldFlipped = [drawImage isFlipped]; + [drawImage setFlipped:YES]; + [drawImage drawAtPoint:rect.origin fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; + [drawImage setFlipped:oldFlipped]; + } +} + +- (void)setImage:(NSImage *)anImage { + [super setImage:anImage]; + [image autorelease]; + image = [anImage copy]; +} + +- (NSImage *)image { + return (image ? image : [super image]); } - (void)dealloc { - [headerCell release]; - [super dealloc]; + [image release]; + [headerCell release]; + [super dealloc]; } @end \ No newline at end of file diff --git a/ITTableView.h b/ITTableView.h old mode 100755 new mode 100644 index 66444e8..1950715 --- a/ITTableView.h +++ b/ITTableView.h @@ -1,24 +1,22 @@ /* * ITKit - * ITTableView - * NSTableView subclass with easy to use accessors for adding a menu - * (with optional image) to the corner view of the TableView. + * ITTableCornerView.h * - * Original Author : Joseph Spiros - * Responsibility : Matthew Judy - * Responsibility : Joseph Spiros + * NSTableView subclass that uses an ITTableCornerView as its default + * cornerView and provides easy to use accessors to the features + * provided by ITTableCornerView when it is being used. * - * Copyright (c) 2002-2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ #import -@class ITTableCornerView; - @interface ITTableView : NSTableView { - ITTableCornerView *corner; + } - (void)setCornerImage:(NSImage*)image; @@ -26,4 +24,4 @@ - (void)setCornerMenu:(NSMenu*)menu; - (NSMenu*)cornerMenu; -@end +@end \ No newline at end of file diff --git a/ITTableView.m b/ITTableView.m old mode 100755 new mode 100644 index 7cba72b..829b039 --- a/ITTableView.m +++ b/ITTableView.m @@ -1,47 +1,50 @@ #import "ITTableView.h" #import "ITTableCornerView.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; + if ((self = [super initWithFrame:frame])) { + [self setCornerView:[[ITTableCornerView alloc] initWithFrame:[[self cornerView] frame]]]; + } + 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; +- (id)initWithCoder:(NSCoder *)coder { + if ((self = [super initWithCoder:coder])) { + [self setCornerView:[[ITTableCornerView alloc] initWithFrame:[[self cornerView] frame]]]; + } + return self; } -- (void)encodeWithCoder:(NSCoder*)coder { - [super encodeWithCoder:coder]; +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; } -- (void)setCornerImage:(NSImage*)image { - [corner setImage:image]; +- (void)setCornerImage:(NSImage *)image { + if ([_cornerView isKindOfClass:[ITTableCornerView class]]) { + [(ITTableCornerView *)_cornerView setImage:image]; + } } -- (NSImage*)cornerImage { - return [corner image]; +- (NSImage *)cornerImage { + if ([_cornerView isKindOfClass:[ITTableCornerView class]]) { + return [(ITTableCornerView *)_cornerView image]; + } + return nil; } -- (void)setCornerMenu:(NSMenu*)menu { - [corner setMenu:menu]; +- (void)setCornerMenu:(NSMenu *)menu { + if ([_cornerView isKindOfClass:[ITTableCornerView class]]) { + [(ITTableCornerView *)_cornerView setMenu:menu]; + } } -- (NSMenu*)cornerMenu { - return [corner menu]; +- (NSMenu *)cornerMenu { + if ([_cornerView isKindOfClass:[ITTableCornerView class]]) { + return [(ITTableCornerView *)_cornerView menu]; + } + return nil; } -@end +@end \ No newline at end of file diff --git a/ITTextField.h b/ITTextField.h old mode 100755 new mode 100644 index d796245..9e73b1c --- a/ITTextField.h +++ b/ITTextField.h @@ -1,21 +1,18 @@ /* * ITKit - * ITTextField - * Allows shadows to be drawn under text. + * ITTextField.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy - * Responsibility : Joseph Spiros + * Custom NSTextField subclass that uses ITTextFieldCell. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - #import - @interface ITTextField : NSTextField { } @@ -23,23 +20,22 @@ - (BOOL)castsShadow; - (void)setCastsShadow:(BOOL)newSetting; -- (float)shadowElevation; /* Light source elevation in degrees. Defaults to 45.0 */ +- (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 */ +- (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 */ +- (float)shadowAmbient; /* Amount of ambient light. Defaults to 0.15 */ - (void)setShadowAmbient:(float)newAmbient; -- (float)shadowHeight; /* Height above the canvas. Defaults to 1.0 */ +- (float)shadowHeight; /* Height above the canvas. Defaults to 1.0 */ - (void)setShadowHeight:(float)newHeight; -- (float)shadowRadius; /* Blur radius. Defaults to 4.0 */ +- (float)shadowRadius; /* Blur radius. Defaults to 4.0 */ - (void)setShadowRadius:(float)newRadius; -- (float)shadowSaturation; /* Maximum saturation. Defaults to 1.0 */ +- (float)shadowSaturation; /* Maximum saturation. Defaults to 1.0 */ - (void)setShadowSaturation:(float)newSaturation; - -@end +@end \ No newline at end of file diff --git a/ITTextField.m b/ITTextField.m old mode 100755 new mode 100644 index 3ccab70..841d6c8 --- a/ITTextField.m +++ b/ITTextField.m @@ -1,109 +1,72 @@ #import "ITTextField.h" #import "ITTextFieldCell.h" -#import -#import "ITCoreGraphicsHacks.h" - - -/*************************************************************************/ -#pragma mark - -#pragma mark IMPLEMENTATION -/*************************************************************************/ @implementation ITTextField - -/*************************************************************************/ -#pragma mark - -#pragma mark INITIALIZATION METHODS -/*************************************************************************/ - -+ (void)initialize -{ - if ( self == [ITTextField class] ) { - [self setCellClass:[ITTextFieldCell class]]; - } ++ (void)initialize { + if (self == [ITTextField class]) { + [self setCellClass:[ITTextFieldCell class]]; + } } -+ (Class)cellClass -{ - return [ITTextFieldCell class]; ++ (Class)cellClass { + return [ITTextFieldCell class]; } - -/*************************************************************************/ -#pragma mark - -#pragma mark ACCESSOR METHODS -/*************************************************************************/ - -- (BOOL)castsShadow; -{ - return [[self cell] castsShadow]; +- (BOOL)castsShadow { + return [[self cell] castsShadow]; } -- (void)setCastsShadow:(BOOL)newSetting; -{ - [[self cell] setCastsShadow:newSetting]; +- (void)setCastsShadow:(BOOL)newSetting { + [[self cell] setCastsShadow:newSetting]; } -- (float)shadowElevation; -{ - return [[self cell] shadowElevation]; +- (float)shadowElevation { + return [[self cell] shadowElevation]; } -- (void)setShadowElevation:(float)newElevation; -{ - [[self cell] setShadowElevation:newElevation]; +- (void)setShadowElevation:(float)newElevation { + [[self cell] setShadowElevation:newElevation]; } -- (float)shadowAzimuth; -{ - return [[self cell] shadowAzimuth]; +- (float)shadowAzimuth { + return [[self cell] shadowAzimuth]; } -- (void)setShadowAzimuth:(float)newAzimuth; -{ - [[self cell] setShadowAzimuth:newAzimuth]; +- (void)setShadowAzimuth:(float)newAzimuth { + [[self cell] setShadowAzimuth:newAzimuth]; } -- (float)shadowAmbient; -{ - return [[self cell] shadowAmbient]; +- (float)shadowAmbient { + return [[self cell] shadowAmbient]; } -- (void)setShadowAmbient:(float)newAmbient; -{ - [[self cell] setShadowAmbient:newAmbient]; +- (void)setShadowAmbient:(float)newAmbient { + [[self cell] setShadowAmbient:newAmbient]; } -- (float)shadowHeight; -{ - return [[self cell] shadowHeight]; +- (float)shadowHeight { + return [[self cell] shadowHeight]; } -- (void)setShadowHeight:(float)newHeight; -{ - [[self cell] setShadowHeight:newHeight]; +- (void)setShadowHeight:(float)newHeight { + [[self cell] setShadowHeight:newHeight]; } -- (float)shadowRadius; -{ - return [[self cell] shadowRadius]; +- (float)shadowRadius { + return [[self cell] shadowRadius]; } -- (void)setShadowRadius:(float)newRadius; -{ - [[self cell] setShadowRadius:newRadius]; +- (void)setShadowRadius:(float)newRadius { + [[self cell] setShadowRadius:newRadius]; } -- (float)shadowSaturation; -{ - return [[self cell] shadowSaturation]; +- (float)shadowSaturation { + return [[self cell] shadowSaturation]; } -- (void)setShadowSaturation:(float)newSaturation; -{ - [[self cell] setShadowSaturation:newSaturation]; +- (void)setShadowSaturation:(float)newSaturation { + [[self cell] setShadowSaturation:newSaturation]; } - -@end +@end \ No newline at end of file diff --git a/ITTextFieldCell.h b/ITTextFieldCell.h old mode 100755 new mode 100644 index 5285faf..401e599 --- a/ITTextFieldCell.h +++ b/ITTextFieldCell.h @@ -1,54 +1,49 @@ /* * ITKit - * ITTextFieldCell - * Cell used by the ITTextField control. + * ITTextFieldCell.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy - * Responsibility : Joseph Spiros + * Custom NSTextFieldCell subclass that casts a shadow using CoreGraphics, + * providing support for versions of Cocoa that don't have the NSShadow + * class which was introduced in Mac OS X 10.3 (Panther). * - * Copyright (c) 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - #import - @interface ITTextFieldCell : NSTextFieldCell { - - BOOL castsShadow; - - float shadowElevation; - float shadowAzimuth; - float shadowAmbient; - float shadowHeight; - float shadowRadius; - float shadowSaturation; - + 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 */ +- (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 */ +- (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 */ +- (float)shadowAmbient; /* Amount of ambient light. Defaults to 0.15 */ - (void)setShadowAmbient:(float)newAmbient; -- (float)shadowHeight; /* Height above the canvas. Defaults to 1.0 */ +- (float)shadowHeight; /* Height above the canvas. Defaults to 1.0 */ - (void)setShadowHeight:(float)newHeight; -- (float)shadowRadius; /* Blur radius. Defaults to 4.0 */ +- (float)shadowRadius; /* Blur radius. Defaults to 4.0 */ - (void)setShadowRadius:(float)newRadius; -- (float)shadowSaturation; /* Maximum saturation. Defaults to 1.0 */ +- (float)shadowSaturation; /* Maximum saturation. Defaults to 1.0 */ - (void)setShadowSaturation:(float)newSaturation; - -@end +@end \ No newline at end of file diff --git a/ITTextFieldCell.m b/ITTextFieldCell.m old mode 100755 new mode 100644 index aeb6ca7..2dbc30c --- a/ITTextFieldCell.m +++ b/ITTextFieldCell.m @@ -1,171 +1,126 @@ #import "ITTextFieldCell.h" -#import #import "ITCoreGraphicsHacks.h" - - -/*************************************************************************/ -#pragma mark - -#pragma mark IMPLEMENTATION -/*************************************************************************/ +#import @implementation ITTextFieldCell -/*************************************************************************/ -#pragma mark - -#pragma mark INITIALIZATION METHODS -/*************************************************************************/ - -- (id)initTextCell:(NSString *)string -{ - if ( ( self = [super initTextCell:string] ) ) { - castsShadow = NO; - shadowElevation = 45.0; - shadowAzimuth = 90.0; - shadowAmbient = 0.15; - shadowHeight = 1.00; - shadowRadius = 4.00; - shadowSaturation = 1.0; - } - - return self; +- (id)initTextCell:(NSString *)string { + if ((self = [super initTextCell:string])) { + 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; +- (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)drawWithFrame:(NSRect)rect inView:(NSView *)controlView -{ - 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 drawWithFrame:rect inView:controlView]; - - - if ( castsShadow ) { - // Restore the old context - [NSGraphicsContext restoreGraphicsState]; - CGStyleRelease(style); - } +- (void)drawWithFrame:(NSRect)rect inView:(NSView *)controlView { + 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 drawWithFrame:rect inView:controlView]; + + if (castsShadow) { + // Restore the old context + [NSGraphicsContext restoreGraphicsState]; + CGStyleRelease(style); + } } - - -/*************************************************************************/ -#pragma mark - -#pragma mark ACCESSOR METHODS -/*************************************************************************/ - -- (BOOL)castsShadow; -{ - return castsShadow; +- (BOOL)castsShadow { + return castsShadow; } -- (void)setCastsShadow:(BOOL)newSetting; -{ - castsShadow = newSetting; - [[self controlView] setNeedsDisplay:YES]; +- (void)setCastsShadow:(BOOL)newSetting { + castsShadow = newSetting; + [[self controlView] setNeedsDisplay:YES]; } -- (float)shadowElevation; -{ - return shadowElevation; +- (float)shadowElevation { + return shadowElevation; } -- (void)setShadowElevation:(float)newElevation; -{ - shadowElevation = newElevation; - [[self controlView] setNeedsDisplay:YES]; +- (void)setShadowElevation:(float)newElevation { + shadowElevation = newElevation; + [[self controlView] setNeedsDisplay:YES]; } -- (float)shadowAzimuth; -{ - return shadowAzimuth; +- (float)shadowAzimuth { + return shadowAzimuth; } -- (void)setShadowAzimuth:(float)newAzimuth; -{ - shadowAzimuth = newAzimuth; - [[self controlView] setNeedsDisplay:YES]; +- (void)setShadowAzimuth:(float)newAzimuth { + shadowAzimuth = newAzimuth; + [[self controlView] setNeedsDisplay:YES]; } -- (float)shadowAmbient; -{ - return shadowAmbient; +- (float)shadowAmbient { + return shadowAmbient; } -- (void)setShadowAmbient:(float)newAmbient; -{ - shadowAmbient = newAmbient; - [[self controlView] setNeedsDisplay:YES]; +- (void)setShadowAmbient:(float)newAmbient { + shadowAmbient = newAmbient; + [[self controlView] setNeedsDisplay:YES]; } -- (float)shadowHeight; -{ - return shadowHeight; +- (float)shadowHeight { + return shadowHeight; } -- (void)setShadowHeight:(float)newHeight; -{ - shadowHeight = newHeight; - [[self controlView] setNeedsDisplay:YES]; +- (void)setShadowHeight:(float)newHeight { + shadowHeight = newHeight; + [[self controlView] setNeedsDisplay:YES]; } -- (float)shadowRadius; -{ - return shadowRadius; +- (float)shadowRadius { + return shadowRadius; } -- (void)setShadowRadius:(float)newRadius; -{ - shadowRadius = newRadius; - [[self controlView] setNeedsDisplay:YES]; +- (void)setShadowRadius:(float)newRadius { + shadowRadius = newRadius; + [[self controlView] setNeedsDisplay:YES]; } -- (float)shadowSaturation; -{ - return shadowSaturation; +- (float)shadowSaturation { + return shadowSaturation; } -- (void)setShadowSaturation:(float)newSaturation; -{ - shadowSaturation = newSaturation; - [[self controlView] setNeedsDisplay:YES]; +- (void)setShadowSaturation:(float)newSaturation { + shadowSaturation = newSaturation; + [[self controlView] setNeedsDisplay:YES]; } - -@end +@end \ No newline at end of file diff --git a/ITTransientStatusWindow.h b/ITTransientStatusWindow.h old mode 100755 new mode 100644 index c93f0a6..6118ecc --- a/ITTransientStatusWindow.h +++ b/ITTransientStatusWindow.h @@ -1,38 +1,31 @@ /* * ITKit - * ITTransientStatusWindow - * NSWindow subclass for quick display of status information. - * Similar to volume/brightness/eject bezel key windows. + * ITTransientStatusWindow.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy - * Responsibility : Joseph Spiros - * Contributor : Kent Sutherland + * NSWindow subclass for quick display of status information, similar to + * volume/brightness/eject bezel key windows. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - #import #import "ITWindowPositioning.h" #import "ITWindowEffect.h" -#define DEFAULT_EXIT_DELAY 3.0 - +#define DEFAULT_EXIT_DELAY 3.0 @class ITTextField; @class ITGrayRoundedView; -@class ITWindowEffect; - typedef enum { ITTransientStatusWindowExitOnCommand, - ITTransientStatusWindowExitAfterDelay, + ITTransientStatusWindowExitAfterDelay } ITTransientStatusWindowExitMode; - typedef enum { ITTransientStatusWindowNoBackground, ITTransientStatusWindowRounded, @@ -48,40 +41,31 @@ typedef enum { ITTransientStatusWindowMini } ITTransientStatusWindowSizing; -@interface ITTransientStatusWindow : NSWindow { - - ITWindowVisibilityState _visibilityState; - ITTransientStatusWindowExitMode _exitMode; - float _exitDelay; - ITTransientStatusWindowBackgroundType _backgroundType; - ITWindowEffect *_entryEffect; - ITWindowEffect *_exitEffect; - double _effectProgress; - ITVerticalWindowPosition _verticalPosition; - ITHorizontalWindowPosition _horizontalPosition; - ITTransientStatusWindowSizing _sizing; - float _screenPadding; -// int _screenNumber; +@interface ITTransientStatusWindow : NSWindow { + ITWindowVisibilityState _visibilityState; + ITTransientStatusWindowExitMode _exitMode; + float _exitDelay; + ITTransientStatusWindowBackgroundType _backgroundType; + ITWindowEffect *_entryEffect; + ITWindowEffect *_exitEffect; + double _effectProgress; + ITVerticalWindowPosition _verticalPosition; + ITHorizontalWindowPosition _horizontalPosition; + ITTransientStatusWindowSizing _sizing; + float _screenPadding; NSScreen *_screen; - - BOOL _reallyIgnoresEvents; - - NSTimer *_exitTimer; - - NSView *_contentSubView; + BOOL _reallyIgnoresEvents; + NSTimer *_exitTimer; + NSView *_contentSubView; } + (id)sharedWindow; -- (id)initWithContentView:(NSView *)contentView - exitMode:(ITTransientStatusWindowExitMode)exitMode - backgroundType:(ITTransientStatusWindowBackgroundType)backgroundType; +- (id)initWithContentView:(NSView *)contentView exitMode:(ITTransientStatusWindowExitMode)exitMode backgroundType:(ITTransientStatusWindowBackgroundType)backgroundType; - (void)appear:(id)sender; - (void)vanish:(id)sender; -- (void)setScreen:(NSScreen *)newScreen; - - (void)setSizing:(ITTransientStatusWindowSizing)newSizing; - (ITTransientStatusWindowSizing)sizing; @@ -97,12 +81,6 @@ typedef enum { - (ITTransientStatusWindowBackgroundType)backgroundType; - (void)setBackgroundType:(ITTransientStatusWindowBackgroundType)newType; -- (ITVerticalWindowPosition)verticalPosition; -- (void)setVerticalPosition:(ITVerticalWindowPosition)newPosition; - -- (ITHorizontalWindowPosition)horizontalPosition; -- (void)setHorizontalPosition:(ITHorizontalWindowPosition)newPosition; - - (float)effectProgress; - (void)setEffectProgress:(float)newProgress; @@ -112,5 +90,4 @@ typedef enum { - (ITWindowEffect *)exitEffect; - (void)setExitEffect:(ITWindowEffect *)newEffect; - -@end +@end \ No newline at end of file diff --git a/ITTransientStatusWindow.m b/ITTransientStatusWindow.m old mode 100755 new mode 100644 diff --git a/ITWindowEffect.h b/ITWindowEffect.h old mode 100755 new mode 100644 index 9b6c0bd..4244e09 --- a/ITWindowEffect.h +++ b/ITWindowEffect.h @@ -1,17 +1,16 @@ /* * ITKit - * ITWindowEffect - * Protocal and abstract superclass for performing effects on windows. + * ITWindowEffect.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy + * Protocol and abstract superclass for performing effects on windows. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - #import #import "ITWindowPositioning.h" @@ -20,7 +19,6 @@ #define EFFECT_FPS 30.0 #define DEFAULT_EFFECT_TIME 0.75 - typedef enum { ITWindowHiddenState, ITWindowAppearingState, @@ -28,8 +26,8 @@ typedef enum { ITWindowVanishingState } ITWindowVisibilityState; - @protocol ITWindowEffect + + (NSString *)effectName; + (NSDictionary *)supportedPositions; + (unsigned int)listOrder; @@ -37,27 +35,27 @@ typedef enum { - (void)performVanish; - (void)cancelAppear; - (void)cancelVanish; -@end +@end @protocol ITWindowMotility + - (ITWindowVisibilityState)visibilityState; - (void)setVisibilityState:(ITWindowVisibilityState)newState; - (float)effectProgress; - (void)setEffectProgress:(float)newProgress; -@end +@end -@interface ITWindowEffect : NSObject -{ - ITTransientStatusWindow *_window; - float _effectTime; - float _effectSpeed; - ITVerticalWindowPosition _verticalPosition; - ITHorizontalWindowPosition _horizontalPosition; - NSTimer *_effectTimer; - BOOL __idle; - BOOL __shouldReleaseWhenIdle; +@interface ITWindowEffect : NSObject { + NSWindow *_window; + float _effectTime; + float _effectSpeed; + ITVerticalWindowPosition _verticalPosition; + ITHorizontalWindowPosition _horizontalPosition; + NSTimer *_effectTimer; + BOOL __idle; + BOOL __shouldReleaseWhenIdle; } + (NSArray *)effectClasses; @@ -76,4 +74,4 @@ typedef enum { - (void)releaseWhenIdle; -@end +@end \ No newline at end of file diff --git a/ITWindowEffect.m b/ITWindowEffect.m old mode 100755 new mode 100644 diff --git a/ITWindowPositioning.h b/ITWindowPositioning.h old mode 100755 new mode 100644 index c43a7f4..0d83c42 --- a/ITWindowPositioning.h +++ b/ITWindowPositioning.h @@ -1,40 +1,37 @@ /* * ITKit - * ITWindowPositioning - * Protocol which defines methods for window positioning presets. + * ITWindowPositioning.h * - * Original Author : Matthew Judy - * Responsibility : Matthew Judy - * Responsibility : Joseph Spiros + * Protocol which defines methods for window positioning presets. * - * Copyright (c) 2002 - 2003 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - typedef enum { - ITWindowPositionLeft = 0, + ITWindowPositionLeft = 0, ITWindowPositionCenter = 1, - ITWindowPositionRight = 2, + ITWindowPositionRight = 2 } ITHorizontalWindowPosition; typedef enum { - ITWindowPositionTop = 0, + ITWindowPositionTop = 0, ITWindowPositionMiddle = 1, - ITWindowPositionBottom = 2, + ITWindowPositionBottom = 2 } ITVerticalWindowPosition; - @protocol ITWindowPositioning +- (NSScreen *)screen; +- (void)setScreen:(NSScreen *)newScreen; - (ITVerticalWindowPosition)verticalPosition; - (void)setVerticalPosition:(ITVerticalWindowPosition)newPosition; - (ITHorizontalWindowPosition)horizontalPosition; - (void)setHorizontalPosition:(ITHorizontalWindowPosition)newPosition; - (float)screenPadding; - (void)setScreenPadding:(float)newPadding; -/*- (int)screenNumber; -- (void)setScreenNumber:(int)newNumber;*/ -@end +@end \ No newline at end of file diff --git a/ITZoomWindowEffect.h b/ITZoomWindowEffect.h old mode 100755 new mode 100644 index 9fc920e..42363ce --- a/ITZoomWindowEffect.h +++ b/ITZoomWindowEffect.h @@ -1,23 +1,21 @@ /* * ITKit - * ITZoomWindowEffect - * Effect subclass which zooms (expands/shrinks) a window into position on the screen. + * ITZoomWindowEffect.h * - * Original Author : Kent Sutherland - * Responsibility : Kent Sutherland + * Effect subclass which zooms a window into position on the screen. * - * Copyright (c) 2002 - 2004 iThink Software. - * All Rights Reserved + * Copyright (c) 2005 by iThink Software. + * All Rights Reserved. + * + * $Id$ * */ - #import #import "ITWindowEffect.h" - -@interface ITZoomWindowEffect : ITWindowEffect { +@interface ITZoomWindowEffect : ITWindowEffect { } -@end +@end \ No newline at end of file diff --git a/ITZoomWindowEffect.m b/ITZoomWindowEffect.m old mode 100755 new mode 100644