On Saturday, December 7, 2002, at 06:28 PM, Trey Harris wrote:

Yep, exactly, and thanks.  But as for following the HIG, what is the
recommendation?  I've not had time to read them fully.  I know that many
of Apple's own apps resize themselves when a new element comes into or
goes out of view (for instance, when customizing toolbars or switching
panels is System Preferences)--is this the suggestion?
I suppose that toolbars are a special case. Preference Panes are basically just a tab view without the tabs - you can set that up in IB, and call selectTabViewItemAtIndex() to switch panes manually. There are also select(First|Last|Next|Previous)TabViewItem() methods, that are useful for wizard-like dialogs.

So, my status bar
should not exist until something needs to be displayed to it, and at that
point, the window should lengthen to accomodate the NSTextField?
Apple's guidelines mostly relate to widgets the user can interact with; their concern is that, if the interface changes, widgets become "moving targets," and it becomes more difficult for the user. They have a point, but I think they've driven it a bit too hard - there are many cases, like your own need for a status display, where hiding a control when it's not in use is perfectly valid, and not at all confusing for the user.

Apple breaks their own guidelines, too, and for a need very similar to yours - in Mail.app's status bar, to the far right, there's an indeterminate progress indicator that's only visible when a network operation is in progress. According to their guidelines, it should be visible all the time, but only spinning when needed.

And while I'm on the subject, how do you make dynamic interfaces like
these, where elements of the interface move around and windows change size
in response to user behavior? You can't do it directly in IB, so do you
eschew IB entirely and go back to non-visual interface building, or is
there some compromise?
It's a bit hack-ish, I think.

The compromise is, removing a view from its parent view doesn't unload it. So, as long as you keep a reference to it, and don't explicitly release it, you can add it back to its parent view later on. Take a look through the "Managing the view hierarchy" section in the NSView docs - there are quite a few methods there for handling this sort of stuff.

You can do a lot of the preliminary work in IB. Create the views that you'll want to manage this way in a window that's been set to not be displayed immediately, and never display that window directly. Instead, remove the views you want to work with from the hidden window, and add them to the appropriate superview in the visible window.

There are methods in NSWindow for resizing windows and moving them around. Many of these methods use NSRect structures - these, and their related functions, are supported in Perl, but support is not quite complete. You can easily create them, pass them as parameters, and get them back from methods and functions, but accessing individual elements in NSRect's and other structures is a bit klunky. The entire structure is stored in a single scalar, so you need to use Perl's unpack() function to get at individual elements within it. The scalars are blessed; a future version of CamelBones will provide accessor methods to get at the internal elements.

Apple's "To Do" example in "Learning Cocoa" (1st ed. - I haven't bought the new one) shows how to build an Info panel this way. It's in Objective-C, though, and personally I wouldn't use this method for an Info panel. I'd use a tabbed view with the tabs disabled, so switching panes would be a single method call. I suppose the example was to illustrate how to work with view hierarchies, though, not necessarily to show the simplest way to make an Info panel.

sherm--

If you listen to a UNIX shell, can you hear the C?



Reply via email to