discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replacing views with setContentView


From: Nicola Pero
Subject: Re: Replacing views with setContentView
Date: Tue, 13 Jun 2006 22:07:29 +0100 (BST)

> I am exchanging the contentView of the window as follows:
> 
> - (void)setClientView:(NSView *)view
> {
>     NSRect rect = [[mainWin contentView] frame];
>     [view removeFromSuperviewWithoutNeedingDisplay];
>     [view setFrame:rect];
>     [mainWin setContentView:view];
>     [view setAutoresizesSubviews:NO]; 
>     [view setAutoresizingMask:0];
> }
> 
> The view I am passing to this method is a direct subclass of NSView. 
> This view should not do standard autoresizing of its subviews. I 
> implemented my own mechanism to do so in setFrame:. Now with my GNUstep 
> fix everything works fine. Without the fix resizing of the view (not 
> even initial sizing) does not work. The view gets a wrong width and 
> height!

Thanks ... very interesting stuff :-)

... how do you create the window ?

I tried your code and [GSWindowDecorationView -setFrame:] never gets
called when setClientView: is called.

So for your patch to have some effects, it must have been called somewhere
else! ;-)

How/where do you decide how big the window is ?

Finally, the content view is supposed to fill up the content rect.  
That's in the spec.  So all the visible size of the window should be taken
up by the content view.  If the visible size increases, the content view
of course gets resized up, and if the visible size decreases, the content
view gets resized down.

If you want your view to cover all of the visibile area and to track it,
the set your view as the content view. :-)

If you *don't* want your view to take up all the window space and resize
in this way, then don't set it as the content view! ;-)

In this case (which I believe is your case!) you can just add your view as
a subview of the content view! ;-)

[[mainWin contentView] addSubview: xxx];

Also you have replaceSubview:with: etc.

Instead of replacing the contentView, add your view as a subview of it.  
:-)

You see, the real problem is that your code is concluded by the call

 [cv setAutoresizingMask:0];

which is highly dubious.  Eg, according to the Apple/OpenStep
documentation, the content view *must* track changes in sizes of the
window.  This is the reason that gnustep sets the autoresizing mask to
NSViewWidthSizable | NSViewHeightSizable (which is *not* a safety check,
it's an essential part of the implementation).

So trying to set the autoresizing mask to 0 to prevent it from tracking
changes to the size of the window is plain illegal or at least resulting
in undefined/unexpected behaviour. ;-)

GNUstep is totally correct in setting the autoresizing mask to track
changes in the window size, and you shouldn't be messing that up! ;-)

I think the most likely case is just that you want to set your view as a 
subview of the content view :-)

Thanks

PS: please send any further emails to the list - don't answer directly to
me as I'm overloaded with emails and might lose it or never come back





reply via email to

[Prev in Thread] Current Thread [Next in Thread]