Re: Problem with NSSCrollView.
Re: Problem with NSSCrollView.
- Subject: Re: Problem with NSSCrollView.
- From: Ron Davis <email@hidden>
- Date: Thu, 24 Apr 2003 10:39:18 -0500
on 4/24/03 5:00 AM, Manish Pattath at email@hidden wrote:
>
How do I make the scroll view display all the cells
>
that are created?
You have to programmatically change the frame of your custom view. The frame
is the size of the view independent of the scroller it is in.
I use this code to recalc the height of a view where I want the max number
of columns across based on the scroller width and the max number of rows
based on the number of cells I'm going to display. I only have a vertical
scroll bar.
- (void) recalcSize
{
NSRect curFrameRect = [self frame];
NSScrollView* enclosingScrollView = [self enclosingScrollView];
int viewWidth = [enclosingScrollView contentSize].width;
numCols = (viewWidth/cellWidth);
if ( numCols > numCells ) numCols = numCells;
numRows = (numCells/numCols);
if ( (numCells % numCols) > 0 ) numRows++;
float viewHeight = numRows * cellHeight;
NSRect newFrame = NSMakeRect(curFrameRect.origin.x,
curFrameRect.origin.y,
viewWidth,
viewHeight );
[self setFrame:newFrame];
}
It gets called from frameDidChangeNotification and if the number of cells
change.
--
Ron Davis
"Whether you think you can or think you can't, you are right." -- Henry Ford
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.