Re: question about frame and bounds
Re: question about frame and bounds
- Subject: Re: question about frame and bounds
- From: Ivan Kourtev <email@hidden>
- Date: Sun, 19 Oct 2003 15:00:06 -0400
On Sunday, Oct 19, 2003, at 13:49 US/Eastern, j o a r wrote:
On 2003-10-19, at 19.28, Ivan Kourtev wrote:
2003-10-19 12:03:38.108 V[3441] separator:frame = (2.000000,
2.000000, 665.000000, 1.000000)
2003-10-19 12:03:38.108 V[3441] separator:bounds = (0.000000,
0.000000, 665.000000, 1.000000)
Isn't there something wrong with this output? As I understand it
No, it looks fine. What it tells you is that the view is positioned at
x=2, y=2 in the superview coordinate system. The size of the view is
w=665, h=1. Per default the bounds of the view is originated at x=0,
y=0 and with the same width and height as the view. So everything
seems to be fine and dandy.
Notice that a separator line is a "flat" NSBox. It's not a separate
class of it's own.
j o a r
I understand, thanks. But another question remains (please refer to
original post).
So the separator line (which is an NSBox) has a superview which is NOT
the containing window, correct? What is it?
And on a more general level, let's say I still want to get the sizes of
all UI objects so I can resize appropriately their containing window.
Since an interface object such as the seperator line is contained in a
superview (which is NOT the containing window) it seems I have two
choices:
Choice #1: Know the view container hierarchy for every possible
interface object, go up the hierarchy as required and get the frame of
the outermost view, above which is only 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 */
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,
-- ivan
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).
_______________________________________________
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.