Re: Source lists
Re: Source lists
- Subject: Re: Source lists
- From: Todd Ransom <email@hidden>
- Date: Thu, 22 Sep 2005 15:36:46 -0600
I just finished doing this for a project I am working on. Since you
don't need a header on your table I would suggest just using a two-
column table with an image cell and a text cell. For the gradient
selection tableView you will need subclasses of NSTableView and
NSTextFieldCell (otherwise the text will not change white when you
select the row). I assembled this mostly from stuff on cocoadev.com
with a couple of things from scottlandsoftware.com. It should get you
started. You can find the gradient image in /System/Library/
PreferencePanes/Accounts.prefPane/
Todd Ransom
Return Self Software
http://returnself.com
=================
#import <Cocoa/Cocoa.h>
@interface AVNRaquaTableView : NSTableView {
}
@end
@interface AVNRgradientSelectionTextCell : NSTextFieldCell {
}
@end
#import "AVNRaquaTableView.h"
// RGB values for stripe color (light blue)
#define STRIPE_RED (237.0 / 255.0)
#define STRIPE_GREEN (243.0 / 255.0)
#define STRIPE_BLUE (254.0 / 255.0)
static NSColor *sStripeColor = nil;
@implementation AVNRaquaTableView
- (void)highlightSelectionInClipRect:(NSRect)clipRect {
NSImage *backgroundImage = [NSImage
imageNamed:@"selectionGradient"];
/*
NSImage *backgroundImage;
if([[self window] isMainWindow])
backgroundImage = [NSImage
imageNamed:@"selectionGradientBlue"];
else
backgroundImage = [NSImage
imageNamed:@"selectionGradientGrey"];
*/
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: 0.7];
// fraction:1.0];
}
}
- (id)_highlightColorForCell:(NSCell *)cell {
return nil;
}
- (void)awakeFromNib {
// set the color
if (sStripeColor == nil) {
sStripeColor = [[NSColor colorWithCalibratedRed: STRIPE_RED
green: STRIPE_GREEN
blue: STRIPE_BLUE
alpha:1.0] retain];
}
[self setBackgroundColor: sStripeColor];
}
- (void)dealloc {
[sStripeColor release];
[super dealloc];
}
@end
@implementation AVNRgradientSelectionTextCell
-(void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)
controlView {
if ([self isHighlighted]) {
[self setTextColor: [NSColor whiteColor]];
} else {
[self setTextColor: [NSColor controlTextColor]];
}
[super drawInteriorWithFrame: cellFrame inView: controlView];
}
@end
On Sep 22, 2005, at 1:54 PM, Mike Abdullah wrote:
I'm sure this has been asked before, however in my search for an
answer, I have come across many conflicting solutions and would
like to know what is generally considered best practice as of the
current moment. So:
What is the best way to create a source list in my application?
I wish to create something similar to the source list in Address
Book. Whilst it is not essential that I have the blue "gradient"
effect, it would be nice. I also definitely need to have icons by
each item in the list. Oh, and I don't need a "header" sort of
thing like iTunes has.
So, what is considered the best way of doing this?
Mike.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >Source lists (From: Mike Abdullah <email@hidden>) |