From: Matthew Judy Date: Wed, 23 Apr 2003 12:18:34 +0000 (+0000) Subject: Adding a BevelView to the kit, for use in AG. X-Git-Tag: v0.1~44 X-Git-Url: http://git.ithinksw.org/ITKit.git/commitdiff_plain/3b1f9f1fd5958a8241495edf7c72d335ac302c68 Adding a BevelView to the kit, for use in AG. --- diff --git a/ITBevelView.h b/ITBevelView.h new file mode 100755 index 0000000..de07fd0 --- /dev/null +++ b/ITBevelView.h @@ -0,0 +1,31 @@ +/* + * ITKit + * ITBevelView + * NSView subclass which draws a bevel. + * + * Original Author : Matt Judy + * Responsibility : Matt Judy + * + * Copyright (c) 2003 iThink Software. + * All Rights Reserved + * + */ + +/* + * Draws a bevel of specified thickness, and resizes + * its first subview to fill the remaining space. + */ + + +#import + + +@interface ITBevelView : NSView { + int _bevelDepth; +} + +- (int)bevelDepth; +- (void)setBevelDepth:(int)newDepth; + + +@end diff --git a/ITBevelView.m b/ITBevelView.m new file mode 100755 index 0000000..de94f3b --- /dev/null +++ b/ITBevelView.m @@ -0,0 +1,112 @@ +#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)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; +} + +- (void)setBevelDepth:(int)newDepth +{ + _bevelDepth = newDepth; + [self setNeedsDisplay:YES]; +} + + +/*************************************************************************/ +#pragma mark - +#pragma mark INSTANCE METHODS +/*************************************************************************/ + +- (void)drawRect:(NSRect)aRect +{ + // Draw special bezel, with a thickness of _bevelDepth. + NSRect innerRect = NSMakeRect( (aRect.origin.x + _bevelDepth), + (aRect.origin.y + _bevelDepth), + (aRect.size.width - (_bevelDepth * 2)), + (aRect.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:aRect.origin]; + [leftEdge lineToPoint:NSMakePoint(aRect.origin.x, aRect.size.height)]; + [leftEdge lineToPoint:NSMakePoint( (aRect.origin.x + _bevelDepth), (aRect.size.height - _bevelDepth) )]; + [leftEdge lineToPoint:NSMakePoint( (aRect.origin.x + _bevelDepth), (aRect.origin.y + _bevelDepth) )]; + + [topEdge moveToPoint:NSMakePoint(aRect.origin.x, aRect.size.height)]; + [topEdge lineToPoint:NSMakePoint(aRect.size.width, aRect.size.height)]; + [topEdge lineToPoint:NSMakePoint( (aRect.size.width - _bevelDepth), (aRect.size.height - _bevelDepth) )]; + [topEdge lineToPoint:NSMakePoint( (aRect.origin.x + _bevelDepth), (aRect.size.height - _bevelDepth) )]; + + [rightEdge moveToPoint:NSMakePoint(aRect.size.width, aRect.origin.y)]; + [rightEdge lineToPoint:NSMakePoint(aRect.size.width, aRect.size.height)]; + [rightEdge lineToPoint:NSMakePoint( (aRect.size.width - _bevelDepth), (aRect.size.height - _bevelDepth) )]; + [rightEdge lineToPoint:NSMakePoint( (aRect.size.width - _bevelDepth), (_bevelDepth) )]; + + [bottomEdge moveToPoint:aRect.origin]; + [bottomEdge lineToPoint:NSMakePoint(aRect.size.width, aRect.origin.y)]; + [bottomEdge lineToPoint:NSMakePoint( (aRect.size.width - _bevelDepth), (_bevelDepth) )]; + [bottomEdge lineToPoint:NSMakePoint( (aRect.origin.x + _bevelDepth), (aRect.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]; +} + + +/*************************************************************************/ +#pragma mark - +#pragma mark DEALLOCATION METHOD +/*************************************************************************/ + +- (void)dealloc +{ + [super dealloc]; +} + + +@end diff --git a/ITKit.h b/ITKit.h index 95c6aad..ca9c5dc 100755 --- a/ITKit.h +++ b/ITKit.h @@ -16,6 +16,7 @@ #import #import #import +#import #import #import diff --git a/ITSlideHorizontallyWindowEffect.m b/ITSlideHorizontallyWindowEffect.m index ac302ff..01b3545 100755 --- a/ITSlideHorizontallyWindowEffect.m +++ b/ITSlideHorizontallyWindowEffect.m @@ -137,7 +137,7 @@ [self setSlide:0.0]; [self setWindowVisibility:ITWindowHiddenState]; - __idle =YES; + __idle = YES; if ( __shouldReleaseWhenIdle ) { [self release]; diff --git a/Showcase/Controller.h b/Showcase/Controller.h index f8b3b6d..1bd81ea 100755 --- a/Showcase/Controller.h +++ b/Showcase/Controller.h @@ -16,6 +16,9 @@ // ITTabView Support IBOutlet ITTabView *tabView; + // ITBevelView support + IBOutlet ITBevelView *bevelView; + // ITTextField Support IBOutlet ITTextField *testTextField; @@ -50,4 +53,7 @@ - (IBAction)toggleOptionDragging:(id)sender; - (IBAction)toggleShiftDragging:(id)sender; +// ITBevelView support +- (IBAction)changeBevelViewSetting:(id)sender; + @end diff --git a/Showcase/Controller.m b/Showcase/Controller.m index 80fc5f1..71463aa 100755 --- a/Showcase/Controller.m +++ b/Showcase/Controller.m @@ -1,6 +1,7 @@ #import "Controller.h" #import "ITTransientStatusWindow.h" #import "ITTextField.h" +#import "ITBevelView.h" #import "ITCutWindowEffect.h" #import "ITDissolveWindowEffect.h" #import "ITSlideHorizontallyWindowEffect.h" @@ -28,6 +29,7 @@ [self createStatusItem]; [testTextField setCastsShadow:YES]; [tabView setAllowsDragging:YES]; + [bevelView setBevelDepth:10]; statusWindow = [ITTransientStatusWindow sharedWindow]; [statusWindow setEntryEffect:[[ITCutWindowEffect alloc] initWithWindow:statusWindow]]; [statusWindow setExitEffect:[[ITDissolveWindowEffect alloc] initWithWindow:statusWindow]]; @@ -60,6 +62,10 @@ } [statusItem setMenu:statusItemMenu]; + + [statusItemMenu addItemWithTitle:[NSString stringWithUTF8String:"★★★★★"] + action:nil + keyEquivalent:@""]; } - (void)removeStatusItem @@ -316,6 +322,16 @@ } +/*************************************************************************/ +#pragma mark - +#pragma mark ITBevelView SUPPORT +/*************************************************************************/ + +- (IBAction)changeBevelViewSetting:(id)sender +{ + [bevelView setBevelDepth:[sender intValue]]; +} + /*************************************************************************/ #pragma mark - #pragma mark NSWindow DELEGATE METHODS diff --git a/Showcase/English.lproj/MainMenu.nib/classes.nib b/Showcase/English.lproj/MainMenu.nib/classes.nib index cd76fd0..e76b9cf 100755 --- a/Showcase/English.lproj/MainMenu.nib/classes.nib +++ b/Showcase/English.lproj/MainMenu.nib/classes.nib @@ -3,6 +3,7 @@ { ACTIONS = { buildStatusWindow = id; + changeBevelViewSetting = id; changeWindowSetting = id; toggleCastsShadow = id; toggleCommandDragging = id; @@ -19,6 +20,7 @@ CLASS = Controller; LANGUAGE = ObjC; OUTLETS = { + bevelView = ITBevelView; showImageCheckBox = NSButton; showStatusItemCheckBox = NSButton; showTitleCheckBox = NSButton; @@ -37,6 +39,7 @@ SUPERCLASS = NSObject; }, {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + {CLASS = ITBevelView; LANGUAGE = ObjC; SUPERCLASS = NSView; }, { ACTIONS = {start = id; stop = id; }; CLASS = ITChasingArrowsView; diff --git a/Showcase/English.lproj/MainMenu.nib/info.nib b/Showcase/English.lproj/MainMenu.nib/info.nib index a169d02..3e992c5 100755 --- a/Showcase/English.lproj/MainMenu.nib/info.nib +++ b/Showcase/English.lproj/MainMenu.nib/info.nib @@ -3,7 +3,7 @@ IBDocumentLocation - 2 1 356 240 0 0 1056 770 + 197 65 497 330 0 0 1056 770 IBEditorPositions 197 @@ -15,8 +15,8 @@ 286.0 IBOpenObjects - 21 29 + 21 IBSystem Version 6L28 diff --git a/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib b/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib index dd63502..343c2c0 100755 Binary files a/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib and b/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib differ