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

Re: Preference Window Question


  • Subject: Re: Preference Window Question
  • From: Carl Norum <email@hidden>
  • Date: Sat, 29 Mar 2003 22:20:21 -0600

On Saturday, March 29, 2003, at 10:02 PM, Eric Czarny wrote:
I was wondering if anyone knows of a way to resize a window to accomodate an NSView. I'm trying to make a prefence window seen in many apps, with a toolbar in the header and an NSView below. Whenever the user clicks on a toolbar item the window will resize and display the the preferences in an NSView. I'm able to display the view using the NSWindow method setContentView: however, I'm having trouble figuring out how to resize the window, with the animation. Any help would be greatly appreciated!

Here's what I do (code below). You can see it in action if you download the program ( http://norum.homeunix.net/~carl/vineyard/ ), that is if I've understood what you want to do correctly. The method you want is -[NSWindow setFrame:display:animate], probably.

---------------------- CODE ----------------------------

- (IBAction)changePane:(id)sender
{
CharacterWindowPane *current = [[self window] contentView];
CharacterWindowPane *new;

NSSize currentSize = [current bounds].size;
NSSize windowSize = [[self window] frame].size;
NSPoint windowOrigin = [[self window] frame].origin;

if (sender == [toolbarItems objectForKey:@"Next Pane"])
new = [current nextPane];
else if (sender == [toolbarItems objectForKey:@"Previous Pane"])
new = [current previousPane];
else
new = [panes objectForKey:[sender title]];

if (current != new) {
NSSize newSize = [new bounds].size;

[self saveCharacter:self];

[[self window] setContentView:[[[NSView alloc] initWithFrame:NSZeroRect] autorelease]];

[[self window] setFrame:NSMakeRect(windowOrigin.x,
windowOrigin.y + currentSize.height - newSize.height,
newSize.width,
windowSize.height - currentSize.height + newSize.height)
display:YES
animate:YES];

[[self window] setContentView:new];
[self updateUI];
[[self window] displayIfNeeded];
}
}

---------------------- CODE ----------------------------



--
Carl J Norum
5th Year Electrical Engineering/Computer Science Student
University of Saskatchewan
Saskatoon, Canada

http://norum.homeunix.net/~carl/
_______________________________________________
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: 
 >Preference Window Question (From: Eric Czarny <email@hidden>)

  • Prev by Date: Re: Preference Window Question
  • Next by Date: How to detect whether a filename points to a text clipping?
  • Previous by thread: Re: Preference Window Question
  • Next by thread: How to detect whether a filename points to a text clipping?
  • Index(es):
    • Date
    • Thread