 |
 |
Dynamically changing the interface
|
 |
|
 |
|
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status:
Offline
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status:
Offline
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status:
Offline
|
|
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
|
|
The NSWindow method is
- (void)setFrame  NSRect)frameRect display  BOOL)displayFlag animate  BOOL)animateFlag
See the comment above the declaration for details.
But it might have been added after PB.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|