On Sunday, February 2, 2003, at 07:35 PM, Rich Morin wrote:
You can loop over the columns in your controller's new() method, and initialize it there - that's what the example code below does.BTW, I'm making this call each time I return a table cell. This seems wrong, but I've been unable to make a generic change work.
Yes - I'm surprised to find that you do. I'd have thought that Cocoa would handle this detail when you change the font size - it's usually pretty good about things like that. :-(Anyway, I think I need to inform someone of the fact that the rowHeight has changed.
An NSRect isn't an object - it's just a C struct. It's passed to Perl as a reference to a scalar. You can either dereference it and use unpack(), or call the NSHeight() function to get the height from it.$font = NSFont->userFixedPitchFontOfSize(0); $tmp = $font->boundingRectForFont()->{size}->{height}; $table->setRowHeight($tmp);
I did some hacking with the Data Access example, and either a) there's a bug in CB's struct-handling code, or b) I'm misunderstanding what the boundingRectForFont() method does, because I couldn't get a height that made sense from it.
Fortunately, NSFont has a defaultLineHeightForFont() method that *does* return sensible values, as a simple float. Here's what I came up with:
my $font = NSFont->userFixedPitchFontOfSize(12);
my $height = $font->defaultLineHeightForFont();
$self->{'TableView'}->setRowHeight($height);
my $enum = $self->{'TableView'}->tableColumns()->objectEnumerator();
while (my $column = $enum->nextObject()) {
my $cell = $column->dataCell();
$cell->setFont($font);
}
sherm--
"I have no special gift, I am only passionately curious." - Albert Einstein