Re: column headers
Re: column headers
- Subject: Re: column headers
- From: email@hidden (Heinrich Giesen)
- Date: Fri, 12 Nov 2004 13:02:57 +0100
On Nov 11, 2004, at 15:10, John Spicer wrote:
Is there any way to get a double line headed in a table column? Either
via IB or in code? It would be nice sometimes to have Fee\rTax instead
of Fee Tax.
It can be done, but it's not exactly simple. The solution I have seen
involves a whole lot of subclassing and custom drawing. Regardless of
what you eventually do, you should file an enhancement request (as I
and others have) so that maybe some day it will be simple.
Larry Fransson
Seattle, WA
If you do not urgently need the "correct" background of the headerCell / headerView
of an NSTableView there is a simple way to draw the header in any height you want.
You need no subclassing, you only need to overwrite the drawWithFrame:inView method
(and highlighting) in NSTableHeaderCell. (Overwrite not subclassing!).
This is done in a category:
- - - - -
@implementation NSTableHeaderCell (varHeight)
- (
void) drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
if( [
self isHighlighted] ){
[[NSColor selectedControlColor] set];
[
self setHighlighted:
NO];
}
else{
[[NSColor colorWithCalibratedWhite:
0.92 alpha:
1.0] set];
}
NSRectFill(cellFrame);
[[NSColor blackColor] set];
NSFrameRect(cellFrame);
// Draw a bordered rectangle
[[NSColor headerTextColor] set];
[
self drawInteriorWithFrame:cellFrame inView:controlView];
}
- (
void) highlight:(
BOOL)flag withFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
[
self setHighlighted:
YES];
[
self drawWithFrame:cellFrame inView:controlView];
}
- - - - -
You have to set the hight you want:
[[theTableView headerView] setFrame:theFrameYouWant];
If you want a more nicely "gradiented" backgroundview you can add
something like this (in the category) just behind NSRectFill(cellFrame);
- - - -
bgImage = theImageWhichReflectsTheGradientColor;
[bgImage setScalesWhenResized:
YES];
[bgImage setSize:imgFrame.size]; // slightly modified size of cellFrame
[bgImage compositeToPoint:imgFrame.origin operation:NSCompositeSourceOver];
- - - -
--
Heinrich Giesen
email: 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