Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Dynamically changing the interface

Dynamically changing the interface
Thread Tools
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Jan 16, 2001, 08:31 PM
 
I was wondering if anyone knew how I could dynamically change things in the interface. What I mean is something like PPP Connect or the System Preferences. In PPP Connect after you click connect, the window shrinks while it is connecting and then becomes large again when it is done, this time with new stuff in it. (Status bars and such). In System Preferences when you click on a preference item the window shrinks or expands to accommodate the new controls that are associated with that item and then displays them. I guess to break it down into three simpler questions:

1) How do I change the size, location, etc of existing interface items in a window while a program is running? For example make a text field or something change sizes.

2) How to I make interface items appear or disappear, while a program is running. In System Preferences things associated with an old preference panel disappear when you click on a new preference panel and the things associated with the new one appear.

3) How do I change the size of a window (In code, not by a user dragging it) while a program is running?

Dynamically changing the contents of a window would be really useful and I have no idea how to do it! I'd be really interested to see if anyone knows how to do any of this.
     
Fresh-Faced Recruit
Join Date: Jan 2001
Location: San Jose, CA USA
Status: Offline
Reply With Quote
Jan 22, 2001, 12:10 AM
 
First, you haven't said what environment you're using (Carbon or Cocoa.) Second, things like changing the size of a window are incredibly basic -- I don't mean to sound insulting, but your question implies you probably haven't gone through any coding tutorials or read through the online documentation or the actual header files. Asking other developers for help is no substitute for (and is much slower than) digging into the documentation yourself. In the case of Cocoa the online class documentation for AppKit and Foundation is excellent.
As for changing window contents, in Cocoa the typical way to do this is put each separate set of items inside a parent NSView (often each in their own .nib file), then have an empty NSView in the main window that you can selectively add one or the other of the subviews to. The refcounting (if you use ObjC) is a little tricky -- removing a view from its superview releases it, so you need to make sure you've retained it first otherwise it will probably be disposed.
     
Dalgo  (op)
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Jan 22, 2001, 06:01 AM
 
Thanks. I am using Cocoa. I just never thought to look in NSView for anything dealing with changing what's in a window. I had suspected that I needed to use something like NSNibController but everything there just says "Description Forthcoming". I'll start looking at how to deal with subviews in NSView.
     
Fresh-Faced Recruit
Join Date: Jan 2001
Location: San Jose, CA USA
Status: Offline
Reply With Quote
Jan 23, 2001, 11:23 PM
 
I also happened to notice today that NSWindow has some methods for automatically animating window size changes -- apparently you just tell it the new size and it will smoothly animate to that size. Cool.
     
Dalgo  (op)
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Jan 27, 2001, 10:16 AM
 
So... How do you animate it? I didn't see any methods anywhere to do so. I thought that I'd animate it with repeated calls to setFrame but it'd be nicer if I didn't have to write that.
     
Fresh-Faced Recruit
Join Date: Jan 2001
Location: San Jose, CA USA
Status: Offline
Reply With Quote
Jan 27, 2001, 12:10 PM
 
The NSWindow method is

- (void)setFrameNSRect)frameRect displayBOOL)displayFlag animateBOOL)animateFlag

See the comment above the declaration for details.
But it might have been added after PB.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:16 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2