• 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: Setting the content origin in IB
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting the content origin in IB


  • Subject: Re: Setting the content origin in IB
  • From: Ken Tozier <email@hidden>
  • Date: Fri, 2 Feb 2007 04:15:21 -0500

Fleshing in some of the details...

The view I'm writing consists of two subviews, a title bar and a collapsible "content" view. If I set the content rectangle of the custom view to top/left in IB and turn off all coordinate flipping in the classes themselves, the title bar draws in the lower left of the custom view. Click the expansion triangle in the title bar and the content view appears above it.

Fair enough.

To remedy this problem, I define the "isFlipped" method of the custom view. When I run the app, the title bar appears in it's correct location in the upper left and If I click the expansion triangle, the content view appears below it as expected.

Perfect!

Then the trouble starts...

The content view contains a grid of page icons that "flow" as the view is widened/narrowed. If the view is narrowed beyond a certain threshold, the content view flows pages to a new row and updates the frame size to reflect the new depth. What I expect to happen is that the title bar would stay put and the content view would get deeper. What actually happens is that the content view does get deeper but instead of growing in a downward direction, the bottom stays put and title bar moves up.

Not perfect.

The trouble is undoubtedly related to coordinate flipping or something but since I definitely define the "isFlipped" method, I thought that would set the draw origin in the upper left. I wrote all the subsequent subview positioning code off of this simple assumption but many hours of frustration and a vigorous workout for my repertoire of "colorful language", I'm completely and utterly stumped. It's an extremely simple idea that has turned into a 6 hour nightmare.

Below is the method where I think I'm screwing up. I think the problem is most likely related to the rect.origin not behaving as I expect but have no idea what I'm doing wrong

Any help appreciated.

Ken


- (void) observeValueForKeyPath:(NSString *) inKeyPath
ofObject:(id) inObject
change:(NSDictionary *) inChange
context:(void *) inContext
{
NSRect oldFrame = [self frame];

if ([inKeyPath isEqualToString: @"selected"])
{
// The disclosure button was clicked.
// Handle expand/collapse events
if (isCollapsed == YES)
{
// expand the view to the height of the title bar + the height of the "content" view
[content setHidden: NO];
isCollapsed = NO;
[self setVisibleHeight: [titlebar height] + [content height]];
[self setFrame: NSMakeRect(oldFrame.origin.x, oldFrame.origin.y, oldFrame.size.width, visibleHeight)];
[self setNeedsDisplayInRect: [self frame]];
}
else
{
// collapse the view to just the height of the title bar
[content setHidden: YES];
isCollapsed = YES;
[self setVisibleHeight: [titlebar height]];
[self setFrame: NSMakeRect(oldFrame.origin.x, oldFrame.origin.y, oldFrame.size.width, [titlebar height])];
[self setNeedsDisplayInRect: [self frame]];
}
}
else if ([inKeyPath isEqualToString: @"height"])
{
// The content view added or removed rows
// resize the view.
float newHeight = [[inChange objectForKey: NSKeyValueChangeNewKey] floatValue];
NSRect newFrame = NSMakeRect(oldFrame.origin.x, oldFrame.origin.y, oldFrame.size.width, newHeight + [titlebar height]);

[self setFrame: newFrame];
[self setNeedsDisplayInRect: newFrame];
}
}





On Feb 2, 2007, at 1:29 AM, Ken Tozier wrote:

Hi

I'm sure this is an easy one but I can't figure out how to set the origin of items in IB. It seems that setting the "content rectangle" in the size tab of the IB inspector to "top/left" has absolutely no effect. All my views are drawing from the lower left corner and it's turned into a real PITA. For my custom views, I set the "isFlipped" and they draw their contents from the upper left, but nothing from IB, be they box views, scroller views or the content view of windows pay any attention to my IB settings.

Any insight appreciated.

Ken
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
40comcast.net


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Setting the content origin in IB
      • From: Uli Kusterer <email@hidden>
References: 
 >Setting the content origin in IB (From: Ken Tozier <email@hidden>)

  • Prev by Date: Re: Setting the content origin in IB
  • Next by Date: Regular Expressions with OgreKit
  • Previous by thread: Re: Setting the content origin in IB
  • Next by thread: Re: Setting the content origin in IB
  • Index(es):
    • Date
    • Thread