05.01.2013 Views

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

460<br />

CHAPTER 25 MAC <strong>OS</strong> X DEVELOPMENT: THE TOOLS<br />

The Inspector<br />

Like any inspector panel, Interface Builder’s Inspector allows you to see and change the attributes<br />

of your interface items. The Inspector is open by default, but you can always call it forth by<br />

selecting Inspector from the Tools menu, or by typing Shift+Cmd+I. To inspect an item, simply<br />

click it, and the Inspector’s contents will change as appropriate. The Inspector’s attributes are<br />

divided into several tabs.<br />

Attributes<br />

As interface objects are reusable, they have several configuration options. Although interface<br />

objects can be instantiated and configured in code, it’s easier to set up as many attributes as possible<br />

in Interface Builder itself. This keeps the attributes with the objects they affect, and presents<br />

them in a visual way that often makes their effects easier to understand.<br />

The Attributes tab is divided into subsections based on the object’s inheritance. Our text<br />

field has several attributes, chief among them is its title, which is the text it displays. Editing the<br />

title will change the text just as you did by double-clicking and editing it in place. You can also<br />

set text attributes such as alignment, color, and whether to use rich text, which allows things like<br />

bold or italic formatting.<br />

You can also set attributes on the text field itself, such as its border, whether it should draw<br />

a background, and if so, what color it should be.<br />

Since your text field, as an instance of the class NSTextField, is a subclass of NSControl, the<br />

next subsection allows you to edit the attributes of a control. These include the text’s direction,<br />

how it handles line breaks, and whether it is enabled or grayed out.<br />

As NSControl is in turn a subclass of NSView, you can then edit view attributes like how it<br />

draws a focus ring to indicate it’s the currently selected item, or whether it’s visible at all.<br />

Effects<br />

As discussed in Chapter 24, many Core Animation effects are available from within Interface<br />

Builder. These are settable from the myriad subsections of the Effects tab. Since your text field is<br />

a view subclass, you can take advantage of Core Animation.<br />

When a view uses Core Animation, we say it is layer-backed. Once a view is layer-backed,<br />

all of its subviews are also layer-backed. You can see the view hierarchy and decide at which level<br />

to activate layer-backing from the Rendering Tree subsection.<br />

NOTE Core Animation was originally called Layer Kit, because it uses a lightweight layerbased<br />

model. For whatever reason, <strong>Leopard</strong>’s architects decided to emphasize the framework’s<br />

easy animation over its nifty rendering model. Regardless of this change, we still refer to<br />

layers and call views that can use Core Animation “layer-backed.”<br />

Once your view is layer-backed, you can change its transparency and set a custom shadow<br />

from the Appearance tab. You can add Core Image filters from the Content Filters, Background<br />

Filters, and Compositing Filters subsections. Finally, you can affect the style of animation by setting<br />

custom transitions in the Transitions subsection.<br />

Feel free to play with the various Core Animation and Core Image effects later if you like,<br />

but since none of this affects resizing (the task at hand), let’s move on.<br />

Size<br />

The Size tab would be more properly called Geometry, as it affects more than just size. Nevertheless,<br />

this is where you need to go to set the resizing attributes of your text field. Much like the<br />

Attributes tab, you’ll notice subsections based on inheritance. There are no special text field size<br />

attributes, so the first subsection comes from being a control subclass.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!