I'd like to use an NSTableView for displaying a list of disks to the user and I think it would be better to display them a bit differently than the normal NSTableView does. Here is an image as example:
The features I'd like are these:
I am specially reluctant to do the third as I think it will envolve doing my own cell subclass and drawing the text and image myself, which I have NO clue how to do :(
The other ones I reckon they will not be that difficult once someone points me in the right direction...
PS: The image is from Xcode 4 in the preferences.
Alright! I have found how all these three things can be done:
Now for the third I did something a wee bit differently than I said I wanted:
`
@interface ACTCenteredTextFieldCell : NSTextFieldCell
{
}
@end
@implementation ACTCenteredTextFieldCell
- (NSRect)titleRectForBounds: (NSRect)theRect {
NSRect titleFrame = [super titleRectForBounds: theRect];
NSSize titleSize = [[self attributedStringValue] size];
titleFrame.origin.y = theRect.origin.y + (theRect.size.height - titleSize.height) / 2.0;
return titleFrame;
}
- (void)drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView {
NSRect titleRect = [self titleRectForBounds: cellFrame];
[[self attributedStringValue] drawInRect: titleRect];
}
@end
There! Worked fine for me so far!