• 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: Subviews
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subviews


  • Subject: Re: Subviews
  • From: Jeff Parsons <email@hidden>
  • Date: Fri, 24 Jan 2003 10:05:04 -0400

On Friday, January 24, 2003, at 03:27 AM, Clark Mueller wrote:

Mmm, perhaps I should have been more specific. I'd prefer sample code. The documentation for NSView is not working for me and is not providing the practical information I need; I'd prefer to see a set of sample code that puts the concepts into action.

My program has a window which has a contentView that contains 4 or 5 equal sized subviews. They are arranged vertically in a column. Here's some code from my NSWindow subclass, hope it helps.

- (void) windowSizeChanged
{
NSArray *allViews = [[self contentView] subviews];
NSEnumerator *views = [allViews objectEnumerator];
int i = [allViews count] - 1;
NSRect parentRect = [[self contentView] bounds];
float sizeHeight = parentRect.size.height / [allViews count];
float yPos = 0;
NSView *thisView;

[self disableFlushWindow];
while ( thisView = [views nextObject] )
{
// the first subview will always be positioned at the top at the window titlebar
// as subviews are added they are positioned underneath, last one at the bottom
yPos = i-- * sizeHeight;
NSPoint newPoint = NSMakePoint(
parentRect.origin.x , // use existing parentView left edge
parentRect.origin.y + yPos // make a new bottom edge for this view
);
NSRect newRect;
newRect.origin = newPoint;
newRect.size = NSMakeSize(
parentRect.size.width ,
sizeHeight
);
[thisView setFrame:newRect];
[thisView resetTrackingRects];
}
[self setViewsNeedDisplay:YES];
[self enableFlushWindow];
}

-Jeff
-----
Stay the patient course
Of little worth is your ire
The network is down
-----
_______________________________________________
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.

References: 
 >Re: Subviews (From: Clark Mueller <email@hidden>)

  • Prev by Date: Re: Core Graphics -> PostScript
  • Next by Date: Parsing XML pre cocoa days?
  • Previous by thread: Re: Subviews
  • Next by thread: Re: Subviews
  • Index(es):
    • Date
    • Thread