Re: Strategies for fitting an NSWindow to its content?
Re: Strategies for fitting an NSWindow to its content?
- Subject: Re: Strategies for fitting an NSWindow to its content?
- From: Daryn <email@hidden>
- Date: Tue, 7 Oct 2003 01:15:19 -0500
I recently solved a similiar problem, but not in as generic of method
as your stated requirements.
I'm not sure how (in)efficient this would be: have the window register
for all notifications of type NSViewFrameDidChangeNotification. Use
isDescendantOf: to see if the view descends from the window's
contentView. If so, check if the view's frame exceeds its superview's
bounds using visibleRect. Resize the window by the height & width
deltas -- assuming that the view's autoresizingMask will bring the
cropped region back into view.
Hopefully this provides inspiration.
On Monday, October 6, 2003, at 11:25 PM, Andrew Thompson wrote:
Hi all,
A puzzle with window resizing.
Usually Cocoa employs an outside-in model. ie, one sets the frame of
one's NSWindow, and the views within it are resized according to their
Autosize settings.
However, what if I want to go the other way and have an NSWindow grow
and shrink as children of its content view change size?
The deal is I have a custom NSTextfield, which is one of several child
views of the content view of an NSWindow.
I manipulate this NSTextField, and it uses -[sizeToFit] to alter its
own size to grow or shrink to show its content.
However, if it gets bigger, it will be clipped by its containing
NSWindow.
Is there any way for an NSWindow to consider its content view's
children and realize that one has been resized such that its
frame/bounds lie outside the visible portion of the NSWindow?
To complicate things a little further, sometimes I remove the content
view in question from its parent window and put it elsewhere. It might
resize whilst not in the window, which means when I put it back in the
NSWindow, I might need to resize the window to be large enough to show
the new content.
I'm really just looking for ideas here. I'd like this to happen
automatically... I feel like there should be some way for an NSWindow
custom subclass to monitor what's being resized within its content
view and make sure its an appropriate size for everything to be
visible.
AndyT (lordpixel - the cat who walks through walls)
A little bigger on the inside
(see you later space cowboy ...)
_______________________________________________
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.
Daryn
_______________________________________________
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.