NSView resizing problem
NSView resizing problem
- Subject: NSView resizing problem
- From: Brad Oliver <email@hidden>
- Date: Thu, 21 Nov 2002 10:43:12 -0600
I'm fairly new to Cocoa and I'm having trouble with resizing an NSView.
In Interface Builder, I have a window which contains a custom NSView class.
I've placed this in a NSScrollView class using the "make subviews of..."
command in Interface Builder. I've connected the orignal class to an
IBOutlet so I can manipulate it from my app.
Trouble starts when I want to resize the original custom view I've created.
I want to take the embedded custom view and resize it as needed, either
enlarging or shrinking, and have the scroll bars adjust to reflect the new
size. I don't want to change the scale of the embedded view, just the raw
pixel size.
Here is the relevant code (forgive the syntax, I've had to edit it
slightly):
@interface CustomScrollView : NSView
{
}
@end
@implementation CustomScrollView
-(void)drawRect: (NSRect) rect
{
...
}
@interface MyDoc : NSDocument
{
IBOutlet CustomScrollView* custom_ScrollView;
}
@end
void ResizeView (...)
{
...
NSScrollView *mapView;
mapView = (NSScrollView *)docWindow->custom_ScrollView; //
CustomScrollView *
// Set the size of the contained, non-scrolling view
[[mapView documentView] setBounds: NSMakeRect (0, 0, sizeTotal.cx,
sizeTotal.cy)];
// Now adjust the scrollbar paging
[mapView setHorizontalLineScroll: sizeLine.cx];
[mapView setVerticalLineScroll: sizeLine.cy];
[mapView setHorizontalPageScroll: sizePage.cx];
[mapView setVerticalPageScroll: sizePage.cy];
}
What happens is that on the first setBounds call, control of my app
"disappears" into the Cocoa event loop. That is, execution doesn't continue
on to the next line. The odd thing is that I can resize my window and the
"drawRect" method will still be called.
Any ideas as to what is going on here? Why would Cocoa get sidetracked from
the main execution path like that? More to the point, am I going about this
correctly? My first hunch was that docWindow didn't point to the proper
"MyDoc" but it sure looks like it does in the debugger.
--
Brad Oliver
email@hidden
_______________________________________________
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.