• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: question about frame and bounds
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: question about frame and bounds


  • Subject: Re: question about frame and bounds
  • From: j o a r <email@hidden>
  • Date: Sun, 19 Oct 2003 22:24:05 +0200

On 2003-10-19, at 21.00, Ivan Kourtev wrote:

So the separator line (which is an NSBox) has a superview which is NOT the containing window, correct? What is it?

A window is never the superview of anything. All views in a window are contained in a "view hierarchy" that is rooted in the "content view" of the window. If you simply added the separator to the window - and not to some box, tab view, split view, et.c. in the window - the separator should be a subview to the content view of the window.

Choice #2: Not know the hierarchy but for every interface object do something like this:

register id interface_object = /* the object in question */;
register NSView *containing_window = [[interface_object window] contentView];
register NSView *containing_view = interface_object;
assert( containing_view != containing_window );
while ( YES ) {
register NSView* superview = [containing_view superview];
if ( superview == containing_window )
{ break; }
else
{ containing_view = superview; }
}
/* containing_view contains the outermost superview of interface_object that is
NOT the containing window */

You should write:

if (superview == [window contentView])
break;

...never iterate above the content view of the window! Although there are views above the content view, they are there as an implementation detail of the implementation of NSWindow. They are private and should never be messed with.

Although this code does work -- when called for anything other than an NSWindow object -- I am not sure it is the most efficient way of doing what I need. Any opinions? Thanks,

Why don't you tell us what you're trying to do - that would make it easier to tell you what is the most efficient way to go about doing it.

P.S. Depending on the specific interface, I think a more efficient way to quickly figure out what window area needs to be resized is to enclose a large group of objects in an invisible NSBox, then just deal with this NSBox (as long as interface objects can be grouped in such a fashion).

In IB you can use the "Make subviews of > Box" menu command to make a group of views into a subview of a box. If you set the springs and struts correctly:

<http://developer.apple.com/documentation/Cocoa/Conceptual/DrawViews/ Tasks/MovingResizingViews.html#//apple_ref/doc/uid/20000910/102111>

...you can then simply resize the box and have all it's subviews resized automatically.

j o a r
_______________________________________________
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.

  • Follow-Ups:
    • Re: question about frame and bounds
      • From: "Ivan S. Kourtev" <email@hidden>
References: 
 >Re: question about frame and bounds (From: Ivan Kourtev <email@hidden>)

  • Prev by Date: Re: Default Window Centering
  • Next by Date: Re: flagsChanged:
  • Previous by thread: Re: question about frame and bounds
  • Next by thread: Re: question about frame and bounds
  • Index(es):
    • Date
    • Thread