Appearance Extension
Volume Number: 13
Issue Number: 5
Column Tag: develop
Appearance: Not Just Another Pretty Interface
by Edward Voas
The Macintosh was once the model of consistency: every application behaved and looked
the same, making the user feel at home. But that consistency faded as, due to lack of
support from the Macintosh Toolbox, developers created custom controls, menus, and
windows, moving forward (or sideways) with user interface innovations while the
MacOS lagged behind. Now the Appearance extension takes the first step toward
regaining that consistent look and feel we all remember so fondly, paving the way for
switchable interface themes and making it easier to develop applications for the
MacOS.
You've got this great idea for a user interface, but it means you have to write a slider
CDEF. So you plug away, working to replicate what you've seen in dozens of
applications, while dreaming of sliders that are available as part of the system. Well,
your dream has come true. Meet Appearance, the biggest advancement of the Macintosh
user experience since System 7. The Appearance extension provides sliders plus a lot
more:
• Appearance implements a new look - Apple Grayscale - which was
originally slated to be the default look of Copland, the former MacOS 8 plan.
Under Appearance the standard system windows, controls, and menus all have
the Apple Grayscale look.
• Appearance adds new controls such as progress bars, tabs, disclosure
triangles, and sliders to the standard set, eliminating the need for developers
to roll their own.
• Appearance extends the Window, Control, Dialog, and Menu Managers to
provide functionality that's necessary for some of the new features to work
correctly. Some of the new functionality fills in the gaps that developers have
had to fill in on their own because the Macintosh Toolbox didn't support some
necessary or desirable features. For example, the system MDEF now supports
extended keyboard modifiers for menu item keyboard equivalents.
With Appearance you benefit the most by using as many of the system-supplied user
interface elements as possible. Your user interface won't have a patchwork look - with
the system elements, all pieces of the UI blend together nicely. Plus, as Apple enhances
the UI elements, your applications can immediately (and automatically) benefit as new
system versions are released. This becomes particularly important as we move toward
switchable themes (explained below). Another major benefit is that your applications
can be smaller, because you don't need to implement UI elements that are now supplied
by the Toolbox. A sample application that demonstrates Appearance can be found at
http://www.mactech.com.
Apple intends to supply an Appearance extention to be bundled with applications for
users to install on MacOS 7.6 or earlier (later systems will contain the functionality
of the SDK as part of the base system). Your application can determine whether
Appearance is running by checking a Gestalt selector (gestaltAppearanceAttr). This
selector returns a bitfield indicating which features of Appearance are in effect.
The On-Ramp to Themes
You may have heard about themes at Apple's Worldwide Developers Conference
(WWDC) or read about them in discussions on Copland. Essentially, a theme is an
interface look that spans all elements of the user interface and ties them together with
a certain graphic design. Themes are data driven - all the data that describes the theme
interface is contained in a theme file. The data-driven aspect makes it easy to switch
themes on the fly. Figure 1 gives examples of three themes that were shown at the
1996 WWDC and elsewhere: Apple Grayscale, Gizmo, and High Tech.
Figure 1. Three themes under Appearance.
Now before you get too excited, please note that the theme-switching mechanism isn't
implemented in the first version of Appearance; however, switchable themes are very
much a part of the future of the MacOS. Appearance is the first step toward that future,
and using the system controls, windows, menus, and other features provided by
Appearance will allow your application to handle theme switches automatically when
the time comes. I'll be referring to themes throughout this article, especially when
talking about the Appearance Manager, which lets you get colors and patterns for the
current theme.
What's New and Improved
Appearance redesigns some old controls and provides many new ones. Windows sport a
new look and added features, and there's a new help icon. Here we'll check out these
snazzy Apple Grayscale UI elements and learn a bit about the new features. Then we'll
look at the Appearance Settings control panel, which lets the user control theme
variations and the system font, among other things. In later sections, we'll describe
how the new features work and what you need to do to adapt your applications for
Appearance.
New Controls
Many new controls are added to the system with Appearance.
Bevel button control
The bevel button control implements a rectangular button with a beveled edge.
Typically, a bevel button displays an icon, but it can display an icon, a picture, or
text, singly or in combination. You can also attach a menu to this control. Multiple
bevel thicknesses and several different button behaviors are supported, to suit just
about any use. This versatility makes bevel buttons well suited for use in toolbars or
tool palettes. (These buttons should never be used to replace push buttons, however.)
The sample application accompanying this article shows many different variations of
bevel buttons; you'll be astounded by the possibilities.
List box control
The list box control implements a simple list box. It requires an auxiliary resource of
type 'ldes' to specify the features of the list, such as the number of columns and rows.
(The Appearance Settings control panel, shown later, provides an example of columns
in a list box.) This control allows filtering of keyboard events, and handles the default
keyboard navigation you'd expect from a list box.
Note that if you use the list box control in a dialog, it won't respond to keyboard events
- you can't tab into it, for example - unless the dialog has established an embedding
hierarchy (described later). There's a similar restriction on the clock and editable
text controls.
Clock control
The clock control provides an editable date or time field, as you'd find in the Date &
Time control panel. The little arrows next to the clock are part of the clock control.
(Remember, you won't be able to tab or type characters into the clock control unless
the dialog has established an embedding hierarchy.) You can also specify a noneditable
version that simply shows the date or time. The noneditable clock permits live
updating, so you can put a clock in your interface and let it tick away. The clock control
uses the date and time formats set in the Date & Time control panel.
Slider control
Sliders are finally part of the MacOS repertoire. You can choose which way the
indicator faces or use a non-directional indicator. You can also specify whether to
draw tick marks. The slider supports live feedback (described later).
Image well control
This control holds an icon or picture. In Apple Grayscale, image wells look like an
editable text box with a picture inside instead of text. Image wells have a normal and
selected state, as shown above. A good use for an image well is as a drop target for
images or document icons. Drag and drop support isn't built into this version of
Appearance.
Little arrows control
The little arrows control implements the little up and down arrows you often see tied
to a box displaying a value. The arrows are used to increase or decrease the value. In
the Memory control panel, for example, you click them to set the cache size or virtual
memory partition size.
Progress bar control
Progress bars are now part of the standard control set. You can tell a progress bar to
switch into indeterminate mode, in which it displays an animated barber pole-like
bar; you might use this mode to indicate that you haven't made a connection yet or are
waiting for some piece of data before continuing. Because the indeterminate flag is
separate from the value, you can switch back and forth without affecting the value.
Chasing arrows control
These are the spinning arrows that usually indicate an asynchronous process. In other
words, there's something going on in the background but you can continue to work.
You've no doubt seen them in Find File when searching for files.
Tab control
Currently, the new tab control supports only one row of tabs running along the top of
the control. Future versions will support more variants. As with the list box, you use
an auxiliary resource to specify the tab names and any icons that appear beside the
names.
You should try to restrict your use of tabs to those times when they're really
necessary. Too many tabs can result in a very complex and confusing UI. Also, tabs can
be difficult to localize for different script systems: the width of a text string can
increase up to 50%, causing problems if you've set up the tabs to fit perfectly in a
Roman script system.