BSSidebar
Language: Objective-C, Author: Michele Balistreri
License: Public domain
This NSTableView subclass tries to mimic the appearance of the Finder sidebar using gradients to highlight selections. I suggest replacing the png's gradients with some vector art looking towards Leopard.
You probably also want to download BSLabeledIconCell to have a cell which displays both an icon and a label on a single column, but is not a strict dependency.
BSSidebar source preview
#import "BRSidebar.h" @implementation BSSidebar - (void)highlightSelectionInClipRect:(NSRect)clipRect { NSImage *backgroundImage; if([[self window] isKeyWindow] && [[self window] isMainWindow]) { backgroundImage = [NSImage imageNamed:@"selectionGradient"]; } else { backgroundImage = [NSImage imageNamed:@"selectionGradient_grey"]; } if(backgroundImage) { [backgroundImage setScalesWhenResized:YES]; [backgroundImage setFlipped:YES]; NSRect drawingRect; drawingRect = [self rectOfRow:[self selectedRow]]; NSSize bgImageSize; bgImageSize = drawingRect.size; [backgroundImage setSize:bgImageSize]; NSRect imageRect; imageRect.origin = NSZeroPoint; imageRect.size = [backgroundImage size]; [backgroundImage drawInRect:drawingRect fromRect:imageRect operation:NSCompositeSourceOver fraction:1.0]; } } - (id)_highlightColorForCell:(NSCell *)cell { return nil; } @end
BSSidebar header preview
#import <Cocoa/Cocoa.h> @interface BSSidebar : NSTableView { } @endDownload Archive
Dependencies:
Compatible with:
- Mac OS X 10.3
- Mac OS X 10.4 PPC
- Mac OS X 10.4 Intel
- Mac OS X 10.5 PPC
- Mac OS X 10.5 Intel
Comments
Comment feed
